Bladeren bron

add response

张泳健 8 jaren geleden
bovenliggende
commit
368b071c5d

BIN
.vs/GWSocketClient/v15/.suo Bestand weergeven


+ 181 - 86
GWSocketClient/Form1.Designer.cs Bestand weergeven

@@ -28,7 +28,18 @@
28 28
         /// </summary>
29 29
         private void InitializeComponent()
30 30
         {
31
+            this.components = new System.ComponentModel.Container();
32
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
31 33
             this.groupBox1 = new System.Windows.Forms.GroupBox();
34
+            this.tfTmpSendData = new System.Windows.Forms.TextBox();
35
+            this.tbCCID = new System.Windows.Forms.TextBox();
36
+            this.label5 = new System.Windows.Forms.Label();
37
+            this.btnPressureTest = new System.Windows.Forms.Button();
38
+            this.label4 = new System.Windows.Forms.Label();
39
+            this.tbPresureTestCount = new System.Windows.Forms.TextBox();
40
+            this.btnSendData = new System.Windows.Forms.Button();
41
+            this.btnQuickLogout = new System.Windows.Forms.Button();
42
+            this.btnLogin = new System.Windows.Forms.Button();
32 43
             this.tbEquipmentAddress = new System.Windows.Forms.TextBox();
33 44
             this.tbPort = new System.Windows.Forms.TextBox();
34 45
             this.label3 = new System.Windows.Forms.Label();
@@ -37,31 +48,35 @@
37 48
             this.label1 = new System.Windows.Forms.Label();
38 49
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
39 50
             this.文件FToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
51
+            this.tsmiLoadXml = new System.Windows.Forms.ToolStripMenuItem();
40 52
             this.statusStrip1 = new System.Windows.Forms.StatusStrip();
41 53
             this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
42 54
             this.tsslEquipmentAddress = new System.Windows.Forms.ToolStripStatusLabel();
43
-            this.btnLogin = new System.Windows.Forms.Button();
44
-            this.btnQuickLogout = new System.Windows.Forms.Button();
45
-            this.btnSendData = new System.Windows.Forms.Button();
46
-            this.tbPresureTestCount = new System.Windows.Forms.TextBox();
47
-            this.label4 = new System.Windows.Forms.Label();
48
-            this.btnPressureTest = new System.Windows.Forms.Button();
49
-            this.tbCCID = new System.Windows.Forms.TextBox();
50
-            this.label5 = new System.Windows.Forms.Label();
51 55
             this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
52 56
             this.tsslCCIDLEN = new System.Windows.Forms.ToolStripStatusLabel();
53 57
             this.groupBox2 = new System.Windows.Forms.GroupBox();
54 58
             this.listBoxShow = new System.Windows.Forms.ListBox();
59
+            this.cmslistboxRightMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
60
+            this.rightMenuCopyCmd = new System.Windows.Forms.ToolStripMenuItem();
61
+            this.label6 = new System.Windows.Forms.Label();
62
+            this.tfTmpResponse = new System.Windows.Forms.TextBox();
63
+            this.label7 = new System.Windows.Forms.Label();
64
+            this.rightMenuClearInfo = new System.Windows.Forms.ToolStripMenuItem();
55 65
             this.groupBox1.SuspendLayout();
56 66
             this.menuStrip1.SuspendLayout();
57 67
             this.statusStrip1.SuspendLayout();
58 68
             this.groupBox2.SuspendLayout();
69
+            this.cmslistboxRightMenu.SuspendLayout();
59 70
             this.SuspendLayout();
60 71
             // 
61 72
             // groupBox1
62 73
             // 
63 74
             this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
64 75
             | System.Windows.Forms.AnchorStyles.Right)));
76
+            this.groupBox1.Controls.Add(this.label7);
77
+            this.groupBox1.Controls.Add(this.tfTmpResponse);
78
+            this.groupBox1.Controls.Add(this.label6);
79
+            this.groupBox1.Controls.Add(this.tfTmpSendData);
65 80
             this.groupBox1.Controls.Add(this.tbCCID);
66 81
             this.groupBox1.Controls.Add(this.label5);
67 82
             this.groupBox1.Controls.Add(this.btnPressureTest);
@@ -78,11 +93,96 @@
78 93
             this.groupBox1.Controls.Add(this.label1);
79 94
             this.groupBox1.Location = new System.Drawing.Point(12, 28);
80 95
             this.groupBox1.Name = "groupBox1";
81
-            this.groupBox1.Size = new System.Drawing.Size(883, 93);
96
+            this.groupBox1.Size = new System.Drawing.Size(883, 104);
82 97
             this.groupBox1.TabIndex = 0;
83 98
             this.groupBox1.TabStop = false;
84 99
             this.groupBox1.Text = "groupBox1";
85 100
             // 
101
+            // tfTmpSendData
102
+            // 
103
+            this.tfTmpSendData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
104
+            | System.Windows.Forms.AnchorStyles.Right)));
105
+            this.tfTmpSendData.Location = new System.Drawing.Point(415, 72);
106
+            this.tfTmpSendData.Name = "tfTmpSendData";
107
+            this.tfTmpSendData.Size = new System.Drawing.Size(462, 21);
108
+            this.tfTmpSendData.TabIndex = 13;
109
+            // 
110
+            // tbCCID
111
+            // 
112
+            this.tbCCID.ForeColor = System.Drawing.Color.Blue;
113
+            this.tbCCID.Location = new System.Drawing.Point(464, 14);
114
+            this.tbCCID.Name = "tbCCID";
115
+            this.tbCCID.Size = new System.Drawing.Size(294, 21);
116
+            this.tbCCID.TabIndex = 12;
117
+            this.tbCCID.Text = "3839383630324231313931353530343739383737";
118
+            this.tbCCID.TextChanged += new System.EventHandler(this.tbCCID_TextChanged);
119
+            // 
120
+            // label5
121
+            // 
122
+            this.label5.AutoSize = true;
123
+            this.label5.Location = new System.Drawing.Point(423, 17);
124
+            this.label5.Name = "label5";
125
+            this.label5.Size = new System.Drawing.Size(35, 12);
126
+            this.label5.TabIndex = 11;
127
+            this.label5.Text = "CCCID";
128
+            // 
129
+            // btnPressureTest
130
+            // 
131
+            this.btnPressureTest.Location = new System.Drawing.Point(375, 45);
132
+            this.btnPressureTest.Name = "btnPressureTest";
133
+            this.btnPressureTest.Size = new System.Drawing.Size(75, 23);
134
+            this.btnPressureTest.TabIndex = 10;
135
+            this.btnPressureTest.Text = "压力测试";
136
+            this.btnPressureTest.UseVisualStyleBackColor = true;
137
+            // 
138
+            // label4
139
+            // 
140
+            this.label4.AutoSize = true;
141
+            this.label4.Location = new System.Drawing.Point(252, 50);
142
+            this.label4.Name = "label4";
143
+            this.label4.Size = new System.Drawing.Size(53, 12);
144
+            this.label4.TabIndex = 9;
145
+            this.label4.Text = "压力测试";
146
+            // 
147
+            // tbPresureTestCount
148
+            // 
149
+            this.tbPresureTestCount.ForeColor = System.Drawing.Color.Blue;
150
+            this.tbPresureTestCount.Location = new System.Drawing.Point(312, 47);
151
+            this.tbPresureTestCount.Name = "tbPresureTestCount";
152
+            this.tbPresureTestCount.Size = new System.Drawing.Size(56, 21);
153
+            this.tbPresureTestCount.TabIndex = 8;
154
+            this.tbPresureTestCount.Text = "100";
155
+            // 
156
+            // btnSendData
157
+            // 
158
+            this.btnSendData.Location = new System.Drawing.Point(170, 45);
159
+            this.btnSendData.Name = "btnSendData";
160
+            this.btnSendData.Size = new System.Drawing.Size(75, 23);
161
+            this.btnSendData.TabIndex = 7;
162
+            this.btnSendData.Text = "发送数据";
163
+            this.btnSendData.UseVisualStyleBackColor = true;
164
+            this.btnSendData.Click += new System.EventHandler(this.btnSendData_Click);
165
+            // 
166
+            // btnQuickLogout
167
+            // 
168
+            this.btnQuickLogout.Location = new System.Drawing.Point(88, 45);
169
+            this.btnQuickLogout.Name = "btnQuickLogout";
170
+            this.btnQuickLogout.Size = new System.Drawing.Size(75, 23);
171
+            this.btnQuickLogout.TabIndex = 6;
172
+            this.btnQuickLogout.Text = "退出登录";
173
+            this.btnQuickLogout.UseVisualStyleBackColor = true;
174
+            this.btnQuickLogout.Click += new System.EventHandler(this.btnQuickLogout_Click);
175
+            // 
176
+            // btnLogin
177
+            // 
178
+            this.btnLogin.Location = new System.Drawing.Point(6, 45);
179
+            this.btnLogin.Name = "btnLogin";
180
+            this.btnLogin.Size = new System.Drawing.Size(75, 23);
181
+            this.btnLogin.TabIndex = 3;
182
+            this.btnLogin.Text = "登录";
183
+            this.btnLogin.UseVisualStyleBackColor = true;
184
+            this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
185
+            // 
86 186
             // tbEquipmentAddress
87 187
             // 
88 188
             this.tbEquipmentAddress.ForeColor = System.Drawing.Color.Blue;
@@ -150,10 +250,19 @@
150 250
             // 
151 251
             // 文件FToolStripMenuItem
152 252
             // 
253
+            this.文件FToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
254
+            this.tsmiLoadXml});
153 255
             this.文件FToolStripMenuItem.Name = "文件FToolStripMenuItem";
154 256
             this.文件FToolStripMenuItem.Size = new System.Drawing.Size(58, 21);
155 257
             this.文件FToolStripMenuItem.Text = "文件(&F)";
156 258
             // 
259
+            // tsmiLoadXml
260
+            // 
261
+            this.tsmiLoadXml.Name = "tsmiLoadXml";
262
+            this.tsmiLoadXml.Size = new System.Drawing.Size(166, 22);
263
+            this.tsmiLoadXml.Text = "加载协议XML(&X)";
264
+            this.tsmiLoadXml.Click += new System.EventHandler(this.tsmiLoadXml_Click);
265
+            // 
157 266
             // statusStrip1
158 267
             // 
159 268
             this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -179,81 +288,6 @@
179 288
             this.tsslEquipmentAddress.Size = new System.Drawing.Size(25, 17);
180 289
             this.tsslEquipmentAddress.Text = "6.0";
181 290
             // 
