📜 ⬆️ ⬇️

Real-time WebScada based on OPC UA and WebSocket technologies

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

WebSCADA systems have long been developed by companies developing automation software. Each of these systems has drawbacks related to the complexity of protecting the information transmitted and the timeliness of data acquisition. These shortcomings have always severely limited the industrial implementation of such systems. WebSCADA application can hardly compete with desktop security, 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 the latest developments in the field of automation software and web technologies make it possible to closely approach the capabilities of desktop SCADA systems.

So, something like this was developed that I wanted to create my own mini WebSCADA:
')
1. The OPC Foundation Corporation has released the OPC UA (Unified Architecture OPC) protocol to replace the outdated OPC DA.
2. A protocol for full duplex Internet connections appeared - WebSocket.

Of course, these developments did not appear yesterday, and many things are already working on their basis. But there was no attempt 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 binary data exchange 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 a subscription to events due to the lack of a full-duplex connection. Yes, and the overhead is high because of the "fatness" of XML and the need to parse it. Therefore, I decided to write a gateway for translating WebSocket messages into 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 # is 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 SDK quickly found on the Internet required my choice of platform for implementing the gateway.

The writing of the client part of the gateway (the one that will interact with the OPC servers of various automation devices) was done 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 test the operation of the bundle of protocols, and not for combat use, the gateway was designed as an application and not a service (as would be appropriate for the gateway). For testing, the OPCUA demo server, from the OPCUA SDK developer, was used, which emulates the operation of the “combat server” and the equipment connected to it.

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

image
Interface Websocket-OPCUA 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 currently in monitoring 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, a drop-down list of available connection points for this server will appear in the “connection points” text box. OPCUA technology supports various options for exchanging data, including the exchange of encrypted messages over a secure SSL channel. Connection points are available configurations of this connection for ways of exchanging data between the client and the server.

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

After we have connected to the OPCUA server, we launch the WebSocket server which will transmit the data from the nodes to the browser and back. Choose an existing one or enter your host and the port that the server will listen to.

Next, you will need to configure the web application. This is what I plan to describe in the next article. Work on the web application is not finished yet. The gateway is also likely to change, but the essence of its work will remain the same.

Thanks for attention!

Source: https://habr.com/ru/post/229975/


All Articles