From 8114d1d8998f48e61e2bd4a73d8223961ad4dc17 Mon Sep 17 00:00:00 2001 From: durk Date: Wed, 30 Dec 2009 14:11:16 +0000 Subject: [PATCH] Conditional compilation of ATCDCL module. Use --disable-atcdcl to try building flightgear without ATCDCL code. --- configure.ac | 19 ++++++++++++++++++- src/AIModel/AIAircraft.cxx | 9 --------- src/ATC/trafficcontrol.cxx | 8 ++++---- src/ATC/trafficcontrol.hxx | 1 - src/Airports/apt_loader.cxx | 23 +++++++++++++++++++---- src/Airports/groundnetwork.cxx | 7 +++++++ src/Main/Makefile.am | 9 ++++++++- src/Main/fg_init.cxx | 21 +++++++++++++++++---- src/Makefile.am | 9 ++++++++- 9 files changed, 81 insertions(+), 25 deletions(-) diff --git a/configure.ac b/configure.ac index 6ae6d7438..1c1fa9613 100644 --- a/configure.ac +++ b/configure.ac @@ -158,6 +158,17 @@ else fi AM_CONDITIONAL(ENABLE_SP_FDM, test "x$enable_sp_fdms" != "xno") +# Specify whether we want to compile ATCDCL. +# default to with_atcdcl=yes +AC_ARG_ENABLE(atcdcl, [ --enable-atcdcl Compile and link the depricated atc/ai module], [enable_atcdcl="$enableval"] ) +if test "x$enable_atcdcl" != "xno"; then + AC_DEFINE([ENABLE_ATCDCL], 1, [Define to include old ATC/AI module]) +else + AC_DEFINE([ENABLE_ATCDCL], 0, [Define to include old ATC/AI module]) +fi +AM_CONDITIONAL(ENABLE_ATCDCL, test "x$enable_atcdcl" != "xno") + + dnl EXPERIMENTAL generic event driven input device # defaults to no @@ -202,6 +213,7 @@ fi AC_CHECK_HEADER(pthread.h) AM_CONDITIONAL(WITH_THREADS, test "x$with_threads" = "xyes") + dnl Used by JSBSim to conditionally compile in fgfs interface code AC_DEFINE([FGFS], 1, [Define so that JSBSim compiles in 'library' mode]) @@ -283,7 +295,7 @@ AC_SEARCH_LIBS(clock_gettime, rt) base_LIBS="$LIBS" dnl Check for SDL or glut if enabled. -AC_ARG_ENABLE(osgviewer, [ --enable-osgviewer Configure to use osgViewer(default)], [enable_osgviewer="$enableval"]) +AC_ARG_ENABLE(osgviewer, [ --enable-osgviewer Configure to use osgViewer(default)], [enable_osgviewer="$enableval"]) AC_ARG_ENABLE(sdl, [ --enable-sdl Configure to use SDL], [enable_sdl="$enableval"]) AC_ARG_ENABLE(glut, [ --enable-glut Configure to use GLUT], [enable_glut="$enableval"]) AM_CONDITIONAL(USE_SDL, test "x$enable_sdl" = "xyes") @@ -880,3 +892,8 @@ else echo "Include special purpose flight models: no" fi +if test "x$enable_atcdcl" != "xno"; then + echo "Build depricated ATC/AI module: yes" +else + echo "Build depricated ATC/AI module: no" +fi diff --git a/src/AIModel/AIAircraft.cxx b/src/AIModel/AIAircraft.cxx index 68d7f46c4..eb8469fde 100644 --- a/src/AIModel/AIAircraft.cxx +++ b/src/AIModel/AIAircraft.cxx @@ -447,15 +447,6 @@ void FGAIAircraft::announcePositionToController() { case 4: //Take off tower controller if (trafficRef->getDepartureAirport()->getDynamics()) { controller = trafficRef->getDepartureAirport()->getDynamics()->getTowerController(); - //if (trafficRef->getDepartureAirport()->getId() == "EHAM") { - //string trns = trafficRef->getCallSign() + " at runway " + fp->getRunway() + - // ". Ready for departure. " + trafficRef->getFlightType() + " to " + - // trafficRef->getArrivalAirport()->getId(); - //fgSetString("/sim/messages/atc", trns.c_str()); - // if (controller == 0) { - //cerr << "Error in assigning controller at " << trafficRef->getDepartureAirport()->getId() << endl; - //} - //} } else { cerr << "Error: Could not find Dynamics at airport : " << trafficRef->getDepartureAirport()->getId() << endl; } diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index 57f718812..a04b6fc81 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -264,7 +264,7 @@ bool FGTrafficRecord::isOpposing (FGGroundNetwork *net, FGTrafficRecord &other, if (other.intentions.size()) { for (intVecIterator j = other.intentions.begin(); j != other.intentions.end(); j++) - { + { // cerr << "Current segment 1 " << (*i) << endl; if ((*i) > 0) { if ((opp = net->findSegment(*i)->opposite())) @@ -402,7 +402,7 @@ void FGATCController::transmit(FGTrafficRecord *rec, AtcMsgId msgId, AtcMsgDir m // Assign SID, if necessery (TODO) case MSG_PERMIT_ENGINE_START: taxiFreqStr = formatATCFrequency3_2(taxiFreq); - + heading = rec->getAircraft()->getTrafficRef()->getCourse(); fltType = rec->getAircraft()->getTrafficRef()->getFlightType(); rwyClass= rec->getAircraft()->GetFlightPlan()->getRunwayClassFromTrafficType(fltType); @@ -453,10 +453,8 @@ 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; } } @@ -466,6 +464,8 @@ string FGATCController::formatATCFrequency3_2(int freq) { return string(buffer); } +// TODO: Set transponder codes according to real-world routes. +// The current version just returns a random string of four octal numbers. string FGATCController::genTransponderCode(string fltRules) { if (fltRules == "VFR") { return string("1200"); diff --git a/src/ATC/trafficcontrol.hxx b/src/ATC/trafficcontrol.hxx index 7ca8e88bf..ef984efca 100644 --- a/src/ATC/trafficcontrol.hxx +++ b/src/ATC/trafficcontrol.hxx @@ -45,7 +45,6 @@ typedef vector::iterator intVecIterator; class FGAIFlightPlan; // forward reference class FGGroundNetwork; // forward reference -//class FGAISchedule; // forward reference class FGAIAircraft; // forward reference /************************************************************************************** diff --git a/src/Airports/apt_loader.cxx b/src/Airports/apt_loader.cxx index af9319ae3..3dfcdf059 100644 --- a/src/Airports/apt_loader.cxx +++ b/src/Airports/apt_loader.cxx @@ -45,7 +45,9 @@ #include "simple.hxx" #include "runways.hxx" #include "pavement.hxx" -#include +#if ENABLE_ATCDCL +# include +#endif #include @@ -75,7 +77,12 @@ public: last_apt_type("") {} + +#ifdef ENABLE_ATCDCL void parseAPT(const string &aptdb_file, FGCommList *comm_list) +#else + void parseAPT(const string &aptdb_file) +#endif { sg_gzifstream in( aptdb_file ); @@ -461,7 +468,7 @@ private: pvt->addNode(pos, num == 113); } } - +#if ENABLE_ATCDCL void parseATISLine(FGCommList *comm_list, const vector& token) { if ( rwy_count <= 0 ) { @@ -505,19 +512,27 @@ private: << " type: " << a.type ); #endif } +#endif }; + // Load the airport data base from the specified aptdb file. The // metar file is used to mark the airports as having metar available // or not. bool fgAirportDBLoad( const string &aptdb_file, +#if ENABLE_ATCDCL FGCommList *comm_list, const std::string &metar_file ) +#else + const std::string &metar_file ) +#endif { APTLoader ld; - +#if ENABLE_ATCDCL ld.parseAPT(aptdb_file, comm_list); - +#else + ld.parseAPT(aptdb_file); +#endif // // Load the metar.dat file and update apt db with stations that // have metar data. diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index 8bdd947fc..7600033ce 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -508,6 +508,13 @@ void FGGroundNetwork::signOff(int id) { void FGGroundNetwork::update(int id, double lat, double lon, double heading, double speed, double alt, double dt) { + // Check whether aircraft are on hold due to a preceding pushback. If so, make sure to + // Transmit air-to-ground "Ready to taxi request: + // Transmit ground to air approval / hold + // Transmit confirmation ... + // Probably use a status mechanism similar to the Engine start procedure in the startup controller. + + TrafficVectorIterator i = activeTraffic.begin(); // Search search if the current id has an entry // This might be faster using a map instead of a vector, but let's start by taking a safe route diff --git a/src/Main/Makefile.am b/src/Main/Makefile.am index 0994d859a..996c63e11 100644 --- a/src/Main/Makefile.am +++ b/src/Main/Makefile.am @@ -9,6 +9,13 @@ else SP_FDM_LIBS = endif +if ENABLE_ATCDCL +ATCDCL_LIBS = $(top_builddir)/src/ATCDCL/libATCDCL.a +else +ATCDCL_LIBS = +endif + + if WITH_THREADS THREAD_LIBS = -lsgthreads $(thread_LIBS) else @@ -82,7 +89,7 @@ fgfs_SOURCES = bootstrap.cxx fgfs_LDADD = \ libMain.a \ $(top_builddir)/src/Aircraft/libAircraft.a \ - $(top_builddir)/src/ATCDCL/libATCDCL.a \ + $(ATCDCL_LIBS) \ $(top_builddir)/src/Cockpit/libCockpit.a \ $(top_builddir)/src/Cockpit/built_in/libBuilt_in.a \ $(top_builddir)/src/FDM/libFlight.a \ diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 26a7987f4..ded6765fc 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -73,8 +73,13 @@ #include #include -#include -#include + +#if ENABLE_ATCDCL +# include +# include +# include "ATCDCL/commlist.hxx" +#endif + #include #include #include @@ -82,7 +87,8 @@ #include #include #include -#ifdef ENABLE_SP_FDM + +#if ENABLE_SP_FDM #include #include #include @@ -130,7 +136,7 @@ #include "renderer.hxx" #include "viewmgr.hxx" #include "main.hxx" -#include "ATCDCL/commlist.hxx" + #ifdef __APPLE__ # include @@ -973,9 +979,16 @@ fgInitNav () // Initialise the frequency search map BEFORE reading // the airport database: + + + +#if ENABLE_ATCDCL current_commlist = new FGCommList; current_commlist->init( globals->get_fg_root() ); fgAirportDBLoad( aptdb.str(), current_commlist, p_metar.str() ); +#else + fgAirportDBLoad( aptdb.str(), p_metar.str() ); +#endif FGNavList *navlist = new FGNavList; FGNavList *loclist = new FGNavList; diff --git a/src/Makefile.am b/src/Makefile.am index 178419eb0..39b081ac1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,9 +1,16 @@ +if ENABLE_ATCDCL +ATCDCL_DIR = ATCDCL +else +ATCDCL_DIR = +endif + + SUBDIRS = \ Include \ Aircraft \ Airports \ ATC \ - ATCDCL \ + $(ATCDCL_DIR) \ Autopilot \ Cockpit \ Environment \