Avatar

Please consider registering
guest

sp_LogInOut Log In sp_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 RSS sp_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: 64
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: 64
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: 267

Currently Online:
10 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 103

pramanj: 86

ibrahim: 70

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 38

Rainer Versteeg: 32

Thomas Reuther: 31

Member Stats:

Guest Posters: 0

Members: 1118

Moderators: 14

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1034

Posts: 4352

Newest Members:

aldayr, Python techie, emanuel45q, Patrick, sammycontrols, hellema, linoy, subranna, ray, richN9177

Moderators: Jouni Aro: 853, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 559, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 21, Markus Johansson: 24, Matti Siponen: 64, Lusetti: 0

Administrators: admin: 1