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);