From fd0f5d1b33079c7977d3ab510d4a90effb040bd6 Mon Sep 17 00:00:00 2001 From: lhiven Date: Sat, 16 Aug 2025 07:56:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=968=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.DeweyTester/Commom/BarCodeHelper.cs | 24 + Rs.DeweyTester/Commom/Msgbox.cs | 20 + Rs.DeweyTester/Commom/ScanFailNGHelper.cs | 41 ++ Rs.DeweyTester/Entitys/AlarmEntity.cs | 16 + Rs.DeweyTester/Flow/AlarmConstID.cs | 43 ++ .../Flow/NormalFlow/DischargeFlow.cs | 278 ++++++---- Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs | 65 ++- .../Flow/SubFlow/FiveProductTestFlow.cs | 517 ------------------ .../Flow/SubFlow/FixedGrabProductFlow.cs | 75 ++- Rs.DeweyTester/Rs.DeweyTester.csproj | 3 +- Rs.DeweyTester/Vision/OneGrabOneVision.cs | 21 +- Rs.DeweyTester/Vision/VisionHelper.cs | 4 +- 12 files changed, 419 insertions(+), 688 deletions(-) create mode 100644 Rs.DeweyTester/Commom/BarCodeHelper.cs create mode 100644 Rs.DeweyTester/Commom/ScanFailNGHelper.cs delete mode 100644 Rs.DeweyTester/Flow/SubFlow/FiveProductTestFlow.cs diff --git a/Rs.DeweyTester/Commom/BarCodeHelper.cs b/Rs.DeweyTester/Commom/BarCodeHelper.cs new file mode 100644 index 0000000..f021b39 --- /dev/null +++ b/Rs.DeweyTester/Commom/BarCodeHelper.cs @@ -0,0 +1,24 @@ +using Rs.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace Rs.MotionPlat.Commom +{ + public static class BarCodeHelper + { + public static bool CheckSnLength(string sn) + { + //string reg = "^[ABCDEFGHJKLMNPQRSTUVWXYZ 0-9 + -]+$"; + string reg = "^[A-Z 0-9 + -]+$"; + if (Regex.IsMatch(sn, reg)) + { + return true; + } + return false; + } + } +} diff --git a/Rs.DeweyTester/Commom/Msgbox.cs b/Rs.DeweyTester/Commom/Msgbox.cs index da5e70f..8d4c131 100644 --- a/Rs.DeweyTester/Commom/Msgbox.cs +++ b/Rs.DeweyTester/Commom/Msgbox.cs @@ -34,6 +34,26 @@ namespace Rs.MotionPlat.Commom return ret; } + public static EButtonType ShowTipDialog(AlarmEntity alarmInfo, EButtonType buttons, bool warning = false) + { + if (warning) + { + BuzzerManager.Instance.On(); + LightManger.Instance.SetStatus(ELightStatus.Red); + } + string logInfo = $"{alarmInfo.CN}"; + LogHelper.Debug($"ShowTipDialog({logInfo},{buttons}, {warning})"); + EButtonType ret = EButtonType.None; + FrmDialog fd = new FrmDialog(); + ret = fd.ShowMessage(buttons, alarmInfo.CN, alarmInfo.EN); + if (warning) + { + BuzzerManager.Instance.Off(); + LightManger.Instance.SetStatus(ELightStatus.Green); + } + return ret; + } + /// /// 显示模态弹框 /// diff --git a/Rs.DeweyTester/Commom/ScanFailNGHelper.cs b/Rs.DeweyTester/Commom/ScanFailNGHelper.cs new file mode 100644 index 0000000..b5c5bde --- /dev/null +++ b/Rs.DeweyTester/Commom/ScanFailNGHelper.cs @@ -0,0 +1,41 @@ +using Rs.Framework; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace Rs.MotionPlat.Commom +{ + public class ScanFailNGHelper + { + static int sn; + static string filename = "ng-sn.txt"; + static ScanFailNGHelper() + { + if(File.Exists(filename)) + { + string fc = File.ReadAllText(filename); + if(!int.TryParse(fc, out sn )) + { + sn = 0; + } + } + } + + public static string GetSn() + { + sn++; + File.WriteAllText(filename, sn.ToString()); + return $"SLK{GlobalVar.MachineID}"+ sn.ToString().PadLeft(9, '0'); + } + + public static bool IsScanFailSN(string sn) + { + string reg = "SLKADT\\d{11}"; + return Regex.IsMatch(sn, reg); + } + } +} diff --git a/Rs.DeweyTester/Entitys/AlarmEntity.cs b/Rs.DeweyTester/Entitys/AlarmEntity.cs index 6b62ba6..f10ceea 100644 --- a/Rs.DeweyTester/Entitys/AlarmEntity.cs +++ b/Rs.DeweyTester/Entitys/AlarmEntity.cs @@ -1,6 +1,8 @@ using NPOI.SS.UserModel; using NPOI.XSSF.UserModel; using Rs.Framework; +using Rs.MotionPlat.Commom; +using Rs.MotionPlat.Flow; using System; using System.Collections.Generic; using System.IO; @@ -128,6 +130,20 @@ namespace Rs.MotionPlat.Entitys } return ""; } + + public static void SystemExceptionAlarm(Exception ex) + { + LogHelper.Debug(ex.Message + ex.StackTrace); + AlarmEntity alarmEntity = AlarmCollection.Get(AlarmConstID.系统异常报警).Transform(ex.Message); + if (alarmEntity != null) + { + Msgbox.ShowTipDialog(alarmEntity, EButtonType.Ok, true); + } + else + { + Msg.ShowError("Alarm file cann't find 系统异常报警 item"); + } + } } public class AlarmEntity { diff --git a/Rs.DeweyTester/Flow/AlarmConstID.cs b/Rs.DeweyTester/Flow/AlarmConstID.cs index 2e42bd2..c903caa 100644 --- a/Rs.DeweyTester/Flow/AlarmConstID.cs +++ b/Rs.DeweyTester/Flow/AlarmConstID.cs @@ -244,5 +244,48 @@ namespace Rs.MotionPlat.Flow /// 二维码长度异常报警 /// public const int 二维码长度异常报警 = 1049; + + /// + /// Input料盘开始搬运到Empty前报警 + /// + public const int Input料盘开始搬运到Empty前报警 = 1050; + + /// + /// 轴未到位异常 + /// + public const int 轴未到位异常 = 1051; + + /// + /// 命令发送失败报警 + /// + public const int 命令发送失败报警 = 1052; + + + /// + /// 等待命令超时报警 + /// + public const int 等待命令超时报警 = 1053; + + /// + /// 设备长时间未动作报警 + /// + public const int 设备长时间未动作报警 = 1054; + + + /// + /// 有无相机拍照失败报警 + /// + public const int 有无相机拍照失败报警 = 1055; + + + /// + /// 系统异常报警 + /// + public const int 系统异常报警 = 1056; + + /// + /// 测试软件异常报警 + /// + public const int 测试软件异常报警 = 1057; } } diff --git a/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs index 90f577a..1da4ff6 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs @@ -1,4 +1,5 @@ -using NPOI.SS.Formula.Eval; +using Newtonsoft.Json; +using NPOI.SS.Formula.Eval; using Rs.Camera; using Rs.Controls; using Rs.Framework; @@ -366,135 +367,200 @@ namespace Rs.MotionPlat.Flow } break; case EDischargeFlowStep.料仓取料: - ProductLocationResult ret = productLocationResult.Where(r => r.SlotIndex == takeSlotIndex).FirstOrDefault(); - if(ret != null || GlobalVar.RunSpace) + try { - if((ret!= null && ret.Result== EOneGrabSixteenResult.Ok) ||(ret!=null &&ret.Result== EOneGrabSixteenResult.LocationOkScanBarcodeFail && GlobalVar.EnableVirtualBarCode) || GlobalVar.RunSpace) + ProductLocationResult ret = productLocationResult.Where(r => r.SlotIndex == takeSlotIndex).FirstOrDefault(); + if (ret != null || GlobalVar.RunSpace) { - Nozzle idleNozzle = NozzleManager.GetIdelNozzle(); - if(idleNozzle!=null) + if ((ret != null && ret.Result == EOneGrabSixteenResult.Ok) || (ret != null && ret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail && GlobalVar.EnableVirtualBarCode) || GlobalVar.RunSpace) { - StockTakeFlow.Instance.Take(ETrayType.Input, takeSlotIndex, idleNozzle.NozzleIndex); - takeSlotIndex++; - flowStep = EDischargeFlowStep.判断是否需要从料仓取料; - } - } - else - { - bool exit = false; - while (!exit) - { - ProductLocationResult fixtureret = FixedGrabProductFlow.Instance.TakePicture(ETrayType.Input, ret.SlotIndex); - if (fixtureret.Result == EOneGrabSixteenResult.Ok) + if (GlobalVar.RunSpace || BarCodeHelper.CheckSnLength(ret.SN) || (ret != null && ret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail && GlobalVar.EnableVirtualBarCode)) { - if(fixtureret.SN.Length==GlobalVar.BarcodeLength) - { - ret.Change(fixtureret.SN, fixtureret.OffsetX, fixtureret.OffsetY); - //takeSlotIndex++; - StockTakeFlow.Instance.Take(ETrayType.Input, takeSlotIndex, NozzleManager.GetIdelNozzle().NozzleIndex); - takeSlotIndex++; - flowStep = EDischargeFlowStep.判断是否需要从料仓取料; - exit = true; - } - else - { - //报警弹框 - alarmEntity = AlarmCollection.Get(AlarmConstID.二维码长度异常报警).Transform(ret.SlotIndex); - EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true); - if (buttonSelect == EButtonType.Retry) - { - logInfo = GetClassName() + "选择了重试"; - MessageQueue.Instance.Insert(logInfo); - } - } + StockTakeFlow.Instance.Take(ETrayType.Input, takeSlotIndex, NozzleManager.GetIdelNozzle().NozzleIndex); + takeSlotIndex++; + flowStep = EDischargeFlowStep.判断是否需要从料仓取料; } - else if (fixtureret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail) + else { + LogHelper.Debug(GetClassName() + $"检测到二维码={ret.SN}长度和设置的长度={GlobalVar.BarcodeLength}不一致"); Nozzle idleNozzle = NozzleManager.GetIdelNozzle(); - if(false) + StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex); + if (NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product != null) { - StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex); - //放料 - TraySlot noProductSlot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave); - if (noProductSlot != null) - { - StockPlaceFlow.Instance.Place(ETrayType.ReTest, noProductSlot.Index, idleNozzle.NozzleIndex); - } - else - { - Msgbox.ShowTipDialog(EButtonType.Ok, "Retest tray full,please change tray and click ok button", "tip", true); - GlobalTray.RetestTray.ChangeStatus(ESlotStatus.NotHave); - ThreePointLocationFlow.Instance.Location(ETrayType.ReTest); - //放料 - noProductSlot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave); - StockPlaceFlow.Instance.Place(ETrayType.ReTest, noProductSlot.Index, idleNozzle.NozzleIndex); - } - takeSlotIndex++; - flowStep = EDischargeFlowStep.判断是否需要从料仓取料; - exit = true; + //NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = "SLK11111111PNK60X"; + NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = ScanFailNGHelper.GetSn(); } - else - { - StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex); - if(NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product!=null) - { - NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = "SLK11111111PNK60X"; - } - takeSlotIndex++; - exit = true; - flowStep = EDischargeFlowStep.判断是否需要从料仓取料; - } - + takeSlotIndex++; + flowStep = EDischargeFlowStep.判断是否需要从料仓取料; } - else if (fixtureret.Result == EOneGrabSixteenResult.Slant) + } + else + { + bool exit = false; + while (!exit) { - //报警弹框 - alarmEntity = AlarmCollection.Get(AlarmConstID.取料定位失败报警).Transform(ret.SlotIndex); - EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, true); - //EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, $"穴位{ret.SlotIndex}定位失败,请把产品手动取走后点击跳过","tip",true); - if(buttonSelect== EButtonType.Retry) + //先进行有无料判断 + ProductLocationResult fixtureret = FixedGrabProductFlow.Instance.TakePicture(ETrayType.Input, ret.SlotIndex, 1, true); + if (fixtureret.Result == EOneGrabSixteenResult.NoHaveProdut) { - logInfo = GetClassName() + "选择了重试"; - MessageQueue.Instance.Insert(logInfo); - } - else if (buttonSelect == EButtonType.Skip) - { - logInfo = GetClassName() + "选择了跳过"; - MessageQueue.Instance.Insert(logInfo); + logInfo = GetClassName() + $"视觉检测到穴位{ret.SlotIndex}无料,自动跳过"; + LogHelper.Debug(logInfo); exit = true; GlobalTray.InputTray.ChangeStatus(ret.SlotIndex, ESlotStatus.NotHave); takeSlotIndex++; flowStep = EDischargeFlowStep.判断是否需要从料仓取料; } - else if (buttonSelect == EButtonType.EndInput) + else if (fixtureret.Result == EOneGrabSixteenResult.Slant) { - logInfo = GetClassName() + "选择了结束上料"; - MessageQueue.Instance.Insert(logInfo); - exit = true; - GlobalVar.Clear = true; - takeSlotIndex++; - flowStep = EDischargeFlowStep.判断是否需要从料仓取料; + logInfo = GetClassName() + $"视觉检测到穴位{ret.SlotIndex}有料"; + LogHelper.Debug(logInfo); + fixtureret = FixedGrabProductFlow.Instance.TakePicture(ETrayType.Input, ret.SlotIndex); + if (fixtureret != null && fixtureret.Result == EOneGrabSixteenResult.Ok) + { + LogHelper.Debug(GetClassName() + $"{JsonConvert.SerializeObject(fixtureret)}"); + //if (fixtureret.SN.Length == GlobalVar.BarcodeLength) + if (BarCodeHelper.CheckSnLength(fixtureret.SN)) + { + try + { + LogHelper.Debug(GetClassName() + "检测到二维码长度和设置的长度一致"); + ret.Change(fixtureret.SN, fixtureret.OffsetX, fixtureret.OffsetY); + //takeSlotIndex++; + LogHelper.Debug(GetClassName() + $"产品二维码:{fixtureret.SN}准备取料"); + StockTakeFlow.Instance.Take(ETrayType.Input, takeSlotIndex, NozzleManager.GetIdelNozzle().NozzleIndex); + takeSlotIndex++; + flowStep = EDischargeFlowStep.判断是否需要从料仓取料; + exit = true; + } + catch (Exception ex) + { + Msg.ShowError(ex.Message); + } + } + else + { + try + { + LogHelper.Debug(GetClassName() + $"检测到二维码={fixtureret.SN}长度和设置的长度={GlobalVar.BarcodeLength}不一致"); + Nozzle idleNozzle = NozzleManager.GetIdelNozzle(); + StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex); + if (NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product != null) + { + //NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = "SLK11111111PNK60X"; + NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = ScanFailNGHelper.GetSn(); + } + takeSlotIndex++; + exit = true; + flowStep = EDischargeFlowStep.判断是否需要从料仓取料; + ////报警弹框 + //alarmEntity = AlarmCollection.Get(AlarmConstID.二维码长度异常报警).Transform(ret.SlotIndex); + //EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true); + //if (buttonSelect == EButtonType.Retry) + //{ + // logInfo = GetClassName() + "选择了重试"; + // MessageQueue.Instance.Insert(logInfo); + //} + } + catch (Exception ex) + { + Msg.ShowError(ex.Message); + } + } + } + else if (fixtureret != null && fixtureret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail) + { + Nozzle idleNozzle = NozzleManager.GetIdelNozzle(); + //if (!GlobalVar.ScanFailToTest) + if (false) + { + StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex); + //放料 + TraySlot noProductSlot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave); + if (noProductSlot != null) + { + StockPlaceFlow.Instance.Place(ETrayType.ReTest, noProductSlot.Index, idleNozzle.NozzleIndex); + } + else + { + Msgbox.ShowTipDialog(EButtonType.Ok, "Retest tray full,please change tray and click ok button", "tip", true); + GlobalTray.RetestTray.ChangeStatus(ESlotStatus.NotHave); + ThreePointLocationFlow.Instance.Location(ETrayType.ReTest); + //放料 + noProductSlot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave); + StockPlaceFlow.Instance.Place(ETrayType.ReTest, noProductSlot.Index, idleNozzle.NozzleIndex); + } + takeSlotIndex++; + flowStep = EDischargeFlowStep.判断是否需要从料仓取料; + exit = true; + } + else + { + StockTakeFlow.Instance.Take(ETrayType.Input, ret.SlotIndex, idleNozzle.NozzleIndex); + if (NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product != null) + { + //NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = "SLK11111111PNK60X"; + NozzleManager.GetNozzle(idleNozzle.NozzleIndex).Product.SN = ScanFailNGHelper.GetSn(); + } + takeSlotIndex++; + exit = true; + flowStep = EDischargeFlowStep.判断是否需要从料仓取料; + } + + } + else if (fixtureret != null && fixtureret.Result == EOneGrabSixteenResult.Slant) + { + //if (GlobalVar.BinTakeGrabFailSkip) + if(true) + { + logInfo = GetClassName() + "系统设置了取料拍照失败自动跳过"; + MessageQueue.Instance.Insert(logInfo); + exit = true; + //GlobalTray.InputTray.ChangeStatus(ret.SlotIndex, ESlotStatus.NotHave); + takeSlotIndex++; + flowStep = EDischargeFlowStep.判断是否需要从料仓取料; + } + else + { + //报警弹框 + alarmEntity = AlarmCollection.Get(AlarmConstID.取料定位失败报警).Transform(ret.SlotIndex); + EButtonType buttonSelect = Msgbox.ShowDialog(alarmEntity, EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, true); + //EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, $"穴位{ret.SlotIndex}定位失败,请把产品手动取走后点击跳过","tip",true); + if (buttonSelect == EButtonType.Retry) + { + logInfo = GetClassName() + "选择了重试"; + MessageQueue.Instance.Insert(logInfo); + } + else if (buttonSelect == EButtonType.Skip) + { + logInfo = GetClassName() + "选择了跳过"; + MessageQueue.Instance.Insert(logInfo); + exit = true; + GlobalTray.InputTray.ChangeStatus(ret.SlotIndex, ESlotStatus.NotHave); + takeSlotIndex++; + flowStep = EDischargeFlowStep.判断是否需要从料仓取料; + } + else if (buttonSelect == EButtonType.EndInput) + { + logInfo = GetClassName() + "选择了结束上料"; + MessageQueue.Instance.Insert(logInfo); + exit = true; + GlobalVar.Clear = true; + takeSlotIndex++; + flowStep = EDischargeFlowStep.判断是否需要从料仓取料; + } + } + + } } } - else if(fixtureret.Result== EOneGrabSixteenResult.NoHaveProdut) - { - logInfo =GetClassName()+ $"视觉检测到穴位{ret.SlotIndex}无料,自动跳过"; - exit = true; - GlobalTray.InputTray.ChangeStatus(ret.SlotIndex, ESlotStatus.NotHave); - takeSlotIndex++; - flowStep = EDischargeFlowStep.判断是否需要从料仓取料; - } } - } } - //if (GlobalTray.InputTray.GetSlot(takeSlotIndex).SlotStatus == ESlotStatus.Have) - //{ - // StockTakeFlow.Instance.Take(takeSlotIndex, NozzleManager.GetIdelNozzle().NozzleIndex); - //} - //takeSlotIndex++; - //flowStep = EDischargeFlowStep.判断是否需要从料仓取料; + catch (Exception ex) + { + AlarmCollection.SystemExceptionAlarm(ex); + } break; #endregion diff --git a/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs index daa608f..732c3d4 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs @@ -268,56 +268,63 @@ namespace Rs.MotionPlat.Flow } break; case EGrrFlowStep.料仓取料拍照: - if(VisionHelper.oneGrabOneVision.ClearQueue()) + try { - UpCameraHelper.Grab(); - string msg = VisionHelper.OneGrabOne();//.Grab(EVisionScene.SingleScanBarcode); - if(!string.IsNullOrEmpty(msg)) + if (VisionHelper.oneGrabOneVision.ClearQueue("C")) { - vProductResult.Parse(msg); - if ((vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace) + UpCameraHelper.Grab(); + string msg = VisionHelper.OneGrabOne("M"); + if (!string.IsNullOrEmpty(msg)) { - if(vProductResult.SN.Length==GlobalVar.BarcodeLength) + vProductResult.Parse(msg); + if ((vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace) { - flowStep = EGrrFlowStep.到料仓取料位上方; - } - else - { - alarmEntity = AlarmCollection.Get(AlarmConstID.二维码长度异常报警); - Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); - } - } - else if (vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail) - { - GrrScanFailFrm scanFail = new GrrScanFailFrm((act, qrcode) => { - if (act == 1) + //if(vProductResult.SN.Length==GlobalVar.BarcodeLength) + if (BarCodeHelper.CheckSnLength(vProductResult.SN) || GlobalVar.RunSpace) { - vProductResult.SN = qrcode; flowStep = EGrrFlowStep.到料仓取料位上方; } - }); - scanFail.ShowDialog(); - //vProductResult.SN = VirtualBarCode.Code; + else + { + alarmEntity = AlarmCollection.Get(AlarmConstID.二维码长度异常报警); + Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true); + } + } + else if (vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail) + { + GrrScanFailFrm scanFail = new GrrScanFailFrm((act, qrcode) => { + if (act == 1) + { + vProductResult.SN = qrcode; + flowStep = EGrrFlowStep.到料仓取料位上方; + } + }); + scanFail.ShowDialog(); + //vProductResult.SN = VirtualBarCode.Code; + } + else + { + alarmEntity = AlarmCollection.Get(AlarmConstID.料仓取料拍照失败); + Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true); + } } else { alarmEntity = AlarmCollection.Get(AlarmConstID.料仓取料拍照失败); - Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); + Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true); } } else { alarmEntity = AlarmCollection.Get(AlarmConstID.料仓取料拍照失败); - Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); + Msgbox.ShowDialog(alarmEntity, EButtonType.Retry, true); } } - else + catch (Exception ex) { - alarmEntity = AlarmCollection.Get(AlarmConstID.料仓取料拍照失败); - Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); + AlarmCollection.SystemExceptionAlarm(ex); } - break; case EGrrFlowStep.到料仓取料位上方: //获取空闲吸嘴 diff --git a/Rs.DeweyTester/Flow/SubFlow/FiveProductTestFlow.cs b/Rs.DeweyTester/Flow/SubFlow/FiveProductTestFlow.cs deleted file mode 100644 index e3d856e..0000000 --- a/Rs.DeweyTester/Flow/SubFlow/FiveProductTestFlow.cs +++ /dev/null @@ -1,517 +0,0 @@ -using Rs.Controls; -using Rs.Framework; -using Rs.Motion; -using Rs.MotionPlat.Commom; -using Rs.MotionPlat.Entitys; -using Rs.MotionPlat.Flow.Common; -using Rs.MotionPlat.Flow.NormalFlow; -using Rs.MotionPlat.Flow.SafePosFlow; -using Rs.MotionPlat.Vision; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace Rs.MotionPlat.Flow.SubFlow -{ - enum EFiveProductTestFlowStep - { - OK盘三点定位, - 到料仓拍照位上方, - 等待到料仓拍照位上方, - 料仓取料拍照, - 到料仓取料位上方, - 等待到料仓取料位上方, - 到料仓取料位下方, - 等待到料仓取料位下方, - 料仓取料完成抬起, - 等待料仓取料完成抬起, - 料仓取料真空吸检测, - - - 到料仓放料位上方, - 等待到料仓放料位上方, - 到料仓放料位下方, - 等待到料仓放料位下方, - 料仓放料完成抬起, - 等待料仓放料完成抬起, - 料仓放料完成粘料检测 - } - - public class FiveProductTestFlow - { - private Task mainTask; - private FiveProductTestFlow() { } - - private static FiveProductTestFlow instance; - public static FiveProductTestFlow Instance - { - get - { - if (instance == null) - { - instance = new FiveProductTestFlow(); - } - return instance; - } - } - private AlarmEntity alarmEntity; - Stopwatch timeout = new Stopwatch(); - EFiveProductTestFlowStep flowStep = EFiveProductTestFlowStep.OK盘三点定位; - - int scanNum = 0; - string logInfo = string.Empty; - string alarmInfo = string.Empty; - - private bool stop = true; - private bool run = true; - TargetPosition targetPosition = new TargetPosition(); - ErrorCode errCode = ErrorCode.Ok; - /// - /// 当前取料穴位 - /// - TraySlot curTakeSlot = null; - /// - /// 当前取料穴位的点位 - /// - SlotPoint curTakeSlotPoint = null; - //Nozzle curNozzle = null; - Nozzle curTakeNozzle = null; - Nozzle curDumpNozzle = null; - TestFixture curFixture = null; - //放料穴位 - TraySlot curDumpSlot = null; - /// - /// 最后一次换料的治具编号 - /// - private int lastFixtureIndex = 0; - /// - /// 已经取走的产品数量 - /// - private int takedNum = 0; - //相机拍照结果 - VisionResult vResult = new VisionResult(); - ProductLocationResult vProductResult = new ProductLocationResult(); - - List needGrrFixtureList = new List(); - /// - /// 测试完成的数量 - /// - private int testFinishedNum = 0; - - private void Reset() - { - curTakeSlot = null; - curTakeSlotPoint = null; - curTakeNozzle = null; - curDumpNozzle = null; - curFixture = null; - curDumpSlot = null; - lastFixtureIndex = 0; - takedNum = 0; - testFinishedNum = 0; - VirtualBarCode.Reset(); - } - bool binit = false; - public void Init() - { - if(binit) - { - return; - } - binit = true; - mainTask = new Task(Run); - mainTask.Start(); - } - - public void Deinit() - { - run = false; - } - int takeNum = 0; - private void Run() - { - while (run) - { - if (stop) - { - Thread.Sleep(10); - continue; - } - switch (flowStep) - { - #region 料仓取料 - case EFiveProductTestFlowStep.OK盘三点定位: - ThreePointLocationFlow.Instance.Location(ETrayType.Ok); - flowStep = EFiveProductTestFlowStep.到料仓拍照位上方; - break; - case EFiveProductTestFlowStep.到料仓拍照位上方: - //GlobalTray.InputTray.ChangeStatus(1, ESlotStatus.Have); - //GlobalTray.InputTray.ChangeStatus(2, ESlotStatus.Have); - //GlobalTray.InputTray.ChangeStatus(3, ESlotStatus.Have); - //GlobalTray.InputTray.ChangeStatus(4, ESlotStatus.Have); - //GlobalTray.InputTray.ChangeStatus(5, ESlotStatus.Have); - curTakeSlot = GlobalTray.InputTray.GetSlot(ESlotStatus.Have); - if (curTakeSlot != null) - { - curTakeSlotPoint = TrayPointManager.GetSlotPoint(ETrayType.Input, curTakeSlot.Index); - if (curTakeSlotPoint != null) - { - targetPosition.X = curTakeSlotPoint.X; - targetPosition.Y1 = GlobalVar.StockSideY1; - targetPosition.Y2 = curTakeSlotPoint.Y; - //double curLoadX = Ops.GetCurPosition(AxisControl.LoadX); - //if (curLoadX - GlobalVar.FixtureSafePosX > 50) - //{ - // DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock); - //} - if (GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed, EGoWhichSide.StockSide)) - { - AxisPosPrint.PrintXY1Y2TargetPos("轴loadx,loady1,loady2已停止运动,", targetPosition, GetClassName()); - flowStep = EFiveProductTestFlowStep.等待到料仓拍照位上方; - } - } - } - else - { - //没有料了,判断是否需要换料 - GlobalTray.GrabTray.ChangeStatus(ESlotStatus.Have); - } - break; - case EFiveProductTestFlowStep.等待到料仓拍照位上方: - 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 = EFiveProductTestFlowStep.料仓取料拍照; - } - else - { - flowStep = EFiveProductTestFlowStep.到料仓拍照位上方; - } - } - break; - case EFiveProductTestFlowStep.料仓取料拍照: - UpCameraHelper.Grab(); - string msg = VisionHelper.OneGrabOne();//.Grab(EVisionScene.SingleScanBarcode); - vProductResult.Parse(msg); - if (vProductResult != null && (vProductResult.Result == EOneGrabSixteenResult.Ok || vProductResult.Result== EOneGrabSixteenResult.LocationOkScanBarcodeFail)) - { - flowStep = EFiveProductTestFlowStep.到料仓取料位上方; - } - else if (vProductResult != null && vProductResult.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail) - { - GrrScanFailFrm scanFail = new GrrScanFailFrm((act, qrcode) => { - if (act == 1) - { - vProductResult.SN = qrcode; - flowStep = EFiveProductTestFlowStep.到料仓取料位上方; - } - }); - scanFail.ShowDialog(); - //vProductResult.SN = VirtualBarCode.Code; - - } - else - { - alarmEntity = AlarmCollection.Get(AlarmConstID.料仓取料拍照失败); - Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); - } - break; - case EFiveProductTestFlowStep.到料仓取料位上方: - //获取空闲吸嘴 - //curTakeNozzle = NozzleManager.GetIdelNozzle(); - curTakeNozzle = NozzleManager.GetNozzle(1); - if (curTakeNozzle != null) - { - targetPosition = NozzleManager.GetToTraySlot(ETrayType.Input, curTakeSlot.Index, curTakeNozzle.NozzleIndex); - if (curTakeNozzle != null) - { - targetPosition.X += vProductResult.OffsetX + offsetX; - targetPosition.Y2 += vProductResult.OffsetY + offsetY; - if (GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed, EGoWhichSide.StockSide)) - { - AxisPosPrint.PrintXY1Y2TargetPos("到料仓取料位上方,", targetPosition, GetClassName()); - flowStep = EFiveProductTestFlowStep.等待到料仓取料位上方; - } - } - } - - break; - case EFiveProductTestFlowStep.等待到料仓取料位上方: - if (Ops.IsStop("LoadX", "LoadY1", "LoadY2") || GlobalVar.VirtualAxis) - { - AxisPosPrint.PrintXY1Y2CurrentPos("轴XY1Y2已停止运动,", GetClassName()); - if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2)) - { - AxisPosPrint.PrintXY1Y2CurrentPos("已运动到等待到料仓取料位上方,", GetClassName()); - flowStep = EFiveProductTestFlowStep.到料仓取料位下方; - } - else - { - flowStep = EFiveProductTestFlowStep.到料仓取料位上方; - } - } - break; - case EFiveProductTestFlowStep.到料仓取料位下方: - targetPosition.NozzleZ = NozzleManager.GetNozzleToTrayTakeProductPos(ETrayType.Input, curTakeNozzle.NozzleIndex); - errCode = AxisControl.GetAxis($"NozzleZ{curTakeNozzle.NozzleIndex}").MovePos(targetPosition.NozzleZ, GlobalVar.WholeSpeed); - if (errCode == ErrorCode.Ok) - { - logInfo = $"{GetClassName()}到料仓取料位下方"; - MessageQueue.Instance.Insert(logInfo); - flowStep = EFiveProductTestFlowStep.等待到料仓取料位下方; - } - break; - case EFiveProductTestFlowStep.等待到料仓取料位下方: - if (Ops.IsStop($"NozzleZ{curTakeNozzle.NozzleIndex}")) - { - logInfo = $"{GetClassName()}已运动到料仓取料位下方"; - MessageQueue.Instance.Insert(logInfo); - if (GlobalVar.RunSpace) - { - flowStep = EFiveProductTestFlowStep.料仓取料完成抬起; - } - else - { - Ops.On($"吸料真空{curTakeNozzle.NozzleIndex}吸"); - Thread.Sleep(100); - flowStep = EFiveProductTestFlowStep.料仓取料完成抬起; - } - } - break; - case EFiveProductTestFlowStep.料仓取料完成抬起: - if (NozzleManager.GotoSafePos(curTakeNozzle.NozzleIndex)) - { - logInfo = $"{GetClassName()}料仓取料完成抬起"; - MessageQueue.Instance.Insert(logInfo); - flowStep = EFiveProductTestFlowStep.等待料仓取料完成抬起; - } - break; - case EFiveProductTestFlowStep.等待料仓取料完成抬起: - if (Ops.IsStop($"NozzleZ{curTakeNozzle.NozzleIndex}")) - { - logInfo = $"{GetClassName()}料仓取料完成已抬起"; - MessageQueue.Instance.Insert(logInfo); - flowStep = EFiveProductTestFlowStep.料仓取料真空吸检测; - } - break; - case EFiveProductTestFlowStep.料仓取料真空吸检测: - if (Ops.IsOn($"吸料真空{curTakeNozzle.NozzleIndex}检测") || GlobalVar.RunSpace) - { - curTakeNozzle.Product = new TestProduct() { SN = "", FromSlotIndex = curTakeSlot.Index }; - curTakeNozzle.Status = ENozzleStatus.ToUnload; - GlobalTray.NozzleTray.ChangeStatus(curTakeNozzle.NozzleIndex, ESlotStatus.Have); - GlobalTray.InputTray.ChangeStatus(curTakeSlot.Index, ESlotStatus.NotHave); - logInfo = $"{GetClassName()}料仓{curTakeSlot.Index}号穴位取料完成真空检测OK,产品SN:{curTakeNozzle.Product.SN}被吸嘴{curTakeNozzle.NozzleIndex}取走"; - MessageQueue.Instance.Insert(logInfo); - flowStep = EFiveProductTestFlowStep.到料仓放料位上方; - } - else - { - alarmEntity = AlarmCollection.Get(AlarmConstID.GRR取料失败报警); - Msgbox.ShowDialog(alarmEntity, EButtonType.Retry); - flowStep = EFiveProductTestFlowStep.到料仓取料位上方; - } - break; - #endregion - - - - - //料仓放料 - - case EFiveProductTestFlowStep.到料仓放料位上方: - //curDumpNozzle = NozzleManager.GetToUnloadNozzle(); - curDumpNozzle = NozzleManager.GetNozzle(1); - if (curDumpNozzle != null) - { - //吸嘴放料,加测吸嘴上的产品的测试结果,决定把料放到哪个料仓 - //目前先都方到OK料仓 - //curDumpSlot = GlobalTray.GrrTray.GetSlot(ESlotStatus.NotHave); - curDumpSlot = GlobalTray.OkTary.GetSlot(ESlotStatus.NotHave); - if (curDumpSlot != null) - { - //double curLoadX = Ops.GetCurPosition(AxisControl.LoadX); - //if (curLoadX - GlobalVar.FixtureSafePosX > 50) - //{ - // DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock); - //} - targetPosition = NozzleManager.GetToTraySlot(ETrayType.Ok, curDumpSlot.Index, curDumpNozzle.NozzleIndex); - if (GroupAxisMove.XY1Y2MovePos(targetPosition, GlobalVar.WholeSpeed, EGoWhichSide.StockSide)) - { - AxisPosPrint.PrintXY1Y2TargetPos("到料仓放料位上方,", targetPosition, GetClassName()); - flowStep = EFiveProductTestFlowStep.等待到料仓放料位上方; - } - } - else - { - GlobalTray.GrrTray.ChangeStatus(ESlotStatus.NotHave); - } - } - break; - case EFiveProductTestFlowStep.等待到料仓放料位上方: - 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 = EFiveProductTestFlowStep.到料仓放料位下方; - } - else - { - flowStep = EFiveProductTestFlowStep.到料仓放料位上方; - } - } - break; - case EFiveProductTestFlowStep.到料仓放料位下方: - targetPosition.NozzleZ = NozzleManager.GetNozzleToTrayTakeProductPos(ETrayType.Ok, curDumpNozzle.NozzleIndex); - if (NozzleManager.Go(curDumpNozzle, targetPosition.NozzleZ, GlobalVar.WholeSpeed)) - { - logInfo = $"{GetClassName()}到料仓放料位下方"; - MessageQueue.Instance.Insert(logInfo); - flowStep = EFiveProductTestFlowStep.等待到料仓放料位下方; - } - break; - case EFiveProductTestFlowStep.等待到料仓放料位下方: - if (Ops.IsStop($"NozzleZ{curDumpNozzle.NozzleIndex}")) - { - logInfo = $"{GetClassName()}已运动到料仓放料位下方"; - MessageQueue.Instance.Insert(logInfo); - if (GlobalVar.RunSpace) - { - flowStep = EFiveProductTestFlowStep.料仓放料完成抬起; - } - else - { - curDumpNozzle.VacSuction(EIoOperate.Close, GetClassName()); - curDumpNozzle.VacBreak(EIoOperate.Open, GetClassName()); - curDumpNozzle.VacBreak(EIoOperate.Close, GetClassName()); - flowStep = EFiveProductTestFlowStep.料仓放料完成抬起; - } - } - break; - case EFiveProductTestFlowStep.料仓放料完成抬起: - if (NozzleManager.GotoSafePos(curDumpNozzle.NozzleIndex)) - { - logInfo = $"{GetClassName()}料仓放料完成抬起"; - MessageQueue.Instance.Insert(logInfo); - flowStep = EFiveProductTestFlowStep.等待料仓放料完成抬起; - } - break; - case EFiveProductTestFlowStep.等待料仓放料完成抬起: - if (Ops.IsStop($"NozzleZ{curDumpNozzle.NozzleIndex}")) - { - logInfo = $"{GetClassName()}料仓放料完成已抬起"; - MessageQueue.Instance.Insert(logInfo); - takedNum++; - curDumpNozzle.Status = ENozzleStatus.IDLE; - GlobalTray.OkTary.ChangeStatus(curDumpSlot.Index, ESlotStatus.Have); - - if (takedNum < 5) - { - flowStep = EFiveProductTestFlowStep.到料仓拍照位上方; - } - else - { - DischargeModuleGoSafePosFlow.Instance.GoSafePostion(); - stop = true; - } - } - break; - } - Thread.Sleep(5); - } - } - - public void Start() - { - GlobalTray.InputTray.ChangeStatus(1, ESlotStatus.Have); - GlobalTray.InputTray.ChangeStatus(2, ESlotStatus.Have); - GlobalTray.InputTray.ChangeStatus(3, ESlotStatus.Have); - GlobalTray.InputTray.ChangeStatus(4, ESlotStatus.Have); - GlobalTray.InputTray.ChangeStatus(5, ESlotStatus.Have); - - GlobalTray.OkTary.ChangeStatus(1, ESlotStatus.NotHave); - GlobalTray.OkTary.ChangeStatus(2, ESlotStatus.NotHave); - GlobalTray.OkTary.ChangeStatus(3, ESlotStatus.NotHave); - GlobalTray.OkTary.ChangeStatus(4, ESlotStatus.NotHave); - GlobalTray.OkTary.ChangeStatus(5, ESlotStatus.NotHave); - flowStep = EFiveProductTestFlowStep.OK盘三点定位; - takedNum = 0; - stop = false; - } - public void Stop() - { - stop = true; - } - private string GetClassName() - { - return "GrrFlow-"; - } - - private double offsetX = 0; - private double offsetY = 0; - public void SetOffset(double x,double y) - { - offsetX = x; - offsetY = y; - } - - /// - /// 获取吸嘴取料取不起来时,吸嘴在原取料位的偏移 - /// 奇数向下偏移 - /// 偶数向上偏移 - /// - /// - /// - private double GetVacOffsetHeight(int fetchNum) - { - if (fetchNum == 0) return 0; - //先判断是奇数还是偶数 - int count = 0; - int oddOrEven = fetchNum & 0x01; - - double offsetDisct = 0.0; - if (oddOrEven == 1) - { - count = (fetchNum / 2) + 1; - offsetDisct = -0.1 * count; - } - - else if (oddOrEven == 0) - { - count = (fetchNum / 2); - offsetDisct = 0.1 * count; - } - return offsetDisct; - } - - public string GetCurStep() - { - return flowStep.ToString(); - } - - public void VirtualAxisSleep() - { - if (GlobalVar.VirtualAxis) - { - Thread.Sleep(GlobalVar.VirtualAxisMoveTime); - } - } - - - private void GotoNextFixture() - { - lastFixtureIndex = ((lastFixtureIndex + 1) % needGrrFixtureList.Count); - } - - - } -} diff --git a/Rs.DeweyTester/Flow/SubFlow/FixedGrabProductFlow.cs b/Rs.DeweyTester/Flow/SubFlow/FixedGrabProductFlow.cs index 3ee0e20..8e10438 100644 --- a/Rs.DeweyTester/Flow/SubFlow/FixedGrabProductFlow.cs +++ b/Rs.DeweyTester/Flow/SubFlow/FixedGrabProductFlow.cs @@ -41,7 +41,7 @@ namespace Rs.MotionPlat.Flow.SubFlow bool finished = true; EFixedGrabProductFlowStep step = EFixedGrabProductFlowStep.到拍照位上方; - public ProductLocationResult TakePicture(ETrayType trayType,int slotInex,int grabNum=3) + public ProductLocationResult TakePicture(ETrayType trayType, int slotInex, int grabNum = 3, bool hasProdcutCheck = false) { ProductLocationResult result = new ProductLocationResult() { @@ -119,42 +119,69 @@ namespace Rs.MotionPlat.Flow.SubFlow } break; case EFixedGrabProductFlowStep.相机拍照处理: - VisionHelper.oneGrabOneVision.ClearQueue(); - UpCameraHelper.Grab(); - string msg = VisionHelper.OneGrabOne(); - result.Parse(msg); - //VisionResult vResult = VisionHelper.Grab(EVisionScene.SingleScanBarcode); - if ((result != null && result.Result== EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace) + if (hasProdcutCheck) { - finished = true; - if (GlobalVar.RunSpace) + VisionHelper.oneGrabOneVision.ClearQueue("C2"); + UpCameraHelper.Grab(); + string msg = VisionHelper.OneGrabOne("M2"); + result.Parse(msg); + //VisionResult vResult = VisionHelper.Grab(EVisionScene.SingleScanBarcode); + if ((result != null && result.Result == EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace) { - result = new ProductLocationResult() { Result= EOneGrabSixteenResult.Ok}; + finished = true; + if (GlobalVar.RunSpace) + { + result = new ProductLocationResult() { Result = EOneGrabSixteenResult.Ok }; + } + return result; + } + else + { + finished = true; + return result; } - return result; } else { - if(curGrabNum<=3) + VisionHelper.oneGrabOneVision.ClearQueue("C"); + UpCameraHelper.Grab(); + string msg = VisionHelper.OneGrabOne("M"); + result.Parse(msg); + //VisionResult vResult = VisionHelper.Grab(EVisionScene.SingleScanBarcode); + if ((result != null && result.Result == EOneGrabSixteenResult.Ok) || GlobalVar.RunSpace) { - step = EFixedGrabProductFlowStep.到拍照位上方; + LogHelper.Debug("result=ok"); + finished = true; + if (GlobalVar.RunSpace) + { + result = new ProductLocationResult() { Result = EOneGrabSixteenResult.Ok }; + } + return result; } else { - AlarmEntity alarmEntity = AlarmCollection.Get(AlarmConstID.料仓取料拍照失败).Transform(grabSlot.Index); - // EButtonType btn = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry| EButtonType.Cancel); - //if(btn== EButtonType.Retry) - //{ - // curGrabNum = 1; - // step = EFixedGrabProductFlowStep.到拍照位上方; - //} - //else if(btn== EButtonType.Cancel) + LogHelper.Debug("result=ng"); + if (curGrabNum <= 3) + { + step = EFixedGrabProductFlowStep.到拍照位上方; + } + else { - finished=true; - return result; + //AlarmEntity alarmEntity = AlarmCollection.Get(AlarmConstID.料仓取料拍照失败).Transform(grabSlot.Index); + // EButtonType btn = Msgbox.ShowDialog(alarmEntity, EButtonType.Retry| EButtonType.Cancel); + //if(btn== EButtonType.Retry) + //{ + // curGrabNum = 1; + // step = EFixedGrabProductFlowStep.到拍照位上方; + //} + //else if(btn== EButtonType.Cancel) + { + finished = true; + return result; + } } + curGrabNum++; } - curGrabNum++; } break; } diff --git a/Rs.DeweyTester/Rs.DeweyTester.csproj b/Rs.DeweyTester/Rs.DeweyTester.csproj index 4455001..2c14a34 100644 --- a/Rs.DeweyTester/Rs.DeweyTester.csproj +++ b/Rs.DeweyTester/Rs.DeweyTester.csproj @@ -135,6 +135,7 @@ + @@ -148,6 +149,7 @@ + @@ -164,7 +166,6 @@ DataRecords.cs - diff --git a/Rs.DeweyTester/Vision/OneGrabOneVision.cs b/Rs.DeweyTester/Vision/OneGrabOneVision.cs index 8b51351..face0f6 100644 --- a/Rs.DeweyTester/Vision/OneGrabOneVision.cs +++ b/Rs.DeweyTester/Vision/OneGrabOneVision.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; @@ -25,12 +26,13 @@ namespace Rs.MotionPlat.Vision else { data = Encoding.ASCII.GetString(reciveBuffer.ToArray()); - MessageQueue.Instance.Insert(data); - if (data == "M,0") + //MessageQueue.Instance.Insert(data); + if (data == "M,0" || data=="M2,0") { - MessageQueue.Instance.Insert("视觉收到拍照指令"); + MessageQueue.Instance.Insert($">>> {data}"); } - else if (data == "C,0") + //else if (Regex.IsMatch( data,"C\\d{0,1},0"))// == "C,0") + else if (data == "C,0" || data == "C2,0") { visionGrabEvent.Set(); MessageQueue.Instance.Insert($" >>> {data}"); @@ -71,10 +73,10 @@ namespace Rs.MotionPlat.Vision } } - public bool ClearQueue(int timeout = 10000) + public bool ClearQueue(string cmd,int timeout = 10000) { visionGrabEvent.Reset(); - string content = $"C;"; + string content = $"{cmd};"; int len = vNozzleCalib.Send(content); //reciveData = true; if (len > 0) @@ -103,18 +105,19 @@ namespace Rs.MotionPlat.Vision /// /// /// - public string OneGrabOne(int timeout = 10000) + public string OneGrabOne(string cmd,int timeout = 10000) { data = ""; result = null; NozzleCalibReciveEvent.Reset(); - int len = vNozzleCalib.Send("M;"); + int len = vNozzleCalib.Send($"{cmd};"); + LogHelper.Debug($"<<< {cmd};len={len}"); if (len > 0) { if (NozzleCalibReciveEvent.WaitOne(timeout)) { - MessageQueue.Instance.Insert($"收到视觉结果:{data}"); + MessageQueue.Instance.Insert($">>> {data}"); return data; } else diff --git a/Rs.DeweyTester/Vision/VisionHelper.cs b/Rs.DeweyTester/Vision/VisionHelper.cs index d7bfd9b..555124d 100644 --- a/Rs.DeweyTester/Vision/VisionHelper.cs +++ b/Rs.DeweyTester/Vision/VisionHelper.cs @@ -85,9 +85,9 @@ namespace Rs.MotionPlat.Commom } - public static string OneGrabOne() + public static string OneGrabOne(string cmd) { - return oneGrabOneVision.OneGrabOne(); + return oneGrabOneVision.OneGrabOne(cmd); } } }