0:33, EEST
August 7, 2018
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!
13:29, EEST
April 17, 2013
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:
myNameNode .updateValue(val);
//or alternatively: myNameNode .setValue(val);
18:56, EEST
August 7, 2018
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
12:56, EEST
April 17, 2013
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.
Most Users Ever Online: 1919
Currently Online:
14 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: 730
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech KubalaModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1