Commit 0a2f94ec LN

当未找到有效码时重新扫码

1 个父辈 dc9b6c0a
...@@ -399,7 +399,7 @@ namespace OnlineStore.AssemblyLine ...@@ -399,7 +399,7 @@ namespace OnlineStore.AssemblyLine
private void btnScan_Click(object sender, EventArgs e) private void btnScan_Click(object sender, EventArgs e)
{ {
List<string> camers = equipBean.Config.GetCameraList(); List<string> camers = equipBean.Config.GetCameraList();
List<string> LastCodeList = CodeManager.CameraScan(camers,equipBean.Name,true); List<string> LastCodeList = CodeManager.CameraScan(camers,equipBean.Name.Trim()+"测试",true);
string cameraStr = ""; string cameraStr = "";
foreach (string ca in camers) foreach (string ca in camers)
{ {
......
...@@ -566,7 +566,7 @@ namespace OnlineStore.AssemblyLine ...@@ -566,7 +566,7 @@ namespace OnlineStore.AssemblyLine
private void btnScan_Click(object sender, EventArgs e) private void btnScan_Click(object sender, EventArgs e)
{ {
List<string> camers = equipBean.Config.GetCameraList(); List<string> camers = equipBean.Config.GetCameraList();
List<string> LastCodeList = CodeManager.CameraScan(camers,equipBean.Name); List<string> LastCodeList = CodeManager.CameraScan(camers,equipBean.Name.Trim()+"测试");
string cameraStr = ""; string cameraStr = "";
foreach(string ca in camers) foreach(string ca in camers)
{ {
......
...@@ -559,7 +559,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -559,7 +559,7 @@ namespace OnlineStore.DeviceLibrary
if (DeviceID.Equals(301)) if (DeviceID.Equals(301))
{ {
if (Line3LastTrayP > Line3MaxPosition) { Line3LastTrayP = Line3MaxPosition; } if (Line3LastTrayP > Line3MaxPosition) { Line3LastTrayP = Line3MaxPosition; }
// StationInfo_NG = new StationTrayInfo(StationInfo_Scan.TrayValue, StationInfo_Scan.CodeStr); // StationInfo_NG = new StationTrayInfo(StationInfo_Scan.TrayValue, StationInfo_Scan.CodeStr);
} }
else else
{ {
...@@ -570,9 +570,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -570,9 +570,10 @@ namespace OnlineStore.DeviceLibrary
} }
LogUtil.info(hengyiName + "扫码工位:开始扫码,IsInScanCode=" + IsInScanCode); LogUtil.info(hengyiName + "扫码工位:开始扫码,IsInScanCode=" + IsInScanCode);
List<string> LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), hengyiName, true); List<string> LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), hengyiName, true);
if (LastCodeList.Count <= 0) bool hasR = CodeManager.HasRightCode(LastCodeList.ToArray());
if (!hasR)
{ {
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), hengyiName, true); LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), hengyiName, true, 3000);
} }
LastCode = SServerManager.ProcessCodeList(LastCodeList); LastCode = SServerManager.ProcessCodeList(LastCodeList);
} }
...@@ -582,7 +583,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -582,7 +583,7 @@ namespace OnlineStore.DeviceLibrary
} }
finally finally
{ {
UpdateScanInfo(IO_VALUE.HIGH, LastCode); UpdateScanInfo(IO_VALUE.HIGH, LastCode);
IsInScanCode = false; IsInScanCode = false;
LogUtil.info(hengyiName + " 扫码工位 : 扫码结束 ," + StationInfo_Scan.ToStr + " IsInScanCode = " + IsInScanCode); LogUtil.info(hengyiName + " 扫码工位 : 扫码结束 ," + StationInfo_Scan.ToStr + " IsInScanCode = " + IsInScanCode);
......
...@@ -1195,12 +1195,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -1195,12 +1195,8 @@ namespace OnlineStore.DeviceLibrary
{ {
Task<List<string>> scanTask = Task.Factory.StartNew(delegate Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{ {
Thread.Sleep(500);
NextCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name); NextCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name.Trim()+"预扫码");
//if (NextCodeList.Count <= 0)
//{
// NextCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
//}
bool isCanUse = true; bool isCanUse = true;
//判断是否可用 //判断是否可用
foreach (string nC in NextCodeList) foreach (string nC in NextCodeList)
...@@ -1214,11 +1210,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -1214,11 +1210,15 @@ namespace OnlineStore.DeviceLibrary
break; break;
} }
} }
} }
if (!isCanUse) if (!isCanUse)
{ {
NextCodeList = new List<string>(); NextCodeList = new List<string>();
} }
if (!CodeManager.HasRightCode(NextCodeList.ToArray()))
{
NextCodeList = new List<string>();
}
return NextCodeList; return NextCodeList;
}); });
} }
...@@ -1268,16 +1268,16 @@ namespace OnlineStore.DeviceLibrary ...@@ -1268,16 +1268,16 @@ namespace OnlineStore.DeviceLibrary
InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码"); InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码");
MoveInfo.OneWaitCanEndStep = true; MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitFeedScanCode()); MoveInfo.WaitList.Add(WaitResultInfo.WaitFeedScanCode());
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(6000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
try try
{ {
Task<List<string>> scanTask = Task.Factory.StartNew(delegate Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{ {
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(),Name); bool hasRightCode = CodeManager.HasRightCode(LastCodeList.ToArray());
if (LastCodeList.Count <= 0) if (!hasRightCode)
{ {
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(),Name); LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, false, 3000);
} }
return LastCodeList; return LastCodeList;
}); });
......
...@@ -98,7 +98,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -98,7 +98,7 @@ namespace OnlineStore.DeviceLibrary
private static int ScanCount = 0; private static int ScanCount = 0;
private static int codeCount = ConfigAppSettings.GetIntValue(Setting_Init.CodeCount); private static int codeCount = ConfigAppSettings.GetIntValue(Setting_Init.CodeCount);
[HandleProcessCorruptedStateExceptions] [HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan(List<string> cameraList, string deviceName, bool findRightCodeBreak = false) public static List<string> CameraScan(List<string> cameraList, string deviceName, bool findRightCodeBreak = false,int timeOut=2000)
{ {
List<string> codeList = new List<string>(); List<string> codeList = new List<string>();
if (cameraList == null || cameraList.Count <= 0) if (cameraList == null || cameraList.Count <= 0)
...@@ -143,7 +143,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -143,7 +143,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
cc = HDCodeHelper.DecodeCode(ho_Image, codeCount, GetCodeParamFilePath(codeType), codeType); cc = HDCodeHelper.DecodeCode(ho_Image, codeType, GetCodeParamFilePath(codeType), codeCount, timeOut);
} }
foreach (CodeInfo c in cc) foreach (CodeInfo c in cc)
{ {
...@@ -154,7 +154,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -154,7 +154,7 @@ namespace OnlineStore.DeviceLibrary
r = r + "##" + str; r = r + "##" + str;
if (!findRightCode) if (!findRightCode)
{ {
findRightCode = IsRightCode(str); findRightCode = HasRightCode(str);
} }
} }
} }
...@@ -226,7 +226,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -226,7 +226,7 @@ namespace OnlineStore.DeviceLibrary
} }
private static void SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap) private static void SaveImageToFile(string deviceName, string cameraName, Bitmap bitmap)
{ {
string date = DateTime.Now.ToString("HH-mm-ss-") + DateTime.Now.Millisecond; string date = deviceName.Trim().Replace('_', '-') +"-"+ DateTime.Now.ToString("HH-mm-ss-") + DateTime.Now.Millisecond;
string dire = @"D:\image\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\"; string dire = @"D:\image\" + deviceName.Trim().Replace('_', '-') + @"\" + cameraName.Trim().Replace('_', '-').Replace(':', '-') + @"\";
string iamgeName = date + ".bmp"; string iamgeName = date + ".bmp";
try try
...@@ -245,25 +245,28 @@ namespace OnlineStore.DeviceLibrary ...@@ -245,25 +245,28 @@ namespace OnlineStore.DeviceLibrary
} }
} }
private static bool IsRightCode(string code) public static bool HasRightCode(params string[] codes)
{ {
//分号分割后长度=4,L,E,B,R //分号分割后长度=4,L,E,B,R
try try
{ {
string[] strarray = code.Split(';'); foreach (string code in codes)
if (strarray.Length == 4) {
{ string[] strarray = code.Split(';');
if (strarray[0].StartsWith("L") && if (strarray.Length == 4)
strarray[1].StartsWith("E") &&
strarray[2].StartsWith("B") &&
strarray[3].StartsWith("R"))
{ {
return true; if (strarray[0].StartsWith("L") &&
} strarray[1].StartsWith("E") &&
strarray[2].StartsWith("B") &&
strarray[3].StartsWith("R"))
{
return true;
}
}
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
} }
return false; return false;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!