Hi,
I'm trying to read structure with client. I'm using the client_cpp_sdk project.
I'm using OPC UA Demo Server.
Particullary, I'm trying to read the Variable (CarExtras under Root->Objects->Demo->000_Static->Scalar->Structures) with Identifier = Demo.Static.Scalar.CarExtras IdentifierType = String, NamespaceIndex = 2.
In UAExpert I see that the Node is a structure with 4 field: [0] air conditioner, [1] super charged, [2] launch control, [3] navigation system.
Using client_cpp_sdk example, I see that the same structure CarExtras has 2 fields with the name Value and ValidBits.
Why is the same structure seen in two different ways?
Thanks,
Lorenzo
Client SDK: Reading Structure
Moderator: uasdkcpp
- Support Team
- Hero Member
- Posts: 3071
- Joined: 18 Mar 2011, 15:09
Re: Client SDK: Reading Structure
Hello Lorenzo,
the DataType CarExtras is an OptionSet. UaExpert shows all options (so that they can also be written).
The console client just show the seleced options.
option on index 0 and 4 is turned off.
option[1] (super charged) and option[2] (launch control) is set -> value is 6
ValidBits is 0x0F because all fields have a meaning and can be used by the client.
This is all correct so far - however the output is not easy to read. That is why we changed the output for OptionSets in the console client. It will be available in the next service release:
result:
the DataType CarExtras is an OptionSet. UaExpert shows all options (so that they can also be written).
The console client just show the seleced options.
option on index 0 and 4 is turned off.
option[1] (super charged) and option[2] (launch control) is set -> value is 6
ValidBits is 0x0F because all fields have a meaning and can be used by the client.
This is all correct so far - however the output is not easy to read. That is why we changed the output for OptionSets in the console client. It will be available in the next service release:
Code: Select all
void printGenericOptionSetValue(const UaGenericOptionSetValue& value)
{
UaOptionSetDefinition definition = value.optionSetDefinition();
for (int i = 0; i < definition.childrenCount(); i++)
{
UaLocalizedText field = definition.child(i);
// Get field name
UaString sFieldName = field.toString();
// Get field value
UaVariant vFieldValue = value.value(i);
printf(" [%d] %s = %s\n", i, sFieldName.toUtf8(), vFieldValue.toString().toUtf8());
}
}
Code: Select all
** UaSession::read result **************************************
Variable Demo.Static.Scalar.CarExtras with value:
[0] air conditioner = false
[1] super charged = true
[2] launch control = true
[3] navigation system = false
****************************************************************
Best regards
Unified Automation Support Team
Unified Automation Support Team