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,