diff --git a/Rs.DeweyTester/Commom/GlobalVar.cs b/Rs.DeweyTester/Commom/GlobalVar.cs index a90c450..5c0c4ea 100644 --- a/Rs.DeweyTester/Commom/GlobalVar.cs +++ b/Rs.DeweyTester/Commom/GlobalVar.cs @@ -17,6 +17,18 @@ namespace Rs.Framework { #region newpro + /// + /// 允许料仓放料前拍照 + /// + [ParameterInit("bool", "true", "system", "允许料仓放料前拍照")] + public static bool EnableBeforePlaceProductGrab + { + get + { + return SysConfigParam.GetValue(nameof(EnableBeforePlaceProductGrab)); + } + } + /// /// 允许Ok tray 满料检查 /// diff --git a/Rs.DeweyTester/Flow/SafePosFlow/DischargeModuleGoSafePosFlow.cs b/Rs.DeweyTester/Flow/SafePosFlow/DischargeModuleGoSafePosFlow.cs index 5aeed81..62a4ad4 100644 --- a/Rs.DeweyTester/Flow/SafePosFlow/DischargeModuleGoSafePosFlow.cs +++ b/Rs.DeweyTester/Flow/SafePosFlow/DischargeModuleGoSafePosFlow.cs @@ -74,11 +74,11 @@ namespace Rs.MotionPlat.Flow.SafePosFlow step = EDischargeModuleGoSafePosFlowStep.到安全位; while (true && !finished) { - if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop) - { - Thread.Sleep(10); - continue; - } + //if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop) + //{ + // Thread.Sleep(10); + // continue; + //} switch (step) { case EDischargeModuleGoSafePosFlowStep.到安全位: diff --git a/Rs.DeweyTester/Flow/SubFlow/StockGrabFlow.cs b/Rs.DeweyTester/Flow/SubFlow/StockGrabFlow.cs index 4dee701..87cdbff 100644 --- a/Rs.DeweyTester/Flow/SubFlow/StockGrabFlow.cs +++ b/Rs.DeweyTester/Flow/SubFlow/StockGrabFlow.cs @@ -79,7 +79,7 @@ namespace Rs.MotionPlat.Flow.SubFlow break; case EStockGrabFlowStep.通知上料仓拍照: vr = VisionHelper.Grab(Vision.EVisionScene.HaveOrNot); - if (vr.Result) + if (vr!=null && vr.Result) { flowStep = EStockGrabFlowStep.处理上料仓拍照数据; } diff --git a/Rs.DeweyTester/Flow/SubFlow/StockPlaceFlow.cs b/Rs.DeweyTester/Flow/SubFlow/StockPlaceFlow.cs index 0f69bac..7cdf90b 100644 --- a/Rs.DeweyTester/Flow/SubFlow/StockPlaceFlow.cs +++ b/Rs.DeweyTester/Flow/SubFlow/StockPlaceFlow.cs @@ -4,6 +4,7 @@ using Rs.MotionPlat.Commom; using Rs.MotionPlat.Entitys; using Rs.MotionPlat.Flow.Common; using Rs.MotionPlat.Flow.SafePosFlow; +using Rs.MotionPlat.Vision; using System; using System.Collections.Generic; using System.Linq; @@ -16,6 +17,9 @@ namespace Rs.MotionPlat.Flow.SubFlow enum EStockPlaceFlowStep { 待触发, + 到料仓拍照位上方, + 等待到料仓拍照位上方, + 料仓学位拍照, 到料仓放料位上方, 等待到料仓放料位上方, 到料仓放料位下方, @@ -31,6 +35,8 @@ namespace Rs.MotionPlat.Flow.SubFlow { public event Action PlaceFinishedEvent; bool finished = true; + double slotOffsetX = 0.0; + double slotOffsetY = 0.0; EStockPlaceFlowStep flowStep = EStockPlaceFlowStep.待触发; public StockPlaceFlow() { @@ -101,7 +107,67 @@ namespace Rs.MotionPlat.Flow.SubFlow switch (flowStep) { case EStockPlaceFlowStep.待触发: - flowStep = EStockPlaceFlowStep.到料仓放料位上方; + slotOffsetX = 0; + slotOffsetY = 0; + if (GlobalVar.EnableBeforePlaceProductGrab) + { + flowStep = EStockPlaceFlowStep.到料仓拍照位上方; + } + else + { + flowStep = EStockPlaceFlowStep.到料仓放料位上方; + } + break; + case EStockPlaceFlowStep.到料仓拍照位上方: + curPlaceSlot = tray.GetSlot(slotIndex); + if(curPlaceSlot!=null) + { + SlotPoint sp = TrayPointManager.GetSlotPoint(trayType, curPlaceSlot.Index); + if(sp!=null) + { + targetPosition.X = sp.X; + targetPosition.Y1 = GlobalVar.StockSideY1; + targetPosition.Y2 = sp.Y; + double curLoadX = Ops.GetCurPosition(AxisControl.LoadX); + if (curLoadX - GlobalVar.FixtureSafePosX > 50) + { + DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock); + } + if (GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed)) + { + AxisPosPrint.PrintXY1Y2TargetPos("到料仓拍照位上方,", targetPosition, GetClassName()); + flowStep = EStockPlaceFlowStep.等待到料仓拍照位上方; + } + } + } + break; + case EStockPlaceFlowStep.等待到料仓拍照位上方: + if (Ops.IsStop("LoadX", "LoadY1", "LoadY2")) + { + AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,", GetClassName()); + if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2)) + { + AxisPosPrint.PrintXY1Y2CurrentPos("已运动到料仓拍照位上方,", GetClassName()); + flowStep = EStockPlaceFlowStep.料仓学位拍照; + } + else + { + flowStep = EStockPlaceFlowStep.到料仓拍照位上方; + } + } + break; + case EStockPlaceFlowStep.料仓学位拍照: + UpCameraHelper.Grab(); + VisionResult vr = VisionHelper.Grab(Vision.EVisionScene.TrayLocation); + if(vr!=null && vr.Result) + { + slotOffsetX = vr.OffsetX; slotOffsetY=vr.OffsetY; + flowStep = EStockPlaceFlowStep.到料仓放料位上方; + } + else + { + Msgbox.ShowTipDialog(EButtonType.Retry, "料仓穴位定位失败", "", true); + } break; case EStockPlaceFlowStep.到料仓放料位上方: //curNozzle = NozzleManager.GetToUnloadNozzle(); @@ -112,6 +178,8 @@ namespace Rs.MotionPlat.Flow.SubFlow if (curPlaceSlot != null) { targetPosition = NozzleManager.GetToTraySlot(trayType, curPlaceSlot.Index, curNozzle.NozzleIndex); + targetPosition.X += slotOffsetX; + targetPosition.Y2+= slotOffsetY; double curLoadX = Ops.GetCurPosition(AxisControl.LoadX); if (curLoadX - GlobalVar.FixtureSafePosX > 50) { diff --git a/Rs.DeweyTester/Module/NozzleCollection.cs b/Rs.DeweyTester/Module/NozzleCollection.cs index 52a7e40..eb1c773 100644 --- a/Rs.DeweyTester/Module/NozzleCollection.cs +++ b/Rs.DeweyTester/Module/NozzleCollection.cs @@ -510,13 +510,20 @@ namespace Rs.MotionPlat.Commom { TargetPosition targetPosition=new TargetPosition(); SlotPoint curTakeSlotPoint = null; - if(trayType== ETrayType.Input) + if(GlobalVar.EnableBeforePlaceProductGrab) { curTakeSlotPoint = TrayPointManager.GetSlotPoint(trayType, slotIndex); } else { - curTakeSlotPoint = TrayRunPointManager.GetSlotPoint(trayType, slotIndex); + if (trayType == ETrayType.Input) + { + curTakeSlotPoint = TrayPointManager.GetSlotPoint(trayType, slotIndex); + } + else + { + curTakeSlotPoint = TrayRunPointManager.GetSlotPoint(trayType, slotIndex); + } } MessageQueue.Instance.Insert($"基础loadx:{curTakeSlotPoint.X},loady2:{curTakeSlotPoint.Y}"); if (curTakeSlotPoint != null)