Commit 4ba25353 LN

扫码问题调整

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