Skip to content

Commit

Permalink
merge feature/delete-times
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoKle committed Sep 5, 2023
2 parents 41b3dc9 + ae645b6 commit acf90b3
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 18 deletions.
49 changes: 48 additions & 1 deletion com/Airport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions com/Airport.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <thread>
#include <map>
#include <mutex>
#include <list>

#include <json/json.h>

Expand Down Expand Up @@ -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);
Expand Down
94 changes: 79 additions & 15 deletions vACDM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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:
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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() {
Expand All @@ -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);
}

Expand Down
12 changes: 10 additions & 2 deletions vACDM.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum itemType
AORT,
CTOT,
ECFMP_MEASURES,
EventBooking,
EVENT_BOOKING,
};

enum itemFunction
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
};
Expand Down

0 comments on commit acf90b3

Please sign in to comment.