]> git.mxchange.org Git - flightgear.git/blobdiff - src/Radio/radio.cxx
Expose a radio function (receiveBeacon) to the Nasal subsystem
[flightgear.git] / src / Radio / radio.cxx
index 53e6c21f2ec24652906ab762a5fb92c6239e2ab3..3412a151b3fd48f1f5f6b7839073580200d13d0a 100644 (file)
@@ -37,7 +37,7 @@
 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:
@@ -115,6 +115,28 @@ double FGRadioTransmission::receiveNav(SGGeod tx_pos, double freq, int transmiss
 
 }
 
+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) {
@@ -362,15 +384,15 @@ double FGRadioTransmission::ITM_calculate_attenuation(SGGeod pos, double freq, i
        double num_points= (double)elevations.size();
 
 
-       _elevations.push_front(point_distance);
-       _elevations.push_front(num_points -1);
+       elevations.push_front(point_distance);
+       elevations.push_front(num_points -1);
 
-       int size = _elevations.size();
+       int size = elevations.size();
        double *itm_elev;
        itm_elev = new double[size];
 
        for(int i=0;i<size;i++) {
-               itm_elev[i]=_elevations[i];
+               itm_elev[i]=elevations[i];
                
 
        }