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: 400
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: 78

Currently Online:
21 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 91

pramanj: 86

ibrahim: 68

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 36

Rainer Versteeg: 32

peterrob45: 25

Member Stats:

Guest Posters: 0

Members: 866

Moderators: 12

Admins: 1

Forum Stats:

Groups: 3

Forums: 14

Topics: 885

Posts: 3723

Newest Members:

fred, Galla, RMuth, Michael Jacoby, sanjayyadav, sanjayy, AndreasABB, RAMI4.0, nmnemonic, virgie88y3407

Moderators: Jouni Aro: 830, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 400, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 15, Markus Johansson: 1

Administrators: admin: 0