182
-            // btnLogin
183
-            // 
184
-            this.btnLogin.Location = new System.Drawing.Point(6, 45);
185
-            this.btnLogin.Name = "btnLogin";
186
-            this.btnLogin.Size = new System.Drawing.Size(75, 23);
187
-            this.btnLogin.TabIndex = 3;
188
-            this.btnLogin.Text = "登录";
189
-            this.btnLogin.UseVisualStyleBackColor = true;
190
-            this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
191
-            // 
192
-            // btnQuickLogout
193
-            // 
194
-            this.btnQuickLogout.Location = new System.Drawing.Point(88, 45);
195
-            this.btnQuickLogout.Name = "btnQuickLogout";
196
-            this.btnQuickLogout.Size = new System.Drawing.Size(75, 23);
197
-            this.btnQuickLogout.TabIndex = 6;
198
-            this.btnQuickLogout.Text = "退出登录";
199
-            this.btnQuickLogout.UseVisualStyleBackColor = true;
200
-            this.btnQuickLogout.Click += new System.EventHandler(this.btnQuickLogout_Click);
201
-            // 
202
-            // btnSendData
203
-            // 
204
-            this.btnSendData.Location = new System.Drawing.Point(170, 45);
205
-            this.btnSendData.Name = "btnSendData";
206
-            this.btnSendData.Size = new System.Drawing.Size(75, 23);
207
-            this.btnSendData.TabIndex = 7;
208
-            this.btnSendData.Text = "发送数据";
209
-            this.btnSendData.UseVisualStyleBackColor = true;
210
-            // 
211
-            // tbPresureTestCount
212
-            // 
213
-            this.tbPresureTestCount.ForeColor = System.Drawing.Color.Blue;
214
-            this.tbPresureTestCount.Location = new System.Drawing.Point(312, 47);
215
-            this.tbPresureTestCount.Name = "tbPresureTestCount";
216
-            this.tbPresureTestCount.Size = new System.Drawing.Size(56, 21);
217
-            this.tbPresureTestCount.TabIndex = 8;
218
-            this.tbPresureTestCount.Text = "100";
219
-            // 
220
-            // label4
221
-            // 
222
-            this.label4.AutoSize = true;
223
-            this.label4.Location = new System.Drawing.Point(252, 50);
224
-            this.label4.Name = "label4";
225
-            this.label4.Size = new System.Drawing.Size(53, 12);
226
-            this.label4.TabIndex = 9;
227
-            this.label4.Text = "压力测试";
228
-            // 
229
-            // btnPressureTest
230
-            // 
231
-            this.btnPressureTest.Location = new System.Drawing.Point(375, 45);
232
-            this.btnPressureTest.Name = "btnPressureTest";
233
-            this.btnPressureTest.Size = new System.Drawing.Size(75, 23);
234
-            this.btnPressureTest.TabIndex = 10;
235
-            this.btnPressureTest.Text = "压力测试";
236
-            this.btnPressureTest.UseVisualStyleBackColor = true;
237
-            // 
238
-            // tbCCID
239
-            // 
240
-            this.tbCCID.ForeColor = System.Drawing.Color.Blue;
241
-            this.tbCCID.Location = new System.Drawing.Point(464, 14);
242
-            this.tbCCID.Name = "tbCCID";
243
-            this.tbCCID.Size = new System.Drawing.Size(294, 21);
244
-            this.tbCCID.TabIndex = 12;
245
-            this.tbCCID.Text = "3839383630324231313931353530343739383737";
246
-            this.tbCCID.TextChanged += new System.EventHandler(this.tbCCID_TextChanged);
247
-            // 
248
-            // label5
249
-            // 
250
-            this.label5.AutoSize = true;
251
-            this.label5.Location = new System.Drawing.Point(423, 17);
252
-            this.label5.Name = "label5";
253
-            this.label5.Size = new System.Drawing.Size(35, 12);
254
-            this.label5.TabIndex = 11;
255
-            this.label5.Text = "CCCID";
256
-            // 
257 291
             // toolStripStatusLabel2
258 292
             // 
259 293
             this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
@@ -284,13 +318,63 @@
284 318
             this.listBoxShow.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
285 319
             | System.Windows.Forms.AnchorStyles.Left) 
286 320
             | System.Windows.Forms.AnchorStyles.Right)));
321
+            this.listBoxShow.ContextMenuStrip = this.cmslistboxRightMenu;
322
+            this.listBoxShow.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
287 323
             this.listBoxShow.FormattingEnabled = true;
288
-            this.listBoxShow.ItemHeight = 12;
324
+            this.listBoxShow.HorizontalScrollbar = true;
325
+            this.listBoxShow.ItemHeight = 14;
289 326
             this.listBoxShow.Location = new System.Drawing.Point(8, 20);
290 327
             this.listBoxShow.Name = "listBoxShow";
291
-            this.listBoxShow.Size = new System.Drawing.Size(869, 184);
328
+            this.listBoxShow.Size = new System.Drawing.Size(869, 172);
292 329
             this.listBoxShow.TabIndex = 0;
293 330
             // 
331
+            // cmslistboxRightMenu
332
+            // 
333
+            this.cmslistboxRightMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
334
+            this.rightMenuCopyCmd,
335
+            this.rightMenuClearInfo});
336
+            this.cmslistboxRightMenu.Name = "cmslistboxRightMenu";
337
+            this.cmslistboxRightMenu.Size = new System.Drawing.Size(141, 48);
338
+            // 
339
+            // rightMenuCopyCmd
340
+            // 
341
+            this.rightMenuCopyCmd.Name = "rightMenuCopyCmd";
342
+            this.rightMenuCopyCmd.Size = new System.Drawing.Size(152, 22);
343
+            this.rightMenuCopyCmd.Text = "复制指令(&C)";
344
+            this.rightMenuCopyCmd.Click += new System.EventHandler(this.rightMenuCopyCmd_Click);
345
+            // 
346
+            // label6
347
+            // 
348
+            this.label6.AutoSize = true;
349
+            this.label6.Location = new System.Drawing.Point(6, 75);
350
+            this.label6.Name = "label6";
351
+            this.label6.Size = new System.Drawing.Size(35, 12);
352
+            this.label6.TabIndex = 14;
353
+            this.label6.Text = "回复:";
354
+            // 
355
+            // tfTmpResponse
356
+            // 
357
+            this.tfTmpResponse.Location = new System.Drawing.Point(47, 72);
358
+            this.tfTmpResponse.Name = "tfTmpResponse";
359
+            this.tfTmpResponse.Size = new System.Drawing.Size(321, 21);
360
+            this.tfTmpResponse.TabIndex = 15;
361
+            // 
362
+            // label7
363
+            // 
364
+            this.label7.AutoSize = true;
365
+            this.label7.Location = new System.Drawing.Point(374, 75);
366
+            this.label7.Name = "label7";
367
+            this.label7.Size = new System.Drawing.Size(29, 12);
368
+            this.label7.TabIndex = 16;
369
+            this.label7.Text = "发送";
370
+            // 
371
+            // rightMenuClearInfo
372
+            // 
373
+            this.rightMenuClearInfo.Name = "rightMenuClearInfo";
374
+            this.rightMenuClearInfo.Size = new System.Drawing.Size(152, 22);
375
+            this.rightMenuClearInfo.Text = "清空信息(&L)";
376
+            this.rightMenuClearInfo.Click += new System.EventHandler(this.rightMenuClearInfo_Click);
377
+            // 
294 378
             // Form1
295 379
             // 
296 380
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -300,7 +384,9 @@
300 384
             this.Controls.Add(this.statusStrip1);
301 385
             this.Controls.Add(this.groupBox1);
302 386
             this.Controls.Add(this.menuStrip1);
387
+            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
303 388
             this.Name = "Form1";
389
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
304 390
             this.Text = "Form1";
305 391
             this.Load += new System.EventHandler(this.Form1_Load);
306 392
             this.groupBox1.ResumeLayout(false);
@@ -310,6 +396,7 @@
310 396
             this.statusStrip1.ResumeLayout(false);
311 397
             this.statusStrip1.PerformLayout();
312 398
             this.groupBox2.ResumeLayout(false);
399
+            this.cmslistboxRightMenu.ResumeLayout(false);
313 400
             this.ResumeLayout(false);
314 401
             this.PerformLayout();
315 402
 
@@ -341,6 +428,14 @@
341 428
         private System.Windows.Forms.ToolStripStatusLabel tsslCCIDLEN;
342 429
         private System.Windows.Forms.GroupBox groupBox2;
343 430
         private System.Windows.Forms.ListBox listBoxShow;
431
+        private System.Windows.Forms.ToolStripMenuItem tsmiLoadXml;
432
+        private System.Windows.Forms.TextBox tfTmpSendData;
433
+        private System.Windows.Forms.ContextMenuStrip cmslistboxRightMenu;
434
+        private System.Windows.Forms.ToolStripMenuItem rightMenuCopyCmd;
435
+        private System.Windows.Forms.Label label7;
436
+        private System.Windows.Forms.TextBox tfTmpResponse;
437
+        private System.Windows.Forms.Label label6;
438
+        private System.Windows.Forms.ToolStripMenuItem rightMenuClearInfo;
344 439
     }
345 440
 }
346 441
 

+ 158 - 7
GWSocketClient/Form1.cs Bestand weergeven

@@ -5,9 +5,12 @@ using System.Data;
5 5
 using System.Drawing;
6 6
 using System.Linq;
7 7
 using System.Text;
8
+using System.Text.RegularExpressions;
9
+using System.Threading;
8 10
 using System.Threading.Tasks;
9 11
 using System.Windows.Forms;
10 12
 using GWSocketClient.util;
13
+using GWSocketClient.xml;
11 14
 using XuanJiSocket;
12 15
 
13 16
 
@@ -23,22 +26,102 @@ namespace GWSocketClient
23 26
         private string ip;
24 27
         private string port;
25 28
         private SocketHelper.TcpClients sockeTcpClients;
29
+        private VcarecityPD vcarecityProtocolBean;
26 30
 
27 31
         private void Form1_Load(object sender, EventArgs e)
28 32
         {
33
+            XmlLoader xmlLoader = new XmlLoader();
34
+            vcarecityProtocolBean = xmlLoader.loadXml();
35
+            this.Text = vcarecityProtocolBean.ProtocolName + " - " + vcarecityProtocolBean.ProtocolNo + " - " +
36
+                        vcarecityProtocolBean.ProtocolStartSymbol;
37
+
38
+
29 39
             SocketHelper.pushSockets = new SocketHelper.PushSockets(receiveData); //注册推送器
30 40
             sockeTcpClients = new SocketHelper.TcpClients();
31 41
             ip = tbIpaddress.Text.Trim();
32 42
             port = tbPort.Text.Trim();
33 43
         }
34 44
 
45
+
35 46
         private void receiveData(SocketHelper.Sockets sks)
36 47
         {
37
-            byte[] buffer = new byte[sks.Offset];
38
-            Array.Copy(sks.RecBuffer, buffer, sks.Offset);
39
-            string byteToHexStr = HexUtil.byteToHexStr(buffer);
48
+            this.Invoke(new ThreadStart(delegate
49
+            {
50
+                if (sks.ex != null)
51
+                {
52
+                    switch (sks.ErrorCode)
53
+                    {
54
+                        case SocketHelper.Sockets.ErrorCodes.objectNull:
55
+                            break;
56
+                        case SocketHelper.Sockets.ErrorCodes.ConnectError:
57
+                            break;
58
+                        case SocketHelper.Sockets.ErrorCodes.ConnectSuccess:
59
+                            addToListboxItem("状态信息:连接成功.!");
60
+                            break;
61
+                        case SocketHelper.Sockets.ErrorCodes.TrySendData:
62
+                            break;
63
+                        default:
64
+                            break;
65
+                    }
66
+                    addToListboxItem(string.Format("客户端信息{0}", sks.ex));
67
+                }
68
+                else
69
+                {
70
+                    byte[] buffer = new byte[sks.Offset];
71
+                    Array.Copy(sks.RecBuffer, buffer, sks.Offset);
72
+                    string byteToHexStr = HexUtil.byteToHexStr(buffer);
73
+                    if (byteToHexStr.Equals("ServerOff"))
74
+                    {
75
+                        addToListboxItem("状态信息:服务端主动关闭!");
76
+                    }
77
+                    else
78
+                    {
79
+                        if (!byteToHexStr.Equals(""))
80
+                        {
81
+                            addToListboxItem(string.Format("收到服务端{0}发来消息:[{1}]", sks.Ip, byteToHexStr));
82
+                            handleResponse(sks, byteToHexStr);
83
+                        }
84
+                        else
85
+                        {
86
+                            addToListboxItem("状态信息:服务端主动关闭!");
87
+                            sockeTcpClients.Stop();
88
+                        }
89
+                        //                    listBoxShow.Text += "\r\n";
90
+                        //                    listBoxShow.Text += string.Format("服务端{0}发来消息:{1}", sks.Ip, byteToHexStr);
91
+                    }
92
+                }
93
+            }));
94
+        }
95
+
96
+        //处理回复信息
97
+        private void handleResponse(SocketHelper.Sockets sks, string reqData)
98
+        {
99
+            string resp = tfTmpSendData.Text.Trim();
100
+
101
+            if (resp.Equals(""))
102
+            {
103
+                resp = "00";
104
+            }
105
+
106
+            string functionWord = reqData.Substring(18, 2);
107
+            int funcode = Utils.hexToTen(functionWord);
108
+
40 109
 
41
-            MessageBox.Show("1" + byteToHexStr);
110
+            if (funcode >= 80 || funcode == 1 || funcode == 2)
111
+            {
112
+                return;
113
+            }
114
+            funcode = funcode + 128;
115
+            functionWord = Utils.stringWith0(Utils.tenToHex(funcode), 2);
116
+            string cmd = reqData.Substring(0, 18) + functionWord;
117
+            string data = reqData.Substring(24, 10) + resp;
118
+            cmd = cmd + Utils.stringWith0(Utils.tenToHex(data.Length / 2), 4) + data;
119
+            cmd = Utils.calcCrcCode(cmd);
120
+
121
+            addToListboxItem(string.Format("回复服务端{0}回应消息:[{1}]", sks.Ip, cmd));
122
+
123
+            byte[] ts = HexUtil.hexToBytes(cmd);
124
+            sockeTcpClients.SendData(ts);
42 125
         }
43 126
 
44 127
         private void tbEquipmentAddress_TextChanged(object sender, EventArgs e)
@@ -58,14 +141,19 @@ namespace GWSocketClient
58 141
                 sockeTcpClients.InitSocket(ip, int.Parse(port));
59 142
                 sockeTcpClients.Start();
60 143
 
61
-                byte[] ts = HexUtil.hexToBytes("7e7e7e4442832e833c8200143839383630324231313931353530343739383737f7");
144
+                string loginCmd = "7e7e7e4442832e833c8200143839383630324231313931353530343739383737f7";
145
+                //发送登录命令
146
+                byte[] ts = HexUtil.hexToBytes(loginCmd);
147
+
148
+                addToListboxItem(string.Format("发送到服务端:[{0}]", loginCmd));
149
+
62 150
                 sockeTcpClients.SendData(ts);
63 151
             }
64 152
             catch (Exception ex)
65 153
             {
66
-//                statuslist.Items.Add(string.Format("连接失败!原因:{0}", ex.Message));
67
-
154
+//                statuslist.Items.Add(string.Format("连接失败!原因:{0}", ex.Message
68 155
                 btnLogin.Enabled = true;
156
+                Console.WriteLine(ex.Message);
69 157
             }
70 158
         }
71 159
 
@@ -80,5 +168,68 @@ namespace GWSocketClient
80 168
         {
81 169
             sockeTcpClients.Stop();
82 170
         }
171
+
172
+        private void tsmiLoadXml_Click(object sender, EventArgs e)
173
+        {
174
+        }
175
+
176
+        private void btnSendData_Click(object sender, EventArgs e)
177
+        {
178
+            string trim = tfTmpSendData.Text.Trim();
179
+            trim = trim.Replace("\n", "").Replace("\r", "").Replace("\t", "").Replace(" ", "").Replace("-", "");
180
+
181
+            if (!trim.Equals(""))
182
+            {
183
+                byte[] ts = HexUtil.hexToBytes(trim);
184
+
185
+                addToListboxItem(string.Format("发送到服务端:[{0}]", trim));
186
+
187
+                sockeTcpClients.SendData(ts);
188
+            }
189
+        }
190
+
191
+        private void rightMenuCopyCmd_Click(object sender, EventArgs e)
192
+        {
193
+            int index = listBoxShow.SelectedIndex;
194
+            if (index > 0 && index < listBoxShow.Items.Count)
195
+            {
196
+                string info = listBoxShow.SelectedItem.ToString();
197
+                if (!info.Equals(""))
198
+                {
199
+                    if (info.Contains("["))
200
+                    {
201
+                        Regex reg = new Regex(@"\[\w+\]"); //注意里面的引号 要用双引号表示,而不是用反斜
202
+                        Match match = reg.Match(info);
203
+                        string ifs = match.ToString();
204
+                        ifs = ifs.Replace("[", "").Replace("]", "");
205
+                        if (!info.Equals(""))
206
+                        {
207
+                            Clipboard.SetDataObject(ifs);
208
+                        }
209
+                        else
210
+                        {
211
+                            Clipboard.SetDataObject(info);
212
+                        }
213
+                    }
214
+                }
215
+            }
216
+        }
217
+
218
+
219
+        private void addToListboxItem(object info)
220
+        {
221
+            if (listBoxShow.Items.Count > 1000)
222
+                listBoxShow.Items.Clear();
223
+
224
+            Console.WriteLine(info);
225
+            listBoxShow.Items.Add(info);
226
+            listBoxShow.TopIndex = listBoxShow.Items.Count - 1;
227
+        }
228
+
229
+
230
+        private void rightMenuClearInfo_Click(object sender, EventArgs e)
231
+        {
232
+            listBoxShow.Items.Clear();
233
+        }
83 234
     }
84 235
 }

Diff onderdrukt omdat het te groot bestand
+ 1136 - 0
GWSocketClient/Form1.resx


BIN
GWSocketClient/GWSocket.ico Bestand weergeven


BIN
GWSocketClient/GWSocket.jpg Bestand weergeven


+ 18 - 1
GWSocketClient/GWSocketClient.csproj Bestand weergeven

@@ -5,7 +5,7 @@
5 5
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6 6
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7 7
     <ProjectGuid>{1E7C256A-9CA5-4937-A5DD-7F281A2EBB21}</ProjectGuid>
8
-    <OutputType>WinExe</OutputType>
8
+    <OutputType>Exe</OutputType>
9 9
     <RootNamespace>GWSocketClient</RootNamespace>
10 10
     <AssemblyName>GWSocketClient</AssemblyName>
11 11
     <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
@@ -31,6 +31,12 @@
31 31
     <ErrorReport>prompt</ErrorReport>
32 32
     <WarningLevel>4</WarningLevel>
33 33
   </PropertyGroup>
34
+  <PropertyGroup>
35
+    <StartupObject />
36
+  </PropertyGroup>
37
+  <PropertyGroup>
38
+    <ApplicationIcon>GWSocket.ico</ApplicationIcon>
39
+  </PropertyGroup>
34 40
   <ItemGroup>
35 41
     <Reference Include="System" />
36 42
     <Reference Include="System.Core" />
@@ -59,6 +65,14 @@
59 65
     <Compile Include="util\CheckUtil.cs" />
60 66
     <Compile Include="util\HexUtil.cs" />
61 67
     <Compile Include="util\Utils.cs" />
68
+    <Compile Include="xml\AFN.cs" />
69
+    <Compile Include="xml\dataItem\DataElementType.cs" />
70
+    <Compile Include="xml\dataItem\DataType.cs" />
71
+    <Compile Include="xml\dataItem\data\DataType2.cs" />
72
+    <Compile Include="xml\DItem.cs" />
73
+    <Compile Include="xml\FindUtil.cs" />
74
+    <Compile Include="xml\VcarecityPD.cs" />
75
+    <Compile Include="xml\XmlLoader.cs" />
62 76
     <EmbeddedResource Include="Form1.resx">
63 77
       <DependentUpon>Form1.cs</DependentUpon>
64 78
     </EmbeddedResource>
@@ -84,5 +98,8 @@
84 98
   <ItemGroup>
85 99
     <None Include="App.config" />
86 100
   </ItemGroup>
101
+  <ItemGroup>
102
+    <Content Include="GWSocket.ico" />
103
+  </ItemGroup>
87 104
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
88 105
 </Project>

+ 43 - 0
GWSocketClient/xml/AFN.cs Bestand weergeven

@@ -0,0 +1,43 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+using GWSocketClient.xml.dataItem;
7
+using GWSocketClient.xml.dataItem.data;
8
+
9
+namespace GWSocketClient.xml
10
+{
11
+    class AFN
12
+    {
13
+        public int afn;
14
+        public int respAfnId;
15
+        public int cmdId;
16
+        public int type;
17
+        public int check;
18
+        public int isPT;
19
+        public int dir;
20
+        public int ack;
21
+        public int status;
22
+        public int mq;
23
+
24
+        public List<DataElementType> DataElement = new List<DataElementType>();
25
+        public List<DataType2> data = new List<DataType2>();
26
+
27
+        public override string ToString()
28
+        {
29
+            return "afn=" + afn +
30
+                   ",respAfnId=" + respAfnId +
31
+                   ",cmdId=" + cmdId +
32
+                   ",type=" + type +
33
+                   ",check=" + check +
34
+                   ",isPT=" + isPT +
35
+                   ",dir=" + dir +
36
+                   ",ack=" + ack +
37
+                   ",status=" + status +
38
+                   ",mq=" + mq +
39
+                   ",DataElement.Count=" + DataElement.Count +
40
+                   ",data.Count=" + data.Count;
41
+        }
42
+    }
43
+}

+ 25 - 0
GWSocketClient/xml/DItem.cs Bestand weergeven

@@ -0,0 +1,25 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace GWSocketClient.xml
8
+{
9
+    class DItem
10
+    {
11
+        public Int32 Len;
12
+        public string Name;
13
+        public Int32 Seq;
14
+        public Int32 type;
15
+        public Int32 val;
16
+    }
17
+
18
+    class DItemComparer : IComparer<DItem>
19
+    {
20
+        public int Compare(DItem x, DItem y)
21
+        {
22
+            return x.Seq.CompareTo(y.Seq);
23
+        }
24
+    }
25
+}

+ 21 - 0
GWSocketClient/xml/FindUtil.cs Bestand weergeven

@@ -0,0 +1,21 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace GWSocketClient.xml
8
+{
9
+    class FindUtil
10
+    {
11
+        public static AFN findAFNByFunctionCode(int afnCode)
12
+        {
13
+            AFN afn = new AFN();
14
+
15
+
16
+
17
+
18
+            return afn;
19
+        }
20
+    }
21
+}

+ 28 - 0
GWSocketClient/xml/VcarecityPD.cs Bestand weergeven

@@ -0,0 +1,28 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace GWSocketClient.xml
8
+{
9
+    class VcarecityPD
10
+    {
11
+        public string ProtocolName;
12
+        public int ProtocolNo;
13
+        public string ProtocolStartSymbol;
14
+        public int ProtocolStartSymbolLen;
15
+        public string ProtocolEndSymbol;
16
+        public int ProtocolEndSymbolLen;
17
+
18
+        public DItem FAddress;
19
+        public DItem TAddress;
20
+        public DItem Function;
21
+        public DItem DataLen;
22
+        public DItem DataSeq;
23
+        public DItem DataCheck;
24
+        public DItem Sn;
25
+
26
+        public List<AFN> dataItem = new List<AFN>();
27
+    }
28
+}

+ 364 - 0
GWSocketClient/xml/XmlLoader.cs Bestand weergeven

