The lifetime of a program, from uploading a program template to the creation of the result, including additional information about the ActiveProgramType and the RunningStateMachineType, is as follows:

  1. Uploading Program Template: The client uploads the ProgramTemplate to the ProgramTemplateSet of the ProgramManager using the Upload Method.
  2. Starting the Program Execution: The program can be started either externally by a Client application using the Start or StartProgram Method or internally by the Device itself based on internal/process reasons.
  3. Program Execution: The program execution progresses through various states defined in the FunctionalStateMachineType. During program execution, the ActiveProgramType provides information about the current state and runtime of the program. The CurrentPauseTime and CurrentRuntime properties indicate the current pause time and runtime of the program run, respectively. The CurrentStepName and CurrentStepNumber properties provide information about the current step being executed. The EstimatedRuntime, EstimatedStepNumbers, and EstimatedStepRuntime properties provide estimated information about the program's total runtime and steps.
  4. Creating Results: As the program is executed, the FunctionalUnit generates data and results during the run. These results are collected in a result object which is managed in the ResultSet, which includes information about the program's initiator, the template used with additional parameters, samples, and contextual information to link and trace the results. The result object can provide the results either as files in the FileSet or as OPC UA variables in the VariableSet.
  5. Program Completion: The program execution continues until it reaches the completion state (e.g., complete state) in the RunningStateMachineType. Once the program is complete, the results in the ResultSet are considered complete and are available for further processing and analysis.

Please note that the program's lifetime and states may vary based on the specific implementation and context of the OPC UA Companion Specification being used. The provided overview is a general outline of the program's lifetime and the high-level information about the ActiveProgramType and ResultSet based on the description provided.

This is illustrated in Figure 4


Figure 4 – Simplified program sequence