添加了装置预升级校验流程
This commit is contained in:
@@ -1713,10 +1713,10 @@ bool ClientManager::read_devversion_action_to_device(const std::string& identifi
|
||||
if (ctx->device_info.device_id == identifier ||
|
||||
ctx->device_info.mac == identifier)
|
||||
{
|
||||
// 生成定值描述报文
|
||||
// 生成版本配置报文
|
||||
auto packet = generate_machineversion_message();
|
||||
|
||||
// 添加动作到队列 (状态: 读取文件目录)
|
||||
// 添加动作到队列 (状态: 读取装置版本信息)
|
||||
ctx->add_action(DeviceState::READING_DEVVERSION, packet);
|
||||
|
||||
// 如果当前空闲则立即执行
|
||||
@@ -1730,6 +1730,39 @@ bool ClientManager::read_devversion_action_to_device(const std::string& identifi
|
||||
return false; // 设备未找到
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 生成预升级校验报文
|
||||
* @param path 预校验文件路径
|
||||
* @return 包含完整报文的字节向量
|
||||
*/
|
||||
bool ClientManager::set_preupgrade_action_to_device(const std::string& identifier, const std::string& path) {
|
||||
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->set_preupgrade_filepath(path);
|
||||
// 生成预升级报文
|
||||
auto packet = generate_preupgrade_message();
|
||||
|
||||
// 添加动作到队列 (状态: 预升级校验)
|
||||
ctx->add_action(DeviceState::SET_PREUPGRADE, packet);
|
||||
|
||||
// 如果当前空闲则立即执行
|
||||
if (ctx->current_state_ == DeviceState::IDLE) {
|
||||
ctx->process_next_action();
|
||||
}
|
||||
|
||||
return true; // 成功添加
|
||||
}
|
||||
}
|
||||
return false; // 设备未找到
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 生成装置控制命令报文
|
||||
* @param type 命令类型 1-装置复位,2-启动录波,3-启动200ms数据记录,4-启动3秒数据记录
|
||||
@@ -1940,6 +1973,7 @@ bool ClientManager::update_current_filename(const std::string& identifier,
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取当前正在下载的文件名
|
||||
std::string ClientManager::get_current_filename(const std::string& identifier) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
for (auto& pair : clients_) {
|
||||
@@ -1950,4 +1984,17 @@ std::string ClientManager::get_current_filename(const std::string& identifier) {
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//获取用于预校验的文件路径
|
||||
std::string ClientManager::get_preupgrade_filepath(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) {
|
||||
return ctx->get_preupgrade_filepath();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
Reference in New Issue
Block a user