BoxBean_Partial.cs
11.1 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
using Asa;
using DeviceLib;
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
{
partial class BoxBean
{
public ConcurrentQueue<InOutParam> waitOutStoreList = new ConcurrentQueue<InOutParam>();
#region 出入库结果验证
private void CheckWait()
{
List<WaitResultInfo> list = MoveInfo.WaitList;
//当等待超过一分钟时,需要打印提示
TimeSpan span = DateTime.Now - MoveInfo.LastSetpTime;
string NotOkMsg = "";
if (list.Count <= 0)
{
MoveInfo.EndStepWait();
return;
}
bool isOk = true;
if (MoveInfo.OneWaitCanEndStep)
{
isOk = false;
}
foreach (WaitResultInfo wait in list)
{
if (wait.IsEnd)
{
continue;
}
NotOkMsg = wait.ToStr();
if (wait.WaitType.Equals(WaitEnum.W001_AxisMove))
{
string msg = "";
if (wait.IsHomeMove)
{
wait.IsEnd = AxisBean.HomeMoveIsEnd(MoveInfo, wait.AxisInfo, out msg);
}
else
{
wait.IsEnd = AxisBean.ACAxisMoveIsEnd(MoveInfo, wait.AxisInfo, wait.TargetPosition, wait.TargetSpeed, out msg);
}
if (!msg.Equals(""))
{
isOk = false;
WarnMsg = msg;
Alarm(AlarmType.AxisMoveError, GetAlarmCodeByAxis(wait.AxisInfo).ToString(), WarnMsg, MoveInfo.MoveType);
break;
}
}
else if (wait.WaitType.Equals(WaitEnum.W002_IOValue))
{
wait.IsEnd = IOValue(wait.IoType).Equals(wait.IoValue);
int timeOutMs = StoreManager.Config.IOSingle_TimerOut;
if (MoveInfo.MoveStep.Equals(StoreMoveStep.BS_08_WaitLineIn) ||
MoveInfo.MoveStep.Equals(StoreMoveStep.BI_04_WaitTakeSingle))
{
timeOutMs = 30000;
}
else if (MoveInfo.MoveStep.Equals(StoreMoveStep.BI_03_LineRun))
{
timeOutMs = 40000;
}
if ((!wait.IsEnd) && span.TotalMilliseconds > timeOutMs && NoAlarm())
{
ConfigIO io = Config.getWaitIO(wait.IoType);
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时";
Alarm(AlarmType.IoSingleTimeOut, io.ElectricalDefinition, WarnMsg, MoveInfo.MoveType);
LogUtil.error(Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "] 等待(" + io.DisplayStr + "=" + wait.IoValue + ") 超时", logType + 14);
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
else if (wait.WaitType.Equals(WaitEnum.W003_Time))
{
wait.IsEnd = (span.TotalMilliseconds >= wait.TimeMSeconds);
}
if (wait.IsEnd)
{
if (MoveInfo.OneWaitCanEndStep)
{
isOk = true;
break;
}
}
else
{
if (!MoveInfo.OneWaitCanEndStep)
{
isOk = false;
break;
}
}
}
if (isOk)
{
MoveInfo.EndStepWait();
}
else if (span.TotalSeconds > MoveInfo.TimeOutSeconds)
{
WarnMsg = Name + "[" + MoveInfo.MoveType + "][" + MoveInfo.MoveStep + "]等待" + NotOkMsg
+ "超时[" + Math.Round(span.TotalSeconds, 1) + "]秒";
int second = 10;
second = (int)(MoveInfo.TimeOutSeconds / span.TotalSeconds) * 10;
if (second > 120)
{
second = 120;
}
else if (second < 10)
{
second = 10;
}
LogUtil.error(WarnMsg, logType + 100, second);
Alarm(AlarmType.IoSingleTimeOut, "", WarnMsg, MoveInfo.MoveType);
}
}
private bool AcInPosition(ConfigMoveAxis axis,int p)
{
return ACServerManager.isInPosition(axis.DeviceName, axis.GetAxisValue(), p, axis.CanErrorCountMax);
}
private static DateTime lastComRHomeTime = DateTime.Now;
private void InOutBackToP1(int InOut_P1)
{
//判断是否在P1,如果是,不需要运行
if (AcInPosition(Config.InOut_Axis, InOut_P1))
{
LogUtil.debug(Name + "进出轴当前已经在P1,不需要再回P1");
}
else
{
InoutAxis.AbsMove(MoveInfo, InOut_P1, Config.InOutAxis_P1_Speed);
}
}
#endregion
#region 入库
private DateTime startInStoreTime = DateTime.Now;
public override void StartInStoreMove(InOutParam param)
{
startInStoreTime = DateTime.Now;
string posId = param != null ? param.PosID : "";
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(MoveType.None)))
{
LogUtil.error(Name + " 启动出库出错,忙碌或报警中 ,storeStatus=" + storeRunStatus + ",MoveType=" + MoveInfo.MoveType + ",isInSuddenDown=" + isInSuddenDown + ",isNoAirCheck" + isNoAirCheck);
return;
}
if (!StoreManager.LoadInoutParam(param, true, this))
{
LogUtil.error(Name + " 启动入库【" + param.ToStr() + "】出错,找不到库位信息");
return;
}
LogInfo(" 启动入库【" + param.ToStr() + "】,压紧点P2【" + param.MoveP.ComPress_P2 + "】压紧前点P3【" + param.MoveP.ComPress_P3 + "】");
storeRunStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.InStoreExecute;
MoveInfo.NewMove(MoveType.InStore, param);
//新的料架库位
MoveInfo.NextMoveStep(StoreMoveStep.BI_11_InoutToP1);
MoveInfo.SingleInstore = true;
InOutStoreLog("料架取料:" + MoveInfo.SLog + " 叉子后退到待机点P1, 重置盘信息");
InoutAxis.AbsMove(MoveInfo, Config.InOutAxis_P1, Config.InOutAxis_P1_Speed);
}
protected override void InStoreProcess()
{
LineMoveP moveP = MoveInfo.MoveParam.MoveP;
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
else
{
LogInfo(" 入库,MoveInfo.MoveStep=" + MoveInfo.MoveStep + ",没有对应的处理!");
}
}
#endregion
#region 出库
private DateTime startOutStoreTime = DateTime.Now;
public bool IsIgnoreComSig = false; //忽略料叉压紧信号
private void StartExecuctOut(InOutParam param)
{
bool result = StartOutStoreMove(param);
if (!result)
{
LogInfo(" 执行出库【" + param.ToStr() + "】失败,加入等待队列");
waitOutStoreList.Enqueue(param);
}
}
public override bool StartOutStoreMove(InOutParam param)
{
startOutStoreTime = DateTime.Now;
string posId = param != null ? param.PosID : "";
if (isInSuddenDown || isNoAirCheck ||
(!storeRunStatus.Equals(StoreRunStatus.Runing))
|| (!MoveInfo.MoveType.Equals(MoveType.None)))
{
LogUtil.error(Name + " 启动出库【" + param.ToStr() + "】失败,忙碌或报警中 ,storeStatus:" + storeRunStatus + ",MoveType:" + MoveInfo.MoveType + ",isInSuddenDown:" + isInSuddenDown + ",isNoAirCheck:" + isNoAirCheck);
return false;
}
if (!StoreManager.LoadInoutParam(param, false, this))
{
LogUtil.error(Name + " 启动出库【" + param.ToStr() + "】出错,找不到库位信息");
return false;
}
storeStatus = StoreStatus.OutStoreExecute;
storeRunStatus = StoreRunStatus.Busy;
MoveInfo.NewMove(MoveType.OutStore, param);
LogInfo("启动出库【" + param.ToStr() + "】 ");
//出库前shelfPosID需要固定,出库时根据rfid判断是否需要出入料架
MoveInfo.NextMoveStep(StoreMoveStep.SO_01_InoutBack);
InOutStoreLog("出库 " + MoveInfo.SLog + ":进出轴到P1 开始");
InOutBackToP1(MoveInfo.MoveParam.MoveP.InOut_P1);
return true;
}
private void SO_03_ToBagPosition()
{
MoveInfo.NextMoveStep(StoreMoveStep.SO_03_ToPosition);
InOutStoreLog("出库 " + MoveInfo.SLog + ":走到库位,压紧轴至P3(压紧前点) ,旋转轴至P2(库位点),升降轴至P5(库位出库前点) ,顶升上升");
ComAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.ComPress_P3, Config.CompAxis_P3_Speed);
MiddleAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.Middle_P2, Config.MiddleAxis_P2_Speed);
UpdownAxis.AbsMove(MoveInfo, MoveInfo.MoveParam.MoveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
CylinderMove(MoveInfo, IO_Type.TopCylinder_Down, IO_Type.TopCylinder_Up);
}
protected override void OutStoreProcess()
{
LineMoveP moveP = MoveInfo.MoveParam.MoveP;
if (MoveInfo.IsInWait)
{
CheckWait();
}
if (MoveInfo.IsInWait)
{
return;
}
else if (MoveInfo.MoveStep <= StoreMoveStep.SO_01_InoutBack)
{
}
else if (MoveInfo.MoveStep >= StoreMoveStep.BS_01_TopDown)
{
}
else
{
LogUtil.error(Name + " 出库处理,MoveInfo.MoveStep=" + MoveInfo.MoveStep + ",没有对应的处理!");
}
}
#endregion
}
}