22:12, EEST
August 7, 2018
Hi,
I am having problems to write to the server with the writeAsync method.. But the writeValue method works fine, with the same NodeId and value, this the code for writeValue:
NodeId nodeId = new NodeId(2, “MyLevel”); //DataType : Double
double vd = 15.5;
try {
client.writeValue(nodeId, vd); //————————-This method works fine!
System.out.println(“Value save succesfully to Node Id: ” + nodeId);
} catch (ServiceException | StatusException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
And this is the code for writeAsync method:
DataValue vdf = new DataValue(new Variant(new Double(vd)));
WriteValue arg0 = new WriteValue(nodeId, Attributes.BrowseName, null, vdf);
System.out.println(nodeId);
System.out.println(Attributes.BrowseName);
System.out.println(vdf);
AsyncResult r = client.writeAsync(arg0); //This does not work!
WriteResponse response;
try {
response = (WriteResponse) r.waitForResult();
StatusCode[] val = response.getResults();
System.out.println(val[0]);
//System.out.println(“Value save succesfully to Node Id: ” + nodeId);
} catch (ServiceResultException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Error: Bad_NotWritable (0x803B0000) “The access level does not allow writing to the Node.”
—- The access level of the NodeId is 3, this is how I created it:
// My Level Measurement
final NodeId myLevelId = new NodeId(ns, “MyLevel”);
UaType doType = server.getNodeManagerRoot().getType(Identifiers.Double);
CacheVariable myLevel = new CacheVariable(myNodeManager, myLevelId, “MyLevel”, LocalizedText.NO_LOCALE);
((UaVariableNode) myLevel).setDataType(doType);
myLevel.setTypeDefinition(myLevelType);
myDevice.addComponent(myLevel);
I do not know what can be the problem, I am trying to write to the same NodeId and one method works and the other does not.
Thank you!
9:36, EEST
April 3, 2012
Hi,
You are not trying to do the same operation.
Sync: writeValue will write the value to the Value Attribute
ASync: you should use Attributes.Value and not Attributes.BrowseName for making the WriteValue.
Basically in OPC UA you can write to any Attribute of the node, but it is upto server implementation if it is supported (or allowed), most servers typically only allow writing to the Value Attribute.
Also the (User)AccessLevel Attributes controls how the Value Attribute is allowed to Read/Write/HistoryRead/HistoryWrite, the (User)WriteMask Attributes controls others.
Most Users Ever Online: 1919
Currently Online:
28 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: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1