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:
parent
83ece7efec
commit
916240693f
4 changed files with 69 additions and 31 deletions
|
@ -337,18 +337,21 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
|
|||
{
|
||||
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";
|
||||
|
@ -359,13 +362,15 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
|
|||
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;
|
||||
|
@ -373,26 +378,30 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
|
|||
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;
|
||||
|
@ -406,12 +415,18 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m
|
|||
// 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
|
||||
|
|
|
@ -204,6 +204,10 @@ class FGATCController
|
|||
{
|
||||
private:
|
||||
double dt_count;
|
||||
|
||||
|
||||
string formatATCFrequency3_2(int );
|
||||
|
||||
public:
|
||||
typedef enum {
|
||||
MSG_ANNOUNCE_ENGINE_START,
|
||||
|
|
|
@ -54,11 +54,9 @@ using std::random_shuffle;
|
|||
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
|
||||
|
@ -76,11 +74,7 @@ FGAirportDynamics::FGAirportDynamics(const FGAirportDynamics& other) :
|
|||
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
|
||||
|
@ -515,3 +509,31 @@ double FGAirportDynamics::getElevation() const {
|
|||
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;
|
||||
}
|
|
@ -64,12 +64,7 @@ private:
|
|||
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);
|
||||
|
@ -107,13 +102,15 @@ public:
|
|||
//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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue