浏览代码

DTU基本完成

琴声悠扬 8 年前
当前提交
c7b7f21edf

+ 21 - 3
GWSocketClient/AnaProtocol.Designer.cs 查看文件

28
         /// </summary>
28
         /// </summary>
29
         private void InitializeComponent()
29
         private void InitializeComponent()
30
         {
30
         {
31
+            this.labelSourceData = new System.Windows.Forms.Label();
31
             this.SuspendLayout();
32
             this.SuspendLayout();
32
             // 
33
             // 
34
+            // labelSourceData
35
+            // 
36
+            this.labelSourceData.AutoSize = true;
37
+            this.labelSourceData.Location = new System.Drawing.Point(357, 13);
38
+            this.labelSourceData.Name = "labelSourceData";
39
+            this.labelSourceData.Size = new System.Drawing.Size(43, 17);
40
+            this.labelSourceData.TabIndex = 0;
41
+            this.labelSourceData.Text = "label1";
42
+            // 
33
             // AnaProtocol
43
             // AnaProtocol
34
             // 
44
             // 
35
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
45
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
36
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
46
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
37
-            this.ClientSize = new System.Drawing.Size(875, 594);
47
+            this.ClientSize = new System.Drawing.Size(1021, 841);
48
+            this.Controls.Add(this.labelSourceData);
49
+            this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
50
+            this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
38
             this.Name = "AnaProtocol";
51
             this.Name = "AnaProtocol";
52
+            this.ShowIcon = false;
39
             this.ShowInTaskbar = false;
53
             this.ShowInTaskbar = false;
40
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
54
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
41
-            this.Text = "AnaProtocol";
55
+            this.Text = "分析";
56
+            this.Load += new System.EventHandler(this.AnaProtocol_Load);
42
             this.ResumeLayout(false);
57
             this.ResumeLayout(false);
58
+            this.PerformLayout();
43
 
59
 
44
         }
60
         }
45
 
61
 
46
         #endregion
62
         #endregion
63
+
64
+        private System.Windows.Forms.Label labelSourceData;
47
     }
65
     }
48
 }
66
 }

+ 9 - 0
GWSocketClient/AnaProtocol.cs 查看文件

19
             InitializeComponent();
19
             InitializeComponent();
20
             this.protocolData = pd;
20
             this.protocolData = pd;
21
         }
21
         }
22
+
23
+        #region 窗体事件
24
+
25
+        private void AnaProtocol_Load(object sender, EventArgs e)
26
+        {
27
+            labelSourceData.Text = this.protocolData;
28
+        }
29
+
30
+        #endregion
22
     }
31
     }
23
 }
32
 }

+ 11 - 12
GWSocketClient/Form1.Designer.cs 查看文件

55
             this.文件FToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
55
             this.文件FToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
56
             this.tsmiLoadXml = new System.Windows.Forms.ToolStripMenuItem();
56
             this.tsmiLoadXml = new System.Windows.Forms.ToolStripMenuItem();
57
             this.心跳HToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
57
             this.心跳HToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
58
+            this.StripMenuItemLoSucHb = new System.Windows.Forms.ToolStripMenuItem();
58
             this.ToolStripMenuItemHbStart = new System.Windows.Forms.ToolStripMenuItem();
59
             this.ToolStripMenuItemHbStart = new System.Windows.Forms.ToolStripMenuItem();
59
             this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
60
             this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
60
             this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
61
             this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
73
             this.rightMenuCopyCmd = new System.Windows.Forms.ToolStripMenuItem();
74
             this.rightMenuCopyCmd = new System.Windows.Forms.ToolStripMenuItem();
74
             this.rightMenuClearInfo = new System.Windows.Forms.ToolStripMenuItem();
75
             this.rightMenuClearInfo = new System.Windows.Forms.ToolStripMenuItem();
75
             this.timerHeartBeat = new System.Windows.Forms.Timer(this.components);
76
             this.timerHeartBeat = new System.Windows.Forms.Timer(this.components);
