ソースを参照

APL 자동 Serial 탐색 기능 추가

YJ 5 年 前
コミット
f791d9cdad

+ 2 - 0
APL_Macro.csproj

@@ -55,6 +55,8 @@
55 55
   <ItemGroup>
56 56
     <Reference Include="System" />
57 57
     <Reference Include="System.Core" />
58
+    <Reference Include="System.Management" />
59
+    <Reference Include="System.Management.Instrumentation" />
58 60
     <Reference Include="System.Xml.Linq" />
59 61
     <Reference Include="System.Data.DataSetExtensions" />
60 62
     <Reference Include="Microsoft.CSharp" />

+ 164 - 20
Form1.Designer.cs

@@ -36,14 +36,25 @@
36 36
             this.comboBox2 = new System.Windows.Forms.ComboBox();
37 37
             this.Ascii_checkBox = new System.Windows.Forms.CheckBox();
38 38
             this.richTextBox1 = new System.Windows.Forms.RichTextBox();
39
+            this.numericUpDown_IMEI = new System.Windows.Forms.NumericUpDown();
40
+            this.numericUpDown_USIM = new System.Windows.Forms.NumericUpDown();
41
+            this.label1 = new System.Windows.Forms.Label();
42
+            this.label2 = new System.Windows.Forms.Label();
43
+            this.label3 = new System.Windows.Forms.Label();
44
+            this.label_Cnt = new System.Windows.Forms.Label();
45
+            this.Start_Clear = new System.Windows.Forms.Button();
46
+            this.button1 = new System.Windows.Forms.Button();
47
+            this.label4 = new System.Windows.Forms.Label();
39 48
             ((System.ComponentModel.ISupportInitialize)(this.dgvList)).BeginInit();
49
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_IMEI)).BeginInit();
50
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_USIM)).BeginInit();
40 51
             this.SuspendLayout();
41 52
             // 
42 53
             // Button_Start
43 54
             // 
44
-            this.Button_Start.Location = new System.Drawing.Point(26, 35);
55
+            this.Button_Start.Location = new System.Drawing.Point(29, 33);
45 56
             this.Button_Start.Name = "Button_Start";
46
-            this.Button_Start.Size = new System.Drawing.Size(108, 89);
57
+            this.Button_Start.Size = new System.Drawing.Size(122, 89);
47 58
             this.Button_Start.TabIndex = 0;
48 59
             this.Button_Start.Text = "시작";
49 60
             this.Button_Start.UseVisualStyleBackColor = true;
@@ -51,27 +62,28 @@
51 62
             // 
52 63
             // Button_Stop
53 64
             // 
54
-            this.Button_Stop.Location = new System.Drawing.Point(140, 35);
65
+            this.Button_Stop.Location = new System.Drawing.Point(158, 35);
55 66
             this.Button_Stop.Name = "Button_Stop";
56
-            this.Button_Stop.Size = new System.Drawing.Size(108, 89);
67
+            this.Button_Stop.Size = new System.Drawing.Size(122, 89);
57 68
             this.Button_Stop.TabIndex = 0;
58 69
             this.Button_Stop.Text = "중지";
59 70
             this.Button_Stop.UseVisualStyleBackColor = true;
71
+            this.Button_Stop.Click += new System.EventHandler(this.Button_Stop_Click);
60 72
             // 
61 73
             // dgvList
62 74
             // 
63 75
             this.dgvList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
64
-            this.dgvList.Location = new System.Drawing.Point(26, 183);
76
+            this.dgvList.Location = new System.Drawing.Point(29, 183);
65 77
             this.dgvList.Name = "dgvList";
66 78
             this.dgvList.RowTemplate.Height = 27;
67
-            this.dgvList.Size = new System.Drawing.Size(830, 804);
79
+            this.dgvList.Size = new System.Drawing.Size(408, 804);
68 80
             this.dgvList.TabIndex = 2;
69 81
             // 
70 82
             // button_ExcelOpen
71 83
             // 
