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: 1026
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: 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, howardkennerley

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1