Configuration functions


Functions

void makeDefault1 (State *state)
 Make the given state become the default state for its parent.
unsigned char makeHistoryStateDefault (State *state, State *initialChild)
 Make the given state uses its history state as the default target for transition and initialize the history state with the given state.
void setEntryWork (State *state, void(*onEnter)(void))
 Make the given state executing the given funtion when entered.
void setExitWork (State *state, void(*onExit)(void))
 Make the given state executing the given funtion when exited.
void allocateSpaceForStates (void *ptr, unsigned short int nbStates)
 Allow you to allocate manually space for the child states.
void allocateSpaceForTransitions (State *state, unsigned short int nbTransition)
 Allow you to allocate manually space for new transitions.
unsigned char addTransition (State *from, void *to, short int eventNum, unsigned char useHistory)
 This create a transition between the source and the target state.

Function Documentation

unsigned char addTransition ( State from,
void *  to,
short int  eventNum,
unsigned char  useHistory 
)

This create a transition between the source and the target state.

Parameters:
from The source state.
to The target of the transition, should be a State or an history state.
eventNum The event number that will trigger the transition.
useHistory Tell the system to target the history state of the 'to' state instead of the 'to' state itself.
Returns:
0 is returned if the funtion fail and 1 is returned if the function secced.
Once created, if the state machine is on the source state or one of its substates, when the indicated event is passed to the state machine, a transition will be triggered to the target state.
Warning:
If you give a 'to' pointer pointing on something else than a state or a parallel state, you might have some surprises !!

void allocateSpaceForStates ( void *  ptr,
unsigned short int  nbStates 
)

Allow you to allocate manually space for the child states.

Parameters:
ptr A pointer on a state or a stateMachine to work on.
nbStates The new number of states to prepare the space for.
This doesn't allocate any new state but prepare a structure to get childs states. If this is not done manually the system will manage it automatically. If the given number of states appear not to be enought, the system will re-allocate the buffer when needed. If the given number match the real number of states that will be added later, this increase the system performances by avoiding many recursives reallocations.
Warning:
The compiler option 'DEACTIVATE_CHECKING' deactivate any automatic allocation so that you need to do this by hand using this function.
See also:
void allocateSpaceForTransitions(State* state, int nbTransition)

void allocateSpaceForTransitions ( State state,
unsigned short int  nbTransition 
)

Allow you to allocate manually space for new transitions.

Parameters:
state A pointer on the state machine to work on.
nbTransition The new number of transitions to prepare the space for.
This doesn't allocate any new transition but prepare a state to get attached transitions. If this is not done manually the system will manage it automatically. If the given number of transitions appear not to be enought, the system will re-allocate the buffer when needed. If the given number match the real number of transitions that will be added later, this increase the system performances by avoiding many recursives reallocations.
Warning:
The deprecated compiler option 'DEACTIVATE_CHECKING' deactivate any automatic allocation so that you need to do this by hand using this function.
See also:
void allocateSpaceForStates(void* ptr, unsigned short int nbStates)

void makeDefault1 ( State state  ) 

Make the given state become the default state for its parent.

Parameters:
state The state the should become the default state.
See also:
unsigned char makeHistoryStateDefault(State* state, State* initialChild)

unsigned char makeHistoryStateDefault ( State state,
State initialChild 
)

Make the given state uses its history state as the default target for transition and initialize the history state with the given state.

Parameters:
state The state that will use its history state as default target for transitions.
initialChild Used to initialize the historyState.
Returns:
Return 0 if the function fail or 1 if it succeed.
See also:
void makeDefault1(State* state)

void setEntryWork ( State state,
void(*)(void)  onEnter 
)

Make the given state executing the given funtion when entered.

Parameters:
state A pointer on a valid state.
onEnter A pointer on a funtion or a NULL pointer.
To remove a function that have been assigned to a state simply call this with NULL as second parameter.
See also:
void setExitWork(State* state, void (*onExit) (void))

void setExitWork ( State state,
void(*)(void)  onExit 
)

Make the given state executing the given funtion when exited.

Parameters:
state A pointer on a valid state.
onExit A pointer on a funtion or a NULL pointer.
To remove a function that have been assigned to a state simply call this with NULL as second parameter.
See also:
void setEntryWork(State* state, void (*onEnter) (void))


Generated on Sat Sep 18 15:39:57 2010 for Easy C State Machine by  doxygen 1.5.8