1
0
Fork 0

Some further work toward adding more AI/ATC messages. This patch provides

some prepratory work for assigning different operations to different
frequencies. It also returns a stub for returning an ATIS message ID.
Currently, the ATIC information ID is hardcoded to "Sierra", which needs
to be replaced by a dynamic ID once ATIS services are fully integrated
with the new trafficcontrol code. At least, it's marginally more realistic
then the previous information XX. :-).
This commit is contained in:
durk 2009-02-07 17:17:07 +00:00 committed by Tim Moore
parent 83ece7efec
commit 916240693f
4 changed files with 69 additions and 31 deletions

View file

@ -337,18 +337,21 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
{ {
string sender, receiver; string sender, receiver;
int stationFreq = 0; int stationFreq = 0;
int taxiFreq = 0;
string atisInformation;
//double commFreqD; //double commFreqD;
switch (msgDir) { switch (msgDir) {
case ATC_AIR_TO_GROUND: case ATC_AIR_TO_GROUND:
sender = rec->getAircraft()->getTrafficRef()->getCallSign(); sender = rec->getAircraft()->getTrafficRef()->getCallSign();
switch (rec->getLeg()) { switch (rec->getLeg()) {
case 2: case 2:
case 3:
stationFreq = stationFreq =
rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(); rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(rec->getLeg());
receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground"; taxiFreq =
break; rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(3);
case 3:
receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground"; receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
atisInformation = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getAtisInformation();
break; break;
case 4: case 4:
receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Tower"; receiver = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Tower";
@ -359,13 +362,15 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
receiver = rec->getAircraft()->getTrafficRef()->getCallSign(); receiver = rec->getAircraft()->getTrafficRef()->getCallSign();
switch (rec->getLeg()) { switch (rec->getLeg()) {
case 2: case 2:
case 3:
stationFreq = stationFreq =
rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(); rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(rec->getLeg());
sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground"; taxiFreq =
break; rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getGroundFrequency(3);
case 3:
sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground"; sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Ground";
atisInformation = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getDynamics()->getAtisInformation();
break; break;
case 4: case 4:
sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Tower"; sender = rec->getAircraft()->getTrafficRef()->getDepartureAirport()->getName() + "-Tower";
break; break;
@ -373,26 +378,30 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
break; break;
} }
string text; string text;
string taxiFreqStr;
char buffer[7];
switch (msgId) { switch (msgId) {
case MSG_ANNOUNCE_ENGINE_START: case MSG_ANNOUNCE_ENGINE_START:
text = sender + ". Ready to Start up"; text = sender + ". Ready to Start up";
break; break;
case MSG_REQUEST_ENGINE_START: case MSG_REQUEST_ENGINE_START:
text = receiver + ", This is " + sender + ". Position " +getGateName(rec->getAircraft()) + text = receiver + ", This is " + sender + ". Position " +getGateName(rec->getAircraft()) +
". Information YY." + ". Information " + atisInformation + ". " +
rec->getAircraft()->getTrafficRef()->getFlightRules() + " to " + rec->getAircraft()->getTrafficRef()->getFlightRules() + " to " +
rec->getAircraft()->getTrafficRef()->getArrivalAirport()->getName() + ". Request start-up"; rec->getAircraft()->getTrafficRef()->getArrivalAirport()->getName() + ". Request start-up";
break; break;
case MSG_PERMIT_ENGINE_START: case MSG_PERMIT_ENGINE_START:
text = receiver + ". Start-up approved. YY correct, runway ZZ, AAA departure, squawk BBBB. " + taxiFreqStr = formatATCFrequency3_2(taxiFreq);
"For push-back and taxi clearance call CCC.CCC. " + sender + " control."; text = receiver + ". Start-up approved. " + atisInformation + " correct, runway ZZ, AAA departure, squawk BBBB. " +
"For push-back and taxi clearance call " + taxiFreqStr + ". " + sender + " control.";
break; break;
case MSG_DENY_ENGINE_START: case MSG_DENY_ENGINE_START:
text = receiver + ". Standby"; text = receiver + ". Standby";
break; break;
case MSG_ACKNOWLEDGE_ENGINE_START: case MSG_ACKNOWLEDGE_ENGINE_START:
text = receiver + ". Start-up approved. YY correct, runway ZZ, AAA departure, squawk BBBB. " + taxiFreqStr = formatATCFrequency3_2(taxiFreq);
"For push-back and taxi clearance call CCC.CCC. " + sender; text = receiver + ". Start-up approved. " + atisInformation + " correct, runway ZZ, AAA departure, squawk BBBB. " +
"For push-back and taxi clearance call " + taxiFreqStr + ". " + sender;
break; break;
default: default:
break; break;
@ -406,12 +415,18 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
// Display ATC message only when one of the radios is tuned // Display ATC message only when one of the radios is tuned
// the relevant frequency. // the relevant frequency.
// Note that distance attenuation is currently not yet implemented // Note that distance attenuation is currently not yet implemented
//cerr << "Transmitting " << text << " at " << stationFreq;
if ((onBoardRadioFreqI0 == stationFreq) || (onBoardRadioFreqI1 == stationFreq)) { if ((onBoardRadioFreqI0 == stationFreq) || (onBoardRadioFreqI1 == stationFreq)) {
fgSetString("/sim/messages/atc", text.c_str()); fgSetString("/sim/messages/atc", text.c_str());
//cerr << "Printing Message: " << endl; //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 * class FGTowerController

View file

@ -204,6 +204,10 @@ class FGATCController
{ {
private: private:
double dt_count; double dt_count;
string formatATCFrequency3_2(int );
public: public:
typedef enum { typedef enum {
MSG_ANNOUNCE_ENGINE_START, MSG_ANNOUNCE_ENGINE_START,

View file

@ -54,11 +54,9 @@ using std::random_shuffle;
FGAirportDynamics::FGAirportDynamics(FGAirport* ap) : FGAirportDynamics::FGAirportDynamics(FGAirport* ap) :
_ap(ap), rwyPrefs(ap) { _ap(ap), rwyPrefs(ap) {
lastUpdate = 0; lastUpdate = 0;
for (int i = 0; i < 10; i++)
{ // For testing only. This needs to be refined when we move ATIS functionality over.
//avWindHeading [i] = 0; atisInformation = "Sierra";
//avWindSpeed [i] = 0;
}
} }
// Note that the ground network should also be copied // Note that the ground network should also be copied
@ -76,11 +74,7 @@ FGAirportDynamics::FGAirportDynamics(const FGAirportDynamics& other) :
for (il = other.takeoff.begin(); il != other.takeoff.end(); il++) for (il = other.takeoff.begin(); il != other.takeoff.end(); il++)
takeoff.push_back(*il); takeoff.push_back(*il);
lastUpdate = other.lastUpdate; lastUpdate = other.lastUpdate;
for (int i = 0; i < 10; i++) atisInformation = other.atisInformation;
{
//avWindHeading [i] = other.avWindHeading[i];
//avWindSpeed [i] = other.avWindSpeed [i];
}
} }
// Destructor // Destructor
@ -515,3 +509,31 @@ double FGAirportDynamics::getElevation() const {
const string& FGAirportDynamics::getId() const { const string& FGAirportDynamics::getId() const {
return _ap->getId(); 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;
}

View file

@ -64,12 +64,7 @@ private:
intVec freqTower; // </TOWER> intVec freqTower; // </TOWER>
intVec freqApproach; // </APPROACH> intVec freqApproach; // </APPROACH>
// Experimental keep a running average of wind dir and speed to prevent string atisInformation;
// 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 chooseRunwayFallback(); string chooseRunwayFallback();
bool innerGetActiveRunway(const string &trafficType, int action, string &runway); bool innerGetActiveRunway(const string &trafficType, int action, string &runway);
@ -107,13 +102,15 @@ public:
//FGAirport *getAddress() { return this; }; //FGAirport *getAddress() { return this; };
//const string &getName() const { return _name;}; //const string &getName() const { return _name;};
// Returns degrees // Returns degrees
int getGroundFrequency() { return freqGround.size() ? freqGround[0] : 0; };
// ATC related functions.
FGStartupController *getStartupController() { return &startupController; }; FGStartupController *getStartupController() { return &startupController; };
FGGroundNetwork *getGroundNetwork() { return &groundNetwork; }; FGGroundNetwork *getGroundNetwork() { return &groundNetwork; };
FGTowerController *getTowerController() { return &towerController; }; FGTowerController *getTowerController() { return &towerController; };
const string& getAtisInformation() { return atisInformation; };
int getGroundFrequency(int leg); //{ return freqGround.size() ? freqGround[0] : 0; };
void setRwyUse(const FGRunwayPreference& ref); void setRwyUse(const FGRunwayPreference& ref);
}; };