From 74aedf0a52e52c067174f727f58d7a2401cee7a9 Mon Sep 17 00:00:00 2001 From: lhiven Date: Sat, 25 May 2024 18:29:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=89=E7=82=B9=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.DeweyTester/Commom/TrayPointManager.cs | 108 +----------------- Rs.DeweyTester/Flow/AlarmConstID.cs | 5 + Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs | 4 +- .../Flow/NormalFlow/ThreePointLocationFlow.cs | 22 +++- Rs.DeweyTester/Module/NozzleCollection.cs | 2 +- .../Recipe/StockTrayLocationRecipe.cs | 29 +++-- 6 files changed, 43 insertions(+), 127 deletions(-) diff --git a/Rs.DeweyTester/Commom/TrayPointManager.cs b/Rs.DeweyTester/Commom/TrayPointManager.cs index 68c252d..a1cc929 100644 --- a/Rs.DeweyTester/Commom/TrayPointManager.cs +++ b/Rs.DeweyTester/Commom/TrayPointManager.cs @@ -60,112 +60,6 @@ namespace Rs.MotionPlat.Commom } return null; } - - /// - /// 获取异常料盘的点位 - /// - /// - /// - /// - /// - /// - public static SlotPoint GetExceptionTrayPoint(int slotIndex) - { - string key = $"{GlobalVar.CurRecipe}-ExceptiontTray-{slotIndex}"; - if (trayPoints.ContainsKey(key)) - { - return trayPoints[key]; - } - return null; - } - - /// - /// 获取测试治具测高的点位 - /// - /// - /// - /// - /// - /// - public static SlotPoint GetTestFixtureTrayCheckHeighPoint(int slotIndex) - { - string key = $"{GlobalVar.CurRecipe}-CheckHeightTestTray-{slotIndex}"; - if (trayPoints.ContainsKey(key)) - { - return trayPoints[key]; - } - return null; - } - - /// - /// 获取周转盘测高的点位 - /// - /// - /// - /// - /// - /// - public static SlotPoint GetTurnoverTrayCheckHeighPoint(int slotIndex) - { - string key = $"{GlobalVar.CurRecipe}-CheckHeightTurnover-{slotIndex}"; - if (trayPoints.ContainsKey(key)) - { - return trayPoints[key]; - } - return null; - } - - /// - /// 获取周转盘强力吸嘴的点位 - /// - /// - /// - /// - /// - /// - public static SlotPoint GetTurnoverTrayForceNozzlePoint(int slotIndex) - { - string key = $"{GlobalVar.CurRecipe}-ForceNozzleTurnover-{slotIndex}"; - if (trayPoints.ContainsKey(key)) - { - return trayPoints[key]; - } - return null; - } - - /// - /// 获取周转盘强力吸嘴的点位 - /// - /// - /// - /// - /// - /// - public static SlotPoint GetExceptiontTrayPoint(int slotIndex) - { - string key = $"{GlobalVar.CurRecipe}-ExceptiontTray-{slotIndex}"; - if (trayPoints.ContainsKey(key)) - { - return trayPoints[key]; - } - return null; - } - - - public static SlotPoint GetDistToNozzle1(int nozzleIndex) - { - //先获取相机的中心位置 - SlotPoint point = new SlotPoint(); - double nozzle1ToCameraCenterX = SysConfigParam.GetValue("InkpadX") - SysConfigParam.GetValue("CameraInkpadX"); - double nozzle1ToCameraCenterY = SysConfigParam.GetValue("InkpadY") - SysConfigParam.GetValue("CameraInkpadY"); - - //再加上指定吸嘴到吸嘴1的距离 - double distToNozzle1X = SysConfigParam.GetValue($"Nozzle{nozzleIndex}CenterX") - SysConfigParam.GetValue($"Nozzle1CenterX"); - double distToNozzle1Y = SysConfigParam.GetValue($"Nozzle{nozzleIndex}CenterY") - SysConfigParam.GetValue($"Nozzle1CenterY"); - - point.X = nozzle1ToCameraCenterX + distToNozzle1X; - point.Y = nozzle1ToCameraCenterY + distToNozzle1Y; - return point; - } + } } diff --git a/Rs.DeweyTester/Flow/AlarmConstID.cs b/Rs.DeweyTester/Flow/AlarmConstID.cs index e14a5dc..32972db 100644 --- a/Rs.DeweyTester/Flow/AlarmConstID.cs +++ b/Rs.DeweyTester/Flow/AlarmConstID.cs @@ -134,5 +134,10 @@ namespace Rs.MotionPlat.Flow /// TakeTrayX运动异常报警 /// public const int TakeTrayX运动异常报警 = 1026; + + /// + /// 料盘定位失败 + /// + public const int 料盘定位失败 = 1027; } } diff --git a/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs index f0f0170..2252e65 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs @@ -263,7 +263,7 @@ namespace Rs.MotionPlat.Flow curTakeNozzle = NozzleManager.GetIdelNozzle(); if (curTakeNozzle != null) { - targetPosition = NozzleManager.GotoTraySlot(ETrayType.Grr, curTakeSlot.Index, curTakeNozzle.NozzleIndex); + targetPosition = NozzleManager.GetToTraySlot(ETrayType.Grr, curTakeSlot.Index, curTakeNozzle.NozzleIndex); if(curTakeNozzle != null) { targetPosition.X += vResult.OffsetX; @@ -768,7 +768,7 @@ namespace Rs.MotionPlat.Flow if (curDumpSlot != null) { - targetPosition = NozzleManager.GotoTraySlot(ETrayType.Grr, curDumpSlot.Index, curDumpNozzle.NozzleIndex); + targetPosition = NozzleManager.GetToTraySlot(ETrayType.Grr, curDumpSlot.Index, curDumpNozzle.NozzleIndex); ////获取点位 //SlotPoint slotPoint = TrayPointManager.GetSlotPoint(ETrayType.Ng, curDumpSlot.Index); //targetPosition.X = slotPoint.X + GlobalVar.Nozzle1ToCameraCenterOffsetX + NozzleManager.GetNozzleOffsetX(curDumpNozzle.NozzleIndex); diff --git a/Rs.DeweyTester/Flow/NormalFlow/ThreePointLocationFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/ThreePointLocationFlow.cs index a333648..5cdcfcb 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/ThreePointLocationFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/ThreePointLocationFlow.cs @@ -3,6 +3,7 @@ using Rs.DataAccess; using Rs.Framework; using Rs.Motion; using Rs.MotionPlat.Commom; +using Rs.MotionPlat.Entitys; using Rs.MotionPlat.Flow.Common; using Rs.MotionPlat.Vision; using System; @@ -42,6 +43,8 @@ namespace Rs.MotionPlat.Flow.NormalFlow string logInfo = string.Empty; VisionResult vr = new VisionResult(); List vResult = new List(); + AlarmEntity alarmEntity=new AlarmEntity(); + /// /// 三点定位(左上/右上/左下) /// @@ -59,7 +62,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow { return; } - Task.Run(() => { + //Task.Run(() => { while (!finished) { if(stop) @@ -99,7 +102,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow } else { - + step = EThreePointLocationFlowStep.到拍照位; } } break; @@ -121,12 +124,21 @@ namespace Rs.MotionPlat.Flow.NormalFlow CalcTrayRunPoint(trayType); TrayRunPointManager.LoadPoint(); finished = true; + Msgbox.ShowDialog(EButtonType.Ok, "Three point location finished"); + } + } + else + { + alarmEntity = AlarmCollection.Get(AlarmConstID.料盘定位失败); + if (alarmEntity != null) + { + Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); } } break; } } - }); + //}); } private void PrintXY1Y2CurrentPos(string prefixLog) @@ -203,8 +215,8 @@ namespace Rs.MotionPlat.Flow.NormalFlow { for (int col = 1; col <= 16; col++) { - double x = y1 + (row - 1) * bigSpaceY + (col - 1) * smallSpaceX; - double y = x1 + (col - 1) * bigSpaceX + (row - 1) * smallSpaceY; + double x = x1 + (row - 1) * bigSpaceX + (col - 1) * smallSpaceX; + double y = y1 + (col - 1) * bigSpaceY + (row - 1) * smallSpaceY; string insertSql = $"insert into trayrunpoints(trayid,recipename,trayname,slotindex,x,y) values(1,'{GlobalVar.CurRecipe}','{trayType}',{index},{x},{y})"; rowAffectNum = db.ExecuteNonQuery(insertSql); diff --git a/Rs.DeweyTester/Module/NozzleCollection.cs b/Rs.DeweyTester/Module/NozzleCollection.cs index a03b423..7027b5d 100644 --- a/Rs.DeweyTester/Module/NozzleCollection.cs +++ b/Rs.DeweyTester/Module/NozzleCollection.cs @@ -474,7 +474,7 @@ namespace Rs.MotionPlat.Commom /// /// /// - public static TargetPosition GotoTraySlot(ETrayType trayType,int slotIndex,int nozzleIndex) + public static TargetPosition GetToTraySlot(ETrayType trayType,int slotIndex,int nozzleIndex) { TargetPosition targetPosition=new TargetPosition(); SlotPoint curTakeSlotPoint = TrayPointManager.GetSlotPoint(trayType, slotIndex); diff --git a/Rs.DeweyTester/Recipe/StockTrayLocationRecipe.cs b/Rs.DeweyTester/Recipe/StockTrayLocationRecipe.cs index db075a6..15059b1 100644 --- a/Rs.DeweyTester/Recipe/StockTrayLocationRecipe.cs +++ b/Rs.DeweyTester/Recipe/StockTrayLocationRecipe.cs @@ -45,6 +45,12 @@ namespace Rs.MotionPlat.Recipe } private void BindPoints() + { + BindBasePoint(); + BindRunPoint(); + } + + void BindBasePoint() { string querySql = $"select * from TrayPoints where trayname='{m_trayName}' and recipename='{GlobalVar.CurRecipe}' order by slotindex"; DataTable dtRunPoints = db.GetDataTable(querySql); @@ -52,10 +58,12 @@ namespace Rs.MotionPlat.Recipe { dgvBasePoints.DataSource = dtRunPoints; } + } - - querySql = $"select * from TrayRunPoints where trayname='{m_trayName}' and recipename='{GlobalVar.CurRecipe}' order by slotindex"; - dtRunPoints = db.GetDataTable(querySql); + void BindRunPoint() + { + string querySql = $"select * from TrayRunPoints where trayname='{m_trayName}' and recipename='{GlobalVar.CurRecipe}' order by slotindex"; + DataTable dtRunPoints = db.GetDataTable(querySql); if (ObjectHelper.IsNotNullorEmpty(dtRunPoints)) { dgvRunPoints.DataSource = dtRunPoints; @@ -166,7 +174,7 @@ namespace Rs.MotionPlat.Recipe if(selectedSlot!=null) { int nozzleIndex = 0; - string querySql = $"select * from TrayPoints where trayid={dt.Rows[0]["id"]} and slotindex={selectedSlot.Index}"; + string querySql = $"select * from TrayRunPoints where trayid={dt.Rows[0]["id"]} and slotindex={selectedSlot.Index}"; DataTable dtGoPosition = db.GetDataTable(querySql); if(ObjectHelper.IsNotNullorEmpty(dtGoPosition)) { @@ -177,14 +185,10 @@ namespace Rs.MotionPlat.Recipe if (parentMenu.Text.IndexOf("Nozzle") >= 0) { nozzleIndex = int.Parse(parentMenu.Text.Replace("Nozzle", "").Replace("GO", "")); - SlotPoint dist = TrayPointManager.GetDistToNozzle1(nozzleIndex); - targetX += dist.X; - targetY += dist.Y; - } - if(subMenu.Text=="GrabPos") - { - targetX += GlobalVar.StockTakePictureOffsetX; - targetY += GlobalVar.StockTakePictureOffsetY; + //SlotPoint dist = TrayPointManager.GetDistToNozzle1(nozzleIndex); + + targetX += NozzleManager.GetNozzleToCameraOffsetX(nozzleIndex); + targetY += NozzleManager.GetNozzleToCameraOffsetY2(nozzleIndex); } DialogResult dr = Msg.ShowQuestion($"Are you sure to move loadx to {targetX},loady to {targetY}?"); if(dr== DialogResult.OK) @@ -410,6 +414,7 @@ namespace Rs.MotionPlat.Recipe { ThreePointLocationFlow.Instance.Location(ETrayType.Ok); } + BindPoints(); }); } }