76
-            this.StripMenuItemLoSucHb = new System.Windows.Forms.ToolStripMenuItem();
77
             this.groupBox1.SuspendLayout();
77
             this.groupBox1.SuspendLayout();
78
             this.menuStrip1.SuspendLayout();
78
             this.menuStrip1.SuspendLayout();
79
             this.statusStrip1.SuspendLayout();
79
             this.statusStrip1.SuspendLayout();
360
             this.心跳HToolStripMenuItem.Size = new System.Drawing.Size(61, 21);
360
             this.心跳HToolStripMenuItem.Size = new System.Drawing.Size(61, 21);
361
             this.心跳HToolStripMenuItem.Text = "心跳(&H)";
361
             this.心跳HToolStripMenuItem.Text = "心跳(&H)";
362
             // 
362
             // 
363
+            // StripMenuItemLoSucHb
364
+            // 
365
+            this.StripMenuItemLoSucHb.Checked = true;
366
+            this.StripMenuItemLoSucHb.CheckOnClick = true;
367
+            this.StripMenuItemLoSucHb.CheckState = System.Windows.Forms.CheckState.Checked;
368
+            this.StripMenuItemLoSucHb.Name = "StripMenuItemLoSucHb";
369
+            this.StripMenuItemLoSucHb.Size = new System.Drawing.Size(196, 22);
370
+            this.StripMenuItemLoSucHb.Text = "登录成功同时开启心跳";
371
+            // 
363
             // ToolStripMenuItemHbStart
372
             // ToolStripMenuItemHbStart
364
             // 
373
             // 
365
             this.ToolStripMenuItemHbStart.CheckOnClick = true;
374
             this.ToolStripMenuItemHbStart.CheckOnClick = true;
368
             this.ToolStripMenuItemHbStart.Size = new System.Drawing.Size(196, 22);
377
             this.ToolStripMenuItemHbStart.Size = new System.Drawing.Size(196, 22);
369
             this.ToolStripMenuItemHbStart.Text = "开启心跳";
378
             this.ToolStripMenuItemHbStart.Text = "开启心跳";
370
             this.ToolStripMenuItemHbStart.CheckStateChanged += new System.EventHandler(this.ToolStripMenuItemHbStart_CheckStateChanged);
379
             this.ToolStripMenuItemHbStart.CheckStateChanged += new System.EventHandler(this.ToolStripMenuItemHbStart_CheckStateChanged);
371
-            this.ToolStripMenuItemHbStart.Click += new System.EventHandler(this.ToolStripMenuItemHbStart_Click);
372
             // 
380
             // 
373
             // toolStripSeparator1
381
             // toolStripSeparator1
374
             // 
382
             // 
400
             // 
408
             // 
401
             // ToolStripMenuItemLogHb
409
             // ToolStripMenuItemLogHb
402
             // 
410
             // 
411
+            this.ToolStripMenuItemLogHb.CheckOnClick = true;
403
             this.ToolStripMenuItemLogHb.Name = "ToolStripMenuItemLogHb";
412
             this.ToolStripMenuItemLogHb.Name = "ToolStripMenuItemLogHb";
404
             this.ToolStripMenuItemLogHb.Size = new System.Drawing.Size(196, 22);
413
             this.ToolStripMenuItemLogHb.Size = new System.Drawing.Size(196, 22);
405
             this.ToolStripMenuItemLogHb.Text = "是否打印心跳";
414
             this.ToolStripMenuItemLogHb.Text = "是否打印心跳";
406
-            this.ToolStripMenuItemLogHb.Click += new System.EventHandler(this.ToolStripMenuItemLogHb_Click);
407
             // 
415
             // 
408
             // statusStrip1
416
             // statusStrip1
409
             // 
417
             // 
504
             this.timerHeartBeat.Interval = 1000;
512
             this.timerHeartBeat.Interval = 1000;
505
             this.timerHeartBeat.Tick += new System.EventHandler(this.timerHeartBeat_Tick);
513
             this.timerHeartBeat.Tick += new System.EventHandler(this.timerHeartBeat_Tick);
506
             // 
514
             // 
507
-            // StripMenuItemLoSucHb
508
-            // 
509
-            this.StripMenuItemLoSucHb.Checked = true;
510
-            this.StripMenuItemLoSucHb.CheckOnClick = true;
511
-            this.StripMenuItemLoSucHb.CheckState = System.Windows.Forms.CheckState.Checked;
512
-            this.StripMenuItemLoSucHb.Name = "StripMenuItemLoSucHb";
513
-            this.StripMenuItemLoSucHb.Size = new System.Drawing.Size(196, 22);
514
-            this.StripMenuItemLoSucHb.Text = "登录成功同时开启心跳";
515
-            // 
516
             // Form1
515
             // Form1
517
             // 
516
             // 
518
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
517
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);

+ 176 - 169
GWSocketClient/Form1.cs 查看文件

27
 
27
 
28
     public partial class Form1 : Form
28
     public partial class Form1 : Form
29
     {
29
     {
30
-        public Form1()
31
-        {
32
-            InitializeComponent();
33
-        }
30
+        #region 属性定义
34
 
31
 
35
         private string ip;
32
         private string ip;
36
         private string port;
33
         private string port;
37
         private SocketHelper.TcpClients sockeTcpClients;
34
         private SocketHelper.TcpClients sockeTcpClients;
35
+
38
         private VcarecityPD vcarecityProtocolBean = null;
36
         private VcarecityPD vcarecityProtocolBean = null;
39
-        private volatile bool hbRunFlag = false; //心跳线程标志
37
+
40
         private ThreadFormDelegate uiDelegate;
38
         private ThreadFormDelegate uiDelegate;
41
 
39
 
40
+        #endregion
41
+
42
+
43
+        #region Form 事件
44
+
45
+        public Form1()
46
+        {
47
+            InitializeComponent();
48
+        }
42
 
49
 
43
         private void Form1_Load(object sender, EventArgs e)
50
         private void Form1_Load(object sender, EventArgs e)
44
         {
51
         {
60
             timerHeartBeat.Enabled = ToolStripMenuItemHbStart.Checked;
67
             timerHeartBeat.Enabled = ToolStripMenuItemHbStart.Checked;
61
         }
68
         }
62
 
69
 
70
+        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
71
+        {
72
+            timerHeartBeat.Enabled = false;
73
+            try
74
+            {
75
+                sockeTcpClients.Stop();
76
+            }
77
+            catch (Exception exception)
78
+            {
79
+            }
80
+            finally
81
+            {
82
+                sockeTcpClients = null;
83
+            }
84
+
85
+            AccsessDbLoader.getInstance().closeConnection();
86
+        }
87
+
88
+        #endregion
89
+
90
+
91
+        #region 点击事件
92
+
93
+        private void btnLogin_Click(object sender, EventArgs e)
94
+        {
95
+            try
96
+            {
97
+                if (!showTopForNoLoadXML())
98
+                    return;
99
+
100
+                ip = tbIpaddress.Text.Trim();
101
+                port = tbPort.Text.Trim();
102
+
103
+                sockeTcpClients.InitSocket(ip, int.Parse(port));
104
+                sockeTcpClients.Start();
105
+            }
106
+            catch (Exception ex)
107
+            {
108
+                //                statuslist.Items.Add(string.Format("连接失败!原因:{0}", ex.Message
109
+                Console.WriteLine(ex.Message);
110
+            }
111
+        }
112
+
113
+        private void btnQuickLogout_Click(object sender, EventArgs e)
114
+        {
115
+            try
116
+            {
117
+                sockeTcpClients.Stop();
118
+            }
119
+            catch (Exception exception)
120
+            {
121
+                addToListboxItem("你还没有登录!!" + exception.Message);
122
+            }
123
+        }
124
+
125
+        private void tsmiLoadXml_Click(object sender, EventArgs e)
126
+        {
127
+            OpenFileDialog ofd = new OpenFileDialog();
128
+            ofd.Filter = "XML文件|*.xml|所有文件|*.*";
129
+            ofd.InitialDirectory = Application.StartupPath;
130
+
131
+            if (ofd.ShowDialog() == DialogResult.OK)
132
+            {
133
+                string xmlFilepath = ofd.FileName;
134
+
135
+                vcarecityProtocolBean = new XmlLoader().load(xmlFilepath).getVcarecityPD();
136
+                this.Text = vcarecityProtocolBean.ProtocolName + " - " + vcarecityProtocolBean.ProtocolNo + " - " +
137
+                            vcarecityProtocolBean.ProtocolStartSymbol;
138
+            }
139
+        }
140
+
141
+        private void btnSendData_Click(object sender, EventArgs e)
142
+        {
143
+            string trim = tfTmpSendData.Text.Trim();
144
+            trim = trim.Replace("\n", "").Replace("\r", "").Replace("\t", "").Replace(" ", "").Replace("-", "");
145
+
146
+            if (!trim.Equals(""))
147
+            {
148
+                byte[] ts = HexUtil.hexToBytes(trim);
149
+
150
+                addToListboxItem(string.Format("发送到服务端:[{0}]", trim));
151
+
152
+                sockeTcpClients.SendData(ts);
153
+            }
154
+        }
155
+
156
+        /// <summary>
157
+        /// 压力测试
158
+        /// </summary>
159
+        private void btnPressureTest_Click(object sender, EventArgs e)
160
+        {
161
+            ip = tbIpaddress.Text.Trim();
162
+            port = tbPort.Text.Trim();
163
+
164
+            int count = int.Parse(tbPresureTestCount.Text);
165
+
166
+            ThreadPool.QueueUserWorkItem(o =>
167
+            {
168
+                for (int i = 1024; i < 1024 + count; i++)
169
+                {
170
+                    SocketHelper.TcpClients clientx = new SocketHelper.TcpClients(); //初始化类库  
171
+                    clientx.InitSocket(ip, int.Parse(port));
172
+                    clientx.Start();
173
+
174
+                    string loginCmd = "7e7e7e";
175
+                    loginCmd += "4442832e" + i;
176
+                    loginCmd += "820014383938363032423131393135353034373938" + i;
177
+                    loginCmd = Utils.calcCrcCode(loginCmd);
178
+                    sockeTcpClients.SendData(HexUtil.hexToBytes(loginCmd));
179
+                    Thread.Sleep(200);
180
+                }
181
+            });
182
+        }
183
+
184
+
185
+        private void buttonCmdManager_Click(object sender, EventArgs e)
186
+        {
187
+            InfoEditor ie = new InfoEditor();
188
+            ie.ShowDialog();
189
+        }
190
+
191
+
192
+        private void btnTextCmd_Click(object sender, EventArgs e)
193
+        {
194
+            //beta test tool
195
+            if (tfTmpSendData.Text.Trim().ToLower().Equals("pre"))
196
+            {
197
+                btnPressureTest.Visible = !btnPressureTest.Visible;
198
+                tbPresureTestCount.Visible = !tbPresureTestCount.Visible;
199
+                label4.Visible = !label4.Visible;
200
+            }
201
+        }
202
+
203
+        #endregion
204
+
63
 
205
 
64
         #region 处理心跳相关的
206
         #region 处理心跳相关的
65
 
207
 
89
             }
231
             }
90
         }
232
         }
91
 
233
 
234
+        private void ToolStripMenuItemHbStart_CheckStateChanged(object sender, EventArgs e)
235
+        {
236
+            timerHeartBeat.Enabled = ToolStripMenuItemHbStart.Checked;
237
+        }
238
+
92
         #endregion
239
         #endregion
93
 
240
 
94
         private bool showTopForNoLoadXML()
241
         private bool showTopForNoLoadXML()
111
                     {
258
                     {
112
                         case SocketHelper.Sockets.ErrorCodes.objectNull:
259
                         case SocketHelper.Sockets.ErrorCodes.objectNull:
113
                             addToListboxItem("状态信息:服务器连接已断开");
260
                             addToListboxItem("状态信息:服务器连接已断开");
114
-                            hbRunFlag = false;
115
                             checkLogin(false);
261
                             checkLogin(false);
116
                             break;
262
                             break;
117
                         case SocketHelper.Sockets.ErrorCodes.ConnectError:
263
                         case SocketHelper.Sockets.ErrorCodes.ConnectError:
118
                             //连接不成功
264
                             //连接不成功
119
                             addToListboxItem("状态信息:连接服务器失败,可能是服务器未开启!");
265
                             addToListboxItem("状态信息:连接服务器失败,可能是服务器未开启!");
266
+                            checkLogin(false);
120
                             break;
267
                             break;
121
                         case SocketHelper.Sockets.ErrorCodes.ConnectSuccess:
268
                         case SocketHelper.Sockets.ErrorCodes.ConnectSuccess:
122
                             //连接成功
269
                             //连接成功
123
                             addToListboxItem("状态信息:与服务器连接成功");
270
                             addToListboxItem("状态信息:与服务器连接成功");
124
                             addToListboxItem(string.Format("客户端信息{0}", sks.ex));
271
                             addToListboxItem(string.Format("客户端信息{0}", sks.ex));
125
-                            checkLogin(true);
126
                             sendLoginCmd();
272
                             sendLoginCmd();
273
+                            checkLogin(true);
274
+
127
                             if (StripMenuItemLoSucHb.Checked)
275
                             if (StripMenuItemLoSucHb.Checked)
128
                             {
276
                             {
129
                                 ToolStripMenuItemHbStart.Checked = true;
277
                                 ToolStripMenuItemHbStart.Checked = true;
130
                             }
278
                             }
131
-                            hbRunFlag = true;
132
-//                            startHeartBeatThread();
133
                             break;
279
                             break;
134
                         case SocketHelper.Sockets.ErrorCodes.TrySendData:
280
                         case SocketHelper.Sockets.ErrorCodes.TrySendData:
135
                             addToListboxItem("状态信息:ErrorCodes");
281
                             addToListboxItem("状态信息:ErrorCodes");
282
+                            checkLogin(false);
136
                             break;
283
                             break;
137
                         default:
284
                         default:
138
                             addToListboxItem(string.Format("客户端信息{0}", sks.ex));
285
                             addToListboxItem(string.Format("客户端信息{0}", sks.ex));
189
 
336
 
190
             if (!(funcode == 16 || funcode == 32))
337
             if (!(funcode == 16 || funcode == 32))
191
             {
338
             {
192
-                Console.WriteLine("功能码10进制=" + funcode + ",所以不用回复!");
339
+                Console.WriteLine("功能码10进制=" + funcode + ",所以不用回复! data=" + reqData);
193
                 return;
340
                 return;
194
             }
341
             }
195
 
342
 
302
             sockeTcpClients.SendData(ts);
449
             sockeTcpClients.SendData(ts);
303
         }
450
         }
304
 
451
 
305
-        private void btnLogin_Click(object sender, EventArgs e)
306
-        {
307
-            try
308
-            {
309
-                if (!showTopForNoLoadXML())
310
-                    return;
311
-
312
-                ip = tbIpaddress.Text.Trim();
313
-                port = tbPort.Text.Trim();
314
-
315
-                sockeTcpClients.InitSocket(ip, int.Parse(port));
316
-                sockeTcpClients.Start();
317
-            }
318
-            catch (Exception ex)
319
-            {
320
-//                statuslist.Items.Add(string.Format("连接失败!原因:{0}", ex.Message
321
-                Console.WriteLine(ex.Message);
322
-            }
323
-        }
324
-
325
 
452
 
326
         private void tbCCID_TextChanged(object sender, EventArgs e)
453
         private void tbCCID_TextChanged(object sender, EventArgs e)
327
         {
454
         {
328
             string ccid = tbCCID.Text.Trim();
455
             string ccid = tbCCID.Text.Trim();
329
-
330
             tsslCCIDLEN.Text = ccid.Length / 2.0 + "";
456
             tsslCCIDLEN.Text = ccid.Length / 2.0 + "";
331
         }
457
         }
332
 
458
 
333
-        private void btnQuickLogout_Click(object sender, EventArgs e)
334
-        {
335
-            try
336
-            {
337
-                sockeTcpClients.Stop();
338
-            }
339
-            catch (Exception exception)
340
-            {
341
-                addToListboxItem("你还没有登录!!" + exception.Message);
342
-            }
343
-        }
344
-
345
-        private void tsmiLoadXml_Click(object sender, EventArgs e)
346
-        {
347
-            OpenFileDialog ofd = new OpenFileDialog();
348
-            ofd.Filter = "XML文件|*.xml|所有文件|*.*";
349
-            ofd.InitialDirectory = Application.StartupPath;
350
-
351
-            if (ofd.ShowDialog() == DialogResult.OK)
352
-            {
353
-                string xmlFilepath = ofd.FileName;
354
-
355
-                vcarecityProtocolBean = new XmlLoader().load(xmlFilepath).getVcarecityPD();
356
-                this.Text = vcarecityProtocolBean.ProtocolName + " - " + vcarecityProtocolBean.ProtocolNo + " - " +
357
-                            vcarecityProtocolBean.ProtocolStartSymbol;
358
-            }
359
-        }
360
-
361
-        private void btnSendData_Click(object sender, EventArgs e)
362
-        {
363
-            string trim = tfTmpSendData.Text.Trim();
364
-            trim = trim.Replace("\n", "").Replace("\r", "").Replace("\t", "").Replace(" ", "").Replace("-", "");
365
-
366
-            if (!trim.Equals(""))
367
-            {
368
-                byte[] ts = HexUtil.hexToBytes(trim);
369
-
370
-                addToListboxItem(string.Format("发送到服务端:[{0}]", trim));
371
 
459
 
372
-                sockeTcpClients.SendData(ts);
373
-            }
374
-        }
460
+        #region ListBox相关
375
 
461
 
462
+        /// <summary>
463
+        /// ListBox右键菜单-点击复制
464
+        /// </summary>
465
+        /// <param name="sender"></param>
466
+        /// <param name="e"></param>
376
         private void rightMenuCopyCmd_Click(object sender, EventArgs e)
467
         private void rightMenuCopyCmd_Click(object sender, EventArgs e)
377
         {
468
         {
378
             int index = listBoxShow.SelectedIndex;
469
             int index = listBoxShow.SelectedIndex;
404
             }
495
             }
405
         }
496
         }
406
 
497
 
407
-
408
         private void addToListboxItem(object info)
498
         private void addToListboxItem(object info)
409
         {
499
         {
410
             if (listBoxShow.Items.Count > 1000)
500
             if (listBoxShow.Items.Count > 1000)
411
             {
501
             {
412
                 listBoxShow.Items.Remove(0);
502
                 listBoxShow.Items.Remove(0);
413
-//                listBoxShow.Items.Clear();
503
+                //                listBoxShow.Items.Clear();
414
             }
504
             }
415
 
505
 
416
             Console.WriteLine(info);
506
             Console.WriteLine(info);
418
             listBoxShow.TopIndex = listBoxShow.Items.Count - 1;
508
             listBoxShow.TopIndex = listBoxShow.Items.Count - 1;
419
         }
509
         }
420
 
510
 
421
-
422
         private void rightMenuClearInfo_Click(object sender, EventArgs e)
511
         private void rightMenuClearInfo_Click(object sender, EventArgs e)
423
         {
512
         {
424
             listBoxShow.Items.Clear();
513
             listBoxShow.Items.Clear();
461
             }
550
             }
462
         }
551
         }
463
 
552
 
464
-        /// <summary>
465
-        /// 压力测试
466
-        /// </summary>
467
-        private void btnPressureTest_Click(object sender, EventArgs e)
468
-        {
469
-            ip = tbIpaddress.Text.Trim();
470
-            port = tbPort.Text.Trim();
471
-
472
-            int count = int.Parse(tbPresureTestCount.Text);
473
-
474
-            ThreadPool.QueueUserWorkItem(o =>
475
-            {
476
-                for (int i = 1024; i < 1024 + count; i++)
477
-                {
478
-                    SocketHelper.TcpClients clientx = new SocketHelper.TcpClients(); //初始化类库  
479
-                    clientx.InitSocket(ip, int.Parse(port));
480
-                    clientx.Start();
481
-
482
-                    string loginCmd = "7e7e7e";
483
-                    loginCmd += "4442832e" + i;
484
-                    loginCmd += "820014383938363032423131393135353034373938" + i;
485
-                    loginCmd = Utils.calcCrcCode(loginCmd);
486
-                    sockeTcpClients.SendData(HexUtil.hexToBytes(loginCmd));
487
-                    Thread.Sleep(200);
488
-                }
489
-            });
490
-        }
491
-
492
         private void listBoxShow_DoubleClick(object sender, EventArgs e)
553
         private void listBoxShow_DoubleClick(object sender, EventArgs e)
493
         {
554
         {
494
             int index = listBoxShow.SelectedIndex;
555
             int index = listBoxShow.SelectedIndex;
505
                         ifs = ifs.Replace("[", "").Replace("]", "");
566
                         ifs = ifs.Replace("[", "").Replace("]", "");
506
                         if (!info.Equals(""))
567
                         if (!info.Equals(""))
507
                         {
568
                         {
508
-//                            MessageBox.Show(ifs);
569
+                            //                            MessageBox.Show(ifs);
509
                             AnaProtocol ap = new AnaProtocol(ifs);
570
                             AnaProtocol ap = new AnaProtocol(ifs);
510
                             ap.ShowDialog();
571
                             ap.ShowDialog();
511
                         }
572
                         }
514
             }
575
             }
515
         }
576
         }
516
 
577
 
517
-        private void buttonCmdManager_Click(object sender, EventArgs e)
518
-        {
519
-            InfoEditor ie = new InfoEditor();
520
-            ie.ShowDialog();
521
-        }
522
-
523
-        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
524
-        {
525
-            timerHeartBeat.Enabled = false;
526
-            try
527
-            {
528
-                sockeTcpClients.Stop();
529
-            }
530
-            catch (Exception exception)
531
-            {
532
-            }
533
-            finally
534
-            {
535
-                sockeTcpClients = null;
536
-            }
537
-
538
-            AccsessDbLoader.getInstance().closeConnection();
539
-        }
540
-
541
-        private void btnTextCmd_Click(object sender, EventArgs e)
542
-        {
543
-            //beta test tool
544
-            if (tfTmpSendData.Text.Trim().ToLower().Equals("pre"))
545
-            {
546
-                btnPressureTest.Visible = !btnPressureTest.Visible;
547
-                tbPresureTestCount.Visible = !tbPresureTestCount.Visible;
548
-                label4.Visible = !label4.Visible;
549
-            }
550
-
551
-//            string code = Utils.calcCrcCode("7e7e7e123456789abc20000701010107030001");
552
-//            code = Utils.calcCrcCode("7e7e7e123456789abc10000501010107023f");
553
-//            Console.WriteLine(code);
554
-
555
-//            handleResponse(null, code);
578
+        #endregion
556
 
579
 
557
 
580
 
558
-            /*try
559
-            {
560
-                Dictionary<string, string> abc = AccsessDbLoader.getInstance().getUserIdInfo();
561
-                MessageBox.Show(abc.Count + "");
562
-                string ac = abc["0400"];
563
-                MessageBox.Show(ac);
564
-            }
565
-            catch (Exception exception)
566
-            {
567
-                Console.WriteLine(exception);
568
-            }*/
569
-        }
581
+        #region 检验工具类
570
 
582
 
571
         private void toolStripTextBoxHbtime_KeyPress(object sender, KeyPressEventArgs e)
