增加给Ok料仓放盖子之前,用相机确认产品是否放好

master
lhiven 11 months ago
parent d37d205019
commit ace1f5ec61

@ -567,7 +567,7 @@ namespace Rs.MotionPlat.Flow
{
//料盘放满了,更换料盘
DischargeModuleGoSafePosFlow.Instance.GoSafePostion();
TakeTrayFlow.Instance.Take(ETrayType.Empty, ETrayType.Ok);
TakeTrayFlow.Instance.Take(ETrayType.Empty, ETrayType.Ok,true,true);
GlobalTray.OkTary.ChangeStatus(ESlotStatus.NotHave);
ThreePointLocationFlow.Instance.Location(ETrayType.Ok);
//料盘已满
@ -636,7 +636,7 @@ namespace Rs.MotionPlat.Flow
}
break;
case EDischargeFlowStep.:
TakeTrayFlow.Instance.Take(ETrayType.Empty, ETrayType.Ok);
TakeTrayFlow.Instance.Take(ETrayType.Empty, ETrayType.Ok,true,true);
TakeTrayFlow.Instance.Take(ETrayType.Empty, ETrayType.Input);
Task.Run(() => {
StockManager.DischargeFinish(1);

@ -5,6 +5,7 @@ using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Entitys;
using Rs.MotionPlat.Flow.Common;
using Rs.MotionPlat.Flow.NormalFlow;
using Rs.MotionPlat.Flow.SubFlow;
using Rs.MotionPlat.Module;
using Rs.MotionPlat.Vision;
using System;
@ -30,10 +31,12 @@ namespace Rs.MotionPlat.Flow
,
,
,
,
,
,
,
//到拍照位,
//等待运动到拍照位,
//通知上料仓拍照,
//处理上料仓拍照数据,
,
,
,
,
,
@ -95,7 +98,7 @@ namespace Rs.MotionPlat.Flow
/// <param name="takeTrayFinishedEvent">搬运料盘被拿起后事件</param>
/// <param name="arrivedDumpPosEvent">到达放料盘位上方事件</param>
/// <param name="dumpTrayFinishedEvent">放料盘完成后事件</param>
public void Take(ETrayType fromTray, ETrayType toTray,bool isNeedGoDown=true)
public void Take(ETrayType fromTray, ETrayType toTray,bool isNeedGoDown=true,bool placeTrayGrab=false)
{
switch (fromTray)
{
@ -272,79 +275,94 @@ namespace Rs.MotionPlat.Flow
case ETakeTrayFlowStep.:
if(fromTray== ETrayType.Input)
{
step = ETakeTrayFlowStep.;
step = ETakeTrayFlowStep.;
}
else
{
step = ETakeTrayFlowStep.;
}
break;
case ETakeTrayFlowStep.:
targetPosition.TakeTrayX = GlobalVar.InputStockGrabPos;
if(GroupAxisMove.TakeXMove(GetClassName(), targetPosition.TakeTrayX, GlobalVar.WholeSpeed))
{
logInfo = GetClassName() + $"到料仓{toTray}拍照位";
MessageQueue.Instance.Insert(logInfo);
step = ETakeTrayFlowStep.;
}
break;
case ETakeTrayFlowStep.:
if(Ops.IsStop("TakeTrayX"))
{
step = ETakeTrayFlowStep.;
}
break;
case ETakeTrayFlowStep.:
if(GlobalVar.RunSpace)
case ETakeTrayFlowStep.:
StockGrabFlow.Instance.Grab(fromTray);
if(placeTrayGrab)
{
step = ETakeTrayFlowStep.;
}
else
{
vr = VisionHelper.Grab(Vision.EVisionScene.HaveOrNot);
if (vr.Result)
{
step = ETakeTrayFlowStep.;
}
else
{
Msg.ShowError("有无相机拍照失败,点击确定后重拍");
}
}
break;
case ETakeTrayFlowStep.:
List<int> noHasProduct = new List<int>();
for(int i=0;i<vr.Products.Length;i++)
{
if (vr.Products[i]=='1')
{
GlobalTray.InputTray.ChangeStatus(i + 1, ESlotStatus.Have);
}
else
{
noHasProduct.Add(i + 1);
GlobalTray.InputTray.ChangeStatus(i + 1, ESlotStatus.NotHave);
}
}
if(noHasProduct.Count>0)
{
EButtonType btn = Msgbox.ShowDialog(EButtonType.Retry | EButtonType.Skip, "料盘未放满,请处理","tray info",true);
if(btn== EButtonType.Retry)
{
step = ETakeTrayFlowStep.;
}
else if(btn== EButtonType.Skip)
{
step = ETakeTrayFlowStep.;
}
step = ETakeTrayFlowStep.;
}
else
{
step = ETakeTrayFlowStep.;
}
break;
case ETakeTrayFlowStep.:
StockGrabFlow.Instance.Grab(toTray);
step = ETakeTrayFlowStep.;
break;
//case ETakeTrayFlowStep.到拍照位:
// targetPosition.TakeTrayX = GlobalVar.InputStockGrabPos;
// if(GroupAxisMove.TakeXMove(GetClassName(), targetPosition.TakeTrayX, GlobalVar.WholeSpeed))
// {
// logInfo = GetClassName() + $"到料仓{toTray}拍照位";
// MessageQueue.Instance.Insert(logInfo);
// step = ETakeTrayFlowStep.等待运动到拍照位;
// }
// break;
//case ETakeTrayFlowStep.等待运动到拍照位:
// if(Ops.IsStop("TakeTrayX"))
// {
// step = ETakeTrayFlowStep.通知上料仓拍照;
// }
// break;
//case ETakeTrayFlowStep.通知上料仓拍照:
// if(GlobalVar.RunSpace)
// {
// step = ETakeTrayFlowStep.到放料盘上方;
// }
// else
// {
// vr = VisionHelper.Grab(Vision.EVisionScene.HaveOrNot);
// if (vr.Result)
// {
// step = ETakeTrayFlowStep.处理上料仓拍照数据;
// }
// else
// {
// Msg.ShowError("有无相机拍照失败,点击确定后重拍");
// }
// }
// break;
//case ETakeTrayFlowStep.处理上料仓拍照数据:
// List<int> noHasProduct = new List<int>();
// for(int i=0;i<vr.Products.Length;i++)
// {
// if (vr.Products[i]=='1')
// {
// GlobalTray.InputTray.ChangeStatus(i + 1, ESlotStatus.Have);
// }
// else
// {
// noHasProduct.Add(i + 1);
// GlobalTray.InputTray.ChangeStatus(i + 1, ESlotStatus.NotHave);
// }
// }
// if(noHasProduct.Count>0)
// {
// EButtonType btn = Msgbox.ShowDialog(EButtonType.Retry | EButtonType.Skip, "料盘未放满,请处理","tray info",true);
// if(btn== EButtonType.Retry)
// {
// step = ETakeTrayFlowStep.通知上料仓拍照;
// }
// else if(btn== EButtonType.Skip)
// {
// step = ETakeTrayFlowStep.到放料盘上方;
// }
// }
// else
// {
// step = ETakeTrayFlowStep.到放料盘上方;
// }
// break;
case ETakeTrayFlowStep.:
//if (DischargeFlow.Instance.XYCanGoLocalArea())
{

@ -0,0 +1,138 @@
using Rs.Controls;
using Rs.Framework;
using Rs.MotionPlat.Commom;
using Rs.MotionPlat.Vision;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rs.MotionPlat.Flow.SubFlow
{
enum EStockGrabFlowStep
{
,
,
,
}
/// <summary>
/// 料仓拍照流程
/// </summary>
public class StockGrabFlow
{
bool finished = true;
EStockGrabFlowStep flowStep = EStockGrabFlowStep.;
private static StockGrabFlow instance;
public static StockGrabFlow Instance
{
get
{
if(instance == null)
instance = new StockGrabFlow();
return instance;
}
}
private TargetPosition targetPosition = new TargetPosition();
private string logInfo = string.Empty;
VisionResult vr = new VisionResult();
public void Grab(ETrayType trayType)
{
if (finished)
finished = false;
else
return;
flowStep = EStockGrabFlowStep.;
while (!finished)
{
switch (flowStep)
{
case EStockGrabFlowStep.:
if(trayType== ETrayType.Input)
{
targetPosition.TakeTrayX = GlobalVar.InputStockGrabPos;
}
if(trayType== ETrayType.Ok)
{
targetPosition.TakeTrayX = GlobalVar.OkStockGrabPos;
}
if (GroupAxisMove.TakeXMove(GetClassName(), targetPosition.TakeTrayX, GlobalVar.WholeSpeed))
{
logInfo = GetClassName() + $"到料仓{trayType}拍照位";
MessageQueue.Instance.Insert(logInfo);
flowStep = EStockGrabFlowStep.;
}
break;
case EStockGrabFlowStep.:
if (Ops.IsStop("TakeTrayX"))
{
flowStep = EStockGrabFlowStep.;
}
break;
case EStockGrabFlowStep.:
vr = VisionHelper.Grab(Vision.EVisionScene.HaveOrNot);
if (vr.Result)
{
flowStep = EStockGrabFlowStep.;
}
else
{
Msg.ShowError("有无相机拍照失败,点击确定后重拍");
}
break;
case EStockGrabFlowStep.:
List<int> noHasProduct = new List<int>();
for (int i = 0; i < vr.Products.Length; i++)
{
if (vr.Products[i] == '1')
{
if(trayType== ETrayType.Input)
{
GlobalTray.InputTray.ChangeStatus(i + 1, ESlotStatus.Have);
}
}
else
{
noHasProduct.Add(i + 1);
if(trayType== ETrayType.Input)
{
GlobalTray.InputTray.ChangeStatus(i + 1, ESlotStatus.NotHave);
}
}
}
if (noHasProduct.Count > 0)
{
EButtonType btn = Msgbox.ShowDialog(EButtonType.Retry | EButtonType.Skip, "料盘未放满,请处理", "tray info", true);
if (btn == EButtonType.Retry)
{
flowStep = EStockGrabFlowStep.;
}
else if (btn == EButtonType.Skip)
{
finished = true;
}
}
else
{
finished = true;
}
break;
default:
break;
}
}
}
string GetClassName()
{
return "StockGrabFlow-";
}
}
}

@ -137,6 +137,7 @@
<Compile Include="Commom\TrayRunPointManager.cs" />
<Compile Include="Commom\UpCameraHelper.cs" />
<Compile Include="Entitys\OneGrabSixteenManager.cs" />
<Compile Include="Flow\SubFlow\StockGrabFlow.cs" />
<Compile Include="Flow\SubFlow\EnvironmentPrepareFlow.cs" />
<Compile Include="Flow\SubFlow\FixedGrabProductFlow.cs" />
<Compile Include="Flow\SubFlow\FixturePlaceFlow.cs" />

Loading…
Cancel
Save