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: 983
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: 518

Currently Online: Matti Siponen
6 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 680

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6259

Newest Members:

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

Moderators: Jouni Aro: 1009, 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