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, EEST
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, EEST
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, EEST
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, EEST
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, EEST
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, EEST
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, EEST
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, EEST
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, EEST
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: 267

Currently Online:
7 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 95

pramanj: 86

ibrahim: 69

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 36

Rainer Versteeg: 32

Thomas Reuther: 26

Member Stats:

Guest Posters: 0

Members: 992

Moderators: 13

Admins: 1

Forum Stats:

Groups: 3

Forums: 14

Topics: 949

Posts: 4000

Newest Members:

anhy123, raghunarayanaswamy, jerrodharness1, chandrahollis, kandimilano0008, deonbracewell, swati kulha, muoipoupinel64, lannybroadway, 12315544121666

Moderators: Jouni Aro: 837, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 498, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 18, Markus Johansson: 11, Matti Siponen: 9

Administrators: admin: 0