72
-            this.button_ExcelOpen.Location = new System.Drawing.Point(265, 33);
84
+            this.button_ExcelOpen.Location = new System.Drawing.Point(282, 35);
73 85
             this.button_ExcelOpen.Name = "button_ExcelOpen";
74
-            this.button_ExcelOpen.Size = new System.Drawing.Size(108, 93);
86
+            this.button_ExcelOpen.Size = new System.Drawing.Size(116, 89);
75 87
             this.button_ExcelOpen.TabIndex = 3;
76 88
             this.button_ExcelOpen.Text = "ExcelOpen";
77 89
             this.button_ExcelOpen.UseVisualStyleBackColor = true;
@@ -80,19 +92,20 @@
80 92
             // comboBox1
81 93
             // 
82 94
             this.comboBox1.FormattingEnabled = true;
83
-            this.comboBox1.Location = new System.Drawing.Point(26, 139);
95
+            this.comboBox1.Location = new System.Drawing.Point(29, 139);
84 96
             this.comboBox1.Name = "comboBox1";
85
-            this.comboBox1.Size = new System.Drawing.Size(121, 23);
97
+            this.comboBox1.Size = new System.Drawing.Size(408, 23);
86 98
             this.comboBox1.TabIndex = 4;
99
+            this.comboBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.comboBox1_MouseClick);
87 100
             // 
88 101
             // comboBox2
89 102
             // 
90 103
             this.comboBox2.FormattingEnabled = true;
91 104
             this.comboBox2.Items.AddRange(new object[] {
92 105
             "115200"});
93
-            this.comboBox2.Location = new System.Drawing.Point(180, 139);
106
+            this.comboBox2.Location = new System.Drawing.Point(444, 139);
94 107
             this.comboBox2.Name = "comboBox2";
95
-            this.comboBox2.Size = new System.Drawing.Size(121, 23);
108
+            this.comboBox2.Size = new System.Drawing.Size(136, 23);
96 109
             this.comboBox2.TabIndex = 4;
97 110
             this.comboBox2.Text = "115200";
98 111
             // 
@@ -102,39 +115,161 @@
102 115
             | System.Windows.Forms.AnchorStyles.Left) 
103 116
             | System.Windows.Forms.AnchorStyles.Right)));
104 117
             this.Ascii_checkBox.AutoSize = true;
105
-            this.Ascii_checkBox.Location = new System.Drawing.Point(309, 143);
118
+            this.Ascii_checkBox.Checked = true;
119
+            this.Ascii_checkBox.CheckState = System.Windows.Forms.CheckState.Checked;
120
+            this.Ascii_checkBox.Location = new System.Drawing.Point(596, 143);
106 121
             this.Ascii_checkBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
107 122
             this.Ascii_checkBox.Name = "Ascii_checkBox";
108
-            this.Ascii_checkBox.Size = new System.Drawing.Size(64, 19);
123
+            this.Ascii_checkBox.Size = new System.Drawing.Size(69, 19);
109 124
             this.Ascii_checkBox.TabIndex = 73;
110 125
             this.Ascii_checkBox.Text = "ASCII";
111 126
             this.Ascii_checkBox.UseVisualStyleBackColor = true;
112 127
             // 
113 128
             // richTextBox1
114 129
             // 
115
-            this.richTextBox1.Location = new System.Drawing.Point(391, 35);
130
+            this.richTextBox1.Location = new System.Drawing.Point(440, 183);
116 131
             this.richTextBox1.Name = "richTextBox1";
117
-            this.richTextBox1.Size = new System.Drawing.Size(465, 127);
132
+            this.richTextBox1.Size = new System.Drawing.Size(523, 804);
118 133
             this.richTextBox1.TabIndex = 74;
119 134
             this.richTextBox1.Text = "";
120 135
             // 
