c++ - 使用C++ SDK从OPCUA读取自定义节点-字符串作为节点标识符

标签 c++ sdk opc-ua

我正在使用OPC UAs C++ SDK并尝试读取自定义节点。

在执行提供的示例脚本时,可以很好地读取服务器时间戳(遵循第1课:https://documentation.unified-automation.com/uasdkcpp/1.5.5/html/L3GettingStartedClientLesson01.html)

现在,我试图读取一个自定义节点,其中节点标识符是一个字符串-UaExpert的屏幕截图:

enter image description here

但是我在实现它时遇到了问题:

UaStatus SampleClient::read()
{
    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;
   nodeToRead[0].AttributeId = 1;
   nodeToRead[0].NodeId.Identifier.String = "DISPLAY_VOLTAGE"; //"cant find operator which supports 
                                                               //type const char[16]"
   ...

我也不确定AttributeIde是否为NodeID的命名空间-但我没有找到其他名为“AttributeId”的东西。

可能我需要在这里实现自己的属性-但我不知道如何:
typedef struct _OpcUa_String
{
    OpcUa_UInt          uReserved1;     /* Content is private to String Implementation */
#if OPCUA_STRING_SHORT
    OpcUa_UInt16        uReserved2;     /* Content is private to String Implementation */
#else /* OPCUA_STRING_SHORT */
    OpcUa_UInt32        uReserved2;     /* Content is private to String Implementation */
#endif /* OPCUA_STRING_SHORT */
    OpcUa_Void*         uReserved4;     /* Content is private to String Implementation */
} OpcUa_String, *OpcUa_pString;
#endif

希望你们能给我提示如何解决这个问题。

提前致谢!

最佳答案

我找到了一种可行的方法:

nodeToRead[0].AttributeId = OpcUa_Attributes_Value;
UaNodeId volt(UaString("DISPLAY_VOLTAGE"), 1); //("Identifierstring", Namespace)
volt.copyTo(&nodeToRead[0].NodeId);

关于c++ - 使用C++ SDK从OPCUA读取自定义节点-字符串作为节点标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61610391/

相关文章:

java - Android - SharedPreferences - 无法获得我的值(value)

java - 如何测试 Milo 客户端与服务器的连接是否确实使用加密?

c++ - C++中的空指针是什么?

c++ - base 和 derived 之间的 "IS A"关系是什么意思?

c++ - wxDialog 与 wxMenuBar

java - 如何通过Java程序连接opc kepware服务器,无需用户名和密码?

linux - OPC Publisher 模块无法在我的 Ubuntu VM 上作为边缘模块启动

C++ OpenCV 捕获 easycap usb cam

android - 有没有办法在标准 Android 模拟器中安装 Sense UI?

ios - Rubymotion x Facebook iOS SDK//安装问题//[!] 无法找到 `Facebook-iOS-SDK` 的规范