FGRadioTransmission::FGRadioTransmission() {
- _receiver_sensitivity = -110.0; // typical AM receiver sensitivity seems to be 0.8 microVolt at 12dB SINAD
+ _receiver_sensitivity = -105.0; // typical AM receiver sensitivity seems to be 0.8 microVolt at 12dB SINAD
/** AM transmitter power in dBm.
* Typical output powers for ATC ground equipment, VHF-UHF:
}
+double FGRadioTransmission::receiveBeacon(double lat, double lon, double elev, double heading, double pitch) {
+
+
+ _transmitter_power = 36;
+ _tx_antenna_height += 0.0;
+ _tx_antenna_gain += 0.5;
+ elev = elev * SG_FEET_TO_METER;
+ double freq = _root_node->getDoubleValue("station[0]/frequency", 118.0);
+ int ground_to_air = 1;
+ string text = "Beacon1";
+ double comm1 = getFrequency(1);
+ double comm2 = getFrequency(2);
+ if ( !(fabs(freq - comm1) <= 0.0001) && !(fabs(freq - comm2) <= 0.0001) ) {
+ return -1;
+ }
+ SGGeod tx_pos = SGGeod::fromDegM( lon, lat, elev );
+ double signal = ITM_calculate_attenuation(tx_pos, freq, ground_to_air);
+
+ return signal;
+}
+
+
/*** Receive ATC radio communication as text
***/
void FGRadioTransmission::receiveATC(SGGeod tx_pos, double freq, string text, int ground_to_air) {
double own_alt= own_alt_ft * SG_FEET_TO_METER;
- //cerr << "ITM:: pilot Lat: " << own_lat << ", Lon: " << own_lon << ", Alt: " << own_alt << endl;
+
SGGeod own_pos = SGGeod::fromDegM( own_lon, own_lat, own_alt );
SGGeod max_own_pos = SGGeod::fromDegM( own_lon, own_lat, SG_MAX_ELEVATION_M );
sender_alt = sender_alt_ft * SG_FEET_TO_METER;
SGGeod max_sender_pos = SGGeod::fromGeodM( pos, SG_MAX_ELEVATION_M );
SGGeoc sender_pos_c = SGGeoc::fromGeod( sender_pos );
- //cerr << "ITM:: sender Lat: " << parent->getLatitude() << ", Lon: " << parent->getLongitude() << ", Alt: " << sender_alt << endl;
+
double point_distance= _terrain_sampling_distance;
double course = SGGeodesy::courseRad(own_pos_c, sender_pos_c);
double num_points= (double)elevations.size();
+
elevations.push_front(point_distance);
elevations.push_front(num_points -1);
+
int size = elevations.size();
- double itm_elev[size];
+ double *itm_elev;
+ itm_elev = new double[size];
+
for(int i=0;i<size;i++) {
itm_elev[i]=elevations[i];
- //cerr << "ITM:: itm_elev: " << elevations[i] << endl;
- }
+
+ }
+
if((transmission_type == 3) || (transmission_type == 4)) {
// the sender and receiver roles are switched
point_to_point(itm_elev, receiver_height, transmitter_height,
eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
if( _root_node->getBoolValue( "use-clutter-attenuation", false ) )
- clutterLoss(frq_mhz, itm_elev, materials, receiver_height, transmitter_height, p_mode, horizons, clutter_loss);
+ calculate_clutter_loss(frq_mhz, itm_elev, materials, receiver_height, transmitter_height, p_mode, horizons, clutter_loss);
}
else {
point_to_point(itm_elev, transmitter_height, receiver_height,
eps_dielect, sgm_conductivity, eno, frq_mhz, radio_climate,
pol, conf, rel, dbloss, strmode, p_mode, horizons, errnum);
if( _root_node->getBoolValue( "use-clutter-attenuation", false ) )
- clutterLoss(frq_mhz, itm_elev, materials, transmitter_height, receiver_height, p_mode, horizons, clutter_loss);
+ calculate_clutter_loss(frq_mhz, itm_elev, materials, transmitter_height, receiver_height, p_mode, horizons, clutter_loss);
}
double pol_loss = 0.0;
_root_node->setDoubleValue("station[0]/field-strength-uV", field_strength_uV);
_root_node->setDoubleValue("station[0]/signal", signal);
_root_node->setDoubleValue("station[0]/tx-erp", tx_erp);
+
//_root_node->setDoubleValue("station[0]/tx-pattern-gain", tx_pattern_gain);
//_root_node->setDoubleValue("station[0]/rx-pattern-gain", rx_pattern_gain);
+
+ delete[] itm_elev;
+
return signal;
}
* We are only worried about clutter loss, terrain influence
* on the first Fresnel zone is calculated in the ITM functions
***/
-void FGRadioTransmission::clutterLoss(double freq, double itm_elev[], deque<string> materials,
+void FGRadioTransmission::calculate_clutter_loss(double freq, double itm_elev[], deque<string> &materials,
double transmitter_height, double receiver_height, int p_mode,
double horizons[], double &clutter_loss) {
}
double FGRadioTransmission::dbm_to_watt(double dbm) {
- return exp( (dbm-30) * log(10) / 10); // returns Watts
+ return exp( (dbm-30) * log(10.0) / 10.0); // returns Watts
}
double FGRadioTransmission::dbm_to_microvolt(double dbm) {