FrmInputEquip.cs
31.1 KB
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
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
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.Runtime.CompilerServices;
using System.Threading;
using System.IO;
using System.Runtime.InteropServices;
using OnlineStore.DeviceLibrary;
using log4net;
using System.Reflection;
using UserFromControl;
using OnlineStore.LoadCSVLibrary;
using OnlineStore.Common;
namespace OnlineStore.XLRStore
{
internal partial class FrmInputEquip : FrmBase
{
private bool IsLoad = false;
private InputEquip inputEquip;
internal FrmInputEquip(InputEquip moveEquip)
{
this.inputEquip = moveEquip;
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
LoadIOList();
}
protected Dictionary<string, IOTextControl> DIControlList = new Dictionary<string, IOTextControl>();
protected Dictionary<string, IOTextControl> DOControlList = new Dictionary<string, IOTextControl>();
protected void ReadIOList()
{
foreach (string key in DIControlList.Keys)
{
IOTextControl control = DIControlList[key];
int iov = (int)IOManager.IOValue(key, inputEquip.DeviceID);
if (iov != control.IOValue)
{
control.IOValue = iov;
control.ShowData();
}
}
foreach (string key in this.DOControlList.Keys)
{
IOTextControl control = DOControlList[key];
int iov = (int)IOManager.DOValue(key, inputEquip.DeviceID);
if (iov != control.IOValue)
{
control.IOValue = iov;
control.ShowData();
}
}
}
protected void StartDebug()
{
if (inputEquip.runStatus.Equals(RunStatus.Wait))
{
bool result = inputEquip.StartRun();
if (result)
{
FormStatus(true);
}
else
{
MessageBox.Show(inputEquip.WarnMsg, "启动失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show(inputEquip.Name + "已启动,不能重复启动", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void StopRun()
{
try
{
if (inputEquip.runStatus <= RunStatus.Wait)
{
MessageBox.Show(inputEquip.Name + "请先启动设备", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
LogUtil.info(inputEquip.Name + "点击:停止运行");
inputEquip.StopRun();
FormStatus(false);
}
}
catch (Exception ex)
{
LogUtil.error("出错:", ex);
}
}
private void Reset()
{
if (inputEquip.runStatus >= (RunStatus.HomeMoving))
{
LogUtil.info(inputEquip.Name + "点击 :复位");
inputEquip.Reset();
}
else
{
MessageBox.Show(inputEquip.Name + "请先启动设备", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
private void LoadIOList()
{
int maxCount = 20;
int roleindex = 0;
this.tableLayoutPanel1.RowStyles.Clear();
this.tableLayoutPanel1.RowCount = maxCount;
//this.tableLayoutPanel3.RowStyles.Clear();
//this.tableLayoutPanel3.RowCount = maxCount;
int i = 0;
foreach (ConfigIO ioValue in inputEquip.Config.DIList.Values)
{
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
//if (i >= maxCount)
//{
// this.tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
// this.tableLayoutPanel3.Controls.Add(control, 0, roleindex - maxCount);
//}
//else
{
this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
this.tableLayoutPanel1.Controls.Add(control, 0, roleindex);
}
roleindex++;
i++;
DIControlList.Add(ioValue.ProName, control);
}
tableLayoutPanel2.RowStyles.Clear();
this.tableLayoutPanel2.RowCount = maxCount;
roleindex = 0;
i = 0;
foreach (ConfigIO ioValue in inputEquip.Config.DOList.Values)
{
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
control.Click += Control_Click;
this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
this.tableLayoutPanel2.Controls.Add(control, 0, roleindex);
roleindex++;
i++;
DOControlList.Add(ioValue.ProName, control);
}
this.SuspendLayout(); //此处为不闪屏,一定要有的!
cmbWriteIO.DataSource = new List<ConfigIO>(inputEquip.Config.DOList.Values);
cmbWriteIO.ValueMember = "ProName";
cmbWriteIO.DisplayMember = "DisplayStr";
}
private void Control_Click(object sender, EventArgs e)
{
IOTextControl control = (IOTextControl)sender;
string name = control.Name.Substring(3, control.Name.Length - 3);
List<string> keyList = new List<string>(DOControlList.Keys);
int index = keyList.IndexOf(name);
if (index >= 0)
{
cmbWriteIO.SelectedIndex = index;
}
}
private bool IsInCheck = false;
private void timer1_Tick(object sender, EventArgs e)
{
try
{
if (!this.Visible)
{
return;
}
clampJawControl1.UpdateSta();
ReadIOList();
lblName.BackColor = inputEquip.GetShowColor();
lblStoreStatus.Text = inputEquip.GetRunStr();
if (inputEquip.runStatus > RunStatus.Wait)
{
if (btnStart.Enabled)
{
FormStatus(true);
}
}
else
{
if (!btnStart.Enabled)
{
FormStatus(false);
}
}
lblThisSta.Text = inputEquip.WarnMsg;
lblMoveInfo.Text = inputEquip.GetMoveStr();
if (inputEquip.runStatus.Equals(RunStatus.Runing) && inputEquip.MoveInfo.MoveType.Equals(MoveType.None))
{
groupBox12.Enabled = true;
}
else
{
groupBox12.Enabled = false;
}
if (inputEquip.IsNoReelAlarm() && (!inputEquip.ClampEmptyMove))
{
btnHlhasReel.Visible = true;
}
else
{
btnHlhasReel.Visible = false;
}
string text = "";
}
catch (Exception ex)
{
LogUtil.error(inputEquip.Name + "界面定时器出错:", ex);
}
}
private void FrmTest_FormClosing(object sender, FormClosingEventArgs e)
{
// KNDAIManager.NeedShow = false;
try
{
if (this.timer1.Enabled)
{
this.timer1.Enabled = false;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.StackTrace, "Exception(异常)", MessageBoxButtons.OK, MessageBoxIcon.Error);
LogUtil.error("", ex);
}
}
private void btnOpenDo_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.HIGH);
}
private void btnWriteSingleDO_Click(object sender, EventArgs e)
{
WriteDO(IO_VALUE.LOW);
}
private void WriteDO(IO_VALUE value)
{
string deviceName = txtDoName.Text;
int index = FormUtil.GetIntValue(txtDOIndex);
// IO_VALUE value = checkBox1.Checked ? IO_VALUE.HIGH : IO_VALUE.LOW;
int time = FormUtil.GetIntValue(txtWriteTime);
int slaveId = FormUtil.GetIntValue(txtSlaveId);
if (time > 0)
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value, time);
}
else
{
IOManager.instance.WriteSingleDO(deviceName, (byte)slaveId, (ushort)index, (IO_VALUE)value);
}
}
private ConfigIO GetSelectDO()
{
string text = cmbWriteIO.SelectedValue.ToString();
string newType = text.Replace("SW1_", "SW_").Replace("SW2_", "SW_").Replace("SW3_", "SW_").Replace("SW4_", "SW_");
if (inputEquip.Config.DOList.ContainsKey(newType))
{
ConfigIO io = inputEquip.Config.DOList[newType];
return io;
}
return null;
}
IOTextControl selectControl = null;
private void cmbWriteIO_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbWriteIO.SelectedIndex >= 0)
{
ConfigIO io = GetSelectDO();
if (io != null)
{
// txtIp.Text = io.DeviceName;
txtDOIndex.Text = io.GetIOAddr().ToString();
txtDoName.Text = io.IO_IP;
txtSlaveId.Text = io.SlaveID.ToString();
lblAddr.Text = txtDoName.Text + "_" + txtDOIndex.Text;
IOTextControl newControl = DOControlList[io.ProName];
if (selectControl != null) { selectControl.BackColor = Color.White; }
newControl.BackColor = Color.SkyBlue;
selectControl = newControl;
//txtIOInfo.Text = "IP:" + io.DeviceName + " /" + io.GetIOAddr().ToString();
}
}
}
private void FrmInputEquip_Load(object sender, EventArgs e)
{
cmbInstoreShelf.SelectedIndex = 0;
cmbInstoreTargetP.SelectedIndex = 0;
cmbOutStartP.SelectedIndex = 0;
cmbOutShelf.SelectedIndex = 0;
LoadPosList(cmbInstorePos, 0);
LoadPosList(cmbOutstorePos, 0);
chbDebug.Checked = inputEquip.IsDebug;
chbMoveStop.Checked = inputEquip.MoveStop;
if (inputEquip.ClampJaw == null)
{
clampJawControl1.Visible = false;
btnClampRelax.Visible = true;
btnClampWork.Visible = true;
}
else
{
clampJawControl1.Visible = true;
btnClampRelax.Visible = false;
btnClampWork.Visible = false;
clampJawControl1.clampJaw = inputEquip.ClampJaw;
clampJawControl1.ShowData();
}
axisMoveControl1.LoadData(inputEquip, new AxisBean[] { inputEquip.MiddleAxis, inputEquip.UpdownAxis });
FrmBatchMove frmMove1 = new FrmBatchMove(inputEquip.BatchMove_A);
AddForm(tabControl1, " " + inputEquip.BatchMove_A.Name + " ", frmMove1);
FrmBatchMove frmMove2 = new FrmBatchMove(inputEquip.BatchMove_B);
AddForm(tabControl1, " " + inputEquip.BatchMove_B.Name + " ", frmMove2);
PointEditEnable(false);
checkBox1.Checked = inputEquip.AutoInput;
LoadPoint();
IsLoad = true;
}
private void LoadPoint()
{
InputEquip_Config config = inputEquip.Config;
mideleAxisP1.SetMoveData(inputEquip.MiddleAxis, config.Middle_P1_Speed, config.Middle_P1);
mideleAxisP2.SetMoveData(inputEquip.MiddleAxis, config.Middle_P2_Speed, config.Middle_P2_ATake);
mideleAxisP3.SetMoveData(inputEquip.MiddleAxis, config.Middle_P3_Speed, config.Middle_P3_BTake);
mideleAxisP4.SetMoveData(inputEquip.MiddleAxis, config.Middle_P4_Speed, config.Middle_P4_AUpper);
mideleAxisP5.SetMoveData(inputEquip.MiddleAxis, config.Middle_P5_Speed, config.Middle_P5_BUpper);
mideleAxisP6.SetMoveData(inputEquip.MiddleAxis, config.Middle_P6_Speed, config.Middle_P6_NG);
mideleAxisP7.SetMoveData(inputEquip.MiddleAxis, config.Middle_P7_Speed, config.Middle_P7_AUnder);
mideleAxisP8.SetMoveData(inputEquip.MiddleAxis, config.Middle_P8_Speed, config.Middle_P8_BUnder);
updownAxisP1.SetMoveData(inputEquip.UpdownAxis, config.Updown_P1_Speed, config.Updown_P1);
updownAxisP2.SetMoveData(inputEquip.UpdownAxis, config.Updown_P2_Speed, config.Updown_P2_ATake);
updownAxisP3.SetMoveData(inputEquip.UpdownAxis, config.Updown_P3_Speed, config.Updown_P3_BTake);
updownAxisP4.SetMoveData(inputEquip.UpdownAxis, config.Updown_P4_Speed, config.Updown_P4_AUpperH);
updownAxisP5.SetMoveData(inputEquip.UpdownAxis, config.Updown_P5_Speed, config.Updown_P5_AUpperL);
updownAxisP6.SetMoveData(inputEquip.UpdownAxis, config.Updown_P6_Speed, config.Updown_P6_AUnderH);
updownAxisP7.SetMoveData(inputEquip.UpdownAxis, config.Updown_P7_Speed, config.Updown_P7_AUnderL);
updownAxisP8.SetMoveData(inputEquip.UpdownAxis, config.Updown_P8_Speed, config.Updown_P8_NGH);
updownAxisP9.SetMoveData(inputEquip.UpdownAxis, config.Updown_P9_Speed, config.Updown_P9_NGL);
updownAxisP10.SetMoveData(inputEquip.UpdownAxis, config.Updown_P10_Speed, config.Updown_P10_BUpperH);
updownAxisP11.SetMoveData(inputEquip.UpdownAxis, config.Updown_P11_Speed, config.Updown_P11_BUpperL);
updownAxisP12.SetMoveData(inputEquip.UpdownAxis, config.Updown_P12_Speed, config.Updown_P12_BUnderH);
updownAxisP13.SetMoveData(inputEquip.UpdownAxis, config.Updown_P13_Speed, config.Updown_P13_BUnderL);
}
protected void AddForm(TabControl tabcon, string text, Form form)
{
//text = text.PadRight(10, ' ');
TabPage lineTabPage = new TabPage(text);
// lineTabPage.AutoScroll = true;
// lineTabPage.Tag = StoreBean;
Panel linePan = new Panel();
linePan.Dock = DockStyle.Fill;
linePan.AutoScroll = true;
lineTabPage.Controls.Add(linePan);
form.FormBorderStyle = FormBorderStyle.None;
form.TopLevel = false;
linePan.Controls.Add(form);
form.Dock = DockStyle.Fill;
linePan.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Show();
//tabPageList.Add(lineTabPage);
tabcon.Controls.Add(lineTabPage);
}
private void cmbWriteIO_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index < 0)
{
return;
}
e.DrawBackground();
e.DrawFocusRectangle();
if (cmbWriteIO.Items.Count > e.Index)
{
ConfigIO io = (ConfigIO)cmbWriteIO.Items[e.Index];
e.Graphics.DrawString(io.DisplayStr, e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
}
}
private void btnReadIO_Click(object sender, EventArgs e)
{
ReadIOList();
}
private void FrmIOStatus_Shown(object sender, EventArgs e)
{
timer1.Start();
}
private void btnStart_Click(object sender, EventArgs e)
{
if (inputEquip.runStatus.Equals(RunStatus.Wait))
{
LogUtil.info(inputEquip.Name + "点击:启用调试");
StartDebug();
}
else
{
LogUtil.info(inputEquip.Name + "点击:复位");
Reset();
}
}
internal void FormStatus(bool isStart)
{
//btnStart.Enabled = !isStart;
btnStop.Enabled = true;
if (isStart)
{
btnStart.Text = "复位";
}
else
{
btnStart.Text = "启动调试";
}
//btnReset.Enabled = isStart;
}
private void btnStop_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.Name + "点击:停止");
StopRun();
}
private void chbDebug_CheckedChanged(object sender, EventArgs e)
{
if (!IsLoad)
{
return;
}
if (chbDebug.Checked)
{
if (!inputEquip.IsDebug)
{
DialogResult result = MessageBox.Show("是否切换到调试状态?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result.Equals(DialogResult.Yes))
{
inputEquip.IsDebug = true;
inputEquip.Config.IsDebug = 1;
StoreManager.SaveInputEquipConfig(inputEquip.Config);
inputEquip.ChangeDebug(true);
LogUtil.info(inputEquip.Name + "用户切换到调试状态 ");
}
}
}
else
{
if (inputEquip.IsDebug)
{
DialogResult result = MessageBox.Show("是否切换到正常工作状态?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result.Equals(DialogResult.Yes))
{
inputEquip.IsDebug = false;
inputEquip.Config.IsDebug = 0;
StoreManager.SaveInputEquipConfig(inputEquip.Config);
inputEquip.ChangeDebug(false);
LogUtil.info(inputEquip.Name + "用户切换到正常工作状态 ");
}
}
}
}
private void btnCloseAll_Click(object sender, EventArgs e)
{
foreach (Control con in groupDO.Controls)
{
if (con is Button)
{
con.BackColor = BackColor = Color.White;
}
}
foreach (ConfigIO io in inputEquip.baseConfig.DOList.Values)
{
IOManager.instance.WriteSingleDO(io.IO_IP, io.SlaveID, io.GetIOAddr(), IO_VALUE.LOW);
}
}
private void chbMoveStop_CheckedChanged(object sender, EventArgs e)
{
if (!IsLoad)
{
return;
}
inputEquip.MoveStop = chbMoveStop.Checked;
LogUtil.info(inputEquip.Name + "用户切换是否暂停: " + inputEquip.MoveStop);
}
private void Shelf_StopUp_A_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_A.Name + "点击:" + Shelf_StopUp_A.Text);
inputEquip.BatchMove_A.StopUp();
}
private void Shelf_StopDown_A_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_A.Name + "点击:" + Shelf_StopDown_A.Text);
inputEquip.BatchMove_A.StopDown();
}
private void LineStart_A_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_A.Name + "点击:" + LineStart_A.Text);
inputEquip.BatchMove_A.LineRun();
}
private void LineBack_A_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_A.Name + "点击:" + LineBack_A.Text);
inputEquip.BatchMove_A.LineBack();
}
private void LineStop_A_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_A.Name + "点击:" + LineStop_A.Text);
inputEquip.BatchMove_A.LineStop();
}
private void Shelf_StopUp_B_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_B.Name + "点击:" + Shelf_StopUp_B.Text);
inputEquip.BatchMove_B.StopUp();
}
private void Shelf_StopDown_B_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_B.Name + "点击:" + Shelf_StopDown_B.Text);
inputEquip.BatchMove_B.StopDown();
}
private void LineStart_B_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_B.Name + "点击:" + LineStart_B.Text);
inputEquip.BatchMove_B.LineRun();
}
private void LineBack_B_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_B.Name + "点击:" + LineBack_B.Text);
inputEquip.BatchMove_B.LineBack();
}
private void LineStop_B_Click(object sender, EventArgs e)
{
LogUtil.info(inputEquip.BatchMove_B.Name + "点击:" + LineStop_B.Text);
inputEquip.BatchMove_B.LineStop();
}
private void btnSave_Click(object sender, EventArgs e)
{
inputEquip.Config.Updown_P1 = updownAxisP1.PointValue;
inputEquip.Config.Updown_P2_ATake = updownAxisP2.PointValue;
inputEquip.Config.Updown_P3_BTake = updownAxisP3.PointValue;
inputEquip.Config.Updown_P4_AUpperH = updownAxisP4.PointValue;
inputEquip.Config.Updown_P5_AUpperL = updownAxisP5.PointValue;
inputEquip.Config.Updown_P6_AUnderH = updownAxisP6.PointValue;
inputEquip.Config.Updown_P7_AUnderL = updownAxisP7.PointValue;
inputEquip.Config.Updown_P8_NGH = updownAxisP8.PointValue;
inputEquip.Config.Updown_P9_NGL = updownAxisP9.PointValue;
inputEquip.Config.Updown_P10_BUpperH = updownAxisP10.PointValue;
inputEquip.Config.Updown_P11_BUpperL = updownAxisP11.PointValue;
inputEquip.Config.Updown_P12_BUnderH = updownAxisP12.PointValue;
inputEquip.Config.Updown_P13_BUnderL = updownAxisP13.PointValue;
inputEquip.Config.Middle_P1 = mideleAxisP1.PointValue;
inputEquip.Config.Middle_P2_ATake = mideleAxisP2.PointValue;
inputEquip.Config.Middle_P3_BTake = mideleAxisP3.PointValue;
inputEquip.Config.Middle_P4_AUpper = mideleAxisP4.PointValue;
inputEquip.Config.Middle_P5_BUpper = mideleAxisP5.PointValue;
inputEquip.Config.Middle_P6_NG = mideleAxisP6.PointValue;
inputEquip.Config.Middle_P7_AUnder = mideleAxisP7.PointValue;
inputEquip.Config.Middle_P8_BUnder = mideleAxisP8.PointValue;
StoreManager.SaveInputEquipConfig(inputEquip.Config);
MessageBox.Show("保存成功");
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void PointEditEnable(bool enable)
{
groupBox2.Enabled = enable;
groupBox5.Enabled = enable;
groupBox7.Enabled = enable;
groupBox8.Enabled = enable;
groupBox9.Enabled = enable;
groupBox10.Enabled = enable;
groupBox11.Enabled = enable;
axisMoveControl1.Enabled= enable;
}
private void btnPointEditEnable_Click(object sender, EventArgs e)
{
if (!IsLoad)
{
return;
}
FrmPwd fw = new FrmPwd(10);
DialogResult result = fw.ShowDialog();
if (!result.Equals(DialogResult.OK))
{
LogUtil.info("打开入料机构点位调试时,没有正确输入密码");
return;
}
PointEditEnable(true);
}
internal void FrmInputEquip_VisibleChanged(object sender, EventArgs e)
{
if (!IsLoad)
{
return;
}
}
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (!IsLoad)
{
return;
}
PointEditEnable(false);
}
private void BtnInStoreTest_Click(object sender, EventArgs e)
{
int startShelf = cmbInstoreShelf.SelectedIndex + 1;
string pos = cmbInstorePos.Text;
if (String.IsNullOrEmpty(pos))
{
MessageBox.Show("请选择目标库位", "提示");
return;
}
BoxPosition posiiton = CSVPositionReader<BoxPosition>.GetPositon(pos);
InOutParam param = new InOutParam(new InOutPosInfo("InstoreTEST", pos, posiiton.BagHigh, posiiton.BagWidth));
param.ShelfType = startShelf;
LogUtil.info("点击 " + BtnInStoreTest.Text + " :料串[" + startShelf + "]->" + param.PosInfo.ToStr());
inputEquip.StartInstore(param);
}
private void btnOutStoreTest_Click(object sender, EventArgs e)
{
int startShelf = cmbOutShelf.SelectedIndex + 1;
string pos = cmbOutstorePos.Text;
if (String.IsNullOrEmpty(pos))
{
MessageBox.Show("请选择目标库位", "提示");
return;
}
BoxPosition posiiton = CSVPositionReader<BoxPosition>.GetPositon(pos);
InOutParam param = new InOutParam(new InOutPosInfo("OutstoreTEST", pos, posiiton.BagHigh, posiiton.BagWidth));
param.ShelfType = startShelf;
LogUtil.info("点击 " + btnOutStoreTest.Text + " :" + param.PosInfo.ToStr() + "->料串[" + startShelf + "]");
inputEquip.StartOutstore(param);
}
private void cmbInstoreTargetP_SelectedIndexChanged(object sender, EventArgs e)
{
if (!IsLoad)
{
return;
}
LoadPosList(cmbInstorePos, cmbInstoreTargetP.SelectedIndex);
}
private void cmbOutShelf_SelectedIndexChanged(object sender, EventArgs e)
{
if (!IsLoad)
{
return;
}
LoadPosList(cmbOutstorePos, cmbOutStartP.SelectedIndex);
}
private void LoadPosList(ComboBox cmb, int pIndex)
{
List<string> allList = StoreManager.XLRStore.boxEquip.PositionNumList;
List<string> positions = new List<string>();
if (pIndex.Equals(0))
{
positions = (from m in StoreManager.XLRStore.boxEquip.PositionNumList where m.Contains("AA") select m).ToList<string>();
}
else if (pIndex.Equals(1))
{
positions = (from m in StoreManager.XLRStore.boxEquip.PositionNumList where m.Contains("BB") select m).ToList<string>();
}
cmb.DataSource = null;
cmb.Items.Clear();
cmb.DataSource = positions;
if (positions.Count > 0)
{
cmb.SelectedIndex = 0;
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (!IsLoad)
{
return;
}
if (checkBox1.Checked)
{
if (!inputEquip.AutoInput)
{
DialogResult result = MessageBox.Show("检测到料串自动入库?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result.Equals(DialogResult.Yes))
{
checkBox1.Checked = true;
inputEquip.AutoInput = true;
ConfigAppSettings.SaveValue(Setting_Init.AutoInput, 1);
LogUtil.info(inputEquip.Name + "检测到料串自动入库= " + checkBox1.Checked);
}
}
}
else
{
if (inputEquip.AutoInput)
{
DialogResult result = MessageBox.Show("关闭检测到料串自动入库?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result.Equals(DialogResult.Yes))
{
checkBox1.Checked = false;
inputEquip.AutoInput = false;
ConfigAppSettings.SaveValue(Setting_Init.AutoInput, 0);
LogUtil.info(inputEquip.Name + "检测到料串自动入库= " + checkBox1.Checked);
}
}
}
}
private void btnClampWork_Click(object sender, EventArgs e)
{
inputEquip.ClampWork(null, false);
}
private void btnClampRelax_Click(object sender, EventArgs e)
{
inputEquip.ClampRelax(null);
}
#region 夹爪循环测试
Thread thread;
private void btnClampJawStart_Click(object sender, EventArgs e)
{
if(inputEquip.ClampJaw.IsMoving())
{
MessageBox.Show("夹爪正在运行,稍后再开始!");
return;
}
enable = true;
cnt = 0;
thread = new Thread(ClampJawCycleTest);
thread.IsBackground = true;
thread.Start();
MessageBox.Show("夹爪循环测试开始!");
MessageBox.Show("夹爪循环测试开始!");
}
private void btnClampJawStop_Click(object sender, EventArgs e)
{
enable = false;
LogUtil.info($"夹爪循环测试结束!");
MessageBox.Show("夹爪循环测试结束!");
}
bool enable = false;
int cnt = 0;
private void ClampJawCycleTest()
{
while (enable)
{
inputEquip.ClampJaw.Relax();
while (!inputEquip.ClampJaw.IsReached())
{
Thread.Sleep(300);
}
inputEquip.ClampJaw.Push();
while (!inputEquip.ClampJaw.IsReached())
{
Thread.Sleep(300);
}
cnt++;
LogUtil.info($"夹爪释放夹紧{cnt}次");
Thread.Sleep(8000);
}
}
#endregion
}
}