]> git.mxchange.org Git - flightgear.git/blobdiff - src/Radio/itm.cpp
Expose a radio function (receiveBeacon) to the Nasal subsystem
[flightgear.git] / src / Radio / itm.cpp
index 9c2f010fc2606fe7882eb19e84bec863f3998ebd..bf42ee2e821e5568248d1a6f3b8def3bd449a622 100644 (file)
@@ -39,8 +39,8 @@
 #include <assert.h>
 #include <stdio.h>
 
-const float THIRD = (1.0/3.0);
-const float f_0 = 47.7; // 47.7 MHz from [Alg 1.1], to convert frequency into wavenumber and vica versa
+const double THIRD = (1.0/3.0);
+const double f_0 = 47.7; // 47.7 MHz from [Alg 1.1], to convert frequency into wavenumber and vica versa
 
 
 using namespace std;
@@ -132,8 +132,8 @@ double FORTRAN_DIM(const double &x, const double &y)
                return 0.0;
 }
 
-#define set_warn(txt, err) printf("%s:%d %s\n", __func__, __LINE__, txt);
-
+//#define set_warn(txt, err) printf("%s:%d %s\n", __func__, __LINE__, txt);
+#define set_warn(txt, err) 1;
 
 // :13: single-knife attenuation, page 6
 /*
@@ -1000,7 +1000,7 @@ double avar(double zzt, double zzl, double zzc, prop_type &prop, propv_type &pro
                        kdv = propv.mdvar;
                        no_situation_variability = kdv >= 20;
                        if (no_situation_variability)
-                               no_situation_variability -= 20;
+                               kdv -= 20;
 
                        no_location_variability = kdv >= 10;
                        if (no_location_variability)
@@ -1378,7 +1378,7 @@ double dlthx(double pfl[], const double &x1, const double &x2)
        n = 10 * ka - 5;
        kb = n - ka + 1;
        sn = n - 1;
-       assert((s = new double[n+2]) != 0);
+       s = new double[n+2];
        s[0] = sn;
        s[1] = 1.0;
        xb = (xb - xa) / sn;
@@ -1519,6 +1519,8 @@ void point_to_point(double elev[],
                     double rel,                // 0.01 .. .99, Fractions of time
                     double &dbloss,
                     char *strmode,
+                    int &p_mode,                               // propagation mode selector
+                    double (&horizons)[2],                     // horizon distances
                     int &errnum)
 {
        // radio_climate: 1-Equatorial, 2-Continental Subtropical, 3-Maritime Tropical,
@@ -1568,22 +1570,38 @@ void point_to_point(double elev[],
        fs = 32.45 + 20.0 * log10(frq_mhz) + 20.0 * log10(prop.d / 1000.0);
        q = prop.d - prop.d_L;
 
+       horizons[0] = 0.0;
+       horizons[1] = 0.0;
        if (int(q) < 0.0) {
                strcpy(strmode, "Line-Of-Sight Mode");
+               p_mode = 0;
        } else {
-               if (int(q) == 0.0)
+               if (int(q) == 0.0) {
                        strcpy(strmode, "Single Horizon");
+                       horizons[0] = prop.d_Lj[0];
+                       p_mode = 1;
+               }
 
-               else
-                       if (int(q) > 0.0)
+               else {
+                       if (int(q) > 0.0) {
                                strcpy(strmode, "Double Horizon");
+                               horizons[0] = prop.d_Lj[0];
+                               horizons[1] = prop.d_Lj[1];
+                               p_mode = 1;
+                       }
+               }
 
-               if (prop.d <= prop.d_Ls || prop.d <= prop.dx)
+               if (prop.d <= prop.d_Ls || prop.d <= prop.dx) {
                        strcat(strmode, ", Diffraction Dominant");
+                       p_mode = 1;
+               }
 
-               else
-               if (prop.d > prop.dx)
-                       strcat(strmode, ", Troposcatter Dominant");
+               else {
+                       if (prop.d > prop.dx) {
+                               strcat(strmode, ", Troposcatter Dominant");
+                               p_mode = 2;
+                       }
+               }
        }
 
        dbloss = avar(zr, 0.0, zc, prop, propv) + fs;