30#include <osg/Geometry>
31#include <osg/MatrixTransform>
34#include <simgear/scene/material/EffectGeode.hxx>
35#include <simgear/scene/material/matlib.hxx>
36#include <simgear/scene/material/mat.hxx>
37#include <simgear/scene/util/OsgMath.hxx>
38#include <simgear/timing/sg_time.hxx>
81 double lat,
double lon,
82 double heading,
double speed,
83 double alt,
double radius,
96 rec->setPositionAndHeading(lat, lon, heading, speed, alt, leg);
100 rec->setAircraft(ref);
104 (*i)->setRunway(intendedRoute->
getRunway());
105 (*i)->setPositionAndHeading(lat, lon, heading, speed, alt, leg);
111 double heading,
double speed,
double alt,
114 time_t now =
globals->get_time_params()->get_cur_time();
121 SG_LOG(SG_ATC, SG_ALERT,
122 "FGApproachController updating aircraft without traffic record at " << SG_ORIGIN);
124 (*i)->setPositionAndHeading(geod.getLatitudeDeg(), geod.getLongitudeDeg(), heading, speed, alt,
AILeg::UNKNOWN);
126 if((*current)->getAircraft()) {
129 (*current)->getAircraft()->
130 checkForArrivalTime(
string(
"final001"));
131 if (time_diff != 0) {
132 SG_LOG(SG_ATC, SG_BULK, (*current)->getCallsign() <<
"|ApproachController: checking for speed " << time_diff);
134 if (time_diff > 15) {
135 (*current)->setSpeedAdjustment((*current)->getAircraft()->
136 getPerformance()->vDescent() *
138 }
else if (time_diff > 5) {
139 (*current)->setSpeedAdjustment((*current)->getAircraft()->
140 getPerformance()->vDescent() *
142 }
else if (time_diff < -15) {
143 (*current)->setSpeedAdjustment((*current)->getAircraft()->
144 getPerformance()->vDescent() *
146 }
else if (time_diff < -5) {
147 (*current)->setSpeedAdjustment((*current)->getAircraft()->
148 getPerformance()->vDescent() *
151 (*current)->clearSpeedAdjustment();
157 SG_LOG(SG_ATC, SG_DEBUG, (*current)->getCallsign() <<
"(" << (*current)->getId() <<
") " <<
" Hold " << (*current)->getRunwaySlot() <<
" " << (*current)->getPlannedArrivalTime() <<
" " << ((*current)->getRunwaySlot() > (*current)->getPlannedArrivalTime()));
158 if ((*current)->getRunwaySlot() > (*current)->getPlannedArrivalTime()) {
166 parent->getRunwayQueue((*current)->getRunway())->requestTimeSlot((*current));
198 SG_LOG(SG_ATC, SG_BULK,
"FGApproachController::render function not yet implemented");
203 return string(
parent->parent()->getName() +
"-approach");
206int FGApproachController::getFrequency() {
209 return groundFreq>0?groundFreq:towerFreq;
const std::string & getCallSign() const
const std::string & getRunway() const
time_t getArrivalTime() const
TrafficVectorIterator searchActiveTraffic(int id) const
Search activeTraffic vector to find matching id.
FGAirportDynamics * parent
TrafficVector activeTraffic
@ MSG_ACKNOWLEDGE_CLEARED_TO_LAND
@ MSG_SWITCH_TOWER_FREQUENCY
@ MSG_ACKNOWLEDGE_ARRIVAL
@ MSG_ACKNOWLEDGE_SWITCH_TOWER_FREQUENCY
bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId, AtcMsgDir msgDir)
int getApproachFrequency(unsigned nr)
int getTowerFrequency(unsigned nr)
FGApproachController(FGAirportDynamics *parent)
virtual void render(bool)
virtual std::string getName() const
virtual void update(double dt)
Periodically check for and remove dead traffic records.
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)
virtual void updateAircraftInformation(int id, SGGeod geod, double heading, double speed, double alt, double dt)
virtual ~FGApproachController()
@ ACK_SWITCH_GROUND_TOWER
std::list< SGSharedPtr< FGTrafficRecord > >::const_iterator TrafficVectorIterator