MainMachine _LeftProcess.cs
10.5 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
using CodeLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
bool LeftShelfNoTray = false;
int LeftCount = 0;
void LeftProcess()
{
if (CheckWait(LeftMoveInfo))
return;
switch (LeftMoveInfo.MoveStep)
{
case MoveStep.L01:
LeftCount = 0;
LeftMoveInfo.NextMoveStep(MoveStep.L03);
LeftBatchAxisToP2(true);
LeftMoveInfo.log($"批量轴上升到P2位置,第一次提升,LeftStartMovePosition={LeftStartMovePosition}");
break;
case MoveStep.L02:
LeftMoveInfo.NextMoveStep(MoveStep.L03);
LeftBatchAxisToP2(false);
LeftMoveInfo.log($"批量轴上升到P2位置,二次提升,LeftStartMovePosition={LeftStartMovePosition}");
break;
case MoveStep.L03:
if (IOValue(IO_Type.LeftOverHead_Check).Equals(IO_VALUE.HIGH))
{
LeftMoveInfo.NextMoveStep(MoveStep.L02);
Left_Batch_Axis.AbsMove(LeftMoveInfo, LeftStartMovePosition, Config.Left_Batch_P2_speed);
LeftMoveInfo.log($"批量轴上升过头,下降到:LeftStartMovePosition={LeftStartMovePosition}");
}
else {
LeftMoveInfo.NextMoveStep(MoveStep.L04);
}
break;
case MoveStep.L04:
var currpos = Left_Batch_Axis.GetAclPosition()-Config.Left_Batch_ChangeValue*80;
if (currpos < Config.Left_Batch_P1)
{
LeftMoveInfo.NextMoveStep(MoveStep.L40_ShelfFull);
LeftMoveInfo.log($"批量轴已下降到底,料串已满,Left_Batch_P1={Config.Left_Batch_P1},needpos={currpos}");
}
else
{
LeftMoveInfo.NextMoveStep(MoveStep.L10_WaitReelPut);
Left_Batch_Axis.AbsMove(LeftMoveInfo, currpos, Config.Left_Batch_P1_speed);
LeftMoveInfo.log($"批量轴已下降一张料盘位置,等待料盘放入,needpos={currpos}");
}
break;
case MoveStep.L10_WaitReelPut:
break;
case MoveStep.L11_ReelPutted:
LeftCount++;
LeftMoveInfo.NextMoveStep(MoveStep.L12);
LeftBatchAxisToP2(false);
LeftMoveInfo.log($"料盘已放入,批量轴上升,LeftStartMovePosition={LeftStartMovePosition}");
break;
case MoveStep.L12:
if (IOValue(IO_Type.LeftOverHead_Check).Equals(IO_VALUE.HIGH))
{
LeftMoveInfo.NextMoveStep(MoveStep.L11_ReelPutted);
Left_Batch_Axis.AbsMove(LeftMoveInfo, LeftStartMovePosition, Config.Left_Batch_P2_speed);
LeftMoveInfo.log($"批量轴上升过头,下降到:LeftStartMovePosition={LeftStartMovePosition}");
}
else
{
LabelMoveInfo.MoveParam = LeftMoveInfo.MoveParam.clone();
LeftMoveInfo.NextMoveStep(MoveStep.L20_WaitLabel);
LeftMoveInfo.log($"批量轴完成上升,等待贴标");
}
break;
case MoveStep.L20_WaitLabel:
break;
case MoveStep.L30_LabelFinish:
LeftMoveInfo.NextMoveStep(MoveStep.L04);
LeftMoveInfo.log($"贴标完成,准备下一盘料");
break;
case MoveStep.L40_ShelfFull:
LeftMoveInfo.NextMoveStep(MoveStep.LEND);
Left_Batch_Axis.AbsMove(LeftMoveInfo, Config.Left_Batch_P1, Config.Left_Batch_P1_speed);
LeftMoveInfo.log($"料串已满,批量轴下降到P1位置");
break;
case MoveStep.LEND:
LeftMoveInfo.EndMove();
LeftMoveInfo.log($"结束运动");
break;
//}
//料窜出料流程
//switch (LeftMoveInfo.MoveStep)
//{
case MoveStep.L50_OutShelf:
LeftMoveInfo.NextMoveStep(MoveStep.L51);
Left_Batch_Axis.AbsMove(LeftMoveInfo, Config.Left_Batch_P1, Config.Left_Batch_P1_speed);
LeftMoveInfo.log($"批量轴下降到P1位置");
break;
case MoveStep.L51:
LeftMoveInfo.NextMoveStep(MoveStep.L52);
CylinderMove(null, IO_Type.LeftStopUP, IO_Type.LeftStopDown);
LeftMoveInfo.log($"阻挡下降");
break;
case MoveStep.L52:
LeftMoveInfo.NextMoveStep(MoveStep.L53);
IOMove(IO_Type.LeftMoto_Reverse, IO_VALUE.HIGH);
IOMove(IO_Type.LeftMoto_Run, IO_VALUE.HIGH, false);
MiddleMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftEnd_Check, IO_VALUE.LOW));
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
LeftMoveInfo.log($"电滚筒向外滚动");
break;
case MoveStep.L53:
LeftMoveInfo.NextMoveStep(MoveStep.L54);
MiddleMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftFornt_Check, IO_VALUE.LOW));
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(3000));
LeftMoveInfo.OneWaitCanEndStep = true;
LeftMoveInfo.log($"等待前置检测拉低");
break;
case MoveStep.L54:
LeftMoveInfo.NextMoveStep(MoveStep.REND);
IOMove(IO_Type.LeftMoto_Run, IO_VALUE.LOW, false, 500);
LeftMoveInfo.log($"电滚停止");
break;
//}
//料窜入料流程
//switch (LeftMoveInfo.MoveStep)
//{
case MoveStep.L60_InShelf:
LeftMoveInfo.NextMoveStep(MoveStep.L61);
Left_Batch_Axis.AbsMove(LeftMoveInfo, Config.Left_Batch_P1, Config.Left_Batch_P1_speed);
LeftMoveInfo.log($"批量轴下降到P1位置");
break;
case MoveStep.L61:
LeftMoveInfo.NextMoveStep(MoveStep.L62);
IOMove(IO_Type.LeftStopUP, IO_VALUE.LOW);
LeftMoveInfo.log($"阻挡下降");
break;
case MoveStep.L62:
LeftMoveInfo.NextMoveStep(MoveStep.L63);
IOMove(IO_Type.LeftMoto_Reverse, IO_VALUE.LOW);
IOMove(IO_Type.LeftMoto_Run, IO_VALUE.HIGH, false);
MiddleMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.LeftEnd_Check, IO_VALUE.HIGH));
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(6000));
LeftMoveInfo.OneWaitCanEndStep = true;
LeftMoveInfo.log($"等待料窜到位");
break;
case MoveStep.L63:
LeftMoveInfo.NextMoveStep(MoveStep.L64);
IOMove(IO_Type.LeftMoto_Run, IO_VALUE.LOW, false, 500);
IOMove(IO_Type.LeftStopUP, IO_VALUE.HIGH);
LeftMoveInfo.log($"电滚筒停止,阻挡上升");
break;
case MoveStep.L64:
if (IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.HIGH))
{
LeftMoveInfo.NewMove(MoveStep.L01);
LeftMoveInfo.log($"料窜进入开始上料");
}
else
{
LeftMoveInfo.NextMoveStep(MoveStep.LEND);
LeftMoveInfo.log($"料窜进入失败");
}
break;
default:
LeftMoveInfo.log($"未找到对应步骤:{LeftMoveInfo.MoveStep}");
break;
}
}
string LeftState()
{
string state = "";
if (IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.HIGH))
{
state += $"有料窜,已提取{RightCount}张料盘";
if (LeftShelfNoTray)
state += ",料串已清空";
else
state += ".";
state += "当前ReelID:" + LeftMoveInfo.MoveParam.WareCode;
}
else
{
return "无料窜";
}
return state;
}
int LeftStartMovePosition = 0;
void LeftBatchAxisToP2(bool isFirstMove = true)
{
int targetP2 = Config.Left_Batch_P2;
int targetSpeed = Config.Left_Batch_P2_speed;
if (!isFirstMove)
{
int currPosition = Left_Batch_Axis.GetAclPosition();
if (currPosition != -1)
{
//targetP2 = currPosition + Config.Left_Batch_ChangeValue * 80;
if (targetP2 > Config.Left_Batch_P2)
{
targetP2 = Config.Left_Batch_P2;
}
LeftMoveInfo.log("BatchAxisToP2 目标P2: " + targetP2 + "(" + currPosition + ")");
}
//targetSpeed = Config.BatchAxis_P3Speed / 2;
}
LeftMoveInfo.TimeOutSeconds = 200;
LeftMoveInfo.CanWhileCount = 0;
// 需要增加定时器,获取验证信号并停止伺服
LeftStartMovePosition = Left_Batch_Axis.GetAclPosition();
LeftMoveInfo.WaitList.Add(WaitResultInfo.WaitBatchAxisMove(Config.Left_Batch_Axis, targetP2, targetSpeed));
Config.Left_Batch_Axis.TargetPosition = targetP2;
Left_Batch_Axis.AbsMove(null, targetP2, targetSpeed);
//开始检测信号
Left_Batch_Axis.BatchAxisStartCheck(IO_Type.LeftTop_Check, IO_VALUE.LOW);
}
}
}