解决循环引用

This commit is contained in:
Tian jianyong 2024-12-20 15:14:39 +08:00
parent 7d2733e5cf
commit d319620a2a
2 changed files with 11 additions and 11 deletions

View File

@ -93,7 +93,7 @@ void System::initializeSafetyZones() {
// 清空现有的安全区 // 清空现有的安全区
safetyZones_.clear(); safetyZones_.clear();
// 获取所有<EFBFBD><EFBFBD><EFBFBD>口配置 // 获取所有口配置
const auto& intersections = intersection_config_.getIntersections(); const auto& intersections = intersection_config_.getIntersections();
// 创建坐标转换器 // 创建坐标转换器
@ -177,7 +177,7 @@ void System::processLoop() {
int64_t last_vehicle_timestamp = 0; int64_t last_vehicle_timestamp = 0;
int64_t last_collision_timestamp = 0; int64_t last_collision_timestamp = 0;
int64_t last_traffic_light_timestamp = 0; int64_t last_traffic_light_timestamp = 0;
int64_t last_safety_zone_timestamp = 0; // 添加全区时间戳 int64_t last_safety_zone_timestamp = 0; // 添加<EFBFBD><EFBFBD><EFBFBD>全区时间戳
Logger::debug("数据处理循环启动"); Logger::debug("数据处理循环启动");
@ -301,7 +301,7 @@ void System::processLoop() {
if (veh.timestamp > max_timestamp) { if (veh.timestamp > max_timestamp) {
max_timestamp = veh.timestamp; max_timestamp = veh.timestamp;
} }
Logger::debug(" - 发现新<EFBFBD><EFBFBD><EFBFBD>据!"); Logger::debug(" - 发现新据!");
} else { } else {
Logger::debug(" - 数据未更新"); Logger::debug(" - 数据未更新");
} }
@ -328,7 +328,7 @@ void System::processLoop() {
// auto collision_elapsed = std::chrono::duration_cast<std::chrono::milliseconds>( // auto collision_elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
// now - last_collision_update).count(); // now - last_collision_update).count();
// if (collision_elapsed >= system_config.collision_detection.update_interval_ms) { // if (collision_elapsed >= system_config.collision_detection.update_interval_ms) {
// // 只有有新的数据时才更新冲突检 // // 只有有新的数据时才更新冲突检<EFBFBD><EFBFBD>
// if (last_aircraft_timestamp > last_collision_timestamp || // if (last_aircraft_timestamp > last_collision_timestamp ||
// last_vehicle_timestamp > last_collision_timestamp) { // last_vehicle_timestamp > last_collision_timestamp) {
@ -348,7 +348,7 @@ void System::processLoop() {
// } else if (!lastVehiclesWithRisk_.empty()) { // } else if (!lastVehiclesWithRisk_.empty()) {
// // 当前没有任何风险<E9A38E><E999A9><EFBFBD><EFBFBD>上次有风险车辆需要处理恢复指令 // // 当前没有任何风险<E9A38E><E999A9><EFBFBD><EFBFBD>上次有风险车辆需要处理恢复指令
// Logger::debug("当前无碰撞风险,查是否需要发送恢复指令"); // Logger::debug("当前无碰撞风险,<EFBFBD><EFBFBD><EFBFBD>查是否需要发送恢复指令");
// for (const auto& vehicleId : lastVehiclesWithRisk_) { // for (const auto& vehicleId : lastVehiclesWithRisk_) {
// Logger::debug("车辆 ", vehicleId, " 当前没有风险,准备发送恢复指令"); // Logger::debug("车辆 ", vehicleId, " 当前没有风险,准备发送恢复指令");
// VehicleCommand cmd; // VehicleCommand cmd;
@ -448,7 +448,7 @@ void System::processCollisions(const std::vector<CollisionRisk>& risks) {
auto processVehicle = [&](const std::string& vehicleId, const std::string& otherId) { auto processVehicle = [&](const std::string& vehicleId, const std::string& otherId) {
switch (risk.level) { switch (risk.level) {
case RiskLevel::CRITICAL: { case RiskLevel::CRITICAL: {
// 危险区<EFBFBD><EFBFBD>:立即发送告警指令 // 危险区:立即发送告警指令
VehicleCommand cmd; VehicleCommand cmd;
cmd.vehicleId = vehicleId; cmd.vehicleId = vehicleId;
cmd.type = CommandType::ALERT; cmd.type = CommandType::ALERT;
@ -522,7 +522,7 @@ void System::processCollisions(const std::vector<CollisionRisk>& risks) {
if (id2_controllable) { if (id2_controllable) {
currentVehiclesWithRisk.insert(risk.id2); currentVehiclesWithRisk.insert(risk.id2);
Logger::debug("添加当前有风险的可控车辆: ", risk.id2, Logger::debug("添加当前有风险的可控车辆: ", risk.id2,
", 当<EFBFBD><EFBFBD>风险车辆数量: ", currentVehiclesWithRisk.size()); ", 当风险车辆数量: ", currentVehiclesWithRisk.size());
processVehicle(risk.id2, risk.id1); processVehicle(risk.id2, risk.id1);
} }
@ -723,7 +723,7 @@ void System::broadcastVehicleCommand(const VehicleCommand& cmd) {
j["intersectionId"] = cmd.intersectionId; j["intersectionId"] = cmd.intersectionId;
} }
// 添<EFBFBD><EFBFBD><EFBFBD><EFBFBD>目标位置(对于所有非 RESUME 类型的指令) // 添目标位置(对于所有非 RESUME 类型的指令)
if (cmd.type != CommandType::RESUME) { if (cmd.type != CommandType::RESUME) {
j["targetLatitude"] = cmd.latitude; j["targetLatitude"] = cmd.latitude;
j["targetLongitude"] = cmd.longitude; j["targetLongitude"] = cmd.longitude;
@ -795,7 +795,7 @@ void System::checkSafetyZoneIntrusion(const MovingObject& obj) {
", type=", obj.isAircraft() ? "飞机" : (obj.isSpecialVehicle() ? "特勤车" : "其他"), ", type=", obj.isAircraft() ? "飞机" : (obj.isSpecialVehicle() ? "特勤车" : "其他"),
", position=(", position.x, ",", position.y, ")"); ", position=(", position.x, ",", position.y, ")");
// 检查每<EFBFBD><EFBFBD><EFBFBD>安全<EFBFBD><EFBFBD> // 检查每个安全区
for (auto& [id, zone] : safetyZones_) { for (auto& [id, zone] : safetyZones_) {
// 检查是否在安全区内,同时会尝试设置安全区类型 // 检查是否在安全区内,同时会尝试设置安全区类型
if (zone->isObjectInZone(obj)) { if (zone->isObjectInZone(obj)) {
@ -844,7 +844,7 @@ void System::checkUnmannedVehicleSafetyZones(const std::vector<Vehicle>& vehicle
} }
} }
// 检查是否需要发送恢<EFBFBD><EFBFBD>指令 // 检查是否需要发送恢指令
auto it = lastVehiclesWithSafetyZoneRisk_.find(vehicle.id); auto it = lastVehiclesWithSafetyZoneRisk_.find(vehicle.id);
if (!hasRisk && it != lastVehiclesWithSafetyZoneRisk_.end()) { if (!hasRisk && it != lastVehiclesWithSafetyZoneRisk_.end()) {
// 之前有风险,现在没有风险,发送恢复指令 // 之前有风险,现在没有风险,发送恢复指令

View File

@ -14,11 +14,11 @@
#include "vehicle/ControllableVehicles.h" #include "vehicle/ControllableVehicles.h"
#include "network/WebSocketServer.h" #include "network/WebSocketServer.h"
#include "network/MessageTypes.h" #include "network/MessageTypes.h"
#include "config/SystemConfig.h"
#include "config/IntersectionConfig.h" #include "config/IntersectionConfig.h"
// 前向声明 // 前向声明
class DataCollector; class DataCollector;
class SystemConfig; // 添加前向声明
class System { class System {
public: public: