| 1 | /* |
| 2 | * SPDX-FileName: atc_mgr.hxx |
| 3 | * SPDX-FileComment: Started August 1, 2010; based on earlier work by David C. Luff |
| 4 | * SPDX-FileCopyrightText: Written by Durk Talsma. |
| 5 | * SPDX-FileContributor: Updated by Jonathan Redpath. Started June 12, 2019. Documenting and extending functionality of the ATC subsystem |
| 6 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 7 | */ |
| 8 | |
| 9 | /************************************************************************** |
| 10 | * The ATC Manager interfaces the users aircraft within the AI traffic system |
| 11 | * and also monitors the ongoing AI traffic patterns for potential conflicts |
| 12 | * and interferes where necessary. |
| 13 | *************************************************************************/ |
| 14 | |
| 15 | #pragma once |
| 16 | |
| 17 | #include <simgear/structure/SGReferenced.hxx> |
| 18 | #include <simgear/structure/subsystem_mgr.hxx> |
| 19 | |
| 20 | #include <AIModel/AIAircraft.hxx> |
| 21 | #include <ATC/trafficcontrol.hxx> |
| 22 | #include <Traffic/SchedFlight.hxx> |
| 23 | #include <Traffic/Schedule.hxx> |
| 24 | |
| 25 | |
| 26 | typedef std::vector<FGATCController*> AtcVec; |
| 27 | typedef std::vector<FGATCController*>::iterator AtcVecIterator; |
| 28 | |
| 29 | /** |
| 30 | * This subsystem performs two tasks. It provides the ATC controllers for the AI aircraft |
| 31 | * and shaddows the users aircraft and does the basic ATC and AI interaction. |
| 32 | */ |
| 33 | |
| 34 | class FGATCManager : public SGSubsystem |
| 35 | { |
| 36 | private: |
| 37 | AtcVec activeStations; |
| 38 | FGATCController *controller; |
| 39 | FGATCController *prevController; // The ATC controller that is responsible for the user's aircraft. |
| 40 | bool networkVisible = false; |
| 41 | bool initSucceeded = false; |
| 42 | SGPropertyNode_ptr transNum; |
| 43 | SGPropertyNode_ptr splashAlpha; |
| 44 | double startTime = 0.0; |
| 45 | std::string destination; |
| 46 | |
| 47 | std::unique_ptr<FGAISchedule> userAircraftTrafficRef; |
| 48 | std::unique_ptr<FGScheduledFlight> userAircraftScheduledFlight; |
| 49 | |
| 50 | SGPropertyNode_ptr _routeManagerDestinationAirportNode; |
| 51 | |
| 52 | public: |
| 53 | FGATCManager(); |
| 54 | virtual ~FGATCManager(); |
| 55 | |
| 56 | // Subsystem API. |
| 57 | void postinit() override; |
| 58 | void shutdown() override; |
| 59 | void update(double time) override; |
| 60 | |
| 61 | // Subsystem identification. |
| 62 | static const char* staticSubsystemClassId() { return "ATC"; } |
| 63 | |
| 64 | void addController(FGATCController* controller); |
| 65 | void removeController(FGATCController* controller); |
| 66 | |
| 67 | void reposition(); |
| 68 | private: |
| 69 | void initControllers(); |
| 70 | void signalReady(); |
| 71 | }; |