Errata exists for this version of the document.

The Program model extends the FiniteStateMachineType and basic ObjectType models presented in OPC 10000-5. 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.

image007.png

Figure 4 – Program Type

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

Modelling Rule

HasProperty

Variable

Creatable

Boolean

PropertyType

--

HasProperty

Variable

Deletable

Boolean

PropertyType

Mandatory

HasProperty

Variable

AutoDelete

Boolean

PropertyType

Mandatory

HasProperty

Variable

RecycleCount

Int32

PropertyType

Mandatory

HasProperty

Variable

InstanceCount

UInt32

PropertyType

--

HasProperty

Variable

MaxInstanceCount

UInt32

PropertyType

--

HasProperty

Variable

MaxRecycleCount

UInt32

PropertyType

--

HasComponent

Variable

ProgramDiagnostic

ProgramDiagnostic2DataType

ProgramDiagnostic2Type

Optional

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

OptionalPlaceholder

HasComponent

Method

Suspend

OptionalPlaceholder

HasComponent

Method

Reset

OptionalPlaceholder

HasComponent

Method

Halt

OptionalPlaceholder

HasComponent

Method

Resume

OptionalPlaceholder

HasComponent

Object

FinalResultData

BaseObjectType

Optional

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.

image008.png

Figure 5 – Program References

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.

Table 6 specifies the ProgramStateMachineType’s state Objects. These Objects are instances of the StateType defined in OPC 10000-5, Annex B. Each state is assigned a unique StateNumber value. Subtypes of the ProgramStateMachineType can add references from any state to a subordinate or nested StateMachine Object to extend the FiniteStateMachine.

Table 6 – Program states

BrowseName

References

Target BrowseName

Value

Target TypeDefinition

NOTES

States

Halted

HasProperty

StateNumber

11

PropertyType

ToTransition

HaltedToReady

TransitionType

FromTransition

RunningToHalted

TransitionType

FromTransition

SuspendedToHalted

TransitionType

FromTransition

ReadyToHalted

TransitionType

Ready

HasProperty

StateNumber

12

PropertyType

FromTransition

HaltedToReady

TransitionType

ToTransition

ReadyToRunning

TransitionType

FromTransition

RunningToReady

TransitionType

ToTransition

ReadyToHalted

TransitionType

Running

HasProperty

StateNumber

13

PropertyType

ToTransition

RunningToHalted

TransitionType

ToTransition

RunningToReady

TransitionType

ToTransition

RunningToSuspended

TransitionType

FromTransition

ReadyToRunning

TransitionType

FromTransition

SuspendedToRunning

TransitionType

Suspended

HasProperty

StateNumber

14

PropertyType

ToTransition

SuspendedToRunning

TransitionType

ToTransition

SuspendedToHalted

TransitionType

ToTransition

SuspendedToReady

TransitionType

FromTransition

RunningToSuspended

TransitionType

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-5 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. The Notes column indicates when a cause is referencing Methods and when effects are optional.

Table 7 – Program transitions

BrowseName

References

Target BrowseName

Value

Target TypeDefinition

Notes

Transitions

HaltedToReady

HasProperty

TransitionNumber

1

PropertyType

ToState

Ready

StateType

FromState

Halted

StateType

HasCause

Reset

Method

HasEffect

ProgramTransitionEventType

HasEffect

AuditProgramTransitionEventType

ReadyToRunning

HasProperty

TransitionNumber

2

PropertyType

ToState

Running

StateType

FromState

Ready

StateType

HasCause

Start

Method

HasEffect

ProgramTransitionEventType

HasEffect

AuditProgramTransitionEventType

RunningToHalted

HasProperty

TransitionNumber

3

PropertyType

ToState

Halted

StateType

FromState

Running

StateType

HasCause

Halt

Method

HasEffect

ProgramTransitionEventType

HasEffect

AuditProgramTransitionEventType

RunningToReady

HasProperty

TransitionNumber

4

PropertyType

ToState

Ready

StateType

FromState

Runnning

StateType

HasEffect

ProgramTransitionEventType

HasEffect

AuditProgramTransitionEventType

RunningToSuspended

HasProperty

TransitionNumber

5

PropertyType

ToState

Running

StateType

FromState

Suspended

StateType

HasCause

Suspend

Method

HasEffect

ProgramTransitionEventType

HasEffect

AuditProgramTransitionEventType

SuspendedToRunning

HasProperty

TransitionNumber

6

PropertyType

ToState

Running

StateType

FromState

Suspended

StateType

HasCause

Resume

Method

HasEffect

ProgramTransitionEventType

HasEffect

AuditProgramTransitionEventType

SuspendedToHalted

HasProperty

TransitionNumber

7

PropertyType

ToState

Halted

StateType

FromState

Suspended

StateType

HasCause

Halt

Method

HasEffect

ProgramTransitionEventType

HasEffect

AuditProgramTransitionEventType

SuspendedToReady

HasProperty

TransitionNumber

8

PropertyType

ToState

Ready

StateType

FromState

Suspended

StateType

HasCause

Reset

Method

HasEffect

ProgramTransitionEventType

HasEffect

AuditProgramTransitionEventType

ReadyToHalted

HasProperty

TransitionNumber

9

PropertyType

ToState

Halted

StateType

FromState

Ready

StateType

HasCause

Halt

Method

HasEffect

ProgramTransitionEventType

HasEffect

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. The “Audit Server FacetProfile defined in OPC 10000-7 requires support of the AuditProgramTransitionEventType.

image009.png

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 10 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-5.

HasComponent

Variable

IntermediateResult

BaseDataVariableType

Mandatory

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.

Table 10 – ProgramTransitionEvents

BrowseName

References

Target BrowseName

Value

Target TypeDefinition

Notes

Effects

HaltedToReadyEvent

HasProperty

TransitionNumber

1

PropertyType

HasProperty

FromStateNumber

1

PropertyType

HasProperty

ToStateNumber

2

PropertyType

HasComponent

IntermediateResults

ObjectType

Optional

ReadyToRunningEvent

HasProperty

TransitionNumber

2

PropertyType

HasProperty

FromStateNumber

2

PropertyType

HasProperty

ToStateNumber

3

PropertyType

HasComponent

IntermediateResults

ObjectType

Optional

RunningToHaltedEvent

HasProperty

TransitionNumber

3

PropertyType

HasProperty

FromStateNumber

3

PropertyType

HasProperty

ToStateNumber

1

PropertyType

HasComponent

IntermediateResults

ObjectType

Optional

RunningToReadyEvent

HasProperty

TransitionNumber

4

PropertyType

HasProperty

FromStateNumber

3

PropertyType

HasProperty

ToStateNumber

2

PropertyType

HasComponent

IntermediateResults

ObjectType

Optional

RunningToSuspendedEvent

HasProperty

TransitionNumber

5

PropertyType

HasProperty

FromStateNumber

3

PropertyType

HasProperty

ToStateNumber

4

PropertyType

HasComponent

IntermediateResults

ObjectType

Optional

SuspendedToRunningEvent

HasProperty

TransitionNumber

6

PropertyType

HasProperty

FromStateNumber

4

PropertyType

HasProperty

ToStateNumber

3

PropertyType

HasComponent

IntermediateResults

ObjectType

Optional

SuspendedToHaltedEvent

HasProperty

TransitionNumber

7

PropertyType

HasProperty

FromStateNumber

4

PropertyType

HasProperty

ToStateNumber

1

PropertyType

HasComponent

IntermediateResults

ObjectType

Optional

SuspendedToReadyEvent

HasProperty

TransitionNumber

8

PropertyType

HasProperty

FromStateNumber

4

PropertyType

HasProperty

ToStateNumber

2

PropertyType

HasComponent

IntermediateResults

ObjectType

Optional

ReadyToHaltedEvent

HasProperty

TransitionNumber

9

PropertyType

HasProperty

FromStateNumber

2

PropertyType

HasProperty

ToStateNumber

1

PropertyType

HasComponent

IntermediateResults

ObjectType

Optional

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 they support the Audit Server Facet Profile defined in OPC 10000-7.

Table 11 specifies the definition of the AuditProgramTransitionEventType.

Table 11 – AuditProgramTransitionEventType

Attribute

Value

BrowseName

AuditProgramTransitionEventType

IsAbstract

True

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

Subtype of the AuditUpdateStateEventType defined in OPC 10000-5.

HasProperty

Variable

TransitionNumber

UInt32

PropertyType

Mandatory

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

Table 12 – 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

StatusResult

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

Table 13 – ProgramDiagnostic2DataType definition

Attributes

Value

BrowseName

ProgramDiagnostic2DataType

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

Table 14 – 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