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 values from Simulation server
December 16, 2016
13:12, EET
Avatar
Tony56
Member
Members
Forum Posts: 7
Member Since:
December 13, 2016
sp_UserOfflineSmall Offline

Hi,

I am able to read the values from the server. am getting output like this

DataValue(value=780, statusCode=GOOD (0x00000000) “”, sourceTimestamp=12/16/16 10:34:02.1800000 GMT, sourcePicoseconds=0, serverTimestamp=12/16/16 10:34:02.1810000 GMT, serverPicoseconds=0)

My question is can we get like this “780” just the value. i am trying to implement read function in GUI, so i just need to read the value of tag.
Need your suggestion please!!
Thanks.

December 16, 2016
14:27, EET
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi,

The mentioned output is a DataValue object. To get the value field, call DataValue.getValue(). You will get a Variant object and again, you can access the value field with method Variant.getValue().

December 16, 2016
15:54, EET
Avatar
Tony56
Member
Members
Forum Posts: 7
Member Since:
December 13, 2016
sp_UserOfflineSmall Offline

Hi Tahvanainen,

I got the point what you are proposing. is there any example code available to do that. i am not sure how to access the Variant to get values.
i checked the Client documents and there is no much detail about this.

Thanks!

December 19, 2016
17:00, EET
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi,

Here’s an example which reads the value attribute of MyLevel node from SampleConsoleServer:

DataValue dv = client.readValue(NodeId.parseNodeId("ns=2;s=MyLevel"));
System.out.println("DataValue object=" + dv);
System.out.println("value=" + dv.getValue().getValue());
March 9, 2017
13:05, EET
Avatar
peterrob45
Member
Members
Forum Posts: 25
Member Since:
March 9, 2017
sp_UserOfflineSmall Offline

Hi Tony and Tahvanainen,

I am new to this stuffs, and not good in coding though, I have faced the same problem as you encountered did you get any solutions, I Can able to get the data values in normal way and I tried to use the variant method as Heikki mentioned and I have some error in that, I have posted my code and it has error

I tried like this also
DataValue value = client.readValue(NodeId.parseNodeId(“ns=5;s=Counter1”));
System.out.println(“DataValue object=” + value);
System.out.println(“value2=” + value.getValue().getValue());

I am trying to read the value from the counter1. Can you guys provide your information and this. it would be nice.

ThanksEmbarassedEmbarassed

March 9, 2017
13:35, EET
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi,

Please explain the error that you receive. The posted code is fine.

Without knowing more about the situation, I would guess that the error message is Bad_NodeIdUnknown “The node id refers to a node that does not exist in the server address space.”

This means that the OPC UA server in question does not contain the Counter1 node.

March 9, 2017
15:49, EET
Avatar
peterrob45
Member
Members
Forum Posts: 25
Member Since:
March 9, 2017
sp_UserOfflineSmall Offline

Hi Heikki,

It works fine now I think I made some changes in the code so that the error message came. Thanks for your feedback.

Now I have another task which is I need to print the serverTimestamp as a separate output. I tried the same procedure i.e

DataValue dv = client.readValue(NodeId.parseNodeId(“ns=5;s=Counter1”));
System.out.println(“DataValue object=” + dv);
System.out.println(“value=” + dv.getServerTimestamp().getServerTimestamp());
or
System.out.println(“value=” + dv.getvalue().getServerTimestamp());
client.disconnect();
I would like to kwon how to get this
Thanks.Smile

March 10, 2017
12:28, EET
Avatar
Heikki Tahvanainen
Moderator
Members

Moderators
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Well,

Have you tried:

System.out.println("server timestamp=" + dv.getServerTimestamp());
March 10, 2017
12:37, EET
Avatar
peterrob45
Member
Members
Forum Posts: 25
Member Since:
March 9, 2017
sp_UserOfflineSmall Offline

Hi,

Above code is fine!!! ThanksLaugh

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
15 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

TimK: 41

Member Stats:

Guest Posters: 0

Members: 707

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1465

Posts: 6252

Newest Members:

christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer, shanonhumphreys, KupimotoblokfuB, tamhollander5, paulinafcf, bridgette18l

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 982, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 319, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1