lu
18 小时以前 ce701f953bd952bf8303ccb93520a8a3af33860e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using Gs.DevApp.Entity;
using Gs.DevApp.ToolBox;
using Microsoft.Win32;
using Newtonsoft.Json;
using NModbus;
using NModbus.Serial;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
 
namespace Gs.DevApp.DevFrm.QC
{
    public partial class WeightIqc : DevExpress.XtraEditors.XtraForm
    {
        public SerialPort Sp = new SerialPort();
        private WeightIqc.HandleInterfaceUpdataDelegate interfaceUpdataHandle;
        private string strLine = "";
        private string sqlWOMQAB = "";
        private Dictionary<string, Thread> dicThread = new Dictionary<string, Thread>();
        private StringBuilder sb = new StringBuilder();
        private IContainer components = (IContainer)null;
        private SplitContainerControl splitContainerControl1;
        private ImageComboBoxEdit cmbBaudRate;
        private LabelControl labelControl1;
        private TextEdit txtNum;
        private LabelControl labelControl3;
        private SimpleButton button2;
        private SimpleButton button1;
        private SimpleButton btnRefashC;
        private ImageComboBoxEdit cmbSerialPortNum;
        private LabelControl labelControl2;
        private GridControl gridWOMQAB;
        private GridView viewWOMQAB;
        private GridColumn colQAB001;
        private GridColumn colQAB002;
        private GridColumn colQAB003;
        private GridColumn colQAB005;
        private GridColumn colQAB006;
        private GridColumn colQAB007;
        private GridColumn colQAB009;
        private GridColumn colQAB010;
        private GridColumn colMIH004;
        private GridColumn colPAA002;
        private GridColumn colQAB015;
        private GridColumn colQAB025;
        private GridColumn colMCA022;
        private GridColumn colZT;
        private GridColumn colMCA023;
        private NotifyIcon notifyIcon1;
        private ContextMenuStrip contextMenuStrip1;
        private System.Windows.Forms.Timer timer1;
        private ToolStripMenuItem showInTaskbar;
        private ToolStripMenuItem exitWindow;
 
        public WeightIqc()
        {
            this.InitializeComponent();
            this.timer1.Tick += new EventHandler(this.timer1_Tick);
            this.notifyIcon1.DoubleClick += new EventHandler(this.notifyIcon1_DoubleClick);
            this.SizeChanged += new EventHandler(this.frmMain_SizeChanged);
            this.contextMenuStrip1.ItemClicked += new ToolStripItemClickedEventHandler(this.contextMenuStrip1_ItemClicked);
            this.Initialize();
 
        }
 
        private void Initialize()
        {
            try
            {
                int int32 = 10000;
                string _vanishingSeconds = ConfigurationManager.AppSettings["TimingMailInterval"];
                if (!string.IsNullOrEmpty(_vanishingSeconds))
                    int32 = int.Parse(_vanishingSeconds);
                string appSetting = ConfigurationManager.AppSettings["ProductName"]+"服务";
                this.Text = appSetting;
                this.notifyIcon1.Text = appSetting;
                this.timer1.Interval = int32;
                this.button1.Enabled = true;
                this.button2.Enabled = false;
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.Message);
                Application.Exit();
            }
        }
 
        private void GetComList()
        {
            this.cmbSerialPortNum.Properties.Items.Clear();
            RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("Hardware\\DeviceMap\\SerialComm");
            if (registryKey == null)
                return;
            foreach (string valueName in registryKey.GetValueNames())
            {
                string description = (string)registryKey.GetValue(valueName);
                this.cmbSerialPortNum.Properties.Items.Add(new ImageComboBoxItem(description, (object)description));
            }
            if (this.cmbSerialPortNum.Properties.Items.Count > 0)
                this.cmbSerialPortNum.SelectedIndex = 0;
        }
 
        public void RefreshData()
        {
            while (true)
            {
                try
                {
                    Thread.Sleep(10000);
                }
                catch (Exception ex)
                {
                    Thread.Sleep(10000);
                }
            }
        }
 
        public void GetWeight()
        {
            ModbusFactory factory = new ModbusFactory();
            LoggerHelper.WriteInfoLog("GetWeight创建modbus对象");
            IModbusMaster rtuMaster = (IModbusMaster)factory.CreateRtuMaster(this.Sp);
            bool flag = true;
            while (true)
            {
                try
                {
                    if (!this.Sp.IsOpen)
                    {
                        LoggerHelper.WriteInfoLog("GetWeight 重新打开串口连接");
                        this.Sp.Open();
                        rtuMaster = (IModbusMaster)factory.CreateRtuMaster(this.Sp);
                    }
                    if (rtuMaster == null)
                    {
                        LoggerHelper.WriteInfoLog("GetWeight 重新创建modbus对象");
                        rtuMaster = (IModbusMaster)factory.CreateRtuMaster(this.Sp);
                    }
                    byte slaveAddress3 = byte.Parse("1");
                    ushort startAddress3 = ushort.Parse("0002");
                    ushort numberOfPoints1 = ushort.Parse("2");
                    ushort[] numArray = rtuMaster.ReadHoldingRegisters(slaveAddress3, startAddress3, numberOfPoints1);
                    float single = BitConverter.ToSingle(this.CombomBinaryArray(BitConverter.GetBytes(numArray[1]), BitConverter.GetBytes(numArray[0])), 0);
                    this.Invoke((Delegate)this.interfaceUpdataHandle, (object)single.ToString());
                    byte slaveAddress4 = byte.Parse("1");
                    ushort startAddress4 = ushort.Parse("0001");
                    ushort numberOfPoints2 = ushort.Parse("1");
                    int int32 = Convert.ToInt32(rtuMaster.ReadHoldingRegisters(slaveAddress4, startAddress4, numberOfPoints2)[0].ToString());
                    string str = Convert.ToString(int32, 2).PadLeft(16 /*0x10*/, '0');
                    char ch1 = str[1];
                    char ch2 = str[6];
                    if (ch1 == '0' && ch2 == '0')
                    {
                        flag = true;
                    }
                    else if (flag)
                    {
                        flag = false;
                    }
                    addModel(single.ToString(), int32.ToString());
                    LoggerHelper.WriteInfoLog("single:" + single.ToString() + ",flag:" + flag.ToString() + ",int32:" + int32.ToString());
                    Thread.Sleep(2000);
                }
                catch (Exception ex)
                {
                    Thread.Sleep(2000);
                }
            }
        }
 
        private void UpdateTextBox(string text)
        {
            try
            {
                if (this.txtNum.Text == text)
                    return;
                this.txtNum.Text = text;
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteErrorLog($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:{ex.Message}");
                int num = (int)MessageBox.Show(ex.Message);
            }
        }
 
        public ushort[] stringToUshort2(string inString)
        {
            byte[] bytes = BitConverter.GetBytes(float.Parse(inString));
            ushort uint16 = BitConverter.ToUInt16(bytes, 0);
            return new ushort[2]
            {
      BitConverter.ToUInt16(bytes, 2),
      uint16
            };
        }
 
        private byte[] CombomBinaryArray(byte[] srcArray1, byte[] srcArray2)
        {
            byte[] destinationArray = new byte[srcArray1.Length + srcArray2.Length];
            Array.Copy((Array)srcArray1, 0, (Array)destinationArray, 0, srcArray1.Length);
            Array.Copy((Array)srcArray2, 0, (Array)destinationArray, srcArray1.Length, srcArray2.Length);
            return destinationArray;
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime now = DateTime.Now;
                LoggerHelper.WriteInfoLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":开始采集");
                if (this.cmbBaudRate.Text.Trim() != "" && this.cmbSerialPortNum.Text != "")
                {
                    now = DateTime.Now;
                    LoggerHelper.WriteInfoLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":配置串口通信");
                    this.interfaceUpdataHandle = new WeightIqc.HandleInterfaceUpdataDelegate(this.UpdateTextBox);
                    this.Sp.PortName = this.cmbSerialPortNum.Text.Trim();
                    this.Sp.BaudRate = Convert.ToInt32(this.cmbBaudRate.Text.Trim());
                    this.Sp.Parity = Parity.None;
                    this.Sp.StopBits = StopBits.One;
                    now = DateTime.Now;
                    LoggerHelper.WriteInfoLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":打开串口同通信");
                    this.Sp.Open();
                    this.button1.Enabled = false;
                    this.button2.Enabled = true;
                    this.timer1.Enabled = false;
                    now = DateTime.Now;
                    LoggerHelper.WriteInfoLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":启动刷新数据定时器");
                    this.timer1.Start();
                }
                else
                {
                    now = DateTime.Now;
                    LoggerHelper.WriteErrorLog(now.ToString("yyyy-MM-dd HH:mm:ss") + ":请输入正确的端口号和波特率");
                    int num = (int)MessageBox.Show("请输入正确的端口号和波特率!");
                    this.cmbSerialPortNum.Focus();
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteErrorLog($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:{ex.Message}");
                int num = (int)MessageBox.Show($"端口{this.cmbSerialPortNum.Text.Trim()}打开失败!{ex.Message}");
            }
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.dicThread.Keys.Contains<string>("RefreshData"))
                {
                    Thread thread = this.dicThread["RefreshData"];
                    if (thread.IsAlive)
                        thread.Abort();
                    this.dicThread.Remove("RefreshData");
                }
                if (this.dicThread.Keys.Contains<string>("GetWeight"))
                {
                    Thread thread = this.dicThread["GetWeight"];
                    if (thread.IsAlive)
                        thread.Abort();
                    this.dicThread.Remove("GetWeight");
                }
                this.button1.Enabled = true;
                this.button2.Enabled = false;
                this.timer1.Stop();
                this.Sp.Close();
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.Message);
                Application.Exit();
            }
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (!this.dicThread.Keys.Contains<string>("RefreshData"))
            {
                Thread thread = new Thread(new ThreadStart(this.RefreshData));
                thread.Start();
                this.dicThread.Add("RefreshData", thread);
            }
            if (this.dicThread.Keys.Contains<string>("GetWeight"))
                return;
            Thread thread1 = new Thread(new ThreadStart(this.GetWeight));
            thread1.Start();
            this.dicThread.Add("GetWeight", thread1);
        }
 
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (Sp.IsOpen)
                Sp.Close();
            if (timer1 != null)
            {
                timer1.Stop();
                timer1.Dispose();
            }
            try
            {
                if (this.dicThread.Keys.Contains<string>("RefreshData"))
                {
                    Thread thread = this.dicThread["RefreshData"];
                    if (thread.IsAlive)
                        thread.Abort();
                    this.dicThread.Remove("RefreshData");
                }
                if (this.dicThread.Keys.Contains<string>("GetWeight"))
                {
                    Thread thread = this.dicThread["GetWeight"];
                    if (thread.IsAlive)
                        thread.Abort();
                    this.dicThread.Remove("GetWeight");
                }
                this.timer1.Stop();
                this.Sp.Close();
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.Message);
                Application.Exit();
            }
        }
 
        private void Form1_Load(object sender, EventArgs e) => this.GetComList();
 
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem == this.showInTaskbar)
            {
                if (this.WindowState != FormWindowState.Minimized)
                    return;
                this.WindowState = FormWindowState.Normal;
                this.Activate();
                this.ShowInTaskbar = true;
                this.notifyIcon1.Visible = false;
            }
            else
            {
                if (e.ClickedItem != this.exitWindow)
                    return;
                this.button2_Click((object)null, (EventArgs)null);
                Environment.Exit(0);
            }
        }
 
        private void frmMain_SizeChanged(object sender, EventArgs e)
        {
            //if (this.WindowState != FormWindowState.Minimized)
            //    return;
            //this.ShowInTaskbar = false;
            //this.notifyIcon1.Visible = true;
        }
 
        private void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            if (this.WindowState != FormWindowState.Minimized)
                return;
            this.WindowState = FormWindowState.Normal;
            this.Activate();
            this.ShowInTaskbar = true;
            this.notifyIcon1.Visible = false;
        }
 
        protected override void Dispose(bool disposing)
        {
            if (disposing && this.components != null)
                this.components.Dispose();
            base.Dispose(disposing);
        }
 
        private void InitializeComponent()
        {
            this.components = (IContainer)new System.ComponentModel.Container();
            GridFormatRule gridFormatRule1 = new GridFormatRule();
            FormatConditionRuleExpression conditionRuleExpression1 = new FormatConditionRuleExpression();
            GridFormatRule gridFormatRule2 = new GridFormatRule();
            FormatConditionRuleExpression conditionRuleExpression2 = new FormatConditionRuleExpression();
            ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(WeightIqc));
            this.colZT = new GridColumn();
            this.splitContainerControl1 = new SplitContainerControl();
            this.txtNum = new TextEdit();
            this.labelControl3 = new LabelControl();
            this.button2 = new SimpleButton();
            this.button1 = new SimpleButton();
            this.btnRefashC = new SimpleButton();
            this.cmbSerialPortNum = new ImageComboBoxEdit();
            this.labelControl2 = new LabelControl();
            this.cmbBaudRate = new ImageComboBoxEdit();
            this.labelControl1 = new LabelControl();
            this.gridWOMQAB = new GridControl();
            this.viewWOMQAB = new GridView();
            this.colQAB001 = new GridColumn();
            this.colQAB002 = new GridColumn();
            this.colQAB003 = new GridColumn();
            this.colQAB005 = new GridColumn();
            this.colQAB006 = new GridColumn();
            this.colQAB007 = new GridColumn();
            this.colQAB009 = new GridColumn();
            this.colQAB010 = new GridColumn();
            this.colMIH004 = new GridColumn();
            this.colPAA002 = new GridColumn();
            this.colQAB015 = new GridColumn();
            this.colQAB025 = new GridColumn();
            this.colMCA022 = new GridColumn();
            this.colMCA023 = new GridColumn();
            this.notifyIcon1 = new NotifyIcon(this.components);
            this.contextMenuStrip1 = new ContextMenuStrip(this.components);
            this.showInTaskbar = new ToolStripMenuItem();
            this.exitWindow = new ToolStripMenuItem();
            this.timer1 = new System.Windows.Forms.Timer(this.components);
            this.splitContainerControl1.BeginInit();
            this.splitContainerControl1.SuspendLayout();
            this.txtNum.Properties.BeginInit();
            this.cmbSerialPortNum.Properties.BeginInit();
            this.cmbBaudRate.Properties.BeginInit();
            this.gridWOMQAB.BeginInit();
            this.viewWOMQAB.BeginInit();
            this.contextMenuStrip1.SuspendLayout();
            this.SuspendLayout();
            this.colZT.Caption = "状态";
            this.colZT.FieldName = "ZT";
            this.colZT.Name = "colZT";
            this.splitContainerControl1.Dock = DockStyle.Fill;
            this.splitContainerControl1.Horizontal = false;
            this.splitContainerControl1.Location = new Point(0, 0);
            this.splitContainerControl1.Margin = new Padding(4, 4, 4, 4);
            this.splitContainerControl1.Name = "splitContainerControl1";
            this.splitContainerControl1.Panel1.Controls.Add((Control)this.txtNum);
            this.splitContainerControl1.Panel1.Controls.Add((Control)this.labelControl3);
            this.splitContainerControl1.Panel1.Controls.Add((Control)this.button2);
            this.splitContainerControl1.Panel1.Controls.Add((Control)this.button1);
            this.splitContainerControl1.Panel1.Controls.Add((Control)this.btnRefashC);
            this.splitContainerControl1.Panel1.Controls.Add((Control)this.cmbSerialPortNum);
            this.splitContainerControl1.Panel1.Controls.Add((Control)this.labelControl2);
            this.splitContainerControl1.Panel1.Controls.Add((Control)this.cmbBaudRate);
            this.splitContainerControl1.Panel1.Controls.Add((Control)this.labelControl1);
            this.splitContainerControl1.Panel1.Text = "Panel1";
            this.splitContainerControl1.Panel2.Controls.Add((Control)this.gridWOMQAB);
            this.splitContainerControl1.Panel2.Text = "Panel2";
            this.splitContainerControl1.Size = new Size(859, 391);
            this.splitContainerControl1.SplitterPosition = 139;
            this.splitContainerControl1.TabIndex = 0;
            this.splitContainerControl1.Text = "splitContainerControl1";
            this.txtNum.Location = new Point(588, 19);
            this.txtNum.Margin = new Padding(4, 4, 4, 4);
            this.txtNum.Name = "txtNum";
            this.txtNum.Properties.Appearance.Font = new Font("Tahoma", 24f, FontStyle.Regular, GraphicsUnit.Point, (byte)0);
            this.txtNum.Properties.Appearance.Options.UseFont = true;
            this.txtNum.Size = new Size(187, 54);
            this.txtNum.TabIndex = 8;
            this.labelControl3.Appearance.Font = new Font("Tahoma", 24f, FontStyle.Regular, GraphicsUnit.Point, (byte)0);
            this.labelControl3.Appearance.Options.UseFont = true;
            this.labelControl3.Location = new Point(468, 28);
            this.labelControl3.Margin = new Padding(4, 4, 4, 4);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(120, 48 /*0x30*/);
            this.labelControl3.TabIndex = 7;
            this.labelControl3.Text = "重量:";
            this.button2.Location = new Point(315, 48 /*0x30*/);
            this.button2.Margin = new Padding(4, 4, 4, 4);
            this.button2.Name = "button2";
            this.button2.Size = new Size(100, 29);
            this.button2.TabIndex = 6;
            this.button2.Text = "停止";
            this.button2.Click += new EventHandler(this.button2_Click);
            this.button1.Location = new Point(315, 8);
            this.button1.Margin = new Padding(4, 4, 4, 4);
            this.button1.Name = "button1";
            this.button1.Size = new Size(100, 29);
            this.button1.TabIndex = 5;
            this.button1.Text = "确定";
            this.button1.Click += new EventHandler(this.button1_Click);
            this.btnRefashC.Location = new Point(213, 48 /*0x30*/);
            this.btnRefashC.Margin = new Padding(4, 4, 4, 4);
            this.btnRefashC.Name = "btnRefashC";
            this.btnRefashC.Size = new Size(33, 29);
            this.btnRefashC.TabIndex = 4;
            this.btnRefashC.Text = "R";
            this.cmbSerialPortNum.Location = new Point(72, 49);
            this.cmbSerialPortNum.Margin = new Padding(4, 4, 4, 4);
            this.cmbSerialPortNum.Name = "cmbSerialPortNum";
            this.cmbSerialPortNum.Properties.Buttons.AddRange(new EditorButton[1]
            {
      new EditorButton(ButtonPredefines.Combo)
            });
            this.cmbSerialPortNum.Size = new Size(133, 24);
            this.cmbSerialPortNum.TabIndex = 3;
            this.labelControl2.Location = new Point(16 /*0x10*/, 52);
            this.labelControl2.Margin = new Padding(4, 4, 4, 4);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(45, 18);
            this.labelControl2.TabIndex = 2;
            this.labelControl2.Text = "串口号";
            this.cmbBaudRate.EditValue = (object)"9600";
            this.cmbBaudRate.Location = new Point(72, 11);
            this.cmbBaudRate.Margin = new Padding(4, 4, 4, 4);
            this.cmbBaudRate.Name = "cmbBaudRate";
            this.cmbBaudRate.Properties.Buttons.AddRange(new EditorButton[1]
            {
      new EditorButton(ButtonPredefines.Combo)
            });
            this.cmbBaudRate.Properties.Items.AddRange(new ImageComboBoxItem[5]
            {
      new ImageComboBoxItem("14400", (object) "14400", -1),
      new ImageComboBoxItem("9600", (object) "9600", -1),
      new ImageComboBoxItem("4800", (object) "4800", -1),
      new ImageComboBoxItem("2400", (object) "2400", -1),
      new ImageComboBoxItem("1200", (object) "1200", -1)
            });
            this.cmbBaudRate.Size = new Size(175, 24);
            this.cmbBaudRate.TabIndex = 1;
            this.labelControl1.Location = new Point(16 /*0x10*/, 15);
            this.labelControl1.Margin = new Padding(4, 4, 4, 4);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(45, 18);
            this.labelControl1.TabIndex = 0;
            this.labelControl1.Text = "波特率";
            this.gridWOMQAB.Dock = DockStyle.Fill;
            this.gridWOMQAB.EmbeddedNavigator.Margin = new Padding(4, 4, 4, 4);
            this.gridWOMQAB.Location = new Point(0, 0);
            this.gridWOMQAB.MainView = (BaseView)this.viewWOMQAB;
            this.gridWOMQAB.Margin = new Padding(4, 4, 4, 4);
            this.gridWOMQAB.Name = "gridWOMQAB";
            this.gridWOMQAB.Size = new Size(859, 246);
            this.gridWOMQAB.TabIndex = 1;
            this.gridWOMQAB.ViewCollection.AddRange(new BaseView[1]
            {
      (BaseView) this.viewWOMQAB
            });
            this.viewWOMQAB.Columns.AddRange(new GridColumn[15]
            {
      this.colQAB001,
      this.colQAB002,
      this.colQAB003,
      this.colQAB005,
      this.colQAB006,
      this.colQAB007,
      this.colQAB009,
      this.colQAB010,
      this.colMIH004,
      this.colPAA002,
      this.colQAB015,
      this.colQAB025,
      this.colMCA022,
      this.colZT,
      this.colMCA023
            });
            gridFormatRule1.ApplyToRow = true;
            gridFormatRule1.Column = this.colZT;
            gridFormatRule1.Name = "ZTRule1";
            conditionRuleExpression1.Appearance.BackColor = System.Drawing.Color.Red;
            conditionRuleExpression1.Appearance.Options.UseBackColor = true;
            conditionRuleExpression1.Expression = "ZT='N'";
            gridFormatRule1.Rule = (FormatConditionRuleBase)conditionRuleExpression1;
            gridFormatRule2.ApplyToRow = true;
            gridFormatRule2.Column = this.colZT;
            gridFormatRule2.Name = "ZTRule2";
            conditionRuleExpression2.Appearance.BackColor = System.Drawing.Color.FromArgb(128 /*0x80*/, (int)byte.MaxValue, 128 /*0x80*/);
            conditionRuleExpression2.Appearance.Options.UseBackColor = true;
            conditionRuleExpression2.Expression = "ZT='Y'";
            gridFormatRule2.Rule = (FormatConditionRuleBase)conditionRuleExpression2;
            this.viewWOMQAB.FormatRules.Add(gridFormatRule1);
            this.viewWOMQAB.FormatRules.Add(gridFormatRule2);
            this.viewWOMQAB.GridControl = this.gridWOMQAB;
            this.viewWOMQAB.Name = "viewWOMQAB";
            this.viewWOMQAB.OptionsView.ColumnAutoWidth = false;
            this.viewWOMQAB.OptionsView.ShowGroupPanel = false;
            this.colQAB001.Caption = "ID";
            this.colQAB001.FieldName = "QAB001";
            this.colQAB001.Name = "colQAB001";
            this.colQAB002.Caption = "条码";
            this.colQAB002.FieldName = "QAB002";
            this.colQAB002.MinWidth = 150;
            this.colQAB002.Name = "colQAB002";
            this.colQAB002.Visible = true;
            this.colQAB002.VisibleIndex = 0;
            this.colQAB002.Width = 150;
            this.colQAB003.Caption = "工单";
            this.colQAB003.FieldName = "QAB003";
            this.colQAB003.MinWidth = 100;
            this.colQAB003.Name = "colQAB003";
            this.colQAB003.Visible = true;
            this.colQAB003.VisibleIndex = 1;
            this.colQAB003.Width = 100;
            this.colQAB005.Caption = "物料编码";
            this.colQAB005.FieldName = "QAB005";
            this.colQAB005.MinWidth = 100;
            this.colQAB005.Name = "colQAB005";
            this.colQAB005.Visible = true;
            this.colQAB005.VisibleIndex = 2;
            this.colQAB005.Width = 100;
            this.colQAB006.Caption = "物料名称";
            this.colQAB006.FieldName = "QAB006";
            this.colQAB006.Name = "colQAB006";
            this.colQAB006.Visible = true;
            this.colQAB006.VisibleIndex = 3;
            this.colQAB007.Caption = "物料规格";
            this.colQAB007.FieldName = "QAB007";
            this.colQAB007.MinWidth = 200;
            this.colQAB007.Name = "colQAB007";
            this.colQAB007.Visible = true;
            this.colQAB007.VisibleIndex = 4;
            this.colQAB007.Width = 200;
            this.colQAB009.Caption = "工序编号";
            this.colQAB009.FieldName = "QAB009";
            this.colQAB009.Name = "colQAB009";
            this.colQAB009.Visible = true;
            this.colQAB009.VisibleIndex = 5;
            this.colQAB010.Caption = "工序名称";
            this.colQAB010.FieldName = "QAB010";
            this.colQAB010.Name = "colQAB010";
            this.colQAB010.Visible = true;
            this.colQAB010.VisibleIndex = 6;
            this.colMIH004.Caption = "线别";
            this.colMIH004.FieldName = "MIH004";
            this.colMIH004.Name = "colMIH004";
            this.colMIH004.Visible = true;
            this.colMIH004.VisibleIndex = 7;
            this.colPAA002.Caption = "作业人员";
            this.colPAA002.FieldName = "PAA002";
            this.colPAA002.Name = "colPAA002";
            this.colPAA002.Visible = true;
            this.colPAA002.VisibleIndex = 8;
            this.colQAB015.Caption = "作业时间";
            this.colQAB015.FieldName = "QAB015";
            this.colQAB015.MinWidth = 150;
            this.colQAB015.Name = "colQAB015";
            this.colQAB015.Visible = true;
            this.colQAB015.VisibleIndex = 9;
            this.colQAB015.Width = 150;
            this.colQAB025.Caption = "实际重量";
            this.colQAB025.FieldName = "QAB025";
            this.colQAB025.Name = "colQAB025";
            this.colQAB025.Visible = true;
            this.colQAB025.VisibleIndex = 10;
            this.colMCA022.Caption = "重量下限";
            this.colMCA022.FieldName = "MCA022";
            this.colMCA022.Name = "colMCA022";
            this.colMCA022.Visible = true;
            this.colMCA022.VisibleIndex = 11;
            this.colMCA023.Caption = "重量上限";
            this.colMCA023.FieldName = "MCA023";
            this.colMCA023.Name = "colMCA023";
            this.colMCA023.Visible = true;
            this.colMCA023.VisibleIndex = 12;
            this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
            // this.notifyIcon1.Icon = (Icon)componentResourceManager.GetObject("notifyIcon1.Icon");
            this.notifyIcon1.Text = "技研新阳新技电子有限公司";
            this.notifyIcon1.Visible = true;
            this.contextMenuStrip1.ImageScalingSize = new Size(20, 20);
            this.contextMenuStrip1.Items.AddRange(new ToolStripItem[2]
            {
      (ToolStripItem) this.showInTaskbar,
      (ToolStripItem) this.exitWindow
            });
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new Size(109, 52);
            this.showInTaskbar.Name = "showInTaskbar";
            this.showInTaskbar.Size = new Size(108, 24);
            this.showInTaskbar.Text = "显示";
            this.exitWindow.Name = "exitWindow";
            this.exitWindow.Size = new Size(108, 24);
            this.exitWindow.Text = "退出";
            this.timer1.Interval = 10000;
            this.AutoScaleDimensions = new SizeF(8f, 15f);
            this.AutoScaleMode = AutoScaleMode.Font;
            this.ClientSize = new Size(859, 391);
            this.Controls.Add((Control)this.splitContainerControl1);
            this.Margin = new Padding(4, 4, 4, 4);
            this.Name = nameof(WeightIqc);
            this.Text = "称重取数";
            this.FormClosing += new FormClosingEventHandler(this.Form1_FormClosing);
            this.Load += new EventHandler(this.Form1_Load);
            this.splitContainerControl1.EndInit();
            this.splitContainerControl1.ResumeLayout(false);
            this.txtNum.Properties.EndInit();
            this.cmbSerialPortNum.Properties.EndInit();
            this.cmbBaudRate.Properties.EndInit();
            this.gridWOMQAB.EndInit();
            this.viewWOMQAB.EndInit();
            this.contextMenuStrip1.ResumeLayout(false);
            this.ResumeLayout(false);
        }
 
        public delegate void HandleInterfaceUpdataDelegate(string text);
 
        /// <summary>
        /// 上传称重数据
        /// </summary>
        /// <param name="_realWeight">截取后的数量</param>
        /// <param name="_realWeightTxt">原子串</param>
        private void addModel(string _realWeight, string _realWeightTxt)
        {
            string _lineId = "0";
            var _obj = new
            {
                lineId = _lineId,
                realWeight = _realWeight.Trim(),
                realWeightTxt = _realWeightTxt.Trim(),
            };
            try
            {
                string strJson = UtilityHelper.HttpPost("", "WorkWeight/EditModel", JsonConvert.SerializeObject(_obj));
                ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
                if (_rtn.rtnCode <= 0)
                {
                    LoggerHelper.WriteInfoLog("WorkWeight/EditModel:" + strJson);
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.WriteInfoLog(ex.Message);
            }
        }
    }
}