Skip to content

Latest commit

 

History

History
157 lines (127 loc) · 6.55 KB

history.md

File metadata and controls

157 lines (127 loc) · 6.55 KB
Contents Overview Examples Editor Forum

Video version

Allows a state machine to remember its state configuration. A <transition> taking the <history> state as its target will return the state machine to this recorded configuration.

history_intro

1. Shallow history

If the 'type' of a <history> element is 'shallow', the SCXML processor must record the immediately active children of its parent before taking any transition that exits the parent.

<history type="shallow"/>

Example:

1.1. Configuration before pause

history - shallow - before pause

Active states: Airplane, Engines, Left, Right, LeftOn, RightOn

1.2. Configuration after pause

history - shallow pause

Active state: Expecting

1.3. Configuration after resume

history - shallow after pause

Active states: Airplane, Engines, Left, Right, LeftOff, RightOff

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="Airplane" initial="HistoryPoint">
		<transition event="Pause" target="Expecting"/>
		<parallel id="Engines">
			<transition event="NoFuel" target="Refuel"/>
			<state id="Left" initial="LeftOff">
				<state id="LeftOff">
					<transition event="Startup.Left" target="LeftOn"/>
				</state>
				<state id="LeftOn">
					<transition event="Shutdown.Left" target="LeftOff"/>
				</state>
			</state>
			<state id="Right" initial="RightOff">
				<state id="RightOff">
					<transition event="Startup.Right" target="RightOn"/>
				</state>
				<state id="RightOn">
					<transition event="Shutdown.Right" target="RightOff"/>
				</state>
			</state>
		</parallel>
		<initial>
			<transition target="HistoryPoint"/>
		</initial>
		<history id="HistoryPoint">
			<transition target="Refuel"/>
		</history>
		<state id="Refuel">
			<transition event="Finished" target="Engines"/>
		</state>
	</state>
	<state id="Expecting">
		<transition event="Resume" target="HistoryPoint"/>
	</state>
</scxml>

2. Deep history

If the 'type' of a <history> element is 'deep', the SCXML processor must record the active atomic descendants of the parent before taking any transition that exits the parent.

<history type="deep"/>

2.1. Configuration before pause

history - after deep pause

Active states: Airplane, Engines, Left, Right, LeftOn, RightOn

2.2. Configuration after pause

history - deep pause

Active state: Expecting

2.3. Configuration after resume

history - after deep pause

Active states: Airplane, Engines, Left, Right, LeftOn, RightOn

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="Airplane">
		<transition event="Pause" target="Expecting"/>
		<initial>
			<transition target="HistoryPoint"/>
		</initial>
		<history id="HistoryPoint" type="deep">
			<transition target="Refuel"/>
		</history>
		<parallel id="Engines">
			<transition event="NoFuel" target="Refuel"/>
			<state id="Left" initial="LeftOff">
				<state id="LeftOff">
					<transition event="Startup.Left" target="LeftOn"/>
				</state>
				<state id="LeftOn">
					<transition event="Shutdown.Left" target="LeftOff"/>
				</state>
			</state>
			<state id="Right" initial="RightOff">
				<state id="RightOff">
					<transition event="Startup.Right" target="RightOn"/>
				</state>
				<state id="RightOn">
					<transition event="Shutdown.Right" target="RightOff"/>
				</state>
			</state>
		</parallel>
		<state id="Refuel">
			<transition event="Finished" target="Engines"/>
		</state>
	</state>
	<state id="Expecting">
		<transition event="Resume" target="HistoryPoint"/>
	</state>
</scxml>

Before the parent state has been visited for the first time, if a transition is executed that takes the history state as its target, the SCXML processor MUST behave as if the transition had taken the default stored state configuration as its target.

test387

Before the parent state has been visited for the first time, if a transition is executed that takes the history state as its target, the SCXML processor MUST execute any executable content in the transition after the parent state's onentry content and any content in a possible initial transition.

test579

It follows from the semantics of history states that they never end up in the state configuration.

test580

After the parent state has been visited for the first time, if a transition is executed that takes the history state as its target, the SCXML processor MUST behave as if the transition had taken the stored state configuration as its target.

test388

TOP Contents Overview Examples Editor Forum