15:44, EEST
December 14, 2020
Hi,
I am using the prosys Opc Ua Java SDK for opc Ua server and client development .
I have below queries regarding subscription to server nodes from client:
1)I am currently translating browse path to NodeIds and using them for subscription. As nodeIds might change if we update the model , so not directly subscribing to Nodeids. But can we also have duplicate browse paths?
What should be the correct approach for this subscription?
2)Currently , I have added single listener for all the monitoredItems but what will happen if 2 nodes are changed simultaneously at exact same time? Will I loose 1 of the changes as I have single listener listening to all the changes or the changes will be queued?
What would be better approach- Having single listener for all the node subscriptions or having multiple listeners, one for each node subscription.
3)Is it possible subscribe to parent object and get notified about changes in child nodes as well or should I subscribe to each child node items?
Regards
Nan
9:03, EEST
Moderators
February 11, 2020
Hello,
1) What do you mean with duplicate BrowsePaths?
2) The MonitoredDataItemListener simply provides the MonitoredItem a onDataChange method that is called whenever the DataValue is changed. It’s up to the implementation of the method whether or not it can be called simultaneously for multiple MonitoredItems at the same time and whether you need a single or multiple listeners.
3) You need to subscribe to the child Nodes.
22:03, EEST
December 14, 2020
Thanks Matti.
I have used prosys java sdk for UA client server developement.
In my UAClient, I would like to subscribe to a parent node of opcua server whose child nodes can be dynamically updated(added or removed) at run time.
I assumed that on addition of any child node, MonitoredEventItemListener’s onEvent() method will be called (similar to calling onDataChange() method in AtoMonitoredDataItemListener on value change when subscribed to Valued attributes).
I am not getting notified with below code which is similar to sample client code. Could you please help me here:
///////Inside createMonitoredItem method which is called from subscribe() method
MonitoredEventItem eventItem = createMonitoredEventItem(nodeId); //nodeId of parent node
item = eventItem;
double requestedSamplingInterval = item.getSamplingInterval();
sub.addItem(item);
monitoredItemId = item.getMonitoredItemId();
double revisedSamplingInterval = item.getSamplingInterval();
protected MonitoredEventItem createMonitoredEventItem(NodeId nodeId) {
initEventFieldNames();
EventFilter filter = createEventFilter(eventFieldNames);
// Create the item
MonitoredEventItem eventItem = new MonitoredEventItem(nodeId, filter);
eventItem.setEventListener(eventListener);
return eventItem;
}
In createEventFilter method below filter is added as per Sample Uaclient. Could you please let me know if below filter doesn’t allow GeneralModelChangeEventType? I also tried removing/changing this filter but couldn’t get notification on addition/removal of child node.
// Event filtering: the following sample creates a
// “Not OfType GeneralModelChangeEventType” filter
ContentFilterBuilder fb = new ContentFilterBuilder();
// The element operand refers to another operand –
// operand #1 in this case which is the next,
// LiteralOperand
fb.add(FilterOperator.Not, new ElementOperand(UnsignedInteger.valueOf(1)));
final LiteralOperand filteredType = new LiteralOperand(Identifiers.GeneralModelChangeEventType);
fb.add(FilterOperator.OfType, filteredType);
// Apply the filter to Where-clause
filter.setWhereClause(fb.getContentFilter())
Any help here would really be appreciated.
Thanks
Nan
13:02, EEST
Moderators
February 1, 2019
13:18, EEST
December 14, 2020
Sure Jimmy.
What I basically want to know is how do we subscribe to GeneralModelChangeEventType events. The code above is just the sample client code provided with prosys sdk.
My further analysis show that I could listen to GeneralModelChangeEventType event when I subscribed to “Server” node instead of “Objects ” node. But with subscribing to the server node, how do I know the exact node which is changed i.e. nodeId for parent node in which child node is added or removed and know the child nodes’ nodeId as well.
I have been struggling with this scenario. Any help here would be highly appreciated.
Thanks
Nan
13:45, EEST
Moderators
February 11, 2020
Hello,
Subscribing to the Server Object’s EventNotifier will get you all Events generated by the Server. In this case, it is recommended to do so.
Events of GeneralModelChangeEventType contain Changes Property, which is an array of ModelChangeStructureDataType Structures. Each of these Structures contain the NodeId of the affected Node, the NodeId of its TypeDefinition, and a byte that indicates how it was affected, e.g. it was added, removed and so on. You should be able to use this information to detect when Nodes and References that target them are added to the AddressSpace. Similarly, you can use the information to detect when Nodes and References are deleted.
For more information on BaseModelChangeEventType, GeneralModelChangeEventType and ModelChangeStructureDataType, see
https://reference.opcfoundation.org/v104/Core/docs/Part5/6.4.31/
https://reference.opcfoundation.org/v104/Core/docs/Part5/6.4.32/
https://reference.opcfoundation.org/v104/Core/docs/Part5/12.16/
14:06, EEST
December 14, 2020
Thanks Matti.
That means I need to subscribe to Server node only and not Objects node?
i.e. browse path “Objects/0:Server”
I do see onEvent(MonitoredEventItem sender, Variant[] eventFields) method of MonitoredEventItemListener class being called now.
I am doubtful of how to access GeneralModelChangeEventType object here inside onEvent method so I can get array of ModelChangeStructureDataType and eventually nodeId of the affected nodes.
or some other way to access GeneralModelChangeEventType object in client, when event is triggered from the server.
Thanks
Nan
14:42, EEST
Moderators
February 11, 2020
15:11, EEST
December 14, 2020
Thanks a lot Matti.
That worked for me!!
1)
In my case an instance is added to the Parent node. for which I get Verb-“4” which as per document is
” DataTypeChanged 4 This verb may be used only for affected Nodes that are Variables or VariableTypes. It indicates that the DataType Attribute has changed.”
where as in my case a new instance node is just added and no data type changed.
When the instance is deleted the Verb is “8” which is not mentioned/explained in the doc.
If you could please help me if I am understanding the Verbs wrong here.
2)Is there a way to get NodeId of the node/instance that is added or deleted from parent node?
Thanks
Nan
15:27, EEST
Moderators
February 11, 2020
15:39, EEST
Moderators
February 11, 2020
Hello,
When the Verb is NodeAdded (2^0 = 1), you can get the NodeId of the newly added Node. When the Verb is ReferenceAdded (2^2 = 4), you can get the NodeId of the Node the Reference was added to. If the Reference was birectional, you should get the NodeIds of the SourceNode and the TargetNode as separate ModelChangeStructureDataType Structures. Putting all this information together should allow your Client application to determine the NodeId of the newly added Node and the NodeId of its parent Node.
15:46, EEST
December 14, 2020
1)Does that mean in my case where Reference was added to parent node(Verb=4), I can only get NodeId of the parent node it was added to and no information about the reference itself?
For my use case, where i want to get information about the Reference added, Is browsing the parent node only option?
2)When you say “If the Reference was birectional” , does that mean when Refence is removed from 1 node and added to other?
15:59, EEST
Moderators
February 11, 2020
1) No information on the type of Reference is available in ModelChangeStructureDataType, you will need to find the added Reference with Browse.
2) The Reference is either added to both or removed from both. See https://reference.opcfoundation.org/Core/docs/Part3/5.3.2/ for more information on bidirectional References.
Most Users Ever Online: 1919
Currently Online:
26 Guest(s)
Currently Browsing this Page:
2 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: 738
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6452
Newest Members:
rickyjuarez140, jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCibModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1027, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1