75 lines
2.5 KiB
C++
75 lines
2.5 KiB
C++
#ifndef BATTLEFIELD_CORE_DISPATCH_HPP
|
||
#define BATTLEFIELD_CORE_DISPATCH_HPP
|
||
|
||
#include <string>
|
||
#include <vector>
|
||
#include <chrono>
|
||
#include <cstdint>
|
||
#include "core/plan.hpp"
|
||
|
||
namespace battlefield {
|
||
|
||
/// @brief 指令包数据结构,对应 IF-03 输出格式
|
||
struct CmdPacket {
|
||
std::string packetId; ///< 指令包ID
|
||
std::string planId; ///< 关联方案ID
|
||
std::string targetUnit; ///< 目标执行单元
|
||
std::string payload; ///< 指令载荷(JSON)
|
||
std::chrono::system_clock::time_point issueTime; ///< 下发时间
|
||
};
|
||
|
||
/// @brief 分发日志记录,对应 T_DISPATCH_LOG
|
||
struct DispatchLog {
|
||
std::string logId; ///< 日志ID
|
||
std::string planId; ///< 方案ID
|
||
std::string action; ///< 操作描述
|
||
std::chrono::system_clock::time_point timestamp; ///< 时间戳
|
||
bool success{true}; ///< 是否成功
|
||
};
|
||
|
||
/// @brief 监控状态快照
|
||
struct MonitorStatus {
|
||
int32_t totalTasks{0}; ///< 总任务数
|
||
int32_t completedTasks{0}; ///< 已完成
|
||
int32_t inProgressTasks{0}; ///< 进行中
|
||
int32_t failedTasks{0}; ///< 失败
|
||
double progressPercent{0.0}; ///< 总体进度百分比
|
||
};
|
||
|
||
/// @brief 分发监控模块(覆盖 SRS-F-06-001 ~ SRS-F-06-003)
|
||
class DispatchMonitor {
|
||
public:
|
||
/// @brief 驱动最终方案的分发执行(对应 IF-03 / IF-05)
|
||
/// @param plan 待分发的最终方案
|
||
/// @param targetUnit 目标执行单元
|
||
/// @return 生成的指令包
|
||
CmdPacket DispatchPlan(const Plan& plan, const std::string& targetUnit);
|
||
|
||
/// @brief 获取当前状态监控仪表盘数据
|
||
/// @return MonitorStatus 结构体
|
||
MonitorStatus GetMonitorStatus() const;
|
||
|
||
/// @brief 构建总览看板数据(含反馈闭环,触发重规划标识)
|
||
/// @return 看板摘要字符串
|
||
std::string GetDashboardData() const;
|
||
|
||
/// @brief 记录分发日志
|
||
/// @param planId 方案ID
|
||
/// @param action 操作描述
|
||
/// @param success 是否成功
|
||
void LogDispatch(const std::string& planId, const std::string& action, bool success);
|
||
|
||
/// @brief 模拟推进执行进度
|
||
/// @param completed 新完成的任务数
|
||
void AdvanceProgress(int32_t completed);
|
||
|
||
private:
|
||
std::vector<CmdPacket> issuedPackets_; ///< 已下发的指令包
|
||
std::vector<DispatchLog> logs_; ///< 分发日志
|
||
MonitorStatus status_; ///< 当前监控状态
|
||
};
|
||
|
||
} // namespace battlefield
|
||
|
||
#endif // BATTLEFIELD_CORE_DISPATCH_HPP
|