From 690c9183f13bc275a8643ef28b2670a034b5153e Mon Sep 17 00:00:00 2001 From: lhiven Date: Sun, 28 Jul 2024 07:39:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BD=B4=E4=B9=B1=E8=B7=91?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.DeweyTester/Commom/GlobalVar.cs | 6 -- Rs.DeweyTester/Flow/BaseFlow.cs | 2 +- .../Flow/NormalFlow/DischargeFlow.cs | 63 ++++++++++++++----- Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs | 2 +- .../Flow/NormalFlow/ThreePointLocationFlow.cs | 12 ++-- .../Flow/SubFlow/FiveProductTestFlow.cs | 2 +- .../Flow/SubFlow/FixturePlaceFlow.cs | 4 +- Rs.DeweyTester/Flow/SubFlow/StockPlaceFlow.cs | 20 ++++-- Rs.DeweyTester/Flow/SubFlow/StockTakeFlow.cs | 21 +++++-- Rs.DeweyTester/FormMain.cs | 4 +- Rs.DeweyTester/SysConfig/SelectProductFrm.cs | 35 ++++++----- Rs.DeweyTester/SysConfig/StockConfig.cs | 2 +- Rs.DeweyTester/TestFrm.Designer.cs | 13 ++++ Rs.DeweyTester/TestFrm.cs | 20 ++++++ 14 files changed, 148 insertions(+), 58 deletions(-) diff --git a/Rs.DeweyTester/Commom/GlobalVar.cs b/Rs.DeweyTester/Commom/GlobalVar.cs index c4e6444..a90c450 100644 --- a/Rs.DeweyTester/Commom/GlobalVar.cs +++ b/Rs.DeweyTester/Commom/GlobalVar.cs @@ -3428,11 +3428,5 @@ namespace Rs.Framework return SysConfigParam.GetValue(nameof(EnableIndexTimeStatistics)); } } - /// - /// 设备是否是自动状态 - /// - public static bool DeviceIsAuto { get; set; } = true; - - } } diff --git a/Rs.DeweyTester/Flow/BaseFlow.cs b/Rs.DeweyTester/Flow/BaseFlow.cs index af3b664..b554c32 100644 --- a/Rs.DeweyTester/Flow/BaseFlow.cs +++ b/Rs.DeweyTester/Flow/BaseFlow.cs @@ -34,7 +34,7 @@ namespace Rs.MotionPlat.Flow private void task() { while (b_IsRun) { - if(b_IsStop || !GlobalVar.DeviceIsAuto) + if(b_IsStop) { Thread.Sleep(stopWaitTime); continue; diff --git a/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs index 4557b29..5c2dbbf 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs @@ -39,7 +39,7 @@ namespace Rs.MotionPlat.Flow 到治具取料等待位, 等待到治具取料等待位, 等待治具测试完成换料, - 治具取放料, + 治具取料, 治具放料, //料仓放料 判断是否需要放料到料仓, @@ -132,7 +132,7 @@ namespace Rs.MotionPlat.Flow { while (run) { - if (stop || !GlobalVar.DeviceIsAuto) + if (stop) { Thread.Sleep(10); continue; @@ -508,7 +508,7 @@ namespace Rs.MotionPlat.Flow needPlaceNozzle = GetPlaceNozzle(curFixture); if (needPlaceNozzle != null) { - flowStep = EDischargeFlowStep.治具取放料; + flowStep = EDischargeFlowStep.治具取料; break; } else @@ -516,7 +516,7 @@ namespace Rs.MotionPlat.Flow //治具里面有产品但是吸嘴已经没有可以产品可以交换 if (GlobalVar.Clear && NozzleManager.GetIdelNozzle() != null) { - flowStep = EDischargeFlowStep.治具取放料; + flowStep = EDischargeFlowStep.治具取料; break; //在这里先去把要放的产品给放下去,再回来取 } @@ -537,25 +537,37 @@ namespace Rs.MotionPlat.Flow } break; - case EDischargeFlowStep.治具取放料: + case EDischargeFlowStep.治具取料: FixtureTakeFlow.Instance.Take(curFixture.Index); - if(needPlaceNozzle != null) + if(needPlaceNozzle != null && needPlaceNozzle.Status== ENozzleStatus.ToTest) { flowStep = EDischargeFlowStep.治具放料; } else { int num = TestFixtureManager.Instance.GetHaveProductFixtureList().Count(); - if(GlobalVar.Clear && NozzleManager.GetToTestNozzle()==null && ((num==0) ||(NozzleManager.GetIdelNozzle() == null))) + int tounloadNum = NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count(); + //if(GlobalVar.Clear && ( + // (tounloadNum==3) + // || (num==0) + // ||(NozzleManager.GetToTestNozzle() == null))) + if(tounloadNum == 3 + || num == 0 + //|| NozzleManager.GetToTestNozzle() == null + ) { + logInfo =GetClassName()+ $"clear:{GlobalVar.Clear},tounloadnum:{tounloadNum},num:{num}"; + MessageQueue.Instance.Insert(logInfo); //if(curFixture.Index==6) //{ // DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock); //} + CreateCheckFixtureQueue(curFixture.Index); flowStep = EDischargeFlowStep.判断是否需要放料到料仓; } else { + CreateCheckFixtureQueue(curFixture.Index); flowStep = EDischargeFlowStep.到治具取料等待位; } } @@ -569,18 +581,41 @@ namespace Rs.MotionPlat.Flow //lastFixtureIndex = checkFixtureList[0] - 1; //lastFixtureIndex = curFixture.Index == checkFixtureList.Max() ? checkFixtureList.Min()-1 : curFixture.Index; //lastFixtureIndex = curFixture.Index == 6 ? 0 : curFixture.Index; - if (NozzleManager.GetToTestNozzle() != null || (GlobalVar.Clear && TestFixtureManager.Instance.GetHasProuctFixtureCount()>0)) + + int num = TestFixtureManager.Instance.GetHaveProductFixtureList().Count(); + int tounloadNum = NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count(); + if ( + tounloadNum==3 + || num==0 + || NozzleManager.GetToTestNozzle() == null + ) + //GlobalVar.Clear && ( + //NozzleManager.GetToTestNozzle() == null + //|| (tounloadNum == 3) + //|| (num == 0) + //|| (NozzleManager.GetIdelNozzle() == null))) { - flowStep = EDischargeFlowStep.到治具取料等待位; + flowStep = EDischargeFlowStep.判断是否需要放料到料仓; } else { - //if (curFixture.Index == 6) - //{ - // DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock); - //} - flowStep = EDischargeFlowStep.判断是否需要放料到料仓; + flowStep = EDischargeFlowStep.到治具取料等待位; } + + + // if (NozzleManager.GetToTestNozzle() != null + // ||(GlobalVar.Clear && TestFixtureManager.Instance.GetHasProuctFixtureCount()>0 && NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count<3)) + //{ + // flowStep = EDischargeFlowStep.到治具取料等待位; + //} + //else + //{ + // //if (curFixture.Index == 6) + // //{ + // // DischargeModuleGoSafePosFlow.Instance.GoSafePostion(ESafePosSide.PlaceToStock); + // //} + // flowStep = EDischargeFlowStep.判断是否需要放料到料仓; + //} } break; diff --git a/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs index d46318e..5f29ef0 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs @@ -165,7 +165,7 @@ namespace Rs.MotionPlat.Flow { while (run) { - if (stop || !GlobalVar.DeviceIsAuto) + if (stop) { Thread.Sleep(10); continue; diff --git a/Rs.DeweyTester/Flow/NormalFlow/ThreePointLocationFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/ThreePointLocationFlow.cs index 9571df2..577de54 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/ThreePointLocationFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/ThreePointLocationFlow.cs @@ -65,13 +65,13 @@ namespace Rs.MotionPlat.Flow.NormalFlow //Task.Run(() => { while (!finished) { - if(stop) - { - Thread.Sleep(10); - continue; - } + if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop) + { + Thread.Sleep(10); + continue; + } - switch (step) + switch (step) { case EThreePointLocationFlowStep.到拍照位: diff --git a/Rs.DeweyTester/Flow/SubFlow/FiveProductTestFlow.cs b/Rs.DeweyTester/Flow/SubFlow/FiveProductTestFlow.cs index ed8c0a2..387c799 100644 --- a/Rs.DeweyTester/Flow/SubFlow/FiveProductTestFlow.cs +++ b/Rs.DeweyTester/Flow/SubFlow/FiveProductTestFlow.cs @@ -136,7 +136,7 @@ namespace Rs.MotionPlat.Flow.SubFlow { while (run) { - if (stop || !GlobalVar.DeviceIsAuto) + if (stop) { Thread.Sleep(10); continue; diff --git a/Rs.DeweyTester/Flow/SubFlow/FixturePlaceFlow.cs b/Rs.DeweyTester/Flow/SubFlow/FixturePlaceFlow.cs index e1ba976..1e44410 100644 --- a/Rs.DeweyTester/Flow/SubFlow/FixturePlaceFlow.cs +++ b/Rs.DeweyTester/Flow/SubFlow/FixturePlaceFlow.cs @@ -99,6 +99,7 @@ namespace Rs.MotionPlat.Flow.SubFlow AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,", GetClassName()); if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2)) { + Thread.Sleep(100); AxisPosPrint.PrintXY1Y2CurrentPos($"已运动到治具{curFixture.Index}拍照位,", GetClassName()); flowStep = EFixturePlaceFlowStep.通知相机拍照; } @@ -167,6 +168,7 @@ namespace Rs.MotionPlat.Flow.SubFlow AxisPosPrint.PrintXY1Y2CurrentPos("轴loadx,loady1,loady2已停止运动,", GetClassName()); if (AxisArrived.LoadXY1Y2IsArrived(targetPosition.X, targetPosition.Y1, targetPosition.Y2)) { + Thread.Sleep(100); AxisPosPrint.PrintXY1Y2CurrentPos($"已运动到治具{curFixture.Index}放料位上方,", GetClassName()); flowStep = EFixturePlaceFlowStep.到治具放料位下方1; } @@ -205,7 +207,7 @@ namespace Rs.MotionPlat.Flow.SubFlow case EFixturePlaceFlowStep.等待到治具放料位下方2: if (Ops.IsStop($"NozzleZ{curNozzle.NozzleIndex}")) { - Thread.Sleep(100); + Thread.Sleep(300); logInfo = GetClassName() + $"已运动到治具{curFixture.Index}放料位下方2"; MessageQueue.Instance.Insert(logInfo); if (GlobalVar.RunSpace) diff --git a/Rs.DeweyTester/Flow/SubFlow/StockPlaceFlow.cs b/Rs.DeweyTester/Flow/SubFlow/StockPlaceFlow.cs index 3ac26fa..0f69bac 100644 --- a/Rs.DeweyTester/Flow/SubFlow/StockPlaceFlow.cs +++ b/Rs.DeweyTester/Flow/SubFlow/StockPlaceFlow.cs @@ -186,12 +186,20 @@ namespace Rs.MotionPlat.Flow.SubFlow case EStockPlaceFlowStep.料仓放料完成粘料检测: if (!curNozzle.HasProduct() || GlobalVar.RunSpace) { - PlaceFinishedEvent?.Invoke(curNozzle.Product); - logInfo = $"{GetClassName()}检测到吸嘴{curNozzle.NozzleIndex}无粘料,吸嘴{curNozzle.NozzleIndex}把产品SN:{curNozzle.Product.SN}放入OK料盘{curPlaceSlot.Index}穴位"; - MessageQueue.Instance.Insert(logInfo); - tray.ChangeStatus(curPlaceSlot.Index, ESlotStatus.Have); - curNozzle.Product.ToString(); - curNozzle.Clear(); + if(curNozzle.Product!=null) + { + PlaceFinishedEvent?.Invoke(curNozzle.Product); + logInfo = $"{GetClassName()}检测到吸嘴{curNozzle.NozzleIndex}无粘料,吸嘴{curNozzle.NozzleIndex}把产品SN:{curNozzle.Product.SN}放入OK料盘{curPlaceSlot.Index}穴位"; + MessageQueue.Instance.Insert(logInfo); + tray.ChangeStatus(curPlaceSlot.Index, ESlotStatus.Have); + curNozzle.Product.ToString(); + curNozzle.Clear(); + } + else + { + curNozzle.Clear(); + tray.ChangeStatus(curPlaceSlot.Index, ESlotStatus.Have); + } finished = true; flowStep = EStockPlaceFlowStep.待触发; } diff --git a/Rs.DeweyTester/Flow/SubFlow/StockTakeFlow.cs b/Rs.DeweyTester/Flow/SubFlow/StockTakeFlow.cs index 4f15af0..cd9475c 100644 --- a/Rs.DeweyTester/Flow/SubFlow/StockTakeFlow.cs +++ b/Rs.DeweyTester/Flow/SubFlow/StockTakeFlow.cs @@ -58,7 +58,7 @@ namespace Rs.MotionPlat.Flow.SubFlow /// 料仓取料 /// /// - public void Take(ETrayType trayType, int slotIndex,int nozzleIndex) + public void Take(ETrayType trayType, int slotIndex,int nozzleIndex, ProductLocationResult locaResult=null) { if (finished) finished = false; @@ -105,6 +105,12 @@ namespace Rs.MotionPlat.Flow.SubFlow targetPosition.Y2 += result.OffsetY; } } + if(locaResult!=null) + { + MessageQueue.Instance.Insert($"拍照偏移量 x:{locaResult.OffsetX},y:{locaResult.OffsetY}"); + targetPosition.X += locaResult.OffsetX; + targetPosition.Y2 += locaResult.OffsetY; + } double curLoadX = Ops.GetCurPosition(AxisControl.LoadX); if (curLoadX - GlobalVar.FixtureSafePosX > 50) { @@ -182,14 +188,21 @@ namespace Rs.MotionPlat.Flow.SubFlow } else { - curNozzle.Product = new TestProduct() { SN = OneGrabSixteenManager.Instance.GetResultBySlotIndex(slotIndex).SN, TestNum = 0, From = $"R{waitTakeProductSlot.Row + 1}C{waitTakeProductSlot.Column + 1}" }; + if(OneGrabSixteenManager.Instance.GetResultBySlotIndex(slotIndex)!=null) + { + curNozzle.Product = new TestProduct() { SN = OneGrabSixteenManager.Instance.GetResultBySlotIndex(slotIndex).SN, TestNum = 0, From = $"R{waitTakeProductSlot.Row + 1}C{waitTakeProductSlot.Column + 1}" }; + } } curNozzle.Status = ENozzleStatus.ToTest; //curNozzle.Status = ENozzleStatus.ToUnload; GlobalTray.NozzleTray.ChangeStatus(curNozzle.NozzleIndex, ESlotStatus.Have); GlobalTray.InputTray.ChangeStatus(waitTakeProductSlot.Index, ESlotStatus.NotHave); - logInfo = $"{GetClassName()} from r{waitTakeProductSlot.Row+1}c{waitTakeProductSlot.Column+1} 穴位索引:{waitTakeProductSlot.Index} 产品:{curNozzle.Product.SN}被吸嘴{curNozzle.NozzleIndex}取料完成,"; - MessageQueue.Instance.Insert(logInfo); + if(curNozzle.Product!=null) + { + logInfo = $"{GetClassName()} from r{waitTakeProductSlot.Row + 1}c{waitTakeProductSlot.Column + 1} 穴位索引:{waitTakeProductSlot.Index} 产品:{curNozzle.Product.SN}被吸嘴{curNozzle.NozzleIndex}取料完成,"; + MessageQueue.Instance.Insert(logInfo); + } + //flowStep = EStockTakeFlowStep.判断是否需要从料仓取料; finished = true; flowStep = EStockTakeFlowStep.待触发; diff --git a/Rs.DeweyTester/FormMain.cs b/Rs.DeweyTester/FormMain.cs index 44e3863..d529241 100644 --- a/Rs.DeweyTester/FormMain.cs +++ b/Rs.DeweyTester/FormMain.cs @@ -202,7 +202,7 @@ namespace Rs.MotionPlat GlobalTray.NozzleTray = trayNozzle ; //StockManager.Instance.Start(); LoadStockStatus(); - switchButton1.Checked = GlobalVar.DeviceIsAuto; + switchButton1.Checked = GlobalVar.Clear; ; @@ -272,7 +272,7 @@ namespace Rs.MotionPlat int.TryParse(lblPassNum.Text,out int passNum); int.TryParse(lblNgNum.Text, out int ngNum); totalNum++; - if (pro.Result == "PASS") + if (pro!= null && pro.Result == "PASS") { passNum++; } diff --git a/Rs.DeweyTester/SysConfig/SelectProductFrm.cs b/Rs.DeweyTester/SysConfig/SelectProductFrm.cs index acb0814..fce23d7 100644 --- a/Rs.DeweyTester/SysConfig/SelectProductFrm.cs +++ b/Rs.DeweyTester/SysConfig/SelectProductFrm.cs @@ -1,6 +1,7 @@ using Rs.Controls; using Rs.MotionPlat.Commom; using Rs.MotionPlat.Entitys; +using Rs.MotionPlat.Flow.NormalFlow; using Rs.MotionPlat.Flow.SafePosFlow; using Rs.MotionPlat.Flow.SubFlow; using System; @@ -27,6 +28,10 @@ namespace Rs.MotionPlat.SysConfig private void btnSelect_Click(object sender, EventArgs e) { + if(!string.IsNullOrEmpty(txtSn.Text)) + { + ThreePointLocationFlow.Instance.Location(ETrayType.ReTest); + } SelectProduct(); } @@ -47,15 +52,15 @@ namespace Rs.MotionPlat.SysConfig string[] files = Directory.GetFiles(selectDir); if (files != null && files.Length > 0) { - List fint = new List(); - foreach (string file in files) - { - string fname = Path.GetFileName(file); - string[] items = fname.Split('-'); - int index =int.Parse(Path.GetFileNameWithoutExtension(items[1])); - fint.Add(index); - } - fileName = $"{DateTime.Now.ToString("yyyyMMdd")}-{fint.Max()+1}.csv"; + //List fint = new List(); + //foreach (string file in files) + //{ + // string fname = Path.GetFileName(file); + // string[] items = fname.Split('-'); + // int index =int.Parse(Path.GetFileNameWithoutExtension(items[1])); + // fint.Add(index); + //} + fileName = $"{DateTime.Now.ToString("yyyyMMdd")}-{files.Length+1}.csv"; } else { @@ -79,12 +84,12 @@ namespace Rs.MotionPlat.SysConfig if(txtSn.Text.IndexOf(fixtureret.SN)>=0) { - ProductLocationResult ret = OneGrabSixteenManager.Instance.GetResultByIndex(0); - ret.SlotIndex = i+1; - ret.SN= fixtureret.SN; - ret.OffsetX = fixtureret.OffsetX; - ret.OffsetY = fixtureret.OffsetY; - StockTakeFlow.Instance.Take( ETrayType.Grr, i + 1, 1); + //ProductLocationResult ret = OneGrabSixteenManager.Instance.GetResultByIndex(0); + //ret.SlotIndex = i+1; + //ret.SN= fixtureret.SN; + //ret.OffsetX = fixtureret.OffsetX; + //ret.OffsetY = fixtureret.OffsetY; + StockTakeFlow.Instance.Take( ETrayType.Grr, i + 1, 1, fixtureret); TraySlot slot = GlobalTray.RetestTray.GetSlot(Rs.Controls.ESlotStatus.NotHave); StockPlaceFlow.Instance.Place(ETrayType.ReTest, slot.Index, 1); } diff --git a/Rs.DeweyTester/SysConfig/StockConfig.cs b/Rs.DeweyTester/SysConfig/StockConfig.cs index 55d5822..998b8d4 100644 --- a/Rs.DeweyTester/SysConfig/StockConfig.cs +++ b/Rs.DeweyTester/SysConfig/StockConfig.cs @@ -402,7 +402,7 @@ namespace Rs.MotionPlat.SysConfig private void btnInputToEmpty_Click(object sender, EventArgs e) { Task.Run(() => { - TakeTrayFlow.Instance.Take(ETrayType.Empty, ETrayType.Empty); + TakeTrayFlow.Instance.Take(ETrayType.Input, ETrayType.Empty); }); } diff --git a/Rs.DeweyTester/TestFrm.Designer.cs b/Rs.DeweyTester/TestFrm.Designer.cs index 5f01e15..210172a 100644 --- a/Rs.DeweyTester/TestFrm.Designer.cs +++ b/Rs.DeweyTester/TestFrm.Designer.cs @@ -67,6 +67,7 @@ this.textBox4 = new System.Windows.Forms.TextBox(); this.button7 = new System.Windows.Forms.Button(); this.button8 = new System.Windows.Forms.Button(); + this.button9 = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -518,11 +519,22 @@ this.button8.Text = "button7"; this.button8.UseVisualStyleBackColor = true; // + // button9 + // + this.button9.Location = new System.Drawing.Point(434, 362); + this.button9.Name = "button9"; + this.button9.Size = new System.Drawing.Size(180, 106); + this.button9.TabIndex = 38; + this.button9.Text = "产品搬运"; + this.button9.UseVisualStyleBackColor = true; + this.button9.Click += new System.EventHandler(this.button9_Click); + // // TestFrm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1336, 854); + this.Controls.Add(this.button9); this.Controls.Add(this.button8); this.Controls.Add(this.button7); this.Controls.Add(this.button6); @@ -589,5 +601,6 @@ private System.Windows.Forms.TextBox textBox4; private System.Windows.Forms.Button button7; private System.Windows.Forms.Button button8; + private System.Windows.Forms.Button button9; } } \ No newline at end of file diff --git a/Rs.DeweyTester/TestFrm.cs b/Rs.DeweyTester/TestFrm.cs index 30f8d30..5e1043e 100644 --- a/Rs.DeweyTester/TestFrm.cs +++ b/Rs.DeweyTester/TestFrm.cs @@ -313,5 +313,25 @@ namespace Rs.MotionPlat { } + + private void button9_Click(object sender, EventArgs e) + { + Task.Run(() => { + while (true) + { + TraySlot slot = GlobalTray.GrrTray.GetSlot(ESlotStatus.Have); + if(slot==null) + { + break; + } + else + { + StockTakeFlow.Instance.Take(ETrayType.Grab, slot.Index, 1); + slot = GlobalTray.RetestTray.GetSlot(ESlotStatus.NotHave); + StockPlaceFlow.Instance.Place(ETrayType.ReTest, slot.Index, 1); + } + } + }); + } } }