MainMachine.cs
28.5 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
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DeviceLibrary
{
public partial class MainMachine : IRobot
{
public string Name { get; set; } = "AutoCount";
private bool _canRunning = true;
public bool canRunning
{
get { return _canRunning; }
set
{
if (_canRunning != value) {
Msg.setlogones();
}
_canRunning = value;
}
}
public bool isBusy { get; set; } = false;
public bool isAlarm { get; set; } = false;
public RunStatus runStatus { get; set; } = RunStatus.Stop;
public Robot_Config Config { get; set; }
public bool UserPause { get; set; } = false;
public enum CarPosition {
OnPosition,
BadPosition,
NoCar
}
public CarPosition LoadingCarOnPosition
{
get
{
if (IOValue(IO_Type.Loading_Car_Check2).Equals(IO_VALUE.HIGH)
&& IOValue(IO_Type.Loading_Car_Check).Equals(IO_VALUE.LOW) && IOValue(IO_Type.Loading_Car1315_Check).Equals(IO_VALUE.LOW))
return CarPosition.BadPosition;
else if (IOValue(IO_Type.Loading_Car_Check2).Equals(IO_VALUE.HIGH)
&& (IOValue(IO_Type.Loading_Car_Check).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Loading_Car1315_Check).Equals(IO_VALUE.HIGH)))
return CarPosition.OnPosition;
else
return CarPosition.NoCar;
}
}
public CarPosition UnloadingCarOnPosition
{
get
{
if (IOValue(IO_Type.Unloading_Car_Check2).Equals(IO_VALUE.HIGH)
&& IOValue(IO_Type.Unloading_Car_Check).Equals(IO_VALUE.LOW) && IOValue(IO_Type.Unloading_Car1315_Check).Equals(IO_VALUE.LOW))
return CarPosition.BadPosition;
else if (IOValue(IO_Type.Unloading_Car_Check2).Equals(IO_VALUE.HIGH)
&& (IOValue(IO_Type.Unloading_Car_Check).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Unloading_Car1315_Check).Equals(IO_VALUE.HIGH)))
return CarPosition.OnPosition;
else
return CarPosition.NoCar;
}
}
public MoveInfo ResetMoveInfo;
/// <summary>
/// 右侧移动信息
/// </summary>
public MoveInfo InCarMoveInfo;
public MoveInfo InMoveInfo;
public MoveInfo CountMoveInfo;
public MoveInfo OutCarMoveInfo;
public MoveInfo OutMoveInfo;
public MoveInfo LabelMoveInfo;
public delegate void ProcessMsg(List<Msg> msg);
public event ProcessMsg ProcessMsgEvent;
public event EventHandler<ErrInfo> ButtenEvent;
public AxisBean Loading_Batch_Axis;
internal AxisBean Loading_Middle_Axis;
internal AxisBean Loading_UpDown_Axis;
internal AxisBean Loading_InOut_Axis;
public AxisBean Unloading_Batch_Axis;
internal AxisBean Unloading_Middle_Axis;
internal AxisBean Unloading_UpDown_Axis;
internal AxisBean Unloading_InOut_Axis;
internal AxisBean Label_X_Axis;
internal AxisBean Label_Y_Axis;
internal AxisBean Label_Z_Axis;
internal AxisBean Label_R_Axis;
public bool AutoInOutTest = false;
readonly ServerCommunication ServerCM = new ServerCommunication();
/// <summary>
/// 开始运行的时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 是否在急停中
/// </summary>
public bool isInSuddenDown = false;
public MainMachine(Robot_Config _config) {
Config = _config;
InCarMoveInfo = new MoveInfo($"入料车机构");
InCarMoveInfo.SetStateDelegate(InCarProcessState);
InMoveInfo = new MoveInfo($"取料机构");
InMoveInfo.SetStateDelegate(InMoveState);
CountMoveInfo = new MoveInfo($"点料机构");
CountMoveInfo.SetStateDelegate(CountState);
OutCarMoveInfo = new MoveInfo($"出料车机构");
OutCarMoveInfo.SetStateDelegate(OutCarProcessState);
OutMoveInfo = new MoveInfo($"放料机构");
OutMoveInfo.SetStateDelegate(OutMoveState);
LabelMoveInfo = new MoveInfo($"贴标机构");
LabelMoveInfo.SetStateDelegate(LabelState);
ResetMoveInfo = new MoveInfo($"重置");
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
Crc_LanguageChangeEvent(null, EventArgs.Empty);
#region 初始化led灯
RunningLed = new Led(Config.DOList[IO_Type.Run_Led].GetIOAddr(),LedColor.green);
StandbyLed = new Led(Config.DOList[IO_Type.Standby_Led].GetIOAddr(), LedColor.yellow);
AlarmLed = new Led(Config.DOList[IO_Type.Alarm_Led].GetIOAddr(), LedColor.red);
Loading_NOCar_Led = new Led(Config.DOList[IO_Type.Loading_NOCar_Led].GetIOAddr(), LedColor.none);
Unloading_NOCar_Led = new Led(Config.DOList[IO_Type.Unloading_NOCar_Led].GetIOAddr(), LedColor.none);
//NG_Led = new Led(Config.DOList[IO_Type.MaterialNG_Led].GetIOAddr());
LogUtil.info("led load pass");
#endregion
#region 初始化伺服轴
Loading_Batch_Axis = new AxisBean(Config.Loading_Batch_Axis, Name);
Loading_Batch_Axis.interference += Loading_Batch_Axis_interference;
Loading_Batch_Axis.ForceSafeCheck = true;
Loading_Middle_Axis = new AxisBean(Config.Loading_Middle_Axis, Name);
Loading_Middle_Axis.interference += Loading_Middle_Axis_interference;
Loading_UpDown_Axis = new AxisBean(Config.Loading_UpDown_Axis, Name);
Loading_InOut_Axis = new AxisBean(Config.Loading_InOut_Axis, Name);
Unloading_Batch_Axis = new AxisBean(Config.Unloading_Batch_Axis, Name);
Unloading_Batch_Axis.ForceSafeCheck=true;
Unloading_Batch_Axis.interference += Unloading_Batch_Axis_interference;
Unloading_Middle_Axis = new AxisBean(Config.Unloading_Middle_Axis, Name);
Unloading_Middle_Axis.interference += Unloading_Middle_Axis_interference;
Unloading_UpDown_Axis = new AxisBean(Config.Unloading_UpDown_Axis, Name);
Unloading_InOut_Axis = new AxisBean(Config.Unloading_InOut_Axis, Name);
Label_X_Axis = new AxisBean(Config.Label_X_Axis, Name);
Label_Y_Axis = new AxisBean(Config.Label_Y_Axis, Name);
Label_Z_Axis = new AxisBean(Config.Label_Z_Axis, Name);
Label_R_Axis = new AxisBean(Config.Label_R_Axis, Name);
LogUtil.info("axis load pass");
#endregion
AlarmBuzzer.SetOnOffAction(() =>{ IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.HIGH); }, () => { IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW); });
IOMonitor.RegisterIO(IO_Type.Reset_BTN, Config, IO_VALUE.HIGH, Reset_BTN, 2500,100);
IOMonitor.RegisterIO(IO_Type.AutoRun_Single, Config, IO_VALUE.HIGH, Run_BTN, 2500,100);
IOMonitor.RegisterIO(IO_Type.Reset_BTN, Config, IO_VALUE.HIGH, HomeReset_BTN, 2500, 3000);
LedProcessInit();
LogUtil.info("LedProcess Init pass");
IOManager.IOMove(IO_Type.Counting_Camera_Led, IO_VALUE.HIGH);
IOManager.IOMove(IO_Type.Loading_Device_Led, IO_VALUE.HIGH);
IOManager.IOMove(IO_Type.Unloading_Device_Led, IO_VALUE.HIGH);
}
private (bool, string) Unloading_Batch_Axis_interference(int arg1, int arg2)
{
if (UnloadingCarOnPosition== CarPosition.BadPosition)
{
return (true, "出料车没有推倒位,提升轴不允许运动");
}
return (false, "");
}
private (bool, string) Loading_Batch_Axis_interference(int arg1, int arg2)
{
if (LoadingCarOnPosition == CarPosition.BadPosition)
{
return (true, "入料车没有推倒位,提升轴不允许运动");
}
return (false, "");
}
private (bool, string) Unloading_Middle_Axis_interference(int from, int to)
{
if (to > Config.Unloading_InOut_Axis_P1) {
//if (Label_X_Axis.IsInPosition(Config.Label_X_P2))
}
if (Unloading_InOut_Axis.GetAclPosition() <= Config.Unloading_InOut_Axis_P1 + Unloading_InOut_Axis.Config.CanErrorCountMax)
{
return (false, "");
}
return (true, "进出轴不在原点或待机点,不允许转动旋转轴");
}
private (bool, string) Loading_Middle_Axis_interference(int from, int to)
{
if (Loading_InOut_Axis.GetAclPosition() <= Config.Loading_InOut_Axis_P1 + Loading_InOut_Axis.Config.CanErrorCountMax)
{
return (false, "");
}
return (true, "进出轴不在原点或待机点,不允许转动旋转轴");
}
private void Crc_LanguageChangeEvent(object sender, EventArgs e)
{
InCarMoveInfo.Name="入料车机构";
InMoveInfo.Name = "取料机构";
CountMoveInfo.Name = "点料机构";
OutCarMoveInfo.Name = "出料车机构";
OutMoveInfo.Name = "放料机构";
LabelMoveInfo.Name = "贴标机构";
ResetMoveInfo.Name = "重置";
}
public bool hasAlarm = false;
/// <summary>
/// 整机启动变量,设置为false后将退出线程,只在停止时调用
/// </summary>
bool mstart=true;
public void Run() {
mstart = true;
while (mstart) {
try
{
canRunning = DeviceCheck();
if (canRunning)
{
BtnProcess();
canRunning = SafeCheck();
//if (canRunning && !lastSafeCheckStatus){}
//lastSafeCheckStatus = canRunning;
}
Thread.Sleep(200);
if (!canRunning || !mstart)
continue;
if (runStatus == RunStatus.Running)
{
ioMonitor();
InCarProcess();
InMoveProcess();
CountingMoveProcess();
OutMoveProcess();
OutCarProcess();
PrinterProcess();
LabelProcess();
}
else if (runStatus == RunStatus.HomeReset)
{
HomeReset();
}
}
catch (Exception ex)
{
Msg.add(ex.ToString(), MsgLevel.warning);
Msg.setlogones();
}
finally {
var m = Msg.get();
ProcessMsgEvent?.Invoke(m);
ServerCM.ProcessMsg(m);
StoreStatus currnetstoreStatus= StoreStatus.None;
if (m.Find((aa) => aa.msgLevel == MsgLevel.alarm) == null)
{
hasAlarm = false;
AlarmBuzzer.OFF();
if (ServerCM.storeStatus != StoreStatus.InStoreExecute
&& ServerCM.storeStatus != StoreStatus.OutStoreExecute
&& ServerCM.storeStatus != StoreStatus.ResetMove && ServerCM.storeStatus != StoreStatus.StoreOnline)
{
LogUtil.info($"test storeStatus is {ServerCM.storeStatus} change to StoreOnline");
currnetstoreStatus = StoreStatus.StoreOnline;
}
}
else {
hasAlarm = true;
AlarmBuzzer.ON();
currnetstoreStatus = isInSuddenDown ? StoreStatus.SuddenStop : StoreStatus.Warning;
}
//ProcessMoveinfoEvent?.Invoke(MoveInfo.List);
if (!UserPause)
Msg.clear();
else
currnetstoreStatus = StoreStatus.Debugging;
if (currnetstoreStatus!=StoreStatus.None)
ServerCM.storeStatus = currnetstoreStatus;
}
}
LogUtil.info("主线程已退出.");
}
public void Start() {
ServerCM.StartConnectServer();
Run();
}
public void Stop() {
mstart = false;
PrintJob = null;
CurrentPrintJob = null;
ServerCM.StopConnectServer();
Thread.Sleep(300);
Alarm(AlarmType.None);
StopMove(true);
LedProcess(null);
}
public void BeginHomeReset(bool firstRun=false) {
if (!firstRun)
{
StopMove();
Thread.Sleep(500);
}
OpenAllServo();
Alarm(AlarmType.None);
runStatus = RunStatus.HomeReset;
ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
ResetMoveInfo.log("开始回原");
ResetMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
}
//强制回原
bool forceHome=true;
void HomeReset()
{
if (CheckWait(ResetMoveInfo))
return;
switch (ResetMoveInfo.MoveStep)
{
case MoveStep.H01_HomeReset:
ServerCM.storeStatus = StoreStatus.ResetMove;
Msg.add("", MsgLevel.info, ErrInfo.X09_Clear);
lastReeID = "";
if (IOValue(IO_Type.Loading_Car_Check2).Equals(IO_VALUE.LOW)
&& IOValue(IO_Type.Loading_Car_Check).Equals(IO_VALUE.LOW) && IOValue(IO_Type.Loading_Car1315_Check).Equals(IO_VALUE.LOW))
{
CylinderMove(ResetMoveInfo, IO_Type.Loading_Car_Location_Down, IO_Type.Loading_Car_Location_Up, IO_VALUE.LOW);
}
if (IOValue(IO_Type.Unloading_Car_Check2).Equals(IO_VALUE.LOW)
&& IOValue(IO_Type.Unloading_Car_Check).Equals(IO_VALUE.LOW) && IOValue(IO_Type.Unloading_Car1315_Check).Equals(IO_VALUE.LOW))
{
CylinderMove(ResetMoveInfo, IO_Type.Unloading_Car_Location_Down, IO_Type.Unloading_Car_Location_Up, IO_VALUE.LOW);
}
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset_01);
PrintJob = null;
break;
case MoveStep.H02_HomeReset_01:
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset_02);
ResetMoveInfo.log("小车批量轴, 贴标z轴回原");
Loading_Batch_Axis.HomeMove(null, forceHome);
Unloading_Batch_Axis.HomeMove(null, forceHome);
Label_Z_Axis.HomeMove(null, forceHome);
GrabImageEX();
break;
case MoveStep.H02_HomeReset_02:
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset);
ResetMoveInfo.log("2侧升降轴回原");
Loading_UpDown_Axis.HomeMove(ResetMoveInfo, forceHome);
Unloading_UpDown_Axis.HomeMove(ResetMoveInfo, forceHome);
Label_Z_Axis.HomeMove(ResetMoveInfo, forceHome);
break;
case MoveStep.H02_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset_1);
ResetMoveInfo.log("2侧进出轴回原");
Loading_InOut_Axis.HomeMove(ResetMoveInfo, forceHome);
Unloading_InOut_Axis.HomeMove(ResetMoveInfo, forceHome);
break;
case MoveStep.H02_HomeReset_1:
ResetMoveInfo.NextMoveStep(MoveStep.H02_HomeReset_2);
ResetMoveInfo.log("贴标X轴回原");
Label_X_Axis.HomeMove(ResetMoveInfo, forceHome);
break;
case MoveStep.H02_HomeReset_2:
ResetMoveInfo.NextMoveStep(MoveStep.H03_HomeReset);
ResetMoveInfo.log("贴标Y轴回原");
Label_R_Axis.HomeMove(ResetMoveInfo, forceHome);
Label_Y_Axis.HomeMove(ResetMoveInfo, forceHome);
break;
case MoveStep.H03_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H04_HomeReset);
ResetMoveInfo.log("2侧旋转轴回原");
Loading_Middle_Axis.HomeMove(null, forceHome);
Unloading_Middle_Axis.HomeMove(null, forceHome);
break;
case MoveStep.H04_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H05_HomeReset);
Loading_Batch_Axis.HomeMove(ResetMoveInfo, forceHome);
Unloading_Batch_Axis.HomeMove(ResetMoveInfo, forceHome);
Loading_Middle_Axis.HomeMove(ResetMoveInfo, forceHome);
Unloading_Middle_Axis.HomeMove(ResetMoveInfo, forceHome);
break;
case MoveStep.H05_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H06_HomeReset);
ResetMoveInfo.log("全部轴已正常回原");
break;
case MoveStep.H06_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H15_HomeReset);
ResetMoveInfo.log("压紧轴回原");
Label_X_Axis.AbsMove(ResetMoveInfo, Config.Label_X_P1, Config.Label_X_P1_speed);
Label_Y_Axis.AbsMove(ResetMoveInfo, Config.Label_Y_P1, Config.Label_Y_P1_speed);
Label_Z_Axis.AbsMove(ResetMoveInfo, Config.Label_Z_P1, Config.Label_Z_P1_speed);
Label_R_Axis.AbsMove(ResetMoveInfo, Config.Label_R_P1, Config.Label_R_P1_speed);
Loading_Batch_Axis.AbsMove(ResetMoveInfo, Config.Loading_Batch_Axis_P1, Config.Loading_Batch_Axis_P1_speed);
Loading_Middle_Axis.AbsMove(ResetMoveInfo, Config.Loading_Middle_Axis_P1, Config.Loading_Middle_Axis_P1_speed);
Loading_UpDown_Axis.AbsMove(ResetMoveInfo, Config.Loading_UpDown_Axis_P1, Config.Loading_UpDown_Axis_P1_speed);
Loading_InOut_Axis.AbsMove(ResetMoveInfo, Config.Loading_InOut_Axis_P1, Config.Loading_InOut_Axis_P1_speed);
Unloading_Batch_Axis.AbsMove(ResetMoveInfo, Config.Unloading_Batch_Axis_P1, Config.Unloading_Batch_Axis_P1_speed);
Unloading_Middle_Axis.AbsMove(ResetMoveInfo, Config.Unloading_Middle_Axis_P1, Config.Unloading_Middle_Axis_P1_speed);
Unloading_UpDown_Axis.AbsMove(ResetMoveInfo, Config.Unloading_UpDown_Axis_P1, Config.Unloading_UpDown_Axis_P1_speed);
Unloading_InOut_Axis.AbsMove(ResetMoveInfo, Config.Unloading_InOut_Axis_P1, Config.Unloading_InOut_Axis_P1_speed);
break;
case MoveStep.H15_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
forceHome = true;
InCarMoveInfo.NewMove(MoveStep.Wait);
InMoveInfo.NewMove(MoveStep.Wait);
CountMoveInfo.NewMove(MoveStep.Wait);
OutCarMoveInfo.NewMove(MoveStep.Wait);
OutMoveInfo.NewMove(MoveStep.Wait);
LabelMoveInfo.NewMove(MoveStep.Wait);
PrintMoveInfo.NewMove(MoveStep.Wait);
CylinderMove(ResetMoveInfo, IO_Type.Counting_EnterDoor_Close, IO_Type.Counting_EnterDoor_Open, IO_VALUE.LOW);
CylinderMove(ResetMoveInfo, IO_Type.Counting_ExitDoor_Close, IO_Type.Counting_ExitDoor_Open, IO_VALUE.LOW);
if (IOValue(IO_Type.Counting_Reel_Check).Equals(IO_VALUE.HIGH))
{
CountMoveInfo.NewMove(MoveStep.Count_01);
//CountMoveInfo.MoveParam.IsNg = true;
//CountMoveInfo.MoveParam.NgMsg = "回原时发现无信息料";
CountMoveInfo.log("点料区有料直接开始点料");
}
if (IOValue(IO_Type.Loading_VacuumDegree_Check).Equals(IO_VALUE.HIGH))
{
InMoveInfo.NextMoveStep(MoveStep.In_05);
CountMoveInfo.log("取料吸盘上有料直接开始送入点料机");
InMoveInfo.MoveParam.PlateH = Setting_Init.Temp_Last_InMove_Reel_Height;
InMoveInfo.MoveParam.PlateW = Setting_Init.Temp_Last_InMove_Reel_Width;
InMoveInfo.log($"获取到尺寸{InMoveInfo.MoveParam.PlateW}x{InMoveInfo.MoveParam.PlateH}");
}
break;
case MoveStep.HEND_HomeReset:
ResetMoveInfo.log("回原完成");
ResetMoveInfo.EndMove();
runStatus = RunStatus.Running;
ServerCM.storeStatus = StoreStatus.StoreOnline;
break;
}
}
bool _IgnoreSafecheck = false;
public bool IgnoreSafecheck { get => _IgnoreSafecheck; set {
if (value)
{
IOMove(IO_Type.SafeDoor_Disable, IO_VALUE.HIGH);
}
else {
IOMove(IO_Type.SafeDoor_Disable, IO_VALUE.LOW);
}
_IgnoreSafecheck = value;
} }
public bool IgnoreGratingSignal = false;
bool lastSafeCheckStatus = true;
bool SafeCheck() {
bool ok = true;
var ignorestring = "[" + crc.GetString(L.ignored, "已忽略") + "]";
if (IOValue(IO_Type.AutoRun_Single).Equals(IO_VALUE.LOW))
{
ok = false;
DeviceSuddenStop();
Msg.add("运行开关未打开", MsgLevel.warning);
}
if (IOValue(IO_Type.Loading_SafeDoor_Check).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck)
{
ok = false;
DeviceSuddenStop();
}
Msg.add(crc.GetString(L.left_safedoor_not_close, "上料区门禁没有关闭") + (ok ? ignorestring : ""), MsgLevel.warning);
}
if (IOValue(IO_Type.Unloading_SafeDoor_Check).Equals(IO_VALUE.LOW))
{
if (!IgnoreSafecheck)
{
ok = false;
DeviceSuddenStop();
}
}
if (LoadingCarOnPosition == CarPosition.BadPosition)
{
ok = false;
DeviceSuddenStop();
Msg.add("入料车没有推倒位,暂停运行", MsgLevel.alarm);
}
if (UnloadingCarOnPosition == CarPosition.BadPosition)
{
ok = false;
DeviceSuddenStop();
Msg.add("出料车没有推倒位,暂停运行", MsgLevel.alarm);
}
if (!lastSafeCheckStatus && ok)
{
SafetyDevice.ResumeAll();
}
lastSafeCheckStatus = ok;
return ok;
}
void DeviceSuddenStop() {
if (lastSafeCheckStatus)
{
AxisBean.StopMultiAxis(AxisBean.List);
MoveInfo.List.ForEach((m) => { m.CanWhileCount = 5; });
SafetyDevice.PauseAll();
if (runStatus == RunStatus.HomeReset)
{
ResetMoveInfo.NewMove(MoveStep.H01_HomeReset);
}
}
}
/// <summary>
/// 最后一次气压检测变为0的时间
/// </summary>
DateTime lastAirCloseTime = DateTime.MinValue;
internal DateTime checkAlarmTime = DateTime.Now;
public bool DeviceCheck() {
bool ok = true;
isInSuddenDown = IOValue(IO_Type.SuddenStop_BTN).Equals(IO_VALUE.LOW);
if (UserPause)
{
Msg.add(crc.GetString(L.system_pause, "系统暂停"), MsgLevel.warning);
DeviceSuddenStop();
lastSafeCheckStatus = false;
ok = false;
return ok;
}
else if (isInSuddenDown)
{
Alarm(AlarmType.SuddenStop);
Msg.add(crc.GetString(L.in_suddenstop, "急停中"), MsgLevel.alarm);
ok = false;
}
else if (alarmType != AlarmType.None) {
//if (IOValue(IO_Type.Right_BTN).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Left_BTN).Equals(IO_VALUE.HIGH))
//{
// Alarm(AlarmType.None);
//}
//else
{
Msg.add(crc.GetString(L.system_need_reset, "系统需要重置"), MsgLevel.alarm,ErrInfo.SuddenStop);
ButtenEvent?.Invoke(null, ErrInfo.SuddenStop);
ok = false;
}
}
if (RobotManage.InoutDebugMode)
{
Msg.add(crc.GetString(L.store_inout_debug_mode, "进出库调试模式"), MsgLevel.info);
//ok = false;
}
if (IOValue(IO_Type.Airpressure_Check).Equals(IO_VALUE.LOW))
{
if (lastAirCloseTime == DateTime.MinValue)
lastAirCloseTime = DateTime.Now;
TimeSpan span = DateTime.Now - lastAirCloseTime;
if (span.TotalSeconds > RobotManage.Config.AirCheckSeconds)
{
ok = false;
Msg.add(crc.GetString(L.airpressure_not_enough, "气压不足"), MsgLevel.warning);
}
}
else {
lastAirCloseTime = DateTime.MinValue;
}
if (alarmType!=AlarmType.SuddenStop)
{
TimeSpan span = DateTime.Now - checkAlarmTime;
if (span.TotalSeconds > 2)
{
checkAlarmTime = DateTime.Now;
foreach (ConfigMoveAxis configMoveAxis in Config.moveAxisList)
{
if (AxisManager.GetAlarmStatus(configMoveAxis.DeviceName, configMoveAxis.GetAxisValue()) == 1)
{
if (configMoveAxis.DeviceName == "Comp_Axis")
{
if (runStatus == RunStatus.Running || ResetMoveInfo.IsStep(MoveStep.H06_HomeReset))
{
Msg.add(crc.GetString(configMoveAxis.ProName, configMoveAxis.Explain) + $"[{configMoveAxis.GetAxisValue()}]:"
+ crc.GetString(L.motion_alarm, "运动报警"), MsgLevel.alarm);
RobotManage.UserPause("压紧轴报警", true);
AxisManager.AlarmClear(configMoveAxis.DeviceName, configMoveAxis.GetAxisValue());
Thread.Sleep(2000);
}
}
else
{
Msg.add(crc.GetString(configMoveAxis.ProName, configMoveAxis.Explain) + $"[{configMoveAxis.GetAxisValue()}]:"
+ crc.GetString(L.motion_alarm, "运动报警"), MsgLevel.alarm, ErrInfo.SuddenStop);
ButtenEvent?.Invoke(null, ErrInfo.SuddenStop);
}
LogUtil.error(configMoveAxis.GetAxisValue() + "," + string.Join(",", HuichuanLibrary.HCBoardManager.GetAxisErrorDetail(configMoveAxis.GetAxisValue())));
ok = false;
}
}
}
}
return ok;
}
}
}