diff --git a/Demo.WindowsForms/Forms/MainForm.Designer.cs b/Demo.WindowsForms/Forms/MainForm.Designer.cs --- a/Demo.WindowsForms/Forms/MainForm.Designer.cs +++ b/Demo.WindowsForms/Forms/MainForm.Designer.cs @@ -1554,9 +1554,9 @@ 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 // diff --git a/Demo.WindowsForms/Forms/MainForm.cs b/Demo.WindowsForms/Forms/MainForm.cs --- a/Demo.WindowsForms/Forms/MainForm.cs +++ b/Demo.WindowsForms/Forms/MainForm.cs @@ -47,6 +47,7 @@ namespace Demo.WindowsForms PointLatLng start; PointLatLng end; TimeSpan unixTime; + public MainForm() { InitializeComponent(); @@ -2565,6 +2566,7 @@ namespace Demo.WindowsForms //check to see if data should be processed if (!cboxCollectData.Checked && rawDataReceived.StartsWith("KD8TDF")) { + AddTextDelegate("Bad transmission: " + rawDataReceived); return; } @@ -2619,7 +2621,7 @@ namespace Demo.WindowsForms //handle case of no GPS fix if (latitude == "" || longitude == "") { - AddText("No GPS fix: "); + AddTextDelegate("No GPS fix: "); } else { @@ -2628,7 +2630,7 @@ namespace Demo.WindowsForms } //display transmission in message box - AddText(rawDataReceived + "\r\n"); + AddTextDelegate(rawDataReceived + "\r\n"); //write the data to CSV file WriteToCSV(csvData); @@ -2669,11 +2671,11 @@ namespace Demo.WindowsForms } 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 { @@ -2695,15 +2697,15 @@ namespace Demo.WindowsForms } 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 @@ -2779,11 +2781,11 @@ namespace Demo.WindowsForms //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 { @@ -2793,15 +2795,51 @@ namespace Demo.WindowsForms } 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); } }