Commit f1c775ee LN

1.清空入库任务时清空托盘。2.入料夹爪抓料后如果伺服检测信号亮,从服务器获取库位成功继续入库,未取到尺寸直接NG. 3.皮带线视觉识别图片保存功能。

1 个父辈 a6fb11bc
......@@ -709,6 +709,14 @@ namespace OnlineStore.AssemblyLine
}
else
{
//查找对应的托盘
TrayInfo tray = TrayManager.GetTrayInfo(param.TrayNumber);
if(tray!=null&&tray.IsFull&& tray.InoutPar.PosId.Equals(param.PosId) && tray.InoutPar.WareCode.Equals(param.WareCode))
{
LogUtil.info("手动清除入库任务前清空托盘:" + tray.ToStr());
TrayManager.UpdateTrayInfo(tray.TrayCode);
}
equipBean.RemoveInStore(param, "手动清除入库任务");
txtPosId.Clear();
}
......
......@@ -613,3 +613,23 @@ PRO,0,是否存放的大料盘,IsBigTray,1,,,,,
信号超时报警也需要响蜂鸣器。短皮带线二增加相机检测功能。
Config_DischargeLine_1.csv 需要增加一行配置(r_camera_2需要改为为真实相机名称):
PRO,0,短皮带线2监控相机,CameraName_2,r_camera_2,,,,,
抓料报警。
没有高度,使用
没有宽度尺寸 ,托盘标记为NG, 到检测点 NG
没有从服务器获取到尺寸NG 。
料串自动下降到信号灭。
流水线清理入库任务,同时清空托盘,给服务器发取消任务。
20221124修改:
1.清空入库任务时清空托盘。
2.入料夹爪抓料后如果伺服检测信号亮,从服务器获取库位成功继续入库,未取到尺寸直接NG.
3.皮带线视觉识别图片保存功能。
\ No newline at end of file
......@@ -841,7 +841,7 @@ namespace OnlineStore.DeviceLibrary
if (TrayLCylinderMoveCount < 10)
{
MoveInfo.NextMoveStep(LineMoveStep.FI_07_TrayLocation_Before);
InLog("料架入库" + MoveInfo.SLog + ":升降盘定位气缸第"+TrayLCylinderMoveCount+"次前进 2秒");
InLog("料架入库" + MoveInfo.SLog + ":升降盘定位气缸第" + TrayLCylinderMoveCount + "次前进 2秒");
TrayLCylinderBefore(null);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
}
......@@ -917,11 +917,40 @@ namespace OnlineStore.DeviceLibrary
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_17_UpdownAxisToP1))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_18_WaitNoLocationCheck);
InLog("料盘移栽" + MoveInfo.SLog + ":等待 SL_AxisLocationCheck=LOW");
InLog("料盘移栽" + MoveInfo.SLog + ":等待 SL_AxisLocationCheck=LOW,最多等待 5000,清空 LastHeight,LastWidth ");
LastHeight = 0;
LastWidth = 0;
MoveInfo.WaitList.Add(WaitResultInfo.WaitIO(IO_Type.SL_AxisLocationCheck, IO_VALUE.LOW));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(5000));
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_18_WaitNoLocationCheck))
{
//判断是否检测到
if (IOValue(IO_Type.SL_AxisLocationCheck).Equals(IO_VALUE.HIGH))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_18_GetReelSize);
InLog("料盘移栽" + MoveInfo.SLog + ":SL_AxisLocationCheck=HIGH, 从服务器获取尺寸 ");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(10000));
string code = CodeManager.ProcessCode(LastCodeList);
//从服务器获取尺寸信息
string result = SServerManager.GetReelSize(Name, code, out int width, out int height);
if (string.IsNullOrEmpty(result) && width > 0 && height > 0)
{
LastWidth = width;
LastHeight = height;
LogUtil.error(Name + "料盘移栽" + MoveInfo.SLog + ":SL_AxisLocationCheck =HIGH,从服务器获取到尺寸【" + LastWidth + "X" + LastHeight + "】 不需要计算高度直接继续,横移气缸上升 ");
}
else
{
//判断是否有宽度
LastWidth = GetNoHeightWidth();
LastHeight = 0;
LogUtil.error(Name + "料盘移栽" + MoveInfo.SLog + ":SL_AxisLocationCheck =HIGH,从服务器获取到尺寸结果【" + result + "】,【" + LastWidth + "X" + LastHeight + "】 不需要计算高度直接继续,横移气缸上升 ");
}
FI_19_GetHFromServer();
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.FI_19_BatchAxisToP3);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
LastWidth = GetWidth();
......@@ -936,6 +965,23 @@ namespace OnlineStore.DeviceLibrary
}
BatchAxisToP3(false);
}
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_19_GetHFromServer))
{
if (MoveCylineIsUp())
{
FI_21_CylinderGive();
}
else
{
MoveInfo.NextMoveStep(LineMoveStep.FI_20_SaveSize);
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移气缸放料SOL前先上升横移气缸");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
}
InLog("料盘移栽" + MoveInfo.SLog + ":记录 高度【" + LastHeight + "】宽度【" + LastWidth + "】,预扫码");
YuScanCode();
}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_19_BatchAxisToP3))
{
MoveInfo.NextMoveStep(LineMoveStep.FI_20_SaveSize);
......@@ -959,9 +1005,6 @@ namespace OnlineStore.DeviceLibrary
}
if (MoveCylineIsUp())
{
//MoveInfo.NextMoveStep(LineMoveStep.FI_21_CylinderGive);
//InLog("料盘移栽" + MoveInfo.SLog + ":上料横移气缸放料SOL");
//CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give);
FI_21_CylinderGive();
}
else
......@@ -970,24 +1013,7 @@ namespace OnlineStore.DeviceLibrary
InLog("料盘移栽" + MoveInfo.SLog + ":上料横移气缸放料SOL前先上升横移气缸");
CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
}
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
//LastHeight = GetHeight();
//if (LastWidth.Equals(7))
//{
// if (LastHeight > 16)
// {
// LogUtil.error(Name + "计算后高度" + LastWidth + "X" + LastHeight + ",七寸盘默认盘高最高=16,修改高度为16");
// LastHeight = 16;
// }
//}
//else
//{
// if (LastHeight < 12)
// {
// LogUtil.error(Name + "计算后高度" + LastWidth + "X" + LastHeight + ",非七寸盘默认盘高最低=12,修改高度为12");
// LastHeight = 12;
// }
//}
//判断是否还有料盘
if (IOValue(IO_Type.SL_AxisLocationCheck).Equals(IO_VALUE.LOW))
{
......@@ -1018,9 +1044,6 @@ namespace OnlineStore.DeviceLibrary
{
if (MoveCylineIsUp())
{
//MoveInfo.NextMoveStep(LineMoveStep.FI_21_CylinderGive);
//InLog("料盘移栽" + MoveInfo.SLog + ":上料横移气缸放料SOL");
//CylinderMove(MoveInfo, IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give);
FI_21_CylinderGive();
}
else
......@@ -1048,34 +1071,7 @@ namespace OnlineStore.DeviceLibrary
FI_25_WaitTray();
//FI_24_GetPosID();
}
//else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_23_WaitReelCheck))
//{
// FI_24_GetPosID();
//}
//else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_24_GetPosID))
//{
// FI_25_WaitTray();
//if (getPosTask.IsCompleted && LastPosParam != null)
//{
// MoveInfo.NextMoveStep(LineMoveStep.FI_25_WaitTray);
// MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
// if ((!LastPosParam.PlateH.Equals(LastHeight)) || (!LastPosParam.PlateW.Equals(LastWidth)))
// {
// InLog(" " + MoveInfo.SLog + " 原有料盘尺寸:【" + LastWidth + "X" + LastHeight + "】更改为服务器返回尺寸【" + LastPosParam.PlateW + "X" + LastPosParam.PlateH + "】 ");
// LastWidth = LastPosParam.PlateW;
// LastHeight = LastPosParam.PlateH;
// }
// InLog(" " + MoveInfo.SLog + " 开始拦截空托盘 " + LastPosParam.ToStr() + "");
// getPosIdMsg = "";
// ClearTimeoutAlarm("获取库位号超时");
//}
//else if (MoveInfo.IsTimeOut(120))
//{
// WarnMsg = MoveInfo.Name + "[" + MoveInfo.MoveStep + "] 获取库位号超时 "+ getPosIdMsg + " [" + Math.Round(MoveInfo.StepSpan().TotalSeconds, 1) + "]秒";
// LogUtil.error(WarnMsg, DeviceID * 1000 + 30);
// Alarm(LineAlarmType.IoSingleTimeOut);
//}
//}
else if (MoveInfo.MoveStep.Equals(LineMoveStep.FI_25_WaitTray))//TODO
{
if (SecondMoveInfo.MoveStep.Equals(LineMoveStep.MO_11_CodeRember))
......@@ -1272,9 +1268,26 @@ namespace OnlineStore.DeviceLibrary
#endregion
}
private void FI_19_GetHFromServer()
{
//尺寸正常,当做正常抓到的料 提升轴下降到信号灭
MoveInfo.NextMoveStep(LineMoveStep.FI_19_GetHFromServer);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
InLog("料盘移栽" + MoveInfo.SLog + ":SL_AxisLocationCheck =HIGH,从服务器获取到高度【" + LastHeight + "】,盘宽【" + LastWidth + "】不需要计算高度直接继续,横移气缸上升 ");
if (!CylinderIsOk(IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up))
{
CylinderMove(null, IO_Type.SL_MoveCylinder_Down, IO_Type.SL_MoveCylinder_Up);
}
else
{
CylinderMove(null, IO_Type.SL_MoveCylinder_Take, IO_Type.SL_MoveCylinder_Give);
}
}
private void FI_25_WaitTray()
{
if (getPosTask.IsCompleted && LastPosParam != null)
if ((getPosTask==null|| getPosTask.IsCompleted) && LastPosParam != null)
{
MoveInfo.NextMoveStep(LineMoveStep.FI_25_WaitTray);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
......@@ -1311,10 +1324,49 @@ namespace OnlineStore.DeviceLibrary
{
//MoveInfo.NextMoveStep(LineMoveStep.FI_24_GetPosID);
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(200));
InLog("清空LastPosResult,从服务器获取入库库位");
LastPosParam = null;
string code = CodeManager.ProcessCode(LastCodeList);
lastcode = code;
//如果尺寸或者高度为0,不需要获取库位号
if (LastWidth <= 0 || LastHeight <= 0)
{
InLog($"【" + code + "】清空LastPosResult,料盘尺寸 {LastWidth}X{LastHeight} 尺寸不完整,直接NG不需要获取库位号");
getPosTask = null;
LastPosParam = new InOutParam(0,lastcode,"",LastHeight,LastWidth,true) ;
LastPosParam.NgMsg =$"入库:{LastWidth}X{LastHeight} 尺寸不完整";
LastPosParam.InStoreNg = true;
LastPosParam.rfid = CurrShelfId;
LastPosParam.WareCode = lastcode;
LastPosParam.ManualJudgeNG = true;
//如果没有宽度,默认最宽料盘
if (LastWidth <= 0)
{
LastWidth = 15;
LastHeight = 56;
LastPosParam.PlateH = LastHeight;
LastPosParam.PlateW = LastWidth;
InLog($"【{ code }】宽度为0,默认最大料盘尺寸 {LastPosParam.PlateW}X{LastPosParam.PlateH} ,标记 ManualJudgeNG=true");
}
else
{
if (LastWidth.Equals(7))
{
LastHeight = 16;
}
else
{
LastHeight = 56;
}
LastPosParam.PlateH = LastHeight;
InLog($"【{ code }】宽度为{LastWidth},默认最大料盘尺寸 {LastPosParam.PlateW}X{LastPosParam.PlateH} ,标记 ManualJudgeNG=true");
}
return;
}
InLog("清空LastPosResult,从服务器获取入库库位");
getPosTask = Task.Factory.StartNew(delegate
{
//更新托盘条码信息
......@@ -1743,6 +1795,33 @@ namespace OnlineStore.DeviceLibrary
}
return width;
}
public int GetNoHeightWidth()
{
int width = 15;
if (IOValue(IO_Type.SL_TrayCheck4).Equals(IO_VALUE.HIGH))
{
width = 15;
}
else if (IOValue(IO_Type.SL_TrayCheck3).Equals(IO_VALUE.HIGH))
{
width = 13;
}
else if (IOValue(IO_Type.SL_TrayCheck2).Equals(IO_VALUE.HIGH))
{
width = 11;
}
else if (IOValue(IO_Type.SL_TrayCheck1).Equals(IO_VALUE.HIGH))
{
width = 7;
}
else
{
LogUtil.error(Name + "GetWidth :1234都未检测到,默认为7寸盘");
width = 0;
}
return width;
}
#endregion
#region 判断托盘是否需要
......
......@@ -599,7 +599,7 @@ namespace OnlineStore.DeviceLibrary
//如果当前正在出入库中,需要记录下来,等待空闲时执行
LogUtil.info(deviceName + "[" + moveEquip.Name + " ]入库命令: " + param.ToStr() + "加入等待列表中!");
InOutParam inOutParam = moveEquip.waitInStoreList.Find(s => param.PosId.Equals(s.PosId));
if(inOutParam!=null)
if (inOutParam != null)
{
moveEquip.waitInStoreList.Remove(inOutParam);
}
......@@ -823,9 +823,9 @@ namespace OnlineStore.DeviceLibrary
{
return (-1, data.data);
}
else if(data.code.Equals(100))
else if (data.code.Equals(100))
{
if(data.data.plateH>0&& data.data.plateW>0)
if (data.data.plateH > 0 && data.data.plateW > 0)
{
return (100, data.data);
}
......@@ -844,7 +844,67 @@ namespace OnlineStore.DeviceLibrary
{
LogUtil.error("getTaskInfo " + ex.ToString());
}
return (result,task);
return (result, task);
}
/// <summary>
///上料机构获取料盘高度
/// </summary>
private static string Addr_getReelHeight = "/rest/api/qisda/device/getReelSize";
public static string GetReelSize(string deviceName, string barcode, out int outWidth, out int outHeight)
{
outWidth = 0;
outHeight = 0;
string msg = "";
try
{
if (String.IsNullOrEmpty(barcode))
{
return msg = deviceName + "未扫到条码";
}
///rest/api/qisda/device/getReelSize
//传入参数: barcode
//返回: {code:0, msg:"",data:{"barcode":"ABC","plateW": 7,"plateH":8}}
//code= 0 表示正常,其他为异常
Dictionary<string, string> paramMap = new Dictionary<string, string>();
paramMap.Add("barcode", barcode);// barcode = 扫到的条码
string server = GetAddr(Addr_getReelHeight, paramMap);
DateTime startTime = DateTime.Now;
string resultStr = HttpHelper.Post(server, "");
LogUtil.info("GetReelSize " + FormUtil.GetSpanStr(DateTime.Now - startTime) + " 【" + server + "】【" + resultStr + "】");
//返回: { "code": 0, "msg":"ok", data: 7}
ReturnData4 serverResult = JsonHelper.DeserializeJsonToObject<ReturnData4>(resultStr);
if (serverResult == null)
{
return msg = deviceName + " GetReelSize 条码【 " + barcode + "】没有收到服务器反馈";
}
else if (serverResult.code.Equals(0).Equals(false))
{
return msg = deviceName + " GetReelSize 条码【 " + barcode + "】返回:" + "[" + serverResult.code + "]" + serverResult.msg;
}
if (serverResult.data == null)
{
return msg = deviceName + " GetReelSize 条码【 " + barcode + "】未解析到尺寸信息";
}
else
{
// data:料盘直径,= 7时升起气缸
outWidth = serverResult.data.plateW;
outHeight = serverResult.data.plateH;
LogUtil.info(deviceName + "GetReelSize 条码【 " + barcode + "】,获得尺寸:" + outWidth + "X" + outHeight);
return "";
}
}
catch (Exception ex)
{
LogUtil.error(deviceName + " ", ex);
return "GetReelSize 条码【 " + barcode + "】出错:"+ex.ToString();
}
}
}
......@@ -893,6 +953,32 @@ namespace OnlineStore.DeviceLibrary
public taskInfo data { get; set; }
}
//返回: {code:0, msg:"",data:{"barcode":"ABC","plateW": 7,"plateH":8}}
public class ReturnData4
{
// { "code":0,"msg":"ok","data":true}
public int code { get; set; }
public string msg { get; set; }
public reelInfo data { get; set; }
}
public class reelInfo
{
/// <summary>
/// 解析后的条码
/// </summary>
public string barcode { get; set; }
/// <summary>
/// 料盘尺寸
/// </summary>
public int plateW { get; set; }
/// <summary>
/// 料盘厚度
/// </summary>
public int plateH { get; set; }
}
public class taskInfo
{
/// <summary>
......
......@@ -41,7 +41,7 @@ namespace OnlineStore.DeviceLibrary
{
try
{
Bitmap b = GetReducedImage(a, 1024, 0);
Bitmap b = GetReducedImage(a, a.Width, a.Height);
a.Dispose();
EyemImage image = new EyemImage();
......
......@@ -165,22 +165,26 @@ dMinorStep 步进,默认1.0。
eyemTrackFeature(image, mask, tpRoi, hGlobal, ipResults.Length, tpHsvModel, ipResults, out EyemImage tpDstImg);
string resultStr = "";
int hasReelCount = 0;
for (int i = 0; i < ipResults.Length; i++)
{
if (ipResults[i] == 1)
{
Console.WriteLine("检测到{0}位置有料盘", i);
hasReelCount++;
}
resultStr += ipResults[i];
}
Bitmap dstBitmap = eyemCvtToBitmap(tpDstImg);
if (dstBitmap != null && SaveImage)
if (dstBitmap != null &&(hasReelCount<2) && SaveImage)
{
string dataFolder = DateTime.Now.ToString("yyyyMMdd");
string hourFolder = DateTime.Now.ToString("HH");
string date = cameraName.Trim().Replace('_', '-') + "-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + DateTime.Now.Millisecond;
string imageName = date + "-" + resultStr + ".bmp";
imgName = imageName;
string path = "D:\\image\\" + cameraName + "\\ResOut\\";
string path = "D:\\image\\" + cameraName + "\\ResOut\\"+ dataFolder+"\\"+hourFolder+"\\";
if (canSavePic(path))
{
dstBitmap.Save(path + imageName, ImageFormat.Jpeg);
......@@ -212,7 +216,7 @@ dMinorStep 步进,默认1.0。
int zhao =(int)( freespace / 1024);
if (zhao < 5)
{
LogUtil.error(volume + "盘剩余空间:" + freespace + "M, 不再保存料盘图片");
LogUtil.error(volume + "盘剩余空间:" + freespace + "G, 不再保存料盘图片");
return false;
}
return true;
......
......@@ -798,12 +798,25 @@ namespace OnlineStore.DeviceLibrary
/// </summary>
[Description("入料_取料完成_等待伺服检测信号消失")]
FI_18_WaitNoLocationCheck,
/// <summary>
/// 料盘移栽:等待没有伺服料盘检测信号,从服务器获取库位号
/// </summary>
[Description("入料_取料完成_等待没有伺服料盘检测信号,从服务器获取库位号")]
FI_18_GetReelSize,
/// <summary>
/// 料盘移栽:提升伺服运动到P3,横移气缸上升
/// </summary>
[Description("入料_取料完成_提升伺服运动到P3,横移气缸上升")]
FI_19_BatchAxisToP3,
/// <summary>
/// 料盘移栽:提升伺服运动到P3,横移气缸上升
/// </summary>
[Description("入料_取料完成_伺服检测信号一直亮,从服务器获取尺寸,横移气缸上升")]
FI_19_GetHFromServer,
/// <summary>
/// 料盘移栽:记录高度尺寸
/// </summary>
[Description("入料_取料完成_记录高度尺寸")]
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!