# OPC-UA Agent for Legacy Programmable Logic Controllers +
## 4 Performance Evaluation
### OPC-UA Client Function Blocks for IEC 61131-3  
To evaluate the OPC-UA client function block, the response time of the client function called from the PLC program was measured. Among the 28 client APIs in Table 1, the function blocks using the number of node items as an input argument were set to have a value of 1000. The legacy controller was programmed to run a single PLC task with a period of 1 ms. To handle the subscription service, the external server must set both the publishing interval and sampling interval. The sampling interval is the rate at which the external server checks the values of monitored items in the subscription. If a publish request is sent from the OPC-UA client agent to the external server after the variable value is changed, the response is delivered to the client in the next publishing cycle. In the experiment, the external server set the publish interval to 500 ms and the sampling interval to 250 ms, respectively. Table 3 summarizes the measurement results of \(R_{func}\) and \(R_{client}\) for each client function block. The averages of \(R_{func}\) for all function blocks were found to be very similar. However, the averages of \(R_{client}\) were measured to be significantly different depending on the client function. This is because shared memory is updated periodically and \(R_{func}\) is strongly affected by the update cycle of shared memory. Therefore, it can be seen that \(R_{func}\) can be improved significantly by reducing the update cycle of shared memory. It was also found that the \(R_{client}\) of UA_Connect, which is used to establish a new connection of an OPC-UA session, is large compared to other function blocks. The response times for UA_MethodGetHandleList, UA_MethodReleaseHandleList, and UA_EventItemOperateList are very small because the functions are executed without communication with the external server. Figure 11: Average latencies for read service (\(L_{read}\)) and response time of the OPC-UA server (\(R_{server}\)) according to the number of data items (\(N_{read}\)) in a single request. Among frequently used function blocks, the response time of UA_ReadList, UA_WriteList, and UA_MonitoredItemAddList may vary depending on \(N_{read}\), the number of node items. In particular, it is interesting to analyze the trend of response times, \(R_{client}\) and \(L_{client}\) according to the number of items, and discuss the time required for function execution and data exchange with an external server. Figure 12 shows the experiment results. It can be seen that \(R_{func}\) is highly affected by the shared memory update cycle because \(R_{client}\) and \(L_{client}\) are very small until \(N_{read}\) increases to 3000. As \(N_{read}\) increases gradually, it takes time to dynamically create the requested nodes and update the response variables before and after executing the client function, so it was observed that \(R_{client}\) increases as rapidly as \(N_{read}\) increases. The latency \(L_{client}\) of UA_MonitoredItemAddList is always larger than the other two function blocks. This is because more processing is required for data exchange such as for the variables, status, and timestamps, as well as the node list in the subscription service.