]> git.mxchange.org Git - flightgear.git/commitdiff
Rename conversion functions to be more explicit
authoradrian <adrian@localhost.com>
Sat, 3 Dec 2011 16:48:24 +0000 (18:48 +0200)
committeradrian <adrian@localhost.com>
Sat, 3 Dec 2011 16:48:24 +0000 (18:48 +0200)
...and set some more properties: tx-erp, etc.

src/Radio/radio.cxx
src/Radio/radio.hxx

index 20322a0cf9d630c9252eafbbe69524bcb1d75dbb..038f4a8307652c32cbcc7924bbd8e8bb9dfbd180 100644 (file)
@@ -145,10 +145,7 @@ void FGRadioTransmission::receiveATC(SGGeod tx_pos, double freq, string text, in
                        else {
                                
                                fgSetString("/sim/messages/atc", text.c_str());
-                               /** write signal strength above threshold to the property tree
-                               *       to implement a simple S-meter just divide by 3 dB per grade (VHF norm)
-                               **/
-                               _root_node->setDoubleValue("station[0]/signal", signal);
+                               
                        }
                }
                else if ( _propagation_model == 2 ) {
@@ -180,15 +177,10 @@ void FGRadioTransmission::receiveATC(SGGeod tx_pos, double freq, string text, in
                                //cerr << "Usable signal at limit: " << signal << endl;
                                fgSetDouble("/sim/sound/voices/voice/volume", volume);
                                fgSetString("/sim/messages/atc", text.c_str());
-                               _root_node->setDoubleValue("station[0]/signal", signal);
                                fgSetDouble("/sim/sound/voices/voice/volume", old_volume);
                        }
                        else {
                                fgSetString("/sim/messages/atc", text.c_str());
-                               /** write signal strength above threshold to the property tree
-                               *       to implement a simple S-meter just divide by 3 dB per grade (VHF norm)
-                               **/
-                               _root_node->setDoubleValue("station[0]/signal", signal);
                        }
                        
                }
@@ -233,6 +225,8 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
        
        double link_budget = tx_pow - _receiver_sensitivity - _rx_line_losses - _tx_line_losses + ant_gain;     
        double signal_strength = tx_pow - _rx_line_losses - _tx_line_losses + ant_gain; 
+       double tx_erp = dbm_to_watt(tx_pow + _tx_antenna_gain - _tx_line_losses);
+       
 
        FGScenery * scenery = globals->get_scenery();
        
@@ -309,7 +303,7 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
        //cerr << "ITM:: RX-height: " << receiver_height << " meters, TX-height: " << transmitter_height << " meters, Distance: " << distance_m << " meters" << endl;
        _root_node->setDoubleValue("station[0]/rx-height", receiver_height);
        _root_node->setDoubleValue("station[0]/tx-height", transmitter_height);
-       _root_node->setDoubleValue("station[0]/distance", distance_m);
+       _root_node->setDoubleValue("station[0]/distance", distance_m / 1000);
        
        unsigned int e_size = (deque<unsigned>::size_type)max_points;
        
@@ -411,6 +405,8 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
        double field_strength_uV = dbm_to_microvolt(signal_strength_dbm);
        _root_node->setDoubleValue("station[0]/signal-dbm", signal_strength_dbm);
        _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);
        return signal;
 
 }
@@ -921,16 +917,16 @@ double FGRadioTransmission::polarization_loss() {
 }
 
 
-double FGRadioTransmission::power_to_dbm(double power_watt) {
+double FGRadioTransmission::watt_to_dbm(double power_watt) {
        return 10 * log10(1000 * power_watt);   // returns dbm
 }
 
-double FGRadioTransmission::dbm_to_power(double dbm) {
+double FGRadioTransmission::dbm_to_watt(double dbm) {
        return exp( (dbm-30) * log(10) / 10);   // returns Watts
 }
 
 double FGRadioTransmission::dbm_to_microvolt(double dbm) {
-       return sqrt(dbm_to_power(dbm) * 50) * 1000000;  // returns microvolts
+       return sqrt(dbm_to_watt(dbm) * 50) * 1000000;   // returns microvolts
 }
 
 
index 619de3950fe9366b9238866276fc116a81caab43..7b07d927e9e4e4b7eef9411f9c68c88dc5a26751 100644 (file)
@@ -80,8 +80,8 @@ public:
     void setPropagationModel(int model) { _propagation_model = model; };
     void setPolarization(int polarization) { _polarization = polarization; };
     // accessory functions for unit conversions
-    double power_to_dbm(double power_watt);
-    double dbm_to_power(double dbm);
+    double watt_to_dbm(double power_watt);
+    double dbm_to_watt(double dbm);
     double dbm_to_microvolt(double dbm);