From ace1f5ec615ac6e07402b7692d77482fb1ce63ed Mon Sep 17 00:00:00 2001 From: lhiven Date: Sat, 29 Jun 2024 08:52:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=99Ok=E6=96=99=E4=BB=93?= =?UTF-8?q?=E6=94=BE=E7=9B=96=E5=AD=90=E4=B9=8B=E5=89=8D=EF=BC=8C=E7=94=A8?= =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E7=A1=AE=E8=AE=A4=E4=BA=A7=E5=93=81=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E6=94=BE=E5=A5=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Flow/NormalFlow/DischargeFlow.cs | 4 +- .../Flow/NormalFlow/TakeTrayFlow.cs | 148 ++++++++++-------- Rs.DeweyTester/Flow/SubFlow/StockGrabFlow.cs | 138 ++++++++++++++++ Rs.DeweyTester/Rs.DeweyTester.csproj | 1 + 4 files changed, 224 insertions(+), 67 deletions(-) create mode 100644 Rs.DeweyTester/Flow/SubFlow/StockGrabFlow.cs diff --git a/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs index d54c5a2..9a96118 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs @@ -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); diff --git a/Rs.DeweyTester/Flow/NormalFlow/TakeTrayFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/TakeTrayFlow.cs index 9248f13..25e95d1 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/TakeTrayFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/TakeTrayFlow.cs @@ -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 /// 搬运料盘被拿起后事件 /// 到达放料盘位上方事件 /// 放料盘完成后事件 - 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 noHasProduct = new List(); - for(int i=0;i0) - { - 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 noHasProduct = new List(); + // for(int i=0;i0) + // { + // 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()) { diff --git a/Rs.DeweyTester/Flow/SubFlow/StockGrabFlow.cs b/Rs.DeweyTester/Flow/SubFlow/StockGrabFlow.cs new file mode 100644 index 0000000..bdac4be --- /dev/null +++ b/Rs.DeweyTester/Flow/SubFlow/StockGrabFlow.cs @@ -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 + { + 到拍照位, + 等待运动到拍照位, + 通知上料仓拍照, + 处理上料仓拍照数据 + } + + + /// + /// 料仓拍照流程 + /// + 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 noHasProduct = new List(); + 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-"; + } + } +} diff --git a/Rs.DeweyTester/Rs.DeweyTester.csproj b/Rs.DeweyTester/Rs.DeweyTester.csproj index ccc8544..5b6b618 100644 --- a/Rs.DeweyTester/Rs.DeweyTester.csproj +++ b/Rs.DeweyTester/Rs.DeweyTester.csproj @@ -137,6 +137,7 @@ +