FlightGear next
ATCController.hxx
Go to the documentation of this file.
1/*
2 * SPDX-FileName: ATCController.hxx
3 * SPDX-FileComment: Extracted from trafficrecord.hxx - Implementation of AIModels ATC code.
4 * SPDX-FileCopyrightText: Copyright (C) 2006 Durk Talsma
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8#ifndef ATC_CONTROLLER_HXX
9#define ATC_CONTROLLER_HXX
10
12
13#include <random>
14
15#include <osg/Geode>
16#include <osg/Geometry>
17#include <osg/MatrixTransform>
18#include <osg/Shape>
19
20#include <simgear/compiler.h>
21#include <simgear/constants.h>
22#include <simgear/debug/logstream.hxx>
23#include <simgear/structure/SGReferenced.hxx>
24#include <simgear/structure/SGSharedPtr.hxx>
25
28
30{
31 enum Type
32 {
33 // 0 = Normal; no action required
35 // 1 = "Acknowledge "Hold position
37 // 2 = "Acknowledge "Resume taxi".
39 // 3 = "Issue TaxiClearance"
41 // 4 = Acknowledge Taxi Clearance"
43 // 5 = Post acknowlegde taxiclearance: Start taxiing
45 // 6 = Report runway
47 // 7 = Acknowledge report runway
49 // 8 = Switch tower frequency
51 // 9 = Acknowledge switch tower frequency
53 // 10 = Cleared for takeoff
64 };
65}
66
72{
73private:
74
75
76protected:
77 // guard variable to avoid modifying state during destruction
78 bool _isDestroying = false;
83 std::default_random_engine generator;
84 double dt_count;
85 osg::Group* group;
87 /*Shared Groundradar. All controllers of an airport share it.*/
88 SGSharedPtr<AirportGroundRadar> airportGroundRadar;
89
90
91 std::string formatATCFrequency3_2(int );
92 std::string genTransponderCode(const std::string& fltRules);
96 void eraseDeadTraffic();
98 virtual int getFrequency() = 0;
99public:
134
139
141 virtual ~FGATCController();
142 void init();
143 void setAirportGroundRadar(SGSharedPtr<AirportGroundRadar> groundRadar);
144
145
146 virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
147 double lat, double lon,
148 double hdg, double spd, double alt, double radius, int leg,
149 FGAIAircraft *aircraft) = 0;
150 virtual void updateAircraftInformation(int id, SGGeod geod,
151 double heading, double speed, double alt, double dt) = 0;
152 bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
153 AtcMsgDir msgDir);
154
155 SGSharedPtr<FGTrafficRecord> getRecord(int id) const;
156 virtual void handover(SGSharedPtr<FGTrafficRecord> aiObject, int leg);
157
158 virtual void signOff(int id);
159 bool hasInstruction(int id);
161
163 return ! activeTraffic.empty();
164 };
168
169 double getDt() {
170 return dt_count;
171 };
172 void setDt(double dt) {
173 dt_count = dt;
174 };
175 void transmit(FGTrafficRecord *rec, FGAirportDynamics *parent, AtcMsgId msgId, AtcMsgDir msgDir, bool audible);
176 std::string getGateName(FGAIAircraft *aircraft);
177 virtual void render(bool) = 0;
178 virtual std::string getName() const = 0;
179 virtual void update(double) = 0;
180
181
182private:
183 AtcMsgDir lastTransmissionDirection;
184};
185
186#endif
const double rec
#define i(x)
std::default_random_engine generator
virtual void updateAircraftInformation(int id, SGGeod geod, double heading, double speed, double alt, double dt)=0
void clearTrafficControllers()
bool hasInstruction(int id)
TrafficVectorIterator searchActiveTraffic(int id) const
Search activeTraffic vector to find matching id.
TrafficVector & getActiveTraffic()
virtual void update(double)=0
bool isUserAircraft(FGAIAircraft *)
virtual void handover(SGSharedPtr< FGTrafficRecord > aiObject, int leg)
We share the traffic record much like real life.
virtual ~FGATCController()
virtual void signOff(int id)
Sign off the aircraft with the id from this controller.
FGAirportDynamics * parent
void setAirportGroundRadar(SGSharedPtr< AirportGroundRadar > groundRadar)
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute, double lat, double lon, double hdg, double spd, double alt, double radius, int leg, FGAIAircraft *aircraft)=0
SGSharedPtr< FGTrafficRecord > getRecord(int id) const
FGATCInstruction getInstruction(int id)
SGSharedPtr< AirportGroundRadar > airportGroundRadar
TrafficVector activeTraffic
void setDt(double dt)
osg::Group * group
virtual int getFrequency()=0
Returns the frequency to be used.
virtual void render(bool)=0
virtual std::string getName() const =0
void transmit(FGTrafficRecord *rec, FGAirportDynamics *parent, AtcMsgId msgId, AtcMsgDir msgDir, bool audible)
std::string genTransponderCode(const std::string &fltRules)
@ MSG_ACKNOWLEDGE_REPORT_RUNWAY_HOLD_SHORT
@ MSG_ACKNOWLEDGE_SWITCH_GROUND_FREQUENCY
@ MSG_ACKNOWLEDGE_SWITCH_TOWER_FREQUENCY
std::string formatATCFrequency3_2(int)
bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId, AtcMsgDir msgDir)
std::string getGateName(FGAIAircraft *aircraft)
std::list< SGSharedPtr< FGTrafficRecord > >::const_iterator TrafficVectorIterator
std::list< SGSharedPtr< FGTrafficRecord > > TrafficVector