Avatar
Please consider registering
guest
sp_LogInOut Log Insp_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 RSSsp_TopicIcon
Register value change inside server
October 7, 2020
9:00, EEST
Avatar
Tobs
Member
Members
Forum Posts: 4
Member Since:
December 1, 2019
sp_UserOfflineSmall Offline

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;
}

October 7, 2020
11:28, EEST
Avatar
Matti Siponen
Moderator
Members

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

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.

October 7, 2020
15:35, EEST
Avatar
Tobs
Member
Members
Forum Posts: 4
Member Since:
December 1, 2019
sp_UserOfflineSmall Offline

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 🙂

October 7, 2020
16:00, EEST
Avatar
Matti Siponen
Moderator
Members

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

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.

Forum Timezone: Europe/Helsinki
Most Users Ever Online: 1919
Currently Online:
Guest(s) 13
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 90
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 733
Moderators: 8
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1545
Posts: 6516
Newest Members:
basilpullman, Richardmip, mood edibles, LouieWreve, daniellabdx, janessan21, sammiebeak359, gena7127517, thorstenbouldin, Brett.Rollason
Moderators: Jouni Aro: 1029, Pyry: 1, Petri: 1, Bjarne Boström: 1045, Jimmy Ni: 26, Matti Siponen: 353, Lusetti: 0, Elias: 0
Administrators: admin: 1