operatingState = initialState;
switch(operatingState) {
case PARKED:
+ tuned_station = ground;
ourGate = ground->GetGateNode();
if(ourGate == NULL) {
// Implies no available gates - what shall we do?
Transform();
break;
case TAXIING:
+ tuned_station = ground;
// FIXME - implement this case properly
return(false); // remove this line when fixed!
break;
// since we've got the implementation for this case already.
// TODO - implement proper generic in_pattern startup.
+ tuned_station = tower;
+
// Get the active runway details (and copy them into rwy)
GetRwyDetails();
string trns = "Tower ";
double f = globals->get_ATC_mgr()->GetFrequency(airportID, TOWER) / 100.0;
char buf[10];
- sprintf(buf, "%f", f);
+ sprintf(buf, "%.2f", f);
trns += buf;
trns += " ";
trns += plane.callsign;
pending_transmission = trns;
- Transmit(30.0);
+ ConditionalTransmit(30.0);
responseCounter = 0.0;
contactTower = false;
changeFreq = true;
if((changeFreq) && (responseCounter > 8.0)) {
switch(changeFreqType) {
case TOWER:
+ tuned_station = tower;
freq = (double)tower->get_freq() / 100.0;
//Transmit("DING!");
// Contact the tower, even if only virtually
tower->ContactAtHoldShort(plane, this, CIRCUIT);
break;
case GROUND:
+ tuned_station = ground;
freq = (double)ground->get_freq() / 100.0;
break;
// And to avoid compiler warnings...
- case APPROACH:
- break;
- case ATIS:
- break;
- case ENROUTE:
- break;
- case DEPARTURE:
- break;
- case INVALID:
- break;
+ case APPROACH: break;
+ case ATIS: break;
+ case ENROUTE: break;
+ case DEPARTURE: break;
+ case INVALID: break;
}
}
StartTaxi();
} else if(!taxiRequestPending) {
//cout << "(" << flush;
- ground->RequestDeparture(plane, this);
// Do some communication
// airport name + tower + airplane callsign + location + request taxi for + operation type + ?
string trns = "";
trns += " on apron parking request taxi for traffic pattern";
//cout << "trns = " << trns << endl;
pending_transmission = trns;
- Transmit();
+ Transmit(1);
taxiRequestCleared = false;
taxiRequestPending = true;
}
//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
- cout << "Descent to start = " << stod << " meters out\n";
+ //cout << "Descent to start = " << stod << " meters out\n";
if(stod < blp) { // Start descending on final
SoD.leg = FINAL;
SoD.y = stod * -1.0;
void FGAILocalTraffic::TransmitPatternPositionReport(void) {
// airport name + "traffic" + airplane callsign + pattern direction + pattern leg + rwy + ?
string trns = "";
+ int code = 0;
trns += tower->get_name();
trns += " Traffic ";
// Fall through to DOWNWIND
case DOWNWIND:
trns += "downwind ";
+ code = 11;
break;
case TURN3:
// Fall through to BASE
trns += tower->get_name();
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) {