Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Traverse all nodes to subscribe to variable changes
June 14, 2022
15:00, EEST
Avatar
stela_n
New Member
Members
Forum Posts: 2
Member Since:
June 14, 2022
sp_UserOfflineSmall Offline

Hello,
Using the Java SDK I want to create subscription, which receives all updates for all variable changes from a PLC added to a server. However I don’t know the structure of the PLC beforehand and want to get it programmatically and I expected that there will be a lot of nested nodes (folders) until it gets to a variable node.

I was thinking of traversing the whole structure recursively using uaClient.getAddressSpace().browse() until I reach all leaves of the tree and create MonitoredDataItem from those nodes, but my concern is that this could take a long time for PLCs with loads of nodes.

Is there an existing method to traverse all nodes or should I implement DFS myself? Also is there another smarter way to get all the variable nodes in the PLC?

June 14, 2022
15:53, EEST
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 321
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

First of all, monitoring all Variables on a Server’s AddressSpace for changes sounds like a very bad idea. Depending on the Server, there can hundreds or even thousands of Variables. Monitoring them all would put quite a heavy load the Server and possibly on the Client as well.

And if you do not know the structure of the PLC beforehand, what would be the significance of the received data changes? There is no guarantee that the NodeIds, BrowseNames or DisplayNames on the Server would give enough semantic meaning to the Variables you monitor, so understanding the structure of the PLC might be required to interpret the received data changes. And if you know the structure of the PLC, you don’t have to traverse the entire AddressSpace for Variables and you can just monitor those that represent important information.

That being said, recursive browsing with browse methods of AddressSpace class, such as browse(NodeId nodeId), is the only way of traversing the entire AddressSpace. Since OPC UA doesn’t have a strict parent-child hierarchy for Nodes, it is possible to reach a Node with multiple BrowsePaths so you have to keep track of Nodes that have already been processed to avoid processing them more than once.

June 14, 2022
17:36, EEST
Avatar
stela_n
New Member
Members
Forum Posts: 2
Member Since:
June 14, 2022
sp_UserOfflineSmall Offline

So basically I am trying to rework an already existing application. We are already subscribing to hundreds of Variables and we must continue to support this, so every Variable change is important to us. Because of the hierarchy of folders in the PLC we have determined that the NodeId of the Variable together with Description and possibly DataType is going to provide enough information about the Variable and will give us the structure of the PLC.

Currently stl files with the structure of the PLC are being uploaded to our system and we get the NodeIds of the Variables through those files. However this method is prone to errors since when the structure of the PLC changes a new file needs to be uploaded to our system in order to start tracking the changes. That’s why I want to get this information directly from the server. Is there actually a way to track when the structure of the PLC was changed and how – for example new Variables were added, some nodes were deleted or a Variable description was changed? If a Variable is added as a MonitoredDataItem to a Subscription what will happen if that Variable is deleted from the PLC or it’s DataType is changed?

June 15, 2022
8:45, EEST
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 321
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline

Hello,

If the Server generates them, you could monitor the Server’s Server Object for ModelChangeEvents. Those Events are generated when Nodes or References are added or deleted and also when DataType Attributes of Variables change. Handling ModelChangeEvents would make it easier for your Client to react to changes in the Server’s AddressSpace. However, Servers are not required to generate ModelChangeEvents so you might not be able to rely on them.

For more information on ModelChangeEvents and how they express the changes using ModelChangeStructureDataType, see https://reference.opcfoundation.org/v105/Core/docs/Part3/#9.32 https://reference.opcfoundation.org/Core/docs/Part5/6.4.32/ and https://reference.opcfoundation.org/Core/docs/Part5/12.16/

If the Server doesn’t generate ModelChangeEvents, there isn’t any way to detect changes in the AddressSpace except by periodically browsing it from root to leaves to check for changes.

You can create MonitoredItems for other Attributes in addition to the typical Value Attribute. If you think that the Descriptions of Variables could change, you can create MonitoredItems to monitor changes in the Description Attributes of Variable Nodes. You could also monitor DataType Attributes if the Server doesn’t generate ModelChangeEvents and you think those could change too.

If a Variable Node on the Server corresponding to a MonitoredItem is deleted, the Server is expected to send a Notification for that MonitoredItem with StatusCode Bad_NodeIdUnknown to indicate that the Variable has been deleted. For more information, see https://reference.opcfoundation.org/Core/docs/Part4/5.12.1/#5.12.1.6

A change in the DataType Attribute of a Variable Node won’t affect a MonitoredItem monitoring the Value Attribute of the same Variable. You would keep receiving Notifications for new Values of the Variable, though their DataType would be different than before. As mentioned before, if you expect this to happen, you can monitor the DataType Attributes of Variable Nodes as well.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
24 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 681

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1