sE searched 

Keep Bail Out!








                     C O N S U L T A N T S


   On 'events', intervention-efforts and transition:  

What Is A State Machine?

State machines have been around in computer science for a long time. You'll find they are especially popular in reactive systems, like the software for video games and robotics. Designers use state machines to model a system using states, events, and transitions.

A state represents a situation or circumstance. In the diagram below, we have a state machine with two states: a "power on" state and a "power off" state. The machine will always be in one of these two states.

A simple state machine

An event is some outside stimulus. In figure 1, we only have one type of event - a button click event. The state machine will respond to this event in either the "power on" or the "power off" state. Not all states have to respond to the same events.

A transition moves the state machine into a new state. A transition can only occur in response to an event. Transitions don't have to move the state machine to a new state - a transition could loop back to the same state. When the machine receives a button click event in the "power off" state, it transitions to the "power on" state. Conversely, if the machine is in the "power on" state and receives a button click event, it moves to the power off state.

Implied in the concept of a state transition is that some action will take place before or after the transition. A state machine doesn’t merely store state - it also executes code when events arrive. In our diagram the state machine would be controlling the flow of electricity by opening or closing a circuit when it arrives in a new state.  






Page mailing to a friend temporary disabled