Real-time mode in WebScada based on OPC UA and WebSocket technologies

It so happened that with the education of a process automation engineer, I work as a web programmer. But I always wanted to combine my knowledge from the field of automation and Internet technologies. Moreover, this has long been done by others.

WebSCADA systems have long been developed by software development companies for automation systems. Each of these systems has disadvantages associated with the complexity of protecting the transmitted information and the timely receipt of data. These shortcomings have always severely limited the industrial implementation of such systems. WebSCADA application is unlikely to compete in security with the desktop, and the problem of timely receipt of information in it when using the Internet has always existed due to the lack of full duplex connections (the server cannot send information to the client on its own initiative). But recent developments in the field of automation software and web technologies allow you to come close to the capabilities of desktop SCADA systems.

So, something like this was developed that I wanted to create my own mini WebSCADA:

1. OPC Foundation Corporation released a new protocol OPC UA (OPC Unified Architecture) to replace the outdated OPC DA.
2. The protocol of full duplex Internet connections appeared - WebSocket.

Of course, these developments did not appear yesterday, and on their basis a lot of things already work. But there have been no attempts to combine these technologies, and I decided to try.

OPCUA is a very flexible protocol with a service oriented architecture. It supports both web services (SOAP) and the binary communication protocol.

Of course, using SOAP, you can write a WebSCADA system that directly interacts with the OPC UA server, without any “web sockets” there. But in this case, we cannot get a full-fledged mechanism for obtaining information on subscribing to events due to the lack of full-duplex connection. Yes, and the overhead is high due to the "fat" XML and the need for parsing it. Therefore, I decided to write a gateway for translating WebSocket messages into the OPCUA binary protocol and vice versa. And of course, you need to write a web application directly interacting with the gateway.

My programming experience in C #, a very good implementation of the OPCUA stack on .NET (apparently the fact that the OPC protocol was originally developed exclusively for Windows) and the necessary SDK, quickly found on the Internet, determined my choice of a platform for implementing the gateway.

The client part of the gateway (the one that will interact with the OPC servers of various automation devices) was written using the ".NET Based OPC UA Client & Server SDK", a class library developed by the German company Unified Automation GmbH . For the server part (implementing the WebSocket protocol), the bauglir-websocket library was used .

Due to the fact that the development was carried out to verify the operation of the protocol bundle, and not for military use, the gateway is designed as an application and not a service (as it should be for a gateway). For testing, an OPCUA demo server was used, from the developer of the OPCUA SDK, emulating the operation of a “combat server” and equipment connected to it.

As a result of the work done, we got an OPCUA-WebSocket gateway in the form of a small application that allows you to connect to the OPCUA server and exchange data from the automation system nodes using the WebSocket protocol. Therefore, we have the opportunity to receive information from process control devices in real time directly in the browser (real time, of course, with the reservation for the delay time in the network).

image
Websocket-OPCUA interface of the gateway (the gateway is connected to the OPC server and the web socket server is running)

For clarity, I added the functionality of monitoring the OPCUA server nodes, controlling the attributes of these nodes, monitoring the nodes that are currently being monitored and controlling the parameters of WebSocket connections.

Starting the gateway is quite simple. In the “Url address” field, enter the host name (or IP address) and the port through which the connection will be made. If there is an active “listening” OPCUA server at this address, then a drop-down list of available connection points for this server will appear in the text field of the “connection point”. OPCUA technology supports a variety of data exchange options, including encrypted messaging over a secure SSL channel. Connection points are the available configurations of this connection for ways of exchanging data between the client and server.

Upon successful connection to the OPC server, a tree of objects connected to the server appears in the upper left area of ​​the Websocket-OPCUA gateway working window. To the right of the area of ​​the tree of objects is the area for viewing the values ​​of node attributes.

After we are connected to the OPCUA server, we launch the WebSocket server, which will transmit data from nodes to the browser and vice versa. We select an existing one or enter our host and port which the server will listen to.

Next, you will need to configure the operation of the web application. I plan to describe this in the next article. The web application is not finished yet. There will most likely be changes in the gateway, but the essence of its work will remain the same.

Thanks for attention!

Also popular now: