The Program model extends the FiniteStateMachineType and basic ObjectType models presented in OPC 10000-16. Each Program has a Type Definition that is the subtype of the FiniteStateMachineType. The ProgramStateMachineType describes the Finite State Machine model supported by any Program Invocation of that type. The ProgramStateMachineType also defines the property set that characterizes specific aspects of that Program’s behaviour such as lifetime and recycling as well as specifying the result data that is produced by the Program.
The base ProgramStateMachineType defines the standard Finite State Machine specified for all Programs. This includes the states, transitions, and transition causes (Methods) and effects (Events). Subtypes of the base ProgramStateMachineType can be defined to extend or more specifically characterize the behaviour of an individual Program as illustrated with “MyProgramType” in Figure 4.
The additional properties and components that compose the ProgramStateMachineType are listed in Table 5. No ProgramStateMachineType specific semantics are assigned to the other base ObjectType or FiniteStateMachineType Attributes or Properties.
Table 5 – ProgramStateMachineType
Attribute |
Value |
||||
|
Includes all attributes specified for the FiniteStateMachineType |
||||
BrowseName |
ProgramStateMachineType |
||||
IsAbstract |
False |
||||
|
|
||||
References |
NodeClass |
BrowseName |
Data Type |
TypeDefinition |
Other |
HasProperty |
Variable |
Creatable |
Boolean |
PropertyType |
|
HasProperty |
Variable |
Deletable |
Boolean |
PropertyType |
M |
HasProperty |
Variable |
AutoDelete |
Boolean |
PropertyType |
M |
HasProperty |
Variable |
RecycleCount |
Int32 |
PropertyType |
M |
HasProperty |
Variable |
InstanceCount |
UInt32 |
PropertyType |
|
HasProperty |
Variable |
MaxInstanceCount |
UInt32 |
PropertyType |
|
HasProperty |
Variable |
MaxRecycleCount |
UInt32 |
PropertyType |
|
|
|
|
|
|
|
HasComponent |
Variable |
ProgramDiagnostic |
ProgramDiagnostic2DataType |
ProgramDiagnostic2Type |
O |
|
|
|
|
|
|
HasComponent |
Object |
Halted |
|
StateType |
|
HasComponent |
Object |
Ready |
|
StateType |
|
HasComponent |
Object |
Running |
|
StateType |
|
HasComponent |
Object |
Suspended |
|
StateType |
|
|
|
|
|
|
|
HasComponent |
Object |
HaltedToReady |
|
TransitionType |
|
HasComponent |
Object |
ReadyToRunning |
|
TransitionType |
|
HasComponent |
Object |
RunningToHalted |
|
TransitionType |
|
HasComponent |
Object |
RunningToReady |
|
TransitionType |
|
HasComponent |
Object |
RunningToSuspended |
|
TransitionType |
|
HasComponent |
Object |
SuspendedToRunning |
|
TransitionType |
|
HasComponent |
Object |
SuspendedToHalted |
|
TransitionType |
|
HasComponent |
Object |
SuspendedToReady |
|
TransitionType |
|
HasComponent |
Object |
ReadyToHalted |
|
TransitionType |
|
|
|
|
|
|
|
HasComponent |
Method |
Start |
|
|
OP |
HasComponent |
Method |
Suspend |
|
|
OP |
HasComponent |
Method |
Reset |
|
|
OP |
HasComponent |
Method |
Halt |
|
|
OP |
HasComponent |
Method |
Resume |
|
|
OP |
|
|
|
|
|
|
HasComponent |
Object |
FinalResultData |
|
BaseObjectType |
O |
Conformance Units |
|||||
Program Basic |
The component Variables of the ProgramStateMachineType have additional Attributes defined in Table 6.
Table 6 – ProgramStateMachineType Attribute values for child Nodes
BrowsePath |
Value Attribute |
||
|
11 |
||
|
12 |
||
|
13 |
||
|
14 |
||
|
1 |
||
|
2 |
||
|
3 |
||
|
4 |
||
|
5 |
||
|
6 |
||
|
7 |
||
|
8 |
||
|
9 |
The Creatable Property is a boolean that specifies if Program Invocations of this ProgramStateMachineType can be created by a Client. If False, these Program Invocations are persistent or may only be created by the Server.
The Deletable Property is a boolean that specifies if a Program Invocation of this ProgramStateMachineType can be deleted by a Client. If False, these Program Invocations can only be deleted by the Server.
The AutoDelete Property is a boolean that specifies if Program Invocations of this ProgramStateMachineType are removed by the Server when execution terminates. If False, these Program Invocations persist on the Server until they are deleted by the Client. When the Program Invocation is deleted, any result data associated with the instance is also removed.
The RecycleCount Property is an unsigned integer that specifies the number of times a Program Invocation of this type has been recycled or restarted from its starting point (not resumed). Note that the Reset Method may be required to prepare a Program to be restarted.
The MaxRecycleCount Property is an integer that specifies the maximum number of times a Program Invocation of this type can be recycled or restarted from its starting point (not resumed). If the value is less than 0, then there is no limit to the number of restarts. If the value is zero, then the Program may not be recycled or restarted.
The InstanceCount Property is an unsigned integer that specifies the number of Program Invocations of this type that currently exist.
The MaxInstanceCount Property is an integer that specifies the maximum number of Program Invocations of this type that can exist simultaneously on this Server. If the value is less than 0, then there is no limit.
The ProgramStateMachineType components consist of a set of References to the Object instances of StateTypes, TransitionTypes, EventTypes and the Methods that collectively define the Program FiniteStateMachine.
Figure 5 illustrates the component References that define the associations between two of the ProgramStateMachineType’s states, Ready and Running. The complementary ReferenceTypes have been omitted to simplify the illustration.
The state Objects are instances of the StateType defined in OPC 10000-16. Each state is assigned a unique StateNumber value defined in Table 6. Subtypes of the ProgramStateMachineType can add references from any state to a subordinate or nested StateMachine Object to extend the FiniteStateMachine.
The Halted state is the idle state for a Program. It can be an initial state or a terminal state. As an initial state, the Program Invocation cannot begin execution due to conditions at the Server. As a terminal state, Halted can indicate either a failed or completed Program. A subordinate state or result can be used to distinguish the nature of the termination. The Halted state references four Transition Objects, which identify the allowed state transitions to the Ready state and from the Ready, Running, and Suspended states.
The Ready state indicates that the Program is prepared to begin execution. Programs that are ready to begin upon their creation may transition immediately to the Ready state. The Ready state references four Transition Objects, which identify the allowed state transitions to the Running and Halted states and from the Halted and Ready states.
The Running state indicates that the Program is actively performing its Function. The Running state references five Transition Objects, which identify the allowed state transitions to the Halted, Ready, and Suspended states and from the Ready and Suspended states.
The Suspended state indicates that the Program has stopped performing its Function, but retains the ability to resume the Function at the point at which it was executing when suspended. The Suspended state references four Transition Objects, which identify the allowed state transitions to the Ready, Running, and Halted state and from the Ready state.
ProgramStateMachineType Transitions are instances of the TransitionType defined in OPC 10000-16 which also includes the definitions of the ToState, FromState, HasCause, and HasEffect references used. Table 7 specifies the transitions defined for the ProgramStateMachineType. Each transition is assigned a unique TransitionNumber defined in Table 6.
Table 7 – ProgramStateMachineType Additional References
SourceBrowsePath |
Reference Type |
Is Forward |
TargetBrowsePath |
HaltedToReady |
ToState |
True |
Ready |
|
FromState |
True |
Halted |
|
HasCause |
True |
Reset |
|
HasEffect |
True |
ProgramTransitionEventType |
|
HasEffect |
True |
AuditProgramTransitionEventType |
|
|
|
|
ReadyToRunning |
ToState |
True |
Running |
|
FromState |
True |
Ready |
|
HasCause |
True |
Start |
|
HasEffect |
True |
ProgramTransitionEventType |
|
HasEffect |
True |
AuditProgramTransitionEventType |
|
|
|
|
RunningToHalted |
ToState |
True |
Halted |
|
FromState |
True |
Running |
|
HasCause |
True |
Halt |
|
HasEffect |
True |
ProgramTransitionEventType |
|
HasEffect |
True |
AuditProgramTransitionEventType |
|
|
|
|
RunningToReady |
ToState |
True |
Ready |
|
FromState |
True |
Running |
|
HasEffect |
True |
ProgramTransitionEventType |
|
HasEffect |
True |
AuditProgramTransitionEventType |
|
|
|
|
RunningToSuspended |
ToState |
True |
Running |
|
FromState |
True |
Suspended |
|
HasCause |
True |
Suspend |
|
HasEffect |
True |
ProgramTransitionEventType |
|
HasEffect |
True |
AuditProgramTransitionEventType |
|
|
|
|
SuspendedToRunning |
ToState |
True |
Running |
|
FromState |
True |
Suspended |
|
HasCause |
True |
Resume |
|
HasEffect |
True |
ProgramTransitionEventType |
|
HasEffect |
True |
AuditProgramTransitionEventType |
|
|
|
|
SuspendedToHalted |
ToState |
True |
Halted |
|
FromState |
True |
Suspended |
|
HasCause |
True |
Halt |
|
HasEffect |
True |
ProgramTransitionEventType |
|
HasEffect |
True |
AuditProgramTransitionEventType |
|
|
|
|
SuspendedToReady |
ToState |
True |
Ready |
|
FromState |
True |
Suspended |
|
HasCause |
True |
Reset |
|
HasEffect |
True |
ProgramTransitionEventType |
|
HasEffect |
True |
AuditProgramTransitionEventType |
|
|
|
|
ReadyToHalted |
ToState |
True |
Halted |
|
FromState |
True |
Ready |
|
HasCause |
True |
Halt |
|
HasEffect |
True |
ProgramTransitionEventType |
|
HasEffect |
True |
AuditProgramTransitionEventType |
The HaltedToReady transition specifies the transition from the Halted to Ready states. It may be caused by the Reset Method.
The ReadyToRunning transition specifies the transition from the Ready to Running states. It is caused by the Start Method.
The RunningToHalted transition specifies the transition from the Running to Halted states. It is caused by the Halt Method.
The RunningToReady transition specifies the transition from the Running to Ready states. The RunningToSuspended transition specifies the Transition from the Running to Suspended states. It is caused by the Suspend Method.
The SuspendedToRunning transition specifies the transition from the Suspended to Running states. It is caused by the Resume Method.
The SuspendedToHalted transition specifies the transition from the Suspended to Halted states. It is caused by the Halt Method.
The SuspendedToReady transition specifies the transition from the Suspended to Ready states. It is caused internally.
The ReadyToHalted transition specifies the transition from the Ready to Halted states. It is caused by the Halt Method.
Two HasEffect References are specified for each Program transition. These effects are Events of ProgramTransitionEventType and AuditProgramTransitionEventType defined in 5.2.5. The ProgramTransitionEventType notifies Clients of the Program transition and conveys result data. The AuditProgramTransitionEventType is used to audit transitions that result from Program Control Methods.
Figure 6 – ProgramStateMachineType causes and effects
The ProgramStateMachineType includes references to the Causes of specific Program state transitions. These causes refer to Method instances. Programs that do not support a Program Control Method will omit the Causes reference to that Method from the ProgramStateMachineType references. If a Method’s Causes reference is omitted from the ProgramStateMachineType then a Client cannot cause the associated state transition. The Method instances referenced by the ProgramStateMachineType identify the InputArguments and OutputArguments required for the Method calls to Program Invocations of that ProgramStateMachineType. Table 8 specifies the Methods defined as Causes for ProgramStateMachineTypes. Figure 6 illustrates the References associating the components and Properties of Methods and Events with Program transitions.
Table 8 – ProgramStateMachineType causes
BrowseName |
References |
Target BrowseName |
Value |
Target TypeDefinition |
NOTES |
Causes |
|||||
Start |
HasProperty |
InputArguments |
|
PropertyType |
Optional |
|
HasProperty |
OutputArguments |
|
PropertyType |
Optional |
|
|
|
|
|
|
Suspend |
HasProperty |
InputArguments |
|
PropertyType |
Optional |
|
HasProperty |
OutputArguments |
|
PropertyType |
Optional |
|
|
|
|
|
|
Resume |
HasProperty |
InputArguments |
|
PropertyType |
Optional |
|
HasProperty |
OutputArguments |
|
PropertyType |
Optional |
|
|
|
|
|
|
Halt |
HasProperty |
InputArguments |
|
PropertyType |
Optional |
|
HasProperty |
OutputArguments |
|
PropertyType |
Optional |
|
|
|
|
|
|
Reset |
HasProperty |
InputArguments |
|
PropertyType |
Optional |
|
HasProperty |
OutputArguments |
|
PropertyType |
Optional |
|
|
|
|
|
|
The Start Method causes the ReadyToRunning Program transition.
The Suspend Method causes the RunningToSuspended Program transition.
The Resume Method causes the SuspendedToRunning Program transition.
The Halt Method causes the RunningToHalted, SuspendedToHalted, or ReadyToHalted Program transition depending on the current state of the Program.
The Reset Method causes the HaltedToReady Program transition.
The Executable Method attribute indicates if a method can currently be executed. For Program Control Methods, this means that the owning Program has a current state that supports the transition caused by the Method.
Methods can reference a set of InputArguments. For each ProgramStateMachineType, a set of InputArguments may be defined for the supported Program Control Methods. The data passed in the arguments supplements the information required by the Program to perform its Function. All calls to a Program Control Method for each Program Invocation of that ProgramStateMachineType shall pass the specified arguments.
Methods can reference a set of OutputArguments. For each ProgramStateMachineType, a set of OutputArguments is defined for the supported Program Control Methods. All calls to a Program Control Method for each Program Invocation of that ProgramStateMachineType shall pass the specified arguments.
The ProgramStateMachineType includes component references to the Effects of each of the Program’s state transitions. These Effects are Events. Each Transition shall have a HasEffect Reference to a ProgramTransitionEventType and can have an AuditProgramTransitionEventType. When the transition occurs, Event notifications of the referenced type are generated for subscribed Clients. The Program Invocation may serve as the EventNotifier for these Events or an owning Object or the Server Object may provide the notifications.
ProgramTransitionEventTypes provide the means for delivering result data and confirming state transitions for subscribed Clients on each defined Program State Transition. The AuditProgramTransitionEventType allows the auditing of changes to the Program’s state in conjunction with Client Method Calls.
The ProgramTransitionEventType is a subtype of the TransitionEventType. It is used with Programs to acquire intermediate or final results or other data associated with a state transition. A Program can have a unique ProgramTransitionEventType definition for any transition. Each ProgramTransitionEventType specifies the IntermediateResult data specific to the designated state transition on that ProgramStateMachineType. Each transition can yield different intermediate result data. Table 9 specifies the ProgramTransitionEventType.
Table 9 identifies the ProgramTransitionEventTypes that are specified for ProgramStateMachineTypes.
Table 9 – ProgramTransitionEventType
Attribute |
Value |
||||
BrowseName |
ProgramTransitionEventType |
||||
IsAbstract |
True |
||||
References |
NodeClass |
BrowseName |
DataType |
TypeDefinition |
ModellingRule |
Subtype of the base TransitionEventType defined in OPC 10000-16. |
|||||
HasComponent |
Variable |
IntermediateResult |
BaseDataType |
BaseDataVariableType |
Mandatory |
Conformance Units |
|||||
Program Basic |
TransitionNumber identifies the Program transition that triggered the Event.
FromStateNumber identifies the state before the Program transition.
ToStateNumber identifies the state after the Program transition.
The IntermediateResult is an Object that aggregates a set of Variables whose values are relevant for the Program at the instant of the associated transition. The ObjectType for the IntermediateResult specifies the collection of Variables using a set of HasComponent References.
The AuditProgramTransitionEventType is a subtype of the AuditUpdateStateEventType. It is used with Programs to provide a means to audit the Program State transitions associated with any Client invoked Program Control Method. Servers shall generate AuditProgramTransitionEvents if auditing is supported.
Table 10 specifies the definition of the AuditProgramTransitionEventType.
Table 10 – AuditProgramTransitionEventType
Attribute |
Value |
||||
BrowseName |
AuditProgramTransitionEventType |
||||
IsAbstract |
True |
||||
References |
NodeClass |
BrowseName |
DataType |
TypeDefinition |
ModellingRule |
Subtype of the AuditUpdateStateEventType defined in OPC 10000-16. |
|||||
HasProperty |
Variable |
TransitionNumber |
UInt32 |
PropertyType |
Mandatory |
Conformance Units |
|||||
Program Auditing |
This EventType inherits all Properties of the AuditUpdateStateEventType defined in OPC 10000-5, except as noted below.
The Status Property, specified in OPC 10000-5,, identifies whether the state transition resulted from a Program Control Method call (set Status to ) or not (set Status to FALSE).
The SourceName specified in OPC 10000-5, identifies the Method causing the Program transition when it is the result of a Client invoked ProgramControlMethod. The SourceName is prefixed with “Method/” and the name of the ProgramControlMethod, “Method/Start” for example.
The ClientUserId Property, specified in OPC 10000-5, identifies the user of the Client that issued the Program Control Method if it is associated with this Program state transition.
The ActionTimeStamp Property, specified in OPC 10000-5 “AuditEventType”, identifies when the time the Program state transition that resulted in the Event being generated occurred.
The TransitionNumber Property is a Variable that identifies the transition that triggered the Event.
The FinalResultData ObjectType specifies the VariableTypes that are preserved when the Program has completed its Function. The ObjectType includes a HasComponent for a VariableType of each Variable that comprises the final result data.
This structure contains elements that chronicle the Program Invocation’s activity and can be used to aid in the diagnosis of Program problems.
Note The original ProgramDiagnosticDataType had flaws. To avoid collisions with existing implementations, a new version with name ProgramDiagnostic2DataType has been created.
Its composition is defined in Table 11.
Table 11 – ProgramDiagnostic2DataType structure
Name |
Type |
Description |
ProgramDiagnostic2DataType |
structure |
|
createSessionId |
NodeId |
The CreateSessionId contains the SessionId of the Session on which the call to the Create Method was issued to create the Program Invocation. |
createClientName |
String |
The CreateClientName is the name of the Client of the Session that created the Program Invocation. |
invocationCreationTime |
UtcTime |
The InvocationCreationTime identifies the time the Program Invocation was created. |
lastTransitionTime |
UtcTime |
The LastTransitionTime identifies the time of the last Program state transition that occurred. |
lastMethodCall |
String |
The LastMethodCall identifies the last Program Method called on the Program Invocation. |
lastMethodSessionId |
NodeId |
The LastMethodSessionId contains the SessionId of the Session on which the last Program Control Method call to the Program Invocation was issued. |
lastMethodInputArguments |
Argument[] |
The LastMethodInputArguments provides the input arguments on the last Program Method call. |
lastMethodOutputArguments |
Argument[] |
The LastMethodOutputArguments provides the output arguments on the last Program Method call. |
lastMethodInputValues |
BaseDataType[] |
The LastMethodInputValues preserves the values of the input arguments on the last Program Method call. The size and order of this list matches the size and order of the lastMethodInputArguments field. |
lastMethodOutputValues |
BaseDataType[] |
The LastMethodOutputValues preserves the values of the output arguments on the last Program Method call. The size and order of this list matches the size and order of the lastMethodOutputArguments field. |
lastMethodCallTime |
UtcTime |
The LastMethodCallTime identifies the time of the last Method call to the Program Invocation. |
lastMethodReturnStatus |
StatusCode |
The LastMethodReturnStatus preserves the value of the return status for the last Program Control Method requested for this Program Invocation. |
Its representation in the AddressSpace is defined in Table 12.
Table 12 – ProgramDiagnostic2DataType definition
Attribute |
Value |
|||||
BrowseName |
ProgramDiagnostic2DataType |
|||||
IsAbstract |
False |
|||||
References |
NodeClass |
BrowseName |
DataType |
TypeDefinition |
Other |
|
Subtype of Structure defined in OPC 10000-5. |
||||||
Conformance Units |
||||||
Program Basic |
This VariableType aggregates simple Variables using simple DataTypes that reflect the elements of the ProgramDiagnosticDataType structure. Its DataVariables have the same semantic as defined in in 5.2.8.
Note The original ProgramDiagnosticType VariableType had the same flaws as the structure. To avoid collisions with existing implementations, a new version with name ProgramDiagnostic2Type has been created.
The VariableType is formally defined in Table 13.
Table 13 – ProgramDiagnostic2Type VariableType
Attribute |
Value |
|||
BrowseName |
ProgramDiagnostic2Type |
|||
DataType |
ProgramDiagnostic2DataType |
|||
ValueRank |
-1 (Scalar) |
|||
IsAbstract |
False |
|||
References |
NodeClass |
BrowseName |
DataType / TypeDefinition |
ModellingRule |
Subtype of the BaseDataVariableType defined in OPC 10000-5. |
||||
HasComponent |
Variable |
CreateSessionId |
NodeId |
Mandatory |
HasComponent |
Variable |
CreateClientName |
String |
Mandatory |
HasComponent |
Variable |
InvocationCreationTime |
UtcTime |
Mandatory |
HasProperty |
Variable |
LastTransitionTime |
UtcTime |
Mandatory |
HasComponent |
Variable |
LastMethodCall |
String |
Mandatory |
HasComponent |
Variable |
LastMethodSessionId |
NodeId |
Mandatory |
HasComponent |
Variable |
LastMethodInputArguments |
Argument[] |
Mandatory |
HasComponent |
Variable |
LastMethodOutputArguments |
Argument[] |
Mandatory |
HasComponent |
Variable |
LastMethodInputValues |
BaseDataType[] |
Mandatory |
HasComponent |
Variable |
LastMethodOutputValues |
BaseDataType[] |
Mandatory |
HasComponent |
Variable |
LastMethodCallTime |
UtcTime |
Mandatory |
HasComponent |
Variable |
LastMethodReturnStatus |
StatusCode |
Mandatory |
Conformance Units |
||||
Program Basic |