DB_LA_LineBean.cs
33.3 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
using log4net;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary.doubleStore;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Timers;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 流水线自动料仓-流水线类
/// </summary>
public partial class DB_LA_LineBean
{
public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static bool InSuddonDown = false;
public DB_LA_Store_Config Config;
public string StoreName = "";
public int StoreID = 0;
private StoreMoveInfo StoreMove = null;
public string WarnMsg = "";
public StoreRunStatus storeRunStatus = StoreRunStatus.Wait;
System.Timers.Timer timer = new System.Timers.Timer();
public int currWidth = 0;
public string m_Time = "";
public DB_LA_LineBean(DB_LA_Store_Config config)
{
StoreMove = new StoreMoveInfo(config.Id);
this.Config = config;
this.StoreID = config.Id;
StoreName = (" " + Config.CID + "_LINE_" + StoreID + " ").ToUpper();
}
#region 启动,停止,定时,急停 等处理
/// <summary>
/// 开始运行
/// </summary>
public bool StartRun()
{
if (ShuoKeControls.isRun == false && (!DBStoreManager.OpenShuoKe()))
{
LogUtil.info(StoreName + "打开驱动器串口失败,启动失败!");
return false;
}
//判断急停信号
if (DBStoreManager.GetSingle(Store_IO_Type.LINE_Suddown).Equals(IO_VALUE.LOW))
{
LogUtil.info(StoreName + "流水线急停未开,启动失败!");
return false;
}
InSuddonDown = false;
timer.Interval = 200;
timer.Elapsed += timer_Elapsed;
storeRunStatus = StoreRunStatus.Runing;
StoreMove.EndMove();
LogUtil.info(StoreName + "开始运行!");
KNDIOMove(Store_IO_Type.Line_Back, IO_VALUE.LOW);
if (DBLineControl.TheLineIdList.Contains(StoreID ))
{
FileGenerated.writeLSTFile(DBLineControl.MachineId);
//写入状态
//FileGenerated.writeSGIFile(DBLineControl.MachineId, "0000", "0", "0", 1, 0);
FileGenerated.writeSGIFile(DBLineControl.MachineId, DBStoreManager.GetLightStr(), "0", "0", 0, 0);
FileGenerated.writeSTSFile(DBLineControl.MachineId, 1, 0);
}
ReturnHome();
return true;
}
private bool isInProcess = false;
private DateTime preWriteFileTime = DateTime.Now;
public void timer_Elapsed(object sender, ElapsedEventArgs e)
{
if (!isInProcess)
{
isInProcess = true;
TimerProcess();
isInProcess = false;
}
try
{
//判断间隔时间
TimeSpan span = DateTime.Now - preWriteFileTime;
if (span.TotalMilliseconds > DBLineControl.File_UpdateTime)
{
preWriteFileTime = DateTime.Now;
if (DBLineControl.TheLineIdList.Contains(StoreID))
{
int isHasPCB = 0;
if (StoreMove.MoveType.Equals(StoreMoveType.InStore))
{
isHasPCB = 1;
}
//写定时文件
FileGenerated.writeLCTFile(DBLineControl.MachineId, 1, 0, isHasPCB);
}
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, StoreName + "定时写入文件出错:" + ex.ToString());
}
}
/// <summary>
/// 停止运行
/// </summary>
public void StopRun()
{
StopMove();
if (DBLineControl.TheLineIdList.Contains(StoreID))
{
FileGenerated.writeSGIFile(DBLineControl.MachineId, DBStoreManager.GetLightStr(), "0", "0", 0, 0);
FileGenerated.writeSTSFile(DBLineControl.MachineId, 0, 0);
}
storeRunStatus = StoreRunStatus.Wait;
LOGGER.Info(StoreName + "停止运行");
timer.Enabled = false;
}
/// <summary>
/// 停止运行
/// </summary>
public void StopMove()
{
StoreMove.EndMove();
ShuoKeControls.SuddownStop(Config.LineWidth_Slv);
KNDIOMove(Store_IO_Type.SMEMA_Up, IO_VALUE.LOW);
Thread.Sleep(60);
KNDIOMove(Store_IO_Type.SMEMA_Down, IO_VALUE.LOW);
Thread.Sleep(60);
KNDIOMove(Store_IO_Type.Line_Foward, IO_VALUE.LOW);
Thread.Sleep(60);
KNDIOMove(Store_IO_Type.Line_Back, IO_VALUE.LOW);
Thread.Sleep(60);
KNDIOMove(Store_IO_Type.Line_Width_Foward, IO_VALUE.LOW);
//Thread.Sleep(60);
//KNDIOMove(Store_IO_Type.Line_Width_Back, IO_VALUE.LOW);
LOGGER.Info(StoreName + "停止所有运动");
}
/// <summary>
/// 定时处理
/// </summary>
public void TimerProcess()
{
//设备正常运行中
if (storeRunStatus >= StoreRunStatus.HomeMoving)
//if (DBStoreManager.storeRunStatus >= StoreRunStatus.Runing && storeRunStatus >= StoreRunStatus.Runing)
{
if (StoreMove.MoveType.Equals(StoreMoveType.None) && (InSuddonDown == false))
{
if (KNDIOValue(Store_IO_Type.Line_InDoor_Single).Equals(IO_VALUE.HIGH))
//if (KNDIOValue(Store_IO_Type.Line_InDoor_Single).Equals(IO_VALUE.HIGH) || KNDIOValue(Store_IO_Type.PreMachine_Send).Equals(IO_VALUE.HIGH))
{
StartInLine();
}
else if (!(currWidth.Equals(DBLineControl.CurrWidth)))
{
KNDIOMove(Store_IO_Type.SMEMA_Up, IO_VALUE.LOW);
LOGGER.Info(StoreName + "当前宽度" + currWidth + ",需要更改为" + DBLineControl.CurrWidth);
StartChangeWidth(DBLineControl.CurrWidth);
}
else if (currWidth.Equals(DBLineControl.CurrWidth))
{
if (KNDIOValue(Store_IO_Type.SMEMA_Up).Equals(IO_VALUE.LOW))
{
KNDIOMove(Store_IO_Type.SMEMA_Up, IO_VALUE.HIGH);
}
if (KNDIOValue(Store_IO_Type.SMEMA_Down).Equals(IO_VALUE.HIGH))
{
KNDIOMove(Store_IO_Type.SMEMA_Down, IO_VALUE.LOW);
}
}
}
else if (StoreMove.MoveType.Equals(StoreMoveType.InStore))
{
InStoreProcess();
}
else if (StoreMove.MoveType.Equals(StoreMoveType.StoreReset))
{
ChangeWidthProcess();
}
else if (StoreMove.MoveType.Equals(StoreMoveType.ReturnHome))
{
ReturnHomeProcess();
}
SuddonProcess();
}
}
/// <summary>
/// 急停信号处理
/// </summary>
private void SuddonProcess()
{
//判断急停信号
IO_VALUE suddonValue = DBStoreManager.GetSingle(Store_IO_Type.LINE_Suddown);
//没有在急停中收到急停信号
if (suddonValue.Equals(IO_VALUE.LOW) && (InSuddonDown == false))
{
LogUtil.error(LOGGER, StoreName + "收到急停信号,停止所有运行");
InSuddonDown = true;
StopMove();
}
//已经在急停中,收到复位信号
else if (suddonValue.Equals(IO_VALUE.HIGH) && InSuddonDown)
{
LogUtil.error(LOGGER, StoreName + "急停过程中,急停信号正常,自动复位");
InSuddonDown = false;
Reset();
}
}
public string getRunStr()
{
if (storeRunStatus.Equals(StoreRunStatus.Wait))
{
return "未启动";
}
else if (StoreMove.MoveType.Equals(StoreMoveType.ReturnHome))
{
return "原点返回中";
}
else if (StoreMove.MoveType.Equals(StoreMoveType.StoreReset))
{
return "调宽中";
}
else if (StoreMove.MoveType.Equals(StoreMoveType.InStore))
{
return "板子经过中";
}
else if (storeRunStatus.Equals(StoreRunStatus.Runing))
{
return "运行中";
}
return "";
}
#endregion
#region 原点返回和重置
private void ReturnHome()
{
returnHomeTime = DateTime.Now;
LogUtil.info(LOGGER, StoreName + "开始原点返回:设置电机速度");
storeRunStatus = StoreRunStatus.HomeMoving;
StoreMove.NewMove(StoreMoveType.ReturnHome);
StoreMove.NextMoveStep(StoreMoveStep.LINEH_SetSpeed_001);
//设置速度
ShuoKeControls.SetSpeed(Config.LineWidth_Slv, ShuoKeCMD.SetAddSpeed, DBStoreManager.lineConfig.LineWidth_AddSpeed);
Thread.Sleep(100);
ShuoKeControls.SetSpeed(Config.LineWidth_Slv, ShuoKeCMD.SetDelSpeed, DBStoreManager.lineConfig.LineWidth_DelSpeed);
Thread.Sleep(100);
ShuoKeControls.SetSpeed(Config.LineWidth_Slv, ShuoKeCMD.SetEndSpeed, DBStoreManager.lineConfig.LineWidth_EndSpeed);
Thread.Sleep(100);
ShuoKeControls.SetSpeed(Config.LineWidth_Slv, ShuoKeCMD.SetHomeSpeed, DBStoreManager.lineConfig.LineWidth_HomeSpeed);
Thread.Sleep(100);
ShuoKeControls.SetSpeed(Config.LineWidth_Slv, ShuoKeCMD.SetMaxSpeed, DBStoreManager.lineConfig.LineWidth_MaxSpeed);
Thread.Sleep(100);
ShuoKeControls.SetSpeed(Config.LineWidth_Slv, ShuoKeCMD.SetStartSpeed, DBStoreManager.lineConfig.LineWidth_StartSpeed);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2000));
if (!DBStoreManager.IsRun)
{
timer.Interval = 1000;
timer.Enabled = true;
}
}
private DateTime returnHomeTime = DateTime.Now;
public void ReturnHomeProcess()
{
if ((DateTime.Now - returnHomeTime).TotalSeconds < 1)
{
return;
}
returnHomeTime = DateTime.Now;
if (StoreMove.IsInWait)
{
CheckWait();
}
if (StoreMove.IsInWait)
{
if (StoreMove.MoveStep.Equals(StoreMoveStep.LINEH_RevertMove_002) || StoreMove.MoveStep.Equals(StoreMoveStep.LINEH_LineHome_003))
{
ShuoKeControls.GetStatus(Config.LineWidth_Slv);
}
return;
}
if (StoreMove.MoveStep.Equals(StoreMoveStep.LINEH_SetSpeed_001))
{
LogUtil.info(LOGGER, StoreName + "开始原点返回,调宽先反方向走到20000");
KNDIOMove(Store_IO_Type.Line_Width_Foward, IO_VALUE.HIGH);
StoreMove.NextMoveStep(StoreMoveStep.LINEH_RevertMove_002);
ShuoKeControls.AbsMove(Config.LineWidth_Slv, 20000);
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.LineWidth_Slv, 20000, false));
}
else if (StoreMove.MoveStep.Equals(StoreMoveStep.LINEH_RevertMove_002))
{
LogUtil.info(LOGGER, StoreName + "开始原点返回:电机原点返回");
StoreMove.NextMoveStep(StoreMoveStep.LINEH_LineHome_003);
ShuoKeControls.HomeMove(Config.LineWidth_Slv, 0);
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.LineWidth_Slv, 0, true));
}
else if (StoreMove.MoveStep.Equals(StoreMoveStep.LINEH_LineHome_003))
{
StoreMove.EndMove();
KNDIOMove(Store_IO_Type.Line_Width_Foward, IO_VALUE.LOW);
storeRunStatus = StoreRunStatus.Runing;
currWidth = Config.LineWidth_HomeWidth;
LogUtil.info(LOGGER, StoreName + "原点重置返回完成!");
timer.Interval = 200;
}
}
/// <summary>
/// 重置
/// </summary>
public void Reset()
{
LogUtil.info(LOGGER, StoreName + "开始重置!");
KNDIOMove(Store_IO_Type.Line_Back, IO_VALUE.LOW);
Thread.Sleep(60);
KNDIOMove(Store_IO_Type.SMEMA_Down, IO_VALUE.LOW);
Thread.Sleep(60);
KNDIOMove(Store_IO_Type.SMEMA_Up, IO_VALUE.LOW);
Thread.Sleep(60);
KNDIOMove(Store_IO_Type.Line_Width_Foward, IO_VALUE.HIGH);
Thread.Sleep(60);
ShuoKeControls.SuddownStop(Config.LineWidth_Slv);
FileGenerated.writeLCTFile(DBLineControl.MachineId, 1, 0, 0);
//StoreMove.EndMove();
//storeRunStatus = StoreRunStatus.Runing;
//LogUtil.info(LOGGER, StoreName + "重置完成!");
ShuoKeControls.SuddownStop(Config.LineWidth_Slv);
LogUtil.info(LOGGER, StoreName + "开始重置,调宽先反方向走到20000");
storeRunStatus = StoreRunStatus.HomeMoving;
StoreMove.NewMove(StoreMoveType.ReturnHome);
StoreMove.NextMoveStep(StoreMoveStep.LINEH_RevertMove_002);
ShuoKeControls.AbsMove(Config.LineWidth_Slv, 20000);
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.LineWidth_Slv, 20000, false));
}
#endregion
#region 调宽处理,调宽的StoreMoveType使用重置的类型
private DateTime changeWidthTime = DateTime.Now;
private void StartChangeWidth(int newWidth)
{
changeWidthTime = DateTime.Now;
KNDIOMove(Store_IO_Type.Line_Width_Foward, IO_VALUE.HIGH);
timer.Interval = 1000;
currWidth = newWidth;
StoreMove.NewMove(StoreMoveType.StoreReset);
StoreMove.NextMoveStep(StoreMoveStep.LINECW_LineChangeWidth);
int needPosition = DBLineControl.GetNeedPosition(newWidth, Config.LineWidth_HomeWidth);
ShuoKeControls.AbsMove(Config.LineWidth_Slv, needPosition);
StoreMove.WaitList.Add(WaitResultInfo.WaitShuoKe(Config.LineWidth_Slv, needPosition, false));
LogUtil.info(LOGGER, StoreName + "线体调宽处理,目标宽度【" + currWidth + "】 目标脉冲【" + needPosition + "】流水线开始回原点");
}
private void ChangeWidthProcess()
{
if ((DateTime.Now - changeWidthTime).TotalSeconds < 1)
{
return;
}
changeWidthTime = DateTime.Now;
if (StoreMove.IsInWait)
{
CheckWait();
}
if (StoreMove.IsInWait)
{
ShuoKeControls.GetStatus(Config.LineWidth_Slv);
return;
}
switch (StoreMove.MoveStep)
{
case StoreMoveStep.LINECW_LineChangeWidth:
KNDIOMove(Store_IO_Type.Line_Width_Foward, IO_VALUE.LOW);
ShuoKeControls.SuddownStop(Config.LineWidth_Slv);
StoreMove.EndMove();
storeRunStatus = StoreRunStatus.Runing;
LogUtil.info(LOGGER, StoreName + "线体调宽处理:已完成! ");
timer.Interval = 200;
if (m_Time != DBLineControl.currM_Time)
{
LogUtil.info(LOGGER, StoreName + "调宽完成,写入OK文件,时间【" + m_Time + "】! ");
m_Time = DBLineControl.currM_Time;
//写文件
FileGenerated.writeRequestFile(DBLineControl.MachineId, DBLineControl.CurrAA, DBLineControl.CurrProjectName, FileGenerated.REQUEST_OK, DBLineControl.currM_Time);
//更新文件
FileGenerated.writeLSTFile(DBLineControl.MachineId);
}
break;
default:
break;
}
}
//private void StartChangeWidth(int newWidth)
//{
// currWidth = newWidth;
// StoreMove.NewMove(StoreMoveType.StoreReset);
// StoreMove.NextMoveStep(StoreMoveStep.LINECW_LineReturnHome);
// Thread.Sleep(10);
// KNDIOMove(Store_IO_Type.Line_Width_Foward, IO_VALUE.HIGH);
// StoreMove.WaitList.Add(WaitResultInfo.WaitIO(Store_IO_Type.Line_Home, IO_VALUE.HIGH));
// LogUtil.info(LOGGER, StoreName + "线体调宽处理,目标宽度【" + currWidth + "】,流水线开始回原点");
//}
//private void ChangeWidthProcess()
//{
// if (StoreMove.IsInWait)
// {
// CheckWait();
// }
// if (StoreMove.IsInWait)
// {
// return;
// }
// switch (StoreMove.MoveStep)
// {
// case StoreMoveStep.Wait:
// StoreMove.NewMove(StoreMoveType.StoreReset);
// StoreMove.NextMoveStep(StoreMoveStep.LINECW_LineReturnHome);
// StoreMove.WaitList.Add(WaitResultInfo.WaitIO(Store_IO_Type.Line_Home, IO_VALUE.HIGH));
// KNDIOMove(Store_IO_Type.Line_Width_Foward, IO_VALUE.HIGH);
// LogUtil.info(LOGGER, StoreName + "线体调宽处理,流水线开始回原点");
// break;
// case StoreMoveStep.LINECW_LineReturnHome:
// KNDManager.timer.Enabled = false;
// KNDIOMove(Store_IO_Type.Line_Width_Foward, IO_VALUE.LOW);
// Thread.Sleep(50);
// StoreMove.NextMoveStep(StoreMoveStep.LINECW_LineChangeWidth);
// int needMS = DBLineControl.GetNeedMS(currWidth);
// KNDIOMove(Store_IO_Type.Line_Width_Back, IO_VALUE.HIGH, needMS);
// StoreMove.WaitList.Add(WaitResultInfo.WaitIO(Store_IO_Type.Line_Width_Back, IO_VALUE.LOW));
// StoreMove.WaitList.Add(WaitResultInfo.WaitTime(needMS));
// StoreMove.OneWaitCanEndStep = true;
// LogUtil.info(LOGGER, StoreName + "线体调宽处理,目标宽度【"+currWidth+"】,反向转动时间【" + needMS + "】,检测自动停止");
// break;
// case StoreMoveStep.LINECW_LineChangeWidth:
// KNDIOMove(Store_IO_Type.Line_Width_Back, IO_VALUE.LOW);
// StoreMove.EndMove();
// storeRunStatus = StoreRunStatus.Runing;
// LogUtil.info(LOGGER, StoreName +"线体调宽处理:已完成! ");
// if (m_Time != DBLineControl.currM_Time)
// {
// LogUtil.info(LOGGER, StoreName + "调宽完成,写入OK文件,时间【" + m_Time + "】! ");
// m_Time = DBLineControl.currM_Time;
// //写文件
// FileGenerated.writeRequestFile(DBLineControl.MachineId, DBLineControl.CurrAA, DBLineControl.CurrProjectName, FileGenerated.REQUEST_OK, DBLineControl.currM_Time);
// //更新文件
// FileGenerated.writeLSTFile(DBLineControl.MachineId);
// }
// KNDManager.timer.Enabled = true ;
// break;
// default:
// break;
// }
//}
#endregion
#region 等待处理
private void InOutLog(string msg)
{
LogUtil.info(LOGGER, StoreName + msg);
}
private void CheckWait()
{
if (DeviceControl.isNoDeviceDebug)
{
StoreMove.EndStepWait();
return;
}
List<WaitResultInfo> list = StoreMove.WaitList;
//当等待超过一分钟时,需要打印提示
TimeSpan span = DateTime.Now - StoreMove.LastSetpTime;
if (span.TotalMinutes > 5)
{
WarnMsg = StoreName + "等待超时【" + StoreMove.MoveType + "】【" + StoreMove.MoveStep + "】已等待【" + span.TotalMinutes + "】分钟,";
foreach (WaitResultInfo wait in list)
{
WarnMsg = WarnMsg + "\r\n" + wait.ToStr();
}
LogUtil.error(LOGGER, WarnMsg, 12);
}
if (list.Count > 0)
{
bool isOk = true;
if (StoreMove.OneWaitCanEndStep)
{
isOk = false;
foreach (WaitResultInfo wait in list)
{
if (wait.WaitType == 2)
{
if (KNDIOValue(wait.IoType).Equals(wait.IoValue))
{
isOk = true;
break;
}
else
{
//一分钟还未检测到
if (span.TotalMilliseconds > 60000)
{
WarnMsg = StoreName + " 等待信号(" + getIoType(wait.IoType) + "=" + wait.IoValue + ") 超时!";
LogUtil.error(LOGGER, WarnMsg, 13);
}
}
}
else if (wait.WaitType == 3)
{
if (span.TotalMilliseconds >= wait.TimeMSeconds)
{
isOk = true;
break;
}
}
else if (wait.WaitType == 5)
{
if (wait.IsHomeMove)
{
if (ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime))
{
isOk = true; break;
}
}
else
{
if (ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime))
{
isOk = true; break;
}
}
}
}
}
else
{
foreach (WaitResultInfo wait in list)
{
if (wait.WaitType == 2)
{
if (!KNDIOValue(wait.IoType).Equals(wait.IoValue))
{
//一分钟还未检测到
if (span.TotalMilliseconds > 60000)
{
WarnMsg = StoreName + " 等待信号(" + getIoType(wait.IoType) + "=" + wait.IoValue + ") 超时!";
LogUtil.error(LOGGER, WarnMsg, 13);
}
isOk = false;
break;
}
}
else if (wait.WaitType == 3)
{
if (span.TotalMilliseconds < wait.TimeMSeconds)
{
isOk = false;
break;
}
}
else if (wait.WaitType == 5)
{
if (wait.IsHomeMove)
{
if (!ShuoKeControls.IsHomeMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime))
{
isOk = false;
break;
}
}
else
{
if (!ShuoKeControls.IsMoveEnd(wait.SlvAddr, StoreMove.LastSetpTime))
{
isOk = false;
break;
}
}
}
}
}
if (isOk)
{
StoreMove.EndStepWait();
}
}
else
{
StoreMove.EndStepWait();
}
}
private string getIoType(string ioType)
{
if (Config.StoreDIList.ContainsKey(ioType))
{
return Config.StoreDIList[ioType].DisplayStr;
}
return ioType;
}
#endregion
#region 板子经过流水线处理,storeMoveType全部用入库的模式处理
/// <summary>
/// 开始出库运动
/// </summary>
public void StartInLine()
{
FileGenerated.writeLCTFile(DBLineControl.MachineId, 1, 0, 1);
KNDIOMove(Store_IO_Type.SMEMA_Up, IO_VALUE.LOW);
//阻挡气缸0-2下降
storeRunStatus = StoreRunStatus.Busy;
LogUtil.info(LOGGER, StoreName + "流水线送版 , 步骤一,收到入料信号,皮带转动");
StoreMove.NewMove(StoreMoveType.InStore, null);
StoreMove.NextMoveStep(StoreMoveStep.LINEIN_OpenLine);
//Y33=0,Y26=1,Y35=1
//上位机要料信号=0,上位机送料完成信号=1,皮带转动
Thread.Sleep(100);
KNDIOMove(Store_IO_Type.Line_Back, IO_VALUE.HIGH);
//等待出料口信号
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(Store_IO_Type.Line_InDoor_Single, IO_VALUE.LOW));
FileGenerated.writeSTSFile(DBLineControl.MachineId, 1, 0);
}
protected void InStoreProcess()
{
if (StoreMove.IsInWait)
{
CheckWait();
}
if (StoreMove.IsInWait)
{
return;
}
switch (StoreMove.MoveStep)
{
case StoreMoveStep.LINEIN_OpenLine:
StoreMove.NextMoveStep(StoreMoveStep.LINEIN_WaitOutSingle);
//入料口已经没有信号,发送收料完成信号
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(Store_IO_Type.Line_OutDoor_Single, IO_VALUE.HIGH));
LogUtil.info(LOGGER, StoreName + "流水线送版 , 步骤二,入料口已经没有信号,发送收料完成信号,等待出料口信号");
break;
case StoreMoveStep.LINEIN_WaitOutSingle:
//判断下位机要料信号
if (KNDIOValue(Store_IO_Type.PreMachine_Send).Equals(IO_VALUE.HIGH) || DBLineControl.NoWaitSingle.Equals(1))
{
StoreMove.NextMoveStep(StoreMoveStep.LINEIN_WaitOutSingleLow);
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(Store_IO_Type.Line_OutDoor_Single, IO_VALUE.LOW));
//给下位机发送送版信号
KNDIOMove(Store_IO_Type.SMEMA_Down, IO_VALUE.HIGH);
LogUtil.info(LOGGER, StoreName + "流水线送版 , 步骤三,,收到出料口信号,下位机要料=0");
}
else
{
LogUtil.info(LOGGER, StoreName + "流水线送版 , 步骤三,,收到出料口信号,下位机没有要料,关闭皮带,等下位机要料");
KNDIOMove(Store_IO_Type.Line_Back, IO_VALUE.LOW);
Thread.Sleep(100);
//给下位机发送送版信号
KNDIOMove(Store_IO_Type.SMEMA_Down, IO_VALUE.HIGH);
//KNDIOMove(Store_IO_Type.SMEMA_Down, IO_VALUE.LOW);
StoreMove.NextMoveStep(StoreMoveStep.LINEIN_WatiMachineSingle);
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(Store_IO_Type.PreMachine_Send, IO_VALUE.HIGH));
}
break;
case StoreMoveStep.LINEIN_WatiMachineSingle:
KNDIOMove(Store_IO_Type.SMEMA_Up, IO_VALUE.LOW);
StoreMove.NextMoveStep(StoreMoveStep.LINEIN_WaitOutSingleLow);
KNDIOMove(Store_IO_Type.Line_Back, IO_VALUE.HIGH);
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(Store_IO_Type.Line_OutDoor_Single, IO_VALUE.LOW));
LogUtil.info(LOGGER, StoreName + "流水线送版 , 步骤三,,收到下位机要料信号,送板子过去");
break;
case StoreMoveStep.LINEIN_WaitOutSingleLow:
KNDIOMove(Store_IO_Type.SMEMA_Up, IO_VALUE.LOW);
KNDIOMove(Store_IO_Type.SMEMA_Down, IO_VALUE.LOW);
StoreMove.NextMoveStep(StoreMoveStep.LINEIN_CloseLine);
LogUtil.info(LOGGER, StoreName + "流水线送版 , 步骤四,, 出料口信号=0,关闭皮带");
//StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2500));
//测试暂时修改
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(200));
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(Store_IO_Type.Line_OutDoor_Single, IO_VALUE.LOW));
break;
case StoreMoveStep.LINEIN_CloseLine:
KNDIOMove(Store_IO_Type.Line_Back, IO_VALUE.LOW);
//要料信号
LogUtil.info(LOGGER, StoreName + "送料完成!");
Thread.Sleep(100);
//给下位机发送送版信号
KNDIOMove(Store_IO_Type.SMEMA_Down, IO_VALUE.LOW);
//Thread.Sleep(100);
//KNDIOMove(Store_IO_Type.SMEMA_Up, IO_VALUE.HIGH);
StoreMove.EndMove();
storeRunStatus = StoreRunStatus.Runing;
FileGenerated.writeSTSFile(DBLineControl.MachineId, 1, 0);
FileGenerated.writeLCTFile(DBLineControl.MachineId, 1, 0, 0);
break;
default:
break;
}
}
#endregion
#region IO处理
public void KNDIOMove(string ioType, IO_VALUE ioValue, int ms)
{
if (Config.StoreDOList.ContainsKey(ioType))
{
ConfigIO configIo = Config.StoreDOList[ioType];
KNDManager.WriteSingleDO(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr(), ioValue, ms);
//UpdateDoValue(ioType, ioValue);
}
else
{
LogUtil.error(LOGGER, StoreName + "没有DO=" + ioType);
}
}
public void KNDIOMove(string ioType, IO_VALUE ioValue)
{
if (Config.StoreDOList.ContainsKey(ioType))
{
ConfigIO configIo = Config.StoreDOList[ioType];
KNDManager.WriteSingleDO(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr(), ioValue);
//UpdateDoValue(ioType, ioValue);
}
else
{
LogUtil.error(LOGGER, StoreName + "没有DO=" + ioType);
}
}
public IO_VALUE KNDIOValue(string ioType)
{
IO_VALUE ioValue = IO_VALUE.LOW;
if (Config.StoreDIList.ContainsKey(ioType))
{
ConfigIO configIo = Config.StoreDIList[ioType];
ioValue = KNDManager.GetDIValue(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr());
//UpdateDoValue(ioType, ioValue);
}
else if (Config.StoreDOList.ContainsKey(ioType))
{
ConfigIO configIo = Config.StoreDOList[ioType];
ioValue = KNDManager.GetDOValue(configIo.DeviceName, configIo.SlaveID, configIo.GetIOAddr());
}
else
{
LogUtil.error(LOGGER, StoreName + "没有DO=" + ioType);
}
return ioValue;
}
#endregion
}
}