![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
04/19/2020
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Hi everyone i am using C++ based OPC UA Client/Server SDK + Pub/Sub Bundle v1.7.2
i have file simpleconfig.ini in that where the credential are stored
this are the Nodes i want to read but when i change the string(s) to numeric the reading is failing
NodesToRead/size =4
NodesToRead/Variable00 =ns=2;s=Demo.Dynamic.Scalar.Float
NodesToRead/Variable01 =ns=0;s=Demo.Dynamic.Scalar.Int32
NodesToRead/Variable02 =ns=1;s=AirConditioner_1.Humidity
NodesToRead/Variable03 =ns=2;s=Demo.CTT.AllProfiles.Scalar.String
when i change the s=Demo.Dynamic.Scalar.Float to i=2255 the reading i failing can anyone suggest me
how can i pass the numeric as well as the string so i can read the
////Read code
UaStatus SampleClient::read()
{
UaStatus result;
ServiceSettings serviceSettings;
UaReadValueIds nodesToRead;
UaDataValues values;
UaDiagnosticInfos diagnosticInfos;
// read all nodes from the configuration
UaNodeIdArray nodes = m_pConfiguration->getNodesToRead();
nodesToRead.create(nodes.length());
for (OpcUa_UInt32 i = 0; i < nodes.length(); i++)
{
nodesToRead[i].AttributeId = OpcUa_Attributes_Value;
OpcUa_NodeId_CopyTo(&nodes[i], &nodesToRead[i].NodeId);
}
printf("
Reading ...
");
result = m_pSession->read(
serviceSettings,
0,
OpcUa_TimestampsToReturn_Both,
nodesToRead,
values,
diagnosticInfos);
if (result.isGood())
{
// Read service succeded - check individual status codes
for (OpcUa_UInt32 i = 0; i < nodes.length(); i++)
{
if (OpcUa_IsGood(values[i].StatusCode))
{
printf("Value[%d]: %s
", i, UaVariant(values[i].Value).toString().toUtf8());
}
else
{
printf("Read failed for item[%d] with status %s
", i, UaStatus(values[i].StatusCode).toString().toUtf8());
}
}
}
else
{
// Service call failed
printf("Read failed with status %s
", result.toString().toUtf8());
}
return result;
}
1 Guest(s)