MainMachine _Store.cs
8.2 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
using CodeLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
public void AddOutStoreTask(string posId,string hSerial) {
JobInfo jobInfo = new JobInfo("", posId, hSerial);
OutStoreJobList.Enqueue(jobInfo);
LogUtil.info($"添加出库任务队列: {posId},工单号:{hSerial},当前任务数量: {OutStoreJobList.Count}");
}
MoveInfo InMoveInfo;
InOutSideE CurrentSide;
InOutDevice CurrentInOut;
void StoreProcess()
{
if (CheckWait(StoreMoveInfo))
return;
//常规上料扫码流程
switch (StoreMoveInfo.MoveStep)
{
case MoveStep.Wait:
//判断入库线体有没有等待入库
if (InOutDevice.GetInStoreWaitSide(out InOutSideE inOutSide, out InOutDevice iod))
{
InMoveInfo = iod.MoveInfo;
CurrentSide = inOutSide;
CurrentInOut = iod;
CurrentInOut.CurrnetDirection = InOutDirectionE.IN;
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn01);
StoreMoveInfo.MoveParam = InMoveInfo.MoveParam.clone();
StoreMoveInfo.log($"{CurrentSide}:入库周转箱已准备好");
}
//判断有没有出库任务, 需要入库空闲, 出口空闲
else if (boxTransport.IsComplateOrFree) {
if (InOutDevice.GetOutStoreFreeSide(out InOutSideE inOutSide2, out InOutDevice iod2) && OutStoreJobList.Dequeue(out JobInfo jobInfo))
{
StoreMoveInfo.log("检测到出库空闲侧:" + inOutSide2);
if (iod2.TurnToOut(jobInfo))
{
CurrentSide = inOutSide2;
CurrentInOut = iod2;
StoreMoveInfo.NewMove(MoveStep.StoreOut10);
StoreMoveInfo.MoveParam.PosID = jobInfo.PosId;
StoreMoveInfo.MoveParam.hSerial = jobInfo.hSerial;
StoreMoveInfo.log($"{CurrentSide}:开始出库任务");
ServerCM.storeStatus = StoreStatus.OutStoreExecute;
}
}
}
break;
case MoveStep.StoreIn01:
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
var ac = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
boxTransport.Start(new BoxStorePosition(Config, CurrentSide), new BoxStorePosition(ac), StoreMoveType.InStore, StoreMoveInfo.MoveParam.WareCode, true);
StoreMoveInfo.log($"{CurrentSide}:开始转运周转箱");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreExecute);
break;
case MoveStep.StoreIn02:
if (InMoveInfo.MoveStep == MoveStep.InWaitBoxLeave)
{
if (boxTransport.ReadyToTakeBox())
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
}
else if (StoreMoveInfo.IsTimeOut(10))
{
boxTransport.Reset();
StoreMoveInfo.log($"{CurrentSide}:等待转运装置到位超时, 退出等待");
StoreMoveInfo.EndMove();
}
}
else if(StoreMoveInfo.IsTimeOut(10)) {
StoreMoveInfo.log($"{CurrentSide}:等待入库料箱到位超时, 退出等待");
StoreMoveInfo.EndMove();
}
break;
case MoveStep.StoreIn03:
if (boxTransport.IsTakedBox)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn04);
InMoveInfo.NextMoveStep(MoveStep.InBoxLeaved);
StoreMoveInfo.log($"{CurrentSide}:周转箱已取走");
}
else
{
Msg.add($"{CurrentSide}:入料线等待周转箱离开", MsgLevel.info);
}
//if (string.IsNullOrEmpty(boxTransport.ErrMsgTxt)) {
// Msg.add(boxTransport.ErrMsgTxt, MsgLevel.warning);
//}
break;
case MoveStep.StoreIn04:
if (boxTransport.IsComplateOrFree)
{
StoreMoveInfo.log($"{CurrentSide}:周转箱已到达目的地");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.InStoreEnd);
StoreMoveInfo.EndMove();
}
break;
case MoveStep.StoreOut10:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
if (StoreMoveInfo.MoveParam.PosID == "Reset")
{
boxTransport.Start(null, new BoxStorePosition(Config, CurrentSide), StoreMoveType.OutStore, StoreMoveInfo.MoveParam.WareCode);
}
else
{
var outac = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
boxTransport.Start(new BoxStorePosition(outac), new BoxStorePosition(Config, CurrentSide), StoreMoveType.OutStore, StoreMoveInfo.MoveParam.WareCode);
}
StoreMoveInfo.log($"{CurrentSide}:开始转运周转箱");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreExecute);
break;
case MoveStep.StoreOut11:
if (boxTransport.IsTakedBox)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut12);
StoreMoveInfo.log($"{CurrentSide}:周转箱已取走");
}
else
{
Msg.add($"{CurrentSide}:出料线等待周转箱到达", MsgLevel.info);
}
//if (string.IsNullOrEmpty(boxTransport.ErrMsgTxt))
//{
// Msg.add(boxTransport.ErrMsgTxt, MsgLevel.warning);
//}
break;
case MoveStep.StoreOut12:
if (boxTransport.IsPutOnOut)
{
CurrentInOut.MoveInfo.NextMoveStep(MoveStep.OutBoxPutOn);
CurrentInOut.MoveInfo.MoveParam = StoreMoveInfo.MoveParam.clone();
StoreMoveInfo.log($"周转箱已到达目的地");
ServerCM.SendStoreState(StoreMoveInfo.MoveParam.PosID, StoreStatus.OutStoreBoxEnd);
OutStoreJobList.ClearLastPosid(StoreMoveInfo.MoveParam.PosID);
StoreMoveInfo.EndMove();
}
break;
default:
StoreMoveInfo.log($"未找到对应步骤:{StoreMoveInfo.MoveStep}");
break;
}
}
string StoreState() {
string state = "空闲中";
if (StoreMoveInfo.MoveStep >= MoveStep.StoreOut10)
{
state = $"出库中,库位号:{StoreMoveInfo.MoveParam.PosID}";
}
else if (StoreMoveInfo.MoveStep >= MoveStep.StoreIn01)
{
state = $"入库中,库位号:{StoreMoveInfo.MoveParam.PosID}";
}
return state;
}
}
}