添加了文件管理:文件目录读取,文件下载功能

This commit is contained in:
zw
2025-07-30 13:52:52 +08:00
parent fff1312c6e
commit cc9d651b5a
5 changed files with 265 additions and 9 deletions

View File

@@ -992,6 +992,7 @@ bool ClientManager::clear_float_cache(const std::string& identifier) {
return false;
}
//实时数据调用
bool ClientManager::set_real_state_count(const std::string& identifier, int count, ushort point_id) {
std::lock_guard<std::mutex> lock(mutex_);
@@ -1020,6 +1021,66 @@ bool ClientManager::set_real_state_count(const std::string& identifier, int coun
return false;
}
//读取文件目录调用
bool ClientManager::add_file_menu_action_to_device(
const std::string& identifier,
const std::string& file_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)
{
// 生成文件目录读取报文
auto packet = generate_getfilemenu_message(file_path);
// 添加动作到队列 (状态: 读取文件目录)
ctx->add_action(DeviceState::READING_FILEMENU, packet);
// 如果当前空闲则立即执行
if (ctx->current_state_ == DeviceState::IDLE) {
ctx->process_next_action();
}
return true; // 成功添加
}
}
return false; // 设备未找到
}
//文件下载调用
bool ClientManager::add_file_download_action_to_device(
const std::string& identifier,
const std::string& file_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)
{
// 生成下载请求报文 (帧序号固定为1代表开始新文件的下载)
auto downloadMsg = generate_downloadfile_message(1, file_path);
// 添加动作到队列 (状态: 读取文件目录)
ctx->add_action(DeviceState::READING_FILEDATA, downloadMsg);
// 如果当前空闲则立即执行
if (ctx->current_state_ == DeviceState::IDLE) {
ctx->process_next_action();
}
return true; // 成功添加
}
}
return false; // 设备未找到
}
bool ClientManager::get_point_scale_and_pttype(const std::string& identifier,
ushort nCpuNo,
std::string& out_scale,