

9:12, EEST
July 25, 2017

Hello ,
I have to read data from server using a client code which i have developed in VS c++ . I want to know if i can pass a variable in the server node to read instead of hardcoding it.
I am pasting the sample code below.
I am getting BadIDUnkown as the output. Please HELP!!
UaStatus result;
ServiceSettings serviceSettings;
UaReadValueIds nodeToRead;
UaDataValues values;
UaDiagnosticInfos diagnosticInfos;
// Configure one node to read
// We read the value of the ServerStatus -> CurrentTime
nodeToRead.create(1);
nodeToRead[0].AttributeId = OpcUa_Attributes_Value;
nodeToRead[0].NodeId.Identifier.Numeric = OpcUaId_Server_ServerStatus_CurrentTime; //This works fine
nodeToRead[0].NodeId.Identifier.Numeric = (int) settings.currentTime; //But, this gives an ERROR. settings.currentTime is a charecter array inside a structure. It contains “OpcUaId_Server_ServerStatus_CurrentTime” but I am not able to read this.
printf(“
Reading …
“);
result = m_pSession->read(
serviceSettings,
0,
OpcUa_TimestampsToReturn_Both,
nodeToRead,
values,
diagnosticInfos);
if (result.isGood())
{
// Read service succeded – check status of read value
if (OpcUa_IsGood(values[0].StatusCode))
{
printf(“ServerStatus_State: %s
“, UaVariant(values[0].Value).toString().toUtf8());
}
else
{
printf(“Read failed for item[0] with status %s
“, UaStatus(values[0].StatusCode).toString().toUtf8());
}
}
else
{
// Service call failed
printf(“Read failed with status %s
“, result.toString().toUtf8());
}
15:51, EEST

December 21, 2011

7:05, EEST
July 25, 2017

1 Guest(s)