583
         private void toolStripTextBoxHbtime_KeyPress(object sender, KeyPressEventArgs e)
572
         {
584
         {
576
             }
588
             }
577
         }
589
         }
578
 
590
 
579
-        private void ToolStripMenuItemLogHb_Click(object sender, EventArgs e)
580
-        {
581
-            ToolStripMenuItemLogHb.Checked = !ToolStripMenuItemLogHb.Checked;
582
-        }
583
-
584
 
591
 
585
         private void checkLogin(bool isLogin)
592
         private void checkLogin(bool isLogin)
586
         {
593
         {
589
                 btnLogin.Enabled = false;
596
                 btnLogin.Enabled = false;
590
                 btnQuickLogout.Enabled = true;
597
                 btnQuickLogout.Enabled = true;
591
                 btnSendData.Enabled = true;
598
                 btnSendData.Enabled = true;
592
-                ToolStripMenuItemHbStart.Enabled = true;
599
+                ToolStripMenuItemHbStart.Enabled = true; //开启心中的点击选项
600
+                if (StripMenuItemLoSucHb.Checked)
601
+                {
602
+                    //如果勾选了登录成功并心跳
603
+                    timerHeartBeat.Enabled = true;
604
+                }
593
             }
605
             }
594
             else
606
             else
595
             {
607
             {
596
                 btnLogin.Enabled = true;
608
                 btnLogin.Enabled = true;
597
                 btnQuickLogout.Enabled = false;
609
                 btnQuickLogout.Enabled = false;
598
                 btnSendData.Enabled = false;
610
                 btnSendData.Enabled = false;
611
+                ToolStripMenuItemHbStart.Checked = false;
599
                 ToolStripMenuItemHbStart.Enabled = false;
612
                 ToolStripMenuItemHbStart.Enabled = false;
613
+                timerHeartBeat.Enabled = false;
600
             }
614
             }
601
         }
615
         }
602
 
616
 
603
-        private void ToolStripMenuItemHbStart_CheckStateChanged(object sender, EventArgs e)
604
-        {
605
-            timerHeartBeat.Enabled = ToolStripMenuItemHbStart.Checked;
606
-        }
607
-
608
-        private void ToolStripMenuItemHbStart_Click(object sender, EventArgs e)
609
-        {
610
-        }
617
+        #endregion
611
     }
618
     }
612
 }
619
 }

+ 1 - 1
GWSocketClient/GWSocketClient.csproj 查看文件

5
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7
     <ProjectGuid>{1E7C256A-9CA5-4937-A5DD-7F281A2EBB21}</ProjectGuid>
7
     <ProjectGuid>{1E7C256A-9CA5-4937-A5DD-7F281A2EBB21}</ProjectGuid>
8
-    <OutputType>WinExe</OutputType>
8
+    <OutputType>Exe</OutputType>
9
     <RootNamespace>GWSocketClient</RootNamespace>
9
     <RootNamespace>GWSocketClient</RootNamespace>
10
     <AssemblyName>GWSocketClient</AssemblyName>
10
     <AssemblyName>GWSocketClient</AssemblyName>
11
     <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
11
     <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>

+ 1 - 1
GWSocketClient/Properties/AssemblyInfo.cs 查看文件

6
 // 控制。更改这些特性值可修改
6
 // 控制。更改这些特性值可修改
7
 // 与程序集关联的信息。
7
 // 与程序集关联的信息。
8
 [assembly: AssemblyTitle("GWSocketClient")]
8
 [assembly: AssemblyTitle("GWSocketClient")]
9
-[assembly: AssemblyDescription("")]
9
+[assembly: AssemblyDescription("DTU模拟器")]
10
 [assembly: AssemblyConfiguration("")]
10
 [assembly: AssemblyConfiguration("")]
11
 [assembly: AssemblyCompany("Vcarecity")]
11
 [assembly: AssemblyCompany("Vcarecity")]
12
 [assembly: AssemblyProduct("GWSocketClient")]
12
 [assembly: AssemblyProduct("GWSocketClient")]