
Hi Franz
I've tried to use the Statechart library for modelling a simple state machine. I've created three states and three transitions between them and added some debug outputs. When I've looked to the debug outputs I've wondered a little bit. I've thought that the processing of events are in the order 1) exit actions of source state 2) transition actions and 3) entry actions of target state. When I look at my result I see the order 1) transition action 2) exit action of source state and 3) entry action of target state.
I assume you are referring to the following sequence in the output:
trigger event 'Event2' process event 'Event2' process guard 'guard1' process action 'action3' leave state 'StateB' enter state 'StateC'
Does anybody know what I'm doing wrong here?
Yes, it seems you are confusing the react member function of a state with a transition function. I'm referring to the following code fragment:
sc::result StateB::react(const Event2 & e) { if (context<FSMSimple>().guard1()) { context<FSMSimple>().action3(e);
This is a direct call to action3 ...
return transit<StateC>();
... and this is where the transition actually takes place. In order to let the transition action execute at the right time, you should replace the code:
context<FSMSimple>().action3(e); return transit<StateC>();
with // untested code return transit<StateC>(&FSMSimple::action3, e); Please see: http://www.boost.org/doc/libs/1_37_0/libs/statechart/doc/tutorial.html#Trans... Please let me know whether that works for you. Thanks & Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.