Skip to content

Commit

Permalink
Merge branch 'main' into feature/EventBooking
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoKle authored Apr 19, 2023
2 parents 4d02c50 + ab239eb commit fad998b
Show file tree
Hide file tree
Showing 8 changed files with 331 additions and 64 deletions.
59 changes: 56 additions & 3 deletions com/Airport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,25 @@ void Airport::updateTobt(const std::string& callsign, const std::chrono::utc_clo

auto it = this->m_flights.find(callsign);
if (it != this->m_flights.end() && it->second[FlightServer].callsign == callsign) {
bool resetTsat = (tobt == types::defaultTime && true == manualTobt) || tobt >= it->second[FlightConsolidated].tsat;
Json::Value root;

root["callsign"] = callsign;
root["vacdm"] = Json::Value();
root["vacdm"]["tobt"] = Airport::timestampToIsoString(tobt);
root["vacdm"]["tsat"] = Airport::timestampToIsoString(types::defaultTime);
if (true == resetTsat)
root["vacdm"]["tsat"] = Airport::timestampToIsoString(types::defaultTime);
if (false == manualTobt)
root["vacdm"]["tobt_state"] = "NOW";
root["vacdm"]["tobt_state"] = "CONFIRMED";
root["vacdm"]["ttot"] = root["vacdm"]["tsat"].asString();
root["vacdm"]["asat"] = root["vacdm"]["tsat"].asString();
root["vacdm"]["aobt"] = root["vacdm"]["tsat"].asString();
root["vacdm"]["atot"] = root["vacdm"]["tsat"].asString();

it->second[FlightEuroscope].lastUpdate = std::chrono::utc_clock::now();
it->second[FlightConsolidated].tobt = tobt;
it->second[FlightConsolidated].tsat = types::defaultTime;
if (true == resetTsat)
it->second[FlightConsolidated].tsat = types::defaultTime;
it->second[FlightConsolidated].ttot = types::defaultTime;
it->second[FlightConsolidated].exot = types::defaultTime;
it->second[FlightConsolidated].asat = types::defaultTime;
Expand Down Expand Up @@ -243,6 +246,52 @@ void Airport::updateAtot(const std::string& callsign, const std::chrono::utc_clo
}
}

void Airport::updateAsrt(const std::string& callsign, const std::chrono::utc_clock::time_point& asrt) {
if (true == this->m_pause)
return;

std::lock_guard guard(this->m_lock);

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"]["asrt"] = Airport::timestampToIsoString(asrt);


it->second[FlightEuroscope].lastUpdate = std::chrono::utc_clock::now();
it->second[FlightConsolidated].asrt = asrt;

logging::Logger::instance().log("Airport", logging::Logger::Level::Debug, "Updating ASRT: " + callsign + ", " + root["vacdm"]["asrt"].asString());
Server::instance().patchFlight(callsign, root);
}
}

void Airport::updateAort(const std::string& callsign, const std::chrono::utc_clock::time_point& aort) {
if (true == this->m_pause)
return;

std::lock_guard guard(this->m_lock);

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"]["aort"] = Airport::timestampToIsoString(aort);


it->second[FlightEuroscope].lastUpdate = std::chrono::utc_clock::now();
it->second[FlightConsolidated].aort = aort;

logging::Logger::instance().log("Airport", logging::Logger::Level::Debug, "Updating AORT: " + callsign + ", " + root["vacdm"]["aort"].asString());
Server::instance().patchFlight(callsign, root);
}
}

