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,14 +178,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -178,14 +178,6 @@ namespace OnlineStore.DeviceLibrary
} }
} }
} }
if (!findRightCode)
{
SaveNGImageToFile(deviceName, cameraName, bmp);
}
else
{
SaveOKImageToFile(deviceName, cameraName, bmp);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -193,7 +185,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -193,7 +185,14 @@ namespace OnlineStore.DeviceLibrary
} }
} }
LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】[" + findRightCode + "]" + ScanCount + " :" + r); LogUtil.info(deviceName + " 【" + cameraName + "】扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】[" + findRightCode + "]" + ScanCount + " :" + r);
if (!findRightCode)
{
SaveNGImageToFile(deviceName, cameraName, bmp);
}
else
{
SaveOKImageToFile(deviceName, cameraName, bmp);
}
} }
catch (AccessViolationException e) catch (AccessViolationException e)
{ {
......
...@@ -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,42 +370,39 @@ namespace OnlineStore.DeviceLibrary ...@@ -369,42 +370,39 @@ 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 }
{ //TODO 需要判断是否和上次的条码重复,重复的条码不可用
LastCodeList = new List<string>(codes); bool isCanUse = true;
} //判断是否可用
//TODO 需要判断是否和上次的条码重复,重复的条码不可用 foreach (string nC in LastCodeList)
bool isCanUse = true; {
//判断是否可用 foreach (string n in preCodeList)
foreach (string nC in LastCodeList) {
{ //if(CodeManager.HasRightCode(nC))
foreach (string n in preCodeList) if (nC.Length > 15 && nC.Equals(n))
{ {
//if(CodeManager.HasRightCode(nC)) LogUtil.error(Name + "扫码结果【" + nC + "】与上个条码【" + n + "】重复,扫码结果不可用");
if (nC.Length > 15 && nC.Equals(n)) isCanUse = false;
{ break;
LogUtil.error(Name + "扫码结果【" + nC + "】与上个条码【" + n + "】重复,扫码结果不可用"); }
isCanUse = false; }
break; }
} if (!isCanUse)
} {
} codes = new List<string>();
if (!isCanUse) }
{
LastCodeList = 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!