Changeset - 105a3022c22b
[Not reviewed]
default
0 2 0
mkanning@CL-ENS241-10.cedarville.edu - 13 years ago 2013-02-21 15:29:54
mkanning@CL-ENS241-10.cedarville.edu
fixed the chart cross threading issue, renamed items on form
2 files changed with 52 insertions and 14 deletions:
0 comments (0 inline, 0 general)
Demo.WindowsForms/Forms/MainForm.Designer.cs
Show inline comments
 
@@ -1551,15 +1551,15 @@
 
            // lblBottomRightChartTitle
 
            // 
 
            this.lblBottomRightChartTitle.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
 
            this.lblBottomRightChartTitle.AutoSize = true;
 
            this.lblBottomRightChartTitle.Location = new System.Drawing.Point(0, 186);
 
            this.lblBottomRightChartTitle.Name = "lblBottomRightChartTitle";
 
            this.lblBottomRightChartTitle.Size = new System.Drawing.Size(28, 13);
 
            this.lblBottomRightChartTitle.Size = new System.Drawing.Size(44, 13);
 
            this.lblBottomRightChartTitle.TabIndex = 2;
 
            this.lblBottomRightChartTitle.Text = "Map";
 
            this.lblBottomRightChartTitle.Text = "Velocity";
 
            // 
 
            // chrtBottomRight
 
            // 
 
            this.chrtBottomRight.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
 
            | System.Windows.Forms.AnchorStyles.Left) 
 
            | System.Windows.Forms.AnchorStyles.Right)));
Demo.WindowsForms/Forms/MainForm.cs
Show inline comments
 
@@ -44,12 +44,13 @@ namespace Demo.WindowsForms
 
        GMapMarkerRect CurentRectMarker = null;
 
        string mobileGpsLog = string.Empty;
 
        bool isMouseDown = false;
 
        PointLatLng start;
 
        PointLatLng end;
 
        TimeSpan unixTime;
 
 
        public MainForm()
 
        {
 
            InitializeComponent();
 
            unixTime = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0));
 
 
            if (!DesignMode)
 
