The additional properties and components that compose the ProgramStateMachineTypeare listed in Table 5. No ProgramStateMachineType specific semantics are assigned to the other base ObjectTypeor FiniteStateMachineType Attributesor 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 Variablesof the ProgramStateMachineType have additional Attributesdefined in Table 6.

Table 6– ProgramStateMachineType Attribute values for child Nodes

BrowsePath

Value Attribute

Halted

StateNumber

11

Ready

StateNumber

12

Running

StateNumber

13

Suspended

StateNumber

14

HaltedToReady

TransitionNumber

1

ReadyToRunning

TransitionNumber

2

RunningToHalted

TransitionNumber

3

RunningToReady

TransitionNumber

4

RunningToSuspended

TransitionNumber

5

SuspendedToRunning

TransitionNumber

6

SuspendedToHalted

TransitionNumber

7

SuspendedToReady

TransitionNumber

8

ReadyToHalted

TransitionNumber

9

The Creatable Propertyis a boolean that specifies if Program Invocationsof this ProgramStateMachineType can be created by a Client. If False, these Program Invocationsare persistent or may only be created by the Server.

The Deletable Propertyis a boolean that specifies if a Program Invocationof this ProgramStateMachineType can be deleted by a Client. If False, these Program Invocationscan only be deleted by the Server.

The AutoDelete Propertyis a boolean that specifies if Program Invocationsof this ProgramStateMachineType are removed by the Server when execution terminates. If False, these Program Invocationspersist on the Server until they are deleted by the Client. When the Program Invocationis deleted, any result data associated with the instance is also removed.

The RecycleCount Propertyis an unsigned integer that specifies the number of times a Program Invocationof this type has been recycled or restarted from its starting point (not resumed). Note that the Reset Method may be required to prepare a Programto be restarted.

The MaxRecycleCount Propertyis an integer that specifies the maximum number of times a Program Invocationof 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 Propertyis an unsigned integer that specifies the number of Program Invocationsof this type that currently exist.

The MaxInstanceCount Propertyis an integer that specifies the maximum number of Program Invocationsof this type that can exist simultaneously on this Server. If the value is less than 0, then there is no limit.

The ProgramStateMachineTypecomponents consist of a set of Referencesto the Objectinstances of StateTypes, TransitionTypes, EventTypesand the Methodsthat collectively define the Program FiniteStateMachine.

image008.png

Figure 5– Program References

Figure 5illustrates the componentReferencesthat define the associations between two of the ProgramStateMachineType’sstates, Ready and Running. The complementary ReferenceTypes have been omitted to simplify the illustration.

The state Objectsare instances of the StateTypedefined in OPC 10000-16. Each state is assigned a unique StateNumber value defined in Table 6. Subtypes of the ProgramStateMachineTypecan add references from any state to a subordinate or nested StateMachine Object to extend theFiniteStateMachine.

TheHaltedstate is the idle state for a Program. It can be an initial state or a terminal state. As an initial state, the Program Invocationcannot 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 Programis 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 Programis 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 Functionat 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 Readystate.

ProgramStateMachineType Transitions are instances of the TransitionTypedefined in OPC 10000-16which also includes the definitions of the ToState, FromState, HasCause, and HasEffect references used. Table 7specifies the transitions defined for the ProgramStateMachineType. Each transition is assigned a unique TransitionNumberdefined 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

TheHaltedToReady transition specifies the transition from the Halted to Ready states. It may be caused by the Reset Method.

TheReadyToRunning transition specifies the transition from the Ready to Runningstates. It is caused by the Start Method.

TheRunningToHalted transition specifies the transition from the Runningto Halted states. It is caused by the Halt Method.

TheRunningToReady transition specifies the transition from the Running to Ready states. TheRunningToSuspended transition specifies the Transition from the Running to Suspended states. It is caused by the Suspend Method.

TheSuspendedToRunning transition specifies the transition from the Suspended to Running states. It is caused by the Resume Method.

