1
0
Fork 0

FGCom: Add a different max range for ground and tower frequencies

This commit is contained in:
Clément de l'Hamaide 2013-08-27 20:23:14 +02:00
parent 4052c45ea3
commit 2bf62464cf
2 changed files with 21 additions and 2 deletions

View file

@ -43,8 +43,11 @@
#define NUM_CALLS 4 #define NUM_CALLS 4
#define MAX_GND_RANGE 10.0
#define MAX_TWR_RANGE 50.0
#define MAX_RANGE 100.0 #define MAX_RANGE 100.0
#define MIN_RANGE 20.0 #define MIN_RANGE 20.0
#define MIN_GNDTWR_RANGE 0.0
#define DEFAULT_SERVER "fgcom.flightgear.org" #define DEFAULT_SERVER "fgcom.flightgear.org"
#define IAX_DELAY 300 // delay between calls in milliseconds #define IAX_DELAY 300 // delay between calls in milliseconds
#define TEST_FREQ 910.00 #define TEST_FREQ 910.00
@ -167,6 +170,9 @@ void FGCom::init()
//_comm1Changed = false; //_comm1Changed = false;
//_nav0Changed = false; //_nav0Changed = false;
//_nav1Changed = false; //_nav1Changed = false;
_maxRange = MAX_RANGE;
_minRange = MIN_RANGE;
} }
@ -494,6 +500,17 @@ std::string FGCom::getAirportCode(const double& freq)
return std::string(); return std::string();
} }
if( apt->type() == FGPositioned::FREQ_TOWER ) {
_maxRange = MAX_TWR_RANGE;
_minRange = MIN_GNDTWR_RANGE;
} else if( apt->type() == FGPositioned::FREQ_GROUND ) {
_maxRange = MAX_GND_RANGE;
_minRange = MIN_GNDTWR_RANGE;
} else {
_maxRange = MAX_RANGE;
_minRange = MIN_RANGE;
}
_aptPos = apt->geod(); _aptPos = apt->geod();
return apt->airport()->ident(); return apt->airport()->ident();
} }
@ -579,8 +596,8 @@ bool FGCom::isInRange(const double &freq) const
double delta_elevation_ft = fabs(acftPos.getElevationFt() - _aptPos.getElevationFt()); double delta_elevation_ft = fabs(acftPos.getElevationFt() - _aptPos.getElevationFt());
double rangeNm = 1.23 * sqrt(delta_elevation_ft); double rangeNm = 1.23 * sqrt(delta_elevation_ft);
if (rangeNm > MAX_RANGE) rangeNm = MAX_RANGE; if (rangeNm > _maxRange) rangeNm = _maxRange;
if (rangeNm < MIN_RANGE) rangeNm = MIN_RANGE; if (rangeNm < _minRange) rangeNm = _minRange;
if( distNm > rangeNm ) return 0; if( distNm > rangeNm ) return 0;
return 1; return 1;
} }

View file

@ -63,6 +63,8 @@ class FGCom : public SGSubsystem, public SGPropertyChangeListener
double _maxRange;
double _minRange;
double _currentComm0; double _currentComm0;
//double _currentComm1; //double _currentComm1;
//double _currentNav0; //double _currentNav0;