{
string sender, receiver;
int stationFreq = 0;
+ int taxiFreq = 0;
+ string atisInformation;
//double commFreqD;
switch (msgDir) {
case ATC_AIR_TO_GROUND:
sender = rec->getAircraft()->getTrafficRef()->getCallSign();
switch (rec->getLeg()) {
case 2:
+ case 3:
stationFreq =
- rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency();
- receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
- break;
- case 3:
+ rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(rec->getLeg());
+ taxiFreq =
+ rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(3);
receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
+ atisInformation = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getAtisInformation();
break;
case 4:
receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Tower";
receiver = rec->getAircraft()->getTrafficRef()->getCallSign();
switch (rec->getLeg()) {
case 2:
+ case 3:
stationFreq =
- rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency();
- sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
- break;
- case 3:
+ rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(rec->getLeg());
+ taxiFreq =
+ rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(3);
sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
+ atisInformation = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getAtisInformation();
break;
+
case 4:
sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Tower";
break;
break;
}
string text;
+ string taxiFreqStr;
+ char buffer[7];
switch (msgId) {
case MSG_ANNOUNCE_ENGINE_START:
text = sender + ". Ready to Start up";
break;
case MSG_REQUEST_ENGINE_START:
text = receiver + ", This is " + sender + ". Position " +getGateName(rec->getAircraft()) +
- ". Information YY." +
+ ". Information " + atisInformation + ". " +
rec->getAircraft()->getTrafficRef()->getFlightRules() + " to " +
rec->getAircraft()->getTrafficRef()->getArrivalAirport()->getName() + ". Request start-up";
break;
case MSG_PERMIT_ENGINE_START:
- text = receiver + ". Start-up approved. YY correct, runway ZZ, AAA departure, squawk BBBB. " +
- "For push-back and taxi clearance call CCC.CCC. " + sender + " control.";
+ taxiFreqStr = formatATCFrequency3_2(taxiFreq);
+ text = receiver + ". Start-up approved. " + atisInformation + " correct, runway ZZ, AAA departure, squawk BBBB. " +
+ "For push-back and taxi clearance call " + taxiFreqStr + ". " + sender + " control.";
break;
case MSG_DENY_ENGINE_START:
text = receiver + ". Standby";
break;
case MSG_ACKNOWLEDGE_ENGINE_START:
- text = receiver + ". Start-up approved. YY correct, runway ZZ, AAA departure, squawk BBBB. " +
- "For push-back and taxi clearance call CCC.CCC. " + sender;
+ taxiFreqStr = formatATCFrequency3_2(taxiFreq);
+ text = receiver + ". Start-up approved. " + atisInformation + " correct, runway ZZ, AAA departure, squawk BBBB. " +
+ "For push-back and taxi clearance call " + taxiFreqStr + ". " + sender;
break;
default:
break;
// Display ATC message only when one of the radios is tuned
// the relevant frequency.
// Note that distance attenuation is currently not yet implemented
+ //cerr << "Transmitting " << text << " at " << stationFreq;
if ((onBoardRadioFreqI0 == stationFreq) || (onBoardRadioFreqI1 == stationFreq)) {
fgSetString("/sim/messages/atc", text.c_str());
//cerr << "Printing Message: " << endl;
}
}
+string FGATCController::formatATCFrequency3_2(int freq) {
+ char buffer[7];
+ snprintf(buffer, 7, "%3.2f", ( (float) freq / 100.0) );
+ return string(buffer);
+}
/***************************************************************************
* class FGTowerController
FGAirportDynamics::FGAirportDynamics(FGAirport* ap) :
_ap(ap), rwyPrefs(ap) {
lastUpdate = 0;
- for (int i = 0; i < 10; i++)
- {
- //avWindHeading [i] = 0;
- //avWindSpeed [i] = 0;
- }
+
+ // For testing only. This needs to be refined when we move ATIS functionality over.
+ atisInformation = "Sierra";
}
// Note that the ground network should also be copied
for (il = other.takeoff.begin(); il != other.takeoff.end(); il++)
takeoff.push_back(*il);
lastUpdate = other.lastUpdate;
- for (int i = 0; i < 10; i++)
- {
- //avWindHeading [i] = other.avWindHeading[i];
- //avWindSpeed [i] = other.avWindSpeed [i];
- }
+ atisInformation = other.atisInformation;
}
// Destructor
const string& FGAirportDynamics::getId() const {
return _ap->getId();
}
+
+// Experimental: Return a different ground frequency depending on the leg of the
+// Flight. Leg should always have a minimum value of two when this function is called.
+// Note that in this scheme, the assignment of various frequencies to various ground
+// operations is completely arbitrary. As such, is a short cut I need to take now,
+// so that at least I can start working on assigning different frequencies to different
+// operations.
+
+int FGAirportDynamics::getGroundFrequency(int leg) {
+ //return freqGround.size() ? freqGround[0] : 0; };
+ int groundFreq;
+ if (leg < 2) {
+ SG_LOG(SG_ATC, SG_ALERT, "Leg value is smaller than two at " << SG_ORIGIN);
+ }
+ if (freqGround.size() == 0) {
+ return 0;
+ }
+ if ((freqGround.size() >= leg-1) && (leg > 1)) {
+ groundFreq = freqGround[leg-1];
+ }
+ if ((freqGround.size() < leg-1) && (leg > 1)) {
+ groundFreq = (freqGround.size() < (leg-2)) ? freqGround[freqGround.size()-1] : freqGround[leg-2];
+ }
+ if ((freqGround.size() >= leg-1) && (leg > 1)) {
+ groundFreq = freqGround[leg-2];
+ }
+ return groundFreq;
+}
\ No newline at end of file
intVec freqTower; // </TOWER>
intVec freqApproach; // </APPROACH>
- // Experimental keep a running average of wind dir and speed to prevent
- // Erratic runway changes.
- // Note: I should add these to the copy constructor and assigment operator to be
- // constistent
- //double avWindHeading [10];
- //double avWindSpeed [10];
+ string atisInformation;
string chooseRunwayFallback();
bool innerGetActiveRunway(const string &trafficType, int action, string &runway);
//FGAirport *getAddress() { return this; };
//const string &getName() const { return _name;};
// Returns degrees
- int getGroundFrequency() { return freqGround.size() ? freqGround[0] : 0; };
+
+ // ATC related functions.
FGStartupController *getStartupController() { return &startupController; };
FGGroundNetwork *getGroundNetwork() { return &groundNetwork; };
FGTowerController *getTowerController() { return &towerController; };
-
+ const string& getAtisInformation() { return atisInformation; };
+ int getGroundFrequency(int leg); //{ return freqGround.size() ? freqGround[0] : 0; };
void setRwyUse(const FGRunwayPreference& ref);
};