Changeset - 6b1dee8bd7ef
[Not reviewed]
default
0 1 0
mkanning@CL-ENS241-10.cedarville.edu - 13 years ago 2013-02-14 16:26:44
mkanning@CL-ENS241-10.cedarville.edu
fixed some mapping bugs and found converter for GPS
1 file changed with 31 insertions and 9 deletions:
0 comments (0 inline, 0 general)
Demo.WindowsForms/Forms/MainForm.cs
Show inline comments
 
@@ -175,193 +175,193 @@ namespace Demo.WindowsForms
 
                //}
 
 
                // perf
 
                timerPerf.Tick += new EventHandler(timer_Tick);
 
                #endregion
 
 
                // add custom layers  
 
                {
 
                    MainMap.Overlays.Add(routes);
 
                    //MainMap.Overlays.Add(polygons);
 
                    MainMap.Overlays.Add(objects);
 
                    MainMap.Overlays.Add(top);
 
 
                    routes.Routes.CollectionChanged += new GMap.NET.ObjectModel.NotifyCollectionChangedEventHandler(Routes_CollectionChanged);
 
                    objects.Markers.CollectionChanged += new GMap.NET.ObjectModel.NotifyCollectionChangedEventHandler(Markers_CollectionChanged);
 
                }
 
 
                // set current marker
 
                currentMarker = new GMarkerGoogle(MainMap.Position, GMarkerGoogleType.arrow);
 
                currentMarker.IsHitTestVisible = false;
 
                top.Markers.Add(currentMarker);
 
 
                //MainMap.VirtualSizeEnabled = true;
 
                //if(false)
 
                {
 
                    // add my city location for demo
 
                    //GeoCoderStatusCode status = GeoCoderStatusCode.Unknow;
 
                    {
 
                        //PointLatLng? pos = GMapProviders.GoogleMap.GetPoint("Lithuania, Vilnius", out status);
 
                        //if (pos != null && status == GeoCoderStatusCode.G_GEO_SUCCESS)
 
                        //{
 
                        //    currentMarker.Position = pos.Value;
 
 
                        //    // - MDKEdit
 
                        //    //GMapMarker myCity = new GMarkerGoogle(pos.Value, GMarkerGoogleType.green_small);
 
                        //    //myCity.ToolTipMode = MarkerTooltipMode.Always;
 
                        //    //myCity.ToolTipText = "Welcome to Lithuania! ;}";
 
                        //    //objects.Markers.Add(myCity);
 
                        //}
 
                    }
 
 
                    // add some points in lithuania - MDKEdit
 
                    //AddLocationLithuania("Kaunas");
 
                    //AddLocationLithuania("Klaipėda");
 
                    //AddLocationLithuania("Šiauliai");
 
                    //AddLocationLithuania("Panevėžys");
 
 
                    if (objects.Markers.Count > 0)
 
                    {
 
                        MainMap.ZoomAndCenterMarkers(null);
 
                    }
 
 
                    //RegeneratePolygon();
 
 
                    try
 
                    {
 
                        GMapOverlay overlay = DeepClone<GMapOverlay>(objects);
 
                        Debug.WriteLine("ISerializable status for markers: OK");
 
 
                        //GMapOverlay overlay2 = DeepClone<GMapOverlay>(polygons);
 
                        //Debug.WriteLine("ISerializable status for polygons: OK");
 
 
                        GMapOverlay overlay3 = DeepClone<GMapOverlay>(routes);
 
                        Debug.WriteLine("ISerializable status for routes: OK");
 
                    }
 
                    catch (Exception ex)
 
                    {
 
                        Debug.WriteLine("ISerializable failure: " + ex.Message);
 
 
#if DEBUG
 
                        if (Debugger.IsAttached)
 
                        {
 
                            Debugger.Break();
 
                        }
 
#endif
 
                    }
 
                }
 
            }
 
        }
 
 
        public T DeepClone<T>(T obj)
 
        {
 
            using (var ms = new System.IO.MemoryStream())
 
            {
 
                var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
 
 
                formatter.Serialize(ms, obj);
 
 
                ms.Position = 0;
 
 
                return (T)formatter.Deserialize(ms);
 
            }
 
        }
 
 
        void Markers_CollectionChanged(object sender, GMap.NET.ObjectModel.NotifyCollectionChangedEventArgs e)
 
        {
 
            textBoxMarkerCount.Text = objects.Markers.Count.ToString();
 
            //textBoxMarkerCount.Text = objects.Markers.Count.ToString();
 
        }
 
 
        void Routes_CollectionChanged(object sender, GMap.NET.ObjectModel.NotifyCollectionChangedEventArgs e)
 
        {
 
            textBoxrouteCount.Text = routes.Routes.Count.ToString();
 
        }
 
 
        #region -- performance test --
 
 
        double NextDouble(Random rng, double min, double max)
 
        {
 
            return min + (rng.NextDouble() * (max - min));
 
        }
 
 
        int tt = 0;
 
        void timer_Tick(object sender, EventArgs e)
 
        {
 
            var pos = new PointLatLng(NextDouble(rnd, MainMap.ViewArea.Top, MainMap.ViewArea.Bottom), NextDouble(rnd, MainMap.ViewArea.Left, MainMap.ViewArea.Right));
 
            GMapMarker m = new GMarkerGoogle(pos, GMarkerGoogleType.green_pushpin);
 
            {
 
                m.ToolTipText = (tt++).ToString();
 
                m.ToolTipMode = MarkerTooltipMode.Always;
 
            }
 
 
            objects.Markers.Add(m);
 
 
            if (tt >= 333)
 
            {
 
                timerPerf.Stop();
 
                tt = 0;
 
            }
 
        }
 
 
        System.Windows.Forms.Timer timerPerf = new System.Windows.Forms.Timer();
 
        #endregion
 
 
        #region -- flight demo --
 
        //BackgroundWorker flightWorker = new BackgroundWorker();
 
 
        //readonly List<FlightRadarData> flights = new List<FlightRadarData>();
 
        //readonly Dictionary<int, GMapMarker> flightMarkers = new Dictionary<int, GMapMarker>();
 
 
        //bool firstLoadFlight = true;
 
        //GMapMarker currentFlight;
 
 
        //void flight_ProgressChanged(object sender, ProgressChangedEventArgs e)
 
        //{
 
        //    // stops immediate marker/route/polygon invalidations;
 
        //    // call Refresh to perform single refresh and reset invalidation state
 
        //    MainMap.HoldInvalidation = true;
 
 
        //    lock (flights)
 
        //    {
 
        //        foreach (FlightRadarData d in flights)
 
        //        {
 
        //            GMapMarker marker;
 
 
        //            if (!flightMarkers.TryGetValue(d.Id, out marker))
 
        //            {
 
        //                marker = new GMarkerGoogle(d.point, GMarkerGoogleType.blue_small);
 
        //                marker.Tag = d.Id;
 
        //                marker.ToolTipMode = MarkerTooltipMode.OnMouseOver;
 
        //                //(marker as GMapMarkerGoogleGreen).Bearing = (float?)d.bearing;
 
 
        //                flightMarkers[d.Id] = marker;
 
        //                objects.Markers.Add(marker);
 
        //            }
 
        //            else
 
        //            {
 
        //                marker.Position = d.point;
 
        //                //(marker as GMapMarkerGoogleGreen).Bearing = (float?)d.bearing;
 
        //            }
 
        //            marker.ToolTipText = d.name + ", " + d.altitude + ", " + d.speed;
 
 
        //            if (currentFlight != null && currentFlight == marker)
 
        //            {
 
        //                MainMap.Position = marker.Position;
 
        //                //MainMap.Bearing = (float)d.bearing;
 
        //            }
 
        //        }
 
        //    }
 
 
        //    if (firstLoadFlight)
 
        //    {
 
        //        MainMap.Zoom = 5;
 
        //        MainMap.SetZoomToFitRect(new RectLatLng(54.4955675218741, -0.966796875, 28.916015625, 13.3830987326932));
 
        //        firstLoadFlight = false;
 
        //    }
 
        //    MainMap.Refresh();
 
        //}
 
 
        //void flight_DoWork(object sender, DoWorkEventArgs e)
 
        //{
 
        //    bool restartSesion = true;
 
 
        //    while (!flightWorker.CancellationPending)
 
@@ -2328,494 +2328,516 @@ namespace Demo.WindowsForms
 
 
        // load gpx file
 
        private void btnLoadGPX_Click(object sender, EventArgs e)
 
        {
 
            using (FileDialog dlg = new OpenFileDialog())
 
            {
 
                dlg.CheckPathExists = true;
 
                dlg.CheckFileExists = false;
 
                dlg.AddExtension = true;
 
                dlg.DefaultExt = "gpx";
 
                dlg.ValidateNames = true;
 
                dlg.Title = "GMap.NET: open gpx log";
 
                dlg.Filter = "gpx files (*.gpx)|*.gpx";
 
                dlg.FilterIndex = 1;
 
                dlg.RestoreDirectory = true;
 
 
                if (dlg.ShowDialog() == DialogResult.OK)
 
                {
 
                    try
 
                    {
 
                        string gpx = File.ReadAllText(dlg.FileName);
 
 
                        gpxType r = MainMap.Manager.DeserializeGPX(gpx);
 
                        if (r != null)
 
                        {
 
                            if (r.trk.Length > 0)
 
                            {
 
                                foreach (var trk in r.trk)
 
                                {
 
                                    List<PointLatLng> points = new List<PointLatLng>();
 
 
                                    foreach (var seg in trk.trkseg)
 
                                    {
 
                                        foreach (var p in seg.trkpt)
 
                                        {
 
                                            points.Add(new PointLatLng((double)p.lat, (double)p.lon));
 
                                        }
 
                                    }
 
 
                                    GMapRoute rt = new GMapRoute(points, string.Empty);
 
                                    {
 
                                        rt.Stroke = new Pen(Color.FromArgb(144, Color.Red));
 
                                        rt.Stroke.Width = 5;
 
                                        rt.Stroke.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
 
                                    }
 
                                    routes.Routes.Add(rt);
 
                                }
 
 
                                MainMap.ZoomAndCenterRoutes(null);
 
                            }
 
                        }
 
                    }
 
                    catch (Exception ex)
 
                    {
 
                        Debug.WriteLine("GPX import: " + ex.ToString());
 
                        MessageBox.Show("Error importing gpx: " + ex.Message, "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 
                    }
 
                }
 
            }
 
        }
 
 
        // enable/disable host tracing
 
        //private void checkBoxTraceRoute_CheckedChanged(object sender, EventArgs e)
 
        //{
 
        //   TryTraceConnection = checkBoxTraceRoute.Checked;
 
        //   if(!TryTraceConnection)
 
        //   {
 
        //      if(iptracerWorker.IsBusy)
 
        //      {
 
        //         iptracerWorker.CancelAsync();
 
        //      }
 
        //      routes.Routes.Clear();
 
        //   }
 
        //}
 
 
        //private void GridConnections_DoubleClick(object sender, EventArgs e)
 
        //{
 
        //   GridConnections.ClearSelection();
 
        //}
 
 
        // open disk cache location
 
        private void button17_Click(object sender, EventArgs e)
 
        {
 
            try
 
            {
 
                string argument = "/select, \"" + MainMap.CacheLocation + "TileDBv5\"";
 
                System.Diagnostics.Process.Start("explorer.exe", argument);
 
            }
 
            catch (Exception ex)
 
            {
 
                MessageBox.Show("Failed to open: " + ex.Message, "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Error);
 
            }
 
        }
 
 
        #endregion
 
 
        #region graph functions
 
        #region graph and map functions
 
 
        #region chart coloring
 
        //this method clears the background of all charts
 
        private void ResetChartColors()
 
        {
 
            chrtTopLeft.BackColor = Color.LightGray;
 
            chrtTopRight.BackColor = Color.LightGray;
 
            chrtBottomLeft.BackColor = Color.LightGray;
 
            chrtBottomRight.BackColor = Color.LightGray;
 
        }
 
 
        //highlight Top Left chart on click
 
        //set text box values based on this chart
 
        private void chrtTopLeft_Click(object sender, EventArgs e)
 
        {
 
            ResetChartColors();
 
            chrtTopLeft.BackColor = Color.Gray;
 
            tboxChartData.Text = "Altitude";
 
            tboxCurrent.Text = "";
 
            tboxAverage.Text = "";
 
            tboxMax.Text = "";
 
            tboxMin.Text = "";
 
        }
 
 
        //highlight Top Right chart on click
 
        //set text box values based on this chart
 
        private void chrtTopRight_Click(object sender, EventArgs e)
 
        {
 
            ResetChartColors();
 
            chrtTopRight.BackColor = Color.Gray;
 
            tboxChartData.Text = "Humidity";
 
            tboxCurrent.Text = "";
 
            tboxAverage.Text = "";
 
            tboxMax.Text = "";
 
            tboxMin.Text = "";
 
        }
 
 
        //highlight Bottom Left chart on click
 
        //set text box values based on this chart
 
        private void chrtBottomLeft_Click(object sender, EventArgs e)
 
        {
 
            ResetChartColors();
 
            chrtBottomLeft.BackColor = Color.Gray;
 
            tboxChartData.Text = "Pressure";
 
            tboxCurrent.Text = "";
 
            tboxAverage.Text = "";
 
            tboxMax.Text = "";
 
            tboxMin.Text = "";
 
        }
 
 
        //highlight Bottom Right chart on click
 
        //set text box values based on this chart
 
        private void chrtBottomRight_Click(object sender, EventArgs e)
 
        {
 
            ResetChartColors();
 
            chrtBottomRight.BackColor = Color.Gray;
 
            tboxChartData.Text = "Map";
 
            tboxCurrent.Text = "";
 
            tboxAverage.Text = "";
 
            tboxMax.Text = "";
 
            tboxMin.Text = "";
 
        }
 
 
        #endregion
 
 
        public void PrepareGraphs(){
 
 
            //set up for graphs MDKEdit
 
            // http://www.youtube.com/watch?v=zTod4-Fg6Ew - split containers
 
            // http://www.youtube.com/watch?v=bMXtgPk875I - chart controls
 
 
            chrtTopLeft.ChartAreas.Add("altitudeArea");
 
            chrtTopLeft.Series.Add("altitudeTrend");
 
 
            chrtTopRight.ChartAreas.Add("humidityArea");
 
            chrtTopRight.Series.Add("humidityTrend");
 
 
            chrtBottomLeft.Series.Add("pressureTrend");
 
            chrtBottomLeft.ChartAreas.Add("pressureArea");
 
 
            chrtBottomRight.ChartAreas.Add("velocityArea");
 
            chrtBottomRight.Series.Add("velocityTrend");
 
 
            // declare all series, data points to be modified dynamically at run
 
 
            //---------prep altitude area BEGIN 
 
            chrtTopLeft.Series["altitudeTrend"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
 
            chrtTopLeft.Series["altitudeTrend"].Color = Color.Green;
 
            System.Windows.Forms.DataVisualization.Charting.AxisName.X.Equals("Time");
 
            System.Windows.Forms.DataVisualization.Charting.AxisName.Y.Equals("Altitude");
 
            
 
            ///required initial value
 
            chrtTopLeft.Series["altitudeTrend"].Points.AddXY(0, 0);
 
            //---------prep altitude area END 
 
 
 
            //-----------prep humidity area BEGIN
 
            chrtTopRight.Series["humidityTrend"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
 
            chrtTopRight.Series["humidityTrend"].Color = Color.Red;
 
            System.Windows.Forms.DataVisualization.Charting.AxisName.X.Equals("Time");
 
            System.Windows.Forms.DataVisualization.Charting.AxisName.Y.Equals("Humidity");
 
 
            ///required initial value
 
            chrtTopRight.Series["humidityTrend"].Points.AddXY(0, 0);
 
            //-----------prep humidity area END
 
 
 
            //-----------prep pressure area BEGIN
 
            chrtBottomLeft.Series["pressureTrend"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
 
            chrtBottomLeft.Series["pressureTrend"].Color = Color.Blue;
 
            System.Windows.Forms.DataVisualization.Charting.AxisName.X.Equals("Time");
 
            System.Windows.Forms.DataVisualization.Charting.AxisName.Y.Equals("Pressure");
 
 
            ///required initial value
 
            chrtBottomLeft.Series["pressureTrend"].Points.AddXY(0, 0);
 
            //-----------prep pressure area END
 
 
 
            //----------prep velocity area BEGIN
 
            chrtBottomRight.Series["velocityTrend"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
 
            chrtBottomRight.Series["velocityTrend"].Color = Color.Green;
 
            System.Windows.Forms.DataVisualization.Charting.AxisName.X.Equals("Time");
 
            System.Windows.Forms.DataVisualization.Charting.AxisName.Y.Equals("Altitude");
 
 
            ///required initial value
 
            chrtBottomRight.Series["velocityTrend"].Points.AddXY(0, 0);
 
            //----------prep velocity area END
 
 
            //put chart displays in a ready state
 
            ResetChartColors();
 
        }
 
        string latitude;
 
        string longitude;
 
        //handle line of input data and put into chart
 
 
        //parses transmissions and saves data to CSV file
 
        public void ParseIncomingData(string rawDataReceived)
 
        {
 
            //check to see if data should be processed
 
            //if (!cboxCollectData.Checked)
 
            //{
 
            //    return;
 
            //}
 
            if (!cboxCollectData.Checked)
 
            {
 
                return;
 
            }
 
            /* sample stansmission
 
            KD8TDF-9>APRS,WIDE2-1:/151916z3944.87N/08348.75WO005/0.013 SV:09 A-30.5 B45.64 C99542
 
                                          ^char 31 ^char 40            ^60
 
            */
 
 
            //TODO: verify index charcter accuracy with real transmission
 
            int indexStart = rawDataReceived.IndexOf("z");
 
            int indexEnd = rawDataReceived.IndexOf("N/");
 
            latitude = rawDataReceived.Substring(indexStart + 1, indexEnd - indexStart - 1);
 
 
            indexStart = rawDataReceived.IndexOf("N/");
 
            indexEnd = rawDataReceived.IndexOf("WO");
 
            longitude = rawDataReceived.Substring(indexStart + 2, indexEnd - indexStart - 2);
 
 
            //addMarkerFromTransmit(latitude, longitude);
 
            if (latitude != "" && longitude != "")
 
            {
 
                addMarkerFromTransmit(latitude, longitude);
 
            }
 
            AddText(rawDataReceived + "\r\n");
 
 
            rawDataReceived = rawDataReceived.Substring(59); //remove APRS overhead from string
 
 
            //place each datum in its own variable
 
            string[] dataTransmission;
 
            dataTransmission = rawDataReceived.Split(' ');
 
 
            //parse out the data type - should be a single letter
 
            string typeCode;
 
            double data;
 
            string csvData = "";
 
 
            //loop through all datums in the transmission and send them to the chart builder
 
            for (int i = 1; i < dataTransmission.Length; i++)
 
            {
 
                typeCode = dataTransmission[i].Substring(0, 1);
 
                data = double.Parse(dataTransmission[i].Substring(1));
 
                //addToChart(typeCode, data);
 
                csvData += typeCode + data + ",";
 
            }
 
 
            //write the data to CSV file
 
            WriteToCSV(csvData);
 
        }
 
 
        //write the data to CSV file
 
        private void WriteToCSV(string data)
 
        {
 
            using (StreamWriter writer = new StreamWriter("debug.csv", true))
 
            {
 
                writer.WriteLine(data);
 
            }
 
        }
 
        //method to insert parsed data into the charts
 
        //TODO: add inserts for all charts. altitude is finished and is a template
 
        private void addToChart(string dataType, double data)
 
        {
 
            ///data types organized by listing in google doc
 
            //MASTER MODULE DATA VALUES
 
            if (dataType.Equals("t"))  //board temperature
 
            {
 
 
            }
 
            else if (dataType.Equals("L"))  //battery level
 
            {
 
 
            }
 
            else if (dataType.Equals("X"))  //Latitude accuracy
 
            {
 
 
            }
 
            else if (dataType.Equals("Y"))  //Longitude accuracy
 
            {
 
 
            }
 
            else if (dataType.Equals("V"))  //Velocity
 
            {
 
                chrtBottomRight.Series.FindByName("velocityTrend").Points.AddY(data);
 
            }
 
            else if (dataType.Equals("I"))  //Info/error Message
 
            {
 
 
            }
 
 
            //ATMOSPHERIC MODULE DATA VALUES
 
            else if (dataType.Equals("l"))  //battery level
 
            {
 
 
            }
 
            else if (dataType.Equals("C"))  //battery level
 
            {
 
 
            }
 
            else if (dataType.Equals("H"))  //Humidity
 
            {
 
                chrtTopRight.Series.FindByName("humidityTrend").Points.AddY(data);
 
            }
 
            else if (dataType.Equals("P"))  //Pressure
 
            {
 
                chrtBottomLeft.Series.FindByName("pressureTrend").Points.AddY(data);
 
            }
 
            else if (dataType.Equals("A"))  //Altitude
 
            {
 
                chrtTopLeft.Series.FindByName("altitudeTrend").Points.AddY(data);
 
            }
 
 
            //GEIGER MODULE DATA VALUES
 
            else if (dataType.Equals("l"))  //battery level
 
            {
 
 
            }
 
            else if (dataType.Equals("R"))  //radiation (CPM)
 
            {
 
 
            }
 
 
            // CAMERA MODULE DATA VALUES
 
            else if (dataType.Equals("l"))  //battery level
 
            {
 
 
            }
 
            else  //invalid data type
 
            {
 
 
            }
 
        }
 
 
        // add marker from an APRS transmission - MDKEdit
 
        private void addMarkerFromTransmit(string lat, string lng)
 
        {
 
 
            double latitude = double.Parse(lat), longitude = double.Parse(lng);
 
            PointLatLng APRSloc = new PointLatLng();
 
            APRSloc.Lat = latitude;
 
            APRSloc.Lng = longitude;
 
            APRSloc.Lat = conv_coords((float)latitude);
 
            APRSloc.Lng = conv_coords((float)longitude)*-1;
 
 
            GMarkerGoogle m = new GMarkerGoogle(APRSloc, GMarkerGoogleType.blue_small);
 
 
            Placemark? p = null;
 
            if (xboxPlacemarkInfo.Checked)
 
            {
 
                GeoCoderStatusCode status;
 
                var ret = GMapProviders.GoogleMap.GetPlacemark(currentMarker.Position, out status);
 
                if (status == GeoCoderStatusCode.G_GEO_SUCCESS && ret != null)
 
                {
 
                    p = ret;
 
                }
 
            }
 
 
            objects.Markers.Add(m);
 
        }
 
 
        float conv_coords(float in_coords)
 
        {
 
            //Initialize the location.
 
            float f = in_coords;
 
            // Get the first two digits by turning f into an integer, then doing an integer divide by 100;
 
            // firsttowdigits should be 77 at this point.
 
            int firsttwodigits = ((int)f) / 100;                               //This assumes that f < 10000.
 
            float nexttwodigits = f - (float)(firsttwodigits * 100);
 
            float theFinalAnswer = (float)(firsttwodigits + nexttwodigits / 60.0);
 
            return theFinalAnswer;
 
        }
 
        public decimal DmsToDD(double d, double m = 0, double s = 0)
 
        {
 
            return Convert.ToDecimal((d + (m / 60) + (s / 3600)) * (d < 0 ? -1 : 1));
 
        }
 
 
        #endregion
 
 
        #region cross theading
 
 
        //these are for function calls across threads
 
        delegate void SetTextDelegate(string value);
 
        public void AddText(string value)
 
        {
 
            if (InvokeRequired)
 
            {
 
                Invoke(new SetTextDelegate(AddText), value);
 
            }
 
            else
 
            {
 
                tboxMessageBox.AppendText(value);// += value;
 
                textBoxMarkerCount.Text = objects.Markers.Count.ToString();
 
            }
 
        }
 
 
        delegate void ChartDataDelegate(string dataType, double data);
 
        public void AddDataToChart(string dataType, double data)
 
        {
 
            if (InvokeRequired)
 
            {
 
                Invoke(new ChartDataDelegate(AddDataToChart), dataType, data);
 
            }
 
            else
 
            {
 
                addToChart(dataType, data);
 
            }
 
        }
 
 
        #endregion
 
 
        #region testing
 
        
 
        //click event on the test button
 
        //currently simulates serial inputs
 
        string testData;
 
        int testIteration = 0;
 
        double testLat = 39.751248, testLng = -83.809848, testVelocity = 5.8, testAltitude = 100, testPressure = 700, testHumidity = 38;
 
        private void btnTest_Click(object sender, EventArgs e)
 
        {
 
            testLat += GetRandomNumber(-.005, .015);
 
            testLng += GetRandomNumber(-.005, .015);
 
            testVelocity += GetRandomNumber(1, 15);
 
            testAltitude += GetRandomNumber(50, 150);
 
            testPressure -= GetRandomNumber(10, 50);
 
            testHumidity -= GetRandomNumber(1, 3);
 
 
            switch (testIteration)
 
            {
 
                case 0:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude+" H"+testHumidity+" P"+testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                case 1:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude + " H" + testHumidity + " P" + testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                case 2:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude + " H" + testHumidity + " P" + testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                case 3:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude + " H" + testHumidity + " P" + testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                case 4:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude + " H" + testHumidity + " P" + testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                case 5:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude + " H" + testHumidity + " P" + testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                case 6:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude + " H" + testHumidity + " P" + testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                case 7:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude + " H" + testHumidity + " P" + testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                case 8:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude + " H" + testHumidity + " P" + testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                case 9:
 
                    testData = "KD8TDF-9>APRS,WIDE2-1:/151916z" + testLat + "N/" + testLng + "WO005/0.013 V" + testVelocity + " A" + testAltitude + " H" + testHumidity + " P" + testPressure;
 
                    ParseIncomingData(testData);
 
                    break;
 
                default:
 
                    break;
 
            }
 
            testIteration++;
 
        }
 
 
        public double GetRandomNumber(double minimum, double maximum)
 
        {
 
            Random random = new Random();
 
            return random.NextDouble() * (maximum - minimum) + minimum;
 
        }
 
 
        #endregion
 
 
    }
 
}
 
//TODO: CSV logging, offline caching
0 comments (0 inline, 0 general)