1
0
Fork 0

cosmetics -- NO CODE CHANGE!

remove trailing spaces
fix very liberal indentation (logical block not indented at all, 5 spaces, ...)
removed commented out code
This commit is contained in:
mfranz 2005-11-25 19:07:24 +00:00
parent 85b93d8347
commit f323c2e7ea

View file

@ -120,7 +120,6 @@ TACAN::init ()
_bearing_node = node->getChild("indicated-bearing-true-deg", 0, true);
_carrier_lat_node = fgGetNode("/ai/models/carrier/position/latitude-deg", true);
_carrier_lon_node = fgGetNode("/ai/models/carrier/position/longitude-deg", true);
// _carrier_name_node = fgGetNode("/ai/models/carrier/name", true);
SGPropertyNode *cnode = fgGetNode("/ai/models/carrier", num, true );
_carrier_name_node = cnode->getChild("name", 0, true);
@ -139,19 +138,15 @@ TACAN::update (double delta_time_sec)
string _channel, _last_channel, _channel_1, _channel_2,_channel_3, _channel_4;
// If it's off, don't waste any time.
if (!_serviceable_node->getBoolValue() ||
!_electrical_node->getBoolValue()
) {
_last_distance_nm = 0;
_in_range_node->setBoolValue(false);
_distance_node->setDoubleValue(0);
_speed_node->setDoubleValue(0);
_time_node->setDoubleValue(0);
SG_LOG( SG_INSTR, SG_DEBUG, "skip tacan " );
return;
}else{
//SG_LOG( SG_INSTR, SG_DEBUG, "run tacan " );
}
if (!_serviceable_node->getBoolValue() || !_electrical_node->getBoolValue()) {
_last_distance_nm = 0;
_in_range_node->setBoolValue(false);
_distance_node->setDoubleValue(0);
_speed_node->setDoubleValue(0);
_time_node->setDoubleValue(0);
SG_LOG( SG_INSTR, SG_DEBUG, "skip tacan" );
return;
}
// Figure out the source
const char * source = _source_node->getStringValue();
@ -159,7 +154,6 @@ TACAN::update (double delta_time_sec)
if (source[0] == '\0') {
string branch;
branch = "/instrumentation/" + name + "/frequencies/selected-channel";
// branch = "/instrumentation/" + _name + "/frequencies/selected-mhz";
_source_node->setStringValue(branch.c_str());
source = _source_node->getStringValue();
SG_LOG( SG_INSTR, SG_DEBUG, "source " << source );
@ -183,57 +177,56 @@ TACAN::update (double delta_time_sec)
}
// Get the aircraft position
double longitude_deg = _longitude_node->getDoubleValue();
double latitude_deg = _latitude_node->getDoubleValue();
double altitude_m = _altitude_node->getDoubleValue() * SG_FEET_TO_METER;
double longitude_rad = longitude_deg * SGD_DEGREES_TO_RADIANS;
double latitude_rad = latitude_deg * SGD_DEGREES_TO_RADIANS;
double longitude_deg = _longitude_node->getDoubleValue();
double latitude_deg = _latitude_node->getDoubleValue();
double altitude_m = _altitude_node->getDoubleValue() * SG_FEET_TO_METER;
double longitude_rad = longitude_deg * SGD_DEGREES_TO_RADIANS;
double latitude_rad = latitude_deg * SGD_DEGREES_TO_RADIANS;
// On timeout, scan again
_time_before_search_sec -= delta_time_sec;
if (_time_before_search_sec < 0 && frequency_mhz > 0)
search(frequency_mhz, longitude_rad,
latitude_rad, altitude_m);
search(frequency_mhz, longitude_rad, latitude_rad, altitude_m);
// Calculate the distance to the transmitter
//calculate the bearing and range of the carrier from the aircraft
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_lat " << _carrier_lat);
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_lon " << _carrier_lon);
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_name " << _carrier_name);
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_valid " << _carrier_valid);
geo_inverse_wgs_84(altitude_m,
latitude_deg,
longitude_deg,
_carrier_lat,
_carrier_lon,
&carrier_bearing, &carrier_az2, &carrier_distance);
//calculate the bearing and range of the carrier from the aircraft
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_lat " << _carrier_lat);
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_lon " << _carrier_lon);
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_name " << _carrier_name);
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_valid " << _carrier_valid);
geo_inverse_wgs_84(altitude_m,
latitude_deg,
longitude_deg,
_carrier_lat,
_carrier_lon,
&carrier_bearing, &carrier_az2, &carrier_distance);
//calculate the bearing and range of the station from the aircraft
geo_inverse_wgs_84(altitude_m,
latitude_deg,
longitude_deg,
_transmitter_lat,
_transmitter_lon,
&bearing, &az2, &distance);
//calculate the bearing and range of the station from the aircraft
geo_inverse_wgs_84(altitude_m,
latitude_deg,
longitude_deg,
_transmitter_lat,
_transmitter_lon,
&bearing, &az2, &distance);
//select the nearer
if ( carrier_distance <= distance && _carrier_valid) {
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_distance_nm " << carrier_distance);
SG_LOG( SG_INSTR, SG_DEBUG, "distance_nm " << distance);
bearing = carrier_bearing;
distance = carrier_distance;
_transmitter_elevation_ft = _carrier_elevation_ft;
_transmitter_range_nm = _carrier_range_nm;
_transmitter_bias = _carrier_bias;
_transmitter_name = _carrier_name;
_name_node->setStringValue(_transmitter_name.c_str());
}
//select the nearer
if ( carrier_distance <= distance && _carrier_valid) {
SG_LOG( SG_INSTR, SG_DEBUG, "carrier_distance_nm " << carrier_distance);
SG_LOG( SG_INSTR, SG_DEBUG, "distance_nm " << distance);
bearing = carrier_bearing;
distance = carrier_distance;
_transmitter_elevation_ft = _carrier_elevation_ft;
_transmitter_range_nm = _carrier_range_nm;
_transmitter_bias = _carrier_bias;
_transmitter_name = _carrier_name;
_name_node->setStringValue(_transmitter_name.c_str());
}
double distance_nm = distance * SG_METER_TO_NM;
SG_LOG( SG_INSTR, SG_DEBUG, "distance_nm " << distance_nm << " bearing " << bearing);
double distance_nm = distance * SG_METER_TO_NM;
SG_LOG( SG_INSTR, SG_DEBUG, "distance_nm " << distance_nm << " bearing " << bearing);
/*Point3D location =
sgGeodToCart(Point3D(longitude_rad, latitude_rad, altitude_m));
@ -268,8 +261,7 @@ TACAN::update (double delta_time_sec)
}
// If we can't find a valid station set everything to zero
if (!_transmitter_valid && !_carrier_valid)
{
if (!_transmitter_valid && !_carrier_valid) {
_in_range_node->setBoolValue(false);
_distance_node->setDoubleValue(0);
_speed_node->setDoubleValue(0);
@ -283,7 +275,7 @@ TACAN::update (double delta_time_sec)
void
TACAN::search (double frequency_mhz, double longitude_rad,
double latitude_rad, double altitude_m)
double latitude_rad, double altitude_m)
{
SG_LOG( SG_INSTR, SG_DEBUG, "tacan freq " << frequency_mhz );
@ -310,30 +302,27 @@ TACAN::search (double frequency_mhz, double longitude_rad,
int i;
for ( i = 0; i < number; ++i ) {
string str2 ( carrier[i]->getStringValue("name", ""));
// SG_LOG( SG_INSTR, SG_DEBUG, "carrier name " << str2 );
string str2 ( carrier[i]->getStringValue("name", ""));
// SG_LOG( SG_INSTR, SG_DEBUG, "carrier name " << str2 );
//string str2 ( _carrier_name_node->getStringValue());
SG_LOG( SG_INSTR, SG_DEBUG, "strings 1 " << str1 << " 2 " << str2 );
unsigned int loc1= str1.find( str2, 0 );
if( loc1 != string::npos && str2 != "" ){
SG_LOG( SG_INSTR, SG_DEBUG, " string found" );
_carrier_lat = _carrier_lat_node->getDoubleValue();
_carrier_lon = _carrier_lon_node->getDoubleValue();
_carrier_elevation_ft = carrier_tacan->get_elev_ft();
_carrier_range_nm = carrier_tacan->get_range();
_carrier_bias = carrier_tacan->get_multiuse();
_carrier_name = carrier_tacan->get_name();
_carrier_valid = 1;
SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter valid " << _carrier_valid );
break;
}
else{
_carrier_valid = 0;
SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter invalid " << _carrier_valid );
}
}
SG_LOG( SG_INSTR, SG_DEBUG, "strings 1 " << str1 << " 2 " << str2 );
unsigned int loc1= str1.find( str2, 0 );
if ( loc1 != string::npos && str2 != "" ) {
SG_LOG( SG_INSTR, SG_DEBUG, " string found" );
_carrier_lat = _carrier_lat_node->getDoubleValue();
_carrier_lon = _carrier_lon_node->getDoubleValue();
_carrier_elevation_ft = carrier_tacan->get_elev_ft();
_carrier_range_nm = carrier_tacan->get_range();
_carrier_bias = carrier_tacan->get_multiuse();
_carrier_name = carrier_tacan->get_name();
_carrier_valid = 1;
SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter valid " << _carrier_valid );
break;
} else {
_carrier_valid = 0;
SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter invalid " << _carrier_valid );
}
}
//_name_node->setStringValue(_transmitter_name.c_str());
@ -342,14 +331,14 @@ TACAN::search (double frequency_mhz, double longitude_rad,
SG_LOG( SG_INSTR, SG_DEBUG, "elev " << _carrier_elevation_ft);
} else {
SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter invalid " << _carrier_valid );
}
SG_LOG( SG_INSTR, SG_DEBUG, " carrier transmitter invalid " << _carrier_valid );
}
// try the TACAN/VORTAC list next
FGNavRecord *tacan
= globals->get_tacanlist()->findByFreq( frequency_mhz, longitude_rad,
latitude_rad, altitude_m);
latitude_rad, altitude_m);
_transmitter_valid = (tacan != NULL);
@ -369,9 +358,8 @@ TACAN::search (double frequency_mhz, double longitude_rad,
SG_LOG( SG_INSTR, SG_DEBUG, "elev " << _transmitter_elevation_ft);
} else {
SG_LOG( SG_INSTR, SG_DEBUG, "transmitter invalid " << _transmitter_valid );
}
SG_LOG( SG_INSTR, SG_DEBUG, "transmitter invalid " << _transmitter_valid );
}
}
double
@ -387,7 +375,8 @@ TACAN::searchChannel (const string& _channel){
frequency_khz = freq->get_freq();
SG_LOG( SG_INSTR, SG_DEBUG, "freq output " << frequency_khz );
//check sanity
if (frequency_khz >9620 && frequency_khz <= 12130)return frequency_khz/100;
if (frequency_khz >9620 && frequency_khz <= 12130)
return frequency_khz/100;
}
return frequency_khz = 0;
} // end TACAN::searchChannel