Tweaks to use the ATC/AI interaction framework
This commit is contained in:
parent
d5d9723d9b
commit
c76dd941f4
2 changed files with 37 additions and 17 deletions
|
@ -200,6 +200,7 @@ bool FGAILocalTraffic::Init(string ICAO, OperatingState initialState, PatternLeg
|
||||||
operatingState = initialState;
|
operatingState = initialState;
|
||||||
switch(operatingState) {
|
switch(operatingState) {
|
||||||
case PARKED:
|
case PARKED:
|
||||||
|
tuned_station = ground;
|
||||||
ourGate = ground->GetGateNode();
|
ourGate = ground->GetGateNode();
|
||||||
if(ourGate == NULL) {
|
if(ourGate == NULL) {
|
||||||
// Implies no available gates - what shall we do?
|
// Implies no available gates - what shall we do?
|
||||||
|
@ -223,6 +224,7 @@ bool FGAILocalTraffic::Init(string ICAO, OperatingState initialState, PatternLeg
|
||||||
Transform();
|
Transform();
|
||||||
break;
|
break;
|
||||||
case TAXIING:
|
case TAXIING:
|
||||||
|
tuned_station = ground;
|
||||||
// FIXME - implement this case properly
|
// FIXME - implement this case properly
|
||||||
return(false); // remove this line when fixed!
|
return(false); // remove this line when fixed!
|
||||||
break;
|
break;
|
||||||
|
@ -231,6 +233,8 @@ bool FGAILocalTraffic::Init(string ICAO, OperatingState initialState, PatternLeg
|
||||||
// since we've got the implementation for this case already.
|
// since we've got the implementation for this case already.
|
||||||
// TODO - implement proper generic in_pattern startup.
|
// TODO - implement proper generic in_pattern startup.
|
||||||
|
|
||||||
|
tuned_station = tower;
|
||||||
|
|
||||||
// Get the active runway details (and copy them into rwy)
|
// Get the active runway details (and copy them into rwy)
|
||||||
GetRwyDetails();
|
GetRwyDetails();
|
||||||
|
|
||||||
|
@ -315,12 +319,12 @@ void FGAILocalTraffic::Update(double dt) {
|
||||||
string trns = "Tower ";
|
string trns = "Tower ";
|
||||||
double f = globals->get_ATC_mgr()->GetFrequency(airportID, TOWER) / 100.0;
|
double f = globals->get_ATC_mgr()->GetFrequency(airportID, TOWER) / 100.0;
|
||||||
char buf[10];
|
char buf[10];
|
||||||
sprintf(buf, "%f", f);
|
sprintf(buf, "%.2f", f);
|
||||||
trns += buf;
|
trns += buf;
|
||||||
trns += " ";
|
trns += " ";
|
||||||
trns += plane.callsign;
|
trns += plane.callsign;
|
||||||
pending_transmission = trns;
|
pending_transmission = trns;
|
||||||
Transmit(30.0);
|
ConditionalTransmit(30.0);
|
||||||
responseCounter = 0.0;
|
responseCounter = 0.0;
|
||||||
contactTower = false;
|
contactTower = false;
|
||||||
changeFreq = true;
|
changeFreq = true;
|
||||||
|
@ -330,6 +334,7 @@ void FGAILocalTraffic::Update(double dt) {
|
||||||
if((changeFreq) && (responseCounter > 8.0)) {
|
if((changeFreq) && (responseCounter > 8.0)) {
|
||||||
switch(changeFreqType) {
|
switch(changeFreqType) {
|
||||||
case TOWER:
|
case TOWER:
|
||||||
|
tuned_station = tower;
|
||||||
freq = (double)tower->get_freq() / 100.0;
|
freq = (double)tower->get_freq() / 100.0;
|
||||||
//Transmit("DING!");
|
//Transmit("DING!");
|
||||||
// Contact the tower, even if only virtually
|
// Contact the tower, even if only virtually
|
||||||
|
@ -337,19 +342,15 @@ void FGAILocalTraffic::Update(double dt) {
|
||||||
tower->ContactAtHoldShort(plane, this, CIRCUIT);
|
tower->ContactAtHoldShort(plane, this, CIRCUIT);
|
||||||
break;
|
break;
|
||||||
case GROUND:
|
case GROUND:
|
||||||
|
tuned_station = ground;
|
||||||
freq = (double)ground->get_freq() / 100.0;
|
freq = (double)ground->get_freq() / 100.0;
|
||||||
break;
|
break;
|
||||||
// And to avoid compiler warnings...
|
// And to avoid compiler warnings...
|
||||||
case APPROACH:
|
case APPROACH: break;
|
||||||
break;
|
case ATIS: break;
|
||||||
case ATIS:
|
case ENROUTE: break;
|
||||||
break;
|
case DEPARTURE: break;
|
||||||
case ENROUTE:
|
case INVALID: break;
|
||||||
break;
|
|
||||||
case DEPARTURE:
|
|
||||||
break;
|
|
||||||
case INVALID:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +470,6 @@ void FGAILocalTraffic::Update(double dt) {
|
||||||
StartTaxi();
|
StartTaxi();
|
||||||
} else if(!taxiRequestPending) {
|
} else if(!taxiRequestPending) {
|
||||||
//cout << "(" << flush;
|
//cout << "(" << flush;
|
||||||
ground->RequestDeparture(plane, this);
|
|
||||||
// Do some communication
|
// Do some communication
|
||||||
// airport name + tower + airplane callsign + location + request taxi for + operation type + ?
|
// airport name + tower + airplane callsign + location + request taxi for + operation type + ?
|
||||||
string trns = "";
|
string trns = "";
|
||||||
|
@ -479,7 +479,7 @@ void FGAILocalTraffic::Update(double dt) {
|
||||||
trns += " on apron parking request taxi for traffic pattern";
|
trns += " on apron parking request taxi for traffic pattern";
|
||||||
//cout << "trns = " << trns << endl;
|
//cout << "trns = " << trns << endl;
|
||||||
pending_transmission = trns;
|
pending_transmission = trns;
|
||||||
Transmit();
|
Transmit(1);
|
||||||
taxiRequestCleared = false;
|
taxiRequestCleared = false;
|
||||||
taxiRequestPending = true;
|
taxiRequestPending = true;
|
||||||
}
|
}
|
||||||
|
@ -892,7 +892,7 @@ void FGAILocalTraffic::CalculateSoD(double base_leg_pos, double downwind_leg_pos
|
||||||
//double turn_allowance = 150.0; // Approximate distance in meters that a 90deg corner is shortened by turned in a light plane.
|
//double turn_allowance = 150.0; // Approximate distance in meters that a 90deg corner is shortened by turned in a light plane.
|
||||||
|
|
||||||
double stod = pa / tan(ga * DCL_DEGREES_TO_RADIANS); // distance in meters from touchdown point to start descent
|
double stod = pa / tan(ga * DCL_DEGREES_TO_RADIANS); // distance in meters from touchdown point to start descent
|
||||||
cout << "Descent to start = " << stod << " meters out\n";
|
//cout << "Descent to start = " << stod << " meters out\n";
|
||||||
if(stod < blp) { // Start descending on final
|
if(stod < blp) { // Start descending on final
|
||||||
SoD.leg = FINAL;
|
SoD.leg = FINAL;
|
||||||
SoD.y = stod * -1.0;
|
SoD.y = stod * -1.0;
|
||||||
|
@ -911,6 +911,7 @@ void FGAILocalTraffic::CalculateSoD(double base_leg_pos, double downwind_leg_pos
|
||||||
void FGAILocalTraffic::TransmitPatternPositionReport(void) {
|
void FGAILocalTraffic::TransmitPatternPositionReport(void) {
|
||||||
// airport name + "traffic" + airplane callsign + pattern direction + pattern leg + rwy + ?
|
// airport name + "traffic" + airplane callsign + pattern direction + pattern leg + rwy + ?
|
||||||
string trns = "";
|
string trns = "";
|
||||||
|
int code = 0;
|
||||||
|
|
||||||
trns += tower->get_name();
|
trns += tower->get_name();
|
||||||
trns += " Traffic ";
|
trns += " Traffic ";
|
||||||
|
@ -932,6 +933,7 @@ void FGAILocalTraffic::TransmitPatternPositionReport(void) {
|
||||||
// Fall through to DOWNWIND
|
// Fall through to DOWNWIND
|
||||||
case DOWNWIND:
|
case DOWNWIND:
|
||||||
trns += "downwind ";
|
trns += "downwind ";
|
||||||
|
code = 11;
|
||||||
break;
|
break;
|
||||||
case TURN3:
|
case TURN3:
|
||||||
// Fall through to BASE
|
// Fall through to BASE
|
||||||
|
@ -954,7 +956,21 @@ void FGAILocalTraffic::TransmitPatternPositionReport(void) {
|
||||||
trns += tower->get_name();
|
trns += tower->get_name();
|
||||||
|
|
||||||
pending_transmission = trns; // FIXME - make up pending_transmission natively
|
pending_transmission = trns; // FIXME - make up pending_transmission natively
|
||||||
Transmit(90.0); // Assume a report of this leg will be invalid if we can't transmit within a minute and a half.
|
ConditionalTransmit(90.0, code); // Assume a report of this leg will be invalid if we can't transmit within a minute and a half.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Callback handler
|
||||||
|
void FGAILocalTraffic::ProcessCallback(int code) {
|
||||||
|
// 1 - Request Departure from ground
|
||||||
|
// 10 - report crosswind
|
||||||
|
// 11 - report downwind
|
||||||
|
// 12 - report base
|
||||||
|
// 13 - report final
|
||||||
|
if(code == 1) {
|
||||||
|
ground->RequestDeparture(plane, this);
|
||||||
|
} else if(code == 11) {
|
||||||
|
tower->ReportDownwind(plane.callsign);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGAILocalTraffic::ExitRunway(Point3D orthopos) {
|
void FGAILocalTraffic::ExitRunway(Point3D orthopos) {
|
||||||
|
|
|
@ -82,6 +82,10 @@ public:
|
||||||
|
|
||||||
void RegisterTransmission(int code);
|
void RegisterTransmission(int code);
|
||||||
|
|
||||||
|
// Process callbacks sent by base class
|
||||||
|
// (These codes are not related to the codes above)
|
||||||
|
void ProcessCallback(int code);
|
||||||
|
|
||||||
// This is a hack and will probably go eventually
|
// This is a hack and will probably go eventually
|
||||||
inline bool AtHoldShort() {return holdingShort;}
|
inline bool AtHoldShort() {return holdingShort;}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue