Finite State Machines

Finite State Machines

Description

Definition from Wikipedia:

A finite-state machine (FSM) or finite-state automaton (plural: automata), or simply a state machine, is a mathematical model used to design computer programs and digital logic circuits. It is conceived as an abstract machine that can be in one of a finite number of states. The machine is in only one state at a time; the state it is in at any given time is called the current state. It can change from one state to another when initiated by a triggering event or condition, this is called a transition. A particular FSM is defined by a list of the possible states it can transition to from each state, and the triggering condition for each transition.

In ROOM each actor class can implement its behavior using a state machine. Events occurring at the end ports of an actor will be forwarded to and processed by the state machine. Events possibly trigger state transitions.

Motivation

For event driven systems a finite state machine is ideal for processing the stream of events. Typically during processing new events are produced which are sent to peer actors.

We distinguish flat and hierarchical state machines.

Notation

Flat Finite State Machine

The simpler flat finite state machines are composed of the following elements:

Description Graphical Notation Textual Notation
State
InitialPoint
implicit
TransitionPoint
ChoicePoint
Initial Transition
Triggered Transition

Hierarchical Finite State Machine

The hierarchical finite state machine adds the notion of a sub state machine nested in a state. A few modeling elements are added to the set listed above:

Description Graphical Notation Textual Notation
State with sub state machine Parent State
Sub state machine
Entry Point In sub state machine
On parent state
Exit Point In sub state machine
On parent state

Examples

Example of a flat finite state machine:

Example of a hierarchical finite state machine:

Top level

Sub state machine of Initializing

Sub state machine of Running