KTK_Store.cs
28.4 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
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public abstract class KTK_Store
{
public LineRunStatus runStatus = LineRunStatus.Wait;
public string WarnMsg = "";
public DeviceConfig baseConfig = null;
public string Name { get; set; }
public int DeviceID { get; set; }
protected System.Timers.Timer mainTimer;
protected Thread mainThread;
protected bool loop;
protected bool pause = false;
protected int threadInterval = 300;
private bool isInit = false;
/// <summary>
/// 使用timer定时器
/// </summary>
protected bool useTimer = ConfigHelper.Config.Get("Device_MainThreadUseTimer", true);
public bool IsMainStarted
{
get
{
if (useTimer)
{
return mainTimer.Enabled;
}
else
{
return !pause;
}
}
}
//public bool mainTimerStart { get => mainTimer.Enabled; }
/// <summary>
/// 托盘检测信号需要持续时间
/// </summary>
protected static int TrayWaitTime = 600;
public KTK_Store()
{
}
~KTK_Store()
{
if (useTimer)
{
}
else
{
loop = false;
}
}
/// <summary>
/// 主进程启动
/// </summary>
public void mainStart()
{
if (useTimer)
{
if (mainTimer != null)
{
mainTimer.Start();
}
}
else
{
// pause = false;
}
}
public void SetInterval(int interval = 300)
{
if (useTimer)
{
if (mainTimer != null)
{
mainTimer.Interval = interval;
}
}
else
{
threadInterval = interval;
}
}
/// <summary>
/// 主进程停止
/// </summary>
public void mainStop()
{
if (useTimer)
{
mainTimer?.Stop();
}
else
{
//pause = true;
}
}
/// <summary>
/// 开始运行的时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 最后一次气压检测变为0的时间
/// </summary>
public DateTime lastAirCloseTime = DateTime.Now;
/// <summary>
/// 是否在急停中
/// </summary>
public bool isInSuddenDown = false;
/// <summary>
/// 是否没有检测到气压
/// </summary>
public bool isNoAirCheck = false;
public LineAlarmType alarmType = LineAlarmType.None;
public AlarmInfo alarmInfo = new AlarmInfo();
/// <summary>
/// 记录上一次的部分IO状态,主要是急停,气压检测信号,复位信号,用来判断是否io发生改变
/// </summary>
public Dictionary<string, IO_VALUE> DILastValueMap = new Dictionary<string, IO_VALUE>();
public object lastDiListLock = "";
public void addLastDI(string type, IO_VALUE value)
{
try
{
lock (lastDiListLock)
{
if (DILastValueMap.ContainsKey(type))
{
DILastValueMap.Remove(type);
}
DILastValueMap.Add(type, value);
}
}
catch (Exception ex)
{
LogUtil.info(ex.ToString());
}
}
/// <summary>
/// 运动处理
/// </summary>
protected bool isInPro = false;
protected virtual void BusyMoveProcess()
{
isInPro = true;
try
{
switch (MoveInfo.MoveType)
{
case LineMoveType.InStore:
InStoreProcess();
isInPro = false;
break;
case LineMoveType.OutStore:
OutStoreProcess();
isInPro = false;
break;
case LineMoveType.RHome:
ResetProcess();
isInPro = false;
break;
case LineMoveType.Reset:
ResetProcess();
isInPro = false;
break;
default: break;
}
}
catch (Exception ex)
{
LogUtil.error("BusyMoveProcess出错:", ex);
}
isInPro = false;
}
protected void SaveAlarmInfo(LineAlarmType alarmType, string alarmDetial, string alarmMsg, LineMoveType storeMoveType)
{
alarmMsg = alarmMsg.Replace(Name, "");
int inoutStatus = 0;
if (storeMoveType.Equals(LineMoveType.InStore))
{
inoutStatus = 1;
}
else if (storeMoveType.Equals(LineMoveType.InStore))
{
inoutStatus = 2;
}
int aType = 0;
switch (alarmType)
{
case LineAlarmType.AxisMoveError:
aType = 2;
break;
case LineAlarmType.AxisAlarm:
aType = 2;
break;
case LineAlarmType.SuddenStop:
aType = 1;
alarmDetial = "1";
break;
case LineAlarmType.NoAirCheck:
aType = 1;
alarmDetial = "2";
break;
case LineAlarmType.IoSingleTimeOut:
aType = 3;
break;
default: break;
}
alarmInfo = new AlarmInfo(DeviceID, aType, alarmDetial, alarmMsg, inoutStatus);
}
/// <summary>
/// 没有严重的报警
/// </summary>
/// <returns></returns>
internal bool NoErrorAlarm()
{
if (isInSuddenDown || isNoAirCheck)
{
return false;
}
if (alarmType > LineAlarmType.IoSingleTimeOut)
{
return false;
}
return true;
}
internal bool NoAlarm()
{
if (isInSuddenDown || isNoAirCheck)
{
return false;
}
if (alarmType.Equals(LineAlarmType.None))
{
return true;
}
return false;
}
public abstract bool StartRun(bool isDebug = false);
public abstract void StopRun();
public abstract void Alarm(LineAlarmType alarmType);
public abstract bool Reset();
internal abstract void StopMove(string stopDes = "");
protected abstract void ResetProcess();
protected virtual void Init()
{
if (!isInit)
{
if (useTimer)
{
mainTimer = new System.Timers.Timer();
mainTimer.Enabled = false;
mainTimer.Interval = 300;
mainTimer.Elapsed += mainTimer_Elapsed;
mainTimer.AutoReset = true;
}
else
{
mainThread = new Thread(mainThread_Handle);
mainThread.IsBackground = true;
threadInterval = 300;
loop = true;
GC.KeepAlive(mainThread);
mainThread.Start();
}
isInit = true;
}
}
public LineMoveInfo MoveInfo = null;
string threadInfo = "";
void mainThread_Handle()
{
while (loop)
{
if (pause)
{
Thread.Sleep(1000);
}
else
{
mainThread_Process();
Thread.Sleep(threadInterval);
try
{
string curStr = $"{Name}-{DeviceID}:Thread ID: {Thread.CurrentThread.ManagedThreadId}";
if (!curStr.Equals(threadInfo))
{
threadInfo = curStr;
LogUtil.LOGGER.Info(curStr);
}
}
finally { }
}
}
}
protected abstract void mainThread_Process();
void mainTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
mainThread_Process();
}
#region 出库
/// <summary>
/// 开始出库运动
/// </summary>
public abstract bool StartOutStoreMove(InOutParam param);
protected abstract void OutStoreProcess();
#endregion
#region 入库
/// <summary>
/// 开始入库移动移动
/// </summary>
public abstract bool StartInStoreMove(InOutParam param);
protected abstract void InStoreProcess();
#endregion
//public void SetWarnMsg(string msg = "")
//{
// if (String.IsNullOrEmpty(msg).Equals(false))
// {
// if (!msg.StartsWith(Name))
// {
// msg = Name + msg;
// }
// if (WarnMsg.Equals(msg))
// {
// if (msg.StartsWith(Name))
// {
// LogUtil.error(msg, 801);
// }
// else
// {
// LogUtil.error(Name + msg, 801);
// }
// }
// else
// {
// if (msg.StartsWith(Name))
// {
// LogUtil.error(msg);
// }
// else
// {
// LogUtil.error(Name + msg);
// }
// }
// }
// WarnMsg = msg;
//}
public string GetRunStr()
{
string sta = "运行中";
string aa = "";
switch (runStatus)
{
case LineRunStatus.Busy:
sta = "忙碌";
break;
case LineRunStatus.HomeMoving:
sta = "原点返回";
break;
case LineRunStatus.Reset:
sta = "重置";
break;
case LineRunStatus.Runing:
sta = "运行中";
break;
case LineRunStatus.Wait:
sta = "等待启动";
break;
}
if (runStatus > LineRunStatus.Wait)
{
if (isInSuddenDown)
{
aa = "急停中";
}
else if (isNoAirCheck)
{
aa = "无气压信号";
}
}
if (!aa.Equals(""))
{
return sta + "_" + aa;
}
else
{
return sta;
}
}
public static string GetRunStr(LineRunStatus runs, LineStatus ls = LineStatus.None)
{
string sta = "运行中";
string aa = "";
switch (runs)
{
case LineRunStatus.Busy:
sta = "忙碌";
break;
case LineRunStatus.HomeMoving:
sta = "原点返回";
break;
case LineRunStatus.Reset:
sta = "重置";
break;
case LineRunStatus.Runing:
sta = "运行中";
break;
case LineRunStatus.Wait:
sta = "等待启动";
break;
}
if (runs > LineRunStatus.Wait && ls > LineStatus.None)
{
//"0":"急停中", "1":"设备联机", "2":"故障中", "3":"入库执行中", "4":"出库执行中", 5":"料盘入仓位完成", "6":"料盘出仓位完成", 7":"设备调试中",
switch (ls)
{
case LineStatus.Debugging:
aa = "设备调试中";
break;
//case LineStatus.InStoreEnd:
// aa = "料盘入仓位完成";
// break;
case LineStatus.InStoreExecute:
aa = "入库执行中";
break;
case LineStatus.InTrouble:
aa = "故障中";
break;
//case LineStatus.OutStoreBoxEnd:
// aa = "料盘出仓位完成";
// break;
case LineStatus.OutStoreExecute:
aa = "出库执行中";
break;
case LineStatus.StoreOnline:
aa = "设备联机";
break;
case LineStatus.SuddenStop:
aa = "急停中";
break;
//case LineStatus.OutMoveExecute:
// aa = "出库完成";
// break;
//case LineStatus.InStoreFaild:
// aa = "入库失败(" + WarnMsg + ")";
// break;
//case LineStatus.OutStoreFaild:
// aa = "出库失败(" + WarnMsg + ")";
// break;
}
}
if (!aa.Equals(""))
{
return sta + "_" + aa;
}
else
{
return sta;
}
}
public bool CylinderIsOk(string IoLowType, string IoHighType)
{
if (!baseConfig.DIList.ContainsKey(IoLowType) || (!baseConfig.DIList.ContainsKey(IoHighType)))
{
return true;
}
if (IOManager.DIValue(IoLowType, DeviceID).Equals(IO_VALUE.LOW) && IOManager.DIValue(IoHighType, DeviceID).Equals(IO_VALUE.HIGH))
{
return true;
}
return false;
}
public void CylinderMove(LineMoveInfo moveInfo, string IoLowType, string IoHighType, bool isCheckMove = false)
{
try
{
if (baseConfig.DType.Equals(DeviceType.HYEquip))
{
//需要判断是否包含此DO
}
if (baseConfig.DType.Equals(DeviceType.FeedingEquip))
{
if (!baseConfig.DOList.ContainsKey(IoLowType))
{
return;
}
if (!baseConfig.DOList.ContainsKey(IoHighType))
{
return;
}
}
if (moveInfo != null)
{
if (IoHighType.Equals(IO_Type.ClampCylinder_Work) || IoHighType.Equals(IO_Type.ClampCylinder_Relax) ||
IoHighType.Equals(IO_Type.UpDownCylinder_Down) || IoHighType.Equals(IO_Type.UpDownCylinder_Up) ||
IoHighType.Equals(IO_Type.BeforeAfterCylinder_After) || IoHighType.Equals(IO_Type.BeforeAfterCylinder_Before)
)
{
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(300));
}
//如果是进仓门口 夹紧
if (baseConfig.DType.Equals(DeviceType.FeedingEquip) && (IoHighType.Equals(IO_Type.SL_ClampCylinder_Work)))
{
//夹爪夹紧
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
}
else if (baseConfig.DType.Equals(DeviceType.FeedingEquip) && (IoHighType.Equals(IO_Type.SL_ClampCylinder_Relax)))
{
//夹爪放松
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW));
}
else if (baseConfig.DType.Equals(DeviceType.MoveEquip) && (IoHighType.Equals(IO_Type.ClampCylinder_Relax)))
{
//夹爪放松
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW));
}
else if (baseConfig.DType.Equals(DeviceType.MoveEquip) && (IoHighType.Equals(IO_Type.ClampCylinder_Work)))
{
//夹爪夹紧
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
}
else if (baseConfig.DType.Equals(DeviceType.HYEquip) && (IoHighType.Equals(IO_Type.HY_ClampCylinder_Relax)))
{
//夹爪放松
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW));
}
else if (baseConfig.DType.Equals(DeviceType.HYEquip) && (IoHighType.Equals(IO_Type.HY_ClampCylinder_Work)))
{
//夹爪夹紧
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
}
else
{
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoLowType, IO_VALUE.LOW));
moveInfo.WaitList.Add(WaitResultInfo.WaitIO(IoHighType, IO_VALUE.HIGH));
}
}
if (isCheckMove)
{
CheckAndMove(IoLowType, IO_VALUE.LOW);
CheckAndMove(IoHighType, IO_VALUE.HIGH);
}
else
{
IOMove(IoLowType, IO_VALUE.LOW);
IOMove(IoHighType, IO_VALUE.HIGH);
}
}
catch (Exception ex)
{
LogUtil.error(Name + "CylinderMove [" + moveInfo.Name + "] [" + IoLowType + "] [" + IoHighType + "] [" + isCheckMove + "] 出错:" + ex.ToString());
}
}
public void CheckAndMove(string IoType, IO_VALUE value)
{
if (!IOValue(IoType).Equals(value))
{
IOMove(IoType, value);
}
}
public void IOMove(string IoType, IO_VALUE value, int msTime = 0)
{
if (msTime <= 0)
{
IOManager.IOMove(IoType, value, baseConfig.Id);
}
else
{
Task.Factory.StartNew(delegate
{
IOManager.IOMove(IoType, value, baseConfig.Id);
Thread.Sleep(msTime);
IO_VALUE tValue = value.Equals(IO_VALUE.HIGH) ? IO_VALUE.LOW : IO_VALUE.HIGH;
if (IOValue(IoType).Equals(tValue).Equals(false))
{
if (IoType.Equals(IO_Type.StopDown1).Equals(false))
//if (IoType.Equals(IO_Type.StopDown1).Equals(false)&&IoType.Equals(IO_Type.SW_StopDown).Equals(false))
{
LogUtil.debug(Name + "定时回写IO: [" + IoType + "]=[" + value + "],[" + baseConfig.Id + "],msTime=" + msTime);
}
}
IOManager.IOMove(IoType, tValue, baseConfig.Id);
});
}
}
public IO_VALUE IOValue(string IoType)
{
return IOManager.IOValue(IoType, baseConfig.Id);
}
public void DebugInfo(string logInfo)
{
LogUtil.debug(Name + logInfo);
}
public void LogInfo(string logInfo)
{
LogUtil.info(Name + logInfo);
}
/// <summary>
/// 阻塞等待IO信号,等到返回true,未等到返回false
/// </summary>c
protected bool WaitIo(string ioType, IO_VALUE value, int timeOut, string errName = "")
{
try
{
return WaitUtil.Wait(timeOut, delegate ()
{
return value.Equals(IOValue(ioType));
}, errName);
}
catch (Exception ex)
{
LogUtil.error(Name + "等待" + ioType + "=" + value + "超时:" + ex.ToString());
return false;
}
}
protected static bool CheckStopWatch(Stopwatch watch, int targetMs, bool isStop = true)
{
if (!watch.IsRunning)
{
watch.Restart();
return false;
}
else if (watch.ElapsedMilliseconds >= targetMs)
{
if (isStop)
{
watch.Stop();
}
return true;
}
return false;
}
private WarnParam warnParam = new WarnParam();
/// <summary>
/// 设置报警消息,报警类型,清除报警时记录日志
/// </summary>
/// <param name="msg"></param>
/// <param name="logtype"></param>
/// <param name="logseconds"></param>
public void SetWarnMsg(string msg = "", string alarmType = "", LineMoveInfo moveInfo = null, int logseconds = 10)
{
try
{
int logtype = 801;
if (moveInfo != null)
{
logtype = DeviceID * 10000 + (int)moveInfo.MoveStep;
}
if (String.IsNullOrEmpty(msg).Equals(false))
{
if (WarnMsg.Equals(msg) || warnParam.AlarmType.Equals(alarmType))
{
if (msg.StartsWith(Name))
{
LogUtil.error(msg, logtype, logseconds);
}
else
{
LogUtil.error(Name + msg, logtype, logseconds);
}
}
else
{
if (msg.StartsWith(Name))
{
LogUtil.error(msg);
}
else
{
LogUtil.error(Name + msg);
}
}
}
if (!warnParam.AlarmType.Equals(alarmType))
{
//报警类型不一致,若之前不是空,记录日志
if (!String.IsNullOrEmpty(warnParam.AlarmType))
{
RunLogUtil.ErrorLog(new ErrorLog(Name, warnParam.AlarmType, WarnMsg, warnParam.StartTime, DateTime.Now, warnParam.OperteType, warnParam.PosId, warnParam.Barcode));
}
//更新开始时间
warnParam.StartTime = DateTime.Now;
if (moveInfo != null)
{
warnParam.PosId = moveInfo.MoveParam?.PosId;
warnParam.Barcode = moveInfo.MoveParam?.WareCode;
warnParam.OperteType = moveInfo.GetMoveType();
}
else
{
warnParam.PosId = "";
warnParam.Barcode = "";
warnParam.OperteType = "";
}
}
}
catch (Exception ex)
{
LogUtil.error("SetWarnMsg Error: " + ex.ToString());
}
WarnMsg = msg;
warnParam.AlarmType = alarmType;
}
protected void MoveTimeoutAlarm(LineMoveInfo move, string alarmType)
{
try
{
SetWarnMsg(move.Name + "[" + move.GetMoveType() + "][" + move.SLog + "] " + alarmType + " [" + FormUtil.GetSpanStr(move.StepSpan()) + "]", alarmType, move);
Alarm(LineAlarmType.IoSingleTimeOut);
}
catch (Exception ex)
{
}
}
protected void ClearTimeoutAlarm(string msg)
{
if (isInSuddenDown || isNoAirCheck)
{
return;
}
if (WarnMsg.Contains(msg) && alarmType.Equals(LineAlarmType.IoSingleTimeOut))
{
LogUtil.info(Name + "清理信号超时报警【" + WarnMsg + "】 ");
alarmType = LineAlarmType.None;
SetWarnMsg("");
}
}
protected void ClearStepAlarm(string stepDes)
{
if (isInSuddenDown || isNoAirCheck)
{
return;
}
if (String.IsNullOrEmpty(WarnMsg).Equals(false) && String.IsNullOrEmpty(warnParam.AlarmType).Equals(false))
{
if (alarmType.Equals(LineAlarmType.IoSingleTimeOut))
{
string alarmTypeStr = stepDes + "_超时报警";
if (warnParam.AlarmType.Equals(alarmTypeStr))
{
LogUtil.info(Name + $"步骤{stepDes}结束,清理【{WarnMsg}】 ");
alarmType = LineAlarmType.None;
SetWarnMsg("");
}
}
else if (alarmType.Equals(LineAlarmType.AxisMoveError))
{
string alarmTypeStr = stepDes + "_轴运动报警";
if (warnParam.AlarmType.Equals(alarmTypeStr))
{
LogUtil.info(Name + $"步骤{stepDes}结束,清理【{WarnMsg}】 ");
alarmType = LineAlarmType.None;
SetWarnMsg("");
}
}
}
}
}
public class WarnParam
{
public WarnParam()
{
}
public WarnParam(string alarmType, DateTime startTime, string operType, string posId, string barcode)
{
this.AlarmType = alarmType;
this.StartTime = startTime;
this.OperteType = operType;
this.PosId = posId;
this.Barcode = barcode;
}
public string AlarmType = "";
public DateTime StartTime = DateTime.Now;
public string OperteType = "";
public string PosId = "";
public string Barcode = "";
}
}