From 38bb940113fb57950656a63971cb27954c48126b Mon Sep 17 00:00:00 2001 From: zhaoxi <535394140@qq.com> Date: Sun, 16 Feb 2025 15:36:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20=E6=9B=B4=E6=96=B0=20OPC=20UA=20?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=AD=97=E9=9D=A2=E9=87=8F=E5=88=B0?= =?UTF-8?q?=20Variable=20=E8=BD=AC=E6=8D=A2=E6=9E=84=E9=80=A0=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/opcua/include/rmvl/opcua/variable.hpp | 6 +++--- modules/opcua/test/test_opcua_client.cpp | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/opcua/include/rmvl/opcua/variable.hpp b/modules/opcua/include/rmvl/opcua/variable.hpp index f2fd8f4..8c88550 100644 --- a/modules/opcua/include/rmvl/opcua/variable.hpp +++ b/modules/opcua/include/rmvl/opcua/variable.hpp @@ -166,7 +166,7 @@ class RMVL_EXPORTS_W Variable final * @param[in] str 字符串 */ template - Variable(const char (&str)[N]) : Variable(std::string(str, N)) {} + Variable(const char (&str)[N]) : Variable(std::string(str)) {} /** * @brief 列表构造 @@ -367,8 +367,8 @@ struct RMVL_EXPORTS_W_AG DataSourceVariable RMVL_W_RW std::string display_name{}; //! 变量的描述 RMVL_W_RW std::string description{}; - //! 访问性 - RMVL_W_RW uint8_t access_level{}; + //! 访问性,默认为只读 + RMVL_W_RW uint8_t access_level{1U}; /** * @brief 数据源 Read 回调函数 diff --git a/modules/opcua/test/test_opcua_client.cpp b/modules/opcua/test/test_opcua_client.cpp index 12c6041..df836f7 100644 --- a/modules/opcua/test/test_opcua_client.cpp +++ b/modules/opcua/test/test_opcua_client.cpp @@ -198,11 +198,13 @@ TEST(OPC_UA_ClientTest, event_monitor) srv.addEventTypeNode(etype); rm::Client cli("opc.tcp://127.0.0.1:5010"); - std::string source_name; + std::string source_name{}; + std::string messgae{}; int aaa{}; - cli.monitor({"SourceName", "aaa"}, [&](rm::ClientView, const rm::Variables &fields) { - source_name = fields[0].cast(); - aaa = fields[1]; + cli.monitor({"Message", "SourceName", "aaa"}, [&](rm::ClientView, const rm::Variables &fields) { + messgae = fields[0].cast(); + source_name = fields[1].cast(); + aaa = fields[2]; }); // 触发事件 auto event = rm::Event::makeFrom(etype);