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
Problem writing to Server with writeAsync method
August 31, 2018
22:12, EEST
Avatar
carlos.gonzalez
Member
Members
Forum Posts: 12
Member Since:
August 7, 2018
sp_UserOfflineSmall Offline

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!Cry

September 3, 2018
9:36, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

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.

September 3, 2018
20:50, EEST
Avatar
carlos.gonzalez
Member
Members
Forum Posts: 12
Member Since:
August 7, 2018
sp_UserOfflineSmall Offline

Hi,

Thank you so much for your quickly response!

It is working now.

Thanks!

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
13 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: 681

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com

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