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.

Deep History

Summary

A transition to a Deep History Point from within a Composite State, will transition to and invoke Deep History on the last active substate of the Composite State, and will continue to invoke Deep History for that substate and so on, until a Simple State is reached.

Graphic

A Deep History Point is represented by the following graphic:

One or more incoming transitions may be connected to a Deep History Point. It may also have a 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 Deep 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 Deep History will again be invoked on it, and this will continue with each nested active composite substate, until a Simple State (Leaf State) is reached.

When a transition is made to a Deep 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 Deep 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 a Deep 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 Deep History is recursively invoked on it's decomposition, transitioning to it's last active state and so on, until a Simple State is reached within the nested active state hierarchy of the Composite State.
     
  2. Last State is Not Defined: The Default History Transition is followed if it has been specified for the Deep History Point.
     
  3. Last State is a Final State: The Default History Transition is followed if it has been specified for the Deep 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 Deep History Point, then the Default Entry is invoked for the enclosing Composite State.

Usage

A common usage for 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 Deep History Point, which will then return the Composite State to it's last active substate, and will continue to invoke Deep History for that substate and so on, until a Simple State is reached.

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 Stats transition originating from the top level of the state operates as a Group Transition which responds to a particular chat message via a listen event which asks the Kiosk to report various statistics it has gathered. (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, a Stats event occurs, all currently active substates will exit in turn, (executing their Exit Actions if they exist), and the transition action associated with Stats will be executed.

The Stats transition connects to a Deep 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, and continues to transition to it's last active state, one of Waiting or Display_Info.  (Contrast this with the example shown in Shallow History, where the return would be to Kiosk_On's Default Entry, and so takes the Initial Transition within it's decomposition to the Waiting state.)

Top State

Kiosk_On Decomposition

Notes

  • Only one Deep 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 reinitializes 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 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