diff --git a/modules/opcua/include/rmvl/opcua/client.hpp b/modules/opcua/include/rmvl/opcua/client.hpp index 5ecbdb4..2d81d2a 100644 --- a/modules/opcua/include/rmvl/opcua/client.hpp +++ b/modules/opcua/include/rmvl/opcua/client.hpp @@ -222,7 +222,7 @@ class RMVL_EXPORTS_W Client /** * @brief 直接以底层数据调用指定对象节点中的方法 - * + * * @param[in] obj_nd 对象节点 * @param[in] name 方法名 * @param[in] args 方法的所有传入参数 @@ -315,7 +315,7 @@ class RMVL_EXPORTS_W ClientTimer final * @param[in] period 定时器周期,单位:毫秒 `ms` * @param[in] callback 定时器回调函数 */ - RMVL_W ClientTimer(ClientView cv, double period, std::function callback); + RMVL_W ClientTimer(ClientView cv, double period, std::function callback); //! @cond ClientTimer(const ClientTimer &) = delete; @@ -332,9 +332,9 @@ class RMVL_EXPORTS_W ClientTimer final RMVL_W void cancel(); private: - ClientView _cv; //!< 客户端视图 - std::function _cb; //!< 定时器回调函数 - uint64_t _id{}; //!< 定时器 ID + ClientView _cv; //!< 客户端视图 + std::function _cb; //!< 定时器回调函数 + uint64_t _id{}; //!< 定时器 ID }; //! @} opcua diff --git a/modules/opcua/include/rmvl/opcua/variable.hpp b/modules/opcua/include/rmvl/opcua/variable.hpp index 99ae397..f2fd8f4 100644 --- a/modules/opcua/include/rmvl/opcua/variable.hpp +++ b/modules/opcua/include/rmvl/opcua/variable.hpp @@ -150,14 +150,14 @@ class RMVL_EXPORTS_W Variable final */ template , typename = std::enable_if_t>> RMVL_W_SUBST("V") - Variable(Tp val) : access_level(3U), _value(val), _data_type(DataType(typeid(DecayT))), _size(1) {} + Variable(Tp val) : _value(val), _data_type(DataType(typeid(DecayT))), _size(1) {} /** * @brief 字符串构造 * * @param[in] str 字符串 */ - RMVL_W Variable(const std::string &str) : access_level(3U), _value(str), _data_type(DataType(typeid(std::string))), _size(1) {} + RMVL_W Variable(const std::string &str) : _value(str), _data_type(DataType(typeid(std::string))), _size(1) {} /** * @brief 字符串字面量构造 @@ -176,7 +176,7 @@ class RMVL_EXPORTS_W Variable final */ template && !std::is_same_v>> RMVL_W_SUBST("V_List") - Variable(const std::vector &arr) : access_level(3U), _value(arr), _data_type(DataType(typeid(Tp))), _size(static_cast(arr.size())) {} + Variable(const std::vector &arr) : _value(arr), _data_type(DataType(typeid(Tp))), _size(static_cast(arr.size())) {} /** * @brief 从变量类型创建新的变量节点 @@ -257,7 +257,7 @@ class RMVL_EXPORTS_W Variable final RMVL_W inline uint32_t size() const { return _size; } private: - explicit Variable(const VariableType &vtype) : access_level(3U), _type(vtype), _value(vtype.data()), _data_type(vtype.getDataType()), _size(vtype.size()) {} + explicit Variable(const VariableType &vtype) : _type(vtype), _value(vtype.data()), _data_type(vtype.getDataType()), _size(vtype.size()) {} public: //! 命名空间索引,默认为 `1` @@ -283,7 +283,7 @@ class RMVL_EXPORTS_W Variable final //! 变量的描述 RMVL_W_RW std::string description{}; //! 访问性 - RMVL_W_RW uint8_t access_level{}; + RMVL_W_RW uint8_t access_level{3U}; private: //! 变量类型 diff --git a/modules/opcua/src/client.cpp b/modules/opcua/src/client.cpp index 2b6eb00..a2578a9 100644 --- a/modules/opcua/src/client.cpp +++ b/modules/opcua/src/client.cpp @@ -376,13 +376,13 @@ bool ClientView::write(const NodeId &nd, const Variable &val) const { return cli /////////////////////// 客户端定时器 /////////////////////// -static void timer_cb(UA_Client *p_server, void *data) +static void timer_cb(UA_Client *, void *data) { - auto &func = *reinterpret_cast *>(data); - func(p_server); + auto &func = *reinterpret_cast *>(data); + func(); } -ClientTimer::ClientTimer(ClientView cv, double period, std::function callback) : _cv(cv), _cb(callback) +ClientTimer::ClientTimer(ClientView cv, double period, std::function callback) : _cv(cv), _cb(callback) { auto status = UA_Client_addRepeatedCallback(_cv.get(), timer_cb, &_cb, period, &_id); if (status != UA_STATUSCODE_GOOD) diff --git a/modules/opcua/test/test_opcua_client.cpp b/modules/opcua/test/test_opcua_client.cpp index 56b4428..12c6041 100644 --- a/modules/opcua/test/test_opcua_client.cpp +++ b/modules/opcua/test/test_opcua_client.cpp @@ -227,7 +227,7 @@ TEST(OPC_UA_Client, timer_test) std::this_thread::sleep_for(10ms); rm::Client cli("opc.tcp://127.0.0.1:5015"); int times{}; - auto timer = rm::ClientTimer(cli, 10, [&](rm::ClientView) { times++; }); + auto timer = rm::ClientTimer(cli, 10, [&]() { times++; }); std::this_thread::sleep_for(60ms); cli.spinOnce(); std::this_thread::sleep_for(60ms);