diff --git a/com/Airport.cpp b/com/Airport.cpp index 1c5ef99..5a60c2f 100644 --- a/com/Airport.cpp +++ b/com/Airport.cpp @@ -178,8 +178,10 @@ void Airport::updateTobt(const std::string& callsign, const std::chrono::utc_clo root["vacdm"]["tobt"] = Airport::timestampToIsoString(tobt); if (true == resetTsat) root["vacdm"]["tsat"] = Airport::timestampToIsoString(types::defaultTime); - if (false == manualTobt) + if (false == manualTobt) { root["vacdm"]["tobt_state"] = "CONFIRMED"; + } + root["vacdm"]["ttot"] = Airport::timestampToIsoString(types::defaultTime); root["vacdm"]["asat"] = Airport::timestampToIsoString(types::defaultTime); root["vacdm"]["aobt"] = Airport::timestampToIsoString(types::defaultTime); @@ -207,6 +209,51 @@ void Airport::updateTobt(const std::string& callsign, const std::chrono::utc_clo this->m_manualUpdatePerformance.stop(); } +void Airport::resetTobt(const std::string& callsign, const std::chrono::utc_clock::time_point& tobt, const std::string& tobtState) { + if (true == this->m_pause) + return; + + this->m_manualUpdatePerformance.start(); + auto it = this->m_flights.find(callsign); + if (it != this->m_flights.end() && it->second[FlightServer].callsign == callsign) { + Json::Value root; + + root["callsign"] = callsign; + root["vacdm"] = Json::Value(); + + root["vacdm"]["tobt"] = Airport::timestampToIsoString(tobt); + root["vacdm"]["tobt_state"] = tobtState; + root["vacdm"]["tsat"] = Airport::timestampToIsoString(types::defaultTime); + root["vacdm"]["ttot"] = Airport::timestampToIsoString(types::defaultTime); + root["vacdm"]["asat"] = Airport::timestampToIsoString(types::defaultTime); + root["vacdm"]["asrt"] = Airport::timestampToIsoString(types::defaultTime); + root["vacdm"]["aobt"] = Airport::timestampToIsoString(types::defaultTime); + root["vacdm"]["aort"] = Airport::timestampToIsoString(types::defaultTime); + root["vacdm"]["atot"] = Airport::timestampToIsoString(types::defaultTime); + + it->second[FlightEuroscope].lastUpdate = std::chrono::utc_clock::now(); + it->second[FlightConsolidated].tobt = types::defaultTime; + it->second[FlightConsolidated].tsat = types::defaultTime; + it->second[FlightConsolidated].ttot = types::defaultTime; + it->second[FlightConsolidated].exot = types::defaultTime; + it->second[FlightConsolidated].asat = types::defaultTime; + it->second[FlightConsolidated].asrt = types::defaultTime; + it->second[FlightConsolidated].aobt = types::defaultTime; + it->second[FlightConsolidated].aort = types::defaultTime; + it->second[FlightConsolidated].atot = types::defaultTime; + + logging::Logger::instance().log("Airport", logging::Logger::Level::Debug, "Resetting TOBT: " + callsign + ", " + root["vacdm"]["tobt"].asString()); + + std::lock_guard asyncGuard(this->m_asynchronousMessageLock); + this->m_asynchronousMessages.push_back({ + SendType::Patch, + callsign, + root, + }); + } + this->m_manualUpdatePerformance.stop(); +} + void Airport::updateAsat(const std::string& callsign, const std::chrono::utc_clock::time_point& asat) { if (true == this->m_pause) return; diff --git a/com/Airport.h b/com/Airport.h index 601b164..cfb5ab3 100644 --- a/com/Airport.h +++ b/com/Airport.h @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -61,6 +62,7 @@ class Airport { void flightDisconnected(const std::string& callsign); void updateExot(const std::string& callsign, const std::chrono::utc_clock::time_point& exot); void updateTobt(const std::string& callsign, const std::chrono::utc_clock::time_point& tobt, bool manualTobt); + void resetTobt(const std::string& callsign, const std::chrono::utc_clock::time_point& tobt, const std::string& tobtState); void updateAsat(const std::string& callsign, const std::chrono::utc_clock::time_point& asat); void updateAobt(const std::string& callsign, const std::chrono::utc_clock::time_point& aobt); void updateAtot(const std::string& callsign, const std::chrono::utc_clock::time_point& atot); diff --git a/vACDM.cpp b/vACDM.cpp index 2642a4b..409c819 100644 --- a/vACDM.cpp +++ b/vACDM.cpp @@ -322,7 +322,8 @@ void vACDM::OnGetTagItem(EuroScopePlugIn::CFlightPlan FlightPlan, EuroScopePlugI stream << std::format("{0:%H%M}", data.ctot); *pRGB = Color::instance().colorizeCtotandCtottimer(data); } - case itemType::EventBooking: + break; + case itemType::EVENT_BOOKING: if (data.hasBooking == true) { stream << "B"; *pRGB = this->m_pluginConfig.green; @@ -650,9 +651,7 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC currentAirport->updateAsrt(callsign, std::chrono::utc_clock::now()); } - std::string scratchBackup(radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().GetScratchPadString()); - radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().SetScratchPadString("ST-UP"); - radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().SetScratchPadString(scratchBackup.c_str()); + SetGroundState(radarTarget, "ST-UP"); break; } @@ -670,17 +669,12 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC currentAirport->updateAobt(callsign, std::chrono::utc_clock::now()); // set status depending on if the aircraft is positioned at a taxi-out position - std::string status = ""; if (data.taxizoneIsTaxiout) { - status = "TAXI"; + SetGroundState(radarTarget, "TAXI"); } else { - status = "PUSH"; + SetGroundState(radarTarget, "PUSH"); } - - std::string scratchBackup(radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().GetScratchPadString()); - radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().SetScratchPadString(status.c_str()); - radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().SetScratchPadString(scratchBackup.c_str()); break; } case TOBT_CONFIRM: @@ -701,7 +695,51 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC AddPopupListElement("TOBT confirm", NULL, TOBT_CONFIRM, false, 2, false, false); break; } - case RESET: + case RESET_TOBT: + { + currentAirport->resetTobt(callsign, types::defaultTime, data.tobt_state); + break; + } + case RESET_ASAT: + { + currentAirport->updateAsat(callsign, types::defaultTime); + SetGroundState(radarTarget, "NSTS"); + break; + } + case RESET_ASRT: + { + currentAirport->updateAsrt(callsign, types::defaultTime); + break; + } + case RESET_TOBT_CONFIRM: + { + currentAirport->resetTobt(callsign, data.tobt, "GUESS"); + break; + } + case RESET_AORT: + { + currentAirport->updateAort(callsign, types::defaultTime); + break; + } + case RESET_AOBT_AND_STATE: + { + SetGroundState(radarTarget, "NSTS"); + currentAirport->updateAobt(callsign, types::defaultTime); + break; + } + case RESET_MENU: + { + this->OpenPopupList(area, "RESET menu", 1); + AddPopupListElement("Reset TOBT", NULL, RESET_TOBT, false, 2, false, false); + AddPopupListElement("Reset ASAT", NULL, RESET_ASAT, false, 2, false, false); + AddPopupListElement("Reset ASRT", NULL, RESET_ASRT, false, 2, false, false); + AddPopupListElement("Reset confirmed TOBT", NULL, RESET_TOBT_CONFIRM, false, 2, false, false); + AddPopupListElement("Reset AORT", NULL, RESET_AORT, false, 2, false, false); + AddPopupListElement("Reset AOBT", NULL, RESET_AOBT_AND_STATE, false, 2, false, false); + AddPopupListElement("Reset Aircraft", NULL, RESET_AIRCRAFT, false, 2, false, false); + break; + } + case RESET_AIRCRAFT: { currentAirport->deleteFlight(callsign); break; @@ -711,6 +749,25 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC } } +void vACDM::SetGroundState(const EuroScopePlugIn::CRadarTarget radarTarget, const std::string groundstate) { + // using GRP and default Euroscope ground states + // STATE ABBREVIATION GRP STATE + // - No state(departure) NSTS + // - On Freq ONFREQ Y + // - De - Ice DE-ICE Y + // - Start - Up STUP + // - Pushback PUSH + // - Taxi TAXI + // - Line Up LINEUP Y + // - Taxi In TXIN + // - 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()); +} + void vACDM::RegisterTagItemFuntions() { RegisterTagItemFunction("Modify EXOT", EXOT_MODIFY); RegisterTagItemFunction("TOBT now", TOBT_NOW); @@ -722,7 +779,14 @@ void vACDM::RegisterTagItemFuntions() { RegisterTagItemFunction("Startup Request", STARTUP_REQUEST); RegisterTagItemFunction("Request Offblock", OFFBLOCK_REQUEST); RegisterTagItemFunction("Set AOBT and Groundstate", AOBT_NOW_AND_STATE); - RegisterTagItemFunction("Reset aircraft", RESET); + // Reset Functions + RegisterTagItemFunction("Reset TOBT", RESET_TOBT); + RegisterTagItemFunction("Reset ASAT", RESET_ASAT); + RegisterTagItemFunction("Reset confirmed TOBT", RESET_TOBT_CONFIRM); + RegisterTagItemFunction("Reset Offblock Request", RESET_AORT); + RegisterTagItemFunction("Reset AOBT", RESET_AOBT_AND_STATE); + RegisterTagItemFunction("Reset Menu", RESET_MENU); + RegisterTagItemFunction("Reset aircraft", RESET_AIRCRAFT); } void vACDM::RegisterTagItemTypes() { @@ -734,10 +798,10 @@ void vACDM::RegisterTagItemTypes() { RegisterTagItemType("ASAT", itemType::ASAT); RegisterTagItemType("AOBT", itemType::AOBT); RegisterTagItemType("ATOT", itemType::ATOT); - RegisterTagItemType("ASRT", itemType::ASRT); + RegisterTagItemType("ASRT", itemType::ASRT); RegisterTagItemType("AORT", itemType::AORT); RegisterTagItemType("CTOT", itemType::CTOT); - RegisterTagItemType("Event Booking", itemType::EventBooking); + RegisterTagItemType("Event Booking", itemType::EVENT_BOOKING); RegisterTagItemType("ECFMP Measures", itemType::ECFMP_MEASURES); } diff --git a/vACDM.h b/vACDM.h index 1fdde21..95e4bd5 100644 --- a/vACDM.h +++ b/vACDM.h @@ -31,7 +31,7 @@ enum itemType AORT, CTOT, ECFMP_MEASURES, - EventBooking, + EVENT_BOOKING, }; enum itemFunction @@ -48,7 +48,14 @@ enum itemFunction TOBT_CONFIRM, OFFBLOCK_REQUEST, AOBT_NOW_AND_STATE, - RESET, + RESET_TOBT, + RESET_ASAT, + RESET_ASRT, + RESET_TOBT_CONFIRM, + RESET_AORT, + RESET_AOBT_AND_STATE, + RESET_MENU, + RESET_AIRCRAFT, }; class vACDM : public EuroScopePlugIn::CPlugIn { @@ -84,6 +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 RegisterTagItemFuntions(); void RegisterTagItemTypes(); };