From 622d721a771cbe31eba8291570d9fce78a46bd61 Mon Sep 17 00:00:00 2001 From: wyc <1104749580@qq.com> Date: Fri, 17 Jul 2026 13:52:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E4=B8=AA=E7=82=B9=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E5=89=94=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SSR/ADS_B/ADS_B.hpp | 1 + SSR/Aircraft_Info.cpp | 19 +++++++++++++++---- SSR/export.hpp | 6 ++++-- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/SSR/ADS_B/ADS_B.hpp b/SSR/ADS_B/ADS_B.hpp index 3498737..2f9442f 100644 --- a/SSR/ADS_B/ADS_B.hpp +++ b/SSR/ADS_B/ADS_B.hpp @@ -82,6 +82,7 @@ struct Constraint { bool time_space_filter; bool speed_filter; bool use_system_time; + mutable bool fail_clear_pos = false; // 如果启用那么解码位置失败,将会清空状态 }; template struct CPR_MSG : CPR_Data { diff --git a/SSR/Aircraft_Info.cpp b/SSR/Aircraft_Info.cpp index b17813f..adcbc79 100644 --- a/SSR/Aircraft_Info.cpp +++ b/SSR/Aircraft_Info.cpp @@ -119,16 +119,21 @@ bool parse_absb_17(SSR::Data_Source_Interface* src, SSR::P_S mode_s_msg, JSON& m Parse_no_json(t, BDS06_surface_position) info.refresh_pos(true); t.base_station_pos = base_station_pos; - //bool use_system_time = src->use_system_time.load(); + auto& constraint = surface_constraint; + auto& list = info.surface_pos_track_list; + constraint.fail_clear_pos = list.size() <= 1; auto tp = t.parse_message(mode_s_msg, air_constraint); if (tp.has_value()) { auto t2 = t.odd_msg; Position_Info p(tp.value(), info.altitude_meter().value_or(0)); - info.surface_pos_track_list.push(p); + list.push(p); info.mlat = false; parse_pos_call_back(&info, mode_s_msg, true); msg_json.append_list(t.toJson().children); } + else if (constraint.fail_clear_pos) { + list.reset(); + } msg_json.append(Psc::JSON("地表位置消息", get_current_time_as_string())); } else if ((tc >= 9 && tc <= 18) || (tc >= 20 && tc <= 22)) { @@ -140,16 +145,22 @@ bool parse_absb_17(SSR::Data_Source_Interface* src, SSR::P_S mode_s_msg, JSON& m else if (info.absb_version == 2) { Parse(t2, BDS05_airborne_Position_v2) } + auto& constraint = air_constraint; + auto& list = info.air_pos_track_list; + constraint.fail_clear_pos = list.size() <= 1; using namespace std::chrono; - auto tp = t.parse_message(mode_s_msg, surface_constraint); + auto tp = t.parse_message(mode_s_msg, constraint); if (tp.has_value()) { auto alt = t.get_alt_meter(); Position_Info p(tp.value(), alt); - info.air_pos_track_list.push(p); + list.push(p); info.mlat = false; parse_pos_call_back(&info, mode_s_msg, false); msg_json.append_list(t.toJson().children); } + else if (constraint.fail_clear_pos) { + list.reset(); + } msg_json.append(Psc::JSON("空中位置消息", get_current_time_as_string())); } else if (tc == 19) { diff --git a/SSR/export.hpp b/SSR/export.hpp index cefc041..a77e10c 100644 --- a/SSR/export.hpp +++ b/SSR/export.hpp @@ -185,8 +185,10 @@ RET CPR_MSG::parse_message(P_S msg, Constraint constraint) { return ret; } // 此时新来的点本地解码失败 全局解码也失败 很可能是 中间丢了很多消息 所以旧的pos - // last_parse_pos_time = 0; - // pos = std::nullopt; + if (constraint.fail_clear_pos) { + last_parse_pos_time = 0; + last_parse_pos = std::nullopt; + } that->msg = msg; that->time = time_s; other->reset();