FlightGear next
dynamics.hxx
Go to the documentation of this file.
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/SGReferenced.hxx>
13#include <simgear/structure/SGWeakReferenced.hxx>
14#include <simgear/timing/timestamp.hxx>
15
23
24#include "airports_fwd.hxx"
25#include "parking.hxx"
26#include "runwayprefs.hxx"
27
28
29namespace RunwayAction {
30 enum Type {
33 };
34 }
35
37{
38public:
41
42 // create a parking assignment (and mark it as unavailable)
44
46 void operator=(const ParkingAssignment& aOther);
47
48 bool isValid() const;
49 FGParking* parking() const;
50
51 void release();
52
53private:
54 void clear();
55
57 ParkingAssignmentPrivate* _sharedData;
58};
59
60class FGAirportDynamics : public SGWeakReferenced
61{
62private:
63 FGAirport* _ap;
64
65 typedef std::set<FGParkingRef> ParkingSet;
66 // if a parking item is in this set, it is occupied
67 ParkingSet occupiedParkings;
68
69 FGRunwayPreference rwyPrefs;
70
72 SGSharedPtr<AirportGroundRadar> groundRadar;
74 ActiveRunwayVec activeRunways;
75
76 FGStartupController startupController;
77 FGTowerController towerController;
78 FGApproachController approachController;
79 FGGroundController groundController;
80
81 time_t lastUpdate;
82 std::string prevTrafficType;
83 stringVec landing;
84 stringVec takeoff;
85 stringVec milActive, comActive, genActive, ulActive;
86 stringVec* currentlyActive{nullptr};
87
88 int atisSequenceIndex;
89 double atisSequenceTimeStamp;
90
91 std::string chooseRunwayFallback();
92 bool innerGetActiveRunway(const std::string& trafficType, int action, std::string& runway, double heading);
93 std::string chooseRwyByHeading(stringVec rwys, double heading);
94
95 FGParking* innerGetAvailableParking(double radius, const std::string& flType,
96 const std::string& airline,
97 bool skipEmptyAirlineCode);
98
99 std::string fallbackGetActiveRunway(int action, double heading);
100
101 // runway preference fallback data
102 SGTimeStamp _lastFallbackUpdate;
103 FGRunwayList _fallbackDepartureRunways,
104 _fallbackArrivalRunways;
105 unsigned int _fallbackRunwayCounter{0};
106
107public:
108 explicit FGAirportDynamics(FGAirport* ap);
109 virtual ~FGAirportDynamics();
110
111 void init();
112
113 double getElevation() const;
114 const std::string getId() const;
115
117 {
118 return _ap;
119 }
120
121 void getActiveRunway(const std::string& trafficType,
122 int action,
123 std::string& runway,
124 double heading);
125
126 bool hasParking(FGParking* parking) const;
127
128 bool hasParkings() const;
129
134 ParkingAssignment getAvailableParking(double radius, const std::string& fltype,
135 const std::string& acType, const std::string& airline);
136
137 void setParkingAvailable(FGParking* park, bool available);
138
139 bool isParkingAvailable(FGParking* parking) const;
140
141 void releaseParking(FGParking* id);
142
143 FGParkingList getParkings(bool onlyAvailable, const std::string& type) const;
144
150 ParkingAssignment getParkingByName(const std::string& name) const;
151
157
158 FGParkingRef getOccupiedParkingByName(const std::string& name) const;
159
160 // ATC related functions.
162 {
163 return &startupController;
164 };
166 {
167 return &groundController;
168 };
170 {
171 return &towerController;
172 };
174 {
175 return &approachController;
176 };
177
178 int getApproachFrequency(unsigned nr);
179 int getGroundFrequency(unsigned leg);
180 int getTowerFrequency(unsigned nr);
181
183 const std::string getAtisSequence();
184
186 int updateAtisSequence(int interval, bool forceUpdate);
187
188 void setRwyUse(const FGRunwayPreference& ref);
189
190 ActiveRunwayQueue* getRunwayQueue(const std::string& name);
191};
std::vector< FGRunwayRef > FGRunwayList
std::vector< FGParkingRef > FGParkingList
SGSharedPtr< FGParking > FGParkingRef
FGParkingList getParkings(bool onlyAvailable, const std::string &type) const
Definition dynamics.cxx:405
double getElevation() const
Definition dynamics.cxx:873
ParkingAssignment getParkingByName(const std::string &name) const
Find a parking gate index by name.
Definition dynamics.cxx:315
bool hasParking(FGParking *parking) const
Definition dynamics.cxx:279
ActiveRunwayQueue * getRunwayQueue(const std::string &name)
Definition dynamics.cxx:842
const std::string getAtisSequence()
get current ATIS sequence letter
Definition dynamics.cxx:980
int updateAtisSequence(int interval, bool forceUpdate)
get the current ATIS sequence number, updating it if necessary
Definition dynamics.cxx:993
int getApproachFrequency(unsigned nr)
Definition dynamics.cxx:890
FGTowerController * getTowerController()
Definition dynamics.hxx:169
FGGroundController * getGroundController()
Definition dynamics.hxx:165
void releaseParking(FGParking *id)
Definition dynamics.cxx:369
FGAirportDynamics(FGAirport *ap)
Definition dynamics.cxx:197
void init()
Initialization required after XMLRead.
Definition dynamics.cxx:217
FGParkingRef getOccupiedParkingByName(const std::string &name) const
Definition dynamics.cxx:344
ParkingAssignment getAvailableParking(double radius, const std::string &fltype, const std::string &acType, const std::string &airline)
retrieve an available parking by GateID, or -1 if no suitable parking location could be found.
Definition dynamics.cxx:291
bool hasParkings() const
Definition dynamics.cxx:286
FGAirport * parent() const
Definition dynamics.hxx:116
virtual ~FGAirportDynamics()
Definition dynamics.cxx:209
int getGroundFrequency(unsigned leg)
Definition dynamics.cxx:920
void getActiveRunway(const std::string &trafficType, int action, std::string &runway, double heading)
Definition dynamics.cxx:830
ParkingAssignment getAvailableParkingByName(const std::string &name)
find a parking by name, if available.
Definition dynamics.cxx:328
void setParkingAvailable(FGParking *park, bool available)
Definition dynamics.cxx:355
FGApproachController * getApproachController()
Definition dynamics.hxx:173
FGStartupController * getStartupController()
Definition dynamics.hxx:161
const std::string getId() const
Definition dynamics.cxx:878
int getTowerFrequency(unsigned nr)
Definition dynamics.cxx:950
void setRwyUse(const FGRunwayPreference &ref)
Definition dynamics.cxx:415
bool isParkingAvailable(FGParking *parking) const
Definition dynamics.cxx:364
FGParking * parking() const
Definition dynamics.cxx:135
bool isValid() const
Definition dynamics.cxx:130
void operator=(const ParkingAssignment &aOther)
Definition dynamics.cxx:106
const char * name
std::vector< std::string > stringVec
std::vector< ActiveRunwayQueue > ActiveRunwayVec