MiceOnABeam Product Documentation

Modified: 10/27/2011 7:33 PM
Recently changed articles You can subscribe to this wiki article using an RSS feed reader.

Shallow History

Summary

A transition to a Shallow History Point from within a Composite State, will transition to and invoke the Default Entry on the last active substate of the Composite State.

Graphic

A Shallow History Point is represented by the following graphic:

One or more incoming transitions may be connected to a Shallow History Point. It may also have a single Default History Transition represented as follows. The Default History Transition is always unlabeled.

Description

Each Composite State keeps track of the last active substate within it's decomposition, which is called it's Last State. The Last State of a Composite State that has never been entered is undefined.

When a transition is made to a Shallow History Point the Last State of the Composite State is checked and if it is defined, a transition is made to the substate referred to by the Last State. If this substate is a Composite State, then it's Default Entry is followed.

When a transition is made to a Shallow History Point and the Last State of the Composite State is not defined, or the Last State is a Final State, then the Default History Transition is followed if it has been specified for the Shallow History Point. If in this case a Default History Transition has not been specified, then the Default Entry is invoked for the enclosing Composite State.

In summary, there are several possible outcomes when a transition is made to the Shallow History Point.

  1. Last State is Defined: A transition is made to the substate referred to by the Last State. If this substate is a Composite State, then it's Default Entry is followed.
     
  2. Last State is Not Defined: The Default History Transition is followed if it has been specified for the Shallow History Point.
     
  3. Last State is a Final State: The Default History Transition is followed if it has been specified for the Shallow History Point.
     
  4. Default History Transition Not Specified: If in any of the above scenarios the Default History Transition is indicated to be taken, but has not been specified for the Shallow History Point, then the Default Entry is invoked for the enclosing Composite State.

Usage

A common usage for the Shallow and Deep History Points, is to provide a sort of interrupt-like mechanism for the script. Typically this is done in conjunction with a Group Transition, which serves to define an event that will be responded to regardless as to which substate is currently active within the Composite State.  The Group Transition would have a Transition Action which would specify this common behavior.

The Group Transition can then be connected to a Shallow History Point which will then return the script to it's last active substate, and follow it's Default Entry.

In the following scenario, we have a model for a simple display-type object or Kiosk. It starts off in an idle state, and becomes active when it receives a special link_message event. At this point the model transitions to the Kiosk_On state, performs the Default Entry, and transitions inside the Kiosk_On state to the Waiting state. Whenever a touch_start event is received it will display certain certain information to the user for a period of time, and then return to the Waiting state upon receiving a timer event.

The Reset transition originating from the top level of the state machine operates as a Group Transition which responds to a collision event. (While a transition label defaults to it's event name, it can be renamed by the user.) This means that if during any substate of the state machine, a Reset event occurs, all currently active substates will exit in turn, (executing their Exit Actions if they exist), and the transition action associated with the Reset will be executed.

The Reset transition connects to a Shallow History Point and so the next step is to return the script to the last active substate. If the script was in the state Kiosk_Idle then it returns to that state. If it was in one of the substates of the Composite State Kiosk_On, then the script returns to Kiosk_On, but executes it's Default Entry and so takes the Initial Transition within it's decomposition to the Waiting state. (Contrast this with the example shown in Deep History, where the return would be to the last active substate of Kiosk_On.)

Top State

Kiosk_On Decomposition



Notes

  • Only one Shallow History Point may be defined within the decomposition of a Composite State.
  • In practical terms the Shallow History Point is far less useful than the Deep History Point, as the former causes a return to the last active substate, and then re-initializes it by invoking its Default Entry. Deep History on the other hand causes a return to the last active substate and continues to invoke Deep History for that substate and so on, thereby providing a return to the actual state history prior to the "interrupt".
  • Note that a return to Shallow History will execute the last active state's Entry Action. A return to Deep History will execute the Entry Action's of all states within the nested hierarchy of active states that exist within the substate, until a Simple State is reached.
  • The Default History Transition's name ("defaultHistory") and event (%%defaulthistory_event) are fixed.

 

Tags:
Home: MiceOnABeam Product Documentation Copyright © 2010-2018 MiceOnABeam Software