12:42, EEST
June 8, 2021
Hello,
I am currently prototyping with the evaluation SDK version 4.5.6-1429. I am trying to dynamically add and remove nodes/ variables that are published over MQTT.
When the application starts, a PubSubSystemConf is created with a PubSubVariableDataSetConf that I did not add any variables too. Throughout the application’s runtime, I would like to add/ remove variables from the dataset, how do I go about modifying which variables are being published?
I have tried
1. Directly adding PubSubPublishedVariableConf (created from nodeIds) to the list of PubSubPublishedVariableConf from the PubSubVariableDataSetConf::getPublishedVariables(), but I get an UnsupportedOperationException as it is an UnmodifiableCollection.
2. I thought of replacing the entire PubSubVariableDataSetConf in the Map from PubSubSystemConf::getVariableDataSets(), but it is again, an unmodifiable map.
So my questions is how do I add/ remove Variables from the PubSubPublishedVariableConf?
Do I call PubSubSystem::updateConfiguration() and pass in the function that returns the object PubSubSystemConf::withDataSetAddedOrReplaced when called on the old PubSubSystemConf object?
I’ve been unable to find any examples or documentation regarding this and would appreciate some help.
Thank you!
14:49, EEST
April 3, 2012
Hi,
The tutorial was improved a bit in 4.5.8, but most likely still needs some improvements. I should note that so far we have pretty much only tested “static” configurations (so it is possible that the below would not work). PubSub is really new when compared to the rest of the SDK and we are just starting in integrating it to our own apps. Also it’s design does differ quite a lot, since I tried to avoid some problems we have elsewhere in the SDK (basically having most things immutable fixes a lot).
Anyway, the PubSubSystemConf is immutable by design, it cannot be changed (nor any part of it, recursively). You must pass a function to the PubSubSystem.updateConfiguration that will transform the old configuration to whatever you would like the new configuration to be. We will add more helper/builder methods in the future, but at the moment you would need to replace the dataset.
18:56, EEST
June 8, 2021
Bjarne Boström said
Hi,The tutorial was improved a bit in 4.5.8, but most likely still needs some improvements. I should note that so far we have pretty much only tested “static” configurations (so it is possible that the below would not work). PubSub is really new when compared to the rest of the SDK and we are just starting in integrating it to our own apps. Also it’s design does differ quite a lot, since I tried to avoid some problems we have elsewhere in the SDK (basically having most things immutable fixes a lot).
Anyway, the PubSubSystemConf is immutable by design, it cannot be changed (nor any part of it, recursively). You must pass a function to the PubSubSystem.updateConfiguration that will transform the old configuration to whatever you would like the new configuration to be. We will add more helper/builder methods in the future, but at the moment you would need to replace the dataset. Â
Thank you for your input.
I have just tried implementing an update by passing a function to PubSubSystem.updateConfiguration that creates a new PubSubVariableDataSetConf which is then passed into oldConfig.withDataSetAddedOrReplaced. Through the debugger, it seems that the PubSubSystem is using the new PubSubVariableDataSetConf, but the the PubSubSystem doesn’t seem to be publishing any data on my specified data topic.
Things I have tried:
1. Adding a few nodes to the initial dataset, data is published on MQTT, replacing the original dataset with an empty dataset using PubSubSystemConf.withDataSetAddedOrReplaced. Expected: data to stop publishing, Actual: data is still published
2. Creating an empty initial dataset, no data is published on MQTT, replacing the original dataset with a new dataset with nodes using PubSubSystemConf.withDataSetAddedOrReplaced. Expected: data to start publishing, Actual: no data is published
After a few hours of trial and error, it seems that PubSubSystem.updateConfiguration has to be called twice for it to actually change the nodes in the VariableDataSet. I have no idea what the difference is but here is the code snippet that works for me:
pubSubSystem.updateConfiguration(oldConfig -> oldConfig.withDataSetRemoved(“ExampleDataset”));
pubSubSystem.updateConfiguration(oldConfig -> {
PubSubVariableDataSetConf newVariableDataSetConfig = getVariableDataSetConfig(“ExampleDataset”, listOfVariables, server.getNamespaceTable());
return oldConfig.withDataSetAddedOrReplaced(newVariableDataSetConfig);
});
I am unsure if it is intended, but chain calling pubSubSystem.withDataSetRemoved(“ExampleDataset”).withDataSetAddedOrReplaced(myNewVariableDataSetConfig) does not seem to work, however calling them in two separate PubSubSystem.updateConfiguration calls (one to remove, and one to add) seems to work.
Would appreciate there’s advice on if there is a better/ right way to do it.
Sidenote: is there a roadmap/ estimation for the release of the the rest of the OPCUA PubSub features? or maybe even feature parity with the V1.04 OPCUA spec?
Thank you!
14:24, EEST
April 3, 2012
Thanks for the report.
Sorry, that would seem to be our bug. The ‘intended way’ would just have oldConf -> oldConf.withDataSetAddedOrReplaced(…), but seems this doesn’t work (or is the bug I mean). Normally there should be no need to remove the old dataset, since adding/replacing a new one with the same name replaces the old one (the same applices to anywhere where there is that XXXaddorReplaceXXX signature). Technically first removing it and then adding it in separate calls results in us internally removing internal things and then creating them again. Just having one call will instead ‘update’ the existing one.
We will try to fix this to the next version, but I cannot promise that 100%, since it is quite close to it’s release (4.6.0; in 2-3 weeks).
For the sidenote:
Well… it is complicated. OPC UA 1.05 will most likely arrive at the end of this year or start of next. In general we try to do things people request from us (or things we need internally for our apps). With the current pace of features being added in UA, most likely we will never ‘catch up’ IF we are talking about supporting every possible feature. Though, OPC UA also contains somewhat lot of features that do not see a lot of use (like the Query service call, in almost 10 years I do not recall anyone supporting it).
Basically nowadays it would be more proper to ask which Profiles and Facets are supported (https://reference.opcfoundation.org/Core/docs/Part7/, though navigating that is quite horror, https://profiles.opcfoundation.org/v104/reporting/ is better ). Though it is also perfectly possible that no such are yet specified for feature X.
PubSub contains a lot of features (you could say it is almost “another separate OPC UA” partially “on top of the existing OPC UA”). Is there a particular feature you would be interested in?
Most Users Ever Online: 1919
Currently Online:
16 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 727
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1