Skip to content

Latest commit

 

History

History
194 lines (158 loc) · 6.04 KB

state.md

File metadata and controls

194 lines (158 loc) · 6.04 KB
Contents Overview Examples Editor Forum

Video version

Holds the representation of a state.

state - atomic

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="StateAtomic"/>
</scxml>

Attribute 'id'

The identifier for this state.

Attribute 'initial'

The id of the default initial state (or states) for this state.

Example: 'State1' is specified as initial

state - initial 1

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="Work" initial="State1">
		<state id="State1">
			<onentry>
				<log expr="Hello!" label="State 1"/>
			</onentry>
			<transition event="Step" target="State2"/>
		</state>
		<state id="State2">
			<onentry>
				<log expr="Hello!" label="State 2"/>
			</onentry>
			<transition event="Step" target="State3"/>
		</state>
		<state id="State3">
			<onentry>
				<log expr="Hello!" label="State 3"/>
			</onentry>
			<transition event="Step" target="State1"/>
		</state>
	</state>
</scxml>

Output:

[Log] State 1: "Hello!"

Example: 'State3' is specified as initial

state - initial 2

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="Work" initial="State3">
		<state id="State1">
			<onentry>
				<log expr="Hello!" label="State 1"/>
			</onentry>
			<transition event="Step" target="State2"/>
		</state>
		<state id="State2">
			<onentry>
				<log expr="Hello!" label="State 2"/>
			</onentry>
			<transition event="Step" target="State3"/>
		</state>
		<state id="State3">
			<onentry>
				<log expr="Hello!" label="State 3"/>
			</onentry>
			<transition event="Step" target="State1"/>
		</state>
	</state>
</scxml>

Warning!

1. MUST NOT be specified in conjunction with the <initial> element. state - initial - warning 1

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="Work" initial="State1">
		<state id="State1">
			<onentry>
				<log expr="Hello!" label="State 1"/>
			</onentry>
			<transition event="Step" target="State2"/>
		</state>
		<state id="State2">
			<onentry>
				<log expr="Hello!" label="State 2"/>
			</onentry>
		</state>
		<initial>
			<transition target="State1"/>
		</initial>
	</state>
</scxml>

Output:

Issue (WARNING) at //state[@id="Work"]: State with initial attribute cannot have <initial> child

2. MUST NOT occur in atomic states.

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="StateAtomic" initial="StateXXX"/>
</scxml>

Output:

Issue (FATAL) at //state[@id="StateAtomic"]: Initial attribute has invalid target state with id 'StateXXX'

Atomic state

Has no <state>, <parallel> or <final> children.

state - atomic

Compound state

Has <state>, <parallel>, or <final> children (or a combination of these).

state - compaund - atomic

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="StateCompaund">
		<state id="StateAtomic"/>
	</state>
</scxml>

Default initial state

Specified by the 'initial' attribute or <initial> element, if either is present. Otherwise it is the state's first child state in document order.

Example 1

state - initial - default

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="Work" initial="State2">
		<state id="State1">
			<transition event="Step" target="State2"/>
		</state>
		<state id="State2">
			<onentry>
				<log expr="I am initial!" label="State 1"/>
			</onentry>
			<transition event="Step" target="State1"/>
		</state>
	</state>
</scxml>

Example 2

state - initial - default - document order

<scxml name="Scxml" version="1.0" xmlns="http://www.w3.org/2005/07/scxml">
	<state id="Work">
		<state id="State1">
			<onentry>
				<log expr="I am initial!" label="State 1"/>
			</onentry>
			<transition event="Step" target="State2"/>
		</state>
		<state id="State2">
			<transition event="Step" target="State1"/>
		</state>
	</state>
</scxml>

Definition: The default initial state(s) of a compound state are those specified by the 'initial' attribute or initial element, if either is present. Otherwise it is the state's first child state in document order. If a compound state is entered either as an initial state or as the target of a transition (i.e. and no descendent of it is specified), then the SCXML Processor MUST enter the default initial state(s) after it enters the parent state.

test364

TOP Contents Overview Examples Editor Forum