修改 SystemConfig 和 System
This commit is contained in:
parent
a0afb0f2d6
commit
348653807e
@ -28,6 +28,9 @@ public:
|
||||
SystemConfig(const SystemConfig&) = delete;
|
||||
SystemConfig& operator=(const SystemConfig&) = delete;
|
||||
|
||||
// 允许 System 类访问构造函数
|
||||
friend class System;
|
||||
|
||||
struct Airport {
|
||||
std::string name;
|
||||
std::string iata;
|
||||
@ -93,8 +96,8 @@ public:
|
||||
} warning;
|
||||
|
||||
private:
|
||||
SystemConfig() = default; // 私有构造函数
|
||||
friend class System; // 允许 System 类访问私有成员
|
||||
// 移动构造函数到 private 区域
|
||||
SystemConfig() = default;
|
||||
};
|
||||
|
||||
// JSON 序列化支持
|
||||
|
||||
@ -13,6 +13,9 @@ System::System() {
|
||||
instance_ = this;
|
||||
std::signal(SIGINT, signalHandler);
|
||||
std::signal(SIGTERM, signalHandler);
|
||||
|
||||
// 使用单例模式获取配置实例
|
||||
auto& config = SystemConfig::instance();
|
||||
}
|
||||
|
||||
System::~System() {
|
||||
@ -90,7 +93,7 @@ void System::initializeSafetyZones() {
|
||||
// 清空现有的安全区
|
||||
safetyZones_.clear();
|
||||
|
||||
// 获取所有路口配置
|
||||
// 获取所有<EFBFBD><EFBFBD><EFBFBD>口配置
|
||||
const auto& intersections = intersection_config_.getIntersections();
|
||||
|
||||
// 创建坐标转换器
|
||||
@ -298,7 +301,7 @@ void System::processLoop() {
|
||||
if (veh.timestamp > max_timestamp) {
|
||||
max_timestamp = veh.timestamp;
|
||||
}
|
||||
Logger::debug(" - 发现新数据!");
|
||||
Logger::debug(" - 发现新<EFBFBD><EFBFBD><EFBFBD>据!");
|
||||
} else {
|
||||
Logger::debug(" - 数据未更新");
|
||||
}
|
||||
@ -445,7 +448,7 @@ void System::processCollisions(const std::vector<CollisionRisk>& risks) {
|
||||
auto processVehicle = [&](const std::string& vehicleId, const std::string& otherId) {
|
||||
switch (risk.level) {
|
||||
case RiskLevel::CRITICAL: {
|
||||
// 危险区域:立即发送告警指令
|
||||
// 危险区<EFBFBD><EFBFBD>:立即发送告警指令
|
||||
VehicleCommand cmd;
|
||||
cmd.vehicleId = vehicleId;
|
||||
cmd.type = CommandType::ALERT;
|
||||
@ -519,7 +522,7 @@ void System::processCollisions(const std::vector<CollisionRisk>& risks) {
|
||||
if (id2_controllable) {
|
||||
currentVehiclesWithRisk.insert(risk.id2);
|
||||
Logger::debug("添加当前有风险的可控车辆: ", risk.id2,
|
||||
", 当前风险车辆数量: ", currentVehiclesWithRisk.size());
|
||||
", 当<EFBFBD><EFBFBD>风险车辆数量: ", currentVehiclesWithRisk.size());
|
||||
processVehicle(risk.id2, risk.id1);
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ public:
|
||||
void broadcastVehicleCommand(const VehicleCommand& cmd);
|
||||
void broadcastTrafficLightStatus(const TrafficLightSignal& signal);
|
||||
|
||||
const SystemConfig& getSystemConfig() const { return system_config_; }
|
||||
const SystemConfig& getSystemConfig() const { return SystemConfig::instance(); }
|
||||
const IntersectionConfig& getIntersectionConfig() const { return intersection_config_; }
|
||||
|
||||
private:
|
||||
@ -84,9 +84,6 @@ private:
|
||||
std::unique_ptr<network::WebSocketServer> ws_server_;
|
||||
std::thread ws_thread_;
|
||||
|
||||
// 系统配置
|
||||
SystemConfig system_config_;
|
||||
|
||||
// 路口配置
|
||||
IntersectionConfig intersection_config_;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user