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
How to read a data from server using Client;
November 3, 2016
20:05, EET
Avatar
karthi
Member
Members
Forum Posts: 16
Member Since:
November 2, 2016
sp_UserOfflineSmall Offline

Hii,
I am beginner to opc ua, I am trying to read data from the OPC server, i just connected my SampleConsoleServer & SampleConsoleClient. i can read the featuers from the sampleConsoleServer. but i need to read a data from other server

I do no how to make a client to read a value from the server or is there any other way to read a data.
can i create a xcel and connect with opc server and can i read that data in xcel using SampleConsoleClient, i need some suggestion regarding this.

Regards,
karthi

November 4, 2016
10:59, EET
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello Karthi,

If I understood correctly, your issue is that you are not able to read data using the SampleConsoleClient. If you have some other issues, please let us know.

In OPC UA, you must first find the node that contains the value that you are interested in. Finding the node is called browsing. So, first browse to the node that you are interested in. After browsing, you will know the NodeId of the node that you are interested in. The node id can be used to read attributes of that node.

The best way to study this functionality is to try it out yourself. I’ll provide you an example about how you can read value from an example node in SampleConsoleServer.

First, open SampleConsoleClient and connect to SampleConsoleServer and press ‘3’. Now, browse to MyLevel node by browsing Objects -> MyObjects -> MyDevice -> MyLevel. Press ‘x’. To read values from the node, press ‘4’. Next, select value attribute by inputting ’13’. The value of the MyLevel node will be printed.

The procedure is exactly same also with other servers than the SampleConsoleServer. Only thing that is different is that different servers contain different kinds of address spaces which means that you must yourself browse to the nodes that you wish to read.

If you would like to see how the reading is done in the Java code, please see the tutorial documents in the doc-folder of the SDK and then look at the SampleConsoleClient code.

November 7, 2016
13:51, EET
Avatar
karthi
Member
Members
Forum Posts: 16
Member Since:
November 2, 2016
sp_UserOfflineSmall Offline

Hi,

Thanks for the help Heikki, I can able to read the data from the sampleConsoleServer as you mentioned,

First, open SampleConsoleClient and connect to SampleConsoleServer and press ‘3’. Now, browse to MyLevel node by browsing Objects -> MyObjects -> MyDevice -> MyLevel. Press ‘x’. To read values from the node, press ‘4’. Next, select value attribute by inputting ’13’. The value of the MyLevel node will be printed.

I have a questions regarding this.
can i directly get the value without doing these steps?
can i create a shell script to do this step by step process automatically?
or
i there any another way to get the data!

Regards.

November 7, 2016
14:12, EET
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hi,

Yes, you can read values directly without browsing. Please see the client tutorial chapter “8. Read values” as a start.

As for the shell script question: the evaluation SDK is actually supplied together with a ready made command line script. So, you could accomplish the before mentioned reading by calling:

SampleConsoleClient.bat -n "ns=2;s=MyLevel" opc.tcp://localhost:52520/OPCUA/SampleConsoleServer 4 13
November 10, 2016
13:21, EET
Avatar
karthi
Member
Members
Forum Posts: 16
Member Since:
November 2, 2016
sp_UserOfflineSmall Offline

Hi Heikki,
Thanks for the help, I read the the Client tutorial document – chapter “8. Read values” as far i understood from what i read is, first we need to select the node then we can read the attributes of the node.
In the SampleConsoleClient code they used DataValue value = client.readAttribute(nodeId, attributeId); i understand how it works!

Regarding this Syntax,
SampleConsoleClient.bat -n “ns=2;s=MyLevel” opc.tcp://localhost:52520/OPCUA/SampleConsoleServer 4 13
I am still not clear how and where to call this code! can you help me in this
should i need to edit this in my SampleConsoleClient program or should i need to invoke this while running the client-server program?

Regards
Karthi

November 10, 2016
13:38, EET
Avatar
Heikki Tahvanainen
Member
Members
Forum Posts: 402
Member Since:
April 17, 2013
sp_UserOfflineSmall Offline

Hello,

Good to know that you got the reading to work.

Regarding the syntax: that is a command line script (.bat). I mentioned it just because you happened to ask how to create a shell script. You can find the SampleConsoleClient.bat in the samples directory of the evaluation SDK. There’s also corresponding linux version in the same folder if you downloaded the linux version of the evaluation SDK.

November 23, 2016
13:10, EET
Avatar
karthi
Member
Members
Forum Posts: 16
Member Since:
November 2, 2016
sp_UserOfflineSmall Offline

Hi Heikki,
I have one doubt regarding writing a value to a selected node.

After selecting MyLevel Node by browsing Objects -> MyObjects -> MyDevice -> MyLevel. Press ‘x’. then i selected the option to write a value to the node.

for example i gave a value as 1555 and i pressed enter it shows “ok”.

Then i tried to check my value, which i changed by reading the same node. There is some change in value like “1538”. Is this normal and whats the reason behind this if i am correct!

Regards,

November 23, 2016
16:07, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

SampleConsoleServer simulates the value of MyLevel, so it is changing every second.

If you want to write to a static value, you will find some nodes from the ComplianceNodes folder.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
12 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: 730

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus, Deakin

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

Administrators: admin: 1