Commit 15312fe1 张东亮

扫码线程处理

1 个父辈 11c360e3
此文件类型无法预览
......@@ -41,7 +41,8 @@
<Reference Include="Asa.Camera.VisionLib">
<HintPath>..\..\dll\Asa.Camera.VisionLib.dll</HintPath>
</Reference>
<Reference Include="CodeLibrary">
<Reference Include="CodeLibrary, Version=1.0.8182.32076, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\CodeLibrary.dll</HintPath>
</Reference>
<Reference Include="halcondotnet">
......
......@@ -45,7 +45,7 @@ namespace OnlineStore.DeviceLibrary
LoadCamera(false);
CodeLibrary.HDCodeLearnHelper.LoadConfig("", codeStr);
CodeLibrary.EyemDecode.InitModel();
//CodeLibrary.EyemDecode.InitModel();
}
catch (Exception ex)
{
......@@ -178,14 +178,6 @@ namespace OnlineStore.DeviceLibrary
}
}
}
if (!findRightCode)
{
SaveNGImageToFile(deviceName, cameraName, bmp);
}
else
{
SaveOKImageToFile(deviceName, cameraName, bmp);
}
}
catch (Exception ex)
{
......@@ -193,7 +185,14 @@ namespace OnlineStore.DeviceLibrary
}
}
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)
{
......
......@@ -452,8 +452,9 @@ namespace OnlineStore.DeviceLibrary
}
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;
}
}
......
......@@ -267,7 +267,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(StepEnum.IB13_ScanOK);
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
return false;
}
bool isScan = ConfigAppSettings.GetIntValue(Setting_Init.NeedScanCode).Equals(1);
Task<List<string>> scanTask = null;
private void IB11_ScanCode()
{
ClearWarnMsg("等待旋转轴离开料串超时");
......@@ -369,42 +370,39 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(6000));
try
{
Task<List<string>> scanTask = Task.Factory.StartNew(delegate
{
Robot.IOMove(IO_Type.CameraLed, IO_VALUE.HIGH);
List<string> codes = CodeManager.CameraScan(Config.CameraName, Name);
if (codes.Count <= 0)
{
LastCodeList = CodeManager.CameraScan(Config.CameraName, Name);
}
else
{
LastCodeList = new List<string>(codes);
}
//TODO 需要判断是否和上次的条码重复,重复的条码不可用
bool isCanUse = true;
//判断是否可用
foreach (string nC in LastCodeList)
{
foreach (string n in preCodeList)
{
//if(CodeManager.HasRightCode(nC))
if (nC.Length > 15 && nC.Equals(n))
{
LogUtil.error(Name + "扫码结果【" + nC + "】与上个条码【" + n + "】重复,扫码结果不可用");
isCanUse = false;
break;
}
}
}
if (!isCanUse)
{
LastCodeList = new List<string>();
}
scanTask = Task.Factory.StartNew(delegate
{
Robot.IOMove(IO_Type.CameraLed, IO_VALUE.HIGH);
List<string> codes = new List<string>();
codes = CodeManager.CameraScan(Config.CameraName, Name);
if (codes.Count <= 0)
{
LogUtil.error($"{Name} 第一次解码失败:{string.Join("|",codes)},重新解码");
codes = CodeManager.CameraScan(Config.CameraName, Name);
}
//TODO 需要判断是否和上次的条码重复,重复的条码不可用
bool isCanUse = true;
//判断是否可用
foreach (string nC in LastCodeList)
{
foreach (string n in preCodeList)
{
//if(CodeManager.HasRightCode(nC))
if (nC.Length > 15 && nC.Equals(n))
{
LogUtil.error(Name + "扫码结果【" + nC + "】与上个条码【" + n + "】重复,扫码结果不可用");
isCanUse = false;
break;
}
}
}
if (!isCanUse)
{
codes = new List<string>();
}
return LastCodeList;
});
return codes;
});
}
catch (Exception ex)
{
......
......@@ -592,7 +592,7 @@ namespace OnlineStore.XLRStore
{
Camera._cam?.CloseAll();
}
CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode(false);
CodeLibrary.FrmCodeDecode frm = new CodeLibrary.FrmCodeDecode();
frm.ShowDialog();
frm.Dispose();
}
......
......@@ -168,7 +168,10 @@ namespace OnlineStore.XLRStore
{
//这里可以进一步地写日志
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);
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!