I have this data structure.
The example from the 1st lesson is being executed. I connect to the server and read the time from it.
But I would like to get the historical data of a certain tag (TNPZ.P_NEFT.R1.M). What do I need to do?
Code: Select all
UaStatus SampleClient::read()
{
UaStatus result;
ServiceSettings serviceSettings;
UaReadValueIds nodeToRead;
UaDataValues values;
UaDiagnosticInfos diagnosticInfos;
nodeToRead.create(1);
nodeToRead[0].AttributeId = OpcUa_Attributes_Value;
nodeToRead[0].NodeId.Identifier.Numeric = OpcUaId_Server_ServerStatus_CurrentTime;
printf("\nReading ...\n");
result = m_pSession->read(
serviceSettings,
0,
OpcUa_TimestampsToReturn_Both,
nodeToRead,
values,
diagnosticInfos);
if (result.isGood())
{
if (OpcUa_IsGood(values[0].StatusCode))
{
printf("ServerStatusCurrentTime: %s\n", UaVariant(values[0].Value).toString().toUtf8());
}
else
{
printf("Read failed for item[0] with status %s\n", UaStatus(values[0].StatusCode).toString().toUtf8());
}
}
else
{
printf("Read failed with status %s\n", result.toString().toUtf8());
}
return result;
}