sml
sml copied to clipboard
Exlicit Entry example needed
I am unsure about the "Explicit Entry" syntax. I tried several variations but none of them seems to make any practical difference.
Code below presents one of these variations:
#include <boost/sml.hpp>
#include
namespace sml = boost::sml;
struct e1 {};
struct sub
{
static constexpr auto ss1 = sml::state
auto operator()()
{
using namespace sml;
return make_transition_table(
*ss1 + on_entry<_> / [] { std::cout << "sub<ss1>::on_entry" << std::endl; }
,ss2 + on_entry<_> / [] { std::cout << "sub<ss2>::on_entry" << std::endl; }
);
}
};
struct parent
{
static constexpr auto ps1 = sml::state
auto operator()()
{
using namespace sml;
return make_transition_table(
*ps1 + on_entry<_> / [] { std::cout << "parent<ps1>::on_entry" << std::endl; }
,ps1 + event<e1> / [] { std::cout << "parent<ps1>::event<e1>" << std::endl; } = sub::ss2
,ps2 + on_entry<_> / [] { std::cout << "parent<ps2>::on_entry" << std::endl; }
);
}
};
int main()
{
sml::sm
Outcome is something like:
parent
::on_entry parent ::event Final state is sub::ss1.
My expectation would have been this instead:
parent
::on_entry parent ::event parent ::on_entry sub ::on_entry Final state is sub::ss2.
Last, a question about the syntax in the example for representing states. My understanding is that:
- SML Actions/Guards are stateless
- SML FSM itself is stateful But what about the state classes that are defined for the FSM itself? Are stateless or stateful? Meaning, would a "static" definition work for multiple FSM instantiations?
Explicit entry is not supported by SML.
Therefore I would say this is not a non-issue and can be closed.
@davidfrulm have a look at https://github.com/erikzenker/hsm it supports explicit entry action. An example can be found here https://github.com/erikzenker/hsm/blob/master/test/integration/entry_exit_pseudo_states.cpp#L63
Explicit entry is not supported by SML.
Therefore I would say this is not a non-issue and can be closed.
Explicit entry/exit is SUPPORTED by SML.
Watch the presentation https://boost-ext.github.io/sml/embo-2018/#/5/4
I am plus the author of the topic.
A good example is needed.
Is it? I can't find it in the presentation you linked.
Is it? I can't find it in the presentation you linked.
Slide 6.5
Oh I see - thanks. But are the slides correct? Have you ever seen code that implements it?
I'm very surprised by this claim because that's a feature I've been missing for a long time. So far I've always been using workarounds to achieve direct entry/exit behaviour. E.g. see this discussion here: https://github.com/boost-ext/sml/issues/185#issuecomment-473380556
Maybe @krzysztof-jusiak can clarify.