Out-of-office display, GFX
 All Classes Files Functions Variables Enumerations Enumerator Groups
Public Attributes | List of all members
transition Struct Reference

Transition between a state and another state. More...

#include <stateMachine.h>

Public Attributes

int eventType
 The event that will trigger this transition.
void * condition
 Condition that event must fulfil.
bool(* guard )(void *condition, struct event *event)
 Check if data passed with event fulfils a condition.
void(* action )(struct event *event)
 Function containing tasks to be performed during the transition.
struct statenextState
 The next state.

Detailed Description

Transition between a state and another state.

All states that are not final must have at least one transition. Transitions are triggered by events. If a state has more than one transition with the same type of event (and the same condition), the first transition in the array will be run. A transition may optionally run a function action, which will have the triggering event passed to it as an argument.

It is perfectly valid for a transition to return to the state it belongs to. Such a transition will not call the state's state::entryAction or state::exitAction.

Examples

See Also
event
state
Examples:
stateMachineExample.c.

Member Data Documentation

void( * transition::action)(struct event *event)

Function containing tasks to be performed during the transition.

The transition may optionally do some work in this function before entering the next state. May be NULL.

Parameters
eventthe event passed to the state machine.
void* transition::condition

Condition that event must fulfil.

This variable will be passed to guard (if guard is non-NULL) and may be used as a condition that the incoming event's data must fulfil in order for the transition to be performed. By using this variable, the number of guard functions can be minimized by making them more general.

bool( * transition::guard)(void *condition, struct event *event)

Check if data passed with event fulfils a condition.

A transition may be conditional. If so, this function, if non-NULL, will be called. Its first argument will be supplied with condition, which can be compared againts event. The user may choose to use this argument or not. Only if the result is true, the transition will take place.

Parameters
conditionevent (data) to compare the incoming event against.
eventthe event passed to the state machine.
Return values
trueif the event's data fulfils the condition, otherwise false.
struct state* transition::nextState

The next state.

This must point to the next state that will be entered. It cannot be NULL, but if it is, the state machine will detect it and enter the error state.


The documentation for this struct was generated from the following file: