Explorar o código

GPS 평균값 출력하도록 수정 완료

아직 테스트 해보지 못함
YJ %!s(int64=5) %!d(string=hai) anos
pai
achega
d2ea9f1d5a

+ 21 - 7
Main.Designer.cs

@@ -88,6 +88,7 @@
88
             this.dataGridView_Gps = new System.Windows.Forms.DataGridView();
88
             this.dataGridView_Gps = new System.Windows.Forms.DataGridView();
89
             this.Gps_SerialNumber = new System.Windows.Forms.DataGridViewTextBoxColumn();
89
             this.Gps_SerialNumber = new System.Windows.Forms.DataGridViewTextBoxColumn();
90
             this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
90
             this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
91
+            this.checkBox_GPGSV = new System.Windows.Forms.CheckBox();
91
             this.panel_Main.SuspendLayout();
92
             this.panel_Main.SuspendLayout();
92
             this.panel4.SuspendLayout();
93
             this.panel4.SuspendLayout();
93
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
94
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
@@ -127,9 +128,9 @@
127
             this.panel_Main.Controls.Add(this.panel4);
128
             this.panel_Main.Controls.Add(this.panel4);
128
             this.panel_Main.Controls.Add(this.label6);
129
             this.panel_Main.Controls.Add(this.label6);
129
             this.panel_Main.Controls.Add(this.panel1);
130
             this.panel_Main.Controls.Add(this.panel1);
131
+            this.panel_Main.Controls.Add(this.panel_GpsTest);
130
             this.panel_Main.Controls.Add(this.panel_SensorTest);
132
             this.panel_Main.Controls.Add(this.panel_SensorTest);
131
             this.panel_Main.Controls.Add(this.panel_Catm1Test);
133
             this.panel_Main.Controls.Add(this.panel_Catm1Test);
132
-            this.panel_Main.Controls.Add(this.panel_GpsTest);
133
             this.panel_Main.Location = new System.Drawing.Point(0, 0);
134
             this.panel_Main.Location = new System.Drawing.Point(0, 0);
134
             this.panel_Main.Name = "panel_Main";
135
             this.panel_Main.Name = "panel_Main";
135
             this.panel_Main.Size = new System.Drawing.Size(930, 710);
136
             this.panel_Main.Size = new System.Drawing.Size(930, 710);
@@ -220,7 +221,7 @@
220
             this.groupBox9.Controls.Add(this.cmBaudRate);
221
             this.groupBox9.Controls.Add(this.cmBaudRate);
221
             this.groupBox9.Location = new System.Drawing.Point(3, 241);
222
             this.groupBox9.Location = new System.Drawing.Point(3, 241);
222
             this.groupBox9.Name = "groupBox9";
223
             this.groupBox9.Name = "groupBox9";
223
-            this.groupBox9.Size = new System.Drawing.Size(153, 281);
224
+            this.groupBox9.Size = new System.Drawing.Size(153, 242);
224
             this.groupBox9.TabIndex = 85;
225
             this.groupBox9.TabIndex = 85;
225
             this.groupBox9.TabStop = false;
226
             this.groupBox9.TabStop = false;
226
             this.groupBox9.Text = "Connection";
227
             this.groupBox9.Text = "Connection";
@@ -231,7 +232,7 @@
231
             this.panel_Port.Controls.Add(this.label_Port);
232
             this.panel_Port.Controls.Add(this.label_Port);
232
             this.panel_Port.Location = new System.Drawing.Point(9, 188);
233
             this.panel_Port.Location = new System.Drawing.Point(9, 188);
233
             this.panel_Port.Name = "panel_Port";
234
             this.panel_Port.Name = "panel_Port";
234
-            this.panel_Port.Size = new System.Drawing.Size(107, 41);
235
+            this.panel_Port.Size = new System.Drawing.Size(138, 41);
235
             this.panel_Port.TabIndex = 93;
236
             this.panel_Port.TabIndex = 93;
236
             this.panel_Port.Click += new System.EventHandler(this.label_Port_Click);
237
             this.panel_Port.Click += new System.EventHandler(this.label_Port_Click);
237
             this.panel_Port.MouseClick += new System.Windows.Forms.MouseEventHandler(this.label_Port_MouseClick);
238
             this.panel_Port.MouseClick += new System.Windows.Forms.MouseEventHandler(this.label_Port_MouseClick);
@@ -243,7 +244,7 @@
243
             this.label_Port.AutoSize = true;
244
             this.label_Port.AutoSize = true;
244
             this.label_Port.Font = new System.Drawing.Font("맑은 고딕", 10F, System.Drawing.FontStyle.Bold);
245
             this.label_Port.Font = new System.Drawing.Font("맑은 고딕", 10F, System.Drawing.FontStyle.Bold);
245
             this.label_Port.ForeColor = System.Drawing.Color.Snow;
246
             this.label_Port.ForeColor = System.Drawing.Color.Snow;
246
-            this.label_Port.Location = new System.Drawing.Point(14, 10);
247
+            this.label_Port.Location = new System.Drawing.Point(31, 10);
247
             this.label_Port.Name = "label_Port";
248
             this.label_Port.Name = "label_Port";
248
             this.label_Port.Size = new System.Drawing.Size(80, 19);
249
             this.label_Port.Size = new System.Drawing.Size(80, 19);
249
             this.label_Port.TabIndex = 31;
250
             this.label_Port.TabIndex = 31;
@@ -260,7 +261,7 @@
260
             this.comboBox_Port.FormattingEnabled = true;
261
             this.comboBox_Port.FormattingEnabled = true;
261
             this.comboBox_Port.Location = new System.Drawing.Point(7, 54);
262
             this.comboBox_Port.Location = new System.Drawing.Point(7, 54);
262
             this.comboBox_Port.Name = "comboBox_Port";
263
             this.comboBox_Port.Name = "comboBox_Port";
263
-            this.comboBox_Port.Size = new System.Drawing.Size(113, 27);
264
+            this.comboBox_Port.Size = new System.Drawing.Size(140, 27);
264
             this.comboBox_Port.TabIndex = 92;
265
             this.comboBox_Port.TabIndex = 92;
265
             // 
266
             // 
266
             // comboBox_bps
267
             // comboBox_bps
@@ -274,7 +275,7 @@
274
             "115200"});
275
             "115200"});
275
             this.comboBox_bps.Location = new System.Drawing.Point(7, 138);
276
             this.comboBox_bps.Location = new System.Drawing.Point(7, 138);
276
             this.comboBox_bps.Name = "comboBox_bps";
277
             this.comboBox_bps.Name = "comboBox_bps";
277
-            this.comboBox_bps.Size = new System.Drawing.Size(113, 27);
278
+            this.comboBox_bps.Size = new System.Drawing.Size(140, 27);
278
             this.comboBox_bps.TabIndex = 91;
279
             this.comboBox_bps.TabIndex = 91;
279
             this.comboBox_bps.Text = "115200";
280
             this.comboBox_bps.Text = "115200";
280
             // 
281
             // 
@@ -683,6 +684,7 @@
683
             // panel_GpsTest
684
             // panel_GpsTest
684
             // 
685
             // 
685
             this.panel_GpsTest.Controls.Add(this.richTextBox_Gps);
686
             this.panel_GpsTest.Controls.Add(this.richTextBox_Gps);
687
+            this.panel_GpsTest.Controls.Add(this.checkBox_GPGSV);
686
             this.panel_GpsTest.Controls.Add(this.dataGridView_Gps);
688
             this.panel_GpsTest.Controls.Add(this.dataGridView_Gps);
687
             this.panel_GpsTest.Location = new System.Drawing.Point(149, 44);
689
             this.panel_GpsTest.Location = new System.Drawing.Point(149, 44);
688
             this.panel_GpsTest.Name = "panel_GpsTest";
690
             this.panel_GpsTest.Name = "panel_GpsTest";
@@ -694,7 +696,7 @@
694
             this.richTextBox_Gps.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
696
             this.richTextBox_Gps.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
695
             this.richTextBox_Gps.Font = new System.Drawing.Font("나눔고딕", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
697
             this.richTextBox_Gps.Font = new System.Drawing.Font("나눔고딕", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
696
             this.richTextBox_Gps.ForeColor = System.Drawing.Color.Yellow;
698
             this.richTextBox_Gps.ForeColor = System.Drawing.Color.Yellow;
697
-            this.richTextBox_Gps.Location = new System.Drawing.Point(276, 3);
699
+            this.richTextBox_Gps.Location = new System.Drawing.Point(280, 3);
698
             this.richTextBox_Gps.Name = "richTextBox_Gps";
700
             this.richTextBox_Gps.Name = "richTextBox_Gps";
699
             this.richTextBox_Gps.Size = new System.Drawing.Size(489, 564);
701
             this.richTextBox_Gps.Size = new System.Drawing.Size(489, 564);
700
             this.richTextBox_Gps.TabIndex = 26;
702
             this.richTextBox_Gps.TabIndex = 26;
@@ -725,6 +727,16 @@
725
             this.dataGridViewTextBoxColumn8.HeaderText = "GPS SNR";
727
             this.dataGridViewTextBoxColumn8.HeaderText = "GPS SNR";
726
             this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
728
             this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
727
             // 
729
             // 
730
+            // checkBox_GPGSV
731
+            // 
732
+            this.checkBox_GPGSV.AutoSize = true;
733
+            this.checkBox_GPGSV.Location = new System.Drawing.Point(26, 573);
734
+            this.checkBox_GPGSV.Name = "checkBox_GPGSV";
735
+            this.checkBox_GPGSV.Size = new System.Drawing.Size(106, 16);
736
+            this.checkBox_GPGSV.TabIndex = 88;
737
+            this.checkBox_GPGSV.Text = "GPGSV  Mode";
738
+            this.checkBox_GPGSV.UseVisualStyleBackColor = true;
739
+            // 
728
             // Main
740
             // Main
729
             // 
741
             // 
730
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
742
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
@@ -767,6 +779,7 @@
767
             this.panel_Catm1Test.ResumeLayout(false);
779
             this.panel_Catm1Test.ResumeLayout(false);
768
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Catm1)).EndInit();
780
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Catm1)).EndInit();
769
             this.panel_GpsTest.ResumeLayout(false);
781
             this.panel_GpsTest.ResumeLayout(false);
782
+            this.panel_GpsTest.PerformLayout();
770
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Gps)).EndInit();
783
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Gps)).EndInit();
771
             this.ResumeLayout(false);
784
             this.ResumeLayout(false);
772
 
785
 
@@ -831,6 +844,7 @@
831
         private System.Windows.Forms.DataGridViewTextBoxColumn Modem_Ver;
844
         private System.Windows.Forms.DataGridViewTextBoxColumn Modem_Ver;
832
         private System.Windows.Forms.DataGridViewTextBoxColumn RSRP;
845
         private System.Windows.Forms.DataGridViewTextBoxColumn RSRP;
833
         private System.Windows.Forms.Button button_Clear;
846
         private System.Windows.Forms.Button button_Clear;
847
+        private System.Windows.Forms.CheckBox checkBox_GPGSV;
834
     }
848
     }
835
 }
849
 }
836
 
850
 

+ 83 - 18
Main.cs

@@ -285,41 +285,106 @@ namespace APL_TestCheck
285
                     {
285
                     {
286
                         tempLines.RemoveFirst();
286
                         tempLines.RemoveFirst();
287
                     }
287
                     }
288
-
289
                     tbReceived.Lines = tempLines.ToArray();
288
                     tbReceived.Lines = tempLines.ToArray();
290
-
291
                 }
289
                 }
292
                 try
290
                 try
293
                 {
291
                 {
294
                     SendMessage(this.Handle, WM_SETREDRAW, true, 0);
292
                     SendMessage(this.Handle, WM_SETREDRAW, true, 0);
295
                 }
293
                 }
296
                 catch { return; }
294
                 catch { return; }
297
-                //tbReceived.AppendText(text);
298
-                tbReceived.AppendText(GPS_TestFunc(text));
299
-                
295
+                if (checkBox_GPGSV.Checked == true && panel_GpsTest.Visible == true)
296
+                {
297
+                    tbReceived.AppendText(GPS_TestFunc(text));
298
+                }
299
+                else
300
+                {
301
+                    tbReceived.AppendText(text);
302
+                }
300
                 tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
303
                 tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
301
                 tbReceived.ScrollToCaret();
304
                 tbReceived.ScrollToCaret();
302
             }
305
             }
303
             catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
306
             catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
304
         }
307
         }
308
+        int GPS_TestSnRValue = 0;
309
+        int Gps_CurrentCount = 0;
310
+        int TestVal = 0;
305
         private string GPS_TestFunc(string data)
311
         private string GPS_TestFunc(string data)
306
         {
312
         {
313
+            int Gps_Count, Sentence,SnrIndex = 3;
314
+          //  string tmpstr = "$GPGSV,2,1,08,10,69,246,47,12,50,082,43,15,12,108,29,20,49,190,45*77\r\n";
315
+           // string tmpstr1 = "$GPGSV,2,2,08,24,36,052,37,25,48,159,42,31,17,245,,32,46,312,45*74\r\n";
307
             string str = data;
316
             string str = data;
308
             string[] sp = str.Split(',');
317
             string[] sp = str.Split(',');
309
-            int location1, location2;
318
+            int location1, location2,LastLocation ;
310
             try
319
             try
311
             {
320
             {
321
+                /*
322
+                if(TestVal == 0)
323
+                {
324
+                    str = tmpstr;
325
+                    TestVal++;
326
+                }
327
+                else
328
+                {
329
+                    str = tmpstr1;
330
+                    TestVal = 0;
331
+                }
332
+                */
312
                 location1 = str.IndexOf("$GPGSV");
333
                 location1 = str.IndexOf("$GPGSV");
313
-                str = str.Substring(location1);
314
-                location2 = str.IndexOf("\r\n");
315
-                str = str.Substring(0,location2 + 2);
316
-                return str;
317
-            }
318
-            catch
319
-            {
320
-
334
+                if (location1 != -1)
335
+                {
336
+                    str = str.Substring(location1);
337
+                    location2 = str.IndexOf("\r\n");
338
+                    str = str.Substring(0, location2 + 2);
339
+                    sp = str.Split(',');
340
+                    if (sp[3].Contains("*"))
341
+                    {
342
+                        sp[3] = sp[3].Substring(0, 2);
343
+                        dataGridView_Gps.Rows[0].Cells[1].Value = sp[3];
344
+                        return str;
345
+                    }
346
+                    else
347
+                    {
348
+                        Sentence = Convert.ToInt32(sp[2]);
349
+                        if(Sentence == 1)
350
+                        {
351
+                            GPS_TestSnRValue = 0;
352
+                            Gps_CurrentCount = 0;
353
+                        }
354
+                        Gps_Count = Convert.ToInt32(sp[3]);
355
+
356
+                        for (int i = 0; i < 4; i++)
357
+                        {
358
+                            SnrIndex += 4;
359
+                            if (sp[SnrIndex].Contains("*"))
360
+                            {
361
+                                LastLocation = sp[SnrIndex].IndexOf("*") - 2;
362
+                                sp[SnrIndex] = sp[SnrIndex].Substring(0,2);
363
+                                GPS_TestSnRValue += Convert.ToInt32(sp[SnrIndex]);
364
+                            }
365
+                            else
366
+                            {
367
+                                if (sp[SnrIndex] == "")
368
+                                    sp[SnrIndex] = "0";
369
+                                GPS_TestSnRValue += Convert.ToInt32(sp[SnrIndex]);
370
+                            }
371
+                            Gps_CurrentCount++;
372
+                            if (Gps_CurrentCount == Gps_Count)
373
+                            {
374
+                                GPS_TestSnRValue /= Gps_Count;
375
+                                dataGridView_Gps.Rows[0].Cells[1].Value = GPS_TestSnRValue.ToString();
376
+                                break;
377
+                            }
378
+                        }
379
+                        
380
+  
381
+                    }
382
+                    return str;
383
+                }
384
+                return "";
321
             }
385
             }
322
-            return str;
386
+            catch (Exception e) { MessageBox.Show(e.StackTrace); }
387
+            return "";
323
         }
388
         }
324
         private void label_Port_MouseLeave(object sender, EventArgs e)
389
         private void label_Port_MouseLeave(object sender, EventArgs e)
325
         {
390
         {
@@ -411,7 +476,7 @@ namespace APL_TestCheck
411
 
476
 
412
         private void dataGridView_Sensor_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
477
         private void dataGridView_Sensor_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
413
         {
478
         {
414
-            string value = "0";
479
+            string value = "";
415
             if (checkBox_Edit.Checked == false)
480
             if (checkBox_Edit.Checked == false)
416
             {
481
             {
417
                 if (InputBox("번호 입력", "일련 번호:", ref value) == DialogResult.OK)
482
                 if (InputBox("번호 입력", "일련 번호:", ref value) == DialogResult.OK)
@@ -423,7 +488,7 @@ namespace APL_TestCheck
423
 
488
 
424
         private void dataGridView_Catm1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
489
         private void dataGridView_Catm1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
425
         {
490
         {
426
-            string value = "0";
491
+            string value = "";
427
             if (checkBox_Edit.Checked == false)
492
             if (checkBox_Edit.Checked == false)
428
             {
493
             {
429
                 if (InputBox("번호 입력", "일련 번호:", ref value) == DialogResult.OK)
494
                 if (InputBox("번호 입력", "일련 번호:", ref value) == DialogResult.OK)
@@ -435,7 +500,7 @@ namespace APL_TestCheck
435
 
500
 
436
         private void dataGridView_Gps_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
501
         private void dataGridView_Gps_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
437
         {
502
         {
438
-            string value = "0";
503
+            string value = "";
439
             if (checkBox_Edit.Checked == false)
504
             if (checkBox_Edit.Checked == false)
440
             {
505
             {
441
                 if (InputBox("번호 입력", "일련 번호:", ref value) == DialogResult.OK)
506
                 if (InputBox("번호 입력", "일련 번호:", ref value) == DialogResult.OK)

+ 6 - 6
Main.resx

@@ -120,6 +120,12 @@
120
   <metadata name="serialPort.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
120
   <metadata name="serialPort.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121
     <value>17, 17</value>
121
     <value>17, 17</value>
122
   </metadata>
122
   </metadata>
123
+  <metadata name="Gps_SerialNumber.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
124
+    <value>True</value>
125
+  </metadata>
126
+  <metadata name="dataGridViewTextBoxColumn8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
127
+    <value>True</value>
128
+  </metadata>
123
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
129
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
124
   <data name="pictureBox_Check2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
130
   <data name="pictureBox_Check2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
125
     <value>
131
     <value>
@@ -254,12 +260,6 @@
254
   <metadata name="RSRP.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
260
   <metadata name="RSRP.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
255
     <value>True</value>
261
     <value>True</value>
256
   </metadata>
262
   </metadata>
257
-  <metadata name="Gps_SerialNumber.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
258
-    <value>True</value>
259
-  </metadata>
260
-  <metadata name="dataGridViewTextBoxColumn8.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
261
-    <value>True</value>
262
-  </metadata>
263
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
263
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
264
     <value>
264
     <value>
265
         AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAMMOAADDDgAAAAAAAAAA
265
         AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAMMOAADDDgAAAAAAAAAA

BIN=BIN
bin/Debug/APL_TestCheck.exe


BIN=BIN
bin/Debug/APL_TestCheck.pdb


BIN=BIN
bin/Debug/APL_TestCheck.zip


BIN=BIN
obj/Debug/APL_TestCheck.csproj.GenerateResource.cache


BIN=BIN
obj/Debug/APL_TestCheck.exe


BIN=BIN
obj/Debug/APL_TestCheck.pdb