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
Reading values from Simulation Server
November 30, 2016
18:05, EET
Avatar
karthi
Member
Members
Forum Posts: 16
Member Since:
November 2, 2016
sp_UserOfflineSmall Offline

Hi,
I am a beginner to OPC UA , I need some help in this area
I am using Prosys Simulation Server , I Connected the SimpleClient program (given in the stack) with that Simulation Server.

DataValue value = client.readValue(Identifiers.Server_ServerStatus_State); using this we can get the server status of the simulation server.

As per the manual, if we need to read a value from the server we need to choose the nodeId
In Prosys Simulation Server, i looked into the address space of it to get the nodeId, i selected simulation in that i selected ‘Random1’ to get nodeID “ns=5;s=Random1”.
ns is the NamespaceIndex and s is the string, Random1 is the value

As i need to read the Value of this Attributes i have to use this syntax UaClient.readValue(nodeId).
My question is should i write my sytanx like this DataValue value = client.readValues(“ns=5;s=Random1”);
or
DataValue value2 = client.readValue(“5:Random1”); or eanything else iam not clear with this!!!!!

December 1, 2016
11:21, EET
Avatar
Heikki Tahvanainen
Moderator
Members

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

Hello Karthick,

In your example, the Identifiers.Server_ServerStatus_State is actually a NodeId object whereas “ns=5;s=Random1” is a String. So, you just need to create a NodeId and use that as the parameter for the readValue method.

Try making a NodeId with

new NodeId(5, "Random1");
December 5, 2016
16:27, EET
Avatar
karthi
Member
Members
Forum Posts: 16
Member Since:
November 2, 2016
sp_UserOfflineSmall Offline

Hello Heikki,

Thanks for the reply,
Can i read a value directly from a simulation server (Prosys) without creating a nodeId. is there any other way to read without creating a nodeId.
Regarding the syntax, i try to create a nodeid in my client program i am not able to do that. is there any example syntax you have it would be useful for me to understand how to access the adressspace correctly.
Regards

December 5, 2016
17:09, EET
Avatar
Heikki Tahvanainen
Moderator
Members

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

Hi Karthick,

NodeIds are the basic functionality coming from OPC UA specification and they are the way how nodes are addressed in OPC UA. So, there is no other way.

Are you getting some error message when you try to create a NodeId in your client program?

December 6, 2016
12:20, EET
Avatar
karthi
Member
Members
Forum Posts: 16
Member Since:
November 2, 2016
sp_UserOfflineSmall Offline

Hi Heikki,

So if we need to read a value from the simulation Server we have to create nodeid everytime ?.
yes i have some issues with the code. i am not sure whether its is correct or not, could you take a look into it and tell me what correction should i need to do. As Random1 is already in server i used Random2.

public class CreatingNodeId {
public static void main(String[] args) throws Exception {
UaClient client = new UaClient(“opc.tcp://karthik:53530/OPCUA/SimulationServer”);
client.setSecurityMode(SecurityMode.NONE);
initialize(client);
client.connect();

NodeId parentIdNode = new NodeId(5, ““85/0:Simulation”);
NodeId newNodeId = new NodeId(5, “Random2”);

NodeId sampleNodeId = new NodeId(5, “Random1”);
UaNode sampleNode = client.getAddressSpace().getNode(sampleNodeId);

sampleNode .setBrowseName(new QualifiedName(5, “Random2”));
sampleNode .setDisplayName(new LocalizedText(“Random2”));
NodeId retNodeId=client.getAddressSpace().addNode(parentIdNode, client.getAddressSpace().getReferenceTypeId(), newNodeId,
sampleNode .getBrowseName(),sampleNode .getNodeClass(), sampleNode .getAttributes(), sampleNode .getNodeId());

this line has some error //sampleNode .setBrowseName(new QualifiedName(5, “Random1”));//
The method setBrowseName(org.opcfoundation.ua.builtintypes.QualifiedName) in the type UaNode is not applicable for the arguments (codegen.parser.QualifiedName)
Looking for your reply.
Regards

December 7, 2016
16:48, EET
Avatar
Heikki Tahvanainen
Moderator
Members

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

Hello,

I think that the original issue here was just that you didn’t know what is the syntax to define the NodeId objects that are used as a parameter in the readValue method call. It seems that this has really turned into a complex discussion about a simple concept.

If you want to read a value from any OPC UA server, you need to define the NodeId of the Node that you wish to read the value from. This is how OPC UA works. The nodes are addressed by the NodeId attribute. This functionality is completely same in all OPC UA servers and clients.

In your original post, you showed the following code example:

DataValue value = client.readValue(Identifiers.Server_ServerStatus_State);

Here the expression Identifiers.Server_ServerStatus_State is a NodeId object. You could create the same NodeId with expression new NodeId(0, 2259).

As for the code example: can you explain in words what is your objective? Are you trying to add a new node to the server’s address space?

Also, the error message shows that you have the codegen jar in your class path which should not happen. The codegen is a standalone tool.

December 8, 2016
15:06, EET
Avatar
karthi
Member
Members
Forum Posts: 16
Member Since:
November 2, 2016
sp_UserOfflineSmall Offline

Hi Heikki,

Sorry for the confusion here!! i misunderstood the previous post!!Frown.
Thanks for being patient and clearing my doubts.

1) i need to read a value from the server. instead of creating an Nodeid to read a value, what i thought is , i should create a Node in addresspace. thats why i was creating a node in server (which is wrong). now everything is clear. i am able to read a value from the server

new NodeId(5, “Counter1”);
new NodeId(5, “Random1”);
DataValue value = client.readValue( new NodeId(5, “Counter1”));
DataValue value1 = client.readValue(new NodeId(5, “Random1”));

when i run this, i am able to get the value of the counter1 and random1.

2) Reading the error while creating a node. i am not sure about the error and its solved somehow when i tired to import the files again.
when i run the same code as i posted above its shows an error message as “server does’t support the requested service”. is there a way to add a node to the server just curious to know about!!Smile

Regards
karthi

December 8, 2016
16:07, EET
Avatar
Heikki Tahvanainen
Moderator
Members

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

Hello Karthi,

Good to know that you got the reading of values to work!

As for the second point: the Simulation Server doesn’t allow clients to add new nodes.

If you are building your own server application, you can enable this feature in the Java SDK with method NodeManagerTable.setNodeManagementEnabled(true). Please see the Javadoc of that method for details.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
11 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 682

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

digitechroshni, LouieWreve, Kickbiche, karrimacvitie5, graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma

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

Administrators: admin: 1