Statechart Notation

 

A statechart is simply a network of states and events.

 

Transitions

If event E occurs in state S and condition C holds then make the transition to state T.

Actions to be carried out when event E occurs in state S are normally put into an event-action table rather than part of the diagram.  The actions could be lengthy and detailed.

 

 

 


Hierarchical statecharts

FSM are flat.  They provide no facility to represent hierarchies.

Details sometimes can to be hidden to portray higher level abstraction.

  

Because the arrows go inside node S, events A and B indicate that there is more detail in state S.

 

 


Clustering

Clustering is another form of hierarchy.

  

The advantage is the reduction in the number of arrows.

Likely states P and Q are abstractly different from T.

 

Three modes of a digital watch

Digital Watch Statechart

 

 

 


Start and Stop States

Start states are the simple large dots.

Stop states are the encircled dots.

A nested statechart should have a start point indicated and a stop state if it's not obvious.

 


History mechanism

When entering a state that has a nested statechart, you may want to resume where you left off when you left the enclosing state.  The encircled H as the entry point as below means to start in the state within that was exited.

Each level can have its own history mechanism.  Each history variable would be initialized to the start state of the level.

The encircled H can have an asterisk attached to indicate that the history mechanism is to be used at all levels of the hierarchy.

 

 


Concurrency

Concurrency refers to the ability to manage more than one state simultaneously.

If a simple FSM is used, the number of states needed is the product of the number of states that can be represented in each group separately.

Example: Consider the 3 style types -- bold, italics and underline.  These styles can be used in any combination. Bold is on or off, italics is on or off, underline is on or off.  The total number of states is 2*2*2 = 8 and the number of transitions is nearly as bad.

Instead, keep each style type as a separate statechart (bold on or off), (italics on or off) and (underline on or off). Each statechart is a simple pair of states.

Example: Consider the 4 paragraph positions -- left, center, right and justified.  These types are mutually exclusive but the number of transition arcs is 10 (=4*5/2).

 

Example: Consider the 3 paragraph types -- normal, bulleted and numbered.  Again these three are mutually exclusive, but can be combined with the 4 positions.  We need 3 states and 6 arcs.  If we tried to combine paragraph positions and types, then we have 12 states in a FSM.  Further, combining with the 8 states of font types, then 96 states would be needed.

There are some clarifications of state entry, history and exit in this form of the hierarchy.

Watch Concurrency

 


Delays and Timeouts

Delays are indicated by including a notation of delayTime < in the state. E.g., 10 sec <

Delays cause the state to hold against any action or event to occur until the delaytime has expired.

Timeouts are indicate by a similar notation < timeoutAmt in the state, e.g, < 5 min and then have an extra event arc labeled "timeout" exiting the state. That is, time out is an event.

In the case of events (and conditions) being ambiguous (i.e., more than one transition could be taken), the arc may have a priority encoded in brackets, e.g. [value]

Arrays of Statecharts

Arrays of Statecharts