From d0b3399c1c0e61e4d787cc881d68837daa96b72b Mon Sep 17 00:00:00 2001 From: LeoKle Date: Sun, 17 Sep 2023 13:44:55 +0200 Subject: [PATCH 1/4] Fix data sending in C and S correlation mode This commit addresses the issue where data was not properly transmitted from the plugin to the backend when operating in C and S correlation mode. Changes Made: - replaced CRadarTarget references by CFlightPlan references --- vACDM.cpp | 40 +++++++++++++++++++--------------------- vACDM.h | 4 ++-- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/vACDM.cpp b/vACDM.cpp index 409c819..ecf0353 100644 --- a/vACDM.cpp +++ b/vACDM.cpp @@ -169,37 +169,37 @@ void vACDM::OnFlightPlanControllerAssignedDataUpdate(EuroScopePlugIn::CFlightPla if (EuroScopePlugIn::CTR_DATA_TYPE_TEMPORARY_ALTITUDE != dataType && EuroScopePlugIn::CTR_DATA_TYPE_SQUAWK != dataType) return; - this->updateFlight(flightplan.GetCorrelatedRadarTarget()); + this->updateFlight(flightplan); } -void vACDM::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget RadarTarget) { - std::string_view origin(RadarTarget.GetCorrelatedFlightPlan().GetFlightPlanData().GetOrigin()); +void vACDM::OnFlightPlanFlightPlanDataUpdate(EuroScopePlugIn::CFlightPlan FlightPlan) { + std::string_view origin(FlightPlan.GetFlightPlanData().GetOrigin()); { std::lock_guard guard(this->m_airportLock); for (auto& airport : this->m_airports) { if (airport->airport() == origin) { - if (false == airport->flightExists(RadarTarget.GetCallsign())) { + if (false == airport->flightExists(FlightPlan.GetCallsign())) { break; } - const auto& flightData = airport->flight(RadarTarget.GetCallsign()); + const auto& flightData = airport->flight(FlightPlan.GetCallsign()); // check for AOBT and ATOT if (flightData.asat.time_since_epoch().count() > 0) { if (flightData.aobt.time_since_epoch().count() <= 0) { float distanceMeters = 0.0f; - GeographicLib::Geodesic::WGS84().Inverse(static_cast(RadarTarget.GetPosition().GetPosition().m_Latitude), static_cast(RadarTarget.GetPosition().GetPosition().m_Longitude), + GeographicLib::Geodesic::WGS84().Inverse(static_cast(FlightPlan.GetFPTrackPosition().GetPosition().m_Latitude), static_cast(FlightPlan.GetFPTrackPosition().GetPosition().m_Longitude), static_cast(flightData.latitude), static_cast(flightData.longitude), distanceMeters); if (distanceMeters >= 5.0f) { - airport->updateAobt(RadarTarget.GetCallsign(), std::chrono::utc_clock::now()); + airport->updateAobt(FlightPlan.GetCallsign(), std::chrono::utc_clock::now()); } } else if (flightData.atot.time_since_epoch().count() <= 0) { - if (RadarTarget.GetGS() > 50) - airport->updateAtot(RadarTarget.GetCallsign(), std::chrono::utc_clock::now()); + if (FlightPlan.GetFPTrackPosition().GetReportedGS() > 50) + airport->updateAtot(FlightPlan.GetCallsign(), std::chrono::utc_clock::now()); } } break; @@ -207,7 +207,7 @@ void vACDM::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget RadarTarge } } - this->updateFlight(RadarTarget); + this->updateFlight(FlightPlan); } void vACDM::OnFlightPlanDisconnect(EuroScopePlugIn::CFlightPlan FlightPlan) { @@ -515,9 +515,7 @@ std::chrono::utc_clock::time_point vACDM::convertToTobt(const std::string& calls return tobt; } -void vACDM::updateFlight(const EuroScopePlugIn::CRadarTarget& rt) { - const auto& fp = rt.GetCorrelatedFlightPlan(); - +void vACDM::updateFlight(const EuroScopePlugIn::CFlightPlan& fp) { // ignore irrelevant and non-IFR flights if (nullptr == fp.GetFlightPlanData().GetPlanType() || 0 == std::strlen(fp.GetFlightPlanData().GetPlanType())) return; @@ -534,10 +532,10 @@ void vACDM::updateFlight(const EuroScopePlugIn::CRadarTarget& rt) { return; types::Flight_t flight; - flight.callsign = rt.GetCallsign(); + flight.callsign = fp.GetCallsign(); flight.inactive = false; - flight.latitude = rt.GetPosition().GetPosition().m_Latitude; - flight.longitude = rt.GetPosition().GetPosition().m_Longitude; + flight.latitude = fp.GetFPTrackPosition().GetPosition().m_Latitude; + flight.longitude = fp.GetFPTrackPosition().GetPosition().m_Longitude; flight.origin = fp.GetFlightPlanData().GetOrigin(); flight.destination = fp.GetFlightPlanData().GetDestination(); flight.rule = "I"; @@ -546,11 +544,11 @@ void vACDM::updateFlight(const EuroScopePlugIn::CRadarTarget& rt) { flight.runway = fp.GetFlightPlanData().GetDepartureRwy(); flight.sid = fp.GetFlightPlanData().GetSidName(); flight.assignedSquawk = fp.GetControllerAssignedData().GetSquawk(); - flight.currentSquawk = rt.GetPosition().GetSquawk(); + flight.currentSquawk = fp.GetFPTrackPosition().GetSquawk(); flight.initialClimb = std::to_string(fp.GetControllerAssignedData().GetClearedAltitude()); - if (rt.GetGS() > 50) { - logging::Logger::instance().log("vACDM", logging::Logger::Level::Debug, flight.callsign + " departed. GS: " + std::to_string(rt.GetGS())); + if (fp.GetFPTrackPosition().GetReportedGS() > 50) { + logging::Logger::instance().log("vACDM", logging::Logger::Level::Debug, flight.callsign + " departed. GS: " + std::to_string(fp.GetFPTrackPosition().GetReportedGS())); flight.departed = true; } @@ -566,8 +564,8 @@ void vACDM::updateFlight(const EuroScopePlugIn::CRadarTarget& rt) { } void vACDM::GetAircraftDetails() { - for (auto rt = RadarTargetSelectFirst(); rt.IsValid(); rt = RadarTargetSelectNext(rt)) - this->updateFlight(rt); + for (auto fp = FlightPlanSelectFirst(); fp.IsValid(); fp = FlightPlanSelectNext(fp)) + this->updateFlight(fp); } static __inline bool isNumber(const std::string& s) { diff --git a/vACDM.h b/vACDM.h index 95e4bd5..9d9968f 100644 --- a/vACDM.h +++ b/vACDM.h @@ -73,7 +73,7 @@ class vACDM : public EuroScopePlugIn::CPlugIn { void reloadConfiguration(); void changeServerUrl(const std::string& url); - void updateFlight(const EuroScopePlugIn::CRadarTarget& rt); + void updateFlight(const EuroScopePlugIn::CFlightPlan& rt); static std::chrono::utc_clock::time_point convertToTobt(const std::string& callsign, const std::string& eobt); void checkServerConfiguration(); @@ -81,7 +81,7 @@ class vACDM : public EuroScopePlugIn::CPlugIn { bool canBeSaved, bool canBeCreated) override; void OnAirportRunwayActivityChanged() override; void OnFlightPlanControllerAssignedDataUpdate(EuroScopePlugIn::CFlightPlan flightplan, const int dataType) override; - void OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget RadarTarget) override; + void OnFlightPlanFlightPlanDataUpdate(EuroScopePlugIn::CFlightPlan FlightPlan) override; void OnFlightPlanDisconnect(EuroScopePlugIn::CFlightPlan FlightPlan) override; void OnTimer(const int Counter) override; void OnGetTagItem(EuroScopePlugIn::CFlightPlan FlightPlan, EuroScopePlugIn::CRadarTarget RadarTarget, int ItemCode, int TagData, From 269db41eff799e70dbbc53996890d654a009ea75 Mon Sep 17 00:00:00 2001 From: LeoKle Date: Sun, 17 Sep 2023 14:00:02 +0200 Subject: [PATCH 2/4] Fix data display in C and S correlation mode This commit addresses the issue where data was not received, but not displayed in the Euroscope OnGetTagItem function --- vACDM.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vACDM.cpp b/vACDM.cpp index ecf0353..215177e 100644 --- a/vACDM.cpp +++ b/vACDM.cpp @@ -248,8 +248,8 @@ void vACDM::OnGetTagItem(EuroScopePlugIn::CFlightPlan FlightPlan, EuroScopePlugI std::lock_guard guard(this->m_airportLock); for (auto& airport : this->m_airports) { if (airport->airport() == origin) { - if (true == airport->flightExists(RadarTarget.GetCallsign())) { - const auto& data = airport->flight(RadarTarget.GetCallsign()); + if (true == airport->flightExists(FlightPlan.GetCallsign())) { + const auto& data = airport->flight(FlightPlan.GetCallsign()); std::stringstream stream; switch (static_cast(ItemCode)) { From 5be690fdd5073f15890d8e0bfccd9265d036fde8 Mon Sep 17 00:00:00 2001 From: LeoKle Date: Mon, 18 Sep 2023 10:40:00 +0200 Subject: [PATCH 3/4] amend OnFunctionCall to use flightplans instead --- vACDM.cpp | 26 +++++++++++++------------- vACDM.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/vACDM.cpp b/vACDM.cpp index 215177e..4755635 100644 --- a/vACDM.cpp +++ b/vACDM.cpp @@ -575,14 +575,14 @@ static __inline bool isNumber(const std::string& s) { void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, RECT area) { std::ignore = pt; - auto radarTarget = this->RadarTargetSelectASEL(); - std::string callsign(radarTarget.GetCallsign()); + auto flightplan = this->FlightPlanSelectASEL(); + std::string callsign(flightplan.GetCallsign()); - if ("I" != std::string_view(radarTarget.GetCorrelatedFlightPlan().GetFlightPlanData().GetPlanType())) + if ("I" != std::string_view(flightplan.GetFlightPlanData().GetPlanType())) return; std::shared_ptr currentAirport; - std::string_view origin(radarTarget.GetCorrelatedFlightPlan().GetFlightPlanData().GetOrigin()); + std::string_view origin(flightplan.GetFlightPlanData().GetOrigin()); this->m_airportLock.lock(); for (const auto& airport : std::as_const(this->m_airports)) { if (airport->airport() == origin) { @@ -649,7 +649,7 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC currentAirport->updateAsrt(callsign, std::chrono::utc_clock::now()); } - SetGroundState(radarTarget, "ST-UP"); + SetGroundState(flightplan, "ST-UP"); break; } @@ -668,10 +668,10 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC // set status depending on if the aircraft is positioned at a taxi-out position if (data.taxizoneIsTaxiout) { - SetGroundState(radarTarget, "TAXI"); + SetGroundState(flightplan, "TAXI"); } else { - SetGroundState(radarTarget, "PUSH"); + SetGroundState(flightplan, "PUSH"); } break; } @@ -701,7 +701,7 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC case RESET_ASAT: { currentAirport->updateAsat(callsign, types::defaultTime); - SetGroundState(radarTarget, "NSTS"); + SetGroundState(flightplan, "NSTS"); break; } case RESET_ASRT: @@ -721,7 +721,7 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC } case RESET_AOBT_AND_STATE: { - SetGroundState(radarTarget, "NSTS"); + SetGroundState(flightplan, "NSTS"); currentAirport->updateAobt(callsign, types::defaultTime); break; } @@ -747,7 +747,7 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC } } -void vACDM::SetGroundState(const EuroScopePlugIn::CRadarTarget radarTarget, const std::string groundstate) { +void vACDM::SetGroundState(const EuroScopePlugIn::CFlightPlan flightplan, const std::string groundstate) { // using GRP and default Euroscope ground states // STATE ABBREVIATION GRP STATE // - No state(departure) NSTS @@ -761,9 +761,9 @@ void vACDM::SetGroundState(const EuroScopePlugIn::CRadarTarget radarTarget, cons // - No state(arrival) NOSTATE Y // - Parked PARK - std::string scratchBackup(radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().GetScratchPadString()); - radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().SetScratchPadString(groundstate.c_str()); - radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().SetScratchPadString(scratchBackup.c_str()); + std::string scratchBackup(flightplan.GetControllerAssignedData().GetScratchPadString()); + flightplan.GetControllerAssignedData().SetScratchPadString(groundstate.c_str()); + flightplan.GetControllerAssignedData().SetScratchPadString(scratchBackup.c_str()); } void vACDM::RegisterTagItemFuntions() { diff --git a/vACDM.h b/vACDM.h index 9d9968f..11d89c3 100644 --- a/vACDM.h +++ b/vACDM.h @@ -91,7 +91,7 @@ class vACDM : public EuroScopePlugIn::CPlugIn { void DisplayDebugMessage(const std::string &message); void GetAircraftDetails(); - void SetGroundState(const EuroScopePlugIn::CRadarTarget radarTarget, const std::string groundstate); + void SetGroundState(const EuroScopePlugIn::CFlightPlan flightplan, const std::string groundstate); void RegisterTagItemFuntions(); void RegisterTagItemTypes(); }; From b7460029533f17eb5b741b6539713d534435c04e Mon Sep 17 00:00:00 2001 From: LeoKle Date: Fri, 22 Sep 2023 14:50:28 +0200 Subject: [PATCH 4/4] fix faulty departure status setting using the groundspeeds of CFlightPlan has proven to be unreliable in some cases resulting in aircraft being flagged as departed while still on ground --- vACDM.cpp | 29 ++++++++++++++++++----------- vACDM.h | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/vACDM.cpp b/vACDM.cpp index 4755635..ee04255 100644 --- a/vACDM.cpp +++ b/vACDM.cpp @@ -172,34 +172,41 @@ void vACDM::OnFlightPlanControllerAssignedDataUpdate(EuroScopePlugIn::CFlightPla this->updateFlight(flightplan); } -void vACDM::OnFlightPlanFlightPlanDataUpdate(EuroScopePlugIn::CFlightPlan FlightPlan) { - std::string_view origin(FlightPlan.GetFlightPlanData().GetOrigin()); +void vACDM::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget RadarTarget) { + + std::string callsign = RadarTarget.GetCallsign(); + if (callsign != RadarTarget.GetCorrelatedFlightPlan().GetCallsign() || callsign == "" || callsign.length() == 0) { + return; + } + + std::string_view origin(RadarTarget.GetCorrelatedFlightPlan().GetFlightPlanData().GetOrigin()); { std::lock_guard guard(this->m_airportLock); for (auto& airport : this->m_airports) { if (airport->airport() == origin) { - if (false == airport->flightExists(FlightPlan.GetCallsign())) { + if (false == airport->flightExists(callsign)) { break; } - const auto& flightData = airport->flight(FlightPlan.GetCallsign()); + const auto& flightData = airport->flight(callsign); // check for AOBT and ATOT if (flightData.asat.time_since_epoch().count() > 0) { if (flightData.aobt.time_since_epoch().count() <= 0) { float distanceMeters = 0.0f; - GeographicLib::Geodesic::WGS84().Inverse(static_cast(FlightPlan.GetFPTrackPosition().GetPosition().m_Latitude), static_cast(FlightPlan.GetFPTrackPosition().GetPosition().m_Longitude), - static_cast(flightData.latitude), static_cast(flightData.longitude), distanceMeters); + GeographicLib::Geodesic::WGS84().Inverse(static_cast(RadarTarget.GetPosition().GetPosition().m_Latitude), static_cast(RadarTarget.GetPosition().GetPosition().m_Longitude), + static_cast(flightData.latitude), static_cast(flightData.longitude), distanceMeters); if (distanceMeters >= 5.0f) { - airport->updateAobt(FlightPlan.GetCallsign(), std::chrono::utc_clock::now()); + airport->updateAobt(callsign, std::chrono::utc_clock::now()); } } else if (flightData.atot.time_since_epoch().count() <= 0) { - if (FlightPlan.GetFPTrackPosition().GetReportedGS() > 50) - airport->updateAtot(FlightPlan.GetCallsign(), std::chrono::utc_clock::now()); + if (RadarTarget.GetGS() > 50) { + airport->updateAtot(callsign, std::chrono::utc_clock::now()); + } } } break; @@ -207,7 +214,7 @@ void vACDM::OnFlightPlanFlightPlanDataUpdate(EuroScopePlugIn::CFlightPlan Flight } } - this->updateFlight(FlightPlan); + this->updateFlight(RadarTarget.GetCorrelatedFlightPlan()); } void vACDM::OnFlightPlanDisconnect(EuroScopePlugIn::CFlightPlan FlightPlan) { @@ -547,7 +554,7 @@ void vACDM::updateFlight(const EuroScopePlugIn::CFlightPlan& fp) { flight.currentSquawk = fp.GetFPTrackPosition().GetSquawk(); flight.initialClimb = std::to_string(fp.GetControllerAssignedData().GetClearedAltitude()); - if (fp.GetFPTrackPosition().GetReportedGS() > 50) { + if (fp.GetCorrelatedRadarTarget().GetGS() > 50) { logging::Logger::instance().log("vACDM", logging::Logger::Level::Debug, flight.callsign + " departed. GS: " + std::to_string(fp.GetFPTrackPosition().GetReportedGS())); flight.departed = true; } diff --git a/vACDM.h b/vACDM.h index 11d89c3..a0bf95e 100644 --- a/vACDM.h +++ b/vACDM.h @@ -81,7 +81,7 @@ class vACDM : public EuroScopePlugIn::CPlugIn { bool canBeSaved, bool canBeCreated) override; void OnAirportRunwayActivityChanged() override; void OnFlightPlanControllerAssignedDataUpdate(EuroScopePlugIn::CFlightPlan flightplan, const int dataType) override; - void OnFlightPlanFlightPlanDataUpdate(EuroScopePlugIn::CFlightPlan FlightPlan) override; + void OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget RadarTarget) override; void OnFlightPlanDisconnect(EuroScopePlugIn::CFlightPlan FlightPlan) override; void OnTimer(const int Counter) override; void OnGetTagItem(EuroScopePlugIn::CFlightPlan FlightPlan, EuroScopePlugIn::CRadarTarget RadarTarget, int ItemCode, int TagData,