添加手动对时类型
This commit is contained in:
@@ -1630,7 +1630,7 @@ bool ClientManager::set_interfixedvalue_action_to_device(const std::string& iden
|
||||
return false; // 设备未找到
|
||||
}
|
||||
|
||||
//读取装置运行信息
|
||||
//读取装置运行信息(外部触发调用)
|
||||
bool ClientManager::read_runninginformation_action_to_device(const std::string& identifier) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
@@ -1657,6 +1657,35 @@ bool ClientManager::read_runninginformation_action_to_device(const std::string&
|
||||
return false; // 设备未找到
|
||||
}
|
||||
|
||||
//装置主动对时动作(外部触发调用)
|
||||
bool ClientManager::set_righttime_action_to_device(const std::string& identifier) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
// 查找匹配的设备
|
||||
for (auto& pair : clients_) {
|
||||
auto& ctx = pair.second;
|
||||
if ((ctx->device_info.device_id == identifier ||
|
||||
ctx->device_info.mac == identifier) && ctx->device_info.righttime && isVersionGreaterOrEqual(ctx->dev_CloudProtocolVer, "V1.5"))
|
||||
{
|
||||
// 获取当前时间
|
||||
auto now = std::chrono::system_clock::now();
|
||||
std::time_t time = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm tm_time = *std::localtime(&time);
|
||||
auto sendbuff = generate_righttime_message(tm_time);//组装装置对时报文
|
||||
// 添加动作到队列 (状态: 手动对时)
|
||||
ctx->add_action(DeviceState::SET_RIGHTTIME_2, sendbuff);//将该状态以及待发送报文存入队列
|
||||
|
||||
// 如果当前空闲则立即执行
|
||||
if (ctx->current_state_ == DeviceState::IDLE) {
|
||||
ctx->process_next_action();
|
||||
}
|
||||
|
||||
return true; // 成功添加
|
||||
}
|
||||
}
|
||||
return false; // 设备未找到
|
||||
}
|
||||
|
||||
//读取装置版本配置信息
|
||||
bool ClientManager::read_devversion_action_to_device(const std::string& identifier) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
Reference in New Issue
Block a user