15:44, EET
February 21, 2014
Hello all,
I’m triggering BaseModelChangeEvents on the “Server” node to signal not further detailed changes in the entire addressSpace for my server. According to the specification, modelChangeEvents need to go along with updating the nodeVersion property. This creates 2 questions:
1) The addressSpace changes happen underneath the Objects folder, while the ModelChangeEvent is triggered from the Server object. Which of the 2 objects’ node version property should be updated?
2) Would I create the nodeVersion property for either of the aforementioned nodes in namespace “0” or in namespace”1″? Neither object comes with an existing nodeVersion object (Prosys SDK 2.03).
Many thanks for your advice,
Hans-Uwe
15:13, EET
December 21, 2011
The NodeVersion must be in the node that has the changes that you want to report. The standard UaNode implementations contain the NodeVersion already, but it seems that it’s not “directly” available, so you need to cast the ObjectsFolder, like this, to initialise the NodeVersion property:
of.initNodeVersion();
Now you can just add nodes to the folder, for example, with
FolderTypeNode.class, "NewFolder");
of.addComponent(newNode);
And the NodeVersion and model change events are triggered automatically.
Or if you want to makes several changes at once, you can use the begin/endModelChange-methods:
try {
FolderTypeNode newNode = mySandboxNodeManager.createInstance(
FolderTypeNode.class, "NewFolder");
of.addComponent(newNode);
…add more nodes…
} finally {
server.getNodeManagerRoot().endModelChange();
}
20:23, EET
February 21, 2014
9:49, EET
December 21, 2011
2:50, EEST
February 21, 2014
Hi,
I have a follow-up problem with the latest version of the SDK:
the mere call of addComponent(…) or deleteNode() does not automatically trigger a ModelChangeEvent as described above. The calls currently have to be surrounded by beginModelChange and endModelChange.
Also, despite calling add/delete nodes, the event only reports added or removed references. And as a consequence, it reports the parent object as the effected node and not the deleted/added nodes themselves. This is not what one would expect, in particular as the OPC UA client would want to learn about the deleted nodeId.
The context for the changes should be the parent object and not the server object (according per OPC UA standard).
Alongside my evaluation, I found the the getEventNotifier() incorrectly checks for the presence of HasEventSource references or otherwise removes the subscribesToEvent bit. According to the OPC UA standard, the ability of reporting of events (“subscribeToEvents”) does not require having an HasEventSource reference. In my case I would need to add an HasEventSource reference from a Folder to somewhere in order to trigger modelchangeevents for added/removed organised nodes.
Best regards, Hans-Uwe
10:32, EEST
April 3, 2012
Hi,
Seems the mention of automatic events without the begin/end was incorrect. Maybe we could implement that in the future, however it would need to be somehow configurable as it might not make sense to make separate event for each change..
There are some quirks on how the ModelChanges are specified and might not be that intuitive. Based on my interpretation of the spec:
1. The events should come from the server object, as per spec (v1.03) Part 3 9.32.3 (ModelChangeEvents) Views:
“…Therefore the only Notifiers which report the
ModelChangeEvents are View Nodes and the Server Object representing the default View.”
The “context” is defined by the affected field of the event. At least I would understand that this means the events are only given by the server object. Also as the event might contain changes from multiple nodes, therefore it would make sense that it is only notified from a central location (while I would argue it would also make sense that it would come from the object itself, if is an object for which references are added/deleted, but it would seem it is not specified so).
2. The affected node can be either the target or the source of the reference. Therefore clients should not assume it is the target. See spec Part 5 12.16 Table 157 for the ‘verb’
ReferenceAdded: “Indicates a Reference has been added. The affected Node may be either a SourceNode or TargetNode.”
For the NodeAdded, NodeDeleted verbs, the spec says 9.32.2:
“There is a correlation between ModelChangeEvents and the NodeVersion Property of Nodes.
Every time a ModelChangeEvent is issued for a Node, its NodeVersion shall be changed, and
every time the NodeVersion is changed, a ModelChangeEvent shall be generated. A Server
shall support both the ModelChangeEvent and the NodeVersion Property or neither, but never
only one of the two mechanisms”
Therefore in order to trigger the NodeAdded, the node must have the property. The nodes created with NodeManagerUaNode.createInstance and NodeBuilder are added to the manager as they are constructed. This also means that unless created by an InstantiationStrategy the node does not contain the property at the time of adding. This should be fixed or e.g. an option added to NodeBuilder which would make the NodeVersion before adding it to the manager. You could workaround this my adding the change manually via NodeManagerTable.getNodeManagerRoot().getModelChangeEvent().addChange(UaNode affectedNode, ModelChangeType… changeTypes) and adding the change manually.
The NodeDeleted should work as expected as it is done before deleting references.
You are correct about the SubscribeToEvents bit. That needs to be fixed. However as per above, you can still only observe ModelChanges from the Server object (which I would argue is anyway the best option as you only need to monitor one node to see all changes).
– Bjarne
21:23, EEST
February 21, 2014
Hi,
I do read the spec a little different indeed. While the server object reports any events, the object holding the NodeVersion property shall trigger the ModelChangeEvent
9.32.2: … “This relation also implies that only those Nodes of the AddressSpace having a NodeVersion shall trigger a ModelChangeEvent. Other Nodes shall not trigger a ModelChangeEvent.”.
As in my application the nodes with the expected changes are known, I’d like to subscribe the changes directly from there to reduce the “clutter” of other events
The spec elaborate, that if multiple node are affected (e.g. through EventCompression) or there are no details about the affected nodes, then the server can trigger the event on the server object.
Anyhow – the specs leave room for interpretation.
As for the automatic trigger of events, I personally do prefer manual control. This allows me to well define and document the behaviour of my server in a toolkit independent way.
Thanks a lot for your interpretation and feedback. As always this is very insightful.
Regards,
Hans-Uwe
Most Users Ever Online: 1919
Currently Online:
6 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: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1