Ejemplo n.º 1
0
        private bool CsvExport_MultipleTimePercentages(string filepath)
        {
            var inputControl = grid_Controls.Children[0] as MultipleTimeInputsControl;

            var exportOptionsWndw = new ExportOptionsWindow()
            {
                ShowMinimum = true
            };

            if (!exportOptionsWndw.ShowDialog().Value)
            {
                return(false);
            }

            var version = Assembly.GetExecutingAssembly().GetName().Version;
            var dll     = FileVersionInfo.GetVersionInfo("p528.dll");

            // Regenerate data at 1 km steps for export
            var A__db = new List <List <double> >();

            for (int i = 0; i < inputControl.TIMEs.Count; i++)
            {
                A__db.Add(new List <double>());
            }
            var    dists    = new List <double>();
            int    warnings = 0;
            double d__km;

            double h_1__meter = (_units == Units.Meters) ? inputControl.H1 : (inputControl.H1 * Constants.METER_PER_FOOT);
            double h_2__meter = (_units == Units.Meters) ? inputControl.H2 : (inputControl.H2 * Constants.METER_PER_FOOT);
            double f__mhz     = inputControl.FMHZ;

            var    result = new CResult();
            double d      = xAxis.MinValue;

            while (d <= xAxis.MaxValue)
            {
                // convert distance to specified units for input to P.528
                d__km = (_units == Units.Meters) ? d : (d * Constants.KM_PER_NAUTICAL_MILE);

                for (int i = 0; i < inputControl.TIMEs.Count; i++)
                {
                    var r = P528(d__km, h_1__meter, h_2__meter, f__mhz, inputControl.TIMEs[i], ref result);

                    // Ignore 'ERROR_HEIGHT_AND_DISTANCE' for visualization.  Just relates to the d__km = 0 point and will return 0 dB result
                    if (r != ERROR_HEIGHT_AND_DISTANCE && r != 0)
                    {
                        warnings = r;
                    }

                    A__db[i].Add(Math.Round(result.A__db, 3));
                }

                dists.Add(Math.Round(d, 0));
                d++;
            }

            using (var fs = new StreamWriter(filepath))
            {
                fs.WriteLine($"Data Generated by the ITS ITU-R Rec P.528-{dll.FileMajorPart} GUI");
                fs.WriteLine($"Generated on {DateTime.Now.ToShortDateString()}");
                fs.WriteLine($"App Version,{version.Major}.{version.Minor}.{version.Build}");
                fs.WriteLine($"P.528-{dll.FileMajorPart} DLL Version,{dll.FileMajorPart}.{dll.FileMinorPart}.{dll.FileBuildPart}");

                // Check and print any warnings
                if (warnings != 0)
                {
                    fs.WriteLine();

                    if ((warnings & WARNING__DFRAC_TROPO_REGION) == WARNING__DFRAC_TROPO_REGION)
                    {
                        fs.WriteLine(Messages.ModelConsistencyWarning);
                    }
                    if ((warnings & WARNING__LOW_FREQUENCY) == WARNING__LOW_FREQUENCY)
                    {
                        fs.WriteLine(Messages.LowFrequencyWarning);
                    }
                }

                fs.WriteLine();
                fs.WriteLine($"h_1,{inputControl.H1}," + ((_units == Units.Meters) ? "meters" : "feet"));
                fs.WriteLine($"h_2,{inputControl.H2}," + ((_units == Units.Meters) ? "meters" : "feet"));
                fs.WriteLine($"f__mhz,{f__mhz}");
                fs.WriteLine();

                if (exportOptionsWndw.IsRowAlignedData)
                {
                    fs.Write(((_units == Units.Meters) ? "d__km" : "d__n_mile") + ",");
                    fs.WriteLine($"{String.Join(",", dists)}");
                    for (int i = 0; i < inputControl.TIMEs.Count; i++)
                    {
                        fs.WriteLine($"time = {inputControl.TIMEs[i]} %,{String.Join(",", A__db[i])}");
                    }
                }
                else
                {
                    fs.Write((_units == Units.Meters) ? "d__km" : "d__n_mile");
                    for (int i = 0; i < inputControl.TIMEs.Count; i++)
                    {
                        fs.Write($",time = {inputControl.TIMEs[i]} %");
                    }
                    fs.WriteLine();

                    for (int i = 0; i < dists.Count; i++)
                    {
                        fs.Write($"{dists[i]}");
                        for (int j = 0; j < inputControl.TIMEs.Count; j++)
                        {
                            fs.Write($",{A__db[j][i]}");
                        }

                        fs.WriteLine();
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        private bool CsvExport_SingleCurve(string filepath)
        {
            var inputControl = grid_Controls.Children[0] as SingleCurveInputsControl;

            var exportOptionsWndw = new ExportOptionsWindow()
            {
                ShowMinimum = false
            };

            if (!exportOptionsWndw.ShowDialog().Value)
            {
                return(false);
            }

            var version = Assembly.GetExecutingAssembly().GetName().Version;
            var dll     = FileVersionInfo.GetVersionInfo("p528.dll");

            // Regenerate data at 1 km steps for export
            var    A__db = new List <double>();
            var    A_fs__db = new List <double>();
            var    dists = new List <double>();
            var    modes = new List <int>();
            int    warnings = 0;
            double d__km, d_out;

            double h_1__meter = (_units == Units.Meters) ? inputControl.H1 : (inputControl.H1 * Constants.METER_PER_FOOT);
            double h_2__meter = (_units == Units.Meters) ? inputControl.H2 : (inputControl.H2 * Constants.METER_PER_FOOT);
            double f__mhz     = inputControl.FMHZ;
            double time       = inputControl.TIME;

            var    result = new CResult();
            double d      = xAxis.MinValue;

            while (d <= xAxis.MaxValue)
            {
                // convert distance to specified units for input to P.528
                d__km = (_units == Units.Meters) ? d : (d * Constants.KM_PER_NAUTICAL_MILE);

                var r = P528(d__km, h_1__meter, h_2__meter, f__mhz, time, ref result);

                // Ignore 'ERROR_HEIGHT_AND_DISTANCE' for visualization.  Just relates to the d__km = 0 point and will return 0 dB result
                if (r != ERROR_HEIGHT_AND_DISTANCE && r != 0)
                {
                    warnings = r;
                }

                // convert output distance from P.528 back into user-specified units
                d_out = (_units == Units.Meters) ? result.d__km : (result.d__km / Constants.KM_PER_NAUTICAL_MILE);

                dists.Add(Math.Round(d_out, 0));
                A__db.Add(Math.Round(result.A__db, 3));
                A_fs__db.Add(Math.Round(result.A_fs__db, 3));
                modes.Add(result.propagation_mode);

                d++;
            }

            using (var fs = new StreamWriter(filepath))
            {
                fs.WriteLine($"Data Generated by the ITS ITU-R Rec P.528-{dll.FileMajorPart} GUI");
                fs.WriteLine($"Generated on {DateTime.Now.ToShortDateString()}");
                fs.WriteLine($"App Version,{version.Major}.{version.Minor}.{version.Build}");
                fs.WriteLine($"P.528-{dll.FileMajorPart} DLL Version,{dll.FileMajorPart}.{dll.FileMinorPart}.{dll.FileBuildPart}");

                // Check and print any warnings
                if (warnings != 0)
                {
                    fs.WriteLine();

                    if ((warnings & WARNING__DFRAC_TROPO_REGION) == WARNING__DFRAC_TROPO_REGION)
                    {
                        fs.WriteLine(Messages.ModelConsistencyWarning);
                    }
                    if ((warnings & WARNING__LOW_FREQUENCY) == WARNING__LOW_FREQUENCY)
                    {
                        fs.WriteLine(Messages.LowFrequencyWarning);
                    }
                }

                fs.WriteLine();
                fs.WriteLine($"h_1,{inputControl.H1}," + ((_units == Units.Meters) ? "meters" : "feet"));
                fs.WriteLine($"h_2,{inputControl.H2}," + ((_units == Units.Meters) ? "meters" : "feet"));
                fs.WriteLine($"f__mhz,{f__mhz}");
                fs.WriteLine($"time%,{time * 100}");
                fs.WriteLine();

                if (exportOptionsWndw.IncludeModeOfPropagation)
                {
                    fs.WriteLine("Mode of Propagation: 1 = Line-of-Sight; 2 = Diffraction; 3 = Troposcatter\n");
                }

                if (exportOptionsWndw.IsRowAlignedData)
                {
                    fs.Write(((_units == Units.Meters) ? "d__km" : "d__n_mile") + ",");
                    fs.WriteLine($"{String.Join(",", dists)}");
                    fs.WriteLine($"A__db,{String.Join(",", A__db)}");
                    if (exportOptionsWndw.IncludeFreeSpaceLoss)
                    {
                        fs.WriteLine($"A_fs__db,{String.Join(",", A_fs__db)}");
                    }
                    if (exportOptionsWndw.IncludeModeOfPropagation)
                    {
                        fs.WriteLine($"Mode,{String.Join(",", modes)}");
                    }
                }
                else
                {
                    fs.Write(((_units == Units.Meters) ? "d__km" : "d__n_mile") + ",");
                    fs.Write("A__db");
                    if (exportOptionsWndw.IncludeFreeSpaceLoss)
                    {
                        fs.Write(",A_fs__db");
                    }
                    if (exportOptionsWndw.IncludeModeOfPropagation)
                    {
                        fs.Write(",PropMode");
                    }
                    fs.WriteLine();

                    for (int i = 0; i < A__db.Count; i++)
                    {
                        fs.Write($"{dists[i]},{A__db[i]}");
                        if (exportOptionsWndw.IncludeFreeSpaceLoss)
                        {
                            fs.Write($",{A_fs__db[i]}");
                        }
                        if (exportOptionsWndw.IncludeModeOfPropagation)
                        {
                            fs.Write($",{modes[i]}");
                        }
                        fs.WriteLine();
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
 internal static extern int P528(double d__km, double h_1__meter, double h_2__meter, double f__mhz, double time_percentage, ref CResult result);
Ejemplo n.º 4
0
 internal static extern int P528EX(double d__km, double h_1__meter, double h_2__meter, double f__mhz, double time_percentage, ref CResult result,
                                   ref Terminal terminal_1, ref Terminal terminal_2, ref TroposcatterParams tropo, ref Path path, ref LineOfSightParams los_params);
Ejemplo n.º 5
0
        private int GetPointsEx(double h_1__meter, double h_2__meter, double f__mhz, double time, out List <Point> btgPoints,
                                out List <Point> losPoints, out List <Point> dfracPoints, out List <Point> scatPoints, out List <Point> fsPoints, bool blendLines)
        {
            losPoints   = new List <Point>();
            dfracPoints = new List <Point>();
            scatPoints  = new List <Point>();
            fsPoints    = new List <Point>();
            btgPoints   = new List <Point>();

            bool dfracSwitch = false;
            bool scatSwitch  = false;

            var    result = new CResult();
            int    rtn = 0;
            double d__km, d_out;

            // iterate on user-specified units (km or n miles)
            double d_step = (xAxis.MaxValue - xAxis.MinValue) / 1500;
            double d      = xAxis.MinValue;

            while (d <= xAxis.MaxValue)
            {
                // convert distance to specified units for input to P.528
                d__km = (_units == Units.Meters) ? d : (d * Constants.KM_PER_NAUTICAL_MILE);

                var r = P528(d__km, h_1__meter, h_2__meter, f__mhz, time, ref result);

                // convert output distance from P.528 back into user-specified units
                d_out = (_units == Units.Meters) ? result.d__km : (result.d__km / Constants.KM_PER_NAUTICAL_MILE);

                // Ignore 'ERROR_HEIGHT_AND_DISTANCE' for visualization.  Just relates to the d__km = 0 point and will return 0 dB result
                if (r != ERROR_HEIGHT_AND_DISTANCE && r != 0)
                {
                    rtn = r;
                }

                switch (result.propagation_mode)
                {
                case 1:     // Line-of-Sight
                    losPoints.Add(new Point(d_out, result.A__db));
                    break;

                case 2:     // Diffraction
                    if (blendLines && !dfracSwitch)
                    {
                        losPoints.Add(new Point(d_out, result.A__db));       // Adding to ensure there is no gap in the curve
                        dfracSwitch = true;
                    }
                    dfracPoints.Add(new Point(d_out, result.A__db));
                    break;

                case 3:     // Troposcatter
                    if (blendLines && !scatSwitch)
                    {
                        dfracPoints.Add(new Point(d_out, result.A__db));     // Adding to ensure there is no gap in the curve
                        scatSwitch = true;
                    }
                    scatPoints.Add(new Point(d_out, result.A__db));
                    break;
                }

                fsPoints.Add(new Point(d_out, result.A_fs__db));
                btgPoints.Add(new Point(d_out, result.A__db));

                d += d_step;
            }

            return(rtn);
        }