@@ -2562,12 +2563,13 @@ namespace Demo.WindowsForms
 
        //parses transmissions and saves data to CSV file
 
        public void ParseIncomingData(string rawDataReceived)
 
        {
 
            //check to see if data should be processed
 
            if (!cboxCollectData.Checked && rawDataReceived.StartsWith("KD8TDF"))
 
            {
 
                AddTextDelegate("Bad transmission: " + rawDataReceived);
 
                return;
 
            }
 
 
            /* sample stansmissions
 
             * KD8TDF-9>APRS,WIDE2-1:/191950zN/WO/ T79 S00 V H99.99 _ |
 
             * KD8TDF-9>APRS,WIDE2-1:/151916z3944.87N/08348.75WO005/0.013 SV:09 A-30.5 B45.64 C99542
 
@@ -2616,22 +2618,22 @@ namespace Demo.WindowsForms
 
                csvData += typeCode + data + ",";
 
            }
 
 
            //handle case of no GPS fix
 
            if (latitude == "" || longitude == "")
 
            {
 
                AddText("No GPS fix: ");
 
                AddTextDelegate("No GPS fix: ");
 
            }
 
            else
 
            {
 
                //marker added here so extra accuracy can be added
 
                addMarkerFromTransmit(latitude, longitude);
 
            }
 
 
            //display transmission in message box
 
            AddText(rawDataReceived + "\r\n");
 
            AddTextDelegate(rawDataReceived + "\r\n");
 
 
            //write the data to CSV file
 
            WriteToCSV(csvData);
 
        }
 
 
        //write the data to CSV file
 
@@ -2666,17 +2668,17 @@ namespace Demo.WindowsForms
 
            else if (dataType.Equals("Y"))  //Longitude accuracy
 
            {
 
 
            }
 
            else if (dataType.Equals("V"))  //Velocity
 
            {
 
                chrtBottomRight.Series.FindByName("velocityTrend").Points.AddY(data);
 
                bottomRightChartDelegate(dataType, data);
 
            }
 
            else if (dataType.Equals("I"))  //Info/error Message
 
            {
 
                AddText("Info: " + data + "\r\n");
 
                AddTextDelegate("Info: " + data + "\r\n");
 
            }
 
            else if (dataType.Equals("_"))  //extra latitude decimals
 
            {
 
                longitude += data / 1000; //TODO: check math and decimal placement
 
            }
 
            else if (dataType.Equals("|"))  //extra longitude decimals
 
@@ -2692,21 +2694,21 @@ namespace Demo.WindowsForms
 
            else if (dataType.Equals("C"))  //
 
            {
 
 
            }
 
            else if (dataType.Equals("H"))  //Humidity
 
            {
 
                chrtTopRight.Series.FindByName("humidityTrend").Points.AddY(data);
 
                topRightChartDelegate(dataType, data);
 
            }
 
            else if (dataType.Equals("P"))  //Pressure
 
            {
 
                chrtBottomLeft.Series.FindByName("pressureTrend").Points.AddY(data);
 
                bottomLeftChartDelegate(dataType, data);
 
            }
 
            else if (dataType.Equals("A"))  //Altitude
 
            {
 
                chrtTopLeft.Series.FindByName("altitudeTrend").Points.AddY(data);
 
                topLeftChartDelegate(dataType, data);
 
            }
 
 
            //GEIGER MODULE DATA VALUES
 
            else if (dataType.Equals("l"))  //battery level
 
            {
 
 
@@ -2776,35 +2778,71 @@ namespace Demo.WindowsForms
 
        #endregion
 
 
        #region cross theading
 
 
        //these are for function calls across threads
 
        delegate void SetTextDelegate(string value);
 
        public void AddText(string value)
 
        public void AddTextDelegate(string value)
 
        {
 
            if (InvokeRequired)
 
            {
 
                Invoke(new SetTextDelegate(AddText), value);
 
                Invoke(new SetTextDelegate(AddTextDelegate), 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)
 
        public void topLeftChartDelegate(string dataType, double data)
 
        {
 
            if (InvokeRequired)
 
            {
 
                Invoke(new ChartDataDelegate(topLeftChartDelegate), dataType, data);
 
            }
 
            else
 
            {
 
                chrtTopLeft.Series.FindByName("altitudeTrend").Points.AddY(data);
 
            }
 
        }
 
 
        public void topRightChartDelegate(string dataType, double data)
 
        {
 
            if (InvokeRequired)
 
            {
 
                Invoke(new ChartDataDelegate(AddDataToChart), dataType, data);
 
                Invoke(new ChartDataDelegate(topRightChartDelegate), dataType, data);
 
            }
 
            else
 
            {
 
                processTransmissionDatum(dataType, data);
 
                chrtTopRight.Series.FindByName("humidityTrend").Points.AddY(data); 
 
            }
 
        }
 
 
        public void bottomLeftChartDelegate(string dataType, double data)
 
        {
 
            if (InvokeRequired)
 
            {
 
                Invoke(new ChartDataDelegate(bottomLeftChartDelegate), dataType, data);
 
            }
 
            else
 
            {
 
                chrtBottomLeft.Series.FindByName("pressureTrend").Points.AddY(data);
 
            }
 
        }
 
 
        public void bottomRightChartDelegate(string dataType, double data)
 
        {
 
            if (InvokeRequired)
 
            {
 
                Invoke(new ChartDataDelegate(bottomRightChartDelegate), dataType, data);
 
            }
 
            else
 
            {
 
                chrtBottomRight.Series.FindByName("velocityTrend").Points.AddY(data);
 
            }
 
        }
 
 
        #endregion
 
 
        #region testing
0 comments (0 inline, 0 general)