136
+            // numericUpDown_IMEI
137
+            // 
138
+            this.numericUpDown_IMEI.Location = new System.Drawing.Point(533, 70);
139
+            this.numericUpDown_IMEI.Maximum = new decimal(new int[] {
140
+            30,
141
+            0,
142
+            0,
143
+            0});
144
+            this.numericUpDown_IMEI.Name = "numericUpDown_IMEI";
145
+            this.numericUpDown_IMEI.ReadOnly = true;
146
+            this.numericUpDown_IMEI.Size = new System.Drawing.Size(135, 25);
147
+            this.numericUpDown_IMEI.TabIndex = 75;
148
+            this.numericUpDown_IMEI.Value = new decimal(new int[] {
149
+            15,
150
+            0,
151
+            0,
152
+            0});
153
+            // 
154
+            // numericUpDown_USIM
155
+            // 
156
+            this.numericUpDown_USIM.Location = new System.Drawing.Point(688, 70);
157
+            this.numericUpDown_USIM.Maximum = new decimal(new int[] {
158
+            30,
159
+            0,
160
+            0,
161
+            0});
162
+            this.numericUpDown_USIM.Name = "numericUpDown_USIM";
163
+            this.numericUpDown_USIM.ReadOnly = true;
164
+            this.numericUpDown_USIM.Size = new System.Drawing.Size(135, 25);
165
+            this.numericUpDown_USIM.TabIndex = 75;
166
+            this.numericUpDown_USIM.Value = new decimal(new int[] {
167
+            15,
168
+            0,
169
+            0,
170
+            0});
171
+            // 
172
+            // label1
173
+            // 
174
+            this.label1.AutoSize = true;
175
+            this.label1.Font = new System.Drawing.Font("굴림", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
176
+            this.label1.Location = new System.Drawing.Point(530, 35);
177
+            this.label1.Name = "label1";
178
+            this.label1.Size = new System.Drawing.Size(106, 24);
179
+            this.label1.TabIndex = 76;
180
+            this.label1.Text = "IMEI 숫자";
181
+            // 
182
+            // label2
183
+            // 
184
+            this.label2.AutoSize = true;
185
+            this.label2.Font = new System.Drawing.Font("굴림", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
186
+            this.label2.Location = new System.Drawing.Point(685, 33);
187
+            this.label2.Name = "label2";
188
+            this.label2.Size = new System.Drawing.Size(118, 24);
189
+            this.label2.TabIndex = 76;
190
+            this.label2.Text = "USIM 숫자";
191
+            // 
192
+            // label3
193
+            // 
194
+            this.label3.AutoSize = true;
195
+            this.label3.Font = new System.Drawing.Font("굴림", 14F);
196
+            this.label3.Location = new System.Drawing.Point(844, 65);
197
+            this.label3.Name = "label3";
198
+            this.label3.Size = new System.Drawing.Size(77, 24);
199
+            this.label3.TabIndex = 77;
200
+            this.label3.Text = "CNT : ";
201
+            // 
202
+            // label_Cnt
203
+            // 
204
+            this.label_Cnt.AutoSize = true;
205
+            this.label_Cnt.Font = new System.Drawing.Font("굴림", 18F, System.Drawing.FontStyle.Bold);
206
+            this.label_Cnt.Location = new System.Drawing.Point(929, 59);
207
+            this.label_Cnt.Name = "label_Cnt";
208
+            this.label_Cnt.Size = new System.Drawing.Size(31, 30);
209
+            this.label_Cnt.TabIndex = 78;
210
+            this.label_Cnt.Text = "0";
211
+            // 
212
+            // Start_Clear
213
+            // 
214
+            this.Start_Clear.Location = new System.Drawing.Point(705, 139);
215
+            this.Start_Clear.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
216
+            this.Start_Clear.Name = "Start_Clear";
217
+            this.Start_Clear.Size = new System.Drawing.Size(258, 35);
218
+            this.Start_Clear.TabIndex = 79;
219
+            this.Start_Clear.Text = "Clear";
220
+            this.Start_Clear.UseVisualStyleBackColor = true;
221
+            this.Start_Clear.Click += new System.EventHandler(this.Start_Clear_Click);
222
+            // 
223
+            // button1
224
+            // 
225
+            this.button1.Location = new System.Drawing.Point(405, 35);
226
+            this.button1.Name = "button1";
227
+            this.button1.Size = new System.Drawing.Size(116, 89);
228
+            this.button1.TabIndex = 3;
229
+            this.button1.Text = "새로 고침";
230
+            this.button1.UseVisualStyleBackColor = true;
231
+            this.button1.Click += new System.EventHandler(this.button1_Click);
232
+            // 
233
+            // label4
234
+            // 
235
+            this.label4.AutoSize = true;
236
+            this.label4.Location = new System.Drawing.Point(898, 990);
237
+            this.label4.Name = "label4";
238
+            this.label4.Size = new System.Drawing.Size(64, 15);
239
+            this.label4.TabIndex = 80;
240
+            this.label4.Text = "출처 : J";
241
+            // 
121 242
             // Form1
122 243
             // 
123
-            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
124
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
125
-            this.ClientSize = new System.Drawing.Size(868, 1011);
244
+            this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
245
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
246
+            this.AutoScroll = true;
247
+            this.AutoSize = true;
248
+            this.ClientSize = new System.Drawing.Size(989, 1017);
249
+            this.Controls.Add(this.label4);
250
+            this.Controls.Add(this.Start_Clear);
251
+            this.Controls.Add(this.label_Cnt);
252
+            this.Controls.Add(this.label3);
253
+            this.Controls.Add(this.label2);
254
+            this.Controls.Add(this.label1);
255
+            this.Controls.Add(this.numericUpDown_USIM);
256
+            this.Controls.Add(this.numericUpDown_IMEI);
126 257
             this.Controls.Add(this.richTextBox1);
127 258
             this.Controls.Add(this.Ascii_checkBox);
128 259
             this.Controls.Add(this.comboBox2);
129 260
             this.Controls.Add(this.comboBox1);
261
+            this.Controls.Add(this.button1);
130 262
             this.Controls.Add(this.button_ExcelOpen);
131 263
             this.Controls.Add(this.dgvList);
132 264
             this.Controls.Add(this.Button_Stop);
133 265
             this.Controls.Add(this.Button_Start);
266
+            this.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
134 267
             this.Name = "Form1";
135
-            this.Text = "Form1";
268
+            this.Text = "IMEI 추출기";
136 269
             this.Load += new System.EventHandler(this.Form1_Load);
137 270
             ((System.ComponentModel.ISupportInitialize)(this.dgvList)).EndInit();
271
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_IMEI)).EndInit();
272
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_USIM)).EndInit();
138 273
             this.ResumeLayout(false);
