MainMachine_RFIDSelftest.cs
11.0 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
using CodeLibrary;
using Newtonsoft.Json;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace DeviceLibrary
{
partial class MainMachine
{
public bool DemoTestMode = false;
List<string> DemoTestList;
int DemoTestIndex = 0;
int DemoTestCount = 0;
bool issame = false;
void TFIDSelfTestProcess()
{
if (CheckWait(StoreMoveInfo))
return;
//常规上料扫码流程
switch (StoreMoveInfo.MoveStep)
{
case MoveStep.Wait:
if (selfAuditMode&&!ServerCM.selfAudit)
{
StoreMoveInfo.log("自检模式结束");
selfAuditMode = false;
return;
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn01);
StoreMoveInfo.log("自检模式开始");
break;
case MoveStep.StoreIn01:
if (IOValue(IO_Type.Out_Drawer).Equals(IO_VALUE.HIGH) && IOValue(IO_Type.Entry_Drawer).Equals(IO_VALUE.HIGH))
{
var slist = CameraPointTest.GetThingStoreName(TestStorePointPort.入口);
if (slist.Count == 0)
{
IOMove(IO_Type.Out_Drawer_Lock, IO_VALUE.HIGH);
IOMove(IO_Type.Entry_Drawer_Lock, IO_VALUE.HIGH);
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
Y_Axis.AbsMove(StoreMoveInfo, 0, Config.Y_Axis_P1_speed);
X_Axis.AbsMove(StoreMoveInfo, 0, Config.X_Axis_P1_speed);
}
else {
IOValue(IO_Type.Entry_Drawer_Lock).Equals(IO_VALUE.LOW);
Msg.add(crc.GetString("Res0174.f33f9554","开始自检时请清空入库抽屉"), MsgLevel.alarm);
}
}
else {
Msg.add(crc.GetString("Res0168.e90e8acf","开始自检时请关好抽屉"), MsgLevel.alarm);
}
break;
case MoveStep.StoreIn02:
if (!ServerCM.selfAudit) {
StoreMoveInfo.NextMoveStep(MoveStep.Wait);
return;
}
var job = ServerCM.SelfAudit_getNetPos();
if (job == null) {
Msg.add(crc.GetString("Res0169.ee0b269b","开始自检,但服务器没有返回正确库位信息."), MsgLevel.alarm);
}
else
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn03);
StoreMoveInfo.MoveParam.WareCode = job.WareNum;
StoreMoveInfo.MoveParam.PosID = job.PosId;
TestStorePointPort tspp = CameraPointTest.GetTestStorePointPort(job.PosId);
if (tspp == TestStorePointPort.上层左侧 || tspp == TestStorePointPort.下层右侧)
{
RobotManage.mainMachine.TPMove.ToLow(StoreMoveInfo);
StoreMoveInfo.log($"{job.WareNum},上层库位移至左侧");
}
else if (tspp == TestStorePointPort.下层左侧)
{
RobotManage.mainMachine.TPMove.ToHigh(StoreMoveInfo);
StoreMoveInfo.log($"{job.WareNum},上层库位移至右侧");
}
}
break;
case MoveStep.StoreIn03:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut10);
{
var tspp = CameraPointTest.GetTestStorePointPort(StoreMoveInfo.MoveParam.PosID);
var slist = CameraPointTest.GetThingStoreName(tspp);
var hasthing = slist.Contains(StoreMoveInfo.MoveParam.PosID);
if (!hasthing)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
ServerCM.SelfAudit_posSelfAuditEnd(StoreMoveInfo.MoveParam.PosID, "", "");
StoreMoveInfo.log($"自检:{StoreMoveInfo.MoveParam.PosID},没有物料");
return;
}
}
break;
case MoveStep.StoreOut10:
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut11);
var from = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
var to = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
StoreMoveInfo.MoveParam.ReelOnFixture = false;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.OutStore, true);
boxTransport.isSelfAudit= true;
StoreMoveInfo.log($"开始转运出库");
break;
case MoveStep.StoreOut11:
case MoveStep.StoreOut12:
if (boxTransport.IsComplateOrFree)
{
if (!boxTransport.CheckHasMatetial)
{
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn02);
ServerCM.SelfAudit_posSelfAuditEnd(StoreMoveInfo.MoveParam.PosID, "", "");
StoreMoveInfo.log($"自检:{StoreMoveInfo.MoveParam.PosID},没有物料");
return;
}
ServerCM.SelfAudit_posOutEnd(StoreMoveInfo.MoveParam.PosID);
issame = false;
string ds="";
for (int i = 0; i < 15; i++)
{
if (RobotManage.RFID.ReadEPC(16, out byte[] data))
{
if (data[0] != 0xFF)
{
ds = Encoding.ASCII.GetString(data).Trim();
if (!string.IsNullOrEmpty(ds))
{
StoreMoveInfo.log("读取到 RFID:" + ds + " , " + RobotManage.RFID.HexBuff(data));
StoreMoveInfo.MoveParam.RFID = ds.TrimStart('S');
if (StoreMoveInfo.MoveParam.WareCode.IndexOf(StoreMoveInfo.MoveParam.RFID) > -1)
{
issame = true;
break;
}
}
}
}
if (!issame) {
if (RobotManage.RFID2.ReadEPC(16, out data))
{
if (data[0] != 0xFF)
{
ds = Encoding.ASCII.GetString(data).Trim();
if (!string.IsNullOrEmpty(ds))
{
StoreMoveInfo.MoveParam.RFID = ds.TrimStart('S');
StoreMoveInfo.log("读取到 RFID2:" + ds + " , " + RobotManage.RFID.HexBuff(data));
if (StoreMoveInfo.MoveParam.WareCode.IndexOf(StoreMoveInfo.MoveParam.RFID) > -1)
{
issame = true;
break;
}
}
}
}
}
Thread.Sleep(200);
}
StoreMoveInfo.NextMoveStep(MoveStep.StoreOut13);
from = CSVPositionReader<ACStorePosition>.GetPositon(RFIDP);
to = CSVPositionReader<ACStorePosition>.GetPositon(StoreMoveInfo.MoveParam.PosID);
StoreMoveInfo.MoveParam.ReelOnFixture = true;
boxTransport.Start(new BoxStorePosition(Config, from, StoreMoveInfo.MoveParam), new BoxStorePosition(Config, to, StoreMoveInfo.MoveParam), StoreMoveType.OutStore, true);
StoreMoveInfo.log($"开始转运出库");
}
break;
case MoveStep.StoreOut13:
if (boxTransport.IsComplateOrFree)
{
Setting_Init.Runtime_Step = Runtime_StepE.None;
StoreMoveInfo.NextMoveStep(MoveStep.StoreIn01);
if (!issame)
{
var crfid = StoreMoveInfo.MoveParam.RFID;
if (string.IsNullOrEmpty(crfid))
{
crfid = "Rfid read fail";
StoreMoveInfo.MoveParam.NgMsg = "Rfid read fail";
}else
StoreMoveInfo.MoveParam.NgMsg = crc.GetString("Res0175.61bd5a58","RFID不符");
NGInfoList.Add(StoreMoveInfo.MoveParam.clone());
ServerCM.SelfAudit_posSelfAuditEnd(StoreMoveInfo.MoveParam.PosID, StoreMoveInfo.MoveParam.WareCode, crfid);
StoreMoveInfo.log($"自检:{StoreMoveInfo.MoveParam.PosID},{StoreMoveInfo.MoveParam.WareCode}!={StoreMoveInfo.MoveParam.RFID}物料数据不符");
}
else
{
ServerCM.SelfAudit_posSelfAuditEnd(StoreMoveInfo.MoveParam.PosID, StoreMoveInfo.MoveParam.WareCode, StoreMoveInfo.MoveParam.WareCode);
StoreMoveInfo.log($"自检:{StoreMoveInfo.MoveParam.PosID},{StoreMoveInfo.MoveParam.WareCode}=={StoreMoveInfo.MoveParam.RFID}物料数据符合");
}
}
break;
default:
StoreMoveInfo.log($"未找到对应步骤:{StoreMoveInfo.MoveStep}");
break;
}
}
}
}