[prev in list] [next in list] [prev in thread] [next in thread] 

List:       flightgear-cvs
Subject:    [Flightgear-cvslogs] CVS: FlightGear/src/ATC tower.cxx, 1.57.2.4,
From:       Melchior Franz <mfranz () flightgear ! org>
Date:       2008-01-31 22:38:35
Message-ID: E1JKi3H-000604-00 () baron ! me ! umn ! edu
[Download RAW message or body]

Update of /var/cvs/FlightGear-0.9/FlightGear/src/ATC
In directory baron:/tmp/cvs-serv23016

Modified Files:
      Tag: PRE_OSG_PLIB_20061029
	tower.cxx tower.hxx 
Log Message:
Daniyar ATADJANOV:

This patch contains bugfixes from my previous patch
 (i made mistakes when using "diff" utility last time):

    1. Now ATC do not tells us to go around because of
       traffic on RWy, when that traffic is WE.
    2. Now ATC don't say that we must follow ourself
       (like "GFS, number two, follow GFS on final").

And new Tower-ATC features:

    1. Requesting departure clearance. When you are
       on taxiway, you can request departure clearance.
       Tower will answer with something like:
       "Line up runway two eight right".

       TODO: check if any AI-Planes on final and tell
       something like: "After the landing AI-CALLSIGN
       line up runway two eight right".

    2. Requesting take-off clearance. If you are on
       runway, you can tell to ATC that you are ready
       for take-off. So, Tower will tell you that you
       are cleared for take-off (or immediate take-off).

    3. Reporting landing gear position on final by pilot.
       If you are on aircraft, which landing gear can
       be UP, when reporting final you will tell
       "Gear down, ready to land".

    4. Reporting landing gear position on final by ATC.
       When i was newbie and was flying on Cessna 310, i
       ALWAYS forgot landing gears on final. Now if you are on
       final and forgot landing gear, Tower will tell you:
       "LANDING GEAR APPEARS UP" or "Check wheels down and
       locked". So you will have some time to push gear
       down or execute missed approach ;)

    5. ATIS phonetic ID in requesting landing message.
       In FG pilots says: "for full stop with ATIS" everytime
       (when airport doesn't have ATIS too). But in real life
       pilot saying phonetic ID of ATIS message. Now we have:
       "for full stop, information alpha ... / ... zulu".
       If airport doesn't have ATIS, pilot don't say this.

       TODO: add this feature to AI-Planes too.

     6. Advising weather condition in airport by Tower.
        If you are requesting take-off or landing in airport
        that doesn't have ATIS service, Tower will tell you
        about wind direction and speed, visibility and QFE.

     7. Reporting downwind if missed approach. When some AI-Plane
        is on final FG's ATC tell you to "continue approach".
        And then you lost radio transmission. Now ATC says:
        "continue approach and report left/right downwind".
        And now we have "Report Downwind" entry (button)
        in "ATC Communication" form.


Index: tower.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/ATC/tower.cxx,v
retrieving revision 1.57.2.4
retrieving revision 1.57.2.5
diff -C 2 -r1.57.2.4 -r1.57.2.5
*** tower.cxx	27 Oct 2007 19:16:41 -0000	1.57.2.4
--- tower.cxx	31 Jan 2008 22:38:32 -0000	1.57.2.5
***************
*** 4,7 ****
--- 4,8 ----
  //
  // Copyright (C) 2002  David C. Luff - david.luff@nottingham.ac.uk
+ // Copyright (C) 2008  Daniyar Atadjanov (ground clearance, gear check, weather, \
etc.)  //
  // This program is free software; you can redistribute it and/or
***************
*** 29,36 ****
  #endif
  
  #include <Main/globals.hxx>
  #include <Airports/runways.hxx>
- #include <simgear/math/sg_geodesy.hxx>
- #include <simgear/debug/logstream.hxx>
  
  #include "tower.hxx"
--- 30,43 ----
  #endif
  
+ #include <sstream>
+ #include <iomanip>
+ 
+ #include <simgear/debug/logstream.hxx>
+ #include <simgear/math/sg_geodesy.hxx>
+ #include <simgear/math/sg_random.h>
+ #include <simgear/misc/sg_path.hxx>
+ 
  #include <Main/globals.hxx>
  #include <Airports/runways.hxx>
  
  #include "tower.hxx"
***************
*** 42,45 ****
--- 49,53 ----
  #include "AILocalTraffic.hxx"
  
+ 
  SG_USING_STD(cout);
  
***************
*** 52,55 ****
--- 60,64 ----
  	clearedToTakeOff(false),
  	holdShortReported(false),
+ 	lineUpReported(false),
  	downwindReported(false),
  	longFinalReported(false),
***************
*** 68,71 ****
--- 77,82 ----
  	leg(LEG_UNKNOWN),
  	landingType(AIP_LT_UNKNOWN),
+ 	gearWasUp(false),
+ 	gearUpReported(false),
  	isUser(false)
  {
***************
*** 79,82 ****
--- 90,94 ----
  	clearedToTakeOff(false),
  	holdShortReported(false),
+ 	lineUpReported(false),
  	downwindReported(false),
  	longFinalReported(false),
***************
*** 95,98 ****
--- 107,112 ----
  	leg(LEG_UNKNOWN),
  	landingType(AIP_LT_UNKNOWN),
+ 	gearWasUp(false),
+ 	gearUpReported(false),
  	isUser(false)
  {
***************
*** 106,109 ****
--- 120,124 ----
  	clearedToTakeOff(false),
  	holdShortReported(false),
+ 	lineUpReported(false),
  	downwindReported(false),
  	longFinalReported(false),
***************
*** 122,125 ****
--- 137,142 ----
  	leg(LEG_UNKNOWN),
  	landingType(AIP_LT_UNKNOWN),
+ 	gearWasUp(false),
+ 	gearUpReported(false),
  	isUser(false)
  {
***************
*** 134,137 ****
--- 151,155 ----
  	clearedToTakeOff(false),
  	holdShortReported(false),
+ 	lineUpReported(false),
  	downwindReported(false),
  	longFinalReported(false),
***************
*** 150,153 ****
--- 168,173 ----
  	leg(LEG_UNKNOWN),
  	landingType(AIP_LT_UNKNOWN),
+ 	gearWasUp(false),
+ 	gearUpReported(false),
  	isUser(false)
  {
***************
*** 291,294 ****
--- 311,316 ----
  	}
  	
+ 	RemoveAllUserDialogOptions();
+ 	
  	// TODO - attempt to get a departure control pointer to see if we need to hand off \
departing traffic to departure.  
***************
*** 301,305 ****
  	// TODO - this currently assumes only one active runway.
  	rwyOccupied = OnActiveRunway(Point3D(user_lon_node->getDoubleValue(), \
                user_lat_node->getDoubleValue(), 0.0));
! 	if(rwyOccupied) {
  		//cout << "User found on active runway\n";
  		// Assume the user is started at the threshold ready to take-off
--- 323,333 ----
  	// TODO - this currently assumes only one active runway.
  	rwyOccupied = OnActiveRunway(Point3D(user_lon_node->getDoubleValue(), \
                user_lat_node->getDoubleValue(), 0.0));
! 	
! 	if(!OnAnyRunway(Point3D(user_lon_node->getDoubleValue(), \
                user_lat_node->getDoubleValue(), 0.0), false)) {
! 		//cout << ident << "  ADD 0\n";
! 		current_atcdialog->add_entry(ident, "@AP Tower, @CS @MI miles @CD of the airport \
                for full stop@AT",
! 				"Contact tower for VFR arrival (full stop)", TOWER,
! 				(int)USER_REQUEST_VFR_ARRIVAL_FULL_STOP);
! 	} else {
  		//cout << "User found on active runway\n";
  		// Assume the user is started at the threshold ready to take-off
***************
*** 312,327 ****
  		t->isUser = true;
  		t->planePtr = NULL;
! 		t->clearedToTakeOff = true;
  		rwyList.push_back(t);
  		rwyListItr = rwyList.begin();
  		departed = false;
! 	} else {
! 		//cout << "User not on active runway\n";
! 		// For now assume that this means the user is not at the airport and is in the \
                air.
! 		// TODO FIXME - this will break when user starts on apron, at hold short, etc.
! 		if(!OnAnyRunway(Point3D(user_lon_node->getDoubleValue(), \
                user_lat_node->getDoubleValue(), 0.0))) {
! 			//cout << ident << "  ADD 0\n";
! 			current_atcdialog->add_entry(ident, "@AP Tower, @CS @MI miles @CD of the airport \
for full stop with ATIS", "Contact tower for VFR arrival (full stop)", TOWER, \
                (int)USER_REQUEST_VFR_ARRIVAL_FULL_STOP);
! 		}
  	}
  }
--- 340,349 ----
  		t->isUser = true;
  		t->planePtr = NULL;
! 		t->clearedToTakeOff = false;
  		rwyList.push_back(t);
  		rwyListItr = rwyList.begin();
  		departed = false;
! 		current_atcdialog->add_entry(ident, "@CS @TO", "Request departure / take-off \
                clearance",
! 				TOWER, (int)USER_REQUEST_TAKE_OFF);
  	}
  }
***************
*** 449,453 ****
  void FGTower::ReceiveUserCallback(int code) {
  	if(code == (int)USER_REQUEST_VFR_DEPARTURE) {
! 		//cout << "User requested departure\n";
  	} else if(code == (int)USER_REQUEST_VFR_ARRIVAL) {
  		VFRArrivalContact("USER");
--- 471,475 ----
  void FGTower::ReceiveUserCallback(int code) {
  	if(code == (int)USER_REQUEST_VFR_DEPARTURE) {
! 		RequestDepartureClearance("USER");
  	} else if(code == (int)USER_REQUEST_VFR_ARRIVAL) {
  		VFRArrivalContact("USER");
***************
*** 465,468 ****
--- 487,492 ----
  	} else if(code == (int)USER_REPORT_GOING_AROUND) {
  		ReportGoingAround("USER");
+ 	} else if(code == (int)USER_REQUEST_TAKE_OFF) {
+ 		RequestTakeOffClearance("USER");
  	}
  }
***************
*** 486,494 ****
  			// Later on we might check the actual heading and direct some of those to enter \
on downwind or base.  Point3D op = ortho.ConvertToLocal(t->pos);
  			if(op.y() < -1000) {
  				trns += " Report three mile straight-in runway ";
  				t->opType = STRAIGHT_IN;
  				if(t->isUser) {
! 					current_atcdialog->add_entry(ident, "@AP Tower, @CS @MI mile final Runway \
@RW", "Report Final", TOWER, (int)USER_REPORT_3_MILE_FINAL);  } else {
  					t->planePtr->RegisterTransmission(14);
--- 510,521 ----
  			// Later on we might check the actual heading and direct some of those to enter \
on downwind or base.  Point3D op = ortho.ConvertToLocal(t->pos);
+ 			float gp = fgGetFloat("/gear/gear/position-norm");
+ 			if(gp < 1)
+ 				t->gearWasUp = true; // This will be needed on final to tell "Gear down, ready \
to land."  if(op.y() < -1000) {
  				trns += " Report three mile straight-in runway ";
  				t->opType = STRAIGHT_IN;
  				if(t->isUser) {
! 					current_atcdialog->add_entry(ident, "@CS @MI mile final runway @RW@GR", \
"Report Final", TOWER, (int)USER_REPORT_3_MILE_FINAL);  } else {
  					t->planePtr->RegisterTransmission(14);
***************
*** 523,526 ****
--- 550,588 ----
  			ProcessDownwindReport(t);
  			t->downwindReported = false;
+ 		} else if(t->lineUpReported) {
+ 			string trns = t->plane.callsign;
+ 			if(rwyOccupied) {
+ 				double f = globals->get_ATC_mgr()->GetFrequency(ident, ATIS) / 100.0;
+ 				string wtr;
+ 				if(!f) {
+ 					wtr = ", " + GetWeather();
+ 				}
+ 				trns += " Cleared for take-off" + wtr;
+ 				t->clearedToTakeOff = true;
+ 			} else {
+ 				if(!OnAnyRunway(Point3D(user_lon_node->getDoubleValue(), \
user_lat_node->getDoubleValue(), 0.0), true)) { + 					// TODO: Check if any AI \
Planes on final and tell something like: "After the landing CALLSIGN line up runway \
two eight right" + 					trns += " Line up runway " + \
ConvertRwyNumToSpokenString(activeRwy); + 					t->clearedToTakeOff = false;
+ 					current_atcdialog->add_entry(ident, "@CS @TO", "Report ready for take-off", \
TOWER, (int)USER_REQUEST_TAKE_OFF); + 
+ 				} else {
+ 					sg_srandom_time();
+ 					if((int(sg_random() * 10) + 1) != 3) {
+ 						t->clearedToTakeOff = true;
+ 						trns += " Cleared immediate take-off ";
+ 					} else {
+ 						t->clearedToTakeOff = false;
+ 						trns += " Negative, departure runway " + \
ConvertRwyNumToSpokenString(activeRwy); + 					}
+ 				}
+ 			}
+ 			if(_display) {
+ 				pending_transmission = trns;
+ 				Transmit();
+ 			} else {
+ 				//cout << "Not displaying, trns was " << trns << '\n';
+ 			}
+ 			t->lineUpReported = false;
  		} else if(t->holdShortReported) {
  			//cout << "Tower " << ident << " is reponding to holdShortReported...\n";
***************
*** 567,571 ****
  					trns += " cleared to land ";
  				} else {
! 					trns += " cleared for the option ";
  				}
  				// TODO - add winds
--- 629,640 ----
  					trns += " cleared to land ";
  				} else {
! 					double f = globals->get_ATC_mgr()->GetFrequency(ident, ATIS) / 100.0;
! 					string wtr;
! 					if(!f) {
! 						wtr = ", " + GetWeather();
! 					} else {
! 						wtr = ", runway " + ConvertRwyNumToSpokenString(activeRwy);
! 					}
! 					trns += " cleared to land" + wtr;
  				}
  				// TODO - add winds
***************
*** 587,590 ****
--- 656,668 ----
  			} else {
  				trns += " continue approach";
+ 				trns += " and report ";
+ 				trns += ((rwy.patternDirection == 1) ? "right " : "left ");
+ 				trns += "downwind runway " + ConvertRwyNumToSpokenString(activeRwy);
+ 				t->opType = CIRCUIT;
+ 				if(t->isUser) {
+ 					current_atcdialog->add_entry(ident, "@AP Tower, @CS Downwind @RW", "Report \
Downwind", TOWER, (int)USER_REPORT_DOWNWIND); + 				} else {
+ 					t->planePtr->RegisterTransmission(15);
+ 				}
  				t->clearedToLand = false;
  			}
***************
*** 622,626 ****
  	TowerPlaneRec* tf = NULL;
  	for(tower_plane_rec_list_iterator twrItr = appList.begin(); twrItr != \
                appList.end(); twrItr++) {
! 		if((*twrItr)->eta < (t->eta + 45)) {
  			a++;
  			tf = *twrItr;
--- 700,704 ----
  	TowerPlaneRec* tf = NULL;
  	for(tower_plane_rec_list_iterator twrItr = appList.begin(); twrItr != \
                appList.end(); twrItr++) {
! 		if((*twrItr)->eta < (t->eta + 45) && strcmp((*twrItr)->plane.callsign.c_str(), \
t->plane.callsign.c_str()) != 0) { // don't let ATC ask you to follow yourself  a++;
  			tf = *twrItr;
***************
*** 741,745 ****
  	if(0) {		// FIXME
  	//if(timeSinceLastDeparture <= 60.0 && departed == true) {
! 		trns += " line up";
  		t->clearedToLineUp = true;
  		t->planePtr->RegisterTransmission(3);	// cleared to line-up
--- 819,823 ----
  	if(0) {		// FIXME
  	//if(timeSinceLastDeparture <= 60.0 && departed == true) {
! 		trns += " line up runway " + ConvertRwyNumToSpokenString(activeRwy);
  		t->clearedToLineUp = true;
  		t->planePtr->RegisterTransmission(3);	// cleared to line-up
***************
*** 864,868 ****
  				//cout << "timeSinceLastDeparture = " << timeSinceLastDeparture << '\n';
  				if(rwyOccupied) {
! 					// Do nothing
  				} else if(timeSinceLastDeparture <= 60.0 && departed == true) {
  					// Do nothing - this is a bit of a hack - should maybe do line up be ready \
                here
--- 942,947 ----
  				//cout << "timeSinceLastDeparture = " << timeSinceLastDeparture << '\n';
  				if(rwyOccupied) {
! 					RemoveAllUserDialogOptions();
! 					current_atcdialog->add_entry(ident, "@CS Ready for take-off", "Request \
take-off clearance", TOWER, (int)USER_REQUEST_TAKE_OFF);  } else \
                if(timeSinceLastDeparture <= 60.0 && departed == true) {
  					// Do nothing - this is a bit of a hack - should maybe do line up be ready \
                here
***************
*** 1069,1084 ****
  				// or stationary near the start [V. BAD!!].
  				// For now this should stop the AI plane landing on top of the user.
! 				string trns = t->plane.callsign;
! 				trns += " GO AROUND TRAFFIC ON RUNWAY I REPEAT GO AROUND";
! 				pending_transmission = trns;
! 				ImmediateTransmit();
! 				t->instructedToGoAround = true;
! 				t->clearedToLand = false;
! 				// Assume it complies!!!
! 				t->opType = CIRCUIT;
! 				t->leg = CLIMBOUT;
! 				if(t->planePtr) {
! 					//cout << "Registering Go-around transmission with AI plane\n";
! 					t->planePtr->RegisterTransmission(13);
  				}
  			} else if(!t->clearedToLand) {
--- 1148,1174 ----
  				// or stationary near the start [V. BAD!!].
  				// For now this should stop the AI plane landing on top of the user.
! 				tower_plane_rec_list_iterator twrItr;
! 				twrItr = rwyList.begin();
! 				TowerPlaneRec* tpr = *twrItr;
! 				if(strcmp(tpr->plane.callsign.c_str(), t->plane.callsign.c_str()) == 0
! 						&& rwyList.size() == 1) {
! 					// Fixing bug when ATC says that we must go around because of traffic on rwy
! 					// but that traffic is our plane! In future we can use this expression
! 					// for other ATC-messages like "On ground at 46, vacate left."
! 
! 				} else {
! 					string trns = t->plane.callsign;
! 					trns += " GO AROUND TRAFFIC ON RUNWAY I REPEAT GO AROUND";
! 					pending_transmission = trns;
! 					ImmediateTransmit();
! 					t->instructedToGoAround = true;
! 					t->clearedToLand = false;
! 					// Assume it complies!!!
! 					t->opType = CIRCUIT;
! 					t->leg = CLIMBOUT;
! 					if(t->planePtr) {
! 						//cout << "Registering Go-around transmission with AI plane\n";
! 						t->planePtr->RegisterTransmission(13);
! 					}
  				}
  			} else if(!t->clearedToLand) {
***************
*** 1214,1217 ****
--- 1304,1308 ----
  		doThresholdETACalc();	// We need this here because planes in the lists are not \
guaranteed to *always* have the correct ETA  //cout << "eta is " << t->eta << ", rwy \
is " << (rwyList.size() ? "occupied " : "clear ") << '\n'; + 		Point3D tortho = \
ortho.ConvertToLocal(t->pos);  if(t->eta < 12 && rwyList.size() && \
!(t->instructedToGoAround)) {  // TODO - need to make this more sophisticated 
***************
*** 1219,1240 ****
  			// or stationary near the start [V. BAD!!].
  			// For now this should stop the AI plane landing on top of the user.
! 			string trns = t->plane.callsign;
! 			trns += " GO AROUND TRAFFIC ON RUNWAY I REPEAT GO AROUND";
! 			pending_transmission = trns;
! 			ImmediateTransmit();
! 			t->instructedToGoAround = true;
! 			t->clearedToLand = false;
! 			t->nextOnRwy = false;	// But note this is recalculated so don't rely on it
! 			// Assume it complies!!!
! 			t->opType = CIRCUIT;
! 			t->leg = CLIMBOUT;
! 			if(!t->isUser) {
! 				if(t->planePtr) {
! 					//cout << "Registering Go-around transmission with AI plane\n";
! 					t->planePtr->RegisterTransmission(13);
! 				}
  			} else {
! 				// TODO - add Go-around ack to comm options,
! 				// remove report rwy vacated. (possibly).
  			}
  		} else if(t->eta < 90 && !t->clearedToLand) {
--- 1310,1357 ----
  			// or stationary near the start [V. BAD!!].
  			// For now this should stop the AI plane landing on top of the user.
! 			tower_plane_rec_list_iterator twrItr;
! 			twrItr = rwyList.begin();
! 			TowerPlaneRec* tpr = *twrItr;
! 			if(strcmp ( tpr->plane.callsign.c_str(), t->plane.callsign.c_str() ) == 0 && \
                rwyList.size() == 1) {
! 					// Fixing bug when ATC says that we must go around because of traffic on rwy
! 					// but that traffic is we! In future we can use this expression
! 					// for other ATC-messages like "On ground at 46, vacate left."
! 
  			} else {
! 				string trns = t->plane.callsign;
! 				trns += " GO AROUND TRAFFIC ON RUNWAY I REPEAT GO AROUND";
! 				pending_transmission = trns;
! 				ImmediateTransmit();
! 				t->instructedToGoAround = true;
! 				t->clearedToLand = false;
! 				t->nextOnRwy = false;	// But note this is recalculated so don't rely on it
! 				// Assume it complies!!!
! 				t->opType = CIRCUIT;
! 				t->leg = CLIMBOUT;
! 				if(!t->isUser) {
! 					if(t->planePtr) {
! 						//cout << "Registering Go-around transmission with AI plane\n";
! 						t->planePtr->RegisterTransmission(13);
! 					}
! 				} else {
! 					// TODO - add Go-around ack to comm options,
! 					// remove report rwy vacated. (possibly).
! 				}
! 			}
! 		} else if(t->isUser && t->eta < 90 && tortho.y() > -2500 && t->clearedToLand && \
                t->gearUpReported == false) {
! 			// Check if gear up or down
! 			double gp = fgGetFloat("/gear/gear/position-norm");
! 			if(gp < 1) {
! 				string trnsm = t->plane.callsign;
! 				sg_srandom_time();
! 				int rnd = int(sg_random() * 2) + 1;
! 				if(rnd == 2) {				// Random message for more realistic ATC ;)
! 					trnsm += ", LANDING GEAR APPEARS UP!";
! 				} else {
! 					trnsm += ", Check wheels down and locked.";
! 				}
! 				pending_transmission = trnsm;
! 				ImmediateTransmit();
! 				t->gearUpReported = true;
  			}
  		} else if(t->eta < 90 && !t->clearedToLand) {
***************
*** 1319,1322 ****
--- 1436,1445 ----
  		else distout = dclGetHorizontalSeparation(Point3D(lon, lat, elev), \
t->planePtr->GetPos());  //cout << " distout = " << distout << '\n';
+ 		if(t->isUser && !(t->clearedToTakeOff)) {	// HACK - we use clearedToTakeOff to \
check if ATC already contacted with plane (and cleared take-off) or not + \
if(!OnAnyRunway(Point3D(user_lon_node->getDoubleValue(), \
user_lat_node->getDoubleValue(), 0.0), false)) { + \
current_atcdialog->remove_entry(ident, USER_REQUEST_TAKE_OFF, TOWER); + \
t->clearedToTakeOff = true;	// FIXME + 			}
+ 		}
  		if(distout > 10000) {
  			string trns = t->plane.callsign;
***************
*** 1328,1332 ****
  				RemoveAllUserDialogOptions();
  				//cout << "ADD A\n";
! 				current_atcdialog->add_entry(ident, "@AP Tower, @CS @MI miles @CD of the \
airport for full stop with ATIS", "Contact tower for VFR arrival (full stop)", TOWER, \
(int)USER_REQUEST_VFR_ARRIVAL_FULL_STOP);  } else {
  				// Send a clear-of-airspace signal
--- 1451,1455 ----
  				RemoveAllUserDialogOptions();
  				//cout << "ADD A\n";
! 				current_atcdialog->add_entry(ident, "@AP Tower, @CS @MI miles @CD of the \
airport for full stop@AT", "Contact tower for VFR arrival (full stop)", TOWER, \
(int)USER_REQUEST_VFR_ARRIVAL_FULL_STOP);  } else {
  				// Send a clear-of-airspace signal
***************
*** 1354,1357 ****
--- 1477,1481 ----
  	current_atcdialog->remove_entry(ident, USER_REPORT_RWY_VACATED, TOWER);
  	current_atcdialog->remove_entry(ident, USER_REPORT_GOING_AROUND, TOWER);	
+ 	current_atcdialog->remove_entry(ident, USER_REQUEST_TAKE_OFF, TOWER);
  }
  
***************
*** 1469,1483 ****
  
  	return((ldiff < rlen) && (wdiff < rwidth));
! }	
! 
  
  // Figure out if a given position lies on any runway or not
  // Only call this at startup - reading the runways database is expensive and needs \
                to be fixed!
! bool FGTower::OnAnyRunway(const Point3D& pt) {
  	ATCData ad;
! 	double dist = current_commlist->FindClosest(lon, lat, elev, ad, TOWER, 10.0);
  	if(dist < 0.0) {
  		return(false);
  	}
  	// Based on the airport-id, go through all the runways and check for a point in \
them  
--- 1593,1607 ----
  
  	return((ldiff < rlen) && (wdiff < rwidth));
! }
  
  // Figure out if a given position lies on any runway or not
  // Only call this at startup - reading the runways database is expensive and needs \
                to be fixed!
! bool FGTower::OnAnyRunway(const Point3D& pt, bool onGround) {
  	ATCData ad;
! 	double dist = current_commlist->FindClosest(lon, lat, elev, ad, TOWER, 7.0);
  	if(dist < 0.0) {
  		return(false);
  	}
+ 	
  	// Based on the airport-id, go through all the runways and check for a point in \
them  
***************
*** 1491,1499 ****
  	}
  	bool on = false;
! 	while(runway._id == ad.ident) {		
  		on = OnRunway(pt, runway);
  		//cout << "Runway " << runway._rwy_no << ": On = " << (on ? "true\n" : \
                "false\n");
! 		if(on) return(true);
! 		globals->get_runways()->next(&runway);		
  	}
  	return(on);
--- 1615,1628 ----
  	}
  	bool on = false;
! 	while(runway._id == ad.ident) {
  		on = OnRunway(pt, runway);
  		//cout << "Runway " << runway._rwy_no << ": On = " << (on ? "true\n" : \
                "false\n");
! 		if(on) {
! 			if(onGround == false)
! 				return(true);
! 			if(runway._rwy_no != "xx")
! 				return(true);
! 		}
! 		globals->get_runways()->next(&runway);
  	}
  	return(on);
***************
*** 1693,1696 ****
--- 1822,1834 ----
  }
  
+ void FGTower::AddToHoldingList(TowerPlaneRec* t) {
+ 	tower_plane_rec_list_iterator it, end = holdList.end();
+ 	for (it = holdList.begin(); it != end; ++it) {
+ 		if ((*it)->plane.callsign == t->plane.callsign)
+ 			return;
+ 	
+ 		holdList.push_back(t);
+ 	}
+ }
  
  // Calculate the eta of a plane to the threshold.
***************
*** 2066,2069 ****
--- 2204,2226 ----
  	//cout << "Request Departure Clearance called...\n";
  }
+ 
+ void FGTower::RequestTakeOffClearance(const string& ID) {
+ 	string uid=ID;
+ 	if(ID == "USER") {
+ 		uid = fgGetString("/sim/user/callsign");
+ 		current_atcdialog->remove_entry(ident, USER_REQUEST_TAKE_OFF, TOWER);
+ 	}
+ 	TowerPlaneRec* t = FindPlane(uid);
+ 	if(t) {
+ 		if(!(t->clearedToTakeOff)) {
+ 			departed = false;
+ 			t->lineUpReported=true;
+ 			responseReqd = true;
+ 		}
+ 	}
+ 	else {
+ 		SG_LOG(SG_ATC, SG_WARN, "WARNING: Unable to find plane " << ID << " in \
FGTower::RequestTakeOffClearance(...)"); + 	}
+ }
  	
  void FGTower::ReportFinal(const string& ID) {
***************
*** 2306,2309 ****
--- 2463,2467 ----
  	//FGTransmission t;
  	string usercall = fgGetString("/sim/user/callsign");
+ 	TowerPlaneRec* t = FindPlane(responseID);
  	
  	//transmission_list_type     tmissions = transmissionlist_station[station];
***************
*** 2322,2325 ****
--- 2480,2484 ----
  			// Replace all the '@' parameters with the actual text.
  			int check = 0;	// If mes gets overflowed the while loop can go infinite
+ 			double gp = fgGetFloat("/gear/gear/position-norm");
  			while ( strchr(&mes[0], crej) != NULL  ) {	// ie. loop until no more occurances \
of crej ('@') found  pos = strchr( &mes[0], crej );
***************
*** 2365,2368 ****
--- 2524,2540 ----
  					*/
  				}
+ 				else if ( strcmp ( tag, "@AT" ) == 0 ) {	// ATIS ID
+ 					/*
+ 					char buf[10];
+ 					sprintf( buf, "%i", (int)(tpars.heading) );
+ 					strcat( &dum[0], &buf[0] );
+ 					*/
+ 					double f = globals->get_ATC_mgr()->GetFrequency(ident, ATIS) / 100.0;
+ 					if(f) {
+ 						string atis_id;
+ 						atis_id = ", information " + GetATISID();
+ 						strcat( &dum[0], atis_id.c_str() );
+ 					}
+ 				}
  				else if ( strcmp ( tag, "@VD" ) == 0 ) {
  					/*
***************
*** 2388,2391 ****
--- 2560,2577 ----
  					*/
  				}
+ 				else if ( strcmp ( tag, "@TO" ) == 0 ) {      // Requesting take-off or \
departure clearance + 					string tmp;
+ 					if (rwyOccupied) {
+ 						tmp = "Ready for take-off";
+ 					} else {
+ 						if (OnAnyRunway(Point3D(user_lon_node->getDoubleValue(),
+ 								user_lat_node->getDoubleValue(), 0.0),true)) {
+ 							tmp = "Request take-off clearance";
+ 						} else {
+ 							tmp = "Request departure clearance";
+ 						}
+ 					}
+ 					strcat(&dum[0], tmp.c_str());
+ 				}
  				else if ( strcmp ( tag, "@MI" ) == 0 ) {
  					char buf[10];
***************
*** 2404,2408 ****
  				else if ( strcmp ( tag, "@RW" ) == 0 ) {
  					strcat(&dum[0], ConvertRwyNumToSpokenString(activeRwy).c_str());
! 				} else if(strcmp(tag, "@CD") == 0) {	// @CD = compass direction
  					double h = GetHeadingFromTo(Point3D(lon, lat, elev), \
Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), \
user_elev_node->getDoubleValue()));  while(h < 0.0) h += 360.0;
--- 2590,2600 ----
  				else if ( strcmp ( tag, "@RW" ) == 0 ) {
  					strcat(&dum[0], ConvertRwyNumToSpokenString(activeRwy).c_str());
! 				}
! 				else if ( strcmp ( tag, "@GR" ) == 0 ) {	// Gear position (on final)
! 					if(t->gearWasUp && gp > 0.99) {
! 						strcat(&dum[0], ", gear down, ready to land.");
! 					}
! 				}
! 				else if(strcmp(tag, "@CD") == 0) {	// @CD = compass direction
  					double h = GetHeadingFromTo(Point3D(lon, lat, elev), \
Point3D(user_lon_node->getDoubleValue(), user_lat_node->getDoubleValue(), \
user_elev_node->getDoubleValue()));  while(h < 0.0) h += 360.0;
***************
*** 2443,2448 ****
  		//}
  	//}
! 	if ( mes[0] ) return mes;
! 	else return "No transmission found";
  }
  
--- 2635,2668 ----
  		//}
  	//}
! 	return mes[0] ? mes : "No transmission found";
! }
! 
! string FGTower::GetWeather() {
! 	std::ostringstream msg;
! 
! 	// wind
! 	double hdg = wind_from_hdg->getDoubleValue();
! 	double speed = wind_speed_knots->getDoubleValue();
! 	if (speed==0)
! 		msg << "wind calm";
! 	else
! 		msg << "wind " << int(hdg) << " degrees at " << int(speed) << " knots";
! 
! 	// visibility
! 	double visibility = fgGetDouble("/environment/visibility-m");
! 	if (visibility < 10000)
! 		msg << ", visibility " << int(visibility / 1609) << " miles";
! 
! 	// pressure / altimeter
! 	double pressure = fgGetDouble("/environment/pressure-sea-level-inhg");
! 	msg << ", QFE " << fixed << setprecision(2) << pressure << ".";
! 
! 	return msg.str();
! }
! 
! string FGTower::GetATISID() {
! 	int hours = fgGetInt("/sim/time/utc/hour");
! 	int phonetic_id = current_commlist->GetCallSign(ident, hours, 0);
! 	return GetPhoneticIdent(phonetic_id);
  }
  

Index: tower.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/FlightGear/src/ATC/tower.hxx,v
retrieving revision 1.34
retrieving revision 1.34.2.1
diff -C 2 -r1.34 -r1.34.2.1
*** tower.hxx	11 Jun 2006 10:21:10 -0000	1.34
--- tower.hxx	31 Jan 2008 22:38:32 -0000	1.34.2.1
***************
*** 61,65 ****
  	USER_REPORT_DOWNWIND = 6,
  	USER_REPORT_RWY_VACATED = 7,
! 	USER_REPORT_GOING_AROUND = 8
  };
  
--- 61,66 ----
  	USER_REPORT_DOWNWIND = 6,
  	USER_REPORT_RWY_VACATED = 7,
! 	USER_REPORT_GOING_AROUND = 8,
! 	USER_REQUEST_TAKE_OFF = 9
  };
  
***************
*** 88,91 ****
--- 89,93 ----
  	// ought to add time cleared to depart so we can nag if necessary
  	bool holdShortReported;
+ 	bool lineUpReported;
  	bool downwindReported;
  	bool longFinalReported;
***************
*** 99,102 ****
--- 101,106 ----
  	bool onRwy;		// is physically on the runway
  	bool nextOnRwy;		// currently projected by tower to be the next on the runway
+ 	bool gearWasUp;          // Tell to ATC about gear
+ 	bool gearUpReported;     // Tell to pilot about landing gear
  	
  	bool vfrArrivalReported;
***************
*** 140,143 ****
--- 144,148 ----
  	
  	void RequestDepartureClearance(const string& ID);
+ 	void RequestTakeOffClearance(const string& ID);
  	void ReportFinal(const string& ID);
  	void ReportLongFinal(const string& ID);
***************
*** 178,184 ****
  	
  	string GenText(const string& m, int c);
  
  private:
! 	FGATCMgr* ATCmgr;	
  	// This is purely for synactic convienience to avoid writing \
globals->get_ATC_mgr()-> all through the code!  
--- 183,191 ----
  	
  	string GenText(const string& m, int c);
+ 	string GetWeather();
+ 	string GetATISID();
  
  private:
! 	FGATCMgr* ATCmgr;
  	// This is purely for synactic convienience to avoid writing \
globals->get_ATC_mgr()-> all through the code!  
***************
*** 214,218 ****
  	
  	// Figure out if a given position lies on a runway or not
! 	bool OnAnyRunway(const Point3D& pt);
  	
  	// Calculate the eta of a plane to the threshold.
--- 221,225 ----
  	
  	// Figure out if a given position lies on a runway or not
! 	bool OnAnyRunway(const Point3D& pt, bool onGround);
  	
  	// Calculate the eta of a plane to the threshold.
***************
*** 256,259 ****
--- 263,267 ----
  	bool rwyOccupied;	// Active runway occupied flag.  For now we'll disregard \
land-and-hold-short operations.  FGATCAlignedProjection ortho;	// Orthogonal mapping \
of the local area with the active runway threshold at the origin + \
FGATCAlignedProjection ortho_temp;	// Ortho for any runway (needed to get plane \
position in airport)  
  	// Figure out which runways are active.
***************
*** 320,323 ****
--- 328,333 ----
  	// Add to vacated list only if not already present
  	void AddToVacatedList(TowerPlaneRec* t);
+ 	
+ 	void AddToHoldingList(TowerPlaneRec* t);
  
  	// Ground can be separate or handled by tower in real life.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Flightgear-cvslogs mailing list
Flightgear-cvslogs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-cvslogs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic