9:00, EEST
December 1, 2019
Hello,
on my opc ua server I want to recognize when a specific value is changing.
I tried to use a custom IoManagerListerner but the onWriteValue method is never called.
I am changing a value from false to true and i want to run some code when it is true.
To add the custom IoManagerListener i am using the following code:
server.getNodeManagerRoot().getIoManager().addListeners(new MyIoManagerListener());
And the onWriteValue method is implemented like so:
@Override
public boolean onWriteValue(ServiceContext serviceContext, NodeId nodeId, UaValueNode node, NumericRange indexRange,
DataValue dataValue) throws StatusException {
logger.error(“onWriteValue Method called”);
return false;
}
11:28, EEST
Moderators
February 11, 2020
Hello,
It would seem like you’re adding your custom IoManagerListener to a wrong NodeManager. Instead of adding it to the Server’s NodeManagerRoot, you should be adding it to the same NodeManager that you’ve added your Nodes to. See ComplianceNodeManager class of SampleConsoleServer for an example of how to add Nodes and a custom IoManagerListener to a NodeManager.
15:35, EEST
December 1, 2019
The nodes are added automatically with the information model. So i created no NodeManager by myself like in the ComplianceNodeManager.
Is there a possibility to find the correct NodeManager?
I found a solution by myself:
server.getAddressSpace().getNodeManager(new NodeId(2, 6263)).getIoManager().addListeners(new MyIoManagerListener());
Thats working. Thanks Matti 🙂
16:00, EEST
Moderators
February 11, 2020
I’m glad to hear that everything worked out for you!
When a model is loaded, a new NodeManager is added to the NodeManagerTable, which you can get with server.getAddressSpace(). You’ve already figured out how to get the right NodeManager from the NodeManagerTable, but you could also get it with just the namespaceIndex. In your case, you could use server.getAddressSpace().getNodeManager(2) to get the NodeManager that corresponds to the loaded model. Alternatively, you could get a NodeManager with the Namespace URI of the loaded model with server.getAddressSpace().getNodeManager(namespaceUri), where namespaceUri is the Namespace URI of your model as a String.
Most Users Ever Online: 518
Currently Online:
15 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
TimK: 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.comModerators: 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