TheSuspendedToHalted transition specifies the transition from the Suspended to Halted states. It is caused by the Halt Method.

TheSuspendedToReady transition specifies the transition from the Suspended to Ready states. It is caused internally.

TheReadyToHalted transition specifies the transition from the Ready to Halted states. It is caused by the Halt Method.

Two HasEffect Referencesare specified for each Programtransition. These effects are Eventsof ProgramTransitionEventTypeand AuditProgramTransitionEventType defined in 5.2.5. The ProgramTransitionEventTypenotifies Clientsof the Programtransition and conveys result data. The AuditProgramTransitionEventTypeis used to audit transitions that result from Program Control Methods.

image009.png

Figure 6– ProgramStateMachineType causes and effects

The ProgramStateMachineTypeincludes references to the Causes of specific Programstate transitions. These causes refer to Method instances. Programs thatdo not supporta Program Control Method will omit the Causes reference to that Methodfrom the ProgramStateMachineType references. If a Method’s Causesreference is omitted from the ProgramStateMachineTypethen a Clientcannot cause the associated state transition. The Methodinstances referenced by the ProgramStateMachineTypeidentify the InputArgumentsand OutputArgumentsrequired for the Methodcalls to Program Invocationsof that ProgramStateMachineType. Table 8specifies the Methods defined as Causes forProgramStateMachineTypes. Figure 6illustrates the Referencesassociating the components and Propertiesof Methodsand Eventswith 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 Methodcauses the ReadyToRunning Program transition.

The Suspend Methodcauses the RunningToSuspended Program transition.

The Resume Methodcauses the SuspendedToRunning Program transition.

The Halt Methodcauses the RunningToHalted, SuspendedToHalted, or ReadyToHalted Program transitiondepending on thecurrent stateof theProgram.

The Reset Methodcauses the HaltedToReady Program transition.

TheExecutable Methodattribute indicates if a method can currently be executed. For Program Control Methods, this means that the owning Programhas a current statethat supports the transition caused by the Method.

Methodscan reference a set of InputArguments.For each ProgramStateMachineType, a set of InputArgumentsmay be defined for the supported Program Control Methods. The data passed in the arguments supplements the information required by the Programto perform its Function. All calls to a Program Control Methodfor each Program Invocationof that ProgramStateMachineTypeshall pass the specified arguments.

Methodscan reference a set of OutputArguments. For each ProgramStateMachineType, a set of OutputArgumentsis defined for the supported Program Control Methods. All calls to a Program Control Methodfor each Program Invocationof that ProgramStateMachineTypeshall pass the specified arguments.

The ProgramStateMachineTypeincludes component references to the Effects of each of the Program’sstate transitions. These EffectsareEvents. EachTransitionshall have a HasEffect Referenceto a ProgramTransitionEventType and can have anAuditProgramTransitionEventType. When the transition occurs, Eventnotifications of the referenced type are generated for subscribed Clients.The Program Invocationmay serve as the EventNotifierfor these Eventsor an owning Objector the Server Object may provide the notifications.

ProgramTransitionEventTypes provide the means for delivering result data and confirming state transitions for subscribed Clientson each definedProgram State Transition.The AuditProgramTransitionEventTypeallows the auditing of changes to the Program’s state in conjunction with Client Method Calls.

TheProgramTransitionEventTypeis a subtype of the TransitionEventType. It is used with Programsto acquire intermediate or final results or other data associated with a state transition. A Programcan have a unique ProgramTransitionEventTypedefinition for any transition. Each ProgramTransitionEventTypespecifies the IntermediateResultdata specific to the designated state transition on that ProgramStateMachineType. Each transition can yield different intermediate result data. Table 9specifies the ProgramTransitionEventType.

Table 9identifies the ProgramTransitionEventTypesthat are specified for ProgramStateMachineTypes.

Table 9– ProgramTransitionEventType

Attribute

Value

BrowseName

ProgramTransitionEventType

