Some cleanup in the ATC/AI code before merging with the next branch:
- Hide the ATC dialog box by default - Allow dynamic enabling and disabling of the AI groundnetwork visualization - Cleanup of debug messages
This commit is contained in:
parent
5228053f7f
commit
3f26233d69
8 changed files with 162 additions and 190 deletions
|
@ -285,6 +285,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) {
|
|||
if (! leadPointReached(curr)) {
|
||||
controlHeading(curr);
|
||||
controlSpeed(curr, next);
|
||||
/*
|
||||
if (speed < 0) {
|
||||
cerr << getCallSign()
|
||||
<< ": verifying lead distance to waypoint : "
|
||||
|
@ -297,7 +298,7 @@ void FGAIAircraft::ProcessFlightPlan( double dt, time_t now ) {
|
|||
<< speed
|
||||
<< ". Minimum Bearing " << minBearing
|
||||
<< endl;
|
||||
}
|
||||
} */
|
||||
} else {
|
||||
if (curr->finished) //end of the flight plan
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
|
||||
FGATCManager::FGATCManager() {
|
||||
|
||||
networkVisible = false;
|
||||
}
|
||||
|
||||
FGATCManager::~FGATCManager() {
|
||||
|
@ -76,7 +76,8 @@ void FGATCManager::init() {
|
|||
ai_ac.setAltitude ( altitude );
|
||||
ai_ac.setPerformance("jet_transport");
|
||||
|
||||
// NEXT UP: Create a traffic Schedule and fill that with appropriate information. This we can use to flight plannign.
|
||||
// NEXT UP: Create a traffic Schedule and fill that with appropriate information. This we can use to flight planning.
|
||||
// Note that these are currently only defaults.
|
||||
FGAISchedule *trafficRef = new FGAISchedule;
|
||||
trafficRef->setFlightType("gate");
|
||||
|
||||
|
@ -179,16 +180,16 @@ void FGATCManager::update ( double time ) {
|
|||
/* test code : find out how the routing develops */
|
||||
int size = fp->getNrOfWayPoints();
|
||||
//cerr << "Setting pos" << pos << " ";
|
||||
cerr << "setting intentions " ;
|
||||
//cerr << "setting intentions " ;
|
||||
for (int i = 0; i < size; i++) {
|
||||
int val = fp->getRouteIndex(i);
|
||||
cerr << val << " ";
|
||||
//cerr << val << " ";
|
||||
//if ((val) && (val != pos)) {
|
||||
//intentions.push_back(val);
|
||||
//cerr << "[done ] " << endl;
|
||||
//}
|
||||
}
|
||||
cerr << "[done ] " << endl;
|
||||
//cerr << "[done ] " << endl;
|
||||
double longitude = fgGetDouble("/position/longitude-deg");
|
||||
double latitude = fgGetDouble("/position/latitude-deg");
|
||||
double heading = fgGetDouble("/orientation/heading-deg");
|
||||
|
@ -215,8 +216,14 @@ void FGATCManager::update ( double time ) {
|
|||
//string airport = fgGetString("/sim/presets/airport-id");
|
||||
//FGAirport *apt = FGAirport::findByIdent(airport);
|
||||
// AT this stage we should update the flightplan, so that waypoint incrementing is conducted as well as leg loading.
|
||||
|
||||
controller->render();
|
||||
static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true);
|
||||
int n = trans_num->getIntValue();
|
||||
if (n == 1) {
|
||||
cerr << "Toggling ground network visibility " << networkVisible << endl;
|
||||
networkVisible = !networkVisible;
|
||||
trans_num->setIntValue(-1);
|
||||
}
|
||||
controller->render(networkVisible);
|
||||
|
||||
//cerr << "Adding groundnetWork to the scenegraph::update" << endl;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ private:
|
|||
FGAIAircraft ai_ac;
|
||||
FGATCController *controller; // The ATC controller that is responsible for the user's aircraft.
|
||||
//FGATCDialogNew dialog; // note that this variable should really replace the ugly global "currentATCDialog();
|
||||
bool networkVisible;
|
||||
|
||||
public:
|
||||
FGATCManager();
|
||||
|
|
|
@ -43,7 +43,7 @@ static bool doATCDialog(const SGPropertyNode* arg) {
|
|||
|
||||
FGATCDialogNew::FGATCDialogNew()
|
||||
{
|
||||
dialogVisible = false;
|
||||
dialogVisible = true;
|
||||
}
|
||||
|
||||
FGATCDialogNew::~FGATCDialogNew()
|
||||
|
@ -89,6 +89,7 @@ static SGPropertyNode *getNamedNode(SGPropertyNode *prop, const char *name) {
|
|||
void FGATCDialogNew::addEntry(int nr, string txt) {
|
||||
commands.clear();
|
||||
commands.push_back(txt);
|
||||
commands.push_back(string("Toggle ground network visibility"));
|
||||
}
|
||||
|
||||
void FGATCDialogNew::removeEntry(int nr) {
|
||||
|
@ -98,49 +99,6 @@ void FGATCDialogNew::removeEntry(int nr) {
|
|||
|
||||
|
||||
void FGATCDialogNew::PopupDialog() {
|
||||
/*double onBoardRadioFreq0 =
|
||||
fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
|
||||
double onBoardRadioFreq1 =
|
||||
fgGetDouble("/instrumentation/comm[1]/frequencies/selected-mhz");
|
||||
|
||||
const char *dialog_name = "atc-dialog";
|
||||
_gui = (NewGUI *)globals->get_subsystem("gui");
|
||||
SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
|
||||
if (!dlg)
|
||||
return;
|
||||
|
||||
_gui->closeDialog(dialog_name);
|
||||
SGPropertyNode_ptr button_group = getNamedNode(dlg, "transmission-choice");
|
||||
button_group->removeChildren("button", false);
|
||||
|
||||
const int bufsize = 32;
|
||||
char buf[bufsize];
|
||||
int commandNr = 0;
|
||||
// loop over all entries that should fill up the dialog; use 10 items for now...
|
||||
for (StringVecIterator i = commands.begin(); i != commands.end(); i++) {
|
||||
snprintf(buf, bufsize, "/sim/atc/opt[%d]", commandNr);
|
||||
fgSetBool(buf, false);
|
||||
SGPropertyNode *entry = button_group->getNode("button", commandNr, true);
|
||||
copyProperties(button_group->getNode("button-template", true), entry);
|
||||
entry->removeChildren("enabled", true);
|
||||
entry->setStringValue("property", buf);
|
||||
entry->setIntValue("keynum", '1' + commandNr);
|
||||
if (commandNr == 0)
|
||||
entry->setBoolValue("default", true);
|
||||
|
||||
snprintf(buf, bufsize, "%d", 1 + commandNr);
|
||||
string legend = string(buf) + (*i); //"; // + current->menuentry;
|
||||
entry->setStringValue("legend", legend.c_str());
|
||||
entry->setIntValue("binding/value", commandNr);
|
||||
commandNr++;
|
||||
//current++;
|
||||
}
|
||||
*/
|
||||
//if (dialogVisible) {
|
||||
// _gui->closeDialog(dialog_name);
|
||||
//} else {
|
||||
// _gui->showDialog(dialog_name);
|
||||
//}
|
||||
dialogVisible = !dialogVisible;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -469,7 +469,7 @@ bool FGATCInstruction::hasInstruction()
|
|||
|
||||
FGATCController::FGATCController()
|
||||
{
|
||||
cerr << "running FGATController constructor" << endl;
|
||||
//cerr << "running FGATController constructor" << endl;
|
||||
dt_count = 0;
|
||||
available = true;
|
||||
lastTransmission = 0;
|
||||
|
@ -478,7 +478,7 @@ FGATCController::FGATCController()
|
|||
|
||||
FGATCController::~FGATCController()
|
||||
{
|
||||
cerr << "running FGATController destructor" << endl;
|
||||
//cerr << "running FGATController destructor" << endl;
|
||||
}
|
||||
|
||||
string FGATCController::getGateName(FGAIAircraft * ref)
|
||||
|
@ -906,8 +906,8 @@ FGATCInstruction FGTowerController::getInstruction(int id)
|
|||
return FGATCInstruction();
|
||||
}
|
||||
|
||||
void FGTowerController::render() {
|
||||
cerr << "FGTowerController::render function not yet implemented" << endl;
|
||||
void FGTowerController::render(bool visible) {
|
||||
//cerr << "FGTowerController::render function not yet implemented" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1033,7 +1033,7 @@ void FGStartupController::signOff(int id)
|
|||
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||
"AI error: Aircraft without traffic record is signing off from tower");
|
||||
} else {
|
||||
cerr << i->getAircraft()->getCallSign() << " signing off from startupcontroller" << endl;
|
||||
//cerr << i->getAircraft()->getCallSign() << " signing off from startupcontroller" << endl;
|
||||
i = activeTraffic.erase(i);
|
||||
}
|
||||
}
|
||||
|
@ -1045,17 +1045,17 @@ bool FGStartupController::checkTransmissionState(int st, time_t now, time_t star
|
|||
if ((state == st) && available) {
|
||||
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);
|
||||
int n = trans_num->getIntValue();
|
||||
if (n >= 0) {
|
||||
if (n == 0) {
|
||||
trans_num->setIntValue(-1);
|
||||
// PopupCallback(n);
|
||||
cerr << "Selected transmission message" << n << endl;
|
||||
cerr << "Selected transmission message " << n << endl;
|
||||
FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
|
||||
atc->getATCDialog()->removeEntry(1);
|
||||
} else {
|
||||
cerr << "creading message for " << i->getAircraft()->getCallSign() << endl;
|
||||
//cerr << "creading message for " << i->getAircraft()->getCallSign() << endl;
|
||||
transmit(&(*i), msgId, msgDir, false);
|
||||
return false;
|
||||
}
|
||||
|
@ -1161,7 +1161,7 @@ static void WorldCoordinate(osg::Matrix& obj_pos, double lat,
|
|||
}
|
||||
|
||||
|
||||
void FGStartupController::render()
|
||||
void FGStartupController::render(bool visible)
|
||||
{
|
||||
|
||||
SGMaterialLib *matlib = globals->get_matlib();
|
||||
|
@ -1175,7 +1175,9 @@ void FGStartupController::render()
|
|||
//geode->releaseGLObjects();
|
||||
//group->removeChild(geode);
|
||||
//delete geode;
|
||||
group = 0;
|
||||
}
|
||||
if (visible) {
|
||||
group = new osg::Group;
|
||||
|
||||
//for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
|
||||
|
@ -1228,7 +1230,7 @@ void FGStartupController::render()
|
|||
group->addChild( obj_trans );
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
} else {
|
||||
cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
|
||||
//cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
|
||||
}
|
||||
for(intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
|
||||
osg::Matrix obj_pos;
|
||||
|
@ -1267,9 +1269,9 @@ void FGStartupController::render()
|
|||
//dx += 0.1;
|
||||
}
|
||||
globals->get_scenery()->get_scene_graph()->addChild(group);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* class FGApproachController
|
||||
*
|
||||
|
@ -1461,6 +1463,6 @@ ActiveRunway *FGApproachController::getRunway(string name)
|
|||
return &(*rwy);
|
||||
}
|
||||
|
||||
void FGApproachController::render() {
|
||||
cerr << "FGApproachController::render function not yet implemented" << endl;
|
||||
void FGApproachController::render(bool visible) {
|
||||
//cerr << "FGApproachController::render function not yet implemented" << endl;
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ public:
|
|||
void setDt(double dt) { dt_count = dt;};
|
||||
void transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir msgDir, bool audible);
|
||||
string getGateName(FGAIAircraft *aircraft);
|
||||
virtual void render() = 0;
|
||||
virtual void render(bool) = 0;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -314,7 +314,7 @@ public:
|
|||
virtual bool hasInstruction(int id);
|
||||
virtual FGATCInstruction getInstruction(int id);
|
||||
|
||||
virtual void render();
|
||||
virtual void render(bool);
|
||||
bool hasActiveTraffic() { return activeTraffic.size() != 0; };
|
||||
TrafficVector &getActiveTraffic() { return activeTraffic; };
|
||||
};
|
||||
|
@ -344,7 +344,7 @@ public:
|
|||
virtual bool hasInstruction(int id);
|
||||
virtual FGATCInstruction getInstruction(int id);
|
||||
|
||||
virtual void render();
|
||||
virtual void render(bool);
|
||||
|
||||
bool hasActiveTraffic() { return activeTraffic.size() != 0; };
|
||||
TrafficVector &getActiveTraffic() { return activeTraffic; };
|
||||
|
@ -377,7 +377,7 @@ public:
|
|||
virtual bool hasInstruction(int id);
|
||||
virtual FGATCInstruction getInstruction(int id);
|
||||
|
||||
virtual void render();
|
||||
virtual void render(bool);
|
||||
|
||||
ActiveRunway* getRunway(string name);
|
||||
|
||||
|
|
|
@ -539,15 +539,15 @@ bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, Traffic
|
|||
if ((state >= minState) && (state <= maxState) && available) {
|
||||
if ((msgDir == ATC_AIR_TO_GROUND) && isUserAircraft(i->getAircraft())) {
|
||||
|
||||
cerr << "Checking state " << state << " for " << i->getAircraft()->getCallSign() << endl;
|
||||
//cerr << "Checking state " << state << " for " << i->getAircraft()->getCallSign() << endl;
|
||||
static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true);
|
||||
int n = trans_num->getIntValue();
|
||||
if (n >= 0) {
|
||||
if (n == 0) {
|
||||
trans_num->setIntValue(-1);
|
||||
// PopupCallback(n);
|
||||
cerr << "Selected transmission message" << n << endl;
|
||||
cerr << "Selected transmission message " << n << endl;
|
||||
} else {
|
||||
cerr << "creading message for " << i->getAircraft()->getCallSign() << endl;
|
||||
//cerr << "creating message for " << i->getAircraft()->getCallSign() << endl;
|
||||
transmit(&(*i), msgId, msgDir, false);
|
||||
return false;
|
||||
}
|
||||
|
@ -1103,7 +1103,7 @@ static void WorldCoordinate(osg::Matrix& obj_pos, double lat,
|
|||
|
||||
|
||||
|
||||
void FGGroundNetwork::render()
|
||||
void FGGroundNetwork::render(bool visible)
|
||||
{
|
||||
|
||||
SGMaterialLib *matlib = globals->get_matlib();
|
||||
|
@ -1117,7 +1117,9 @@ void FGGroundNetwork::render()
|
|||
//geode->releaseGLObjects();
|
||||
//group->removeChild(geode);
|
||||
//delete geode;
|
||||
group = 0;
|
||||
}
|
||||
if (visible) {
|
||||
group = new osg::Group;
|
||||
|
||||
//for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
|
||||
|
@ -1169,7 +1171,7 @@ void FGGroundNetwork::render()
|
|||
group->addChild( obj_trans );
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
} else {
|
||||
cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
|
||||
//cerr << "BIG FAT WARNING: current position is here : " << pos << endl;
|
||||
}
|
||||
for(intVecIterator j = (i)->getIntentions().begin(); j != (i)->getIntentions().end(); j++) {
|
||||
osg::Matrix obj_pos;
|
||||
|
@ -1205,4 +1207,5 @@ void FGGroundNetwork::render()
|
|||
//dx += 0.1;
|
||||
}
|
||||
globals->get_scenery()->get_scene_graph()->addChild(group);
|
||||
}
|
||||
}
|
|
@ -287,7 +287,7 @@ public:
|
|||
bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
|
||||
AtcMsgDir msgDir);
|
||||
bool checkForCircularWaits(int id);
|
||||
virtual void render();
|
||||
virtual void render(bool);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue