Commit 253ddc3c LN

1.皮带线未检测料盘时增加视觉检测标签。

2.出料机构放料到皮带线的报警发给服务器。
3.出料3阻挡2下降需要等待进仓17前阻挡无信号。
4.入料机构升降盘定位气缸前进10次。
1 个父辈 234c7c1f
......@@ -595,3 +595,15 @@ PRO,0,是否存放的大料盘,IsBigTray,1,,,,,
3. 修改相机配置:\Config\Camera.json文件:修改相机IP,用户名,密码
20221117 修改:
1.皮带线未检测料盘时增加视觉检测标签。
2.出料机构放料到皮带线的报警发给服务器。
3.出料3阻挡2下降需要等待进仓17前阻挡无信号。
4.入料机构升降盘定位气缸逻辑修改。
需要修改:
需要关机时,先判断所有横移都无托盘时再关机。
横移先记录状态,需要关机时横移不移托盘,等所有横移都无托盘时关机
\ No newline at end of file
......@@ -536,15 +536,41 @@ namespace OnlineStore.DeviceLibrary
if (IOValue(IO_Type.ExitTray_Check3).Equals(IO_VALUE.LOW))
{
UpdateScanInfo(IO_VALUE.LOW, "");
(bool hasReel, List<string> LastCodeList) = CodeManager.CameraCheckAndScan(Config.GetCameraList(), hengyiName, true);
if (hasReel)
{
LastCode = SServerManager.ProcessCodeList(LastCodeList);
if (LastCodeList.Count > 0)
{
UpdateScanInfo(IO_VALUE.HIGH, LastCode);
LogUtil.info(hengyiName + "ExitTray_Check3不亮,但视觉识别有料,且扫到条码,更改为有料: " + LastCode);
}
else
{
UpdateScanInfo(IO_VALUE.HIGH, LastCode);
LogUtil.info(hengyiName + "ExitTray_Check3不亮,但视觉识别有料,未扫到条码,更改为有料: " + LastCode);
}
if (DeviceID.Equals(301))
{
if (Line3LastTrayP > Line3MaxPosition) { Line3LastTrayP = Line3MaxPosition; }
// StationInfo_NG = new StationTrayInfo(StationInfo_Scan.TrayValue, StationInfo_Scan.CodeStr);
}
else
{
if (Line3LastTrayP > Line3MaxPosition - 1)
{
Line3LastTrayP = Line3MaxPosition - 1;
}
}
}
IsInScanCode = false;
}
else
{
string resStr = "";
bool hasR=false;
bool hasReel=false;
if(IOValue(IO_Type.ExitTray_Check3).Equals(IO_VALUE.HIGH))
bool hasR = false;
bool hasReel = false;
if (IOValue(IO_Type.ExitTray_Check3).Equals(IO_VALUE.HIGH))
{
hasReel = true;
resStr += "信号检测到有料盘,";
......@@ -573,7 +599,7 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(hengyiName + "扫码工位:开始扫码,IsInScanCode=" + IsInScanCode);
List<string> LastCodeList = CodeManager.CameraScan(Config.GetCameraList(), hengyiName, true);
hasR = CodeManager.HasRightCode(LastCodeList.ToArray());
if(LastCodeList.Count>0)
if (LastCodeList.Count > 0)
{
hasReel = true;
resStr += "第一次扫到条码,";
......@@ -606,7 +632,7 @@ namespace OnlineStore.DeviceLibrary
finally
{
if(hasReel)
if (hasReel)
{
UpdateScanInfo(IO_VALUE.HIGH, LastCode);
}
......
......@@ -598,6 +598,21 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
/// <summary>
/// 升降盘是否在前进端
/// </summary>
public bool IsTrayLCylinderBefore()
{
if (IOValue(IO_Type.SL_TrayLocation1_After).Equals(IO_VALUE.LOW) &&
IOValue(IO_Type.SL_TrayLocation1_Before).Equals(IO_VALUE.HIGH) &&
IOValue(IO_Type.SL_TrayLocation2_After).Equals(IO_VALUE.LOW) &&
IOValue(IO_Type.SL_TrayLocation2_Before).Equals(IO_VALUE.HIGH))
{
return true;
}
return false;
}
/// <summary>
/// 判断上料横移机构是否可以横移运动
......
......@@ -812,24 +812,48 @@ namespace OnlineStore.DeviceLibrary
InLog("料架入库" + MoveInfo.SLog + ":升降盘定位气缸第一次前进 2秒,清空条码信息");
LastCodeList = new List<string>();
NextCodeList = new List<string>();
TrayLCylinderMoveCount = 1;
TrayLCylinderBefore(null);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_07_TrayLocation_Before))
{
//判断信号是否到位,到位的话直接下一步,
if (IsTrayLCylinderBefore())
{
LoopCount = 0;
MoveInfo.NextMoveStep(LineMoveStep.FI_10_AxisUpMove);
InLog("料架入库" + MoveInfo.SLog + ":升降盘前进次数:" + TrayLCylinderMoveCount + "已到位,上料轴开始慢速上升到P3点,等待检测到料盘,设置LoopCount = 0");
MoveInfo.ShelfNoTray = false;
BatchAxisToP3();
}
else
{
// 信号不到位,后退,再次循环
MoveInfo.NextMoveStep(LineMoveStep.FI_08_TrayLocation_Back);
InLog("料架入库" + MoveInfo.SLog + ":升降盘定位气缸后退,等待再次前进");
InLog("料架入库" + MoveInfo.SLog + ":升降盘定位气缸第" + TrayLCylinderMoveCount + "次后退,等待再次前进");
TrayLCylinderAfter(MoveInfo);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_08_TrayLocation_Back))
{
TrayLCylinderMoveCount++;
if (TrayLCylinderMoveCount < 10)
{
MoveInfo.NextMoveStep(LineMoveStep.FI_07_TrayLocation_Before);
InLog("料架入库" + MoveInfo.SLog + ":升降盘定位气缸第"+TrayLCylinderMoveCount+"次前进 2秒");
TrayLCylinderBefore(null);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.FI_09_TrayLocation_Before);
InLog("料架入库" + MoveInfo.SLog + ":升降盘定位气缸前进,清空条码信息");
InLog("料架入库" + MoveInfo.SLog + ":升降盘定位气缸第" + TrayLCylinderMoveCount + "次前进,清空条码信息");
LastCodeList = new List<string>();
NextCodeList = new List<string>();
TrayLCylinderBefore(MoveInfo);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_09_TrayLocation_Before))
{
LoopCount = 0;
......@@ -1640,6 +1664,8 @@ namespace OnlineStore.DeviceLibrary
private int LastWidth = 0;
private List<string> LastCodeList = new List<string>();
private List<string> NextCodeList = new List<string>();
private int TrayLCylinderMoveCount=0;//升降盘气缸已运动次数
private int GetHeight()
{
LastHeight = 0;
......
......@@ -363,21 +363,42 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.NextMoveStep(LineMoveStep.FO_07_TrayLocation_Before);
OutLog("准备出库料架 " + MoveInfo.SLog + " :升降盘定位气缸第一次前进 2秒");
TrayLCylinderMoveCount = 1;
TrayLCylinderBefore(null);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_07_TrayLocation_Before))
{ //判断信号是否到位,到位的话直接下一步,
if (IsTrayLCylinderBefore())
{
MoveInfo.NextMoveStep(LineMoveStep.FO_10_AxisUpMove);
OutLog("准备出库料架 " + MoveInfo.SLog + " :第" + TrayLCylinderMoveCount + "次上升到位,上料轴开始慢速上升到P3点,等待检测到料盘");
BatchAxisToP3();
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.FO_08_TrayLocation_Back);
OutLog("准备出库料架 " + MoveInfo.SLog + " :升降盘定位气缸后退,等待再次前进");
OutLog("准备出库料架 " + MoveInfo.SLog + " :升降盘定位气缸第" + TrayLCylinderMoveCount + "次后退,等待再次前进");
TrayLCylinderAfter(MoveInfo);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_08_TrayLocation_Back))
{
TrayLCylinderMoveCount++;
if (TrayLCylinderMoveCount < 10)
{
MoveInfo.NextMoveStep(LineMoveStep.FO_07_TrayLocation_Before);
OutLog("准备出库料架 " + MoveInfo.SLog + " :升降盘定位气缸第" + TrayLCylinderMoveCount + "次前进 2秒");
TrayLCylinderBefore(null);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.FO_09_TrayLocation_Before);
OutLog("准备出库料架 " + MoveInfo.SLog + " :升降盘定位气缸前进");
OutLog("准备出库料架 " + MoveInfo.SLog + " :升降盘定位气缸第" + TrayLCylinderMoveCount + "次前进");
TrayLCylinderBefore(MoveInfo);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FO_09_TrayLocation_Before))
{
MoveInfo.NextMoveStep(LineMoveStep.FO_10_AxisUpMove);
......
......@@ -1125,7 +1125,24 @@ namespace OnlineStore.DeviceLibrary
//}
foreach (EquipBase equip in AllEquipMap.Values)
{
if (equip.alarmType.Equals(LineAlarmType.None) || equip.WarnMsg.Contains("获取库位号超时") ||
if (equip.alarmType.Equals(LineAlarmType.IoSingleTimeOut))
{
if (equip is ProvidingEquip && equip.MoveInfo.MoveStep.Equals(LineMoveStep.PO_09_CylinderRelax))
{
alarmList.Add(new AlarmMsg(equip.Name, "line." + equip.Name + "_" + equip.alarmType, equip.WarnMsg));
}
else if (equip is FeedingEquip && equip.MoveInfo.MoveStep.Equals(LineMoveStep.FI_09_TrayLocation_Before))
{
alarmList.Add(new AlarmMsg(equip.Name, "line." + equip.Name + "_" + equip.alarmType, equip.WarnMsg));
}
else if (equip is FeedingEquip && equip.MoveInfo.MoveStep.Equals(LineMoveStep.FO_09_TrayLocation_Before))
{
alarmList.Add(new AlarmMsg(equip.Name, "line." + equip.Name + "_" + equip.alarmType, equip.WarnMsg));
}
}
//出料机构->皮带线放料,等待夹爪信号灭的报警也发给服务器
else if (equip.alarmType.Equals(LineAlarmType.None) || equip.WarnMsg.Contains("获取库位号超时") ||
equip.alarmType.Equals(LineAlarmType.IoSingleTimeOut))
{
continue;
......
......@@ -313,10 +313,11 @@ namespace OnlineStore.DeviceLibrary
}
else
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
MO_16_Stop2Down();
//SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
//CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
//IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
//SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
}
}
else
......@@ -668,19 +669,36 @@ namespace OnlineStore.DeviceLibrary
//SecondMoveInfo.NextMoveStep(LineMoveStep.MO_15_WaitCanGo);
//CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,等待 NextStopCheck=0");
// SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.NextStopCheck, IO_VALUE.LOW));
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
MO_16_Stop2Down();
//SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
//CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
//IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
//SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
}
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_15_WaitCanGo))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
if (DeviceID.Equals(203)){
MoveEquip moveEquip = LineManager.Line.GetMoveByDId(17);
if (moveEquip.IOValue(IO_Type.StopCylinder_Check1).Equals(IO_VALUE.LOW))
{
MO_16_Stop2Down();
}
else if (SecondMoveInfo.IsTimeOut(60))
{
MoveTimeoutAlarm(MoveInfo, "等待进仓17前阻挡信号X51=LOW超时");
}
}
else
{
MO_16_Stop2Down();
}
//SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
//CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
//IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
//SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
}
else if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_16_Stop2Down))
{
......@@ -713,6 +731,27 @@ namespace OnlineStore.DeviceLibrary
}
#endregion
}
private void MO_16_Stop2Down()
{
if (DeviceID.Equals(203)) {
MoveEquip move17 = LineManager.Line.GetMoveByDId(17);
if (move17.IOValue(IO_Type.StopCylinder_Check1).Equals(IO_VALUE.HIGH))
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_15_WaitCanGo);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
LogUtil.info(Name + "托盘放行 " + SecondMoveInfo.SLog + " ,当前出料3,进仓17前阻挡有料,暂不放行托盘");
return;
}
}
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_16_Stop2Down);
CheckLog("托盘放行 " + SecondMoveInfo.SLog + " ,阻挡2下降");
IOMove(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH);
SecondMoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.StopCylinder_Down2, IO_VALUE.HIGH));
}
private void MO_14_TopDown()
{
SecondMoveInfo.NextMoveStep(LineMoveStep.MO_14_TopDown);
......
......@@ -548,5 +548,173 @@ namespace OnlineStore.DeviceLibrary
}
return ReplaceCode(code);
}
[HandleProcessCorruptedStateExceptions]
public static (bool,List<string>) CameraCheckAndScan(List<string> cameraList, string deviceName, bool findRightCodeBreak = false, int timeOut = 1500)
{
bool isPreScan = deviceName.EndsWith("预扫码");
List<string> codeList = new List<string>();
bool hasReel = false;
if (cameraList == null || cameraList.Count <= 0)
{
return (false,codeList);
}
try
{
foreach (string cameraName in cameraList)
{
if (cameraName.Trim().Equals(""))
{
continue;
}
ScanCount++;
DateTime startTime = DateTime.Now;
if (deviceName != "")
{
LogUtil.debug(deviceName + " 【" + cameraName + "】开始取图片");
}
Bitmap bmp = null;
HalconDotNet.HObject ho_Image = null;
bool findRightCode = false;
try
{
//取照片完成,先检测是否有料,有料才需要扫码,否则直接返回
hasReel = EyemManager.ReelCheck(bmp);
if (!hasReel)
{
return (false, codeList);
}
LogUtil.info(deviceName + " 【" + cameraName + "】视觉识别有料【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】,开始扫码");
ho_Image = Camera._cam.CaptureOnImage(cameraName, out bmp);
if (ho_Image == null)
{
LogUtil.error(deviceName + " 【" + cameraName + "】取图片失败[" + Camera._cam.ErrInfo + "],关闭相机");
CloseCamera(cameraName);
continue;
}
string r = "";
bool eyemNoCode = false;
Task eyemtask = Task.Factory.StartNew(delegate
{
List<CodeInfo> tlci = EyemDecode.ModelDecoder(ref bmp);
foreach (CodeInfo code in tlci)
{
LogUtil.info(deviceName + " 【" + cameraName + "】[eyemDecode]" + code.CodeType + "(X: " + code.X + ",Y: " + code.Y + ") " + code.CodeStr);
string str = CodeManager.ReplaceCode(code.CodeStr);
if (!codeList.Contains(str))
{
codeList.Add(str);
r = r + "##eyem|" + code.CodeType + "|" + str;
if (!findRightCode)
{
findRightCode = HasRightCode(str);
}
}
}
});
//最多等待60秒
bool taskResult = eyemtask.Wait(60000);
if (!taskResult)
{
LogUtil.error(deviceName + " 【" + cameraName + "】eyem扫码超时");
eyemNoCode = true;
}
if (!findRightCode)
{
try
{
List<CodeInfo> cc = new List<CodeInfo>();
eyemNoCode = true;
RemoteDecodeHelper.RemoteDecodeParam remoteDecodeParam = new RemoteDecodeHelper.RemoteDecodeParam
{
codeTypeList = allCodeTypeList.ToArray(),
codeCount = 3,
timeout = 3000
};
cc = RemoteDecodeHelper.DecodeRequest(ho_Image, remoteDecodeParam);
if (cc != null)
{
foreach (CodeInfo c in cc)
{
string str = CodeManager.ReplaceCode(c.CodeStr);
if (!codeList.Contains(str))
{
codeList.Add(str);
r = r + "##halcon|" + c.CodeType + "|" + str;
if (!findRightCode)
{
findRightCode = HasRightCode(str);
}
}
}
}
}
catch (Exception ex)
{
LogUtil.error(deviceName + " RemoteDecodeHelper扫码出错:" + ex.ToString());
}
}
//if (!findRightCode && SaveErrorImageToFile.Equals(1))
if (SaveImage || (((!findRightCode) || eyemNoCode) && (!isPreScan)))
{
//如果halcon没扫出的,
string nameStr = "";
if (findRightCode && eyemNoCode)
{
nameStr = "eyem";
}
SaveImageToFile(deviceName, cameraName + nameStr, bmp);
}
if (deviceName != "" || r != "")
{
LogUtil.info(deviceName + " 【" + cameraName + "】识别扫码完成【" + FormUtil.GetSpanStr(DateTime.Now - startTime) + "】[" + findRightCode + "]" + ScanCount + " :" + r);
}
}
catch (AccessViolationException e)
{
LogUtil.error(deviceName + " 扫码出现AccessViolationException异常,关闭相机【" + cameraName + "】:" + e.ToString());
Camera._cam.Close(cameraName);
// GC.Collect();
}
catch (Exception ex)
{
LogUtil.error(deviceName + " 扫码出错:" + ex.ToString());
}
finally
{
if (ho_Image != null)
{
ho_Image.Dispose();
ho_Image = null;
}
// GC.Collect();
Task.Delay(10);
}
}
}
catch (AccessViolationException e)
{
LogUtil.error(deviceName + " 扫码出现AccessViolationException异常,关闭所有相机:" + e.ToString());
Camera._cam.CloseAll();
//GC.Collect();
}
catch (Exception ex)
{
LogUtil.error(deviceName + " 扫码出错:" + ex.ToString());
}
return (hasReel, codeList);
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!