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
Member
Members
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
Member
Members
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
Member
Members
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
Member
Members
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: 1919

Currently Online:
17 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: 728

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7

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

Administrators: admin: 1