X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FRadio%2Fitm.cpp;h=1ad10d4d8f60e97a69fc8c376c6d63932082849b;hb=cff6b2034de866df70a2b29feb3383ee8ccbbef6;hp=9c2f010fc2606fe7882eb19e84bec863f3998ebd;hpb=9bcc3a87b64fed976e8172e2f6fe643345007631;p=flightgear.git diff --git a/src/Radio/itm.cpp b/src/Radio/itm.cpp index 9c2f010fc..1ad10d4d8 100644 --- a/src/Radio/itm.cpp +++ b/src/Radio/itm.cpp @@ -39,12 +39,14 @@ #include #include -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 - using namespace std; +namespace ITM { + +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 + struct prop_type { // General input @@ -132,8 +134,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) // :13: single-knife attenuation, page 6 /* @@ -811,6 +813,7 @@ void qlra(int kst[], int klimx, int mdvarx, prop_type &prop, propv_type &propv) * computers," Princeton Univ. Press, 1955) and the maximum error should be * 4.5e-4. */ +#if 1 static double qerfi(double q) { @@ -832,6 +835,7 @@ double qerfi(double q) return v; } +#endif // :41: preparatory routine, page 20 @@ -848,6 +852,7 @@ double qerfi(double q) * surface impedance @zgnd * It may be used with either the area prediction or the point-to-point mode. */ +#if 1 static void qlrps(double fmhz, double zsys, double en0, int ipol, double eps, double sgm, prop_type &prop) @@ -880,6 +885,7 @@ void qlrps(double fmhz, double zsys, double en0, int ipol, double eps, double sg prop.Z_g_real = prop_zgnd.real(); prop.Z_g_imag = prop_zgnd.imag(); } +#endif // :30: Function curv, page 15 @@ -899,6 +905,7 @@ double curve(double const &c1, double const &c2, double const &x1, double const // :28: Area variablity, page 14 +#if 1 static double avar(double zzt, double zzl, double zzc, prop_type &prop, propv_type &propv) { @@ -1000,7 +1007,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) @@ -1165,7 +1172,7 @@ double avar(double zzt, double zzl, double zzc, prop_type &prop, propv_type &pro return avarv; } - +#endif // :45: Find to horizons, page 24 /* @@ -1378,7 +1385,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; @@ -1426,6 +1433,7 @@ double dlthx(double pfl[], const double &x1, const double &x2) * pfl[0] = np, the number of points in the path * pfl[1] = xi, the length of each increment */ +#if 1 static void qlrpfl(double pfl[], int klimx, int mdvarx, prop_type &prop, propv_type &propv) { @@ -1496,6 +1504,7 @@ void qlrpfl(double pfl[], int klimx, int mdvarx, prop_type &prop, propv_type &pr lrprop(0.0, prop); } +#endif //******************************************************** @@ -1519,6 +1528,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, @@ -1541,7 +1552,6 @@ void point_to_point(double elev[], double zc, zr; double q = eno; long ja, jb, i, np; - double dkm, xkm; double fs; prop.h_g[0] = tht_m; // Tx height above ground level @@ -1553,8 +1563,10 @@ void point_to_point(double elev[], zc = qerfi(conf); zr = qerfi(rel); np = (long)elev[0]; - dkm = (elev[1] * elev[0]) / 1000.0; - xkm = elev[1] / 1000.0; +#if 0 + double dkm = (elev[1] * elev[0]) / 1000.0; + double xkm = elev[1] / 1000.0; +#endif ja = (long)(3.0 + 0.1 * elev[0]); jb = np - ja + 6; @@ -1568,22 +1580,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; @@ -1831,3 +1859,5 @@ void area(long ModVar, double deltaH, double tht_m, double rht_m, double dist_km errnum = prop.kwx; } #endif + +}