Figure 7– Example of a StateMachineType using inheritance

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.


Figure 8– Example of a StateMachineType with a SubStateMachine using inheritance

Figure 8gives an example of a StateMachineTypehaving a SubStateMachinefor its "State1". For simplicity no effects and causes are shown, as well as type information for the Statesor ModellingRules.

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 9– Example of a StateMachineType using containment

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.

A Client shall be able to handle the information of a StateMachineif the ToStateand FromState Referencesare only exposed as forward Referencesand the inverse Referencesare omitted.

Figure 10gives an example of a state machine having a transition from a sub-state to a state.


Figure 10– Example of a StateMachine with Transitions from sub-states

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.


Figure 11– Example of a StateMachineType having Transition to SubStateMachine

When a subtype of FiniteStateMachineTypehaving Statesextends the StateMachine, it is not allowed to add additional States, but instead SubStateMachinescan be added to existing States.

The example in Figure 12shows a very simple StateMachinewith two States.


Figure 12– Example of a StateMachine with two States

In Figure 13the StateMachineof Figure 12is extended by adding two substates to "State1".


Figure 13– Example of a StateMachine extended with two Substates

In Figure 14the StateMachineof Figure 13is extended by adding two substates to "State2", and an effect on the Transition between "State1" and "State2".


Figure 14– Example of a StateMachine extended with another two Substates

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".


Figure 15– Example of a StateMachineType adding SubStateMachines in Subtypes