简体   繁体   English

如何使用Softing工具包从OPC UA服务器的异步读取操作的回调中的DataValue响应中获取NodeId详细信息

[英]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数据值结构都包含

  • StatusCode 的StatusCode
  • SourceTimestamp SourceTimestamp
  • ServerTimestamp ServerTimestamp
  • SourcePicoseconds SourcePicoseconds
  • ServerPicoseconds ServerPicoseconds
  • Value

An OPC UA Value structure contains OPC UA值结构包含

  • ArrayType (0 in your case = Scalar) ArrayType(您的情况下为0 =标量)
  • DataType (6 in your case = OpcUaType_Int32) 数据类型(您的情况下为6 = OpcUaType_Int32)
  • Value (from an Union depending on the ArrayType and the DataType value) 值(来自Union,取决于ArrayType和DataType值)

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.

相关问题 如何使用从 on_read 处理程序调度的最终回调将响应异步返回给调用者? - how do i return the response back to caller asynchronously using a final callback dispatched from on_read handler? 有什么方法可以减少 OPC UA 客户端中的标签浏览时间?...连接 OPC UA 服务器时 - is there any way to reduce the Tags browse time in OPC UA client?... while connected OPC UA Server 如何使用 open62541 一次使用 OPC-UA 编写多个节点? - How to write multiple nodes with OPC-UA at once using open62541? 从零开始实施Classic OPC DA Server - Implementing Classic OPC DA Server from scratch Embarcadero和免费OPA UA - Embarcadero and free opc ua 如何使用Poco C ++从HTTP服务器响应中读取图像内容? - How to read image content from an HTTP server response using Poco C++? 通过Boost Asio的async_read_some回调函数向服务器发出有关用户-客户端错误的信号 - Signal server about user-client error from Boost Asio's async_read_some callback function 从朋友方法使用async_read - Using async_read from friend method 在C ++中将数据写入管道之前,如何使客户端检查服务器是否已完成从管道的读取操作 - how to make client to check if the server is done with read operation from pipe before writing data into pipe in c++ OPC-UA open62541 sdk 运行服务器后动态添加变量节点 - OPC-UA open62541 sdk Add Variable nodes dynamically after run the server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM