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
Read Attributes from OPCUA Server
September 19, 2018
21:28, EEST
Avatar
carlos.gonzalez
Member
Members
Forum Posts: 12
Member Since:
August 7, 2018
sp_UserOfflineSmall Offline

Hi,

I am having problems to read the value of specific node, this is from Server side.

I am sending “myNodeManager” like parameter to other class when I am going to make the call, this is the code:

IoManagerUaNode ioManagerUaNode = new IoManagerUaNode(myNodeManager);
NodeId nodeIdName = new NodeId(2,”Name”); //This is the node I am going to read the value, and it has value!!
try {
DataValue data = ioManagerUaNode.readAttribute(nodeIdName, Attributes.Value, null, null);
String name = data.getValue().toString();
System.out.println(name);
} catch (StatusException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

But, I am getting this error:
ServiceFault: Bad_InternalError (0x80020000) “An internal error occurred as a result of a programming or configuration error.”
Diagnostic Info: java.lang.NullPointerException
at com.prosysopc.ua.server.IoManagerUaNode.readValue(SourceFile:119)
at com.prosysopc.ua.server.IoManager.readAttribute(SourceFile:870)
at com.prosysopc.ua.server.IoManager.readAttribute(SourceFile:439)

I am getting null value, but the node has value!

I was looking the documentation and there is others methods like readValue or other readAttribute (with more parameters) but I can not see them on my IoManager.

Thank you.

September 20, 2018
13:03, EEST
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi,

I/O managers are used to handle read and write calls from the client applications. It’s not supposed to be used internally by the server application.

In the context of the example above, where you already have access to the NodeManagerUaNode object (myNodeManager), you can access the UaNode objects by calling

NodeManagerUaNode.findNode(NodeId nodeId);

If you would not have access to the NodeManager object, you could also call getNode method of the NodeManagerTable:

UaServer.getAddressSpace().getNode(NodeId nodeId);

You can then access the different attributes of the node with getXxx methods. As an example, the DataValue of the value attribute can be obtained with getValue() method. As a more complete example, please see the below code for obtaining the value attribute in the above scenario:

CacheVariable nameNode= (CacheVariable) myNodeManager.findNode(new NodeId(2,"Name"));
DataValue dv = nameNode.getValue();

All this being said, the server side SDK documentation might need some improvement regarding these aspects. You can find documentation about these methods in the Javadoc, but the tutorial documents don’t offer much help.

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

Hi,

Ok, I will use getValue() method instead IoManager.

Thank you so much for your quickly response!!

Regards.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
16 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 Kubala

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

Administrators: admin: 1