In Figure 7an example of a StateMachineis given using the Notation defined in OPC 10000-3. First, a new StateMachineTypeis defined, called "MyStateMachineType", inheriting from the base FiniteStateMachineType. It contains two States, "State1" and "State2" and a Transition"Transition1" between them. The Transitionpoints to a Method"MyMethod" as the Causeof the Transitionand an EventType"EventType1" as the Effectof the Transition.
Instances of "MyStateMachineType" can be created, for example "MyStateMachine". It has a Variable"CurrentState" representing the current State. The "MyStateMachine" Objectonly includes the Nodeswhich expose information specific to the instance.
The "MyStateMachineType" contains an Object"MySubMachine" of type "AnotherStateMachineType" representing a SubStateMachine. The "State1" references this Objectwith a HasSubStateMachine Reference, thus it is a SubStateMachineof "State1". Since "MySubMachine" is an Objectof type "AnotherStateMachineType" it has a Variablerepresenting the current State. Since it is used as an InstanceDeclaration, no value is assigned to this Variable.
An Objectof "MyStateMachineType", called "MyStateMachine" has Variablesfor the current State, but also has an Object"MySubMachine" and a Variablerepresenting the current state of the SubStateMachine. Since the SubStateMachineis only used when "MyStateMachine" is in "State1", a client would receive a Bad_StateNotActive StatusCodewhen reading the SubStateMachine CurrentState Variableif "MyStateMachine" is in a different State.
Figure 9gives an example of an ObjectTypenot only representing a StateMachinebut also having some other functionality. The ObjectType"MyObjectType" has an Object"MyComponent" representing this other functionality. But it also contains a StateMachine"MyStateMachine" of the type "MyStateMachineType". Objectsof "MyObjectType" also contain such an Objectrepresenting the StateMachine and a Variablecontaining the current state of the StateMachine, as shown in the Figure.
The StateMachinesshown so far only had Transitionsbetween Stateson the same level, that is, on the same StateMachine. Of cause, it is possible and often required to have Transitionsbetween Statesof the StateMachineand Statesof its SubStateMachine.
Because a SubStateMachinecan be defined by another StateMachineTypeand this type can be used in several places, it is not possible to add a bi-directional Referencefrom one of the shared Statesof the SubStateMachineto another StateMachine. In this case it is suitable to expose the FromStateor ToState Referencesuni-directional, that is, only pointing from the Transitionto the Stateand not being able to browse to the other direction. If a Transitionpoints from a Stateof a SubStateMachineto a Stateof another sub-machine, both, the FromStateand the ToState Reference, are handled uni-directional.
Figure 10gives an example of a state machine having a transition from a sub-state to a state.
In Figure 11the representation of this example as StateMachineTypein the AddressSpaceis given. The "Transition1", part of the definition of "MyStateMachineType", points to the "StateX" of the StateMachineType"AnotherStateMachineType". The Referenceis only exposed as forward Referenceand the inverse Referenceis omitted. Thus, there is no Referencefrom the "StateX" of "AnotherStateMachineType" to any part of "MyStateMachineType" and "AnotherStateMachineType" can be used in other places as well.
In Figure 15the representation of this example as StateMachineTypein the AddressSpaceis given. The “MyStateMachineType” defines the StateMachine of Figure 12, and the “MySubStateMachineType” is a subtype and extends the StateMachinewith a SubStateMachineas defined in Figure 13. The “MySubSubStateMachineType” is another subtype as defined in Figure 14.
The States and Transitions of "MyStateMachineType” are replicated to "MySubStateMachineType" and "MySubSubStateMachineType". Since "Method1” is not overridden, the "Transition1" of all three types is referencing the Method of "MyStateMachineType”. In "MySubStateMachineType”, a SubStateMachine for "State1" was added, and in "MySubSubStateMachineType" a SubStateMachine for "State2". In addition, "MySubSubStateMachineType" adds an effect to "Transition1".