Final State Machine macros
[Macros]

Defines

#define FSM_MAXT   64
#define FSM_Switch(fsm)
#define FSM_Transient(state)
#define FSM_Steady(state)
#define FSM_EnterExit(state)
#define FSM_Enter(state)
#define FSM_Exit(state)
#define FSM_Goto(fsm, state)

Define Documentation

#define FSM_Enter ( state   ) 

Within an FSM_Switch() case branch, declares code to be executed on entering the given state.

No calls to FSM_Goto() are allowed within a state's Enter block.

See also:
FSM_Switch
#define FSM_EnterExit ( state   ) 

Create state for FSM_Enter and FSM_Exit.

Handling signed (transient) flag with shift value operation correctly.

See also:
FSM_Switch
#define FSM_Exit ( state   ) 

Within an FSM_Switch() case branch, declares code to be executed on exiting the given state.

See also:
FSM_Switch
#define FSM_Goto ( fsm,
state   ) 

To be used in state exit code, to transition to another state.

Uses stringize (#state), so it only works correctly if 'state' is the enum name itself and not some variable that contains the state code.

See also:
FSM_Switch
#define FSM_Steady ( state   ) 

Declares a steady state; to be used in enum which declares states.

See example in FSM_Transient.

See also:
FSM_Transient, FSM_Switch
#define FSM_Switch ( fsm   ) 

Implements a Finite State Machine.

FSM state is stored in an object of type cFSM.

There are two kinds of states: transient and steady. At each execution of the FSM_Switch() statement, the FSM transitions out of the current (steady) state, potentially undergoes a series of state changes to transient states, and arrives at another steady state.

The actual FSM is embedded in an FSM_Switch(), which has cases for entering and leaving each state:

 FSM_Switch(fsm)
 {
     case FSM_Exit(state1):
         //...
         break;
     case FSM_Enter(state1):
         //...
         break;
     case FSM_Exit(state2):
         //...
         break;
     case FSM_Enter(state2):
         //...
         break;
     //...
 }
 

States are declared in enums, using the FSM_Transient() and FSM_Steady() macros.

State transitions are done via calls to FSM_Goto(), which simply stores the new state in the cFSM object.

See also:
cFSM, FSM_Transient, FSM_Steady, FSM_Goto, FSM_Debug, FSM_Print
#define FSM_Transient ( state   ) 

Declares a transient state; to be used in enum which declares states.

Example:

 enum {
    INIT = 0,
    SLEEP = FSM_Steady(1),
    ACTIVE = FSM_Steady(2),
    SEND = FSM_Transient(1),
 };
 

The numbers in parens must be unique within the state type and they are used for constructing numeric IDs for the states.

See also:
FSM_Steady, FSM_Switch
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3