Commit 0a2f94ec LN

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

1 个父辈 dc9b6c0a
......@@ -399,7 +399,7 @@ namespace OnlineStore.AssemblyLine
private void btnScan_Click(object sender, EventArgs e)
{
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 = "";
foreach (string ca in camers)
{
......
......@@ -566,7 +566,7 @@ namespace OnlineStore.AssemblyLine
private void btnScan_Click(object sender, EventArgs e)
{
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 = "";
foreach(string ca in camers)
{
......
......@@ -570,9 +570,10 @@ namespace OnlineStore.DeviceLibrary
}
LogUtil.info(hengyiName + "扫码工位:开始扫码,IsInScanCode=" + IsInScanCode);
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);
}
......
......@@ -1195,12 +1195,8 @@ namespace OnlineStore.DeviceLibrary
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
NextCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
//if (NextCodeList.Count <= 0)
//{
// NextCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
//}
Thread.Sleep(500);
NextCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name.Trim()+"预扫码");
bool isCanUse = true;
//判断是否可用
foreach (string nC in NextCodeList)
......@@ -1219,6 +1215,10 @@ namespace OnlineStore.DeviceLibrary
{
NextCodeList = new List<string>();
}
if (!CodeManager.HasRightCode(NextCodeList.ToArray()))
{
NextCodeList = new List<string>();
}
return NextCodeList;
});
}
......@@ -1268,16 +1268,16 @@ namespace OnlineStore.DeviceLibrary
InLog("料盘移栽" + MoveInfo.SLog + ":开始扫码");
MoveInfo.OneWaitCanEndStep = true;
MoveInfo.WaitList.Add(WaitResultInfo.WaitFeedScanCode());
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(6000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(7000));
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(),Name);
if (LastCodeList.Count <= 0)
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
bool hasRightCode = CodeManager.HasRightCode(LastCodeList.ToArray());
if (!hasRightCode)
{
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(),Name);
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name, false, 3000);
}
return LastCodeList;
});
......
......@@ -98,7 +98,7 @@ namespace OnlineStore.DeviceLibrary
private static int ScanCount = 0;
private static int codeCount = ConfigAppSettings.GetIntValue(Setting_Init.CodeCount);
[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>();
if (cameraList == null || cameraList.Count <= 0)
......@@ -143,7 +143,7 @@ namespace OnlineStore.DeviceLibrary
}
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)
{
......@@ -154,7 +154,7 @@ namespace OnlineStore.DeviceLibrary
r = r + "##" + str;
if (!findRightCode)
{
findRightCode = IsRightCode(str);
findRightCode = HasRightCode(str);
}
}
}
......@@ -226,7 +226,7 @@ namespace OnlineStore.DeviceLibrary
}
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 iamgeName = date + ".bmp";
try
......@@ -245,11 +245,13 @@ namespace OnlineStore.DeviceLibrary
}
}
private static bool IsRightCode(string code)
public static bool HasRightCode(params string[] codes)
{
//分号分割后长度=4,L,E,B,R
try
{
foreach (string code in codes)
{
string[] strarray = code.Split(';');
if (strarray.Length == 4)
{
......@@ -262,6 +264,7 @@ namespace OnlineStore.DeviceLibrary
}
}
}
}
catch (Exception ex)
{
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!