patrick.xu
2021-05-24 f13235bee2e25d091ba13dc3732b83f905565f80
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
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
 
namespace M423project
{
    public partial class ConfigForm : Form
    {
        public ConfigForm(OPC Opc, ConfigStruct Config)
        {
            InitializeComponent();
            this.opc = Opc;
            this.config = Config;
 
            #region add by Patrick 2020-2-18
            InitialBatteryCheckPage();
            #endregion
        }
 
        #region add by Patrick 2020-2-18
        private void InitialBatteryCheckPage()
        {
            TabPage tbBatteryCheck = new TabPage("电池在位检测配置");
 
            if (!tabControl1.TabPages.ContainsKey(tbBatteryCheck.Name))
            {
                tabControl1.TabPages.Add(tbBatteryCheck);
            }
 
            CtrlSetBatteryCheckROI ctrl = new CtrlSetBatteryCheckROI();
            ctrl.Dock = DockStyle.Fill;
            tbBatteryCheck.Controls.Add(ctrl);
        }
        #endregion
 
        OPC opc;
        ConfigStruct config = new ConfigStruct();
        ToolKit.FileToolkit.SerializeFileTool<ConfigStruct> sftConfig = new ToolKit.FileToolkit.SerializeFileTool<ConfigStruct>();
        string configPath = Directory.GetCurrentDirectory() + "\\Config\\M423Config.xml";
 
        private void ConfigForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }
 
        private void ConfigForm_Load(object sender, EventArgs e)
        {
            textBox17.Text = config.X1Y1AxisAcceleration.ToString();
            textBox18.Text = config.X1Y1AxisDeceleration.ToString();
            textBox22.Text = config.X1LocationSpeed.ToString();
            textBox29.Text = config.Y1LocationSpeed.ToString();
            textBox23.Text = config.X1axisLocationPos.ToString();
            textBox30.Text = config.Y1axisLocationPos.ToString();
            textBox28.Text = config.X1axisHandSpeed.ToString();
            textBox31.Text = config.Y1axisHandSpeed.ToString();
            textBox32.Text = config.X1AxisSpeed.ToString();
            textBox33.Text = config.Y1AxisSpeed.ToString();
            textBox14.Text = config.X2Y2AxisAcceleration.ToString();
            textBox13.Text = config.X2Y2AxisDeceleration.ToString();
            textBox12.Text = config.X2LocationSpeed.ToString();
            textBox1.Text = config.Y2LocationSpeed.ToString();
            textBox8.Text = config.X2axisLocationPos.ToString();
            textBox6.Text = config.Y2axisLocationPos.ToString();
            textBox4.Text = config.X2axisHandSpeed.ToString();
            textBox3.Text = config.Y2axisHandSpeed.ToString();
            textBox5.Text = config.X2axisWaitPos.ToString();
            textBox2.Text = config.Y2axisWaitPos.ToString();
            textBox26.Text = config.X2AxisSpeed.ToString();
            textBox27.Text = config.X2AxisSpeed.ToString();
            textBox24.Text = config.X1ScanOKPosition.ToString();
            textBox25.Text = config.Y1ScanOKPosition.ToString();
            textBox81.Text = config.X1ScanBackPosition.ToString();
            textBox80.Text = config.Y1ScanBackPosition.ToString();
 
            textBox10.Text = config.batteryLengthLimit.Min.ToString();
            textBox7.Text = config.batteryLengthLimit.Max.ToString();
            textBox15.Text = config.batteryWidthLimit.Min.ToString();
            textBox9.Text = config.batteryWidthLimit.Max.ToString();
            textBox16.Text = config.batteryATLHeightLimit.Min.ToString();
            textBox11.Text = config.batteryATLHeightLimit.Max.ToString();
            textBox90.Text = config.batteryLSNHeightLimit.Min.ToString();
            textBox91.Text = config.batteryLSNHeightLimit.Max.ToString();
 
            textBox21.Text = config.batteryLengthOffset.ToString();
            //textBox20.Text = config.batteryWidthOffset.ToString();
            //tbCalibHeight.Text = config.calibrateHeight.ToString();
            textBox19.Text = config.compensationZ.station1.ToString();
            textBox82.Text = config.compensationZ.station2.ToString();
            textBox83.Text = config.compensationZ.station3.ToString();
            textBox84.Text = config.compensationZ.station4.ToString();
            textBox85.Text = config.compensationZ.station5.ToString();
 
            textBox20.Text = config.compensationW.station1.ToString();
            textBox86.Text = config.compensationW.station2.ToString();
            textBox87.Text = config.compensationW.station3.ToString();
            textBox88.Text = config.compensationW.station4.ToString();
            textBox89.Text = config.compensationW.station5.ToString();
 
            tbLoadRobotSpeed.Text = config.loadRbtSpeed.ToString();
            tbUnloadRobotSpeed.Text = config.unloadRbtSpeed.ToString();
            cbTST.Checked = config.isSaveTst;
            cbExcel.Checked = config.isSaveExcel;
            cbUploadPath.Checked = config.isSaveUpload;
            tbTST.Text = config.textTstPath;
            tbExcel.Text = config.textExcelPath;
            tbUpload.Text = config.textUploadPath;
            tbLine.Text = config.textLine;
            tbStation.Text = config.textStation;
 
            LoadAxisDataFromDevice();
            LoadDeviceStatus();
 
            chkSaveOKLWImage.Checked = config.IsSaveSizeOKImage;
 
            nudCellMaxLength.Value = (decimal)config.MaxLength;
            nudCellMaxWidth.Value = (decimal)config.MaxWidth;
            nudCellMinLength.Value = (decimal)config.MinLength;
            nudCellMinWidth.Value = (decimal)config.MinWidth;
        }
 
