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
Most Users Ever Online: 1919
Currently Online:
16 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 726
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_galleryModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1