@@ -0,0 +1,364 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+using System.Windows.Forms;
7
+using System.Xml;
8
+using GWSocketClient.xml.dataItem;
9
+using GWSocketClient.xml.dataItem.data;
10
+
11
+namespace GWSocketClient.xml
12
+{
13
+    class XmlLoader
14
+    {
15
+        private XmlDocument document;
16
+
17
+        private VcarecityPD vcarecityPd = null;
18
+        private string filePath = "";
19
+
20
+        public VcarecityPD getVcarecityPD()
21
+        {
22
+            if (vcarecityPd == null)
23
+            {
24
+                if (filePath.Equals(""))
25
+                {
26
+                    MessageBox.Show("XML路径为空!!!");
27
+                    return null;
28
+                }
29
+                loadXmlDocument(this.filePath);
30
+            }
31
+            return vcarecityPd;
32
+        }
33
+
34
+
35
+        public XmlLoader load(string xmlFilePath)
36
+        {
37
+            this.filePath = xmlFilePath;
38
+            loadXmlDocument(xmlFilePath);
39
+            return this;
40
+        }
41
+
42
+        public XmlLoader()
43
+        {
44
+            string xmlFilePath = @"D:\TestProject\GW\config\dtu.xml";
45
+            loadXmlDocument(xmlFilePath);
46
+        }
47
+
48
+        public XmlLoader(string xmlFilePath)
49
+        {
50
+            loadXmlDocument(xmlFilePath);
51
+        }
52
+
53
+        private void loadXmlDocument(string xmlFilePath)
54
+        {
55
+            vcarecityPd = new VcarecityPD();
56
+            document = new XmlDocument();
57
+            XmlReaderSettings settings = new XmlReaderSettings();
58
+            settings.IgnoreComments = true;
59
+            XmlReader reader = XmlReader.Create(xmlFilePath, settings);
60
+            document.Load(reader);
61
+            XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(document.NameTable);
62
+            xmlNamespaceManager.AddNamespace("ns2", "http://www.example.org/GolfCountryClub");
63
+
64
+            vcarecityPd = loadXml();
65
+        }
66
+
67
+        public VcarecityPD loadXml()
68
+        {
69
+            if (document.DocumentElement == null)
70
+            {
71
+                return null;
72
+            }
73
+
74
+            XmlNodeList allChildNodes = document.DocumentElement.ChildNodes;
75
+
76
+            foreach (XmlElement node in allChildNodes)
77
+            {
78
+                switch (node.Name)
79
+                {
80
+                    case "ProtocolName":
81
+                        vcarecityPd.ProtocolName = node.InnerText;
82
+//                        Console.WriteLine(node.Name + ":" + node.InnerText);
83
+                        break;
84
+                    case "ProtocolNo":
85
+                        vcarecityPd.ProtocolNo = Convert.ToInt32(node.InnerText);
86
+//                        Console.WriteLine(node.Name + ":" + node.InnerText);
87
+                        break;
88
+                    case "ProtocolStartSymbol":
89
+                        vcarecityPd.ProtocolStartSymbol = node.InnerText;
90
+//                        Console.WriteLine(node.Name + ":" + node.InnerText);
91
+                        break;
92
+                    case "ProtocolStartSymbolLen":
93
+                        vcarecityPd.ProtocolStartSymbolLen = Convert.ToInt32(node.InnerText);
94
+//                        Console.WriteLine(node.Name + ":" + node.InnerText);
95
+                        break;
96
+                    case "ProtocolEndSymbol":
97
+                        vcarecityPd.ProtocolEndSymbol = node.InnerText;
98
+//                        Console.WriteLine(node.Name + ":" + node.InnerText);
99
+                        break;
100
+                    case "ProtocolEndSymbolLen":
101
+                        vcarecityPd.ProtocolEndSymbolLen = Convert.ToInt32(node.InnerText);
102
+//                        Console.WriteLine(node.Name + ":" + node.InnerText);
103
+                        break;
104
+                    case "dataItem":
105
+//                        Console.WriteLine(node.Name + ":" + node.InnerText);
106
+                        handleDataItem(node);
107
+                        break;
108
+                    default:
109
+                        handleDItem(node);
110
+
111
+                        break;
112
+                }
113
+            }
114
+
115
+            return vcarecityPd;
116
+        }
117
+
118
+        private void handleDItem(XmlElement node)
119
+        {
120
+            switch (node.Name)
121
+            {
122
+                case "FAddress":
123
+                    vcarecityPd.FAddress = getDItem(node);
124
+                    break;
125
+                case "TAddress":
126
+                    vcarecityPd.TAddress = getDItem(node);
127
+                    break;
128
+                case "Function":
129
+                    vcarecityPd.Function = getDItem(node);
130
+                    break;
131
+                case "DataLen":
132
+                    vcarecityPd.DataLen = getDItem(node);
133
+                    break;
134
+                case "Sn":
135
+                    vcarecityPd.Sn = getDItem(node);
136
+                    break;
137
+                /*case "reverse":
138
+                    vcarecityPd.reverse = getDItem(node);
139
+                    break;*/
140
+                case "DataSeq":
141
+                    vcarecityPd.DataSeq = getDItem(node);
142
+                    break;
143
+                case "DataCheck":
144
+                    vcarecityPd.DataCheck = getDItem(node);
145
+                    break;
146
+                default:
147
+                    break;
148
+            }
149
+        }
150
+
151
+        private List<AFN> dataItems = new List<AFN>();
152
+
153
+        private void handleDataItem(XmlElement node)
154
+        {
155
+            AFN myAfn = new AFN();
156
+
157
+            #region 处理属性问题
158
+
159
+            myAfn.afn = Convert.ToInt32(node.Attributes["afn"].Value);
160
+            myAfn.respAfnId = Convert.ToInt32(node.Attributes["respAfnId"].Value);
161
+
162
+            if (node.HasAttribute("cmdId"))
163
+            {
164
+                myAfn.cmdId = Convert.ToInt32(node.Attributes["cmdId"].Value);
165
+            }
166
+            if (node.HasAttribute("type"))
167
+            {
168
+                myAfn.type = Convert.ToInt32(node.Attributes["type"].Value);
169
+            }
170
+
171
+            if (node.HasAttribute("check"))
172
+            {
173
+                myAfn.check = Convert.ToInt32(node.Attributes["check"].Value);
174
+            }
175
+
176
+            if (node.HasAttribute("isPT"))
177
+            {
178
+                myAfn.isPT = Convert.ToInt32(node.Attributes["isPT"].Value);
179
+            }
180
+
181
+            if (node.HasAttribute("dir"))
182
+            {
183
+                myAfn.dir = Convert.ToInt32(node.Attributes["dir"].Value);
184
+            }
185
+
186
+            if (node.HasAttribute("ack"))
187
+            {
188
+                myAfn.ack = Convert.ToInt32(node.Attributes["ack"].Value);
189
+            }
190
+            if (node.HasAttribute("status"))
191
+            {
192
+                myAfn.status = Convert.ToInt32(node.Attributes["status"].Value);
193
+            }
194
+            if (node.HasAttribute("mq"))
195
+            {
196
+                myAfn.mq = Convert.ToInt32(node.Attributes["mq"].Value);
197
+            }
198
+
199
+            #endregion
200
+
201
+
202
+            #region MyRegion
203
+
204
+            XmlNodeList data_DataElement = node.ChildNodes;
205
+
206
+
207
+            foreach (XmlElement ddE in data_DataElement)
208
+            {
209
+                if (ddE.Name == "DataElement")
210
+                {
211
+                    DataElementType det = handleDataElement(ddE);
212
+                    myAfn.DataElement.Add(det);
213
+                }
214
+                else if (ddE.Name == "data")
215
+                {
216
+                    DataType2 type2 = handleData(ddE);
217
+                    myAfn.data.Add(type2);
218
+                }
219
+            }
220
+
221
+            #endregion
222
+
223
+            //添加到列表中去
224
+            vcarecityPd.dataItem.Add(myAfn);
225
+        }
226
+
227
+
228
+        /*
229
+         <data>
230
+            <ElementSequence>1</ElementSequence>
231
+            <ElementLen>6</ElementLen>
232
+            <ElementName>sysDate</ElementName>
233
+            <ElementValue>ElementValue</ElementValue>
234
+            <ElementType>3</ElementType>
235
+            <ElementPrecision>0</ElementPrecision>
236
+        </data>
237
+         */
238
+        private DataType2 handleData(XmlElement ddE)
239
+        {
240
+            return handlerDataType2(ddE);
241
+        }
242
+
243
+
244
+        /*
245
+        <DataElement>
246
+            <flag>519</flag>
247
+            <num>1</num>
248
+            <data>
249
+                <d1>
250
+                    <ElementSequence>1</ElementSequence>
251
+                    <ElementLen>2</ElementLen>
252
+                    <ElementName>dataType</ElementName>
253
+                    <ElementValue>ElementValue</ElementValue>
254
+                    <ElementType>5</ElementType>
255
+                    <ElementPrecision>0</ElementPrecision>
256
+                </d1>
257
+            </data>
258
+        </DataElement>  
259
+       */
260
+        private DataElementType handleDataElement(XmlElement ddE)
261
+        {
262
+            DataElementType det = new DataElementType();
263
+
264
+            XmlNodeList de = ddE.ChildNodes;
265
+
266
+            foreach (XmlElement data in de)
267
+            {
268
+                switch (data.Name)
269
+                {
270
+                    case "flag":
271
+                        det.flag = Convert.ToInt32(data.InnerText);
272
+
273
+                        break;
274
+                    case "num":
275
+                        det.num = Convert.ToInt32(data.InnerText);
276
+
277
+                        break;
278
+                    case "data":
279
+                        XmlNodeList d1List = data.ChildNodes; //得到所有<data/>,现在来说,只有一个
280
+
281
+                        DataType d1s = new DataType();
282
+
283
+                        foreach (XmlElement d1Item in d1List)
284
+                        {
285
+                            //处理第一个<d1></d1>中的数据,这里得到一个<d1>对象
286
+                            DataType2 dataType2 = handlerDataType2(d1Item);
287
+                            d1s.d1.Add(dataType2);
288
+                        }
289
+                        det.data.Add(d1s);
290
+                        break;
291
+                }
292
+            }
293
+
294
+            return det;
295
+        }
296
+
297
+
298
+        public DItem getDItem(XmlElement node)
299
+        {
300
+            DItem ditme = new DItem();
301
+            if (node.HasAttribute("Len"))
302
+            {
303
+                ditme.Len = Convert.ToInt32(node.Attributes["Len"].Value);
304
+            }
305
+
306
+            if (node.HasAttribute("Name"))
307
+            {
308
+                ditme.Name = node.Attributes["Name"].Value;
309
+            }
310
+
311
+            if (node.HasAttribute("Seq"))
312
+            {
313
+                ditme.Seq = Convert.ToInt32(node.Attributes["Seq"].Value);
314
+            }
315
+
316
+            if (node.HasAttribute("type"))
317
+            {
318
+                ditme.type = Convert.ToInt32(node.Attributes["type"].Value);
319
+            }
320
+
321
+            if (node.HasAttribute("val"))
322
+            {
323
+                ditme.val = Convert.ToInt32(node.Attributes["val"].Value);
324
+            }
325
+
326
+            return ditme;
327
+        }
328
+
329
+
330
+        public DataType2 handlerDataType2(XmlElement d1Item)
331
+        {
332
+            XmlNodeList d1Element = d1Item.ChildNodes;
333
+            DataType2 dataType2 = new DataType2();
334
+            foreach (XmlElement jsonValue in d1Element)
335
+            {
336
+                switch (jsonValue.Name)
337
+                {
338
+                    case "ElementSequence":
339
+                        dataType2.ElementSequence = Convert.ToInt32(jsonValue.InnerText);
340
+                        break;
341
+                    case "ElementLen":
342
+                        dataType2.ElementLen = Convert.ToInt32(jsonValue.InnerText);
343
+                        break;
344
+                    case "ElementName":
345
+                        dataType2.ElementName = jsonValue.InnerText;
346
+                        break;
347
+                    case "ElementValue":
348
+                        dataType2.ElementValue = jsonValue.InnerText;
349
+                        break;
350
+                    case "ElementType":
351
+                        dataType2.ElementType = Convert.ToInt32(jsonValue.InnerText);
352
+                        break;
353
+                    case "ElementFactor":
354
+                        dataType2.ElementFactor = jsonValue.InnerText;
355
+                        break;
356
+                    case "ElementPrecision":
357
+                        dataType2.ElementPrecision = Convert.ToInt32(jsonValue.InnerText);
358
+                        break;
359
+                }
360
+            }
361
+            return dataType2;
362
+        }
363
+    }
364
+}

+ 30 - 0
GWSocketClient/xml/dataItem/DataElementType.cs Bestand weergeven

@@ -0,0 +1,30 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace GWSocketClient.xml.dataItem
8
+{
9
+    class DataElementType
10
+    {
11
+        public int flag;
12
+        public int num;
13
+        public int isPT;
14
+        public List<DataType> data = new List<DataType>();
15
+
16
+
17
+        public override string ToString()
18
+        {
19
+            return "flag=" + flag + ",num=" + num + ",isPT" + isPT + ",dataCount=" + data.Count;
20
+        }
21
+    }
22
+
23
+    class DataElementTypeComparer : IComparer<DataElementType>
24
+    {
25
+        public int Compare(DataElementType x, DataElementType y)
26
+        {
27
+            return x.flag.CompareTo(y.flag);
28
+        }
29
+    }
30
+}

+ 19 - 0
GWSocketClient/xml/dataItem/DataType.cs Bestand weergeven

@@ -0,0 +1,19 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+using GWSocketClient.xml.dataItem.data;
7
+
8
+namespace GWSocketClient.xml.dataItem
9
+{
10
+    class DataType
11
+    {
12
+        public List<DataType2> d1 = new List<DataType2>();
13
+
14
+        public override string ToString()
15
+        {
16
+            return "D1.Count = " + d1.Count;
17
+        }
18
+    }
19
+}

+ 29 - 0
GWSocketClient/xml/dataItem/data/DataType2.cs Bestand weergeven

@@ -0,0 +1,29 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+
8
+namespace GWSocketClient.xml.dataItem.data
9
+{
10
+    class DataType2
11
+    {
12
+        public int ElementSequence;
13
+        public int ElementLen;
14
+        public string ElementName;
15
+        public string ElementValue;
16
+        public int ElementType;
17
+        public string ElementFactor;
18
+        public int ElementPrecision;
19
+
20
+
21
+        public override string ToString()
22
+        {
23
+            return "ElementSequence=" + ElementSequence + ",ElementLen=" + ElementLen +
24
+                   ",ElementName=" + ElementName + ",ElementValue=" + ElementValue +
25
+                   ",ElementType=" + ElementType + ",ElementFactor=" + ElementFactor +
26
+                   ",ElementPrecision=" + ElementPrecision;
27
+        }
28
+    }
29
+}