image shows the uint32 value but i need the NodeId details too, which is "Counter1" as in the NodeId in readAsync 我正在使用Softing OPC UA工具包来开发客户端。使用session-> readAsync()我尝试从OPC UA服务器读取值,使用请求的DataValue的向量调用回调方法onReadComplete,我可以从DataValue中获取值,但是无法使用namespaceIndex,indentifierType,标识符。在Visual Studio调试器中,这些值无法读取内存。
读取异步:
std::vector<ReadValueId> readValueId1s;
ReadValueId ReadValueId1;
ReadValueId1.setNodeId(NodeId(2, _T("Counter1")));
ReadValueId1.setAttributeId(EnumAttributeId_Value);
readValueId1s.push_back(ReadValueId1);
// read the variable asynchronously
result = session->readAsync(pRdReq, EnumTimestampsToReturn_Both,
readValueId1s, 0, pRdReq->getTransId());
回调方法:
void TestSession::onReadComplete(void* requestHandle, EnumStatusCode
serviceResult, std::vector<DataValue>& values)
{
for (unsigned int i = 0; i < values.size(); i++) {
std::wcout << values[i].getValue()->getNodeId().toString() << std::endl;
}
}
答案 0 :(得分:1)
请看看OPC UA Specification Part 4 - Services第5.10.2章已读
OPC UA读取响应包含一个DataValue数组。每个OPC UA数据值结构都包含
OPC UA值结构包含
实际上,您的情况是Int32 Variant Union值= 46132370
修改
ReadResponse DataValue数组中DataValue的顺序与您发送的ReadRequest中的Read NodeId的顺序匹配。然后,您应该在发送ReadRequest之前保存信息,以了解DataValue [“ X”]是哪个NodeId的值。