Hallo,
i am trying to read the Value of a Variable which is a part of an Object. This Variable has an String Node ID.
This is my Method for it:
Bild "string_readproblempsozb.jpg" anzeigen.
My Goal is to Read The Value from the Variable "MeasuredBoltWeight" in the Object "Schraubengewicht".
I understand that i set The NamespaceIndex to the Value of "2" and the NodeId (as seen in UAExpert) to "Schraubengewicht.MeasuredBoltWeight". But the Compiler keeps telling me this Error Message C2679.
What am I doing wrong?
Thanks for the help
Spezies31
Problem to Read a Object->Variable with a String Node ID
Moderator: uasdkcpp
-
- Sr. Member
- Posts: 15
- Joined: 07 Dec 2015, 16:36
-
- Sr. Member
- Posts: 15
- Joined: 07 Dec 2015, 16:36
Re: Problem to Read a Object->Variable with a String Node ID
Hello,
Just an update to my situation.
I declared an Opcua_String Variable and gave it the data "Test".
I changed the Variable i want to read to the "Test" variable because it is not part of an Object. Also the String ist much shorter.
But i Still got the "BadNodeIdUnkown" status. I don't understand why.
In the Debugger i only see "T" as data of the OpcUa_String Variable. But as strContent i see "Test". Could this be the Problem?
With Debugger:
Thanks for the help in advance.
Spezies31
Just an update to my situation.
I declared an Opcua_String Variable and gave it the data "Test".
I changed the Variable i want to read to the "Test" variable because it is not part of an Object. Also the String ist much shorter.
But i Still got the "BadNodeIdUnkown" status. I don't understand why.
In the Debugger i only see "T" as data of the OpcUa_String Variable. But as strContent i see "Test". Could this be the Problem?
With Debugger:
Thanks for the help in advance.
Spezies31
-
- Sr. Member
- Posts: 15
- Joined: 07 Dec 2015, 16:36
Re: Problem to Read a Object->Variable with a String Node ID
Hello,
me again with the solution of the problem.
Maybe somebody has the same issue like me and is happy to find the solution.
It seems that you specifically need to configure the Read Request if you want to read a variable with a String as NodeId Identifier.
Note that if you have an Numeric NodeId Identifier you have not to specify the IdentifierType. If you want to read a Variable with an string NodeId Identifier it is necessary.
I would like an answer to that issue because i find it very confusing. My opinion how it should be is to configure the identifiert type all the time.
Here is the Code:
[img=http://abload.de/thumb/string_readproblem_gevluym.jpg]
yours sincerely
Spezies31
me again with the solution of the problem.
Maybe somebody has the same issue like me and is happy to find the solution.
It seems that you specifically need to configure the Read Request if you want to read a variable with a String as NodeId Identifier.
Note that if you have an Numeric NodeId Identifier you have not to specify the IdentifierType. If you want to read a Variable with an string NodeId Identifier it is necessary.
I would like an answer to that issue because i find it very confusing. My opinion how it should be is to configure the identifiert type all the time.
Here is the Code:
[img=http://abload.de/thumb/string_readproblem_gevluym.jpg]
yours sincerely
Spezies31
- Support Team
- Hero Member
- Posts: 3078
- Joined: 18 Mar 2011, 15:09
Re: Problem to Read a Object->Variable with a String Node ID
Hi,
This is a very basic programming language problem.
Services parameters like ReadValueIds for Read are arrays of C structures. You cannot assign complex values to a C structure element with '='.
The C++ class provides helper classes for dealing with the C structures and arrays of C structures. The class UaReadValueIds takes care about allocation and memory management of an array of OpcUa_ReadValueId structures.
There are other classes like UaNodeId that do this for built-in structures like a NodeId. They have constructors for setting the right values e.g. for different identifier types of a NodeId and they provide methods like UaNodeId::copyTo() to copy the content into a C structure.
See the following example:
Best Regards,
Unified Automation Support Team
This is a very basic programming language problem.
Services parameters like ReadValueIds for Read are arrays of C structures. You cannot assign complex values to a C structure element with '='.
The C++ class provides helper classes for dealing with the C structures and arrays of C structures. The class UaReadValueIds takes care about allocation and memory management of an array of OpcUa_ReadValueId structures.
There are other classes like UaNodeId that do this for built-in structures like a NodeId. They have constructors for setting the right values e.g. for different identifier types of a NodeId and they provide methods like UaNodeId::copyTo() to copy the content into a C structure.
See the following example:
Code: Select all
UaReadValueIds nodesToRead;
nodesToRead.create(1);
nodesToRead[0].AttributeId = OpcUa_Attributes_Value;
UaNodeId myNodeId("MyStringIdentifier", 2);
myNodeId.copyTo(&nodesToRead[0].NodeId);
Unified Automation Support Team