StoreMoveInfo.cs
17.7 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
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 料仓当前运动信息类(出入库状态,步骤记录)
/// </summary>
public class StoreMoveInfo
{
/// <summary>
/// 超时时间
/// </summary>
public int TimeOutSeconds = 60;
public StoreMoveInfo(string deviceName)
{
moveType = StoreMoveType.None;
MoveParam = new InOutStoreParam();
this.DeviceName = deviceName;
this.moveStep = StoreMoveStep.Wait;
IsInWait = false;
MoveNum = 0;
}
public int MoveNum { get; set; }
public DateTime LastSetpTime { get; set; }
/// <summary>
/// =true表示满足一个等待条件,就可以完成此步骤的等待
/// </summary>
public bool OneWaitCanEndStep = false;
/// <summary>
/// 操作类型
/// </summary>
private StoreMoveType moveType = StoreMoveType.None;
public StoreMoveType MoveType
{
get { return moveType; }
}
/// <summary>
///出入库参数,料仓内部使用
/// </summary>
public InOutStoreParam MoveParam { get; set; }
/// <summary>
/// 当前运动是哪个料仓
/// </summary>
public string DeviceName { get; set; }
/// <summary>
/// 是否再当前步骤等待中
/// </summary>
public bool IsInWait { get; set; }
/// <summary>
/// 上一个执行步骤
/// </summary>
public StoreMoveStep PreMoveStep { get; set; }
/// <summary>
/// 当前执行到的步骤
/// </summary>
private StoreMoveStep moveStep;
/// <summary>
/// 可以循环运动的次数(轴卡运动才需要)
/// </summary>
public int CanWhileCount = 0;
/// <summary>
/// 料仓运动步骤记录
/// </summary>
public StoreMoveStep MoveStep
{
get { return moveStep; }
}
/// <summary>
/// 是否是批量出入库
/// </summary>
public bool IsBatchInOutStore=true ;
/// <summary>
/// 是否需要入库,不需要入库把料盘放在门口即可
/// </summary>
public bool IsNeedInStore = true;
public List<WaitResultInfo> WaitList = new List<WaitResultInfo>();
public void NextMoveStep(StoreMoveStep step)
{
PreMoveStep = moveStep;
moveStep = step;
LastSetpTime = DateTime.Now;
IsInWait = true;
WaitList = new List<WaitResultInfo>();
OneWaitCanEndStep = false;
CanWhileCount = 5;
}
/// <summary>
/// 当前步骤执行完成
/// </summary>
public void EndStepWait()
{
IsInWait = false;
WaitList = new List<WaitResultInfo>();
}
public void NewMove(StoreMoveType type )
{
moveStep = StoreMoveStep.Wait;
this.moveType = type;
LastSetpTime = DateTime.Now;
WaitList = new List<WaitResultInfo>();
MoveNum++;
}
public void NewMove(StoreMoveType type, InOutStoreParam param)
{
moveStep = StoreMoveStep.Wait;
this.moveType = type;
this.MoveParam = param;
LastSetpTime = DateTime.Now;
WaitList = new List<WaitResultInfo>();
}
public void EndMove()
{
this.moveType = StoreMoveType.None;
this.MoveParam = null;
moveStep = StoreMoveStep.Wait;
LastSetpTime = DateTime.Now;
IsInWait = false;
WaitList = new List<WaitResultInfo>();
CanWhileCount = 0;
}
}
public class WaitResultInfo
{
private WaitResultInfo()
{
IsEnd = false;
}
public static WaitResultInfo WaitIO(string ioType, IO_VALUE ioValue)
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 0;
wait.WaitType =(int) Wait_Type.IOMove_2;
wait.IoType = ioType;
wait.IoValue = ioValue;
wait.IsEnd = false;
return wait;
}
public static WaitResultInfo WaitAxis(ConfigMoveAxis axis,int targetPosition,int targetSpeed )
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 0;
wait.WaitType = (int)Wait_Type.AxisMove_1;
wait.AxisInfo = axis;
wait.IsHomeMove = false;
wait.TargetPosition = targetPosition;
wait.TargetSpeed = targetSpeed;
wait.IsEnd = false;
return wait;
}
public static WaitResultInfo WaitAxis(ConfigMoveAxis axis, bool isHomeMove)
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 0;
wait.WaitType = (int)Wait_Type.AxisMove_1;
wait.AxisInfo = axis;
wait.IsHomeMove = true;
wait.IsEnd = false;
return wait;
}
public static WaitResultInfo WaitStell(byte slvAddr, int targetPosition, int speed)
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount =10;
wait.WaitType = (int)Wait_Type.StellMove_4;
wait.SlvAddr = slvAddr;
wait.IsHomeMove = false;
wait.TargetPosition = targetPosition;
wait.TargetSpeed = speed;
wait.IsEnd = false;
return wait;
}
public static WaitResultInfo WaitStellHome(byte slvAddr, int targetPosition, int speed)
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 10;
wait.WaitType = (int)Wait_Type.StellMove_4;
wait.SlvAddr = slvAddr;
wait.IsHomeMove = true;
wait.TargetPosition = 0;
wait.TargetSpeed = speed;
wait.IsEnd = false;
return wait;
}
public static WaitResultInfo WaitShuoKe(int slvAddr, int targetPosition, bool isHome)
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 0;
wait.WaitType = (int)Wait_Type.ShuoKe_5 ;
wait.SlvAddr =(byte) slvAddr;
wait.TargetPosition = targetPosition;
wait.IsHomeMove = isHome;
return wait;
}
public static WaitResultInfo WaitTime(int MScends)
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 0;
wait.WaitType = (int)Wait_Type.Time_3;
wait.TimeMSeconds = MScends;
wait.IsEnd = false;
return wait;
}
/// <summary>
/// 6=等待轴原点信号亮
/// </summary>
/// <param name="axis"></param>
/// <param name="value"></param>
/// <returns></returns>
public static WaitResultInfo WaitAxisOrg(ConfigMoveAxis axis,IO_VALUE value )
{
WaitResultInfo wait = new WaitResultInfo();
wait.CanWhileMoveCount = 0;
wait.WaitType = (int)Wait_Type.AxisHomeSingle_6;
wait.AxisInfo = axis;
wait.IsHomeMove = true;
wait.IoValue = value;
wait.IsEnd = false;
return wait;
}
//public static WaitResultInfo WaitHeight(int height)
//{
// WaitResultInfo wait = new WaitResultInfo();
// wait.WaitType = 7;
// wait.HeightValue = height;
// wait.IsEnd = false;
// return wait;
//}
///// <summary>
/////8= 等待轴的反限位为指定值
///// </summary>
//public static WaitResultInfo WaitAxistNegativeLimit(ConfigMoveAxis moveAxis ,IO_VALUE ioValue)
//{
// WaitResultInfo wait = new WaitResultInfo();
// wait.CanWhileMoveCount = 0;
// wait.WaitType = 8;
// wait.AxisInfo = moveAxis;
// wait.IsHomeMove = true;
// wait.IoValue = ioValue;
// wait.IsEnd = false;
// return wait;
//}
///// <summary>
/////9= 等待轴的正限位为指定值
///// </summary>
//public static WaitResultInfo WaitAxistPositiveLimit(ConfigMoveAxis moveAxis, IO_VALUE ioValue)
//{
// WaitResultInfo wait = new WaitResultInfo();
// wait.CanWhileMoveCount = 0;
// wait.WaitType = 9;
// wait.AxisInfo = moveAxis;
// wait.IsHomeMove = true;
// wait.IoValue = ioValue;
// wait.IsEnd = false;
// return wait;
//}
/// <summary>
/// 10=等待批量上下料轴运动 停止
/// </summary>
/// <returns></returns>
public static WaitResultInfo WaitBatchAxisStop(ConfigMoveAxis moveAxis,int targetPosition,string targetIoType,IO_VALUE value=IO_VALUE.HIGH)
{
WaitResultInfo wait = new WaitResultInfo();
wait.TargetPosition = targetPosition;
wait.CanWhileMoveCount = 0;
wait.AxisInfo = moveAxis;
wait.WaitType = (int)Wait_Type.BatchAxisMove_10;
wait.IsHomeMove = true;
wait.IsEnd = false;
wait.IoType = targetIoType;
wait.IoValue = value;
return wait;
}
/// <summary>
/// 11=扫码OK
/// </summary>
/// <returns></returns>
public static WaitResultInfo WaitCodeOK()
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = (int)Wait_Type.ScanCode_11;
return wait;
}
/// <summary>
/// 12=等待操作人员拿走料盘
/// </summary>
/// <returns></returns>
public static WaitResultInfo WaitTakeTray()
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = (int)Wait_Type.TakeTrayGo_12;
return wait;
}
public static WaitResultInfo WaitStoreRuning()
{
WaitResultInfo wait = new WaitResultInfo();
wait.WaitType = (int)Wait_Type.StoreRuning_13;
return wait;
}
public string ToStr()
{
if (WaitType == (int)Wait_Type.AxisMove_1)
{
if (IsHomeMove)
{
return "【" + AxisInfo.DisplayStr + "】" + ResourceControl.GetString(ResourceControl.HomeMove, "原点返回");
}
else
{
return "【" + AxisInfo.DisplayStr + "】" + ResourceControl.GetString(ResourceControl.AbsMove, "绝对运动") + "【" + TargetPosition + "】";
}
}
else if (WaitType == 2)
{
return ResourceControl.GetString(ResourceControl.WaitIo, "IO信号等待") + "【" + IoType + "】=【" + IoValue + "】";
}
else if (WaitType == 3)
{
return ResourceControl.GetString(ResourceControl.WaitTime, "时间等待:") + "【" + TimeMSeconds + "】";
}
else if (WaitType == (int)Wait_Type.StellMove_4)
{
return ResourceControl.GetString(ResourceControl.TargetPosition, "电钢目标位置:") + "【" + TargetPosition + "】 ";
}
else if (WaitType == (int)Wait_Type.ShuoKe_5)
{
return ResourceControl.GetString(ResourceControl.TargetPosition, "电钢目标位置:") + "【" + TargetPosition + "】 ";
}
else if (WaitType == (int)Wait_Type.AxisHomeSingle_6)
{
return "【" + AxisInfo.DisplayStr + "】ORG:【" + IoValue + "】 ";
}
else if (WaitType == (int)Wait_Type.WaitHeight_7)
{
return ResourceControl.GetString(ResourceControl.trayHeight, "料盘高度") + "【" + HeightValue + "】 ";
}
else if (WaitType == (int)Wait_Type.AxisLimitNegativeSingle_8)
{
return "【" + AxisInfo.DisplayStr + "】" + ResourceControl.GetString(ResourceControl.FuLimit, "负限位") + "【" + IoValue + "】 ";
}
else if (WaitType == (int)Wait_Type.AxisLimitPositiveSingle_9)
{
return "【" + AxisInfo.DisplayStr + "】" + ResourceControl.GetString(ResourceControl.ZhLimit, "正限位") + "【" + IoValue + "】 ";
}
else if (WaitType == (int)Wait_Type.BatchAxisMove_10)
{
return ResourceControl.GetString(ResourceControl.BatchStop, "上料轴运动停止 ");
}
else if (WaitType == (int)Wait_Type.ScanCode_11)
{
return ResourceControl.GetString(ResourceControl.ScanOk, "扫码结束");
}
else if (WaitType == (int)Wait_Type.TakeTrayGo_12)
{
if (AutomaticBaiting.WaitIoValue.Equals(IO_VALUE.HIGH))
{
return ResourceControl.GetString("操作人员放入料盘", "操作人员放入料盘");
}
else
{
return ResourceControl.GetString(ResourceControl.TakeTrayGo, "操作人员拿走料盘");
}
}
else if (WaitType == (int)Wait_Type.StoreRuning_13)
{
return ResourceControl.GetString(ResourceControl.WaitEnd, "等待送料结束");
}
else
{
return "WaitType=【" + WaitType + "】";
}
}
/// <summary>
/// 当未结束时可以重复运动的次数
/// </summary>
public int CanWhileMoveCount { get; set; }
/// <summary>
/// 等待结果,1=轴运动,2=IO运动,3=时间,4=电钢,5=硕科电机,6=等待轴原点信号
/// 7=等待高度为0,8=等待轴的负限位,9=等待轴的正限位。10=上料轴运动停止
/// 11=扫码结束。
/// 12=操作人员拿走料盘,并点击确定。
/// </summary>
public int WaitType { get; set; }
/// <summary>
/// 轴运动时表示轴信息
/// </summary>
public ConfigMoveAxis AxisInfo { get; set; }
/// <summary>
/// 电钢地址
/// </summary>
public byte SlvAddr { get; set; }
/// <summary>
/// IO类型
/// </summary>
public String IoType { get; set; }
/// <summary>
/// IO值
/// </summary>
public IO_VALUE IoValue { get; set; }
/// <summary>
/// 等待的毫秒
/// </summary>
public int TimeMSeconds { get; set; }
/// <summary>
/// 是否是原点返回
/// </summary>
public bool IsHomeMove = false;
/// <summary>
/// 轴目标位置
/// </summary>
public int TargetPosition { get; set; }
/// <summary>
/// 轴目标速度
/// </summary>
public int TargetSpeed { get; set; }
/// <summary>
/// 是否已经结束
/// </summary>
public bool IsEnd{ get; set; }
/// <summary>
/// 高度
/// </summary>
public int HeightValue { get; set; }
}
public enum Wait_Type
{
None_0=0,
/// <summary>
/// 1=轴运动,
/// </summary>
AxisMove_1 = 1,
/// <summary>
/// 2=IO运动,
/// </summary>
IOMove_2 = 2,
/// <summary>
/// 3=时间
/// </summary>
Time_3 = 3,
/// <summary>
/// ,4=电钢,
/// </summary>
StellMove_4 = 4,
/// <summary>
/// 5=硕科电机
/// </summary>
ShuoKe_5 = 5,
/// <summary>
/// ,6=等待轴原点信号
/// </summary>
AxisHomeSingle_6 = 6,
/// <summary>
/// 7=等待高度为0,
/// </summary>
WaitHeight_7 = 7,
/// <summary>
/// 8=等待轴的负限位,
/// </summary>
AxisLimitNegativeSingle_8 = 8,
/// <summary>
/// 9=等待轴的正限位。
/// </summary>
AxisLimitPositiveSingle_9 = 9,
/// <summary>
/// 10=上料轴运动停止
/// </summary>
BatchAxisMove_10 = 10,
/// <summary>
/// 11=扫码结束。
/// </summary>
ScanCode_11 = 11,
/// <summary>
/// 12=操作人员拿走料盘,并点击确定。
/// </summary>
TakeTrayGo_12 = 12,
/// <summary>
/// 等待料仓正常运行无操作,等待送料结束
/// </summary>
StoreRuning_13,
}
public enum StoreMoveType
{
/// <summary>
/// 没有任何操作
/// </summary>
None = 0,
/// <summary>
/// 入库
/// </summary>
InStore = 1,
/// <summary>
/// 出库
/// </summary>
OutStore = 2,
/// <summary>
/// 原点返回
/// </summary>
ReturnHome = 3,
/// <summary>
/// 重置
/// </summary>
StoreReset = 4,
///// <summary>
///// 移栽装置的停止,需要先远点返回,然后停止
///// </summary>
//StopMove=5,
///// <summary>
///// 移栽检测托盘
///// </summary>
//CheckFixture=6,
}
}