Added a small and simple dialogbox that allows the user to issue ATC commands.
This commit is contained in:
parent
3bd4e99d81
commit
fa842a42b6
6 changed files with 58 additions and 111 deletions
|
@ -58,6 +58,7 @@ public:
|
||||||
void init();
|
void init();
|
||||||
void addController(FGATCController *controller);
|
void addController(FGATCController *controller);
|
||||||
void update(double time);
|
void update(double time);
|
||||||
|
FGATCDialogNew * getATCDialog() { return currentATCDialog; };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _ATC_MRG_HXX_
|
#endif // _ATC_MRG_HXX_
|
|
@ -86,6 +86,11 @@ static SGPropertyNode *getNamedNode(SGPropertyNode *prop, const char *name) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FGATCDialogNew::addEntry(int nr, string txt) {
|
||||||
|
commands.clear();
|
||||||
|
commands.push_back(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FGATCDialogNew::PopupDialog() {
|
void FGATCDialogNew::PopupDialog() {
|
||||||
double onBoardRadioFreq0 =
|
double onBoardRadioFreq0 =
|
||||||
|
@ -105,22 +110,24 @@ void FGATCDialogNew::PopupDialog() {
|
||||||
|
|
||||||
const int bufsize = 32;
|
const int bufsize = 32;
|
||||||
char buf[bufsize];
|
char buf[bufsize];
|
||||||
|
int commandNr = 0;
|
||||||
// loop over all entries that should fill up the dialog; use 10 items for now...
|
// loop over all entries that should fill up the dialog; use 10 items for now...
|
||||||
for (int i = 0; i < 10; i++) {
|
for (StringVecIterator i = commands.begin(); i != commands.end(); i++) {
|
||||||
snprintf(buf, bufsize, "/sim/atc/opt[%d]", i);
|
snprintf(buf, bufsize, "/sim/atc/opt[%d]", commandNr);
|
||||||
fgSetBool(buf, false);
|
fgSetBool(buf, false);
|
||||||
SGPropertyNode *entry = button_group->getNode("button", i, true);
|
SGPropertyNode *entry = button_group->getNode("button", commandNr, true);
|
||||||
copyProperties(button_group->getNode("button-template", true), entry);
|
copyProperties(button_group->getNode("button-template", true), entry);
|
||||||
entry->removeChildren("enabled", true);
|
entry->removeChildren("enabled", true);
|
||||||
entry->setStringValue("property", buf);
|
entry->setStringValue("property", buf);
|
||||||
entry->setIntValue("keynum", '1' + i);
|
entry->setIntValue("keynum", '1' + commandNr);
|
||||||
if (i == 0)
|
if (commandNr == 0)
|
||||||
entry->setBoolValue("default", true);
|
entry->setBoolValue("default", true);
|
||||||
|
|
||||||
snprintf(buf, bufsize, "%d", i + 1);
|
snprintf(buf, bufsize, "%d", 1 + commandNr);
|
||||||
string legend = string(buf) + ". test"; // + current->menuentry;
|
string legend = string(buf) + (*i); //"; // + current->menuentry;
|
||||||
entry->setStringValue("legend", legend.c_str());
|
entry->setStringValue("legend", legend.c_str());
|
||||||
entry->setIntValue("binding/value", i);
|
entry->setIntValue("binding/value", commandNr);
|
||||||
|
commandNr++;
|
||||||
//current++;
|
//current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,13 +40,16 @@
|
||||||
#include <GUI/gui.h> // mkDialog
|
#include <GUI/gui.h> // mkDialog
|
||||||
#include <GUI/new_gui.hxx>
|
#include <GUI/new_gui.hxx>
|
||||||
|
|
||||||
|
typedef vector<string> StringVec;
|
||||||
|
typedef vector<string>:: iterator StringVecIterator;
|
||||||
|
|
||||||
static bool doATCDialog(const SGPropertyNode* arg);
|
static bool doATCDialog(const SGPropertyNode* arg);
|
||||||
|
|
||||||
class FGATCDialogNew {
|
class FGATCDialogNew {
|
||||||
private:
|
private:
|
||||||
NewGUI *_gui;
|
NewGUI *_gui;
|
||||||
bool dialogVisible;
|
bool dialogVisible;
|
||||||
|
StringVec commands;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FGATCDialogNew();
|
FGATCDialogNew();
|
||||||
|
@ -56,6 +59,7 @@ public:
|
||||||
|
|
||||||
void update(double dt);
|
void update(double dt);
|
||||||
void PopupDialog();
|
void PopupDialog();
|
||||||
|
void addEntry(int, string);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FGATCDialogNew *currentATCDialog;
|
extern FGATCDialogNew *currentATCDialog;
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <AIModel/AIFlightPlan.hxx>
|
#include <AIModel/AIFlightPlan.hxx>
|
||||||
#include <AIModel/performancedata.hxx>
|
#include <AIModel/performancedata.hxx>
|
||||||
#include <AIModel/performancedb.hxx>
|
#include <AIModel/performancedb.hxx>
|
||||||
|
#include <ATC/atc_mgr.hxx>
|
||||||
#include <Traffic/TrafficMgr.hxx>
|
#include <Traffic/TrafficMgr.hxx>
|
||||||
#include <Airports/groundnetwork.hxx>
|
#include <Airports/groundnetwork.hxx>
|
||||||
#include <Airports/dynamics.hxx>
|
#include <Airports/dynamics.hxx>
|
||||||
|
@ -471,7 +472,7 @@ bool FGATCController::isUserAircraft(FGAIAircraft* ac)
|
||||||
};
|
};
|
||||||
|
|
||||||
void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
||||||
AtcMsgDir msgDir)
|
AtcMsgDir msgDir, bool audible)
|
||||||
{
|
{
|
||||||
string sender, receiver;
|
string sender, receiver;
|
||||||
int stationFreq = 0;
|
int stationFreq = 0;
|
||||||
|
@ -636,22 +637,28 @@ void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
||||||
text = text + sender + ". Transmitting unknown Message";
|
text = text + sender + ". Transmitting unknown Message";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
double onBoardRadioFreq0 =
|
if (audible) {
|
||||||
fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
|
double onBoardRadioFreq0 =
|
||||||
double onBoardRadioFreq1 =
|
fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
|
||||||
fgGetDouble("/instrumentation/comm[1]/frequencies/selected-mhz");
|
double onBoardRadioFreq1 =
|
||||||
int onBoardRadioFreqI0 = (int) floor(onBoardRadioFreq0 * 100 + 0.5);
|
fgGetDouble("/instrumentation/comm[1]/frequencies/selected-mhz");
|
||||||
int onBoardRadioFreqI1 = (int) floor(onBoardRadioFreq1 * 100 + 0.5);
|
int onBoardRadioFreqI0 = (int) floor(onBoardRadioFreq0 * 100 + 0.5);
|
||||||
//cerr << "Using " << onBoardRadioFreq0 << ", " << onBoardRadioFreq1 << " and " << stationFreq << " for " << text << endl;
|
int onBoardRadioFreqI1 = (int) floor(onBoardRadioFreq1 * 100 + 0.5);
|
||||||
|
//cerr << "Using " << onBoardRadioFreq0 << ", " << onBoardRadioFreq1 << " and " << stationFreq << " for " << text << endl;
|
||||||
|
|
||||||
// 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
|
||||||
if ((onBoardRadioFreqI0 == stationFreq)
|
if ((onBoardRadioFreqI0 == stationFreq)
|
||||||
|| (onBoardRadioFreqI1 == stationFreq)) {
|
|| (onBoardRadioFreqI1 == stationFreq)) {
|
||||||
if (rec->allowTransmissions()) {
|
if (rec->allowTransmissions()) {
|
||||||
fgSetString("/sim/messages/atc", text.c_str());
|
fgSetString("/sim/messages/atc", text.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
|
||||||
|
atc->getATCDialog()->addEntry(1, text);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1008,6 +1015,7 @@ bool FGStartupController::checkTransmissionState(int st, time_t now, time_t star
|
||||||
int state = i->getState();
|
int state = i->getState();
|
||||||
if ((state == st) && available) {
|
if ((state == st) && available) {
|
||||||
if ((msgDir == ATC_AIR_TO_GROUND) && isUserAircraft(i->getAircraft())) {
|
if ((msgDir == ATC_AIR_TO_GROUND) && isUserAircraft(i->getAircraft())) {
|
||||||
|
|
||||||
cerr << "Checking state " << st << " for " << i->getAircraft()->getCallSign() << endl;
|
cerr << "Checking state " << st << " for " << i->getAircraft()->getCallSign() << endl;
|
||||||
static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true);
|
static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true);
|
||||||
int n = trans_num->getIntValue();
|
int n = trans_num->getIntValue();
|
||||||
|
@ -1016,12 +1024,14 @@ bool FGStartupController::checkTransmissionState(int st, time_t now, time_t star
|
||||||
// PopupCallback(n);
|
// PopupCallback(n);
|
||||||
cerr << "Selected transmission message" << n << endl;
|
cerr << "Selected transmission message" << n << endl;
|
||||||
} else {
|
} else {
|
||||||
|
cerr << "creading message for " << i->getAircraft()->getCallSign() << endl;
|
||||||
|
transmit(&(*i), msgId, msgDir, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (now > startTime) {
|
if (now > startTime) {
|
||||||
//cerr << "Transmitting startup msg" << endl;
|
//cerr << "Transmitting startup msg" << endl;
|
||||||
transmit(&(*i), msgId, msgDir);
|
transmit(&(*i), msgId, msgDir, true);
|
||||||
i->updateState();
|
i->updateState();
|
||||||
lastTransmission = now;
|
lastTransmission = now;
|
||||||
available = false;
|
available = false;
|
||||||
|
@ -1084,92 +1094,17 @@ void FGStartupController::updateAircraftInformation(int id, double lat, double l
|
||||||
checkTransmissionState(6, now, (startTime + 150), i, MSG_ACKNOWLEDGE_INITIATE_CONTACT, ATC_GROUND_TO_AIR);
|
checkTransmissionState(6, now, (startTime + 150), i, MSG_ACKNOWLEDGE_INITIATE_CONTACT, ATC_GROUND_TO_AIR);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if ((state == 0) && available) {
|
|
||||||
if (now > startTime) {
|
|
||||||
//cerr << "Transmitting startup msg" << endl;
|
|
||||||
transmit(&(*i), MSG_ANNOUNCE_ENGINE_START, ATC_AIR_TO_GROUND);
|
|
||||||
i->updateState();
|
|
||||||
lastTransmission = now;
|
|
||||||
available = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((state == 1) && available) {
|
|
||||||
if (now > startTime + 60) {
|
|
||||||
transmit(&(*i), MSG_REQUEST_ENGINE_START, ATC_AIR_TO_GROUND);
|
|
||||||
i->updateState();
|
|
||||||
lastTransmission = now;
|
|
||||||
available = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((state == 2) && available) {
|
|
||||||
if (now > startTime + 80) {
|
|
||||||
transmit(&(*i), MSG_PERMIT_ENGINE_START, ATC_GROUND_TO_AIR);
|
|
||||||
i->updateState();
|
|
||||||
lastTransmission = now;
|
|
||||||
available = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((state == 3) && available) {
|
|
||||||
if (now > startTime + 100) {
|
|
||||||
transmit(&(*i), MSG_ACKNOWLEDGE_ENGINE_START,
|
|
||||||
ATC_AIR_TO_GROUND);
|
|
||||||
i->updateState();
|
|
||||||
lastTransmission = now;
|
|
||||||
available = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Note: The next four stages are only necessesary when Startup control is
|
|
||||||
// on a different frequency, compared to ground control
|
|
||||||
if ((state == 4) && available) {
|
|
||||||
if (now > startTime + 130) {
|
|
||||||
transmit(&(*i), MSG_ACKNOWLEDGE_SWITCH_GROUND_FREQUENCY,
|
|
||||||
ATC_AIR_TO_GROUND);
|
|
||||||
i->updateState();
|
|
||||||
i->nextFrequency();
|
|
||||||
lastTransmission = now;
|
|
||||||
available = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((state == 5) && available) {
|
|
||||||
if (now > startTime + 140) {
|
|
||||||
transmit(&(*i), MSG_INITIATE_CONTACT, ATC_AIR_TO_GROUND);
|
|
||||||
i->updateState();
|
|
||||||
lastTransmission = now;
|
|
||||||
available = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((state == 6) && available) {
|
|
||||||
if (now > startTime + 150) {
|
|
||||||
transmit(&(*i), MSG_ACKNOWLEDGE_INITIATE_CONTACT,
|
|
||||||
ATC_GROUND_TO_AIR);
|
|
||||||
i->updateState();
|
|
||||||
lastTransmission = now;
|
|
||||||
available = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Switch to APRON control and request pushback Clearance.
|
|
||||||
// Get Push back clearance
|
|
||||||
if ((state == 7) && available) {
|
|
||||||
if (now > startTime + 180) {
|
|
||||||
transmit(&(*i), MSG_REQUEST_PUSHBACK_CLEARANCE,
|
|
||||||
ATC_AIR_TO_GROUND);
|
|
||||||
i->updateState();
|
|
||||||
lastTransmission = now;
|
|
||||||
available = false;
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
if ((state == 8) && available) {
|
if ((state == 8) && available) {
|
||||||
if (now > startTime + 200) {
|
if (now > startTime + 200) {
|
||||||
if (i->pushBackAllowed()) {
|
if (i->pushBackAllowed()) {
|
||||||
i->allowRepeatedTransmissions();
|
i->allowRepeatedTransmissions();
|
||||||
transmit(&(*i), MSG_PERMIT_PUSHBACK_CLEARANCE,
|
transmit(&(*i), MSG_PERMIT_PUSHBACK_CLEARANCE,
|
||||||
ATC_GROUND_TO_AIR);
|
ATC_GROUND_TO_AIR, true);
|
||||||
i->updateState();
|
i->updateState();
|
||||||
} else {
|
} else {
|
||||||
transmit(&(*i), MSG_HOLD_PUSHBACK_CLEARANCE,
|
transmit(&(*i), MSG_HOLD_PUSHBACK_CLEARANCE,
|
||||||
ATC_GROUND_TO_AIR);
|
ATC_GROUND_TO_AIR, true);
|
||||||
i->suppressRepeatedTransmissions();
|
i->suppressRepeatedTransmissions();
|
||||||
}
|
}
|
||||||
lastTransmission = now;
|
lastTransmission = now;
|
||||||
|
|
|
@ -276,7 +276,7 @@ public:
|
||||||
|
|
||||||
double getDt() { return dt_count; };
|
double getDt() { return dt_count; };
|
||||||
void setDt(double dt) { dt_count = dt;};
|
void setDt(double dt) { dt_count = dt;};
|
||||||
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir);
|
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir, bool audible);
|
||||||
string getGateName(FGAIAircraft *aircraft);
|
string getGateName(FGAIAircraft *aircraft);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -569,19 +569,19 @@ void FGGroundNetwork::updateAircraftInformation(int id, double lat, double lon,
|
||||||
available = true;
|
available = true;
|
||||||
}
|
}
|
||||||
if ((state < 3) && available) {
|
if ((state < 3) && available) {
|
||||||
transmit(&(*current), MSG_REQUEST_TAXI_CLEARANCE, ATC_AIR_TO_GROUND);
|
transmit(&(*current), MSG_REQUEST_TAXI_CLEARANCE, ATC_AIR_TO_GROUND, true);
|
||||||
current->setState(3);
|
current->setState(3);
|
||||||
lastTransmission = now;
|
lastTransmission = now;
|
||||||
available = false;
|
available = false;
|
||||||
}
|
}
|
||||||
if ((state == 3) && available) {
|
if ((state == 3) && available) {
|
||||||
transmit(&(*current), MSG_ISSUE_TAXI_CLEARANCE, ATC_GROUND_TO_AIR);
|
transmit(&(*current), MSG_ISSUE_TAXI_CLEARANCE, ATC_GROUND_TO_AIR, true);
|
||||||
current->setState(4);
|
current->setState(4);
|
||||||
lastTransmission = now;
|
lastTransmission = now;
|
||||||
available = false;
|
available = false;
|
||||||
}
|
}
|
||||||
if ((state == 4) && available) {
|
if ((state == 4) && available) {
|
||||||
transmit(&(*current), MSG_ACKNOWLEDGE_TAXI_CLEARANCE, ATC_AIR_TO_GROUND);
|
transmit(&(*current), MSG_ACKNOWLEDGE_TAXI_CLEARANCE, ATC_AIR_TO_GROUND, true);
|
||||||
current->setState(5);
|
current->setState(5);
|
||||||
lastTransmission = now;
|
lastTransmission = now;
|
||||||
available = false;
|
available = false;
|
||||||
|
@ -846,11 +846,11 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
|
||||||
if ((origStatus != currStatus) && available) {
|
if ((origStatus != currStatus) && available) {
|
||||||
//cerr << "Issueing hold short instrudtion " << currStatus << " " << available << endl;
|
//cerr << "Issueing hold short instrudtion " << currStatus << " " << available << endl;
|
||||||
if (currStatus == true) { // No has a hold short instruction
|
if (currStatus == true) { // No has a hold short instruction
|
||||||
transmit(&(*current), MSG_HOLD_POSITION, ATC_GROUND_TO_AIR);
|
transmit(&(*current), MSG_HOLD_POSITION, ATC_GROUND_TO_AIR, true);
|
||||||
//cerr << "Transmittin hold short instrudtion " << currStatus << " " << available << endl;
|
//cerr << "Transmittin hold short instrudtion " << currStatus << " " << available << endl;
|
||||||
current->setState(1);
|
current->setState(1);
|
||||||
} else {
|
} else {
|
||||||
transmit(&(*current), MSG_RESUME_TAXI, ATC_GROUND_TO_AIR);
|
transmit(&(*current), MSG_RESUME_TAXI, ATC_GROUND_TO_AIR, true);
|
||||||
//cerr << "Transmittig resume instrudtion " << currStatus << " " << available << endl;
|
//cerr << "Transmittig resume instrudtion " << currStatus << " " << available << endl;
|
||||||
current->setState(2);
|
current->setState(2);
|
||||||
}
|
}
|
||||||
|
@ -865,7 +865,7 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
|
||||||
int state = current->getState();
|
int state = current->getState();
|
||||||
if ((state == 1) && (available)) {
|
if ((state == 1) && (available)) {
|
||||||
//cerr << "ACKNOWLEDGE HOLD" << endl;
|
//cerr << "ACKNOWLEDGE HOLD" << endl;
|
||||||
transmit(&(*current), MSG_ACKNOWLEDGE_HOLD_POSITION, ATC_AIR_TO_GROUND);
|
transmit(&(*current), MSG_ACKNOWLEDGE_HOLD_POSITION, ATC_AIR_TO_GROUND, true);
|
||||||
current->setState(0);
|
current->setState(0);
|
||||||
current->setHoldPosition(true);
|
current->setHoldPosition(true);
|
||||||
lastTransmission = now;
|
lastTransmission = now;
|
||||||
|
@ -874,7 +874,7 @@ void FGGroundNetwork::checkHoldPosition(int id, double lat,
|
||||||
}
|
}
|
||||||
if ((state == 2) && (available)) {
|
if ((state == 2) && (available)) {
|
||||||
//cerr << "ACKNOWLEDGE RESUME" << endl;
|
//cerr << "ACKNOWLEDGE RESUME" << endl;
|
||||||
transmit(&(*current), MSG_ACKNOWLEDGE_RESUME_TAXI, ATC_AIR_TO_GROUND);
|
transmit(&(*current), MSG_ACKNOWLEDGE_RESUME_TAXI, ATC_AIR_TO_GROUND, true);
|
||||||
current->setState(0);
|
current->setState(0);
|
||||||
current->setHoldPosition(false);
|
current->setHoldPosition(false);
|
||||||
lastTransmission = now;
|
lastTransmission = now;
|
||||||
|
|
Loading…
Reference in a new issue