State diagram

From Free net encyclopedia

(Redirected from Statechart)

State diagrams are used to graphically represent finite state machines. State transition tables are another possible representation.

There are many forms of state diagrams that differ slightly and have a different semantics.

Contents

Directed graph

A classic form of a state diagram for a finite state machine is a directed graph where

In practice, vertices are normally represented by circles and, if needed, double circles are used for accept states.

Examples

DFA, NFA, GNFA, or Moore machine

S1 and S2 are states and S1 is an accept state. Each edge is labeled with the input.

Image:DFAexample.png

Mealy machine

S0, S1, and S2 are states. Each edge is labeled with "j / k" where j is the input and k is the output.

Image:Mealymachine jaredwf.png

Harel statechart

Harel statecharts (developed in 1987 by David Harel) are gaining some more widespread usage since a variant has become part of UML. The diagram type allows to model superstates, concurrent state diagrams and e.g. to model activities as part of a state.

Classic state diagrams are so called "or" diagrams, because the machine can only be in one state or the other. With Harel statecharts it is possible to model "and" machines, where a machine is in two or more states at the same time. This is due to the possibility of having superstates.

UML state diagram

Image:UML state diagram.png The Unified Modeling Language (UML) state diagram is essentially a state diagram with standardised notation that can describe a lot of things, from computer programs to business processes. The following tools can be used to make up a diagram:

  • Filled circle, denoting START. Not absolutely necessary to use
  • Hollow circle, denoting STOP. Not absolutely necessary to use
  • Rectangle, denoting state. Top of the rectangle contains a name of the state. Can contain a horizontal line in the middle, below which the activity is written that is done in that state
  • Arrow, denoting transition. An expression can be written on top of the line, enclosed in brackets( [] ) denoting that this expression must be true for the transition to take place
  • Thick horizontal line with either x>1 lines entering and 1 line leaving or 1 line entering and x>1 lines leaving. These denote join/fork, respectively.

Template:Sect-stub

Other extensions

An interesting extension is to allow arcs to flow from any number of states to any number of states. This only makes sense if the system is allowed to be in multiple states at once, which implies that an individual state only describes a condition or other partial aspect of the overall, global state. The resulting formalism is known as a Petri net.

Template:Sect-stub

References

ja:状態遷移図 pt:Diagrama de transição de estados ru:Диаграмма состояний (теория автоматов) sk:Stavový diagram UML