MainMachine_OutCar.cs
13.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
using CodeLibrary;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
bool OutHasCar { get => (IOValue(IO_Type.Unloading_Car_Check).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.Unloading_Car1315_Check).Equals(IO_VALUE.HIGH)); }
public CarTypeE OutCarType = CarTypeE.None;
public int OutCurrentStringNum = 0;
bool outnewreel = false;
/// <summary>
/// 指示入料车是否已经处理完毕
/// </summary>
bool incarProcessFinish = false;
void OutCarProcess()
{
if (CheckWait(OutCarMoveInfo))
return;
switch (OutCarMoveInfo.MoveStep)
{
case MoveStep.Wait:
OutCarType = CarTypeE.None;
var hascar = OutHasCar;
if (hascar)
Unloading_NOCar_Led.LedState = LedState.blink;
else
Unloading_NOCar_Led.LedState = LedState.off;
if (hascar && IOValue(IO_Type.Unloading_CarLock_Btn).Equals(IO_VALUE.HIGH))
{
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_01);
OutCarMoveInfo.log("检测到小车到位");
}
else if (hascar && IOValue(IO_Type.Unloading_Car_Location_Up).Equals(IO_VALUE.HIGH))
{
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_02);
OutCarMoveInfo.log("小车已经到位");
}
break;
case MoveStep.OutCar_01:
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_02);
OutCarMoveInfo.log($"提升定位气缸");
CylinderMove(OutCarMoveInfo, IO_Type.Unloading_Car_Location_Down, IO_Type.Unloading_Car_Location_Up, IO_VALUE.HIGH);
break;
case MoveStep.OutCar_02:
var car7 = IOValue(IO_Type.Unloading_Car_Check).Equals(IO_VALUE.HIGH);
var car13 = IOValue(IO_Type.Unloading_Car1315_Check).Equals(IO_VALUE.HIGH);
if (car7 || car13)
{
if (car7)
OutCarType = CarTypeE.Car7;
else
OutCarType = CarTypeE.Car13;
if (InCarType != CarTypeE.None && InCarType != OutCarType)
{
OutCarMoveInfo.NextMoveStep(MoveStep.OutCarOut_01);
OutCarMoveInfo.log("检测到出料车与入料车尺寸不符");
}
else
{
OutCarMoveInfo.log($"检测到料车尺寸:{OutCarType}");
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_03);
Unloading_NOCar_Led.LedState = LedState.on;
}
}
else {
OutCarMoveInfo.log($"小车丢失,重新检测");
CylinderMove(OutCarMoveInfo, IO_Type.Unloading_Car_Location_Down, IO_Type.Unloading_Car_Location_Up, IO_VALUE.LOW);
OutCarMoveInfo.NextMoveStep(MoveStep.Wait);
}
break;
case MoveStep.OutCar_03:
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_04);
outnewreel = true;
incarProcessFinish = true;
OutCarMoveInfo.log($"新料串");
break;
case MoveStep.OutCar_04:
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_05);
var lowlist = OutGetLowReelCheckIOList();
if (lowlist.Length > 0)
{
OutCarMoveInfo.log($"批量轴高速上升到顶部检测点");
BatchAxisToP2(OutCarMoveInfo, Unloading_Batch_Axis, lowlist, IO_VALUE.HIGH, Config.Unloading_Batch_Axis_P2, Config.Unloading_Batch_Axis_P1_speed);
}
else {
OutCarMoveInfo.log($"批量轴所有监测点都已Low");
}
break;
case MoveStep.OutCar_05:
lowlist = OutGetLowReelCheckIOList();
if (Unloading_Batch_Axis.IsInPosition(Config.Unloading_Batch_Axis_P2)) {
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_06);
OutCarMoveInfo.log($"批量轴已到顶,可放料位置有:{string.Join(",", lowlist)}");
}
else if (lowlist.Count() > 0)
{
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_04);
OutCarMoveInfo.log($"lowlist={string.Join(",", lowlist)}");
}
else {
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_06);
OutCarMoveInfo.log($"批量轴已上升到最后一盘点亮位置");
}
break;
case MoveStep.OutCar_06:
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_07);
OutCarMoveInfo.log($"批量轴高速下降到检测点灭");
BatchAxisToP2(OutCarMoveInfo, Unloading_Batch_Axis, OutGetReelCheckIOList(), IO_VALUE.LOW, Config.Unloading_Batch_Axis_P1, Config.Unloading_Batch_Axis_P1_speed);
break;
case MoveStep.OutCar_07:
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_08);
OutCurrentStringNum = GetBottomStringNum(OutGetLowReelCheckIOList());
OutCarMoveInfo.log($"第一次检测到最低料串为:{OutCurrentStringNum}");
OutCarMoveInfo.log($"批量轴下降1mm再次检测");
Unloading_Batch_Axis.AbsMove(OutCarMoveInfo,Unloading_Batch_Axis.GetAclPosition()-Config.Unloading_UpDown_Axis_MMtoPOS, Config.Unloading_UpDown_Axis_P1_speed);
break;
case MoveStep.OutCar_08:
var cur = GetBottomStringNum(OutGetLowReelCheckIOList());
OutCarMoveInfo.log($"当前low={cur},上次low={OutCurrentStringNum}");
if (cur != OutCurrentStringNum)
{
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_06);
}
else {
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_09);
}
break;
case MoveStep.OutCar_09:
if (Unloading_Batch_Axis.IsInPosition(Config.Unloading_Batch_Axis_P1))
{
OutCarMoveInfo.NextMoveStep(MoveStep.OutCarOut_01);
OutCarMoveInfo.log($"出料料串已满");
}
else
{
OutCurrentStringNum = GetBottomStringNum(OutGetLowReelCheckIOList());
OutCarMoveInfo.log($"确认放料料串为:{OutCurrentStringNum}");
if (OutCurrentStringNum > 0)
{
OutCarMoveInfo.NextMoveStep(MoveStep.OutCarReadyPut);
}
else {
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_06);
}
}
break;
case MoveStep.OutCarReadyPut:
Msg.add("出口料串放料准备就绪", MsgLevel.info);
if (incarProcessFinish && InMoveInfo.MoveStep == MoveStep.Wait && CountMoveInfo.MoveStep == MoveStep.Wait && OutMoveInfo.MoveStep == MoveStep.Wait) {
OutCarMoveInfo.NextMoveStep(MoveStep.OutCarOut_01);
OutCarMoveInfo.log($"入料车已处理完毕");
}
break;
case MoveStep.OutCarReelPut:
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_04);
OutCarMoveInfo.log($"料盘放入, 等待贴标");
break;
case MoveStep.WaitForLabelling:
Msg.add("等待贴标", MsgLevel.info);
break;
case MoveStep.LabelFinish:
OutCarMoveInfo.log($"贴标完毕");
OutCarMoveInfo.NextMoveStep(MoveStep.OutCar_04);
break;
case MoveStep.OutCarOut_01:
OutCarMoveInfo.NextMoveStep(MoveStep.OutCarOut_02);
OutCarMoveInfo.log($"料串下降到P1点");
Unloading_Batch_Axis.AbsMove(OutCarMoveInfo, Config.Unloading_Batch_Axis_P1, Config.Unloading_Batch_Axis_P1_speed);
OutCarMoveInfo.WaitList.Add(WaitResultInfo.WaitMsg("料串正在下降", MsgLevel.warning));
break;
case MoveStep.OutCarOut_02:
OutCarMoveInfo.NextMoveStep(MoveStep.OutCarOut_Released);
OutCarMoveInfo.log($"顶升下降");
CylinderMove(OutCarMoveInfo, IO_Type.Unloading_Car_Location_Down, IO_Type.Unloading_Car_Location_Up, IO_VALUE.LOW);
break;
case MoveStep.OutCarOut_Released:
OutCarMoveInfo.log($"料串已回到待机点");
OutCarMoveInfo.NewMove(MoveStep.Wait);
break;
default:
OutCarMoveInfo.log($"未找到对应步骤:{OutCarMoveInfo.MoveStep}");
break;
}
}
string OutCarProcessState() {
string state = "";
if (OutCarType == CarTypeE.Car13)
state = "13/15寸盘小车";
else if (OutCarType == CarTypeE.Car7)
{
state = "7寸盘小车";
}
else if (InHasCar)
state = "检测到小车,尚未锁定";
if (OutCarMoveInfo.MoveStep == MoveStep.Wait)
{
return "空闲中";
}
else if (OutCarMoveInfo.MoveStep < MoveStep.OutCarReadyPut)
{
return state + "," + "准备中";
}
else if (OutCarMoveInfo.MoveStep == MoveStep.OutCarReadyPut)
{
return state + "," + "允许放料";
}
else if (OutCarMoveInfo.MoveStep >= MoveStep.OutCarOut_01)
{
return state + "," + "释放中";
}
else if (OutCarMoveInfo.MoveStep > MoveStep.OutCar_06)
{
return state;
}
return state;
}
string[] OutGetLowReelCheckIOList(int currentnum = 0) {
if (currentnum > 0)
return new string[] { "Unloading_Batch_ReelCheck_T" + currentnum.ToString() };
List<string> iolist = new List<string>();
if (OutCarType == CarTypeE.Car7)
{
if (IOValue(IO_Type.Unloading_Batch_ReelCheck_T1).Equals(IO_VALUE.LOW))
iolist.Add(IO_Type.Unloading_Batch_ReelCheck_T1);
if (IOValue(IO_Type.Unloading_Batch_ReelCheck_T2).Equals(IO_VALUE.LOW))
iolist.Add(IO_Type.Unloading_Batch_ReelCheck_T2);
if (IOValue(IO_Type.Unloading_Batch_ReelCheck_T4).Equals(IO_VALUE.LOW))
iolist.Add(IO_Type.Unloading_Batch_ReelCheck_T4);
if (IOValue(IO_Type.Unloading_Batch_ReelCheck_T5).Equals(IO_VALUE.LOW))
iolist.Add(IO_Type.Unloading_Batch_ReelCheck_T5);
return iolist.ToArray();
}
else
{
if (IOValue(IO_Type.Unloading_Batch_ReelCheck_T3).Equals(IO_VALUE.LOW))
iolist.Add(IO_Type.Unloading_Batch_ReelCheck_T3);
return iolist.ToArray();
}
}
string[] OutGetReelCheckIOList(int currentnum = 0)
{
if (currentnum > 0)
return new string[] { "Unloading_Batch_ReelCheck_T" + currentnum.ToString() };
if (OutCarType == CarTypeE.Car7)
{
return new string[] { IO_Type.Unloading_Batch_ReelCheck_T1, IO_Type.Unloading_Batch_ReelCheck_T2, IO_Type.Unloading_Batch_ReelCheck_T4, IO_Type.Unloading_Batch_ReelCheck_T5 };
}
else
{
return new string[] { IO_Type.Unloading_Batch_ReelCheck_T3 };
}
}
int GetBottomStringNum(string[] checkiolist)
{
foreach (var io in checkiolist)
{
if (IOValue(io).Equals(IO_VALUE.LOW))
{
return int.Parse(io.Substring(io.Length - 1));
}
}
return 0;
}
}
}