18:05, EET
November 2, 2016
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!!!!!
11:21, EET
April 17, 2013
16:27, EET
November 2, 2016
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
17:09, EET
April 17, 2013
12:20, EET
November 2, 2016
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
16:48, EET
April 17, 2013
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:
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.
15:06, EET
November 2, 2016
Hi Heikki,
Sorry for the confusion here!! i misunderstood the previous post!!.
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!!
Regards
karthi
16:07, EET
April 17, 2013
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.
Most Users Ever Online: 1919
Currently Online:
9 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: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1