FrmBox.cs
31.2 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
829
830
831
832
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.Common;
using System.Reflection;
using log4net;
using OnlineStore.DeviceLibrary;
using System.IO.Ports;
using OnlineStore.LoadCSVLibrary;
using CodeLibrary;
using DeviceLib;
using UserFromControl;
namespace OnlineStore.DUOStore
{
public partial class FrmBox : FrmBase
{
public BoxBean BoxBean = null;
public FrmBox()
{
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
}
#region "初始化界面数据"
private bool LoadOk = false;
private void FrmTest_Load(object sender, EventArgs e)
{
LoadStore();
LoadIOList();
}
public void LoadStore()
{
if (BoxBean == null)
{
LogUtil.error("找不到对应的料仓");
this.Close();
return;
}
// this.groupBox3.Text = "设备[" + BoxBean.CID + "]状态";
this.Text = BoxBean.Name;
axisMoveControl1.LoadData(BoxBean, new AxisBean[] {BoxBean.MiddleAxis,BoxBean.UpdownAxis,BoxBean.InoutAxis,BoxBean.ComAxis });
ACBoxPosition acPosition = null;
if (BoxBean.PositionNumList.Count > 0)
{
cmbPosition.DataSource = BoxBean.PositionNumList;
cmbPosition.SelectedIndex = 0;
acPosition = CSVPositionReader<ACBoxPosition>.GetPositon(cmbPosition.Text);
//BoxBean.PositionNumList = positionNumList;
}
txtMiddleP1.Text = BoxBean.Config.MiddleAxis_P1.ToString();
txtUpdownP11.Text = BoxBean.Config.UpDownAxis_P11.ToString();
txtUpdownP12.Text = BoxBean.Config.UpDownAxis_P12.ToString();
txtUpDownP1.Text = BoxBean.Config.UpDownAxis_P1.ToString();
txtInOutP1.Text = BoxBean.Config.InOutAxis_P1.ToString();
txtComP1.Text = BoxBean.Config.CompAxis_P1.ToString();
txtUpDownP2.Text = BoxBean.Config.UpDownAxis_P2.ToString();
txtMiddleP11.Text = BoxBean.Config.MiddleAxis_P11.ToString();
txtInoutP11.Text = BoxBean.Config.InOutAxis_P11.ToString();
txtComP3.Text = BoxBean.Config.CompAxis_P3.ToString();
txtInOutP2.Text = BoxBean.Config.InOutAxis_P2.ToString();
LoadPData(acPosition);
chbDebug.Checked = BoxBean.IsDebug;
this.ShowInTaskbar = true;
// txtTempPort.Text = BoxBean.Config.Humiture_Port;
timer1.Start();
LoadOk = true;
}
#endregion
private bool preOpen = false;
public void StoreOpenStatus(bool isOpen)
{
if (preOpen.Equals(isOpen))
{
return;
}
preOpen = isOpen;
btnOutStore.Enabled = isOpen;
btnInStore.Enabled = isOpen;
btnStoreStart.Enabled = !isOpen;
btnStoreStop.Enabled = isOpen;
btnSotreReset.Enabled = isOpen;
btnStoreStart.Enabled = !isOpen;
btnSotreReset.Enabled = isOpen;
btnStoreStop.Enabled = isOpen;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (!this.Visible)
{
return;
}
ReadIOList();
if (chbDebug.Checked.Equals(BoxBean.IsDebug).Equals(false))
{
LoadOk = false;
chbDebug.Checked = BoxBean.IsDebug;
LoadOk = true;
}
// lblTemp.Text = BoxBean.humBean.currTempStr;
lblWarnMsg.Text = BoxBean.WarnMsg;
lblMoveInfo.Text = BoxBean.GetMoveStr();
if (BoxBean.MoveInfo.MoveType.Equals(MoveType.InStore))
{
lblMoveEquipInfo.Text = "入库:" + BoxBean.MoveInfo.MoveParam.ToStr();
}
else if (BoxBean.MoveInfo.MoveType.Equals(MoveType.OutStore))
{
lblMoveEquipInfo.Text = "出库:" + BoxBean.MoveInfo.MoveParam.ToStr();
}
else
{
lblMoveEquipInfo.Text = "";
// lblMoveEquipInfo.Text = "";
}
//ReadPosistion();
if (BoxBean.storeRunStatus > StoreRunStatus.Wait)
{
if (btnStoreStart.Enabled.Equals(true))
{
StoreOpenStatus(true);
}
lblThisSta.Text = BoxBean.GetRunStr();
//复位按钮状态显示
if (btnSotreReset.Enabled == false)
{
if ((BoxBean.storeRunStatus.Equals(StoreRunStatus.HomeMoving) || BoxBean.storeRunStatus.Equals(StoreRunStatus.Reset))
&& BoxBean.alarmType.Equals(AlarmType.None))
{
}
else
{
if (btnSotreReset.Enabled.Equals(false))
{
btnSotreReset.Enabled = true;
}
}
}
else
{
if ((BoxBean.storeRunStatus.Equals(StoreRunStatus.HomeMoving) || BoxBean.storeRunStatus.Equals(StoreRunStatus.Reset))
&& BoxBean.alarmType.Equals(AlarmType.None))
{
if (btnStoreStart.Enabled)
{
btnStoreStart.Enabled = false;
btnSotreReset.Enabled = false;
}
}
}
if (BoxBean.AutoInout.autoNext)
{
string msg = BoxBean.AutoInout.autoMsg;
lblMsg.Text = msg;
if (btnStartAuTo.Text.Equals("开始自动出入库"))
{
btnStartAuTo.Text = "停止自动出入库";
}
try
{
msg = msg.Replace("自动出库:", "");
msg = msg.Replace("自动入库:", "");
int index = BoxBean.PositionNumList.IndexOf(msg);
if (index >= 0 && (!msg.Equals("")))
{
cmbPosition.SelectedIndex = index;
}
}
catch (Exception ex) { }
}
else
{
// lblMsg.Text = "没有开启自动出入库";
if (btnStartAuTo.Text.Equals("停止自动出入库"))
{
btnStartAuTo.Text = "开始自动出入库";
}
}
}
else
{
lblThisSta.Text = "等待启动";
// lblWarnMsg.Text = "";
btnStartAuTo.Text = "开始自动出入库";
}
}
private void btnOutStore_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
InOutParam param = new InOutParam("", selectPositionNum, ktk);
BoxBean.StartOutStoreMove(param);
}
else
{
MessageBox.Show("请先启动料仓!");
}
}
private void btnInStore_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
BoxBean.StartInStoreMove(new InOutParam("", selectPositionNum, ktk));
}
else
{
MessageBox.Show("请先启动料仓!");
}
}
private LineMoveP LoadPostion()
{
LineMoveP ktk = new LineMoveP();
ktk.ComPress_P1 = FormUtil.GetIntValue(txtComP1);
ktk.ComPress_P2 = FormUtil.GetIntValue(txtComP2);
ktk.ComPress_P3 = FormUtil.GetIntValue(txtComP3);
ktk.InOut_P1 = FormUtil.GetIntValue(txtInOutP1);
ktk.InOut_P2 = FormUtil.GetIntValue(txtInOutP2);
ktk.InOut_P3 = FormUtil.GetIntValue(txtInOutP3);
ktk.Middle_P1 = FormUtil.GetIntValue(txtMiddleP1);
ktk.Middle_P2 = FormUtil.GetIntValue(txtMiddleP2);
ktk.UpDown_P1 = FormUtil.GetIntValue(txtUpDownP1);
ktk.UpDown_P2 = FormUtil.GetIntValue(txtUpDownP2);
ktk.UpDown_P3 = FormUtil.GetIntValue(txtUpDownP3);
ktk.UpDown_P4 = FormUtil.GetIntValue(txtUpDownP4);
ktk.UpDown_P5 = FormUtil.GetIntValue(txtUpDownP5);
ktk.UpDown_P6 = FormUtil.GetIntValue(txtUpDownP6);
return ktk;
}
private void cmbPosition_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbPosition.SelectedIndex >= 0)
{
string selectPositionNum = cmbPosition.Text;
ACBoxPosition acPosition = CSVPositionReader<ACBoxPosition>.GetPositon(selectPositionNum);
LoadPData(acPosition);
}
}
private void LoadPData(ACBoxPosition acPosition)
{
if (acPosition != null)
{
txtMiddleP2.Text = acPosition.MiddleAxis_P2.ToString();
txtUpDownP3.Text = acPosition.UpdownAxis_IH_P3.ToString();
txtUpDownP4.Text = acPosition.UpdownAxis_IL_P4.ToString();
txtUpDownP5.Text = acPosition.UpdownAxis_OH_P5.ToString();
txtUpDownP6.Text = acPosition.UpdownAxis_OL_P6.ToString();
txtInOutP3.Text = acPosition.InoutAxis_P3.ToString();
txtMiddleP2.Text = acPosition.MiddleAxis_P2.ToString();
int comP2 = BoxBean.Config.GetComP2(acPosition.BagHigh);
txtComP2.Text = comP2.ToString();
lblSize.Text = "尺寸:" + acPosition.BagWidth + "*" + acPosition.BagHigh;
}
}
private void btnSavePosition_Click(object sender, EventArgs e)
{
//料仓格子位置保存
string selectPositionNum = cmbPosition.Text;
ACBoxPosition acPosition = CSVPositionReader<ACBoxPosition>.GetPositon(selectPositionNum);
if (acPosition != null)
{
acPosition.MiddleAxis_P2 = FormUtil.GetIntValue(txtMiddleP2);
acPosition.InoutAxis_P3 = FormUtil.GetIntValue(txtInOutP3);
acPosition.UpdownAxis_IH_P3 = FormUtil.GetIntValue(txtUpDownP3);
acPosition.UpdownAxis_IL_P4 = FormUtil.GetIntValue(txtUpDownP4);
acPosition.UpdownAxis_OH_P5 = FormUtil.GetIntValue(txtUpDownP5);
acPosition.UpdownAxis_OL_P6 = FormUtil.GetIntValue(txtUpDownP6);
}
//位置配置
string appPath = Application.StartupPath;
//如果总配置文件存在,保存到总的配置文件
string positionConfigFile = appPath + ConfigAppSettings.GetValue(Setting_Init.BOX_ConfigPath);
if (!File.Exists(positionConfigFile))
{
string nameStr = BoxBean.ID.ToString();
positionConfigFile = positionConfigFile.Replace(".csv", "_" + nameStr + ".csv");
}
bool result = CSVPositionReader<ACBoxPosition>.SavePostion(positionConfigFile, acPosition);
if (!result)
{
MessageBox.Show("库位【" + selectPositionNum + "】保存失败!");
}
//料仓固定位置保存
bool needUpdate = false;
int inoup1 = FormUtil.GetIntValue(txtInOutP1);
int inoup2 = FormUtil.GetIntValue(txtInOutP2);
int inoutp11 = FormUtil.GetIntValue(txtInoutP11);
int comp1 = FormUtil.GetIntValue(txtComP1);
int comp2 = FormUtil.GetIntValue(txtComP2);
int comp3 = FormUtil.GetIntValue(txtComP3);
int mP1 = FormUtil.GetIntValue(txtMiddleP1);
int mp11 = FormUtil.GetIntValue(txtMiddleP11);
int udp1 = FormUtil.GetIntValue(txtUpDownP1);
int upp2 = FormUtil.GetIntValue(txtUpDownP2);
int upp11 = FormUtil.GetIntValue(txtUpdownP11);
int upp12 = FormUtil.GetIntValue(txtUpdownP12);
if (BoxBean.Config.MiddleAxis_P1 != mP1)
{
BoxBean.Config.MiddleAxis_P1 = mP1;
needUpdate = true;
}
if (BoxBean.Config.MiddleAxis_P11 != mp11)
{
BoxBean.Config.MiddleAxis_P11 = mp11;
needUpdate = true;
}
if (BoxBean.Config.InOutAxis_P1 != inoup1)
{
BoxBean.Config.InOutAxis_P1 = inoup1;
needUpdate = true;
}
if (BoxBean.Config.InOutAxis_P11 != inoutp11)
{
BoxBean.Config.InOutAxis_P11 = inoutp11;
needUpdate = true;
}
if (BoxBean.Config.InOutAxis_P2 != inoup2)
{
BoxBean.Config.InOutAxis_P2 = inoup2;
needUpdate = true;
}
if (BoxBean.Config.UpDownAxis_P1 != udp1)
{
BoxBean.Config.UpDownAxis_P1 = udp1;
needUpdate = true;
}
if (BoxBean.Config.UpDownAxis_P2 != upp2 )
{
BoxBean.Config.UpDownAxis_P2 = upp2;
needUpdate = true;
}
if (BoxBean.Config.UpDownAxis_P11 != upp11)
{
BoxBean.Config.UpDownAxis_P11 = upp11;
needUpdate = true;
}
if (BoxBean.Config.UpDownAxis_P12 != upp12 )
{
BoxBean.Config.UpDownAxis_P12 = upp12;
needUpdate = true;
}
if (BoxBean.Config.CompAxis_P3 != comp3 )
{
BoxBean.Config.CompAxis_P3 = comp3;
needUpdate = true;
}
if (BoxBean.Config.GetComP2(acPosition.BagHigh) != comp2 )
{
BoxBean.Config.UpdateComP2(acPosition.BagHigh,comp2);
needUpdate = true;
}
if (BoxBean.Config.CompAxis_P1 != comp1 )
{
BoxBean.Config.CompAxis_P1 = comp1;
needUpdate = true;
}
if (needUpdate)
{
//更新缓存
StoreManager.UpdateBoxConfig(BoxBean.Config);
}
}
private bool InOutIsIsP1()
{
int InOutDefaultPosition = ConfigAppSettings.GetIntValue(Setting_Init.InOutDefaultPosition);
int currValue = ACServerManager.GetActualtPosition(BoxBean.Config.InOut_Axis.DeviceName, BoxBean.Config.InOut_Axis.GetAxisValue());
if (currValue <= InOutDefaultPosition)
{
return true;
}
MessageBox.Show("叉子不在待机位,请先将叉子退回待机位(" + InOutDefaultPosition + ")", "警告(叉子在待机位时,才能移动升降轴和旋转轴) ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
private void AxisABSMove(ConfigMoveAxis moveAxis, TextBox txtValue, int targetSpeed)
{
if (moveAxis.IsSameAxis(BoxBean.Config.UpDown_Axis) || moveAxis.IsSameAxis(BoxBean.Config.UpDown_Axis))
{
if (!InOutIsIsP1())
{
return;
}
}
int targetPosition = FormUtil.GetIntValue(txtValue);
moveAxis.TargetPosition = targetPosition;
ACServerManager.AbsMove(moveAxis.DeviceName, moveAxis.GetAxisValue(), targetPosition, targetSpeed);
}
private void btnUpDownP1_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtUpDownP1, BoxBean.Config.UpDownAxis_P1_Speed);
}
private void btnUpDownP2_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtUpDownP2, BoxBean.Config.UpDownAxis_P2_Speed);
}
private void btnUpDownP3_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtUpDownP3, BoxBean.Config.UpDownAxis_P3_Speed);
}
private void btnUpDownP4_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtUpDownP4, BoxBean.Config.UpDownAxis_P4_Speed);
}
private void btnUpDownP5_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtUpDownP5, BoxBean.Config.UpDownAxis_P5_Speed);
}
private void btnUpDownP6_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtUpDownP6, BoxBean.Config.UpDownAxis_P6_Speed);
}
private void btnUpdownP11_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtUpdownP11, BoxBean.Config.UpDownAxis_P11_Speed);
}
private void btnInoutP11_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtInoutP11, BoxBean.Config.InOutAxis_P11_Speed);
}
private void btnMiddleP11_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtMiddleP11, BoxBean.Config.MiddleAxis_P11_Speed);
}
private void btnMiddleP1_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.Middle_Axis, txtMiddleP1, BoxBean.Config.MiddleAxis_P1_Speed);
}
private void btnMiddleP2_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.Middle_Axis, txtMiddleP2, BoxBean.Config.MiddleAxis_P2_Speed);
}
private void btnInOutP1_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.InOut_Axis, txtInOutP1, BoxBean.Config.InOutAxis_P1_Speed);
}
private void btnInOutP3_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.InOut_Axis, txtInOutP3, BoxBean.Config.InOutAxis_P3_Speed);
}
private void btnInOutP2_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.InOut_Axis, txtInOutP2, BoxBean.Config.InOutAxis_P2_Speed);
}
private void btnComP2_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.Comp_Axis, txtComP2, BoxBean.Config.CompAxis_P2_Speed);
}
private void btnComP1_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.Comp_Axis, txtComP1, BoxBean.Config.CompAxis_P1_Speed);
}
private void btnComP3_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.Comp_Axis, txtComP3, BoxBean.Config.CompAxis_P3_Speed);
}
int xWidth = SystemInformation.PrimaryMonitorSize.Width;//获取显示器屏幕宽度
int yHeight = SystemInformation.PrimaryMonitorSize.Height;//高度
private void btnStartAuTo_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
{
if (BoxBean.AutoInout.autoNext)
{
BoxBean.AutoInout.StopAuto();
btnStartAuTo.Text = "开始自动出入库";
}
else
{
DialogResult res = MessageBox.Show("确定开始自动出入库?", "提示", MessageBoxButtons.YesNo);
if (res.Equals(DialogResult.Yes) && cmbPosition.SelectedIndex >= 0)
{
int jiange = FormUtil.GetIntValue(txtJiange);
int currIndex = cmbPosition.SelectedIndex;
BoxBean.AutoInout.StartAuto(jiange, currIndex);
string poText = cmbPosition.Text;
BoxBean.AutoInout.autoMsg = "自动出库:" + poText;
LogUtil.info(BoxBean.Name + "开启自动出入库模式,开始位置【" + poText + "】(索引=" + currIndex + "),间隔=" + jiange + ",入库开始!");
//BoxBean.StartOutStoreMove(new InOutStoreParam("", poText));
BoxBean.StartInStoreMove(new InOutParam("", poText));
btnStartAuTo.Text = "停止自动出入库";
}
}
}
else
{
MessageBox.Show("请先启动料仓!");
}
}
private void btnAxisP_Click(object sender, EventArgs e)
{
FormManager.ShowAxisDebug(BoxBean);
}
private void btnStoreStart_Click(object sender, EventArgs e)
{
bool result = BoxBean.StartRun(true);
if (result)
{
StoreOpenStatus(true);
}
else
{
MessageBox.Show(BoxBean.WarnMsg);
}
}
private void 停止ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
{
BoxBean.StopRun();
StoreOpenStatus(false);
}
else
{
MessageBox.Show("请先启动料仓!");
}
}
catch (Exception ex)
{
LogUtil.error("出错:" + ex.StackTrace);
}
}
private void btnSotreReset_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
{
this.BoxBean.Reset();
btnSotreReset.Enabled = false;
}
else
{
MessageBox.Show("请先启动料仓!");
}
}
private void 查看IOToolStripMenuItem_Click(object sender, EventArgs e)
{
// FormManager.ShowIOShow(BoxBean);
}
private void 料仓运转ONToolStripMenuItem_Click(object sender, EventArgs e)
{
btnAxisOn.Enabled = false;
LogUtil.info(BoxBean.Name + "点击:" + btnAxisOn.Text);
BoxBean.OpenAllAxis(false);
btnAxisOn.Enabled = true;
}
private void 料仓运转OFFToolStripMenuItem_Click(object sender, EventArgs e)
{
LogUtil.info(BoxBean.Name + "点击:" + btnAxisOff.Text);
BoxBean.CloseAllAxis();
}
private void FrmStoreBox_Shown(object sender, EventArgs e)
{
this.btnUpDownP1.ForeColor = System.Drawing.Color.Red;
this.btnUpDownP2.ForeColor = System.Drawing.Color.Red;
this.btnUpDownP3.ForeColor = System.Drawing.Color.Red;
this.btnUpDownP4.ForeColor = System.Drawing.Color.Red;
this.btnUpDownP5.ForeColor = System.Drawing.Color.Red;
this.btnUpDownP6.ForeColor = System.Drawing.Color.Red;
//this.lblWarnMsg.ForeColor = System.Drawing.Color.Red;
//this.lblThisSta.ForeColor = System.Drawing.Color.Red;
this.btnComP1.ForeColor = System.Drawing.Color.Purple;
this.btnComP3.ForeColor = System.Drawing.Color.Purple;
this.btnComP2.ForeColor = System.Drawing.Color.Purple;
this.btnInOutP2.ForeColor = System.Drawing.Color.Green;
this.btnInOutP1.ForeColor = System.Drawing.Color.Green;
this.btnInOutP3.ForeColor = System.Drawing.Color.Green;
this.btnMiddleP1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.btnMiddleP2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
}
private void btnTempInit_Click(object sender, EventArgs e)
{
string port = txtTempPort.Text.ToString();
HumitureController.Init(port);
}
private void btnTempClose_Click(object sender, EventArgs e)
{
HumitureController.CloseAllPort();
}
private void btnSelTemp_Click(object sender, EventArgs e)
{
// HumitureParam param = BoxBean.humBean.QueryData();
// txtTemp.Text = param.Temperate.ToString();
// txtHum.Text = param.Humidity.ToString();
}
internal void DebugStatus(bool isDebug)
{
axisMoveControl1.Enabled = isDebug;
groupInout.Enabled = isDebug;
}
private void chbDebug_CheckedChanged(object sender, EventArgs e)
{
if (!LoadOk)
{
return;
}
if (chbDebug.Checked)
{
if (!BoxBean.IsDebug)
{
DialogResult result = MessageBox.Show("是否切换到调试状态?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result.Equals(DialogResult.Yes))
{
BoxBean.IsDebug = true;
BoxBean.Config.IsInDebug = 1;
StoreManager.UpdateBoxConfig(BoxBean.Config);
LogUtil.info("用户切换到调试状态 ");
}
}
}
else
{
if (BoxBean.IsDebug)
{
DialogResult result = MessageBox.Show("是否切换到正常工作状态?", "是否确认切换", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
if (result.Equals(DialogResult.Yes))
{
BoxBean.IsDebug = false;
BoxBean.Config.IsInDebug = 0;
StoreManager.UpdateBoxConfig(BoxBean.Config);
LogUtil.info("用户切换到正常工作状态 ");
}
}
}
}
private void btnUpdown_Click(object sender, EventArgs e)
{
string PortName = BoxBean.Config.UpDown_Axis.DeviceName;
int slvAddr = BoxBean.Config.UpDown_Axis.GetAxisValue();
string ioIP = "192.168.200.13";
int ioIndex = 0;
// if (store.Config.StoreDIList.ContainsKey(IO_Type.UpdownPositionSingal))
if (BoxBean.Config.DIList.ContainsKey(IO_Type.Fixture_Check))
{
ioIP = BoxBean.Config.DIList[IO_Type.Fixture_Check].IO_IP;
ioIndex = BoxBean.Config.DIList[IO_Type.Fixture_Check].GetIOAddr();
}
FrmPositionTool frm = new FrmPositionTool(PortName, slvAddr, ioIP, ioIndex, Text, BoxBean.ID);
frm.ShowDialog();
}
private void btnUpdownP12_Click(object sender, EventArgs e)
{
AxisABSMove(BoxBean.Config.UpDown_Axis, txtUpdownP12, BoxBean.Config.UpDownAxis_P12_Speed);
}
#region IO处理
Dictionary<string, IOTextControl> DIControlList = new Dictionary<string, IOTextControl>();
Dictionary<string, IOTextControl> DOControlList = new Dictionary<string, IOTextControl>();
private void LoadIOList()
{
int roleindex = 0;
this.tableLayoutPanel1.RowStyles.Clear();
this.tableLayoutPanel1.RowCount = BoxBean.Config.DIList.Count;
foreach (ConfigIO ioValue in BoxBean.Config.DIList.Values)
{
this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 26));
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
this.tableLayoutPanel1.Controls.Add(control, 0, roleindex);
roleindex++;
DIControlList.Add(ioValue.ProName, control);
}
tableLayoutPanel2.RowStyles.Clear();
this.tableLayoutPanel2.RowCount = BoxBean.Config.DOList.Count;
roleindex = 0;
foreach (ConfigIO ioValue in BoxBean.Config.DOList.Values)
{
this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
this.tableLayoutPanel2.Controls.Add(control, 0, roleindex);
roleindex++;
DOControlList.Add(ioValue.ProName, control);
}
this.SuspendLayout();
}
private void ReadIOList()
{
foreach (string key in DIControlList.Keys)
{
IOTextControl control = DIControlList[key];
int iov = (int)BoxBean.IOValue(key);
if (iov != control.IOValue)
{
control.IOValue = iov;
control.ShowData();
}
}
foreach (string key in this.DOControlList.Keys)
{
IOTextControl control = DOControlList[key];
int iov = (int)BoxBean.IOValue(key);
if (iov != control.IOValue)
{
control.IOValue = iov;
control.ShowData();
}
}
}
#endregion
private void btnDoorUp_Click(object sender, EventArgs e)
{
BoxBean.CylinderMove(null, IO_Type.OutDoor_Down, IO_Type.OutDoor_Up);
}
private void btnDoorDown_Click(object sender, EventArgs e)
{
BoxBean.CylinderMove(null, IO_Type.OutDoor_Up, IO_Type.OutDoor_Down);
}
private void btnNgPro_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
BoxBean.StartInStoreMove(new InOutParam("", selectPositionNum, ktk,1));
}
else
{
MessageBox.Show("请先启动料仓!");
}
}
private void btnSingleOut_Click(object sender, EventArgs e)
{
if (BoxBean.storeRunStatus >= StoreRunStatus.HomeMoving)
{
string selectPositionNum = cmbPosition.Text;
LineMoveP ktk = LoadPostion();
InOutParam param = new InOutParam("", selectPositionNum, ktk,1);
BoxBean.StartOutStoreMove(param);
}
else
{
MessageBox.Show("请先启动料仓!");
}
}
}
}