139 274
             this.PerformLayout();
140 275
 
@@ -150,6 +285,15 @@
150 285
         private System.Windows.Forms.ComboBox comboBox2;
151 286
         private System.Windows.Forms.CheckBox Ascii_checkBox;
152 287
         private System.Windows.Forms.RichTextBox richTextBox1;
288
+        private System.Windows.Forms.NumericUpDown numericUpDown_IMEI;
289
+        private System.Windows.Forms.NumericUpDown numericUpDown_USIM;
290
+        private System.Windows.Forms.Label label1;
291
+        private System.Windows.Forms.Label label2;
292
+        private System.Windows.Forms.Label label3;
293
+        private System.Windows.Forms.Label label_Cnt;
294
+        private System.Windows.Forms.Button Start_Clear;
295
+        private System.Windows.Forms.Button button1;
296
+        private System.Windows.Forms.Label label4;
153 297
     }
154 298
 }
155 299
 

+ 203 - 23
Form1.cs

@@ -16,7 +16,8 @@ using System.Data.OleDb;
16 16
 using System.IO;
17 17
 using System.IO.Ports;
18 18
 using System.Text.RegularExpressions;
19
-
19
+using System.Management;
20
+using System.Management.Instrumentation;
20 21
 
21 22
 
22 23
 
@@ -25,7 +26,7 @@ namespace APL_Macro
25 26
     public partial class Form1 : Form
26 27
     {
27 28
         private System.IO.Ports.SerialPort serialPort1;
28
-      
29
+        private int RowCnt = 1;
29 30
         // 핸들을 잡기위한 Dll Import
30 31
         [DllImport("user32.dll")]
31 32
         public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
@@ -55,35 +56,149 @@ namespace APL_Macro
55 56
             WM_COMMAND = 0x111
56 57
         }
57 58
 
58
-
59 59
         public Form1()
60 60
         {
61 61
             InitializeComponent();
62 62
         }
63
-        private void Form1_Load(object sender, EventArgs e)
63
+        protected override void WndProc(ref Message m)
64 64
         {
65
-            /*   PrivateFontCollection privateFonts = new PrivateFontCollection();
66
-               privateFonts.AddFontFile("뫼비우스 Bold.ttf");
67
-               Font font = new Font(privateFonts.Families[0], 70f);*/
65
+            UInt32 WM_DEVICECHANGE = 0x0219;
66
+            //UInt32 DBT_DEVTUP_VOLUME = 0x02;
67
+            UInt32 DBT_DEVTUP_VOLUME = 0x00000003;
68
+            
69
+            UInt32 DBT_DEVICEARRIVAL = 0x8000;
70
+            UInt32 DBT_DEVICEREMOVECOMPLETE = 0x8004;
68 71
 
69
-            /*label38.Font = font;
70
-            label38.Text = "누액 감지 시스템";*/
72
+            if ((m.Msg == WM_DEVICECHANGE) && (m.WParam.ToInt32() == DBT_DEVICEARRIVAL))//디바이스 연결
73
+            {
74
+                //int m_Count = 0;
75
+                int devType = Marshal.ReadInt32(m.LParam, 4);
76
+
77
+                if (devType == DBT_DEVTUP_VOLUME)
78
+                {
79
+                    SerialPort_Get();
80
+                    if(PrevSerialName != null){
81
+                        comboBox1.DataSource = PrevSerialName;
82
+                        Button_Start_Click(null,null);
83
+                    }
84
+                }
85
+            }
86
+
87
+            if ((m.Msg == WM_DEVICECHANGE) && (m.WParam.ToInt32() == DBT_DEVICEREMOVECOMPLETE))  //디바이스 연결 해제
88
+            {
89
+                int devType = Marshal.ReadInt32(m.LParam, 4);
90
+                if (devType == DBT_DEVTUP_VOLUME)
91
+                {
92
+                 
93
+                    SerialPort_Get();
94
+                }
95
+            }
96
+
97
+            base.WndProc(ref m);
98
+        }
99
+        string PrevSerialName;
100
+        private void SerialPort_Get()
101
+        {
102
+#if false
103
+            ManagementObjectCollection ManObjReturn;
104
+            ManagementObjectSearcher ManObjSearch;
105
+            ManObjSearch = new ManagementObjectSearcher("Select * from Win32_SerialPort");
106
+            ManObjReturn = ManObjSearch.Get();
107
+            String[] str = new string[10];
108
+            int i = 0;
109
+            foreach (ManagementObject ManObj in ManObjReturn)
110
+            {
111
+                str[i++] = Convert.ToString(ManObj["Name"]);
112
+                //comboBox1.Items.Add(Convert.ToString(ManObj["Name"]));
113
+                //  MessageBox.Show(Convert.ToString(ManObj["Name"]));
114
+            }
115
+#endif
116
+#if false
117
+            foreach (ManagementObject ManObj in ManObjReturn)
118
+            {
119
+                            //int s = ManObj.Properties.Count;
120
+                            //foreach (PropertyData d in ManObj.Properties)
121
+                            //{
122
+                            //    MessageBox.Show(d.Name);
123
+                            //}
124
+                            MessageBox.Show(
125
+                                "Device ID : " + ManObj["DeviceID"] + "\n"
126
+                                + "PNP Device ID : " + ManObj["PNPDeviceID"] + "\n"
127
+                                + "Name : " + ManObj["Name"] + "\n"
128
+                                + "Caption : " + ManObj["Caption"] + "\n"
129
+                                + "Description : " + ManObj["Description"] + "\n"
130
+                                + "Provider Type : " + ManObj["ProviderType"] + "\n"
131
+                            + "Status : " + ManObj["Status"]);
132
+            }
133
+#endif
71 134
 
135
+#if true
72 136
             this.serialPort1 = new System.IO.Ports.SerialPort();
73 137
             this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.SP1_DataReceived);
138
+            string[] port = SerialPort.GetPortNames();
139
+#endif
140
+
141
+#if true
142
+            comboBox1.DataSource = null;
74 143
             comboBox1.BeginUpdate();
75 144
             foreach (string comport in SerialPort.GetPortNames())//foreach (string comport in SerialPort_TestProgram.GetPortNames())
76 145
             {
77 146
                 comboBox1.Items.Add(comport);
78 147
             }
79 148
             comboBox1.EndUpdate();
80
-            //SerialPort 초기 설정
149
+            if(comboBox1.Enabled == true) // 연결이 안된상태
150
+                comboBox1.DataSource = SerialPort.GetPortNames();
151
+            else//연결된 상태 해제시 연결 해제
152
+                Button_Stop_Click(null, null);
153
+#else
154
+#if false
155
+            comboBox1.BeginUpdate();
156
+            foreach (ManagementObject ManObj in ManObjReturn)
157
+            {
158
+                comboBox1.Items.Add(Convert.ToString(ManObj["Name"]));
159
+                //  MessageBox.Show(Convert.ToString(ManObj["Name"]));
160
+            }
161
+            comboBox1.EndUpdate();
162
+#else
163
+            comboBox1.BeginUpdate();
164
+            for(int ii = 0; ii < i; ii++)
165
+            {
166
+                comboBox1.Items.Add(str[ii]);
167
+                //  MessageBox.Show(Convert.ToString(ManObj["Name"]));
168
+            }
169
+            comboBox1.EndUpdate();
170
+#endif
81 171
 
172
+#endif
173
+            if (Button_Start.Visible == false)
174
+            {
175
+                //comboBox1.DataSource = PrevSerialName;
176
+                serialPort1.BaudRate = (int)115200;
177
+                serialPort1.DataBits = (int)8;
178
+                serialPort1.Parity = System.IO.Ports.Parity.None;
179
+                serialPort1.StopBits = StopBits.One;
180
+                serialPort1.Encoding = Encoding.UTF8;
181
+                Button_Start_Click(null,null);
182
+            }
183
+        }
184
+        private void Form1_Load(object sender, EventArgs e)
185
+        {
186
+            /*   PrivateFontCollection privateFonts = new PrivateFontCollection();
187
+               privateFonts.AddFontFile("뫼비우스 Bold.ttf");
188
+               Font font = new Font(privateFonts.Families[0], 70f);*/
189
+
190
+            /*label38.Font = font;
191
+            label38.Text = "누액 감지 시스템";*/
192
+
193
+            
194
+            //SerialPort 초기 설정
195
+            SerialPort_Get();
82 196
             comboBox1.DataSource = SerialPort.GetPortNames();
83 197
             serialPort1.BaudRate = (int)115200;
84 198
             serialPort1.DataBits = (int)8;
85 199
             serialPort1.Parity = System.IO.Ports.Parity.None;
86 200
             serialPort1.StopBits = StopBits.One;
201
+            serialPort1.Encoding = Encoding.UTF8;
87 202
 
88 203
 
89 204
             //Serial Form _Off button 설정
@@ -117,13 +232,14 @@ namespace APL_Macro
117 232
             //포트로 데이터가 들어오면
118 233
             if (serialPort1.IsOpen)
119 234
             {
235
+                string data = serialPort1.ReadExisting();
236
+                Controller_TextLoad(data);
120 237
                 if (Ascii_checkBox.Checked == true)
121 238
                 {
122
-                    string data = serialPort1.ReadExisting();
239
+                    
123 240
                     g_data += data;
124 241
                     if (data != string.Empty)
125 242
                     {
126
-                        Controller_TextLoad(data);
127 243
                         PacketData(data);
128 244
                     }
129 245
                 }
@@ -173,7 +289,7 @@ namespace APL_Macro
173 289
             bool stringExists = Text.Contains("READY");
174 290
             if (stringExists)
175 291
             {
176
-                MessageBox.Show(Text);
292
+            //    MessageBox.Show(Text);
177 293
                 datacnt = 1;
178 294
             }
179 295
             if(datacnt >= 1)
@@ -190,9 +306,10 @@ namespace APL_Macro
190 306
                         }
191 307
                         if (datacnt == 1)
192 308
                         {
193
-                            SubStr[0] = "\r\n IMEI  : " + strTmp.Substring(0, 15);
194
-                            SubStr[1] = "\r\n USIM  : " + strTmp.Substring(15, 15);
195
-                            MessageBox.Show(SubStr[0] + SubStr[1]);
309
+                            SubStr[0] = "\r\n IMEI  : " + strTmp.Substring(0, Convert.ToInt32(numericUpDown_IMEI));
310
+                            SubStr[1] = "\r\n USIM  : " + strTmp.Substring(15, Convert.ToInt32(numericUpDown_USIM));
311
+                            
312
+                         //   MessageBox.Show(SubStr[0] + SubStr[1]);
196 313
                             datacnt = 0;
197 314
                         }
198 315
                         else if (datacnt == 2)
@@ -203,13 +320,16 @@ namespace APL_Macro
203 320
                         else if (datacnt == 3)
204 321
                         {
205 322
                             SubStr[1] = "\r\n USIM  : " + strTmp.Substring(0, 15);
206
-                            MessageBox.Show(SubStr[0] + SubStr[1]);
323
+                          //  MessageBox.Show(SubStr[0] + SubStr[1]);
207 324
                             datacnt = 0;
208 325
                             string[] row0 = { Regex.Replace(SubStr[0], @"\D", ""), Regex.Replace(SubStr[1], @"\D", "") };
209 326
 
210 327
                             // DataGridView에 한 줄씩 삽입합니다.
211 328
                             CheckForIllegalCrossThreadCalls = false;
212 329
                             dgvList.Rows.Add(row0);
330
+                            label_Cnt.Text = Convert.ToString(RowCnt++);
331
+
332
+
213 333
                         }
214 334
                     }
215 335
                 }
@@ -243,9 +363,10 @@ namespace APL_Macro
243 363
             {
244 364
                 try
245 365
                 {
366
+                    CheckForIllegalCrossThreadCalls = false;
246 367
                     SendMessage(this.Handle, WM_SETREDRAW, false, 0);
247 368
                 }
248
-                catch { return; }
369
+                catch(Exception ex) { MessageBox.Show(ex.Message); return; }
249 370
                 if (richTextBox1.Lines.Length > nLimitLines)
250 371
                 {
251 372
                     LinkedList<string> tempLines = new LinkedList<string>(richTextBox1.Lines);
@@ -259,14 +380,16 @@ namespace APL_Macro
259 380
                 }
260 381
                 try
261 382
                 {
383
+                    CheckForIllegalCrossThreadCalls = false;
262 384
                     SendMessage(this.Handle, WM_SETREDRAW, true, 0);
385
+                    this.Refresh();
263 386
                 }
264 387
                 catch { return; }
265 388
                 richTextBox1.AppendText(text);
266 389
                 richTextBox1.SelectionStart = richTextBox1.Text.Length;//맨 마지막 선택... 
267 390
                 richTextBox1.ScrollToCaret();
268 391
             }
269
-            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
392
+            catch { try { CheckForIllegalCrossThreadCalls = false; SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
270 393
         }
271 394
         // 이 코드에는 엑셀파일에서 불러온 데이터를 데이터그리드뷰(DataGridView)에 바인딩하는 것도 포함되어 있다.
272 395
         private void btnOpenExcel_Click(object sender, EventArgs e)
@@ -364,9 +487,19 @@ namespace APL_Macro
364 487
         }
365 488
         private void Button_Start_Click(object sender, EventArgs e)
366 489
         {
367
-
490
+#if false
491
+            int coms_index = comboBox1.Text.ToString().IndexOf("(COM");
492
+            int coms_Len = comboBox1.Text.ToString().Length;
493
+            string portname = comboBox1.Text.ToString().Substring(coms_index + 1, coms_Len - coms_index - 2);
494
+            serialPort1.PortName = portname;//comboBox1.Text.ToString();//
495
+#else
368 496
             serialPort1.PortName = comboBox1.SelectedItem.ToString();
369
-            serialPort1.PortName = comboBox1.Text.ToString();//
497
+            int coms_index = comboBox1.Text.ToString().IndexOf("\0");
498
+            PrevSerialName = comboBox1.Text;
499
+#endif
500
+            //MessageBox.Show();
501
+
502
+
370 503
             try
371 504
             {
372 505
                 serialPort1.Open();
@@ -381,9 +514,10 @@ namespace APL_Macro
381 514
             {
382 515
                 try
383 516
                 {
384
-                    PacketData("Port Open Connect!!!\r\n");
517
+                    Controller_TextLoad("\nPort Open Connect!!!");
385 518
                 }
386 519
                 catch { }
520
+
387 521
                 //rbText.Text = "[" + SP1.PortName.ToString() + "] Port Open Connect!!";
388 522
 
389 523
                 //Serial on/off Button의 보이고 안보이게 하기
@@ -400,7 +534,7 @@ namespace APL_Macro
400 534
                 try
401 535
                 {
402 536
                     // Controller_Debug.tbReceived2.Text = "Port Open Failed!!!";
403
-                    MessageBox.Show("Port Open Failed!!!");
537
+                    MessageBox.Show("Port Open Failed!!!    ");
404 538
                 }
405 539
                 catch { }
406 540
             }
@@ -415,5 +549,51 @@ namespace APL_Macro
415 549
                 */
416 550
             ////////////////////
417 551
         }
552
+
553
+      
554
+        private void Button_Stop_Click(object sender, EventArgs e)
555
+        {
556
+            try
557
+            {
558
+                serialPort1.Close();
559
+                Controller_TextLoad("\nPort Closed!!!    ");
560
+            }
561
+            catch { }
562
+            
563
+            //     Initialize = 0;
564
+
565
+            //Serial on/off Button의 보이고 안보이게 하기
566
+            Button_Start.Enabled = true; //on 기능 나타남
567
+            Button_Start.Visible = true; //on 버튼 나타남
568
+            Button_Stop.Enabled = false;  //off 기능 사라짐
569
+            Button_Stop.Visible = false; //off 버튼 사라짐
570
+
571
+            SerialFormEnagleChoice(true); //serial 설정버튼 on
572
+        }
573
+
574
+        private void Start_Clear_Click(object sender, EventArgs e)
575
+        {
576
+            richTextBox1.Text = "";
577
+        }
578
+
579
+
580
+
581
+        private void comboBox1_Click(object sender, EventArgs e)
582
+        {
583
+           
584
+        }
585
+
586
+        private void button1_Click(object sender, EventArgs e)
587
+        {
588
+            comboBox1.Items.Clear();
589
+            SerialPort_Get();
590
+        }
591
+
592
+        private void comboBox1_MouseClick(object sender, MouseEventArgs e)
593
+        {
594
+            comboBox1.DataSource = null;
595
+            comboBox1.Items.Clear();
596
+            SerialPort_Get();
597
+        }
418 598
     }
419 599
 }

BIN
bin/Debug/APL_Macro.exe


BIN
bin/Debug/APL_Macro.pdb


+ 1 - 1
obj/Debug/APL_Macro.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
1
-eaf1766b6ea42bfda729ba8701a2c4014e61dc5b
1
+d38dd7604ce87458448c6916e94a67fc2dfd5fa8

BIN
obj/Debug/APL_Macro.csproj.GenerateResource.cache


BIN
obj/Debug/APL_Macro.csprojAssemblyReference.cache


BIN
obj/Debug/APL_Macro.exe


BIN
obj/Debug/APL_Macro.pdb


BIN
obj/Debug/DesignTimeResolveAssemblyReferences.cache


BIN
obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache