The program SR_OpcUaHandling implements the program code to control the OPC UA client.
The program implements a state machine for execution of the sequence (refer to diagram below) of the function block calls for reading and/or writing lists of variables, and subscribing and monitoring items.
Function block / step |
Description |
---|---|
UA_Connect |
With the function block UA_Connect, the transport connection and the OPC UA session to the OPC UA server is established. The function block requires the endpoint URL of the server and additional connection parameter regarding security settings, authentication, timeouts, and so on. After the connection has been established successfully, the connection handle is provided which is required by subsequent called function blocks. |
UA_SubscriptionCreate |
With the function block UA_SubscriptionCreate, a subscription can be created. The function block requires the corresponding connection handle. |
UA_SubscriptionDelete |
With the function block UA_SubscriptionDelete, a subscription can be deleted. The function block requires the corresponding subscription handle. |
UA_MonitoredItemAddList |
With the function block UA_MonitoredItemAddList, monitored items can be added to a subscription using the corresponding subscription handle and the list of node handles. Depending on the configured synchronization mode, the values for each node are written to variables in your application automatically or triggered by the application. The variables must be provided to the function blocks via a list of variable references. |
UA_MonitoredItemDeleteList |
With the function block UA_MonitoredItemDeleteList, monitored items can be deleted from a subscription using the corresponding subscription handle and the list of node handles. Deleting all monitored items prior to the execution of UA_SubscriptionDelete is not mandatory because UA_SubscriptionDelete forces a clean-up of the subscription. |
UA_MonitoredItemOperateList |
With the function block UA_MonitoredItemOperateList, the values of multiple monitored items out of one subscription using the corresponding subscription handle and a list of monitored item handles can be updated. This function block can only be called using the controller synchronization mode. |
UA_SubscriptionProcessed |
With the function block UA_SubscriptionProcessed, it is verified that at least one value of the subscription is updated. The function block requires the subscription handle. This function block can only be called using the firmware synchronization mode. |
UA_NamespaceGetIndexList |
With the function block UA_NamespaceGetIndexList, the namespace indexes for the namespaces of interest must be retrieved from the server. The function block requires the connection handle and a list of namespaces of interest. The retrieved namespace indexes must be assigned to the corresponding node Ids, which are required by the function block UA_NodeGetHandleList. |
UA_NodGetHandleList |
With the function block UA_NodeGetHandleList, the handles for the nodes of interest must be retrieved from the OPC UA client. The function block requires the connection handle and a list of node Ids of interest. The retrieved node handles are required by the function blocks UA_ReadList and UA_WriteList. |
UA_ReadList / UA_WriteList |
With the function blocks UA_ReadList and UA_WriteList, the data exchange based on a list of node handles is implemented. The function blocks require the connection handle and a list of node handles so that their values can be read or written. The values for each node are read from or written to variables in your application. The variables must be provided to the function blocks via a list of variable references. |
UA_ConnectionGetStatus |
With the function block UA_ConnectionGetStatus, the status of the connection can be retrieved. The function block requires the corresponding connection handle. |
UA_NodeReleaseHandleList |
With the function block UA_NodeReleaseHandleList, a list of node handles is released in the OPC UA client. Only if all node handles which have been retrieved before are released, a new list of node handles can be queried using the function block UA_NodeGetHandleList. The function block requires the connection handle and a list of node handles which that are to be released. Releasing all node handles prior to the execution of UA_Disconnect is not mandatory because the UA_Disconnect forces a clean-up of the OPC UA client in general. |
UA_Disconnect |
With the function block UA_Disconnect, the connection to the OPC UA server is closed. The function block requires the connection handle of the connection which shall be closed. |
The program code has been divided into single logical functions. The single program parts are processed in subroutines, referred to as actions.
The actions called from the program are listed in the following table:
Name of the subroutine (action) |
Description |
---|---|
ACT_ConfigConnect |
This logic is used to configure the function block UA_Connect. |
ACT_ConfigMonitoredItemAddList |
This logic is used to configure the function block UA_MonitoredItemAddList. |
ACT_ConfigNamespaceGetIndexList |
This logic is used to configure the function block UA_NamespaceGetIndexList. |
ACT_ConfigNodeGetHandleList |
This logic is used to configure the function block UA_NodGetHandleList. |
ACT_ConfigReadList |
This logic is used to configure the function block UA_ReadList. |
ACT_ConfigWriteList |
This logic is used to configure the function block UA_WriteList. |
ACT_Cleanup |
This logic implements the part of the state machine which handles the cleanup of the OPC UA client. The processed states are:
|
ACT_DetectCommands |
In this logic, the commands triggered by the visualization are detected and the flags to control the state machine are set. |
ACT_HandleDataExchangeCommands |
In this logic, the state machine inside |
ACT_HideTokenParam |
In this logic, the token parameters displayed on the visualization are set. |
ACT_Init |
This logic is called only during the very first cycle. It implements the initialization of static parameters. |
ACT_InputMapping |
In this logic, the configuration data and other input variables, mainly coming from the visualization, are verified and assigned to local variables for further processing. |
ACT_OutputMapping |
In this logic, the output variables, mainly designated to the visualization, are verified and assigned to variables declared inside GVL_Visu for further processing. |
ACT_Prepare |
This logic implements the part of the state machine, which handles the preparation of the OPC UA client. The general states are:
|
ACT_Reset |
This subroutine is executed after an error was detected or disconnection. Herein all internal variables are initialized. |
ACT_StateMachine |
This logic implements the state machine for the operation of the OPC UA client. The general states are:
|
The program SR_SimulatedMachineData implements the program code to simulate values for variables which are provided by the OPC UA server.
The program SR_FirewallConfig calls the corresponding program to configure the controller firewall depending on the controller:
On Modicon M262 controllers, the called program implements the dynamic configuration of the controller firewall.
After a warmstart of the application, the firewall of the controller is configured such that the protocols Modbus Server, SNMP, Web Server (HTTP) and WebVisualization (HTTP) received on either Ethernet ports are rejected.
On PacDrive LMC controllers, the called program can be extended to modify the controller firewall settings. Otherwise, the default settings for the controller firewall are left unchanged.