FeedingEquip.cs
15.0 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
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
/// <summary>
/// 流水线自动料仓-入料装置类
/// </summary>
public partial class FeedingEquip : EquipBase
{
public FeedingEquip_Config Config;
public AxisBean BatchAxis = null;
public FeedingEquip(string cid, FeedingEquip_Config config)
{
this.DeviceID = config.Id;
baseConfig = config;
this.Config = config;
IsDebug = config.IsDebug.Equals(1);
Name = (" " + "_入料_" + DeviceID % 100 + " ").ToUpper();
Init();
UseAxis = true;
Config.SetAxisParam();
UpdownAxis = new AxisBean(config.UpDown_Axis);
BatchAxis = new AxisBean(config.Batch_Axis);
MoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-Move");
SecondMoveInfo = new LineMoveInfo(DeviceID, "入料-" + DeviceID + "-SecondMove");
}
/// <summary>
/// 开始运行
/// </summary>
public override bool StartRun(bool isDebug = false)
{
if (CanStartRun().Equals(false))
{
return false;
}
if (RunAxis(true, BatchAxis) && RunAxis(true, UpdownAxis))
{
mainTimer.Enabled = false;
MoveInfo.EndMove();
SecondMoveInfo.EndMove();
lineStatus = LineStatus.StoreOnline;
runStatus = LineRunStatus.HomeMoving;
LogInfo("开始原点返回: ");
MoveInfo.NewMove(LineMoveType.ReturnHome);
StartReset();
if (isDebug)
{
mainTimer.Start();
}
return true;
}
return false;
}
public override bool Reset()
{
StopMove();
if (RunAxis(true, BatchAxis) && RunAxis(true, UpdownAxis))
{
alarmType = LineAlarmType.None;
LogInfo("开始重置: ");
runStatus = LineRunStatus.Reset;
MoveInfo.NewMove(LineMoveType.Reset);
StartReset();
return true;
}return false;
}
private void StartReset()
{
ResetClearData();
lineStatus = LineStatus.ResetMove;
IOMove(IO_Type.SL_HddLed, IO_VALUE.HIGH);
MoveInfo.NextMoveStep(LineMoveStep.FR_01_BatchAxisHome);
LogInfo(MoveInfo.MoveType + ":"+MoveInfo.MoveStep+ ":提升伺服回原点,升降伺服回原点,所有阻挡气缸上升");
BatchAxis.HomeMove(MoveInfo);
UpdownAxis.HomeMove(MoveInfo);
if (Config.SidesWayNum <= 0)
{
IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.FL_StopCylinder_Down2, IO_VALUE.LOW);
//顶升气缸下降
CylinderMove(null, IO_Type.FL_TopCylinder_Up, IO_Type.FL_TopCylinder_Down);
}
//线体停止
IOMove(IO_Type.SL_Line_Run, IO_VALUE.LOW);
IOMove(IO_Type.SL_LocationSideWay_Run, IO_VALUE.LOW);
IOMove(IO_Type.SL_OutSideWay_Run, IO_VALUE.LOW);
//阻挡上升
IOMove(IO_Type.SL_Entry_StopDown, IO_VALUE.LOW);
IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.LOW);
IOMove(IO_Type.SL_Out_StopDown, IO_VALUE.LOW);
isInPro = false;
}
//复位时,应该先提升伺服回原点,然后提升伺服下降到P2点,放开定位气缸,顶升气缸下降,提升伺服在上升到P1点。
protected override void ResetProcess()
{
if (MoveInfo.IsInWait)
{
CheckWait(MoveInfo);
}
if (!MoveInfo.IsInWait)
{
switch (MoveInfo.MoveStep)
{
case LineMoveStep.Wait:
StartReset();
break;
case LineMoveStep.FR_01_BatchAxisHome:
LogInfo(MoveInfo.MoveType + ":FR_03_BatchAxisToP2:提升伺服下降到P2点,升降伺服上升到待机点");
MoveInfo.NextMoveStep(LineMoveStep.FR_03_BatchAxisToP2);
BatchAxis.AbsMove(MoveInfo, Config.BatchAxisP2, Config.BatchAxis_P2Speed);
UpdownAxis.AbsMove(MoveInfo, Config.UpDownAxisP1, Config.UpdownAxis_P1Speed);
break;
case LineMoveStep.FR_03_BatchAxisToP2:
LogInfo(MoveInfo.MoveType + ":FR_04_LocationCylinder_Down: 放开定位气缸");
MoveInfo.NextMoveStep(LineMoveStep.FR_04_LocationCylinder_Down);
TrayLCylinderAfter(MoveInfo);
break;
case LineMoveStep.FR_04_LocationCylinder_Down:
LogInfo(MoveInfo.MoveType + ":FR_05_TopCylinderDown:SL1定位气缸下降SOL");
MoveInfo.NextMoveStep(LineMoveStep.FR_05_TopCylinderDown);
CylinderMove(MoveInfo, IO_Type.SL_LocationCylinder_Up, IO_Type.SL_LocationCylinder_Down);
break;
case LineMoveStep.FR_05_TopCylinderDown:
LogInfo(MoveInfo.MoveType + ":FR_06_BatchAxisToP1:提升伺服在上升到P1点");
MoveInfo.NextMoveStep(LineMoveStep.FR_06_BatchAxisToP1);
BatchAxis.AbsMove (MoveInfo, Config.BatchAxisP1, Config.BatchAxis_P1Speed);
break;
case LineMoveStep.FR_06_BatchAxisToP1:
LogInfo(MoveInfo.MoveType + ":FR_07_MoveCylinder_Up:上料横移机构上升SOL");
MoveInfo.NextMoveStep(LineMoveStep.FR_07_MoveCylinder_Up);
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
break;
case LineMoveStep.FR_07_MoveCylinder_Up:
LogInfo(MoveInfo.MoveType + ":FR_08_MoveCylinder_Slack:上料气缸放松SOL");
MoveInfo.NextMoveStep(LineMoveStep.FR_08_MoveCylinder_Slack);
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Tighten, IO_Type.SL_MoveCylinder_Slack);
break;
case LineMoveStep.FR_08_MoveCylinder_Slack:
LogInfo(MoveInfo.MoveType + ":FR_09_MoveCylinder_Take: 上料横移气缸取料端SOL");
MoveInfo.NextMoveStep(LineMoveStep.FR_09_MoveCylinder_Take);
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Give, IO_Type.SL_MoveCylinder_Take);
break;
case LineMoveStep.FR_09_MoveCylinder_Take:
LogInfo(MoveInfo.MoveType + ":FR_10_OutTopCylinder_Down: 出口顶升下降SOL");
MoveInfo.NextMoveStep(LineMoveStep.FR_10_OutTopCylinder_Down);
CylinderMove(MoveInfo, IO_Type.SL_OutTopCylinder_Up, IO_Type.SL_OutTopCylinder_Down);
break;
case LineMoveStep.FR_10_OutTopCylinder_Down:
LogInfo("重置完成!");
runStatus = LineRunStatus.Runing;
MoveInfo.EndMove();
break;
default: break;
}
}
}
internal override void StopMove()
{
MoveInfo.EndMove();
SecondMoveInfo.EndMove();
BatchAxisStopCheck();
BatchAxis.SuddenStop();
UpdownAxis.SuddenStop();
if (Config.SidesWayNum <= 0)
{
IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.FL_StopCylinder_Down2, IO_VALUE.LOW);
IOMove(IO_Type.FL_TopCylinder_Down, IO_VALUE.LOW);
IOMove(IO_Type.FL_TopCylinder_Up, IO_VALUE.LOW);
}
IOMove(IO_Type.SL_Line_Run, IO_VALUE.LOW);
IOMove(IO_Type.SL_LocationSideWay_Run, IO_VALUE.LOW);
IOMove(IO_Type.SL_OutLine_Run, IO_VALUE.LOW);
IOMove(IO_Type.SL_Entry_StopDown, IO_VALUE.LOW);
IOMove(IO_Type.SL_Buffer_StopDown, IO_VALUE.LOW);
IOMove(IO_Type.SL_Out_StopDown, IO_VALUE.LOW);
}
/// <summary>
/// 停止运行
/// </summary>
public override void StopRun()
{
if (mainTimer != null)
{
mainTimer.Enabled = false;
}
StopMove();
runStatus = LineRunStatus.Wait;
}
public override void TimerProcess()
{
if (IOValue(IO_Type.SL_SuddenStop_BTN).Equals(IO_VALUE.LOW))
{
WarnMsg = Name + "收到急停信号";
LogUtil.error(WarnMsg);
Alarm(LineAlarmType.SuddenStop);
return;
}
if (IOValue(IO_Type.SL_Reset_BTN).Equals(IO_VALUE.HIGH))
{
if (alarmType.Equals(LineAlarmType.None))
{
if (MoveInfo.MoveType.Equals(LineMoveType.None))
{
LogUtil.error(Name + "收到复位信号,当前无报警,不需要复位");
}
else
{
LogUtil.error(Name + "收到复位信号,当前无报警,正在" + MoveInfo.MoveType + "处理中,不需要复位");
}
}
else
{
LogUtil.info(Name + "收到复位信号,开始复位");
Reset();
}
return;
}
BusyMoveProcess();
//判断流水线打开了才可以运行
if (MoveInfo.MoveType.Equals(LineMoveType.None))
{
if (LineManager.Line.CanProcessLine() && SecondMoveInfo.MoveType.Equals(LineMoveType.None))
{
StartCheckFixture();
}
if (MoveInfo.MoveType.Equals(LineMoveType.None) && Config.IsCanOut.Equals(false))
{
StartInStoreP();
}
}
IOTimeOutProcess();
}
/// <summary>
/// 下降所有阻挡气缸
/// </summary>
internal override void OpenStopCylinder()
{
if (Config.SidesWayNum <= 0)
{
LogInfo("下降阻挡气缸,下降顶升气缸 ");
IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.HIGH);
IOMove(IO_Type.FL_StopCylinder_Down2, IO_VALUE.HIGH);
//顶升气缸下降
CylinderMove(null, IO_Type.FL_TopCylinder_Up, IO_Type.FL_TopCylinder_Down);
}
}
internal override void CloseCylinderStop()
{
if (Config.SidesWayNum <= 0)
{
LogInfo("上升阻挡气缸,关闭 顶升气缸IO");
IOMove(IO_Type.FL_StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.FL_StopCylinder_Down2, IO_VALUE.LOW);
//顶升气缸下降
IOMove(IO_Type.FL_TopCylinder_Up, IO_VALUE.LOW);
IOMove(IO_Type.FL_TopCylinder_Down, IO_VALUE.LOW);
}
}
/// <summary>
/// 升降盘定位气缸前进
/// </summary>
public void TrayLCylinderBefore(LineMoveInfo moveinfo = null)
{
IOMove(IO_Type.SL_TrayLocation_After, IO_VALUE.LOW);
IOMove(IO_Type.SL_TrayLocation_Before, IO_VALUE.HIGH);
if (moveinfo != null)
{
moveinfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_TrayLocation1_After, IO_VALUE.LOW));
moveinfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_TrayLocation1_Before, IO_VALUE.HIGH));
moveinfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_TrayLocation2_After, IO_VALUE.LOW));
moveinfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_TrayLocation2_Before, IO_VALUE.HIGH));
}
}
/// <summary>
/// 升降盘定位气缸后退
/// </summary>
public void TrayLCylinderAfter(LineMoveInfo moveinfo = null)
{
IOMove(IO_Type.SL_TrayLocation_After, IO_VALUE.HIGH);
IOMove(IO_Type.SL_TrayLocation_Before, IO_VALUE.LOW);
if (moveinfo != null)
{
moveinfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_TrayLocation1_After, IO_VALUE.HIGH));
moveinfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_TrayLocation1_Before, IO_VALUE.LOW));
moveinfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_TrayLocation2_After, IO_VALUE.HIGH));
moveinfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_TrayLocation2_Before, IO_VALUE.LOW));
}
}
#region 提升轴匀速上升处理
private System.Timers.Timer axisCheckTimer = null;
private string TargetIoType = IO_Type.SL_AxisLocationCheck;
private IO_VALUE TargetIoValue = IO_VALUE.HIGH;
private bool BatchAxisStartCheck(string targetIo = "", IO_VALUE value = IO_VALUE.HIGH)
{
if (String.IsNullOrEmpty(targetIo))
{
targetIo = IO_Type.SL_AxisLocationCheck;
}
if (axisCheckTimer == null)
{
axisCheckTimer = new System.Timers.Timer();
axisCheckTimer.AutoReset = true;
axisCheckTimer.Interval += 30;
axisCheckTimer.Elapsed += CheckTimer_Elapsed;
axisCheckTimer.Enabled = false;
}
TargetIoValue = value;
TargetIoType = targetIo;
axisCheckTimer.Start();
return true;
}
private bool BatchAxisStopCheck()
{
if (!(axisCheckTimer == null))
{
axisCheckTimer.Stop();
}
return true;
}
private bool IsInProcess = false;
private void CheckTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if (IsInProcess) { return; }
IsInProcess = true;
if (IOValue(TargetIoType).Equals(TargetIoValue))
{
LogUtil.info(Name+ "上料轴,检测到 " + TargetIoType + "=" + TargetIoValue + ",可以停止运动");
BatchAxis.SuddenStop();
BatchAxisStopCheck();
}
IsInProcess = false;
}
#endregion
}
}