[statechart] Can inner states be defined for a state in orthogonal region?
I'm unable to compile the machine below that includes inner states within a state in an orthogonal region. The error is: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' {{{ struct SerialPort : public state_machine< SerialPort, StateTXWrapper > {} struct StateTXWrapper: simple_state< StateTXWrapper, SerialPort, mpl::list< StateTXNotReady, StateStart > > {}; // Orthogonal 0 struct StateMrf : simple_state< StateMrf, StateTXWrapper::orthogonal< 0 > > {}; struct StatePortClosed : simple_state< StatePortClosed, StateTXWrapper::orthogonal< 0 > > {}; struct StateOpenPort : simple_state< StateOpenPort, StatePortClosed > {}; struct StateOpenPortWait : simple_state< StateOpenPortWait, StatePortClosed > {}; }}} The assert is invoked for StateOpenPort and StateOpenPortWait: BOOST_STATIC_ASSERT( ( mpl::less< orthogonal_position, typename context_type::no_of_orthogonal_regions >::value ) ); Is it possible to have such inner states? Boost version 1.38 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Hi Gordon I don't have access to a compiler right now, but from looking at the source this seems easy to fix:
struct SerialPort : public state_machine< SerialPort, StateTXWrapper > {}
struct StateTXWrapper: simple_state< StateTXWrapper, SerialPort, mpl::list< StateTXNotReady, StateStart > > {};
The inner initial states StateTXNotReady and StateStart are missing, I guess you did not intend to post the complete code?
struct StateMrf : simple_state< StateMrf, StateTXWrapper::orthogonal< 0 > > {};
Fine so far.
struct StatePortClosed : simple_state< StatePortClosed, StateTXWrapper::orthogonal< 0 > > {};
struct StateOpenPort : simple_state< StateOpenPort, StatePortClosed > {};
struct StateOpenPortWait : simple_state< StateOpenPortWait, StatePortClosed > {};
The error lies in the declaration of the 3 states above. StateOpenPort & StateOpenPortWait claim to be inner states of StatePortClosed. However, since StatePortClosed does not define an inner initial state, it is assumed to be an innermost state, which is why the assertions do not hold. You can fix this e.g. as follows: struct StateOpenPort; struct StatePortClosed : simple_state< StatePortClosed, StateTXWrapper::orthogonal< 0 >, StateOpenPort > {}; HTH, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
participants (2)
-
Andreas Huber
-
Gordon Smith