MainMachine _AutoInOutTest.cs
6.1 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
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.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
public bool StartAutoInOutTest(int posindex, out string errmsg)
{
errmsg = "";
if (!boxTransport.IsComplateOrFree)
{
errmsg = crc.GetString("Res0072","料仓忙碌中,无法启动");
return false;
}
if(!IsInStoreReady)
{
errmsg = crc.GetString("Res0073","入库料盘没有准备好,无法启动");
return false;
}
AutoInOutTest = true;
StopAutoInOut = false;
CurrentPosIndex = posindex;
//AIOTMoveInfo.NewMove(MoveStep.Wait);
return true;
}
public void StopAutoInOutTest()
{
StopAutoInOut = true;
}
int CurrentPosIndex = 0;
/// <summary>
/// 自动出入库状态
/// </summary>
public bool AutoInOutTest { get; set; } = false;
bool StopAutoInOut = false;
void AutoInOutTestProcess()
{
if (CheckWait(AIOTMoveInfo))
return;
//常规上料扫码流程
switch (AIOTMoveInfo.MoveStep)
{
case MoveStep.Wait:
if (IsInStoreReady)
{
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn01);
AIOTMoveInfo.log($"入库料盘已准备好");
}
break;
case MoveStep.StoreIn01:
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn02);
var ac = RobotManage.allPositionMap[RobotManage.StorePositionNumList[CurrentPosIndex]];
var from = RobotManage.allPositionMap["EP_1_1"];
var reel = new ReelParam("auto");
if (!boxTransport.Start(new BoxStorePosition(Config, from, reel), new BoxStorePosition(Config, ac, reel), StoreMoveType.InStore)) {
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
StopAutoInOut = true;
return;
}
AIOTMoveInfo.log($"开始转运料盘第一盘");
break;
case MoveStep.StoreIn02:
case MoveStep.StoreIn03:
if (boxTransport.IsComplateOrFree)
{
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn04);
var ac1 = RobotManage.allPositionMap[RobotManage.StorePositionNumList[CurrentPosIndex]];
if (CurrentPosIndex - 1 < 0 || StopAutoInOut)
{
AIOTMoveInfo.log($"A已达到最后一个库位:{CurrentPosIndex},或手动停止{StopAutoInOut},自动出入库停止,将料盘送至出口");
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut10);
CurrentPosIndex++;
return;
}
var ac2 = RobotManage.allPositionMap[RobotManage.StorePositionNumList[CurrentPosIndex-1]];
reel = new ReelParam("auto");
if (!boxTransport.Start(new BoxStorePosition(Config, ac1, reel), new BoxStorePosition(Config, ac2, reel), StoreMoveType.InStore))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
StopAutoInOut = true;
return;
}
AIOTMoveInfo.log($"开始移库");
}
break;
case MoveStep.StoreIn04:
if (boxTransport.IsComplateOrFree)
{
AIOTMoveInfo.log($"料盘已到达目的地");
if (CurrentPosIndex-1 < 0 || StopAutoInOut)
{
AIOTMoveInfo.log($"B已达到最后一个库位:{CurrentPosIndex},或手动停止{StopAutoInOut},自动出入库停止,将料盘送至出口");
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut10);
return;
}
CurrentPosIndex--;
AIOTMoveInfo.NextMoveStep(MoveStep.StoreIn03);
}
break;
case MoveStep.StoreOut10:
AIOTMoveInfo.NextMoveStep(MoveStep.StoreOut11);
ac = RobotManage.allPositionMap[RobotManage.PositionNumList[CurrentPosIndex]];
var to = RobotManage.allPositionMap["OP_1"];
reel = new ReelParam("auto");
if (!boxTransport.Start(new BoxStorePosition(Config, ac, reel), new BoxStorePosition(Config, to, reel), StoreMoveType.OutStore))
{
AIOTMoveInfo.log($"料仓周转启动失败");
AutoInOutTest = false;
StopAutoInOut = true;
return;
}
AIOTMoveInfo.log($"开始转运料盘");
break;
case MoveStep.StoreOut11:
if (boxTransport.IsComplateOrFree)
{
AIOTMoveInfo.log($"库位测试结束");
AIOTMoveInfo.EndMove();
AutoInOutTest = false;
}
break;
default:
AIOTMoveInfo.log($"未找到对应步骤:{AIOTMoveInfo.MoveStep}");
break;
}
}
}
}