Debian Codegraph @

src/Airports/dynamics.hxx

raw symbols SCIP
1 /*
2 * SPDX-FileName: dynamics.hxx
3 * SPDX-FileComment: a class to manage the higher order airport ground activities
4 * SPDX-FileCopyrightText: Written by Durk Talsma, started December 2004.
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8 #pragma once
9
10 #include <set>
11
12 #include <simgear/structure/SGWeakReferenced.hxx>
13 #include <simgear/timing/timestamp.hxx>
14
15 #include <ATC/ApproachController.hxx>
16 #include <ATC/GroundController.hxx>
17 #include <ATC/StartupController.hxx>
18 #include <ATC/TowerController.hxx>
19 #include <ATC/trafficcontrol.hxx>
20
21 #include "airports_fwd.hxx"
22 #include "parking.hxx"
23 #include "runwayprefs.hxx"
24
25
26 class ParkingAssignment
27 {
28 public:
29 ParkingAssignment();
30 ~ParkingAssignment();
31
32 // create a parking assignment (and mark it as unavailable)
33 ParkingAssignment(FGParking* pk, FGAirportDynamics* apt);
34
35 ParkingAssignment(const ParkingAssignment& aOther);
36 void operator=(const ParkingAssignment& aOther);
37
38 bool isValid() const;
39 FGParking* parking() const;
40
41 void release();
42
43 private:
44 void clear();
45
46 class ParkingAssignmentPrivate;
47 ParkingAssignmentPrivate* _sharedData;
48 };
49
50 class FGAirportDynamics : public SGWeakReferenced
51 {
52 private:
53 FGAirport* _ap;
54
55 typedef std::set<FGParkingRef> ParkingSet;
56 // if a parking item is in this set, it is occupied
57 ParkingSet occupiedParkings;
58
59 FGRunwayPreference rwyPrefs;
60 FGStartupController startupController;
61 FGTowerController towerController;
62 FGApproachController approachController;
63 FGGroundController groundController;
64
65 time_t lastUpdate;
66 std::string prevTrafficType;
67 stringVec landing;
68 stringVec takeoff;
69 stringVec milActive, comActive, genActive, ulActive;
70 stringVec* currentlyActive{nullptr};
71
72 int atisSequenceIndex;
73 double atisSequenceTimeStamp;
74
75 std::string chooseRunwayFallback();
76 bool innerGetActiveRunway(const std::string& trafficType, int action, std::string& runway, double heading);
77 std::string chooseRwyByHeading(stringVec rwys, double heading);
78
79 FGParking* innerGetAvailableParking(double radius, const std::string& flType,
80 const std::string& airline,
81 bool skipEmptyAirlineCode);
82
83 std::string fallbackGetActiveRunway(int action, double heading);
84
85 // runway preference fallback data
86 SGTimeStamp _lastFallbackUpdate;
87 FGRunwayList _fallbackDepartureRunways,
88 _fallbackArrivalRunways;
89 unsigned int _fallbackRunwayCounter{0};
90
91 public:
92 explicit FGAirportDynamics(FGAirport* ap);
93 virtual ~FGAirportDynamics();
94
95 void init();
96
97 double getElevation() const;
98 const std::string getId() const;
99
100 FGAirport* parent() const
101 {
102 return _ap;
103 }
104
105 void getActiveRunway(const std::string& trafficType,
106 int action,
107 std::string& runway,
108 double heading);
109
110 bool hasParking(FGParking* parking) const;
111
112 bool hasParkings() const;
113
114 /**
115 * retrieve an available parking by GateID, or -1 if no suitable
116 * parking location could be found.
117 */
118 ParkingAssignment getAvailableParking(double radius, const std::string& fltype,
119 const std::string& acType, const std::string& airline);
120
121 void setParkingAvailable(FGParking* park, bool available);
122
123 bool isParkingAvailable(FGParking* parking) const;
124
125 void releaseParking(FGParking* id);
126
127 FGParkingList getParkings(bool onlyAvailable, const std::string& type) const;
128
129 /**
130 * Find a parking gate index by name. Note names are often not unique
131 * in our data, so will return the first match. If the parking is found,
132 * it will be marked as in-use (unavailable)
133 */
134 ParkingAssignment getParkingByName(const std::string& name) const;
135
136 /**
137 * find a parking by name, if available. If the name is non-unique, consider all copies for
138 * availability (i.e try them all)
139 */
140 ParkingAssignment getAvailableParkingByName(const std::string& name);
141
142 FGParkingRef getOccupiedParkingByName(const std::string& name) const;
143
144 // ATC related functions.
145 FGStartupController* getStartupController()
146 {
147 return &startupController;
148 };
149 FGGroundController* getGroundController()
150 {
151 return &groundController;
152 };
153 FGTowerController* getTowerController()
154 {
155 return &towerController;
156 };
157 FGApproachController* getApproachController()
158 {
159 return &approachController;
160 };
161
162 int getApproachFrequency(unsigned nr);
163 int getGroundFrequency(unsigned leg);
164 int getTowerFrequency(unsigned nr);
165
166 /// get current ATIS sequence letter
167 const std::string getAtisSequence();
168
169 /// get the current ATIS sequence number, updating it if necessary
170 int updateAtisSequence(int interval, bool forceUpdate);
171
172 void setRwyUse(const FGRunwayPreference& ref);
173 };