diff --git a/Aman/AmanPlugIn.cpp b/Aman/AmanPlugIn.cpp index 934b1d8..4e79271 100644 --- a/Aman/AmanPlugIn.cpp +++ b/Aman/AmanPlugIn.cpp @@ -51,7 +51,7 @@ std::set AmanPlugIn::getAvailableIds() { return set; } -std::vector AmanPlugIn::getInboundsForFix(const std::string& fixName, std::vector viaFixes) { +std::vector AmanPlugIn::getInboundsForFix(const std::string& fixName, std::vector viaFixes, std::vector destinationAirports) { long int timeNow = static_cast(std::time(nullptr)); // Current UNIX-timestamp in seconds CRadarTarget asel = RadarTargetSelectASEL(); @@ -69,8 +69,9 @@ std::vector AmanPlugIn::getInboundsForFix(const std::string& fixNa int targetFixIndex = getFixIndexByName(route, fixName); - if (targetFixIndex != -1 && - route.GetPointDistanceInMinutes(targetFixIndex) > -1) { // Target fix found and has not been passed + if (targetFixIndex != -1 && // Target fix found + route.GetPointDistanceInMinutes(targetFixIndex) > -1 && // Target fix has not been passed + hasCorrectDestination(rt.GetCorrelatedFlightPlan().GetFlightPlanData(), destinationAirports)) { // Aircraft going to the correct destination bool fixIsDestination = targetFixIndex == route.GetPointsNumber() - 1; int timeToFix; @@ -173,6 +174,13 @@ void AmanPlugIn::loadTimelines(const std::string& filename) { } } + std::vector destinationAirports; + if (object.HasMember("destinationAirports") && object["destinationAirports"].IsArray()) { + for (auto& destination : object["destinationAirports"].GetArray()) { + destinationAirports.push_back(destination.GetString()); + } + } + std::string alias; if (object.HasMember("alias") && object["alias"].IsString()) { alias = object["alias"].GetString(); @@ -188,10 +196,15 @@ void AmanPlugIn::loadTimelines(const std::string& filename) { amanController->setTimelineHorizon(alias, startHorizon); } - timelines.push_back(std::make_shared(targetFixes, viaFixes, alias)); + timelines.push_back(std::make_shared(targetFixes, viaFixes, destinationAirports, alias)); } } +bool AmanPlugIn::hasCorrectDestination(CFlightPlanData fpd, std::vector destinationAirports) { + return destinationAirports.size() == 0 ? + true : std::find(destinationAirports.begin(), destinationAirports.end(), fpd.GetDestination()) != destinationAirports.end(); +} + int AmanPlugIn::getFixIndexByName(CFlightPlanExtractedRoute extractedRoute, const std::string& fixName) { for (int i = 0; i < extractedRoute.GetPointsNumber(); i++) { if (!strcmp(extractedRoute.GetPointName(i), fixName.c_str())) { @@ -237,7 +250,7 @@ std::shared_ptr>> AmanPlugIn::getTimel pAircraftList->clear(); for each (auto finalFix in fixes) { - auto var = getInboundsForFix(finalFix, viaFixes); + auto var = getInboundsForFix(finalFix, viaFixes, timeline->getDestinationAirports()); pAircraftList->insert(pAircraftList->end(), var.begin(), var.end()); } diff --git a/Aman/AmanPlugIn.h b/Aman/AmanPlugIn.h index 6cbd726..ebb5abc 100644 --- a/Aman/AmanPlugIn.h +++ b/Aman/AmanPlugIn.h @@ -27,11 +27,12 @@ class AmanPlugIn : public CPlugIn { virtual void OnTimer(int Counter); + bool hasCorrectDestination(CFlightPlanData fpd, std::vector destinationAirports); int getFixIndexByName(CFlightPlanExtractedRoute extractedRoute, const std::string& fixName); int getFirstViaFixIndex(CFlightPlanExtractedRoute extractedRoute, std::vector viaFixes); double findRemainingDist(CRadarTarget radarTarget, CFlightPlanExtractedRoute extractedRoute, int fixIndex); - std::vector getInboundsForFix(const std::string& fixName, std::vector viaFixes); + std::vector getInboundsForFix(const std::string& fixName, std::vector viaFixes, std::vector destinationAirports); void loadTimelines(const std::string& filename); static std::vector splitString(const std::string& string, const char delim); diff --git a/Aman/AmanTimeline.cpp b/Aman/AmanTimeline.cpp index 69b8759..72cef19 100644 --- a/Aman/AmanTimeline.cpp +++ b/Aman/AmanTimeline.cpp @@ -6,10 +6,11 @@ #include "AmanAircraft.h" #include "AmanTimeline.h" -AmanTimeline::AmanTimeline(std::vector fixes, std::vector viaFixes, const std::string& alias) { +AmanTimeline::AmanTimeline(std::vector fixes, std::vector viaFixes, std::vector destinations, const std::string& alias) { this->fixes = fixes; this->viaFixes = viaFixes; this->aircraftList = std::vector(); + this->destinationAirports = destinations; this->alias = alias; } diff --git a/Aman/AmanTimeline.h b/Aman/AmanTimeline.h index 9f9b029..2d8b90f 100644 --- a/Aman/AmanTimeline.h +++ b/Aman/AmanTimeline.h @@ -7,7 +7,7 @@ class AmanAircraft; class AmanTimeline { public: - AmanTimeline(std::vector fixes, std::vector viaFixes, const std::string& alias); + AmanTimeline(std::vector fixes, std::vector viaFixes, std::vector destinationAirports, const std::string& alias); std::string getIdentifier(); bool isDual(); bool containsListForFix(std::string fixName); @@ -16,6 +16,7 @@ class AmanTimeline { std::vector getAircraftList(std::vector fixNames); std::vector getFixes() { return fixes; } std::vector getViaFixes() { return viaFixes; } + std::vector getDestinationAirports() { return destinationAirports; } ~AmanTimeline(); @@ -24,5 +25,6 @@ class AmanTimeline { std::vector aircraftList; std::vector viaFixes; std::vector fixes; + std::vector destinationAirports; }; diff --git a/README.md b/README.md index b1e609b..f6a2cb3 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,15 @@ Example `aman-config.json`: "alias": "19R/19L", "targetFixes": [ "GSW40", "GME40" ], "viaFixes": [ "ADOPI", "LUNIP", "ESEBA", "INREX", "BELGU", "RIPAM" ], - "initialHorizon": 120 + "initialHorizon": 120, + "destinationAirports": [ "ENGM" ] }, { "alias": "...", "targetFixes": [ "....", "...." ], "viaFixes": [ "..." ], - "initialHorizon": 60 + "initialHorizon": 60, + "destinationAirports": [ "....", "...." ] } ] } @@ -31,6 +33,7 @@ Example `aman-config.json`: | `viaFixes` | (optional) Each fix will be assigned a color, and aircraft with a route initially (any direct routings ignored) going through one of these fixes will be marked with the color. For example, this can give a better overview of which direction each aircraft is coming from. Only eight different colors are available at the moment. | `alias` | (optional) If used, this will be the ID of the timeline. If not, the name will be generated from `targetFixes`. | `initialHorizon` | (optional) If used, this will be the initial time horizon (in minutes) when the timeline is loaded. +| `destinationAirports` | (optional) If used, aircraft whose destination is not in `destinationAirports` will not be included. The information displayed for each aircraft has the following layout: diff --git a/Release/Aman.dll b/Release/Aman.dll index 00797ee..50283c1 100644 Binary files a/Release/Aman.dll and b/Release/Aman.dll differ diff --git a/Release/aman-config.json b/Release/aman-config.json index ce3f109..4238090 100644 --- a/Release/aman-config.json +++ b/Release/aman-config.json @@ -4,7 +4,8 @@ "alias": "19R/19L", "targetFixes": [ "GSW40", "GME40" ], "viaFixes": [ "ADOPI", "LUNIP", "ESEBA", "INREX", "BELGU", "RIPAM" ], - "startHorizon": 10 + "startHorizon": 10, + "destinationAirports": [ "ENGM" ] } ] } \ No newline at end of file