A statechart does not only contain the definition of behavior. It also includes structural properties like its declared variables and events. These define its public interface and this interface is represented by a type.
Lets take a look at the example statecharts to get an idea how the state machine types look like:
TrafficLight.sct defines the type
TrafficLight and the statechart
TwoWayTrafficControl. The types include all members defined in the statecharts declaration section. The variables which are of type
TrafficLight are references to instances of this type.
You should know the following facts about state machine types:
IStateMachine. This type defines additional life cycle operations which are implemented by each state machine.
<StatechartName>States. It defines an enumeration value for each state of the statechart.
If you know the state machine code which is generated from statecharts then you will discover that the definitions of the state machine types directly match the definitions of the generated code.
State machine types are always used as reference types. This implies that the state machine which defines a variable of a state machine type does not own the state machine instance. It will never be created by the state machine itself.
As a state machine type is a regular type you can use it like any other type. So you can assign state machine references to variables, use it as event payload, pass it as operation parameter, or use it as an operation’s return value.
Variables of state machine references can be reassigned. A valid value is
null is the default value
after initializing a state machine.