Subscribing to a very large number of Nodes in a Prosys OPC UA Java SDK based Server
17.06.2013
This one is from one of our customers, Daniel Fernandez Boada from Bergauer AG, who is describing an ingenious way to subscribe to a huge number of changing data in an aggregating OPC UA server.
The project
In our last project based on the Prosys OPC UA Java SDK, my team at Bergauer AG was in charge of providing a system containing an aggregation OPC UA server that had to connect to 6 different OPC UA servers, also developed by us.
Each of these 6 OPC UA servers is in permanent communication with the PLCs of one different section of the 35 km long Lötschberg base tunnel in Frutigen, Switzerland. They have to handle an approximate amount of 100k nodes each, with an average of 250 of them changing per second, and notify all these value changes to the aggregation OPC UA server. Here we process all this incoming data and generate alarms, events or also changing the value of other nodes configured exclusively in this server. It represents a data model containing over 600k nodes. To make this all a bit more complex, this aggregation server needs to notify also all its value changes and events to different OPC UA clients that are connected: the GUI management, the alarm management server, the event management server, the historical management server…
A quick glance to the system will tell you that we are generating millions of MonitoredDataItems and MonitoredEvenItems on both sides, server and client, with the consequent loss in performance. I have to say that the first trials subscribing all the elements one by one were not very promising. As one of the requirements of the system, for robustness reasons, was to notify always all the value changes and events from each layer to the next, it seemed that there was very little we could do about it. After several trials with different lengths of subscriptions and monitored items we gave up and realized that a new approach, but still OPC UA compliant, had to be considered.
Monitoring Events via Server Object – only
First we reduced the number of used MonitoredEventItems to one. By reading again the OPC UA specification I found out that we just need to subscribe to the EventNotifier of the Server Object. As long as the Server Object has a reference of type HasNotifier to each of the nodes that may generate events, whenever one of these nodes generates an Event, it must be also notified from the referenced node, in this case the Server Object. This may seem obvious for the experienced OPC UA programmers but I will detail it here for the beginners.
To implement this we create our own class, MyEventManager that extends com.prosysopc.ua.server.EventManager. However, in our notifyEventItem method we always check if the node has a HasNotifier reference to another node. If this is true, we call the same method again until we reach the Server Object, which is the only node we have subscribed to in the client: public class MyEventManager extends EventManager {
The “Event Design” Applied for Data Changes
This reduction of objects for the events gave me another idea, why not just using use one MonitoredDataItem to notify all the value changes in the system? After thinking about this, I came up with the ‘LastValueNode’ concept. This is nothing but a node that contains, and notifies, always the last value that has been changed in the server, no matter which node has been changed. The only problem was to know, which node had really been changed. As the values of our Variables are all Structured Objects all I had to do was to add a new property indicating the NodeId that this value belongs to. Now, just by subscribing to this LastValueNode, the client applications would get all the value changes of all the nodes in the server.
Let’s start by looking at the subscription to this new node. We need to set the MaxNotificationsPerPublish to 0 so we accept any number of notifications per publish. Also we tune the notification buffer size to allow a big number of notifications and set the publishing interval to the minimum value:
The important parameter for the MonitoredDataItem at the client side is its queue. We need to increase it, otherwise we won’t be notified of all changes and most of them will be overridden. In our case it looks like:
In the server we need to remember to always change the LastValueNode immediately after the original node has been changed. A good place to do so is right before the notification of the value change. In our server this is done in our NodeManager class:
In our case we also included some extra logic for this node. When we subscribe to this node, we trigger notifications for all the current values of all the variable nodes. This is done in our SubscriptionManager:
Useful Parameters
Some other parameters we use in our client…
And in the server:
Deployment
This control system is currently deployed at the control center of the Lötschberg base tunnel in Frutigen, Switzerland. It has been controlling the whole tunnel for more than a month and currently we are engaged in the final acceptance tests which hopefully will be passed by 7th of July.
Daniel Fernandez Boada.
Chief of Bergauer AG – Vietnam
dfb (at) bergauer.ch
http://www.bergauer.ch
Tags: Information Models, Java, OPC UA, Performance, Cases
comments powered by DisqusAbout Prosys OPC Ltd
Prosys OPC is a leading provider of professional OPC software and services with over 20 years of experience in the field. OPC and OPC UA (Unified Architecture) are communications standards used especially by industrial and high-tech companies.
Newest blog posts
Why Do Standards Matter in Smart Manufacturing?
The blog post discusses the importance of standards in smart manufacturing, envisioning a future where auto-configurable systems in manufacturing rely on standardized data formats for seamless integration and reduced costs, with a focus on the OPC UA standard family as a key enabler.
OPC UA PubSub to Cloud via MQTT
Detailed overview of the demo presented at the OPC Foundation booth
SimServer How To #3: Simulate data changes on a server using an OPC UA client
A two-part step-by-step tutorial on how to write data changes on an OPC UA server using an OPC UA client.