task_plan_execute_2/include/event_handler.hpp

74 lines
2.7 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef TPS_EVENT_HANDLER_HPP
#define TPS_EVENT_HANDLER_HPP
#include "app.hpp"
#include <string>
#include <vector>
// ============================================================
// 事件接收与处理模块SU-01 / SU-02 事件接收单元 & 事件处理单元)
// ============================================================
/**
* 事件接收与处理处理器。
* 负责原始事件的接收SRS-F-01-001、标准化处理SRS-F-01-002
* 以及待处理事件列表的提供SRS-F-02-001
*/
class EventHandler {
public:
EventHandler() = default;
~EventHandler() = default;
/**
* 接收原始事件数据包。
*
* @requirement(name="接收临机事件和规划事件", id="SRS-F-01-001")
* 接收来自事件生成模块或上游情报系统的事件数据包,支持 JSON/XML 格式,
* 通过 TCP/IP 协议传输,具备心跳机制和断点续传能力。
* 本方法模拟接收原始事件字符串,解析后存入内部缓存并返回确认信息。
*
* @param rawData 原始事件数据包JSON/XML 字符串)
* @param format 数据格式标识("json" 或 "xml"
* @return true 表示接收并确认成功false 表示格式无效或解析失败
*/
bool receiveEvent(const std::string& rawData, const std::string& format);
/**
* 对原始事件进行过滤、标准化转换并封装为内部模型。
*
* @requirement(name="事件数据过滤转化封装", id="SRS-F-01-002")
* 对接收到的事件数据进行字段过滤、时间戳与坐标系格式转换,
* 并封装为标准内部事件模型添加接收时间、处理节点ID等元数据。
*
* @param raw 原始事件数据
* @return NormalizedEvent 标准化后的内部事件对象
*/
NormalizedEvent processEvent(const Event& raw);
/**
* 获取尚未生成任务的待处理事件列表。
*
* @requirement(name="接收待处理事件列表", id="SRS-F-02-001")
* 从事件处理模块获取尚未生成任务的事件集合,用于后续任务生成流程。
*
* @return 待处理事件列表
*/
std::vector<NormalizedEvent> getPendingEvents() const;
/**
* 获取当前缓存的所有原始事件。
*/
std::vector<Event> getAllEvents() const;
private:
std::vector<Event> rawEvents_; ///< 原始事件缓存
std::vector<NormalizedEvent> normalized_; ///< 标准化事件缓存
/**
* 校验事件数据合法性(基础字段检查)。
*/
bool validateEvent(const std::string& rawData, const std::string& format);
};
#endif // TPS_EVENT_HANDLER_HPP