Program Organization Units (POUs)
The program SR_OpcUaHandling implements the program code to control the OPC UA client.
The program implements a state machine for execution of the basic sequence (refer to diagram below) of the function block calls for reading and/or writing lists of variables.
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_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_Cleanup |
This logic implements the part of the state machine which handles the cleanup of the OPC UA client. The processed states are: oRelease node handles for variables to read and to write. oDisconnect from OPC UA server. |
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: oConnect to OPC UA server. oGet namespace indexes. oGet node handles for variables to read and to write. |
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: oCall the subroutine ACT_Prepare. oRead variables from OPC UA server. oWrite variables from OPC UA server. oCall the subroutine ACT_Cleanup. oError handling. |
The program SR_SimulatedMachineData implements the program code to simulate values for variables which are provided by the OPC UA server.
The program implements the dynamic configuration of the controller firewall.
After a warmstart of the application, the firewall of the controller is configured as follows:
Protocol |
Ethernet1 |
Ethernet2 |
---|---|---|
Modbus Server |
Rejected |
Rejected |
SNMP |
Rejected |
Rejected |
Web Server (HTTP) |
Rejected |
Rejected |
WebVisualization (HTTP) |
Rejected |
Rejected |