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
Client always reads value "2"
September 6, 2019
12:23, EEST
Avatar
AndreasABB
Member
Members
Forum Posts: 3
Member Since:
August 30, 2019
sp_UserOfflineSmall Offline

Hi,

I’m trying to get a communication going between some hardware (OPC UA server) and a Java-based client. My end goal is writing data to the server.

I’ve managed to connect and read.
However, the client always reads value “2”. All the variables are initiated on 0 (or empty String).

To test my findings I also set up a localhost server (also all tags created, but values 0) and I got the same results.

I know that the values simply aren’t “2”, since I can easily verify using UaExpert.

Thanks in advance.

Input code:

UaClient client = new UaClient(“opc.tcp://localhost:48010”);
client.setSecurityMode(SecurityMode.NONE);
client.connect();
DataValue value = client.readAttribute(new NodeId(2, 6055), Attributes.NodeClass);
//client.writeAttribute(new NodeId(2, 6055), Attributes.NodeClass, 8.2654);
System.out.println(value);
client.disconnect();

This is my output:

DataValue(value=2, statusCode=GOOD (0x00000000) “”, sourceTimestamp=null, sourcePicoseconds=0, serverTimestamp=09/06/19 09:15:37.7751737 GMT, serverPicoseconds=0)

September 6, 2019
13:43, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1027
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

You are reading the NodeClass Attribute as you pass the Attributes.NodeClass as parameter. That is technically an Enumeration type, and nodes that are Variables have NodeClass.Variable, which enumeration value equals to 2 (Enumerations are encoded as Int32 values). Therefore you will always “get 2”.

If you want to read the Value Attribute, you need to pass Attributes.Value (or just use the readValue convinience methods).

P.S. Technically all Read operations will result in DataValue objects regardless of the Attribute read, but typically grapchical clients wont show that data as typically only the Value Attribute changes over time, i.e. they only visualize the value part of the DataValue (or status if it is bad) for other Attributes.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
31 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: 738

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1524

Posts: 6453

Newest Members:

rickie5305, shaylamaggard4, rickyjuarez140, jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp

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

Administrators: admin: 1