IsAbstract

True

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

Subtype of the base TransitionEventTypedefined in OPC 10000-16.

HasComponent

Variable

IntermediateResult

BaseDataType

BaseDataVariableType

Mandatory

Conformance Units

Program Basic

TransitionNumberidentifies the Programtransition that triggered the Event.

FromStateNumberidentifies the state before the Programtransition.

ToStateNumberidentifies the state after the Programtransition.

The IntermediateResultis an Objectthat aggregates a set of Variableswhose values are relevant for the Programat the instant of the associated transition. The ObjectTypefor the IntermediateResultspecifies the collection of Variablesusing 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 transitionsassociated with any Client invoked Program Control Method. Servers shall generate AuditProgramTransitionEvents if auditing is supported.

Table 10specifies the definition of the AuditProgramTransitionEventType.

Table 10– AuditProgramTransitionEventType

Attribute

Value

BrowseName

AuditProgramTransitionEventType

IsAbstract

True

References

NodeClass

BrowseName

DataType

TypeDefinition

ModellingRule

Subtype of the AuditUpdateStateEventTypedefined in OPC 10000-16.

HasProperty

Variable

TransitionNumber

UInt32

PropertyType

Mandatory

Conformance Units

Program Auditing

This EventTypeinherits all Propertiesof 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 Statusto ) or not (set Statusto FALSE).

The SourceNamespecified in OPC 10000-5, identifies the Methodcausing the Program transition when it is the result of a Clientinvoked ProgramControlMethod. The SourceNameis 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 Clientthat issued the Program Control Methodif 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 Eventbeing generated occurred.

The TransitionNumber Propertyis a Variablethat identifies the transition that triggered the Event.

The FinalResultData ObjectTypespecifies the VariableTypesthat are preserved when the Programhas completed its Function. The ObjectType includesa HasComponent for a VariableTypeof each Variablethat comprises the final result data.

This structure contains elements that chronicle the Program Invocation’sactivity and can be used to aid in the diagnosis of Programproblems.

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 CreateSessionIdcontains the SessionIdof the Sessionon which the call to the Create Method was issued to create the Program Invocation.

createClientName

String

The CreateClientNameis the name of the Clientof the Sessionthat created the Program Invocation.

invocationCreationTime

UtcTime

The InvocationCreationTimeidentifies the time the Program Invocationwas created.

lastTransitionTime

UtcTime

The LastTransitionTimeidentifies the time of the last Program state transition that occurred.

lastMethodCall

String

The LastMethodCallidentifies the last Program Methodcalled on the Program Invocation.

lastMethodSessionId

NodeId

The LastMethodSessionIdcontains the SessionIdof the Sessionon which the last Program Control Methodcall to the Program Invocationwas issued.

lastMethodInputArguments

Argument[]

The LastMethodInputArgumentsprovides the input arguments on the last Program Methodcall.

lastMethodOutputArguments

Argument[]

The LastMethodOutputArgumentsprovides the output arguments on the last Program Methodcall.

lastMethodInputValues

BaseDataType[]

The LastMethodInputValuespreserves the values of the input arguments on the last Program Methodcall. The size and order of this list matches the size and order of the lastMethodInputArgumentsfield.

lastMethodOutputValues

BaseDataType[]

The LastMethodOutputValuespreserves the values of the output arguments on the last Program Methodcall. The size and order of this list matches the size and order of the lastMethodOutputArgumentsfield.

lastMethodCallTime

UtcTime

The LastMethodCallTimeidentifies the time of the last Method call to the Program Invocation.

lastMethodReturnStatus

StatusCode

The LastMethodReturnStatus preserves the value of the return statusfor the last Program Control Method requested forthis Program Invocation.

Its representation in the AddressSpaceis 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 VariableTypeaggregates simple Variablesusing simple DataTypesthat reflect the elements of the ProgramDiagnosticDataType structure. Its DataVariableshave 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 VariableTypeis 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