Commit 15312fe1 张东亮

扫码线程处理

1 个父辈 11c360e3
此文件类型无法预览
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
<Reference Include="Asa.Camera.VisionLib"> <Reference Include="Asa.Camera.VisionLib">
<HintPath>..\..\dll\Asa.Camera.VisionLib.dll</HintPath> <HintPath>..\..\dll\Asa.Camera.VisionLib.dll</HintPath>
</Reference> </Reference>
<Reference Include="CodeLibrary"> <Reference Include="CodeLibrary, Version=1.0.8182.32076, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\CodeLibrary.dll</HintPath> <HintPath>..\..\dll\CodeLibrary.dll</HintPath>
</Reference> </Reference>
<Reference Include="halcondotnet"> <Reference Include="halcondotnet">
......
...@@ -45,7 +45,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -45,7 +45,7 @@ namespace OnlineStore.DeviceLibrary
LoadCamera(false); LoadCamera(false);
CodeLibrary.HDCodeLearnHelper.LoadConfig("", codeStr); CodeLibrary.HDCodeLearnHelper.LoadConfig("", codeStr);
CodeLibrary.EyemDecode.InitModel(); //CodeLibrary.EyemDecode.InitModel();
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -178,6 +178,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -178,6 +178,13 @@ namespace OnlineStore.DeviceLibrary
} }
} }
} }
}
catch (Exception ex)
{
LogUtil.error(deviceName + " RemoteDecodeHelper扫码出错:" + ex.ToString());
}
}
LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】[" + findRightCode + "]" + ScanCount + " :" + r);
if (!findRightCode) if (!findRightCode)
{ {
SaveNGImageToFile(deviceName, cameraName, bmp); SaveNGImageToFile(deviceName, cameraName, bmp);
...@@ -187,14 +194,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -187,14 +194,6 @@ namespace OnlineStore.DeviceLibrary
SaveOKImageToFile(deviceName, cameraName, bmp); SaveOKImageToFile(deviceName, cameraName, bmp);
} }
} }
catch (Exception ex)
{
LogUtil.error(deviceName + " RemoteDecodeHelper扫码出错:" + ex.ToString());
}
}
LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】[" + findRightCode + "]" + ScanCount + " :" + r);
}
catch (AccessViolationException e) catch (AccessViolationException e)
{ {
LogUtil.error(deviceName + " 扫码出现AccessViolationException异常,关闭相机【" + cameraName + "】:" + e.ToString()); LogUtil.error(deviceName + " 扫码出现AccessViolationException异常,关闭相机【" + cameraName + "】:" + e.ToString());
......
...@@ -452,8 +452,9 @@ namespace OnlineStore.DeviceLibrary ...@@ -452,8 +452,9 @@ namespace OnlineStore.DeviceLibrary
} }
else if (wait.WaitType.Equals(WaitEnum.W102_FeedScanCode)) else if (wait.WaitType.Equals(WaitEnum.W102_FeedScanCode))
{ {
if (LastCodeList.Count > 0) if (scanTask==null || scanTask.IsCompleted)//LastCodeList.Count > 0
{ {
LastCodeList=scanTask.Result;
wait.IsEnd = true; wait.IsEnd = true;
} }
} }
......
...@@ -267,7 +267,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -267,7 +267,7 @@ namespace OnlineStore.DeviceLibrary
{ {
MoveInfo.NextMoveStep(StepEnum.IB13_ScanOK); MoveInfo.NextMoveStep(StepEnum.IB13_ScanOK);
var span = DateTime.Now - MoveInfo.LastSetpTime; var span = DateTime.Now - MoveInfo.LastSetpTime;
WorkLog("料串入料 :扫码结束【" + code + "】,等待取料机构来取料," + MoveInfo.MoveParam.PosInfo.ToStr()); WorkLog($"料串入料 :扫码结束【{code}】【{string.Join("|", LastCodeList)}】,等待取料机构来取料," + MoveInfo.MoveParam.PosInfo.ToStr());
} }
} }
...@@ -345,6 +345,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -345,6 +345,7 @@ namespace OnlineStore.DeviceLibrary
return false; return false;
} }
bool isScan = ConfigAppSettings.GetIntValue(Setting_Init.NeedScanCode).Equals(1); bool isScan = ConfigAppSettings.GetIntValue(Setting_Init.NeedScanCode).Equals(1);
Task<List<string>> scanTask = null;
private void IB11_ScanCode() private void IB11_ScanCode()
{ {
ClearWarnMsg("等待旋转轴离开料串超时"); ClearWarnMsg("等待旋转轴离开料串超时");
...@@ -369,18 +370,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -369,18 +370,15 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(6000)); MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(6000));
try try
{ {
Task<List<string>> scanTask = Task.Factory.StartNew(delegate scanTask = Task.Factory.StartNew(delegate
{ {
Robot.IOMove(IO_Type.CameraLed, IO_VALUE.HIGH); Robot.IOMove(IO_Type.CameraLed, IO_VALUE.HIGH);
List<string> codes = new List<string>();
List<string> codes = CodeManager.CameraScan(Config.CameraName, Name); codes = CodeManager.CameraScan(Config.CameraName, Name);
if (codes.Count <= 0) if (codes.Count <= 0)
{ {
LastCodeList = CodeManager.CameraScan(Config.CameraName, Name); LogUtil.error($"{Name} 第一次解码失败:{string.Join("|",codes)},重新解码");
} codes = CodeManager.CameraScan(Config.CameraName, Name);
else
{
LastCodeList = new List<string>(codes);
} }
//TODO 需要判断是否和上次的条码重复,重复的条码不可用 //TODO 需要判断是否和上次的条码重复,重复的条码不可用
bool isCanUse = true; bool isCanUse = true;
...@@ -400,10 +398,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -400,10 +398,10 @@ namespace OnlineStore.DeviceLibrary
} }
if (!isCanUse) if (!isCanUse)
{ {
LastCodeList = new List<string>(); codes = new List<string>();
} }
return LastCodeList; return codes;
}); });
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -592,7 +592,7 @@ namespace OnlineStore.XLRStore ...@@ -592,7 +592,7 @@ namespace OnlineStore.XLRStore
{ {
Camera._cam?.CloseAll(); Camera._cam?.CloseAll();
} }
CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode(false); CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode();
frm.ShowDialog(); frm.ShowDialog();
frm.Dispose(); frm.Dispose();
} }
......
...@@ -168,7 +168,10 @@ namespace OnlineStore.XLRStore ...@@ -168,7 +168,10 @@ namespace OnlineStore.XLRStore
{ {
//这里可以进一步地写日志 //这里可以进一步地写日志
LogUtil.error("【" + type + "】" + exceptionobj); LogUtil.error("【" + type + "】" + exceptionobj);
MiniDump.Write(Application.StartupPath + "\\ErrorDump\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-XLR-error.dmp"); string dir = Application.StartupPath + "\\ErrorDump\\";
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
MiniDump.Write(dir + DateTime.Now.ToString("yyyyMMddHHmmss") + "-XLR-error.dmp");
MessageBox.Show(exceptionobj, type); MessageBox.Show(exceptionobj, type);
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!