if (! leadPointReached(curr)) {
controlHeading(curr);
controlSpeed(curr, next);
+ /*
if (speed < 0) {
cerr << getCallSign()
<< ": verifying lead distance to waypoint : "
<< speed
<< ". Minimum Bearing " << minBearing
<< endl;
- }
+ } */
} else {
if (curr->finished) //end of the flight plan
{
FGATCManager::FGATCManager() {
-
+ networkVisible = false;
}
FGATCManager::~FGATCManager() {
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");
/* 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");
//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;
}
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();
FGATCDialogNew::FGATCDialogNew()
{
- dialogVisible = false;
+ dialogVisible = true;
}
FGATCDialogNew::~FGATCDialogNew()
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) {
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;
}
FGATCController::FGATCController()
{
- cerr << "running FGATController constructor" << endl;
+ //cerr << "running FGATController constructor" << endl;
dt_count = 0;
available = true;
lastTransmission = 0;
FGATCController::~FGATCController()
{
- cerr << "running FGATController destructor" << endl;
+ //cerr << "running FGATController destructor" << endl;
}
string FGATCController::getGateName(FGAIAircraft * ref)
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;
}
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);
}
}
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;
}
}
-void FGStartupController::render()
+void FGStartupController::render(bool visible)
{
SGMaterialLib *matlib = globals->get_matlib();
//geode->releaseGLObjects();
//group->removeChild(geode);
//delete geode;
+ group = 0;
}
- group = new osg::Group;
-
- //for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
- double dx = 0;
- for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
- // Handle start point
- int pos = i->getCurrentPosition();
- //cerr << "rendering for " << i->getAircraft()->getCallSign() << "pos = " << pos << endl;
- if (pos > 0) {
- FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(pos);
- SGGeod start(SGGeod::fromDeg((i->getLongitude()), (i->getLatitude())));
- SGGeod end (SGGeod::fromDeg(segment->getEnd()->getLongitude(), segment->getEnd()->getLatitude()));
-
- double length = SGGeodesy::distanceM(start, end);
- //heading = SGGeodesy::headingDeg(start->getGeod(), end->getGeod());
-
- double az2, heading; //, distanceM;
- SGGeodesy::inverse(start, end, heading, az2, length);
- double coveredDistance = length * 0.5;
- SGGeod center;
- SGGeodesy::direct(start, heading, coveredDistance, center, az2);
- //cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << endl;
- ///////////////////////////////////////////////////////////////////////////////
- // Make a helper function out of this
- osg::Matrix obj_pos;
+ if (visible) {
+ group = new osg::Group;
+
+ //for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
+ double dx = 0;
+ for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
+ // Handle start point
+ int pos = i->getCurrentPosition();
+ //cerr << "rendering for " << i->getAircraft()->getCallSign() << "pos = " << pos << endl;
+ if (pos > 0) {
+ FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(pos);
+ SGGeod start(SGGeod::fromDeg((i->getLongitude()), (i->getLatitude())));
+ SGGeod end (SGGeod::fromDeg(segment->getEnd()->getLongitude(), segment->getEnd()->getLatitude()));
+
+ double length = SGGeodesy::distanceM(start, end);
+ //heading = SGGeodesy::headingDeg(start->getGeod(), end->getGeod());
+
+ double az2, heading; //, distanceM;
+ SGGeodesy::inverse(start, end, heading, az2, length);
+ double coveredDistance = length * 0.5;
+ SGGeod center;
+ SGGeodesy::direct(start, heading, coveredDistance, center, az2);
+ //cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << endl;
+ ///////////////////////////////////////////////////////////////////////////////
+ // Make a helper function out of this
+ osg::Matrix obj_pos;
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
obj_trans->setDataVariance(osg::Object::STATIC);
// wire as much of the scene graph together as we can
//->addChild( obj_trans );
group->addChild( obj_trans );
- /////////////////////////////////////////////////////////////////////
- } else {
- 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;
- int k = (*j);
- if (k > 0) {
- //cerr << "rendering for " << i->getAircraft()->getCallSign() << "intention = " << k << endl;
- osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
- obj_trans->setDataVariance(osg::Object::STATIC);
- FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(k);
- WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), parent->getElevation()+8+dx, -(segment->getHeading()) );
-
- obj_trans->setMatrix( obj_pos );
- //osg::Vec3 center(0, 0, 0)
-
- float width = segment->getLength() /2.0;
- osg::Vec3 corner(-width, 0, 0.25f);
- osg::Vec3 widthVec(2*width + 1, 0, 0);
- osg::Vec3 heightVec(0, 1, 0);
- osg::Geometry* geometry;
- geometry = osg::createTexturedQuadGeometry(corner, widthVec, heightVec);
- simgear::EffectGeode* geode = new simgear::EffectGeode;
- geode->setName("test");
- geode->addDrawable(geometry);
- //osg::Node *custom_obj;
- SGMaterial *mat = matlib->find("UnidirectionalTaper");
- if (mat)
- geode->setEffect(mat->get_effect());
- obj_trans->addChild(geode);
- // wire as much of the scene graph together as we can
- //->addChild( obj_trans );
- group->addChild( obj_trans );
+ /////////////////////////////////////////////////////////////////////
} else {
- cerr << "BIG FAT WARNING: k 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;
+ int k = (*j);
+ if (k > 0) {
+ //cerr << "rendering for " << i->getAircraft()->getCallSign() << "intention = " << k << endl;
+ osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
+ obj_trans->setDataVariance(osg::Object::STATIC);
+ FGTaxiSegment *segment = parent->getGroundNetwork()->findSegment(k);
+ WorldCoordinate( obj_pos, segment->getLatitude(), segment->getLongitude(), parent->getElevation()+8+dx, -(segment->getHeading()) );
+
+ obj_trans->setMatrix( obj_pos );
+ //osg::Vec3 center(0, 0, 0)
+
+ float width = segment->getLength() /2.0;
+ osg::Vec3 corner(-width, 0, 0.25f);
+ osg::Vec3 widthVec(2*width + 1, 0, 0);
+ osg::Vec3 heightVec(0, 1, 0);
+ osg::Geometry* geometry;
+ geometry = osg::createTexturedQuadGeometry(corner, widthVec, heightVec);
+ simgear::EffectGeode* geode = new simgear::EffectGeode;
+ geode->setName("test");
+ geode->addDrawable(geometry);
+ //osg::Node *custom_obj;
+ SGMaterial *mat = matlib->find("UnidirectionalTaper");
+ if (mat)
+ geode->setEffect(mat->get_effect());
+ obj_trans->addChild(geode);
+ // wire as much of the scene graph together as we can
+ //->addChild( obj_trans );
+ group->addChild( obj_trans );
+ } else {
+ cerr << "BIG FAT WARNING: k is here : " << pos << endl;
+ }
+ }
+ //dx += 0.1;
}
- //dx += 0.1;
+ globals->get_scenery()->get_scene_graph()->addChild(group);
}
- globals->get_scenery()->get_scene_graph()->addChild(group);
}
-
/***************************************************************************
* class FGApproachController
*
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;
}
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:
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; };
};
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; };
virtual bool hasInstruction(int id);
virtual FGATCInstruction getInstruction(int id);
- virtual void render();
+ virtual void render(bool);
ActiveRunway* getRunway(string name);
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;
}
-void FGGroundNetwork::render()
+void FGGroundNetwork::render(bool visible)
{
SGMaterialLib *matlib = globals->get_matlib();
//geode->releaseGLObjects();
//group->removeChild(geode);
//delete geode;
+ group = 0;
}
- group = new osg::Group;
-
- //for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
- double dx = 0;
- for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
- // Handle start point
- int pos = i->getCurrentPosition() - 1;
- if (pos >= 0) {
+ if (visible) {
+ group = new osg::Group;
+
+ //for ( FGTaxiSegmentVectorIterator i = segments.begin(); i != segments.end(); i++) {
+ double dx = 0;
+ for (TrafficVectorIterator i = activeTraffic.begin(); i != activeTraffic.end(); i++) {
+ // Handle start point
+ int pos = i->getCurrentPosition() - 1;
+ if (pos >= 0) {
- SGGeod start(SGGeod::fromDeg((i->getLongitude()), (i->getLatitude())));
- SGGeod end (SGGeod::fromDeg(segments[pos]->getEnd()->getLongitude(), segments[pos]->getEnd()->getLatitude()));
-
- double length = SGGeodesy::distanceM(start, end);
- //heading = SGGeodesy::headingDeg(start->getGeod(), end->getGeod());
-
- double az2, heading; //, distanceM;
- SGGeodesy::inverse(start, end, heading, az2, length);
- double coveredDistance = length * 0.5;
- SGGeod center;
- SGGeodesy::direct(start, heading, coveredDistance, center, az2);
- //cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << endl;
+ SGGeod start(SGGeod::fromDeg((i->getLongitude()), (i->getLatitude())));
+ SGGeod end (SGGeod::fromDeg(segments[pos]->getEnd()->getLongitude(), segments[pos]->getEnd()->getLatitude()));
+
+ double length = SGGeodesy::distanceM(start, end);
+ //heading = SGGeodesy::headingDeg(start->getGeod(), end->getGeod());
+
+ double az2, heading; //, distanceM;
+ SGGeodesy::inverse(start, end, heading, az2, length);
+ double coveredDistance = length * 0.5;
+ SGGeod center;
+ SGGeodesy::direct(start, heading, coveredDistance, center, az2);
+ //cerr << "Active Aircraft : Centerpoint = (" << center.getLatitudeDeg() << ", " << center.getLongitudeDeg() << "). Heading = " << heading << endl;
///////////////////////////////////////////////////////////////////////////////
- // Make a helper function out of this
- osg::Matrix obj_pos;
+ // Make a helper function out of this
+ osg::Matrix obj_pos;
osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
obj_trans->setDataVariance(osg::Object::STATIC);
// wire as much of the scene graph together as we can
//->addChild( obj_trans );
group->addChild( obj_trans );
- /////////////////////////////////////////////////////////////////////
- } else {
- 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;
- int k = (*j)-1;
- if (k >= 0) {
- osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
- obj_trans->setDataVariance(osg::Object::STATIC);
-
- WorldCoordinate( obj_pos, segments[k]->getLatitude(), segments[k]->getLongitude(), parent->elevation()+8+dx, -(segments[k]->getHeading()) );
-
- obj_trans->setMatrix( obj_pos );
- //osg::Vec3 center(0, 0, 0)
-
- float width = segments[k]->getLength() /2.0;
- osg::Vec3 corner(-width, 0, 0.25f);
- osg::Vec3 widthVec(2*width + 1, 0, 0);
- osg::Vec3 heightVec(0, 1, 0);
- osg::Geometry* geometry;
- geometry = osg::createTexturedQuadGeometry(corner, widthVec, heightVec);
- simgear::EffectGeode* geode = new simgear::EffectGeode;
- geode->setName("test");
- geode->addDrawable(geometry);
- //osg::Node *custom_obj;
- SGMaterial *mat = matlib->find("UnidirectionalTaper");
- if (mat)
- geode->setEffect(mat->get_effect());
- obj_trans->addChild(geode);
- // wire as much of the scene graph together as we can
- //->addChild( obj_trans );
- group->addChild( obj_trans );
+ /////////////////////////////////////////////////////////////////////
+ } else {
+ //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;
+ int k = (*j)-1;
+ if (k >= 0) {
+ osg::MatrixTransform *obj_trans = new osg::MatrixTransform;
+ obj_trans->setDataVariance(osg::Object::STATIC);
+
+ WorldCoordinate( obj_pos, segments[k]->getLatitude(), segments[k]->getLongitude(), parent->elevation()+8+dx, -(segments[k]->getHeading()) );
+
+ obj_trans->setMatrix( obj_pos );
+ //osg::Vec3 center(0, 0, 0)
+
+ float width = segments[k]->getLength() /2.0;
+ osg::Vec3 corner(-width, 0, 0.25f);
+ osg::Vec3 widthVec(2*width + 1, 0, 0);
+ osg::Vec3 heightVec(0, 1, 0);
+ osg::Geometry* geometry;
+ geometry = osg::createTexturedQuadGeometry(corner, widthVec, heightVec);
+ simgear::EffectGeode* geode = new simgear::EffectGeode;
+ geode->setName("test");
+ geode->addDrawable(geometry);
+ //osg::Node *custom_obj;
+ SGMaterial *mat = matlib->find("UnidirectionalTaper");
+ if (mat)
+ geode->setEffect(mat->get_effect());
+ obj_trans->addChild(geode);
+ // wire as much of the scene graph together as we can
+ //->addChild( obj_trans );
+ group->addChild( obj_trans );
+ }
}
+ //dx += 0.1;
}
- //dx += 0.1;
+ globals->get_scenery()->get_scene_graph()->addChild(group);
}
- globals->get_scenery()->get_scene_graph()->addChild(group);
}
\ No newline at end of file
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);
};