private void bw_Horizon_Calculate_DoWork(object sender, DoWorkEventArgs e) { // name the thread for debugging if (String.IsNullOrEmpty(Thread.CurrentThread.Name)) { Thread.CurrentThread.Name = Name + "_" + this.GetType().Name; } try { Stopwatch st = new Stopwatch(); st.Start(); // clear all diagrams ClearAllDiagrams(); PropagationHorizonDesignator hd = PropagationData.Database.PropagationHorizonFindOrCreate( bw_Horizon_Calculate, Location.Lat, Location.Lon, Elevation + AntennaHeight, CalculationDistance, Bands.ToGHz(Properties.Settings.Default.Band), LatLon.Earth.Radius * Properties.Settings.Default.Path_Band_Settings[Properties.Settings.Default.Band].K_Factor, Properties.Settings.Default.Path_Band_Settings[Properties.Settings.Default.Band].F1_Clearance, ElevationData.Database.GetDefaultStepWidth(Properties.Settings.Default.ElevationModel), Properties.Settings.Default.ElevationModel, LocalObstruction); st.Stop(); bw_Horizon_Calculate.ReportProgress(-1, "Calculation of radio horizon of " + Location.Call + " finished, " + st.ElapsedMilliseconds + "ms."); // report complete horizon to main thread bw_Horizon_Calculate.ReportProgress(360, hd); } catch (Exception ex) { bw_Horizon_Calculate.ReportProgress(-1, ex.ToString()); } }
private void bw_Horizon_Calculate_ProgressChanged(object sender, ProgressChangedEventArgs e) { if (e.ProgressPercentage < 0) { tsl_Main.Text = (string)e.UserState; } else if ((e.ProgressPercentage >= 0) && (e.ProgressPercentage <= 359)) { // draw single horizon point when new calculation is running HorizonPoint hp = (HorizonPoint)e.UserState; DrawHorizonPoint(e.ProgressPercentage, hp); } else if (e.ProgressPercentage == 360) { // store complete horizon Horizon = (PropagationHorizonDesignator)e.UserState; } }
private void CalculateHorizons() { List <LocationDesignator> lds = StationData.Database.LocationGetAll(); foreach (LocationDesignator ld in lds) { Stopwatch st = new Stopwatch(); try { // short max = ElevationModel.Database.ElevationTilesMaxElevation(ELEVATIONMODEL.SRTM1, Properties.Settings.Default.MinLat, Properties.Settings.Default.MinLon, Properties.Settings.Default.MaxLat, Properties.Settings.Default.MaxLon); short max = 4797; ELEVATIONMODEL model = ELEVATIONMODEL.SRTM1; BAND band = BAND.B1_2G; short antenna_height = 40; short h1 = (short)(ElevationData.Database[ld.Lat, ld.Lon, model] + antenna_height); double dist = 500.0; double stepwidth = ElevationData.Database.GetDefaultStepWidth(model); int count = (int)(dist / stepwidth / 1000.0); HorizonPoint hp = new HorizonPoint(); st.Start(); List <HorizonPoint>[] l = new List <HorizonPoint> [360]; for (int j = 0; j < 360; j++) { Say("Calculation horizon of " + ld.Call + ": " + j + " of 360..."); l[j] = new List <HorizonPoint>(); ElevationPathDesignator path = new ElevationPathDesignator(); path = ElevationData.Database.ElevationPathCreateFromBearing(this, ld.Lat, ld.Lon, j, dist, stepwidth, model); short[] elv = path.Path; // iterate through frequencies foreach (int f in Enum.GetValues(typeof(BAND))) { double f1_clearance = 0.6; if (f <= 144) { f1_clearance = 0.2; } else if (f <= 432) { f1_clearance = 0.4; } hp = PropagationHorizonDesignator.EpsilonMaxFromPath(h1, ref elv, dist, stepwidth, f / 1000.0, f1_clearance, max, LatLon.Earth.Radius * 1.33); l[j].Add(hp); } hp = l[j].ElementAt(0); Application.DoEvents(); } st.Stop(); using (StreamWriter sw = new StreamWriter("Horizon.csv")) { sw.WriteLine("bearing[deg];eps_50M[deg];eps_70M[deg];eps[144M[deg];eps_432M[deg];eps_1.2G[deg];eps_2.3G[deg];eps_3.4G[deg];eps_5.7G[deg];eps_10G[deg];eps_24G[deg];eps_47G[deg];eps_76G[deg]"); for (int j = 0; j < l.Length; j++) { sw.Write(j + ";"); for (int k = 0; k < l[0].Count; k++) { sw.Write((l[j].ElementAt(k).Epsmin / Math.PI * 180.0).ToString("F8")); if (k < l[0].Count - 1) { sw.Write(";"); } } sw.WriteLine(); } } } catch (Exception ex) { } } }