AC_SA_BoxBean_Inventory.cs
9.7 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
namespace OnlineStore.DeviceLibrary
{
public partial class AC_SA_BoxBean
{
//进出轴到P1
//InOutBackToP1(StoreMove.MoveParam.MoveP.InOut_P1);
protected override void InventoryProcess()
{
LineMoveP moveP = StoreMove.MoveParam.MoveP;
bool IsExist = false;
if (StoreMove.IsInWait)
{
CheckWait();
}
if (StoreMove.IsInWait)
{
return;
}
if (StoreMove.MoveStep == StoreMoveStep.SC_01_InOutAxisHome)
{
StoreMove.NextMoveStep(StoreMoveStep.SC_02_MoveToLBag);
ACAxisMove(Config.Middle_Axis, moveP.Middle_P3, Config.MiddleAxis_P2_Speed);
int outCount = ACServerManager.GetActualtPosition(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
int disCount = Math.Abs(outCount - moveP.UpDown_P5);
//CheckPositionLog("升降轴当前位置与目标位置距离为(高低速距离阈值为150000)" + disCount.ToString());
if (disCount > 150000)
{
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P5, Config.UpDownAxis_P5_Speed);
CheckPositionLog(" 旋转轴 至P3(料叉背向库位点)升降轴到P5(库位低点) UpDownAxis_P5_Speed=" + Config.UpDownAxis_P5_Speed.ToString());
}
else
{
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P5, Config.UpDownAxis_P6_Speed);
CheckPositionLog(" 旋转轴 至P3(料叉背向库位点)升降轴到P5(库位低点) UpDownAxis_P6_Speed=" + Config.UpDownAxis_P6_Speed.ToString());
}
}
else if (StoreMove.MoveStep == StoreMoveStep.SC_02_MoveToLBag)
{
StoreMove.NextMoveStep(StoreMoveStep.SC_03_MoveToHBag);
CheckPositionLog(" 升降轴到库位高点P9, UpDownAxis_P9_Speed=" + Config.UpDownAxis_P9_Speed.ToString());
ACAxisMove(Config.UpDown_Axis, moveP.UpDown_P9, Config.UpDownAxis_P9_Speed);
StoreMove.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.CheckPos, IO_VALUE.HIGH));
StoreMove.OneWaitCanEndStep = true;
}
else if (StoreMove.MoveStep == StoreMoveStep.SC_03_MoveToHBag)
{
ACServerManager.SuddenStop(Config.UpDown_Axis.DeviceName, Config.UpDown_Axis.GetAxisValue());
StoreMove.NextMoveStep(StoreMoveStep.SC_04_Inventory);
StoreMove.WaitList.Add(WaitResultInfo.WaitTime(2000));
int outCount = ACServerManager.GetActualtPosition(Config.UpDown_Axis);
int errorCount = Math.Abs(outCount - moveP.UpDown_P9);
if (errorCount <= Config.UpDown_Axis.CanErrorCountMax)
{
CheckPositionLog(" 升降轴到目标位置停止, 当前位置=" + ACServerManager.GetActualtPosition(Config.UpDown_Axis));
}
else
{
CheckPositionLog(" 升降轴未到目标停止, 当前位置=" + ACServerManager.GetActualtPosition(Config.UpDown_Axis));
}
// if (ACAxisMoveIsEnd(Config.UpDown_Axis, moveP.UpDown_P9,Config.UpDownAxis_P9_Speed, out string msg))
//{
//}
//else
//{
// //IsExist = true;
// //IsExist = IOManager.IOValue(IO_Type.CheckPos).Equals(IO_VALUE.HIGH);
//}
}
else if (StoreMove.MoveStep == StoreMoveStep.SC_04_Inventory)
{
IsExist = IOManager.IOValue(IO_Type.CheckPos).Equals(IO_VALUE.HIGH);
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("cid", CID);//cid = 料仓CID
paramMap.Add("pos", StoreMove.MoveParam.PosInfo.PosId); // 库位
paramMap.Add("hasReel", IsExist.ToString()); // 是否有料
string server = StoreManager.GetAddr(StoreManager.Addr_posReelCheck, paramMap);
string resultStr = HttpHelper.Post(server, "");
CheckPositionLog("盘点仓位: [CID=" + CID + "] [" + StoreMove.MoveParam.PosInfo.PosId + "] [IO_Type.CheckPos=" + IsExist.ToString() + "] [resultStr=" + resultStr + "]");
StoreMove.EndMove();
storeRunStatus = StoreRunStatus.Runing;
//设备连接,盘点后,BOX恢复原始状态
storeStatus = StoreStatus.StoreOnline;
InventoryEndProcess(StoreMoveType.CheckPosition);
}
}
/// <summary>
/// 自动盘点是否结束
/// </summary>
/// <param name="storeMoveType"></param>
private void InventoryEndProcess(StoreMoveType storeMoveType)
{
try
{
CurrInOutCount++;
CurrInOutACount++;
//是否自动状态
if (!autoNext)
{
return;
}
if (storeMoveType.Equals(StoreMoveType.CheckPosition))
{
int newIndex = autoPositionIndex - 1;
if (newIndex < 0)
{
if (AutoStartIndex >= 0 && AutoStartIndex < PositionNumList.Count)
{
newIndex = AutoStartIndex;
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,重新开始自动盘点,索引【" + AutoStartIndex + "】");
}
else
{
autoNext = false;
autoMsg = "自动盘点结束!";
LogUtil.info(LOGGER, StoreName + "下一个索引不存在,自动盘点结束!");
//回待机位
MoveToP1();
}
}
else
{
autoPositionIndex = newIndex;
string posid = PositionNumList[autoPositionIndex];
InOutPosInfo inoutinfo = new InOutPosInfo(autoInoutCode, posid);
//判断是否需要重置
if (CurrInOutACount >= Config.Box_ResetACount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个仓位:posid=" + posid + ",当时已经盘点" + CurrInOutACount + "次,需要重置BOX");//,先把盘点信息存入排队列表中
Reset(false);
autoMsg = "自动盘点:" + posid;
AddWaitOutInfo(inoutinfo);
}
else if (CurrInOutCount >= Config.Box_ResetMCount)
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个仓位:posid=" + posid + ",当时已经出盘点" + CurrInOutCount + "次,需要重置BOX旋转轴");
//ResetMiddleAxis(false);
autoMsg = "自动盘点:" + posid;
AddWaitOutInfo(inoutinfo);
}
else
{
LogUtil.info(LOGGER, StoreName + "自动进入下一个仓位:posid=" + posid);
autoMsg = "自动盘点:" + posid;
StartInventoryMove(new InOutParam(inoutinfo));
}
}
}
}
catch (Exception ex)
{
LogUtil.error(LOGGER, ex.ToString());
}
}
/// <summary>
/// 开始库位盘点
/// </summary>
public void StartInventoryMove(InOutParam param)
{
startInStoreTime = DateTime.Now;
string posId = param != null ? param.PosInfo.PosId : "";
if (storeRunStatus == StoreRunStatus.Runing)
{
if (!LoadParamPosition(param))
{
LogUtil.error(LOGGER, StoreName + " 启动盘点库位【" + posId + "】出错,找不到库位信息");
return;
}
LogUtil.info(LOGGER, StoreName + " 启动盘点库位【" + posId + "】", storeMoveColor);
storeRunStatus = StoreRunStatus.Busy;
storeStatus = StoreStatus.CheckPosMove;
StoreMove.NewMove(StoreMoveType.CheckPosition, param);
SC_01_Move(param.MoveP);
}
else
{
LogUtil.error(LOGGER, StoreName + " 启动盘点库位【" + posId + "】出错,当前状态,storeStatus=" + storeRunStatus);
}
}
private void SC_01_Move(LineMoveP moveP)
{
StoreMove.NextMoveStep(StoreMoveStep.SC_01_InOutAxisHome);
CheckPositionLog("盘点:SC_01_InOutAxisHome 进出轴(叉子)动作至P1");
InOutBackToP1(moveP.InOut_P1);
}
private void CheckPositionLog(string msg)
{
string posId = StoreMove.MoveParam != null ? "【" + StoreMove.MoveParam.PosInfo.PosId + "】" : " ";
LogUtil.info(LOGGER, posId + StoreMove.MoveStep + " " + msg, storeMoveColor);
}
}
}