Commit 4ba25353 LN

扫码问题调整

1 个父辈 9c775eb9
此文件类型无法预览
此文件类型无法预览
......@@ -109,6 +109,7 @@ namespace OnlineStore.DeviceLibrary
LogInfo("StartReset: 重置灯状态,关闭所有皮带线,定位气缸下降 开始;");
//复位时默认为有托盘
IsInScanCode = false;
TrayLine1.LastTrayPosition = 1;
TrayLine2.LastTrayPosition = 1;
Line3LastTrayP = 1;
......@@ -276,7 +277,7 @@ namespace OnlineStore.DeviceLibrary
else
{
//皮带线3出口有料,分盘定位装置无料
if (Line3TurnIsStop() && IOValue(IO_Type.SeparateDevice_Check).Equals(IO_VALUE.LOW) && StationInfo_NG.TrayValue.Equals(IO_VALUE.HIGH)&&IsInScanCode.Equals(false))
if (Line3TurnIsStop() && IOValue(IO_Type.SeparateDevice_Check).Equals(IO_VALUE.LOW) && StationInfo_NG.TrayValue.Equals(IO_VALUE.HIGH)&& ScanIsEnd())
{
StartOutStoreMove(new InOutParam());
}
......@@ -369,7 +370,7 @@ namespace OnlineStore.DeviceLibrary
TrayLine2.Line3CanRun &&
ngNoTray &&
Line3HasTray()
&& (IsInScanCode.Equals(false))
&& (ScanIsEnd())
)
{
//判断皮带三还有料盘,需要转动一个工位
......@@ -435,9 +436,28 @@ namespace OnlineStore.DeviceLibrary
NewTypeScan();
}
}
private bool ScanIsEnd()
{
TimeSpan span = DateTime.Now - LastScanTime;
if (IsInScanCode && span.TotalMinutes < 1)
{
return false ;
}
return true;
}
private DateTime LastScanTime = DateTime.Now;
private void NewTypeScan(bool isfirst = false)
{
TimeSpan span = DateTime.Now - LastScanTime;
if (!ScanIsEnd())
{
LogInfo("NewTypeScan return ");
return;
}
IsInScanCode = true;
LastScanTime=DateTime.Now;
string LastCode = "";
Task.Factory.StartNew(delegate
{
......@@ -463,18 +483,23 @@ namespace OnlineStore.DeviceLibrary
{
try
{
LogUtil.info(hengyiName + "扫码工位:开始扫码,IsInScanCode=" + IsInScanCode);
List<string> LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
if (LastCodeList.Count <= 0)
LastCode = "";
StationInfo_Scan = new StationTrayInfo(IO_VALUE.HIGH, LastCode);
if (DeviceID.Equals(301))
{
Thread.Sleep(300);
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
StationInfo_NG = new StationTrayInfo(StationInfo_Scan.TrayValue, StationInfo_Scan.CodeStr);
}
LogUtil.info(hengyiName + "扫码工位:开始扫码,IsInScanCode=" + IsInScanCode);
List<string> LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), hengyiName);
if (LastCodeList.Count <= 0)
{
Thread.Sleep(300);
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), hengyiName);
}
//if (LastCodeList.Count <= 0)
//{
// Thread.Sleep(300);
// LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), Name);
//}
LastCode = SServerManager.ProcessCodeList(LastCodeList);
// Thread.Sleep(5000);
}
......@@ -547,9 +572,9 @@ namespace OnlineStore.DeviceLibrary
{
msg += "Move:" + MoveInfo.MoveType + " " + MoveInfo.MoveStep + " " + LastWidth + "=" + StationInfo_Move.CodeStr + "\n";
}
msg += "扫码工位:" + StationInfo_Scan.ToStr + "\n";
msg += "NG 工位:" + StationInfo_NG.ToStr + "\n";
msg += "IsInScanCode:" + IsInScanCode;
//msg += "NG 工位:" + StationInfo_NG.ToStr + "\n";
//msg += "扫码工位:" + StationInfo_Scan.ToStr + "\n";
//msg += "IsInScanCode:" + IsInScanCode;
// msg += "LastWidth:" + LastWidth + "\n";
return msg;
......
......@@ -87,7 +87,7 @@ namespace OnlineStore.DeviceLibrary
&& Line3TurnIsStop()
&& Line3Turn.CanStart()
&& ScanNgIsBack()
&& ( IsInScanCode.Equals(false))
&& (ScanIsEnd())
)
{
return true;
......
......@@ -399,6 +399,7 @@ namespace OnlineStore.DeviceLibrary
{
Thread.Sleep(50);
TimeSpan span = DateTime.Now - startTime;
bool isRestart = false;
if (span.TotalSeconds > 2 && IOManager.IOValue(moveDO, subType).Equals(IO_VALUE.LOW))
{
LogUtil.error(subType + " LineRunAndWait2 转动[" + moveDO + "][" + checkDI + "],已等待[" + FormUtil.GetSpanStr(span) + "],重写IO:" + moveDO);
......@@ -419,6 +420,7 @@ namespace OnlineStore.DeviceLibrary
{
if (canWhileCount > 0 && span.TotalMilliseconds < 800)
{
isRestart = true ;
canWhileCount--;
LogUtil.info(subType + " 异常停止,重新开始转动:[" + moveDO + "] [" + checkDI + "] 耗时 [" + FormUtil.GetSpanStr(span) + "]["+canWhileCount+"]");
LineRunAndWait(moveDO, checkDI, timeOutMS);
......@@ -444,10 +446,13 @@ namespace OnlineStore.DeviceLibrary
}
LastEndTime = DateTime.Now;
IOManager.IOMove(moveDO, IO_VALUE.LOW, subType);
Task.Factory.StartNew(delegate
if (!isRestart)
{
turnEnd?.Invoke(result.Equals(""));
});
Task.Factory.StartNew(delegate
{
turnEnd?.Invoke(result.Equals(""));
});
}
InTurn = false;
return result;
}
......
......@@ -104,6 +104,7 @@ namespace OnlineStore.DeviceLibrary
try
{
bitm= Camera._cam.GrabOneImage(cameraName);
//Camera._cam.Close(cameraName);
}
catch (Exception ex)
{
......@@ -144,11 +145,12 @@ namespace OnlineStore.DeviceLibrary
}
LogUtil.info(deviceName + " 【" + cameraName + "】取图片完成,开始转换并扫码");
System.Threading.Thread.Sleep(1);
// System.Threading.Thread.Sleep(1);
//转换托盘大概100-150ms,不打印日志
Bitmap bit = new Bitmap(bitmap);
LogUtil.info(deviceName + " 【" + cameraName + "】new Bitmap(bitmap);完成");
HalconDotNet.HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bit);
// LogUtil.info(" 相机【" + cameraName + "】转换图片完成,开始扫码");
LogUtil.info(deviceName + " 【" + cameraName + "】转换图片完成,开始扫码");
List<CodeInfo> cc = new List<CodeInfo>();
string r = "";
foreach (string codeType in codeTypeList)
......@@ -187,7 +189,7 @@ namespace OnlineStore.DeviceLibrary
catch (AccessViolationException e)
{
LogUtil.error(deviceName + " 扫码出现AccessViolationException异常:" + e.ToString());
GC.Collect();
// GC.Collect();
}
catch (Exception ex)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!