The UserFiniteStateMachine.h file, contains the application for the finite state machine.
The general declaration for a state is:
(this is an example of the "START" state)



Finite state "START" is the only required state and must be present. Phase actions and transisition depend on your control application. When no extra functionallity is added to the START state (no "control" specific code), the FSM will only run the START state, all functions, e.g. the serial monitor, HMI (debugger), plotter and access database are already available.


Endless loop:

  • the "START" state is the first active state after a restart of the board.
  • only the code of active states is executed in the FSM loop, the FSM loop is repeated endlessly.
  • all code in an active state  if (MachineState == "<statename>") {<codeblock>}  is executed, until a call to TransitionToState ("<statename>") is made.
  • a transition to another state will put the current state to inactive.
  • a transition to the "END" state will kill/end the current state.
  • a transition to another state, leaves the current state inactive by default. When also the current state must stay active; make also a TransitionToState to the current state.


Enter and exit:

  • when entering or leaving a certain state, you can add specific functionallity in the EnterState() {<codeblock>} and ExitState() {<codeblock>}; this code is executed just one time in this state depending on entering or leaving.


Adding states:

  • with the Configurator you can add (or delete) extra states to the control. When added, the configurator is adding a state code block to the UserFiniteStateMachine.h file. It is not necassery to add this by hand (and introduce faulty code).


When you have added the new state, program the phase actions and the conditions for a transit to another state. Check the example, it is self documenting!

Click here for an example.