# HG changeset patch # User mkanning@CL-ENS241-10.cedarville.edu # Date 2013-04-15 15:15:19 # Node ID f7749bd9aa121bc70d7f2aa3e5e14af646332cbb # Parent 59758290cb2c9ef0e6756859f495befdce607d85 added dynamic callsign 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 @@ -59,6 +59,10 @@ this.lblMapType = new System.Windows.Forms.Label(); this.comboBoxMapType = new System.Windows.Forms.ComboBox(); this.gboxCoordinates = new System.Windows.Forms.GroupBox(); + this.tboxCOMPort = new System.Windows.Forms.TextBox(); + this.label33 = new System.Windows.Forms.Label(); + this.tboxAPRSCallsign = new System.Windows.Forms.TextBox(); + this.label32 = new System.Windows.Forms.Label(); this.btnZoomCenter = new System.Windows.Forms.Button(); this.btnReload = new System.Windows.Forms.Button(); this.btnGoToCoords = new System.Windows.Forms.Button(); @@ -377,13 +381,14 @@ this.xPanderPanelMain.CustomColors.FlatCaptionGradientBegin = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(248))))); this.xPanderPanelMain.CustomColors.FlatCaptionGradientEnd = System.Drawing.Color.FromArgb(((int)(((byte)(252)))), ((int)(((byte)(252)))), ((int)(((byte)(252))))); this.xPanderPanelMain.CustomColors.InnerBorderColor = System.Drawing.SystemColors.Window; + this.xPanderPanelMain.Expand = true; this.xPanderPanelMain.ForeColor = System.Drawing.SystemColors.ControlText; this.xPanderPanelMain.Image = null; this.xPanderPanelMain.IsClosable = false; this.xPanderPanelMain.Margin = new System.Windows.Forms.Padding(2); this.xPanderPanelMain.Name = "xPanderPanelMain"; this.xPanderPanelMain.PanelStyle = BSE.Windows.Forms.PanelStyle.Office2007; - this.xPanderPanelMain.Size = new System.Drawing.Size(258, 25); + this.xPanderPanelMain.Size = new System.Drawing.Size(258, 605); this.xPanderPanelMain.TabIndex = 0; this.xPanderPanelMain.Text = "map"; this.xPanderPanelMain.ToolTipTextCloseIcon = null; @@ -404,7 +409,7 @@ this.tableLayoutPanel4.Name = "tableLayoutPanel4"; this.tableLayoutPanel4.RowCount = 1; this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tableLayoutPanel4.Size = new System.Drawing.Size(256, 0); + this.tableLayoutPanel4.Size = new System.Drawing.Size(256, 580); this.tableLayoutPanel4.TabIndex = 38; // // tableLayoutPanel5 @@ -425,7 +430,7 @@ this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel5.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 6F)); - this.tableLayoutPanel5.Size = new System.Drawing.Size(206, 1); + this.tableLayoutPanel5.Size = new System.Drawing.Size(206, 578); this.tableLayoutPanel5.TabIndex = 30; // // gboxRemove @@ -436,7 +441,7 @@ this.gboxRemove.Controls.Add(this.btnClearMarkers); this.gboxRemove.Controls.Add(this.btnClearRoutes); this.gboxRemove.Dock = System.Windows.Forms.DockStyle.Fill; - this.gboxRemove.Location = new System.Drawing.Point(3, 450); + this.gboxRemove.Location = new System.Drawing.Point(3, 497); this.gboxRemove.Name = "gboxRemove"; this.gboxRemove.Size = new System.Drawing.Size(200, 91); this.gboxRemove.TabIndex = 37; @@ -484,7 +489,7 @@ this.gboxMapItems.Controls.Add(this.btnSetStart); this.gboxMapItems.Controls.Add(this.btnAddRoute); this.gboxMapItems.Dock = System.Windows.Forms.DockStyle.Fill; - this.gboxMapItems.Location = new System.Drawing.Point(3, 322); + this.gboxMapItems.Location = new System.Drawing.Point(3, 369); this.gboxMapItems.Name = "gboxMapItems"; this.gboxMapItems.Size = new System.Drawing.Size(200, 122); this.gboxMapItems.TabIndex = 35; @@ -545,7 +550,7 @@ this.gboxGmap.Controls.Add(this.lblMapType); this.gboxGmap.Controls.Add(this.comboBoxMapType); this.gboxGmap.Dock = System.Windows.Forms.DockStyle.Fill; - this.gboxGmap.Location = new System.Drawing.Point(3, 153); + this.gboxGmap.Location = new System.Drawing.Point(3, 200); this.gboxGmap.Name = "gboxGmap"; this.gboxGmap.Size = new System.Drawing.Size(200, 163); this.gboxGmap.TabIndex = 31; @@ -656,6 +661,10 @@ // this.gboxCoordinates.AutoSize = true; this.gboxCoordinates.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.gboxCoordinates.Controls.Add(this.tboxCOMPort); + this.gboxCoordinates.Controls.Add(this.label33); + this.gboxCoordinates.Controls.Add(this.tboxAPRSCallsign); + this.gboxCoordinates.Controls.Add(this.label32); this.gboxCoordinates.Controls.Add(this.btnZoomCenter); this.gboxCoordinates.Controls.Add(this.btnReload); this.gboxCoordinates.Controls.Add(this.btnGoToCoords); @@ -667,11 +676,45 @@ this.gboxCoordinates.Dock = System.Windows.Forms.DockStyle.Fill; this.gboxCoordinates.Location = new System.Drawing.Point(3, 3); this.gboxCoordinates.Name = "gboxCoordinates"; - this.gboxCoordinates.Size = new System.Drawing.Size(200, 144); + this.gboxCoordinates.Size = new System.Drawing.Size(200, 191); this.gboxCoordinates.TabIndex = 28; this.gboxCoordinates.TabStop = false; this.gboxCoordinates.Text = "coordinates"; // + // tboxCOMPort + // + this.tboxCOMPort.Location = new System.Drawing.Point(87, 127); + this.tboxCOMPort.Name = "tboxCOMPort"; + this.tboxCOMPort.Size = new System.Drawing.Size(100, 20); + this.tboxCOMPort.TabIndex = 42; + this.tboxCOMPort.Text = "1"; + // + // label33 + // + this.label33.AutoSize = true; + this.label33.Location = new System.Drawing.Point(25, 130); + this.label33.Name = "label33"; + this.label33.Size = new System.Drawing.Size(53, 13); + this.label33.TabIndex = 41; + this.label33.Text = "COM Port"; + // + // tboxAPRSCallsign + // + this.tboxAPRSCallsign.Location = new System.Drawing.Point(87, 101); + this.tboxAPRSCallsign.Name = "tboxAPRSCallsign"; + this.tboxAPRSCallsign.Size = new System.Drawing.Size(100, 20); + this.tboxAPRSCallsign.TabIndex = 40; + this.tboxAPRSCallsign.Text = "KD8TDF-11"; + // + // label32 + // + this.label32.AutoSize = true; + this.label32.Location = new System.Drawing.Point(6, 104); + this.label32.Name = "label32"; + this.label32.Size = new System.Drawing.Size(75, 13); + this.label32.TabIndex = 39; + this.label32.Text = "APRS Callsign"; + // // btnZoomCenter // this.btnZoomCenter.Location = new System.Drawing.Point(84, 71); @@ -684,7 +727,7 @@ // // btnReload // - this.btnReload.Location = new System.Drawing.Point(6, 101); + this.btnReload.Location = new System.Drawing.Point(6, 148); this.btnReload.Name = "btnReload"; this.btnReload.Size = new System.Drawing.Size(74, 24); this.btnReload.TabIndex = 9; @@ -714,12 +757,13 @@ // cboxCollectData // this.cboxCollectData.AutoSize = true; - this.cboxCollectData.Location = new System.Drawing.Point(86, 106); + this.cboxCollectData.Location = new System.Drawing.Point(86, 153); this.cboxCollectData.Name = "cboxCollectData"; this.cboxCollectData.Size = new System.Drawing.Size(84, 17); this.cboxCollectData.TabIndex = 38; this.cboxCollectData.Text = "Collect Data"; this.cboxCollectData.UseVisualStyleBackColor = true; + this.cboxCollectData.Click += new System.EventHandler(this.cboxCollectData_Click); // // lblLat // @@ -761,7 +805,7 @@ this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel6.Size = new System.Drawing.Size(44, 1); + this.tableLayoutPanel6.Size = new System.Drawing.Size(44, 576); this.tableLayoutPanel6.TabIndex = 31; // // btnZoomIn @@ -788,7 +832,7 @@ this.trackBarZoomLevel.Minimum = 1; this.trackBarZoomLevel.Name = "trackBarZoomLevel"; this.trackBarZoomLevel.Orientation = System.Windows.Forms.Orientation.Vertical; - this.trackBarZoomLevel.Size = new System.Drawing.Size(45, 1); + this.trackBarZoomLevel.Size = new System.Drawing.Size(45, 522); this.trackBarZoomLevel.TabIndex = 29; this.trackBarZoomLevel.TickFrequency = 100; this.trackBarZoomLevel.TickStyle = System.Windows.Forms.TickStyle.TopLeft; @@ -799,7 +843,7 @@ // this.btnZoomOut.Dock = System.Windows.Forms.DockStyle.Fill; this.btnZoomOut.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnZoomOut.Location = new System.Drawing.Point(0, -26); + this.btnZoomOut.Location = new System.Drawing.Point(0, 549); this.btnZoomOut.Margin = new System.Windows.Forms.Padding(0); this.btnZoomOut.Name = "btnZoomOut"; this.btnZoomOut.Size = new System.Drawing.Size(45, 27); @@ -1008,14 +1052,13 @@ this.xPanderPanelCache.CustomColors.FlatCaptionGradientBegin = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(248))))); this.xPanderPanelCache.CustomColors.FlatCaptionGradientEnd = System.Drawing.Color.FromArgb(((int)(((byte)(252)))), ((int)(((byte)(252)))), ((int)(((byte)(252))))); this.xPanderPanelCache.CustomColors.InnerBorderColor = System.Drawing.SystemColors.Window; - this.xPanderPanelCache.Expand = true; this.xPanderPanelCache.ForeColor = System.Drawing.SystemColors.ControlText; this.xPanderPanelCache.Image = null; this.xPanderPanelCache.IsClosable = false; this.xPanderPanelCache.Margin = new System.Windows.Forms.Padding(2); this.xPanderPanelCache.Name = "xPanderPanelCache"; this.xPanderPanelCache.PanelStyle = BSE.Windows.Forms.PanelStyle.Office2007; - this.xPanderPanelCache.Size = new System.Drawing.Size(258, 605); + this.xPanderPanelCache.Size = new System.Drawing.Size(258, 25); this.xPanderPanelCache.TabIndex = 4; this.xPanderPanelCache.Text = "cache"; this.xPanderPanelCache.ToolTipTextCloseIcon = null; @@ -1064,7 +1107,7 @@ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 16F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(256, 580); + this.tableLayoutPanel1.Size = new System.Drawing.Size(256, 0); this.tableLayoutPanel1.TabIndex = 41; // // textBoxCacheSize @@ -2188,6 +2231,10 @@ private System.Windows.Forms.TextBox tboxAtmoLight; private System.Windows.Forms.Label label31; private System.Windows.Forms.Button btnClearAll; + private System.Windows.Forms.TextBox tboxAPRSCallsign; + private System.Windows.Forms.Label label32; + private System.Windows.Forms.TextBox tboxCOMPort; + private System.Windows.Forms.Label label33; } 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 @@ -1061,9 +1061,9 @@ namespace Demo.WindowsForms chrtTopRight.ChartAreas.Add("humidityArea"); chrtTopRight.Series.Add("humidityTrend"); + chrtBottomLeft.ChartAreas.Add("pressureArea"); chrtBottomLeft.Series.Add("pressureTrend"); - chrtBottomLeft.ChartAreas.Add("pressureArea"); - + chrtBottomRight.ChartAreas.Add("velocityArea"); chrtBottomRight.Series.Add("velocityTrend"); @@ -1125,7 +1125,7 @@ namespace Demo.WindowsForms AddTextDelegate("Transmission not saved: " + rawDataReceived +"\r\n"); return; } - else if (!rawDataReceived.StartsWith("KD8TDF")) + else if (!rawDataReceived.StartsWith(callsign)) //reject other callsigns { AddTextDelegate("Foreign transmission: " + rawDataReceived + "\r\n"); return; @@ -1264,6 +1264,39 @@ namespace Demo.WindowsForms m.ToolTipMode = MarkerTooltipMode.OnMouseOver; objects.Markers.Add(m); } + + int comPort = 0; + string callsign; + private void cboxCollectData_Click(object sender, EventArgs e) + { + //sets comPort and callsign, uncheck if parse does not work + if (int.TryParse(tboxCOMPort.Text, out comPort)) + { + callsign = tboxAPRSCallsign.Text; + } + else + { + cboxCollectData.Checked = false; + } + + //disable callsign and port edits while collecting transmissions + tboxAPRSCallsign.Enabled = !cboxCollectData.Checked; + tboxCOMPort.Enabled = !cboxCollectData.Checked; + } + + //sets and opens the COM port + delegate void SetSerialDelegate(int COM); + public void setSerialPort(int COM) + { + if (InvokeRequired) + { + Invoke(new SetSerialDelegate(setSerialPort), COM); + } + else + { + + } + } //places text in the message box delegate void SetTextDelegate(string value); @@ -1460,60 +1493,199 @@ namespace Demo.WindowsForms #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; + testData = "KD8TDF-11>APRS,N8NQH-1,WIDE2*:/051919z3921.07N/08357.76WO63.36/41.178 ~v41.178~_937~|229~t929~s10~h0.79~t024~l056~t111~l10~P3411~C0~H999~A69147"; 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; + testData = "KD8TDF-11>APRS,N8NQH-1,WIDE2*:/051919z3921.20N/08357.31WO72.82/44.951 ~v44.951~_836~|685"; 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; + testData = "KD8TDF-11>APRS,N8NQH-1,WIDE2*:/051921z3921.71N/08355.84WO68.07/35.951 ~v35.951~_022~|024~t929~s10~h0.79~t022~l057~t111~l10~P3147~C0~H999~A70308"; 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; + testData = "KD8TDF-11>APRS,WC8EMA,WIDE2*:/051921z3921.71N/08355.84WO68.07/35.951 ~v35.951~_022~|024~t929~s10~h0.79~t022~l057~t111~l10~P3147~C0~H999~A70308"; 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; + testData = "KD8TDF-11>APRS,WIDE2-1:/051923z3922.04N/08354.25WO86.93/42.990 ~v42.990~_349~|968"; 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; + testData = "KD8TDF-11>APRS,WIDE2-1:/051924z3922.21N/08353.23WO84.56/30.156 ~v30.156~_164~|009"; 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; + testData = "KD8TDF-11>APRS,WC8EMA,WIDE2*:/051924z3922.21N/08353.23WO84.56/30.156 ~v30.156~_164~|009"; 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; + testData = "KD8TDF-11>APRS,WC8EMA,WIDE2*:/051925z3922.29N/08352.75WO70.13/40.926 ~v40.926~_762~|813~t930~s11~h0.74~t024~l056~t111~l10~P2814~C0~H999~A71889"; 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; + testData = "KD8TDF-11>APRS,WIDE2-1:/051928z3922.77N/08349.49WO80.58/48.331 ~v48.331~_045~|896~t930~s11~h0.73~t024~l056~t113~l10~P3205~C0~H999~A70046"; 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; + testData = "KD8TDF-11>APRS,N8NQH-1,WIDE2*:/051928z3922.77N/08349.49WO80.58/48.331 ~v48.331~_045~|896~t930~s11~h0.73~t024~l056~t113~l10~P3205~C0~H999~A70046"; + ParseIncomingData(testData); + break; + case 10: + testData = "KD8TDF-11>APRS,WIDE2-1:/051933z3923.24N/08346.56WO103.57/31.550 ~v31.550~_165~|142~t930~s10~h0.78~t022~l056~t113~l10~P7153~C0~H999~A57607"; + ParseIncomingData(testData); + break; + case 11: + testData = "KD8TDF-11>APRS,WIDE2-1:/051934z3923.38N/08345.75WO87.77/44.916 ~v44.916~_934~|738~t932~s10~h0.78~t022~l056~t113~l10~P8471~C0~H999~A54733"; + ParseIncomingData(testData); + break; + case 12: + testData = "KD8TDF-11>APRS,WIDE2-1:/051935z3923.42N/08345.41WO84.64/25.176 ~v25.176~_260~|774"; + ParseIncomingData(testData); + break; + case 13: + testData = "KD8TDF-11>APRS,WIDE2-1:/051937z3923.33N/08342.85WO87.66/35.760 ~v35.760~_489~|460~t929~s10~h0.87~t020~l056~t110~l10~P13239~C0~H999~A46693"; + ParseIncomingData(testData); + break; + case 14: + testData = "KD8TDF-11>APRS,WC8EMA,WIDE2*:/051937z3923.33N/08342.85WO87.66/35.760 ~v35.760~_489~|460~t929~s10~h0.87~t020~l056~t110~l10~P13239~C0~H999~A46693"; + ParseIncomingData(testData); + break; + case 15: + testData = "KD8TDF-11>APRS,WIDE2-1:/051938z3923.30N/08342.29WO93.89/39.613 ~v39.613~_208~|441"; + ParseIncomingData(testData); + break; + case 16: + testData = "KD8TDF-11>APRS,WIDE2-1:/051939z3923.28N/08341.71WO89.80/47.399 ~v47.399~_382~|785~t929~s10~h0.81~t020~l056~t110~l10~P15171~C0~H999~A44101"; + ParseIncomingData(testData); + break; + case 17: + testData = "KD8TDF-11>APRS,WC8EMA,WIDE2*:/051939z3923.28N/08341.71WO89.80/47.399 ~v47.399~_382~|785~t929~s10~h0.81~t020~l056~t110~l10~P15171~C0~H999~A44101"; + ParseIncomingData(testData); + break; + case 18: + testData = "KD8TDF-11>APRS,WIDE2-1:/051939z3923.29N/08341.21WO89.68/42.977 ~v42.977~_049~|692"; + ParseIncomingData(testData); + break; + case 19: + testData = "KD8TDF-11>APRS,WIDE2-1:/051940z3923.17N/08340.68WO104.09/41.096 ~v41.096~_196~|818~t928~s10~h0.81~t019~l056~t18~l10~P17216~C0~H999~A41631"; + ParseIncomingData(testData); + break; + case 20: + testData = "KD8TDF-11>APRS,WIDE2-1:/051940z3923.08N/08340.12WO99.91/40.414 ~v40.414~_749~|332"; + ParseIncomingData(testData); + break; + case 21: + testData = "KD8TDF-11>APRS,WIDE2-1:/051941z3923.06N/08339.67WO105.12/26.372 ~v26.372~_625~|764~t928~s10~h0.81~t019~l056~t16~l10~P19373~C0~H999~A39276"; + ParseIncomingData(testData); + break; + case 22: + testData = "KD8TDF-11>APRS,WIDE2-1:/051942z3922.93N/08339.26WO128.58/35.021 ~v35.021~_092~|564"; + ParseIncomingData(testData); + break; + case 23: + testData = "KD8TDF-11>APRS,WIDE2-1:/051942z3922.68N/08338.87WO136.93/37.963 ~v37.963~_409~|785~t926~s09~h0.87~t017~l056~t14~l10~P21733~C0~H999~A36927"; + ParseIncomingData(testData); + break; + case 24: + testData = "KD8TDF-11>APRS,WC8EMA,WIDE2*:/051942z3922.68N/08338.87WO136.93/37.963 ~v37.963~_409~|785~t926~s09~h0.87~t017~l056~t14~l10~P21733~C0~H999~A36927"; + ParseIncomingData(testData); + break; + case 25: + testData = "KD8TDF-11>APRS,WIDE2-1:/051943z3922.03N/08338.26WO160.38/56.614 ~v56.614~_060~|181~t924~s09~h0.87~t017~l056~t12~l10~P24231~C0~H999~A34657"; + ParseIncomingData(testData); + break; + case 26: + testData = "KD8TDF-11>APRS,WIDE2-1:/051944z3921.35N/08337.97WO163.68/88.044 ~v88.044~_733~|114"; + ParseIncomingData(testData); + break; + case 27: + testData = "KD8TDF-11>APRS,WIDE2-1:/051945z3920.52N/08337.69WO165.97/86.908 ~v86.908~_646~|070~t922~s09~h0.87~t015~l056~t11~l10~P26698~C0~H999~A32594"; + ParseIncomingData(testData); + break; + case 28: + testData = "KD8TDF-11>APRS,WC8EMA,WIDE2*:/051945z3920.52N/08337.69WO165.97/86.908 ~v86.908~_646~|070~t922~s09~h0.87~t015~l056~t11~l10~P26698~C0~H999~A32594"; + ParseIncomingData(testData); + break; + case 29: + testData = "KD8TDF-11>APRS,WIDE2-1:/051945z3919.65N/08337.35WO155.12/91.951 ~v91.951~_048~|484"; + ParseIncomingData(testData); + break; + case 30: + testData = "KD8TDF-11>APRS,WIDE2-1:/051946z3918.82N/08337.00WO159.97/90.062 ~v90.062~_362~|669~t920~s09~h0.96~t015~l056~t1-1~l10~P29320~C0~H999~A30566"; + ParseIncomingData(testData); + break; + case 31: + testData = "KD8TDF-11>APRS,WIDE2-1:/051946z3918.00N/08336.65WO158.88/83.565 ~v83.565~_177~|836"; + ParseIncomingData(testData); + break; + case 32: + testData = "KD8TDF-11>APRS,WIDE2-1:/051947z3917.24N/08336.30WO160.33/75.922 ~v75.922~_318~|316~t919~s09~h0.96~t013~l056~t11~l10~P31996~C0~H999~A28641"; + ParseIncomingData(testData); + break; + case 33: + testData = "KD8TDF-11>APRS,WIDE2-1:/051947z3916.50N/08335.94WO162.38/72.423 ~v72.423~_912~|245"; + ParseIncomingData(testData); + break; + case 34: + testData = "KD8TDF-11>APRS,WC8EMA,WIDE2*:/051947z3916.50N/08335.94WO162.38/72.423 ~v72.423~_912~|245"; + ParseIncomingData(testData); + break; + case 35: + testData = "KD8TDF-11>APRS,WIDE2-1:/051948z3915.80N/08335.61WO162.44/80.541 ~v80.541~_756~|326~t917~s08~h0.97~t013~l056~t12~l10~P34716~C0~H999~A26813"; + ParseIncomingData(testData); + break; + case 36: + testData = "KD8TDF-11>APRS,WIDE2-1:/051949z3915.10N/08335.30WO161.20/82.223 ~v82.223~_935~|370"; + ParseIncomingData(testData); + break; + case 37: + testData = "KD8TDF-11>APRS,WIDE2-1:/051949z3914.43N/08334.98WO159.63/62.921 ~v62.921~_493~|370~t915~s09~h0.89~t011~l056~t14~l10~P37541~C0~H999~A25036"; + ParseIncomingData(testData); + break; + case 38: + testData = "KD8TDF-11>APRS,WIDE2-1:/051950z3913.80N/08334.71WO164.45/64.565 ~v64.565~_434~|297"; + ParseIncomingData(testData); + break; + case 39: + testData = "KD8TDF-11>APRS,WIDE2-1:/051950z3913.22N/08334.46WO163.22/57.953 ~v57.953~_077~|680~t915~s09~h0.89~t011~l056~t16~l10~P40480~C0~H999~A23294"; + ParseIncomingData(testData); + break; + case 40: + testData = "KD8TDF-11>APRS,WIDE2-1:/051951z3912.62N/08334.20WO162.48/62.928 ~v62.928~_018~|886"; + ParseIncomingData(testData); + break; + case 41: + testData = "KD8TDF-11>APRS,WIDE2-1:/051952z3912.09N/08333.98WO158.93/62.192 ~v62.192~_550~|711~t913~s09~h0.90~t010~l056~t14~l10~P43509~C0~H999~A21607"; + ParseIncomingData(testData); + break; + case 42: + testData = "KD8TDF-11>APRS,WIDE2-1:/051952z3911.55N/08333.74WO160.42/53.084 ~v53.084~_827~|212"; + ParseIncomingData(testData); + break; + case 43: + testData = "KD8TDF-11>APRS,WIDE2-1:/051953z3911.02N/08333.46WO157.50/60.661 ~v60.661~_647~|296~t913~s09~h0.90~t010~l056~t12~l10~P46544~C0~H999~A20007"; + ParseIncomingData(testData); + break; + case 44: + testData = "KD8TDF-11>APRS,WIDE2-1:/051953z3910.49N/08333.21WO150.50/52.105 ~v52.105~_520~|688"; + ParseIncomingData(testData); + break; + case 45: + testData = "KD8TDF-11>APRS,WIDE2-1:/051954z3910.04N/08332.97WO146.63/42.412 ~v42.412~_652~|898~t911~s09~h0.99~t010~l056~t12~l10~P49829~C0~H999~A18370"; + ParseIncomingData(testData); + break; + case 46: + testData = "KD8TDF-11>APRS,WIDE2-1:/051955z3909.67N/08332.70WO147.20/47.361 ~v47.361~_446~|617"; ParseIncomingData(testData); break; default: @@ -1533,7 +1705,5 @@ namespace Demo.WindowsForms } } -//TODO: CSV logging, offline caching -//weekly changes: chart text display, map functionality[routes, layout, markers], find/remove unused code, -// figured out caching but still needs to be tested + \ No newline at end of file diff --git a/Demo.WindowsForms/Source/Program.cs b/Demo.WindowsForms/Source/Program.cs --- a/Demo.WindowsForms/Source/Program.cs +++ b/Demo.WindowsForms/Source/Program.cs @@ -13,416 +13,416 @@ using System.Threading; namespace Demo.WindowsForms { - class Program - { - /// - /// The main entry point for the application. - /// - /// - // Instantiate the communications port - private SerialPort port = new SerialPort("COM5", 9600, Parity.None, 8, StopBits.One); - static MainForm windowGUI; + class Program + { + /// + /// The main entry point for the application. + /// + /// + // Instantiate the communications port + public SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One); + static MainForm windowGUI; - [STAThread] - static void Main() - { - Application.SetCompatibleTextRenderingDefault(false); - var program = new Program(); - windowGUI = new MainForm(); - program.SerialInitialize(); - Application.EnableVisualStyles(); + [STAThread] + static void Main() + { + Application.SetCompatibleTextRenderingDefault(false); + var program = new Program(); + windowGUI = new MainForm(); + program.SerialInitialize(); + Application.EnableVisualStyles(); - Application.Run(windowGUI); - } + Application.Run(windowGUI); + } - //inits the serial port and event handler - private void SerialInitialize() - { - // http://msmvps.com/blogs/coad/archive/2005/03/23/SerialPort-_2800_RS_2D00_232-Serial-COM-Port_2900_-in-C_2300_-.NET.aspx - // Attach a method to be called when there is data waiting in the port's buffer - port.DataReceived += new SerialDataReceivedEventHandler(ReceiveData); + //inits the serial port and event handler + public void SerialInitialize() + { + // http://msmvps.com/blogs/coad/archive/2005/03/23/SerialPort-_2800_RS_2D00_232-Serial-COM-Port_2900_-in-C_2300_-.NET.aspx + // Attach a method to be called when there is data waiting in the port's buffer + port.DataReceived += new SerialDataReceivedEventHandler(ReceiveData); - // Open the port for communications - port.Open(); + // Open the port for communications + port.Open(); - } + } - //process received data - private void ReceiveData(object sender, SerialDataReceivedEventArgs e) - { - // Show all the incoming data in the port's buffer - string testChk = port.ReadLine(); - windowGUI.ParseIncomingData(testChk); - } - } + //process received data + public void ReceiveData(object sender, SerialDataReceivedEventArgs e) + { + // Show all the incoming data in the port's buffer + string testChk = port.ReadLine(); + windowGUI.ParseIncomingData(testChk); + } + } - public class Dummy - { + //public class Dummy + //{ - } + //} - removed 4-15 - class IpInfo - { - public string Ip; - //public int Port; - //public TcpState State; - //public string ProcessName; + class IpInfo + { + public string Ip; + //public int Port; + //public TcpState State; + //public string ProcessName; - public string CountryName; - public string RegionName; - public string City; - public double Latitude; - public double Longitude; - public DateTime CacheTime; + public string CountryName; + public string RegionName; + public string City; + public double Latitude; + public double Longitude; + public DateTime CacheTime; - //public DateTime StatusTime; - //public bool TracePoint; - } + //public DateTime StatusTime; + //public bool TracePoint; + } - struct IpStatus - { - private string countryName; - public string CountryName - { - get - { - return countryName; - } - set - { - countryName = value; - } - } + struct IpStatus + { + private string countryName; + public string CountryName + { + get + { + return countryName; + } + set + { + countryName = value; + } + } - private int connectionsCount; - public int ConnectionsCount - { - get - { - return connectionsCount; - } - set - { - connectionsCount = value; - } - } - } + private int connectionsCount; + public int ConnectionsCount + { + get + { + return connectionsCount; + } + set + { + connectionsCount = value; + } + } + } - class DescendingComparer : IComparer - { - public bool SortOnlyCountryName = false; + class DescendingComparer : IComparer + { + public bool SortOnlyCountryName = false; - public int Compare(IpStatus x, IpStatus y) - { - int r = 0; + public int Compare(IpStatus x, IpStatus y) + { + int r = 0; - if(!SortOnlyCountryName) - { - r = y.ConnectionsCount.CompareTo(x.ConnectionsCount); - } + if (!SortOnlyCountryName) + { + r = y.ConnectionsCount.CompareTo(x.ConnectionsCount); + } - if(r == 0) - { - return x.CountryName.CompareTo(y.CountryName); - } - return r; - } - } + if (r == 0) + { + return x.CountryName.CompareTo(y.CountryName); + } + return r; + } + } - class TraceRoute - { - readonly static string Data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - readonly static byte[] DataBuffer; - readonly static int timeout = 8888; + class TraceRoute + { + readonly static string Data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + readonly static byte[] DataBuffer; + readonly static int timeout = 8888; - static TraceRoute() - { - DataBuffer = Encoding.ASCII.GetBytes(Data); - } + static TraceRoute() + { + DataBuffer = Encoding.ASCII.GetBytes(Data); + } - public static List GetTraceRoute(string hostNameOrAddress) - { - var ret = GetTraceRoute(hostNameOrAddress, 1); + public static List GetTraceRoute(string hostNameOrAddress) + { + var ret = GetTraceRoute(hostNameOrAddress, 1); - return ret; - } + return ret; + } - private static List GetTraceRoute(string hostNameOrAddress, int ttl) - { - List result = new List(); + private static List GetTraceRoute(string hostNameOrAddress, int ttl) + { + List result = new List(); - using(Ping pinger = new Ping()) - { - PingOptions pingerOptions = new PingOptions(ttl, true); + using (Ping pinger = new Ping()) + { + PingOptions pingerOptions = new PingOptions(ttl, true); - PingReply reply = pinger.Send(hostNameOrAddress, timeout, DataBuffer, pingerOptions); + PingReply reply = pinger.Send(hostNameOrAddress, timeout, DataBuffer, pingerOptions); - //Debug.WriteLine("GetTraceRoute[" + hostNameOrAddress + "]: " + reply.RoundtripTime + "ms " + reply.Address + " -> " + reply.Status); + //Debug.WriteLine("GetTraceRoute[" + hostNameOrAddress + "]: " + reply.RoundtripTime + "ms " + reply.Address + " -> " + reply.Status); - if(reply.Status == IPStatus.Success) - { - result.Add(reply); - } - else if(reply.Status == IPStatus.TtlExpired) - { - // add the currently returned address - result.Add(reply); + if (reply.Status == IPStatus.Success) + { + result.Add(reply); + } + else if (reply.Status == IPStatus.TtlExpired) + { + // add the currently returned address + result.Add(reply); - // recurse to get the next address... - result.AddRange(GetTraceRoute(hostNameOrAddress, ttl + 1)); + // recurse to get the next address... + result.AddRange(GetTraceRoute(hostNameOrAddress, ttl + 1)); + } + else + { + Debug.WriteLine("GetTraceRoute: " + hostNameOrAddress + " - " + reply.Status); + } } - else - { - Debug.WriteLine("GetTraceRoute: " + hostNameOrAddress + " - " + reply.Status); - } - } - return result; - } - } + return result; + } + } #if !MONO - #region Managed IP Helper API + #region Managed IP Helper API - public struct TcpTable : IEnumerable - { - #region Private Fields + public struct TcpTable : IEnumerable + { + #region Private Fields - private IEnumerable tcpRows; + private IEnumerable tcpRows; - #endregion + #endregion - #region Constructors + #region Constructors - public TcpTable(IEnumerable tcpRows) - { - this.tcpRows = tcpRows; - } + public TcpTable(IEnumerable tcpRows) + { + this.tcpRows = tcpRows; + } - #endregion + #endregion - #region Public Properties + #region Public Properties - public IEnumerable Rows - { - get - { - return this.tcpRows; - } - } + public IEnumerable Rows + { + get + { + return this.tcpRows; + } + } - #endregion + #endregion - #region IEnumerable Members + #region IEnumerable Members - public IEnumerator GetEnumerator() - { - return this.tcpRows.GetEnumerator(); - } + public IEnumerator GetEnumerator() + { + return this.tcpRows.GetEnumerator(); + } - #endregion + #endregion - #region IEnumerable Members + #region IEnumerable Members - IEnumerator IEnumerable.GetEnumerator() - { - return this.tcpRows.GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() + { + return this.tcpRows.GetEnumerator(); + } - #endregion - } + #endregion + } - public struct TcpRow - { - #region Private Fields + public struct TcpRow + { + #region Private Fields - private IPEndPoint localEndPoint; - private IPEndPoint remoteEndPoint; - private TcpState state; - private int processId; + private IPEndPoint localEndPoint; + private IPEndPoint remoteEndPoint; + private TcpState state; + private int processId; - #endregion + #endregion - #region Constructors + #region Constructors - public TcpRow(IpHelper.TcpRow tcpRow) - { - this.state = tcpRow.state; - this.processId = tcpRow.owningPid; + public TcpRow(IpHelper.TcpRow tcpRow) + { + this.state = tcpRow.state; + this.processId = tcpRow.owningPid; - int localPort = (tcpRow.localPort1 << 8) + (tcpRow.localPort2) + (tcpRow.localPort3 << 24) + (tcpRow.localPort4 << 16); - long localAddress = tcpRow.localAddr; - this.localEndPoint = new IPEndPoint(localAddress, localPort); + int localPort = (tcpRow.localPort1 << 8) + (tcpRow.localPort2) + (tcpRow.localPort3 << 24) + (tcpRow.localPort4 << 16); + long localAddress = tcpRow.localAddr; + this.localEndPoint = new IPEndPoint(localAddress, localPort); - int remotePort = (tcpRow.remotePort1 << 8) + (tcpRow.remotePort2) + (tcpRow.remotePort3 << 24) + (tcpRow.remotePort4 << 16); - long remoteAddress = tcpRow.remoteAddr; - this.remoteEndPoint = new IPEndPoint(remoteAddress, remotePort); - } + int remotePort = (tcpRow.remotePort1 << 8) + (tcpRow.remotePort2) + (tcpRow.remotePort3 << 24) + (tcpRow.remotePort4 << 16); + long remoteAddress = tcpRow.remoteAddr; + this.remoteEndPoint = new IPEndPoint(remoteAddress, remotePort); + } - #endregion + #endregion - #region Public Properties + #region Public Properties - public IPEndPoint LocalEndPoint - { - get - { - return this.localEndPoint; - } - } + public IPEndPoint LocalEndPoint + { + get + { + return this.localEndPoint; + } + } - public IPEndPoint RemoteEndPoint - { - get - { - return this.remoteEndPoint; - } - } + public IPEndPoint RemoteEndPoint + { + get + { + return this.remoteEndPoint; + } + } - public TcpState State - { - get - { - return this.state; - } - } + public TcpState State + { + get + { + return this.state; + } + } - public int ProcessId - { - get - { - return this.processId; - } - } + public int ProcessId + { + get + { + return this.processId; + } + } - #endregion - } + #endregion + } - public static class ManagedIpHelper - { - public static readonly List TcpRows = new List(); + public static class ManagedIpHelper + { + public static readonly List TcpRows = new List(); - #region Public Methods - - public static void UpdateExtendedTcpTable(bool sorted) - { - TcpRows.Clear(); - - IntPtr tcpTable = IntPtr.Zero; - int tcpTableLength = 0; + #region Public Methods - if(IpHelper.GetExtendedTcpTable(tcpTable, ref tcpTableLength, sorted, IpHelper.AfInet, IpHelper.TcpTableType.OwnerPidConnections, 0) != 0) - { - try - { - tcpTable = Marshal.AllocHGlobal(tcpTableLength); - if(IpHelper.GetExtendedTcpTable(tcpTable, ref tcpTableLength, true, IpHelper.AfInet, IpHelper.TcpTableType.OwnerPidConnections, 0) == 0) - { - IpHelper.TcpTable table = (IpHelper.TcpTable)Marshal.PtrToStructure(tcpTable, typeof(IpHelper.TcpTable)); + public static void UpdateExtendedTcpTable(bool sorted) + { + TcpRows.Clear(); - IntPtr rowPtr = (IntPtr)((long)tcpTable + Marshal.SizeOf(table.Length)); - for(int i = 0; i < table.Length; ++i) - { - TcpRows.Add(new TcpRow((IpHelper.TcpRow)Marshal.PtrToStructure(rowPtr, typeof(IpHelper.TcpRow)))); - rowPtr = (IntPtr)((long)rowPtr + Marshal.SizeOf(typeof(IpHelper.TcpRow))); - } - } - } - finally + IntPtr tcpTable = IntPtr.Zero; + int tcpTableLength = 0; + + if (IpHelper.GetExtendedTcpTable(tcpTable, ref tcpTableLength, sorted, IpHelper.AfInet, IpHelper.TcpTableType.OwnerPidConnections, 0) != 0) { - if(tcpTable != IntPtr.Zero) - { - Marshal.FreeHGlobal(tcpTable); - } - } - } - } - - #endregion - } - - #endregion + try + { + tcpTable = Marshal.AllocHGlobal(tcpTableLength); + if (IpHelper.GetExtendedTcpTable(tcpTable, ref tcpTableLength, true, IpHelper.AfInet, IpHelper.TcpTableType.OwnerPidConnections, 0) == 0) + { + IpHelper.TcpTable table = (IpHelper.TcpTable)Marshal.PtrToStructure(tcpTable, typeof(IpHelper.TcpTable)); - #region P/Invoke IP Helper API + IntPtr rowPtr = (IntPtr)((long)tcpTable + Marshal.SizeOf(table.Length)); + for (int i = 0; i < table.Length; ++i) + { + TcpRows.Add(new TcpRow((IpHelper.TcpRow)Marshal.PtrToStructure(rowPtr, typeof(IpHelper.TcpRow)))); + rowPtr = (IntPtr)((long)rowPtr + Marshal.SizeOf(typeof(IpHelper.TcpRow))); + } + } + } + finally + { + if (tcpTable != IntPtr.Zero) + { + Marshal.FreeHGlobal(tcpTable); + } + } + } + } - /// - /// - /// - public static class IpHelper - { - #region Public Fields + #endregion + } + + #endregion + + #region P/Invoke IP Helper API - public const string DllName = "iphlpapi.dll"; - public const int AfInet = 2; + /// + /// + /// + public static class IpHelper + { + #region Public Fields - #endregion + public const string DllName = "iphlpapi.dll"; + public const int AfInet = 2; - #region Public Methods + #endregion + + #region Public Methods - /// - /// - /// - [DllImport(IpHelper.DllName, SetLastError = true)] - public static extern uint GetExtendedTcpTable(IntPtr tcpTable, ref int tcpTableLength, bool sort, int ipVersion, TcpTableType tcpTableType, int reserved); + /// + /// + /// + [DllImport(IpHelper.DllName, SetLastError = true)] + public static extern uint GetExtendedTcpTable(IntPtr tcpTable, ref int tcpTableLength, bool sort, int ipVersion, TcpTableType tcpTableType, int reserved); - #endregion + #endregion - #region Public Enums + #region Public Enums - /// - /// - /// - public enum TcpTableType - { - BasicListener, - BasicConnections, - BasicAll, - OwnerPidListener, - OwnerPidConnections, - OwnerPidAll, - OwnerModuleListener, - OwnerModuleConnections, - OwnerModuleAll, - } + /// + /// + /// + public enum TcpTableType + { + BasicListener, + BasicConnections, + BasicAll, + OwnerPidListener, + OwnerPidConnections, + OwnerPidAll, + OwnerModuleListener, + OwnerModuleConnections, + OwnerModuleAll, + } - #endregion + #endregion - #region Public Structs + #region Public Structs - /// - /// - /// - [StructLayout(LayoutKind.Sequential)] - public struct TcpTable - { - public uint Length; - public TcpRow row; - } + /// + /// + /// + [StructLayout(LayoutKind.Sequential)] + public struct TcpTable + { + public uint Length; + public TcpRow row; + } - /// - /// - /// - [StructLayout(LayoutKind.Sequential)] - public struct TcpRow - { - public TcpState state; - public uint localAddr; - public byte localPort1; - public byte localPort2; - public byte localPort3; - public byte localPort4; - public uint remoteAddr; - public byte remotePort1; - public byte remotePort2; - public byte remotePort3; - public byte remotePort4; - public int owningPid; - } + /// + /// + /// + [StructLayout(LayoutKind.Sequential)] + public struct TcpRow + { + public TcpState state; + public uint localAddr; + public byte localPort1; + public byte localPort2; + public byte localPort3; + public byte localPort4; + public uint remoteAddr; + public byte remotePort1; + public byte remotePort2; + public byte remotePort3; + public byte remotePort4; + public int owningPid; + } - #endregion - } + #endregion + } - #endregion + #endregion #endif }