        private void btnSaveConfig_Click(object sender, EventArgs e)
        {
            /*
            config.X1Y1AxisAcceleration = Convert.ToDouble(textBox17.Text);
            config.X1Y1AxisDeceleration = Convert.ToDouble(textBox18.Text);
            config.X1LocationSpeed = Convert.ToDouble(textBox22.Text);
            config.Y1LocationSpeed = Convert.ToDouble(textBox29.Text);
            config.X1axisLocationPos = Convert.ToDouble(textBox23.Text);
            config.Y1axisLocationPos = Convert.ToDouble(textBox30.Text);
            config.X1axisHandSpeed = Convert.ToDouble(textBox28.Text);
            config.Y1axisHandSpeed = Convert.ToDouble(textBox31.Text);
            config.X1AxisSpeed = Convert.ToDouble(textBox32.Text);
            config.Y1AxisSpeed = Convert.ToDouble(textBox33.Text);
            config.X2Y2AxisAcceleration = Convert.ToDouble(textBox14.Text);
            config.X2Y2AxisDeceleration = Convert.ToDouble(textBox13.Text);
            config.X2LocationSpeed = Convert.ToDouble(textBox12.Text);
            config.Y2LocationSpeed = Convert.ToDouble(textBox1.Text);
            config.X2axisLocationPos = Convert.ToDouble(textBox8.Text);
            config.Y2axisLocationPos = Convert.ToDouble(textBox6.Text);
            config.X2axisHandSpeed = Convert.ToDouble(textBox4.Text);
            config.Y2axisHandSpeed = Convert.ToDouble(textBox3.Text);
            config.X2axisWaitPos = Convert.ToDouble(textBox5.Text);
            config.Y2axisWaitPos = Convert.ToDouble(textBox2.Text);
            config.X2AxisSpeed = Convert.ToDouble(textBox26.Text);
            config.Y2AxisSpeed = Convert.ToDouble(textBox27.Text);
            config.X1ScanOKPosition = Convert.ToDouble(textBox24.Text);
            config.Y1ScanOKPosition = Convert.ToDouble(textBox25.Text);
            config.X1ScanBackPosition = Convert.ToDouble(textBox81.Text);
            config.Y1ScanBackPosition = Convert.ToDouble(textBox80.Text);*/
 
            config.batteryLengthLimit.Min = Convert.ToDouble(textBox10.Text);
            config.batteryLengthLimit.Max = Convert.ToDouble(textBox7.Text);
            config.batteryWidthLimit.Min = Convert.ToDouble(textBox15.Text);
            config.batteryWidthLimit.Max = Convert.ToDouble(textBox9.Text);
            //config.batteryHeightLimit.Min = Convert.ToDouble(textBox16.Text);
            //config.batteryHeightLimit.Max = Convert.ToDouble(textBox11.Text);
            config.batteryATLHeightLimit.Min = Convert.ToDouble(textBox16.Text);
            config.batteryATLHeightLimit.Max = Convert.ToDouble(textBox11.Text);
            config.batteryLSNHeightLimit.Min = Convert.ToDouble(textBox90.Text);
            config.batteryLSNHeightLimit.Max = Convert.ToDouble(textBox91.Text);
 
            config.batteryLengthOffset = Convert.ToDouble(textBox21.Text);
            //config.batteryWidthOffset = Convert.ToDouble(textBox20.Text);
 
            //config.calibrateHeight = Convert.ToDouble(tbCalibHeight.Text);
            config.compensationZ.station1 = Convert.ToDouble(textBox19.Text);
            config.compensationZ.station2 = Convert.ToDouble(textBox82.Text);
            config.compensationZ.station3 = Convert.ToDouble(textBox83.Text);
            config.compensationZ.station4 = Convert.ToDouble(textBox84.Text);
            config.compensationZ.station5 = Convert.ToDouble(textBox85.Text);
 
            config.compensationW.station1 = Convert.ToDouble(textBox20.Text);
            config.compensationW.station2 = Convert.ToDouble(textBox86.Text);
            config.compensationW.station3 = Convert.ToDouble(textBox87.Text);
            config.compensationW.station4 = Convert.ToDouble(textBox88.Text);
            config.compensationW.station5 = Convert.ToDouble(textBox89.Text);
            config.X1Y1AxisAcceleration = Convert.ToDouble(textBox17.Text);
 
 
            config.X1Y1AxisDeceleration = Convert.ToDouble(textBox18.Text);
            opc.Write(OPCOutputTag.X1Y1AxisDeceleration, Convert.ToDouble(textBox18.Text));
 
            config.X1LocationSpeed = Convert.ToDouble(textBox22.Text);
            opc.Write(OPCOutputTag.X1LocationSpeed, Convert.ToDouble(textBox22.Text));
 
            config.Y1LocationSpeed = Convert.ToDouble(textBox29.Text);
            opc.Write(OPCOutputTag.X1LocationSpeed, Convert.ToDouble(textBox29.Text));
 
            config.X1axisLocationPos = Convert.ToDouble(textBox23.Text);
            opc.Write(OPCOutputTag.X1axisLocationPos, Convert.ToDouble(textBox23.Text));
 
            config.Y1axisLocationPos = Convert.ToDouble(textBox30.Text);
            opc.Write(OPCOutputTag.Y1axisLocationPos, Convert.ToDouble(textBox30.Text));
 
            config.X1axisHandSpeed = Convert.ToDouble(textBox28.Text);
            opc.Write(OPCOutputTag.X1axisHandSpeed, Convert.ToDouble(textBox28.Text));
 
            config.Y1axisHandSpeed = Convert.ToDouble(textBox31.Text);
            opc.Write(OPCOutputTag.Y1axisHandSpeed, Convert.ToDouble(textBox31.Text));
 
            config.X1AxisSpeed = Convert.ToDouble(textBox32.Text);
            opc.Write(OPCOutputTag.X1AxisSpeed, Convert.ToDouble(textBox32.Text));
 
            config.Y1AxisSpeed = Convert.ToDouble(textBox33.Text);
            opc.Write(OPCOutputTag.Y1AxisSpeed, Convert.ToDouble(textBox33.Text));
 
            config.X2Y2AxisAcceleration = Convert.ToDouble(textBox14.Text);
            opc.Write(OPCOutputTag.X2Y2AxisAcceleration, Convert.ToDouble(textBox14.Text));
 
            config.X2Y2AxisDeceleration = Convert.ToDouble(textBox13.Text);
            opc.Write(OPCOutputTag.X2Y2AxisDeceleration, Convert.ToDouble(textBox13.Text));
 
            config.X2LocationSpeed = Convert.ToDouble(textBox12.Text);
            opc.Write(OPCOutputTag.X2LocationSpeed, Convert.ToDouble(textBox12.Text));
 
            config.Y2LocationSpeed = Convert.ToDouble(textBox1.Text);
            opc.Write(OPCOutputTag.Y2LocationSpeed, Convert.ToDouble(textBox1.Text));
 
            config.X2axisLocationPos = Convert.ToDouble(textBox8.Text);
            opc.Write(OPCOutputTag.X2axisLocationPos, Convert.ToDouble(textBox8.Text));
 
            config.Y2axisLocationPos = Convert.ToDouble(textBox6.Text);
            opc.Write(OPCOutputTag.Y2axisLocationPos, Convert.ToDouble(textBox6.Text));
 
            config.X2axisHandSpeed = Convert.ToDouble(textBox4.Text);
            opc.Write(OPCOutputTag.X2axisHandSpeed, Convert.ToDouble(textBox4.Text));
 
            config.Y2axisHandSpeed = Convert.ToDouble(textBox3.Text);
            opc.Write(OPCOutputTag.Y2axisHandSpeed, Convert.ToDouble(textBox3.Text));
 
            config.X2axisWaitPos = Convert.ToDouble(textBox5.Text);
            opc.Write(OPCOutputTag.X2axisWaitPos, Convert.ToDouble(textBox5.Text));
 
            config.Y2axisWaitPos = Convert.ToDouble(textBox2.Text);
            opc.Write(OPCOutputTag.Y2axisWaitPos, Convert.ToDouble(textBox2.Text));
 
            config.X2AxisSpeed = Convert.ToDouble(textBox26.Text);
            opc.Write(OPCOutputTag.X2AxisSpeed, Convert.ToDouble(textBox26.Text));
 
            config.Y2AxisSpeed = Convert.ToDouble(textBox27.Text);
            opc.Write(OPCOutputTag.Y2AxisSpeed, Convert.ToDouble(textBox27.Text));
 
            config.X1ScanOKPosition = Convert.ToDouble(textBox24.Text);
            opc.Write(OPCOutputTag.X1ScanOKPosition, Convert.ToDouble(textBox24.Text));
 
            config.Y1ScanOKPosition = Convert.ToDouble(textBox25.Text);
            opc.Write(OPCOutputTag.Y1ScanOKPosition, Convert.ToDouble(textBox25.Text));
 
            config.X1ScanBackPosition = Convert.ToDouble(textBox81.Text);
            opc.Write(OPCOutputTag.X1ScanBackPosition, Convert.ToDouble(textBox81.Text));
 
            config.Y1ScanBackPosition = Convert.ToDouble(textBox80.Text);
            opc.Write(OPCOutputTag.Y1ScanBackPosition, Convert.ToDouble(textBox80.Text));
 
 
            if (Convert.ToDouble(tbLoadRobotSpeed.Text) <= 100) config.loadRbtSpeed = Convert.ToDouble(tbLoadRobotSpeed.Text);
            else
            {
                MessageBox.Show("上料机械手速度超过最大值,请重新设定!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (Convert.ToDouble(tbUnloadRobotSpeed.Text) <= 100) config.unloadRbtSpeed = Convert.ToDouble(tbUnloadRobotSpeed.Text);
            else
            {
                MessageBox.Show("下料机械手速度超过最大值,请重新设定!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            config.isSaveExcel = cbExcel.Checked;
            config.isSaveTst = cbTST.Checked;
            config.isSaveUpload = cbUploadPath.Checked;
            config.textTstPath = tbTST.Text;
            config.textExcelPath = tbExcel.Text;
            config.textUploadPath = tbUpload.Text;
            config.textLine = tbLine.Text;
            config.textStation = tbStation.Text;
 
            #region 保存电池长宽限制
            config.MaxWidth = (float)nudCellMaxWidth.Value;
            config.MaxLength = (float)nudCellMaxLength.Value;
            config.MinWidth = (float)nudCellMinWidth.Value;
            config.MinLength = (float)nudCellMinLength.Value;
            #endregion
 
            sftConfig.SetConfig(configPath, config);
 
            OnConfigSaved?.Invoke(config);
            MessageBox.Show("配置保存完成!");
        }
 
        private void btnX1ToOri_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisToOri, true);
        }
 
        private void btnX1ToOri_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisToOri, false);
        }
 