Airport::SendType Airport::deltaEuroscopeToBackend(const std::array<types::Flight_t, 3>& data, Json::Value& root) {
root.clear();

Expand Down Expand Up @@ -357,6 +406,10 @@ void Airport::consolidateData(std::array<types::Flight_t, 3>& data) {
data[FlightConsolidated].asat = data[FlightServer].asat;
data[FlightConsolidated].aobt = data[FlightServer].aobt;
data[FlightConsolidated].atot = data[FlightServer].atot;
data[FlightConsolidated].aort = data[FlightServer].aort;
data[FlightConsolidated].asrt = data[FlightServer].asrt;
data[FlightConsolidated].tobt_state = data[FlightServer].tobt_state;

data[FlightConsolidated].hasBooking = data[FlightServer].hasBooking;

data[FlightConsolidated].runway = data[FlightEuroscope].runway;
Expand Down
2 changes: 2 additions & 0 deletions com/Airport.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Airport {
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);
void updateAsrt(const std::string& callsign, const std::chrono::utc_clock::time_point& asrt);
void updateAort(const std::string& callsign, const std::chrono::utc_clock::time_point& aort);
bool flightExists(const std::string& callsign);
const types::Flight_t& flight(const std::string& callsign);
};
Expand Down
6 changes: 5 additions & 1 deletion com/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,12 @@ std::list<types::Flight_t> Server::allFlights(const std::string& airport) {
flights.back().aobt = Server::isoStringToTimestamp(flight["vacdm"]["aobt"].asString());
flights.back().atot = Server::isoStringToTimestamp(flight["vacdm"]["atot"].asString());
flights.back().exot = std::chrono::utc_clock::time_point(std::chrono::minutes(flight["vacdm"]["exot"].asInt64()));
flights.back().hasBooking = flight["hasBooking"].asBool();
flights.back().asrt = Server::isoStringToTimestamp(flight["vacdm"]["asrt"].asString());
flights.back().aort = Server::isoStringToTimestamp(flight["vacdm"]["aort"].asString());
flights.back().tobt_state = flight["vacdm"]["tobt_state"].asString();

flights.back().hasBooking = flight["hasBooking"].asBool();

flights.back().runway = flight["clearance"]["dep_rwy"].asString();
flights.back().sid = flight["clearance"]["sid"].asString();
flights.back().assignedSquawk = flight["clearance"]["assigned_squawk"].asString();
Expand Down
2 changes: 2 additions & 0 deletions config/FileFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ bool FileFormat::parse(const std::string& filename, SystemConfig& config) {
parsed = this->parseColor(entry[1], config.green, lineOffset);
} else if ("COLOR_blue" == entry[0]) {
parsed = this->parseColor(entry[1], config.blue, lineOffset);
} else if ("COLOR_lightyellow" == entry[0]) {
parsed = this->parseColor(entry[1], config.lightyellow, lineOffset);
} else if ("COLOR_yellow" == entry[0]) {
parsed = this->parseColor(entry[1], config.yellow, lineOffset);
} else if ("COLOR_orange" == entry[0]) {
Expand Down
4 changes: 4 additions & 0 deletions types/Flight.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef struct Flight {
// position/*
double latitude = 0.0;
double longitude = 0.0;
bool taxizoneIsTaxiout = false;

// flightplan/*
std::string origin;
Expand All @@ -32,6 +33,9 @@ typedef struct Flight {
std::chrono::utc_clock::time_point asat = defaultTime;
std::chrono::utc_clock::time_point aobt = defaultTime;
std::chrono::utc_clock::time_point atot = defaultTime;
std::chrono::utc_clock::time_point asrt = defaultTime;
std::chrono::utc_clock::time_point aort = defaultTime;
std::string tobt_state = "";

// booking/*
bool hasBooking = false;
Expand Down
1 change: 1 addition & 0 deletions types/SystemConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace vacdm {
COLORREF lightblue = RGB(53, 218, 235);
COLORREF green = RGB(0, 181, 27);
COLORREF blue = RGB(0, 0, 255);
COLORREF lightyellow = RGB(255, 255, 191);
COLORREF yellow = RGB(255, 255, 0);
COLORREF orange = RGB(255, 153, 0);
COLORREF red = RGB(255, 0, 0);
Expand Down
Loading

0 comments on commit fad998b

Please sign in to comment.