triggering process_event as an action in a transition table
I'm testing the example code:
using namespace sml;
return make_transition_table(
*"s1"_s + event<my_event> / process_event(other_event{}) = "s2"_s,
"s2"_s + event<other_event> = X
);
I am getting the error: error: 'process_event' was not declared in this scope
It works fine without the process_event:
using namespace sml;
return make_transition_table(
*"s1"_s + event<my_event> = "s2"_s,
"s2"_s + event<other_event> = X
);
Any Ideas?
Compiling with GCC 5.4.2 Building with PlatformIO for a teensy4.1
Hi @Trenton-Ruf
I think you meant to use process instead of process_event?
- https://github.com/boost-ext/sml/blob/master/example/defer_and_process.cpp
Alright! That works!
using namespace sml;
return make_transition_table(
*"s1"_s + event<my_event> / process(other_event{}) = "s2"_s,
"s2"_s + event<other_event> = X
);
Another question, can process be called within an action? I tried this:
// Action
const auto trigger = []{
sml::process(other_event{});
};
using namespace sml;
return make_transition_table(
*"s1"_s + event<my_event> / trigger,
"s2"_s + event<other_event> = X
);
It Compiles but does not process other_event.
Yeah, it's possible, you have to use process<events...> Something like
, state + event<e1> / [this](sml::back::process<e2, e3> processEvent) -> void {
processEvent(e2{});
processEvent(e3{});
}
That also requires to inject a process_even storage policy
sml::sm<c, sml::process_queue<std::queue>> sm{};
Full example
- https://github.com/boost-ext/sml/blob/master/test/ft/actions_process.cpp#L171
Sick, Thanks a ton!
How can we pass a processEvent to lambda and have it be executed outside the process loop (e.g. a timer event)?
I know it's possible to do that using the full action signature [&](auto&& /*event*/, auto&& sm, auto&& deps, auto&& subs) { but that requires me to capture 4 references, which leads to dynamic memory allocation (not possible in my embedded project).
thanks.