ProvidingEquip.cs
7.6 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
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 ProvidingEquip : EquipBase
{
public ProvidingEquip_Config Config;
public ProvidingEquip(string cid, ProvidingEquip_Config config)
{
baseConfig = config;
this.DeviceID = config.Id;
this.Config = config;
IsDebug = config.IsDebug.Equals(1);
baseConfig = config;
Name = (" " + "_出料_" + DeviceID % 100 + " ").ToUpper();
Init();
UseAxis = false;
MoveInfo = new LineMoveInfo(DeviceID, "出料-" + DeviceID + "-MoveInfo");
SecondMoveInfo = new LineMoveInfo(DeviceID, "出料-" + DeviceID + "-SecondMoveInfo");
}
public override bool StartRun(bool isDebug=false)
{
preTrayNum = 0;
currMoveTrayNum = 0;
mainTimer.Enabled = false;
MoveInfo.EndMove();
SecondMoveInfo.EndMove();
lineStatus = LineStatus.StoreOnline;
//TODO 调试时暂时注释
runStatus = LineRunStatus.HomeMoving;
bool result = ReturnHome();
if (result&&isDebug)
{
mainTimer.Enabled = true;
}
return result;
}
public override void StopRun()
{
if (mainTimer != null)
{
mainTimer.Enabled = false;
}
StopMove();
//停止运行时,把所有IO 置零
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
IOMove(IO_Type.TopCylinder_UP, IO_VALUE.LOW);
IOMove(IO_Type.TopCylinder_Down, IO_VALUE.LOW);
IOMove(IO_Type.BeforeAfterCylinder_Before, IO_VALUE.LOW);
IOMove(IO_Type.BeforeAfterCylinder_After, IO_VALUE.LOW);
IOMove(IO_Type.UpDownCylinder_Up, IO_VALUE.LOW);
IOMove(IO_Type.UpDownCylinder_Down, IO_VALUE.LOW);
IOMove(IO_Type.ClampCylinder_Slack, IO_VALUE.LOW);
IOMove(IO_Type.ClampCylinder_Tighten, IO_VALUE.LOW);
runStatus = LineRunStatus.Wait;
}
public override void TimerProcess()
{
BusyMoveProcess();
//判断流水线打开了才可以运行
if (SecondMoveInfo.MoveType.Equals(LineMoveType.None))
{
LineBean lineBean = LineManager.Line;
if (LineManager.Line.CanProcessLine())
{
StartCheckFixture();
}
}
IOTimeOutProcess();
}
public bool ReturnHome()
{
WarnMsg = "";
mainTimer.Stop();
alarmType = LineAlarmType.None;
runStatus = LineRunStatus.HomeMoving;
LogInfo("开始原点返回: (上下气上升,阻挡气缸上升 )开始");
SecondMoveInfo.EndMove();
MoveInfo.EndMove();
MoveInfo.NewMove(LineMoveType.ReturnHome);
StartReset();
return true;
}
public override bool Reset()
{
WarnMsg = "";
alarmType = LineAlarmType.None;
preTrayNum = 0;
currMoveTrayNum = 0;
LogInfo("开始重置:清理盘号,(上下气上升,阻挡气缸上升 )开始 ");
runStatus = LineRunStatus.Reset;
MoveInfo.EndMove();
SecondMoveInfo.EndMove();
MoveInfo.NewMove(LineMoveType.Reset);
StartReset();
return true;
}
private void StartReset()
{
MoveInfo.NextMoveStep(LineMoveStep.MH_UpDownCylinder_Up);
CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
if (IsDebug)
{
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.HIGH);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
}
else
{
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
}
isInPro = false;
}
protected override void ResetProcess( )
{
if (MoveInfo.IsInWait)
{
CheckWait(MoveInfo);
}
else if (SecondMoveInfo.IsInWait)
{
CheckWait(SecondMoveInfo);
}
if (!MoveInfo.IsInWait && !SecondMoveInfo.IsInWait)
{
switch (MoveInfo.MoveStep)
{
case LineMoveStep.MH_UpDownHomeMove:
MoveInfo.NextMoveStep(LineMoveStep.MH_UpDownCylinder_Up);
LogInfo(MoveInfo.MoveType+" : (上下轴原点返回完成,上下轴走到待机点 )开始");
// UpdownUpMove();
break;
case LineMoveStep.MH_UpDownCylinder_Up:
MoveInfo.NextMoveStep(LineMoveStep.MH_OtherCylinder_Back);
LogInfo(MoveInfo.MoveType + " : (上升到位,顶升气缸下降,前后气缸后退,夹紧气缸放松 )开始");
CylinderMove(MoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
CylinderMove(MoveInfo, IO_Type.BeforeAfterCylinder_Before, IO_Type.BeforeAfterCylinder_After);
CylinderMove(MoveInfo, IO_Type.ClampCylinder_Slack, IO_Type.ClampCylinder_Tighten);
break;
case LineMoveStep.MH_OtherCylinder_Back:
MoveInfo.EndMove();
SecondMoveInfo.EndMove();
LogInfo(MoveInfo.MoveType + " 完成!");
runStatus = LineRunStatus.Runing;
if (IsDebug)
{
lineStatus = LineStatus.Debugging;
}
else
{
lineStatus = LineStatus.StoreOnline;
}
break;
default: break;
}
}
}
protected override void ReturnHomeProcess()
{
ResetProcess();
}
public override void StopMove()
{
MoveInfo.EndMove();
SecondMoveInfo.EndMove();
runStatus = LineRunStatus.Busy;
LogInfo("停止运动:(上下气缸上升 ,阻挡气缸输入=0,顶升气缸下降 ) ");
//MoveInfo.NewMove(LineMoveType.StopMove);
//MoveInfo.NextMoveStep(LineMoveStep.MH_UpDownCylinder_Up);
CylinderMove(MoveInfo, IO_Type.UpDownCylinder_Down, IO_Type.UpDownCylinder_Up);
CylinderMove(MoveInfo, IO_Type.TopCylinder_UP, IO_Type.TopCylinder_Down);
IOMove(IO_Type.StopCylinder_Down1, IO_VALUE.LOW);
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.LOW);
}
public override void StartInStoreMove(InOutParam param)
{
}
protected override void InStoreProcess()
{
}
}
}