State Machines

A state is the key structural element used in developing the MiceOnABeam model for a script.

Generally speaking, the state of a software system is represented by the values of all it's currently active variables (as determined by it's previous history), together with the set of outside events that the system will respond to at a point in time.  States as visually represented in a MiceOnABeam model, can be used to replace the most significant of these variables, making the design intent clearer.

A state further represents a static or quiescent point in the script's program logic, at which point a new event may be processed and transition the script to a new state. Having different states within a model, allows for the handling of a particular event in different ways, depending on which state the script is in when the event is received.

The following model shows the state machine for a light switch, which transitions back and forth between two states when a button is pressed. The action associated with the same touch_start event is different (turn light on and turn light off respectively), depending on which state is currently active.