新增了装置重启命令的校验和执行流程。
This commit is contained in:
@@ -1730,6 +1730,38 @@ bool ClientManager::read_devversion_action_to_device(const std::string& identifi
|
||||
return false; // 设备未找到
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 生成装置控制命令报文
|
||||
* @param type 命令类型 1-装置复位,2-启动录波,3-启动200ms数据记录,4-启动3秒数据记录
|
||||
* @param ctrlflag 命令校验 首次传入0x00 接收校验应答后 0x01执行 0x02取消
|
||||
* @return 包含完整报文的字节向量
|
||||
*/
|
||||
bool ClientManager::set_ctrl_action_to_device(const std::string& identifier, uint8_t type, uint8_t ctrlflag) {
|
||||
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)
|
||||
{
|
||||
// 生成控制命令报文
|
||||
auto packet = generate_control_message(type, ctrlflag);
|
||||
|
||||
// 添加动作到队列 (状态: 设置装置控制命令)
|
||||
ctx->add_action(DeviceState::SET_CTRL, packet);
|
||||
|
||||
// 如果当前空闲则立即执行
|
||||
if (ctx->current_state_ == DeviceState::IDLE) {
|
||||
ctx->process_next_action();
|
||||
}
|
||||
|
||||
return true; // 成功添加
|
||||
}
|
||||
}
|
||||
return false; // 设备未找到
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 补招事件日志动作
|
||||
* @param Time1 起始时间
|
||||
|
||||
Reference in New Issue
Block a user