[英]How to get NodeId details from DataValue response in callback of async read operation from OPC UA server using Softing toolkit
image shows the uint32 value but i need the NodeId details too, which is "Counter1" as in the NodeId in readAsync I am using Softing OPC UA toolkit to develop a client. 该图显示了uint32值,但我也需要NodeId详细信息,就像readAsync中的NodeId一样,它是“ Counter1”。我正在使用Softing OPC UA工具包来开发客户端。 With session->readAsync() i try to read value from OPC UA server, the callback method onReadComplete is invoked with the vector of DataValue requested for, i could get the value from the DataValue but unable to get the NodeId with namespaceIndex, indentifierType, identifier.
使用session-> readAsync()我尝试从OPC UA服务器读取值,使用请求的DataValue的向量调用回调方法onReadComplete,我可以从DataValue中获取值,但无法使用namespaceIndex,indentifierType,标识符。 In Visual Studio debugger these values are Unable to read memory.
在Visual Studio调试器中,这些值无法读取内存。
read async: 异步读取:
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());
callback method: 回调方法:
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;
}
}
Please take a look at the OPC UA Specification Part 4 - Services Chapter 5.10.2 Read 请查看OPC UA规范的第4部分-服务第5.10.2章,阅读
An OPC UA Read Response contains an array of DataValue. OPC UA读取响应包含一个DataValue数组。 Each OPC UA DataValue structure contains
每个OPC UA数据值结构都包含
An OPC UA Value structure contains OPC UA值结构包含
So actually in your case the value is Int32 Variant Union value = 46132370 所以实际上您的情况是Int32 Variant Union值= 46132370
Edit 编辑
The order of the DataValue in the ReadResponse DataValue Array match with the order of Read NodeId from the ReadRequest you have sent. ReadResponse DataValue数组中DataValue的顺序与您发送的ReadRequest中的Read NodeId的顺序匹配。 You should then save the information before sending the ReadRequest in order to know for which NodeId the DataValue ["X"] is the value.
然后,您应该在发送ReadRequest之前保存信息,以便知道DataValue [“ X”]是哪个NodeId的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.