        private void btnX1axisLocation_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisLocation, true);
        }
 
        private void btnX1axisLocation_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisLocation, false);
        }
 
        private void btnX1axistoR_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisRshift, true);
        }
 
        private void btnX1axistoR_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisRshift, false);
        }
 
        private void btnX1axistoL_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisLshift, true);
        }
 
        private void btnX1axistoL_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisLshift, false);
        }
 
        private void btnTableAction_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.ZhPanAction, true);
        }
 
        private void btnY1ToOri_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisToOri, true);
        }
 
        private void btnY1ToOri_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisToOri, false);
        }
 
        private void btnY1axisLocation_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisLocation, true);
        }
 
        private void btnY1axisLocation_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisLocation, false);
        }
 
        private void btnY1axistoR_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisRshift, true);
        }
 
        private void btnY1axistoR_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisRshift, false);
        }
 
        private void btnY1axistoL_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisLshift, true);
        }
 
        private void btnY1axistoL_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisLshift, false);
        }
 
        private void cbLineMachinePower2_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.LineMachinePower2, !cbLineMachinePower2.Checked);
        }
 
        private void btnX2ToOri_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisToOri, true);
        }
 
        private void btnX2ToOri_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisToOri, false);
        }
 
        private void btnX2axisLocation_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisLocation, true);
        }
 
        private void btnX2axisLocation_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisLocation, false);
        }
 
        private void btnX2axistoR_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisRshift, true);
        }
 
        private void btnX2axistoR_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisRshift, false);
        }
 
        private void btnX2axistoL_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisLshift, true);
        }
 
        private void btnX2axistoL_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisLshift, false);
        }
 
        private void cbSifuPower4_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.SifuPower4, !cbSifuPower4.Checked);
        }
 
        private void cbLineMachinePower4_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.LineMachinePower4, !cbLineMachinePower4.Checked);
        }
 
        private void btnY2ToOri_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisToOri, true);
        }
 
        private void btnY2ToOri_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisToOri, false);
        }
 
        private void btnY2axisLocation_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisLocation, true);
        }
 
        private void btnY2axisLocation_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisLocation, false);
        }
 
        private void btnY2axistoR_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisRshift, true);
        }
 
        private void btnY2axistoR_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisRshift, false);
        }
 
        private void btnY2axistoL_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisLshift, true);
        }
 
        private void btnY2axistoL_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisLshift, false);
        }
 
        private void cbRingLight2_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.HuanxLight2, !cbRingLight2.Checked);
        }
 
        private void cbLight_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Light, !cbLight.Checked);
        }
 
        private void cbValve1_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Valve1, !cbValve1.Checked);
        }
 
        private void cbValve2_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Valve2, !cbValve2.Checked);
        }
 
        private void cbValve3_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Valve3, !cbValve3.Checked);
        }
 
        private void cbValve4_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Valve4, !cbValve4.Checked);
        }
 
        private void cbValve5_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Valve5, !cbValve5.Checked);
        }
 
        private void cbBackLight4_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.BackLight4, !cbBackLight4.Checked);
        }
 
        private void btnCloseAlarm_MouseDown(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.CloseAlarm, true);
        }
 
        private void btnCloseAlarm_MouseUp(object sender, MouseEventArgs e)
        {
            opc.Write(OPCOutputTag.CloseAlarm, false);
        }
 
        private void cbCylinder1_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Cylinder1, !cbCylinder1.Checked);
        }
 
        private void cbCylinder2_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Cylinder2, !cbCylinder2.Checked);
        }
 
        private void cbCylinder3_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Cylinder3, !cbCylinder3.Checked);
        }
 
        private void cbCylinder4_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Cylinder4, !cbCylinder4.Checked);
        }
 
        private void cbCylinder5_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Cylinder5, !cbCylinder5.Checked);
        }
 
        private void cbRingLight4_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.HuanxLight4, !cbRingLight4.Checked);
        }
 
        private void cbZAxisStop_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.ZAxisStop, !cbZAxisStop.Checked);
        }
 
        private void cbLoadRbtAlarm_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.LoadRbtAlarm, cbLoadRbtAlarm.Checked);
        }
 
        private void cbUnloadRbtAlarm_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.UnloadRbtAlarm, cbUnloadRbtAlarm.Checked);
        }
 
        private void cbRbtHandAuto_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.RobotHandAuto, !cbRbtHandAuto.Checked);
            cbRbtHandAuto.Text = cbRbtHandAuto.Checked ? "自动" : "手动";
        }
 
        private void cbLoadRbtControl_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.LoadRbtControl, !cbLoadRbtControl.Checked);
            cbLoadRbtControl.Text = !cbLoadRbtControl.Checked ? "自动" : "手动调试";
        }
 
        private void cbUnloadRbtControl_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.UnloadRbtControl, !cbUnloadRbtControl.Checked);
            cbUnloadRbtControl.Text = !cbUnloadRbtControl.Checked ? "自动" : "手动调试";
        }
 
        private void btnCloseAlarm_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.CloseAlarm, true);
        }
 
        private void cbPingbiSafeGuard_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.PingbiSafeGuard, cbPingbiSafeGuard.Checked);
        }
 
        private void cbPingbiGuangshan_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.PingbiGuangShan, cbPingbiGuangshan.Checked);
        }
 
        private void cbTST_CheckedChanged(object sender, EventArgs e)
        {
            btnTstPath.Enabled = cbTST.Checked;
            btnExcelPath.Enabled = cbExcel.Checked;
            btnUploadPath.Enabled = cbUploadPath.Checked;
            tbLine.Enabled = cbUploadPath.Checked;
            tbStation.Enabled = cbUploadPath.Checked;
        }
 
        private void btnLoadCylinderEnter_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.LoadCylinder, true);
        }
 
        private void btnLoadCylinderBack_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.LoadCylinder, false);
        }
 
        private void btnNGCylinderEnter_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.NGCylinder, true);
        }
 
        private void btnNGCylinderBack_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.NGCylinder, false);
        }
 
        private void btnUnloadCylinderEnter_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.UnloadCylinder, true);
        }
 
        private void btnUnloadCylinderBack_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.UnloadCylinder, false);
        }
 
        private void btnChangeTuitou_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.ChangeTuitou, true);
        }
 
        private void btnX2axisLocation_Click(object sender, EventArgs e)
        {
 
        }
 
        private void btnX1axistoR_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisRshift, true);
 
        }
 
        private void btnX1axistoL_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisLshift, true);
        }
 
        private void btnX2ToOri_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisToOri, true);
        }
 
        private void btnX1ToOri_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.X1axisToOri, true);
        }
 
        private void btnY1ToOri_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisToOri, true);
        }
 
        private void btnY2ToOri_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisToOri, true);
        }
 
        private void btnY1axistoR_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisRshift, true);
 
        }
 
        private void btnX2axistoR_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisRshift, true);
        }
 
        private void btnY2axistoR_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisRshift, true);
        }
 
        private void cbX1AxisEnable_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.X1AxisEnable, cbX1AxisEnable.Checked);
 
        }
 
        private void cbY1AxisEnable_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Y1AxisEnable, cbY1AxisEnable.Checked);
        }
 
        private void cbX2AxisEnable_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.X2AxisEnable, cbX2AxisEnable.Checked);
        }
 
        private void cbY2AxisEnable_CheckedChanged(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Y2AxisEnable, cbY2AxisEnable.Checked);
        }
 
        private void btnX2axistoL_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.X2axisLshift, true);
        }
 
        private void btnY2axistoL_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Y2axisLshift, true);
        }
 
        private void btnY1axistoL_Click(object sender, EventArgs e)
        {
            opc.Write(OPCOutputTag.Y1axisLshift, true);
 
        }
 
        private void LoadAxisDataFromDevice()
        {
            object o = new int();
            try
            {
                textBox17.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X1Y1AxisAcceleration, ref o) ? ((int)o).ToString() : string.Empty;
                textBox18.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X1Y1AxisDeceleration, ref o) ? ((int)o).ToString() : string.Empty;
                textBox22.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X1LocationSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.X1LocationSpeed.ToString();
                textBox29.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y1LocationSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.Y1LocationSpeed.ToString();
                textBox23.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X1axisLocationPos, ref o) ? ((int)o).ToString() : string.Empty;  //config.X1axisLocationPos.ToString();
                textBox30.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y1axisLocationPos, ref o) ? ((int)o).ToString() : string.Empty; //config.Y1axisLocationPos.ToString();
                textBox28.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X1axisHandSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.X1axisHandSpeed.ToString();
                textBox31.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y1axisHandSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.Y1axisHandSpeed.ToString();
                textBox32.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X1AxisSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.X1AxisSpeed.ToString();
                textBox33.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y1AxisSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.Y1AxisSpeed.ToString();
 
                textBox14.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X2Y2AxisAcceleration, ref o) ? ((int)o).ToString() : string.Empty;  //config.X2Y2AxisAcceleration.ToString();
                textBox13.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X2Y2AxisDeceleration, ref o) ? ((int)o).ToString() : string.Empty;  // config.X2Y2AxisDeceleration.ToString();
                textBox12.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X2LocationSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.X2LocationSpeed.ToString();
                textBox1.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y2LocationSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.Y2LocationSpeed.ToString();
                textBox8.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X2axisLocationPos, ref o) ? ((int)o).ToString() : string.Empty;  //config.X2axisLocationPos.ToString();
                textBox6.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y2axisLocationPos, ref o) ? ((int)o).ToString() : string.Empty;  //config.Y2axisLocationPos.ToString();
                textBox4.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X2axisHandSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.X2axisHandSpeed.ToString();
                textBox3.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y2axisHandSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.Y2axisHandSpeed.ToString();
                textBox5.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X2axisWaitPos, ref o) ? ((int)o).ToString() : string.Empty;  //config.X2axisWaitPos.ToString();
                textBox2.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y2axisWaitPos, ref o) ? ((int)o).ToString() : string.Empty;  //config.Y2axisWaitPos.ToString();
                textBox26.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X2AxisSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.X2AxisSpeed.ToString();
                textBox27.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y2AxisSpeed, ref o) ? ((int)o).ToString() : string.Empty;  //config.X2AxisSpeed.ToString();
                textBox24.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X1ScanOKPosition, ref o) ? ((int)o).ToString() : string.Empty;  //config.X1ScanOKPosition.ToString();
                textBox25.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y1ScanOKPosition, ref o) ? ((int)o).ToString() : string.Empty;  //config.Y1ScanOKPosition.ToString();
                textBox81.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.X1ScanBackPosition, ref o) ? ((int)o).ToString() : string.Empty;  //config.X1ScanBackPosition.ToString();
                textBox80.Text = opc.ReadOneItem_Wrapper(OPCOutputTag.Y1ScanBackPosition, ref o) ? ((int)o).ToString() : string.Empty;  //config.Y1ScanBackPosition.ToString();
            }
            catch (Exception e)
            {
                CommonUtil.WriteLog(LogType.Exc, string.Format("读取轴设备数据出现异常:{0}", e.Message));
            }
 
        }
 
        private void LoadDeviceStatus()
        {
            object o = new object();
            try
            {
                cbX1AxisEnable.Checked = opc.ReadOneItem_Wrapper(OPCOutputTag.X1AxisEnable, ref o) ? (bool)o : false;
                cbX2AxisEnable.Checked = opc.ReadOneItem_Wrapper(OPCOutputTag.X2AxisEnable, ref o) ? (bool)o : false;
                cbY1AxisEnable.Checked = opc.ReadOneItem_Wrapper(OPCOutputTag.Y1AxisEnable, ref o) ? (bool)o : false;
                cbY2AxisEnable.Checked = opc.ReadOneItem_Wrapper(OPCOutputTag.Y2AxisEnable, ref o) ? (bool)o : false;
            }
            catch (Exception e)
            {
                CommonUtil.WriteLog(LogType.Exc, string.Format("读取设备数据出现异常:{0}", e.Message));
            }
 
        }
 
        private void btnClearCheck_Click(object sender, EventArgs e)
        {
            SpotCheckData spotCheck = new SpotCheckData();
            spotCheck.ClearTodayCheck();
        }
 
        #region add by Patrick 2020-02-20
 
        public static event Action<ConfigStruct> OnConfigSaved;
        private void chkSaveOKLWImage_CheckedChanged(object sender, EventArgs e)
        {
            config.IsSaveSizeOKImage = chkSaveOKLWImage.Checked;
        }
        #endregion
    }
}