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
Method onWriteValue on MyIoManagerListener
September 20, 2018
0:33, EEST
Avatar
carlos.gonzalez
Member
Members
Forum Posts: 12
Member Since:
August 7, 2018
sp_UserOfflineSmall Offline

Hi,

I have doubts in order to know how can I add more code and do another things on the onWriteValue method and the listener still works, because right now, on the second write to the Server, the listener does not tell me that had writes. This is my code:

@Override
public boolean onWriteValue(ServiceContext serviceContext, NodeId nodeId, UaValueNode node,
NumericRange indexRange,
DataValue dataValue) throws StatusException {
logger.info(“onWriteValue: nodeId=” + nodeId + (node != null ? ” node=” + node.getBrowseName() : “”)
+ (indexRange != null ? ” indexRange=” + indexRange : “”) + ” value=” + dataValue);
//Object to JSON Serialization – Heartbeat
String node_Write = node.getBrowseName().toString();
if (node_Write.equals(“2:Write_to_json”) ) {
System.out.println(“Write to JSON = True”);
UnderlyingSystem_t underlyingSystem_t = new UnderlyingSystem_t();
try {
underlyingSystem_t.Heartbeat(myserver, myNodeManager2);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return false;
}

This is my Heartbeat method from my UnderlyingSystem_t Class:

public boolean Heartbeat(UaServer server, NodeManagerUaNode myNodeManager) throws FileNotFoundException{
IoManagerUaNode ioManagerUaNode = new IoManagerUaNode(myNodeManager);
NodeId nodeIdName = new NodeId(2,”Name”);
try {
DataValue val = new DataValue(new Variant(new Boolean(false)));
ioManagerUaNode.writeAttribute(nodeIdWrite , Attributes.Value, null, val);
} catch (StatusException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return false;
}

My method works fine, write the value correctly, but when I write again to the Server, the listener does not make the call to my method again.

Thank you!

September 20, 2018
13:29, EEST
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello,

Could you explain what do you exactly mean with the description “listener does not tell me that had writes”? Is the problem that the logger.info line is not called at all?

Also, the code example in the current form is a little bit hard to reason about. As an example, there’s a variable “nodeIdName” but this variable is not used. Instead, the writeAttribute call uses a variable called “nodeIdWrite” as a parameter, but we cannot know how the “nodeIdWrite” is defined.

P.s. Actually it’s not correct to use the IoManager as discussed in the other forum post. Instead, you should use the UaNode objects:

CacheVariable myNameNode = (CacheVariable) myNodeManager.findNode(new NodeId(2,”Name”));
myNameNode .updateValue(val);
//or alternatively: myNameNode .setValue(val);
September 20, 2018
18:56, EEST
Avatar
carlos.gonzalez
Member
Members
Forum Posts: 12
Member Since:
August 7, 2018
sp_UserOfflineSmall Offline

Hi,

I am sorry, my mistake about nodeIdWrite variable, te correct variable is nodeIdName on the writeAttribute method.

And yes, I am not going to use IoManager anymore for the servers calls, only for the clients.

My problem in this topic, is the listener works fine just the for the first write from the client to the server, i will explain with steps:
1 – Client writes to the server
2 – The listener tell me and the logger.info is called
3 – Execute underlyingSystem_t.Heartbeat(myserver, myNodeManager2) method
4 – Method works fine, return false
5 – Client write again to the server
6 – The listener does not do anything

And that is my problem, what do I have to do in order to the listener tell me again and the logger.info is called again.

Thanks for you quickly response

September 21, 2018
12:56, EEST
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Allright, based on the above description it sounds like the IoManagerListener.onWriteValue method is not called at all.

Is the client application writing value to the same node at both times? If the client application is writing values to two different nodes, it is possible that the nodes in question are handled by different NodeManagers (and IoManagers and IoManagerListeners) and for this reason the IoManagerListener would not get called during the second write.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
17 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: 682

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc

Moderators: 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