Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新 OPC UA 字符串字面量到 Variable 转换构造函数的写法 #228

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/opcua/include/rmvl/opcua/variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class RMVL_EXPORTS_W Variable final
* @param[in] str 字符串
*/
template <std::size_t N>
Variable(const char (&str)[N]) : Variable(std::string(str, N)) {}
Variable(const char (&str)[N]) : Variable(std::string(str)) {}

/**
* @brief 列表构造
Expand Down Expand Up @@ -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 回调函数
Expand Down
10 changes: 6 additions & 4 deletions modules/opcua/test/test_opcua_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>();
aaa = fields[1];
cli.monitor({"Message", "SourceName", "aaa"}, [&](rm::ClientView, const rm::Variables &fields) {
messgae = fields[0].cast<std::string>();
source_name = fields[1].cast<std::string>();
aaa = fields[2];
});
// 触发事件
auto event = rm::Event::makeFrom(etype);
Expand Down