From 93ceaf876d88f70e54677fd6fe5a90bee93a8006 Mon Sep 17 00:00:00 2001 From: lhiven Date: Thu, 4 Jan 2024 12:15:58 +0900 Subject: [PATCH] =?UTF-8?q?1=20=E7=9B=B8=E6=9C=BA=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9B=9D=E5=85=89/=E5=A2=9E=E7=9B=8A?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=202=20=E6=96=99=E7=9B=98=E6=90=AC?= =?UTF-8?q?=E8=BF=90=E6=94=B9=E4=B8=BA=E5=8E=9F=E6=9D=A5=E7=9A=84=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E6=9F=A5=E7=9C=8B=E6=96=99=E7=9B=98=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=203=20=E5=A2=9E=E5=8A=A0=E6=96=99=E7=9B=98=E6=90=AC=E8=BF=90?= =?UTF-8?q?=E6=97=B6=E6=98=AF=E5=90=A6=E5=B1=8F=E8=94=BD=E7=9C=9F=E7=A9=BA?= =?UTF-8?q?=E5=90=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.SkyLine/Commom/GlobalVar.cs | 11 ++ Rs.SkyLine/Flow/NormalFlow/TakeTrayFlow.cs | 111 +++++++++++----- Rs.SkyLine/SysConfig/ClampConfig.Designer.cs | 1 - Rs.SkyLine/SysConfig/LookCamera.cs | 4 +- Rs.SkyLine/SysConfig/LookCamera.designer.cs | 130 ++++++++++--------- Rs.SkyLine/SysConfig/StockControl.cs | 4 +- 6 files changed, 165 insertions(+), 96 deletions(-) diff --git a/Rs.SkyLine/Commom/GlobalVar.cs b/Rs.SkyLine/Commom/GlobalVar.cs index 713699a..d6a6691 100644 --- a/Rs.SkyLine/Commom/GlobalVar.cs +++ b/Rs.SkyLine/Commom/GlobalVar.cs @@ -896,5 +896,16 @@ namespace Rs.Framework return SysConfigParam.GetValue(nameof(TurnoverTrayHaveOrNotGrayArea)); } } + + /// + /// 料盘搬运屏蔽真空吸 + /// + public static bool TakeTrayDisableVac + { + get + { + return true; + } + } } } diff --git a/Rs.SkyLine/Flow/NormalFlow/TakeTrayFlow.cs b/Rs.SkyLine/Flow/NormalFlow/TakeTrayFlow.cs index 7db141a..d21ae02 100644 --- a/Rs.SkyLine/Flow/NormalFlow/TakeTrayFlow.cs +++ b/Rs.SkyLine/Flow/NormalFlow/TakeTrayFlow.cs @@ -29,9 +29,11 @@ namespace Rs.MotionPlat.Flow 等待到放料盘上方, 等待放料仓准备就绪, 等待运动到放料位下方, + 等待夹爪气缸张开, 放料盘完成后抬起, 等待放料完成抬起, - 放料完成后真空检测 + 放料完成后真空检测, + 搬运完成 } public enum ETakeStatus @@ -101,14 +103,14 @@ namespace Rs.MotionPlat.Flow case ETakeTrayFlowStep.到取料盘上方: //double centerX = SysConfigParam.GetValue($"Tray{m_fromTray.ToString()}CenterX"); //double centerY = SysConfigParam.GetValue($"Tray{m_fromTray.ToString()}CenterY"); - //double cameraCenterX = SysConfigParam.GetValue("ClampCenter2UpCameraCenterX"); - //double cameraCenterY = SysConfigParam.GetValue("ClampCenter2UpCameraCenterY"); + double cameraCenterX = SysConfigParam.GetValue("ClampCenter2UpCameraCenterX"); + double cameraCenterY = SysConfigParam.GetValue("ClampCenter2UpCameraCenterY"); targetX = SysConfigParam.GetValue($"{m_fromTray.ToString()}TakeTrayX"); targetY = SysConfigParam.GetValue($"{m_fromTray.ToString()}TakeTrayY"); - Motion.ErrorCode errCode = AxisControl.LoadX.MovePos(targetX, GlobalVar.TakeTraySpeed); + Motion.ErrorCode errCode = AxisControl.LoadX.MovePos(targetX + cameraCenterX, GlobalVar.TakeTraySpeed); if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis) { - errCode = AxisControl.LoadY.MovePos(targetY, GlobalVar.TakeTraySpeed); + errCode = AxisControl.LoadY.MovePos(targetY+ cameraCenterY, GlobalVar.TakeTraySpeed); if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis) { if (GlobalVar.VirtualAxis) @@ -159,17 +161,23 @@ namespace Rs.MotionPlat.Flow logInfo =GetClassName()+ $"检测上下气缸动位OK"; MessageQueue.Instance.Insert(logInfo); stopwatch.Stop(); - Ops.On("夹爪真空吸"); - logInfo = GetClassName() + $"打开夹爪夹爪真空吸"; + Ops.On("夹爪气缸电磁阀"); + logInfo = GetClassName() + $"夹爪气缸on"; MessageQueue.Instance.Insert(logInfo); - Thread.Sleep(150); + Thread.Sleep(1000); + if (!GlobalVar.TakeTrayDisableVac) + { + Ops.On("夹爪真空吸"); + logInfo = GetClassName() + $"打开夹爪夹爪真空吸"; + MessageQueue.Instance.Insert(logInfo); + } Ops.Off($"{(int)m_fromTray}号料仓斜推气缸"); logInfo = GetClassName() + $"关闭{m_fromTray}号料仓斜推气缸"; MessageQueue.Instance.Insert(logInfo); Ops.Off($"{(int)m_toTray}号料仓斜推气缸"); logInfo = GetClassName() + $"关闭{m_toTray}号料仓斜推气缸"; MessageQueue.Instance.Insert(logInfo); - Thread.Sleep(200); + step = ETakeTrayFlowStep.取料盘完成抬起; } else if (stopwatch.ElapsedMilliseconds > 5000) @@ -198,7 +206,14 @@ namespace Rs.MotionPlat.Flow { logInfo = $"检测到上下气缸原位OK"; stopwatch.Restart(); - step = ETakeTrayFlowStep.取料盘后真空检测; + if(GlobalVar.TakeTrayDisableVac) + { + step = ETakeTrayFlowStep.到放料盘上方; + } + else + { + step = ETakeTrayFlowStep.取料盘后真空检测; + } } } else @@ -246,15 +261,15 @@ namespace Rs.MotionPlat.Flow //centerX = SysConfigParam.GetValue($"Tray{m_toTray.ToString()}CenterX"); //centerY = SysConfigParam.GetValue($"Tray{m_toTray.ToString()}CenterY"); - //cameraCenterX = SysConfigParam.GetValue("ClampCenter2UpCameraCenterX"); - //cameraCenterY = SysConfigParam.GetValue("ClampCenter2UpCameraCenterY"); + cameraCenterX = SysConfigParam.GetValue("ClampCenter2UpCameraCenterX"); + cameraCenterY = SysConfigParam.GetValue("ClampCenter2UpCameraCenterY"); targetX = SysConfigParam.GetValue($"{m_toTray.ToString()}TakeTrayX"); targetY = SysConfigParam.GetValue($"{m_toTray.ToString()}TakeTrayY"); - errCode = AxisControl.LoadX.MovePos(targetX+2, GlobalVar.TakeTraySpeed); + errCode = AxisControl.LoadX.MovePos(targetX+ cameraCenterX, GlobalVar.TakeTraySpeed); if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis) { - errCode = AxisControl.LoadY.MovePos(targetY - 1, GlobalVar.TakeTraySpeed); + errCode = AxisControl.LoadY.MovePos(targetY+ cameraCenterY - 2, GlobalVar.TakeTraySpeed); if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis) { if (GlobalVar.VirtualAxis) @@ -309,18 +324,27 @@ namespace Rs.MotionPlat.Flow logInfo = GetClassName()+ "检测到上下气缸动位 OK"; MessageQueue.Instance.Insert(logInfo); stopwatch.Stop(); - Ops.Off("夹爪真空吸"); - logInfo = GetClassName() + "夹爪真空吸 off"; - MessageQueue.Instance.Insert(logInfo); - Thread.Sleep(10); - Ops.On("夹爪真空破"); - logInfo = GetClassName() + "夹爪真空破 on"; - MessageQueue.Instance.Insert(logInfo); - Thread.Sleep(200); - Ops.Off("夹爪真空破"); - logInfo = GetClassName() + "夹爪真空破 off"; + if(!GlobalVar.TakeTrayDisableVac) + { + Ops.Off("夹爪真空吸"); + logInfo = GetClassName() + "夹爪真空吸 off"; + MessageQueue.Instance.Insert(logInfo); + Thread.Sleep(10); + Ops.On("夹爪真空破"); + logInfo = GetClassName() + "夹爪真空破 on"; + MessageQueue.Instance.Insert(logInfo); + Thread.Sleep(200); + Ops.Off("夹爪真空破"); + logInfo = GetClassName() + "夹爪真空破 off"; + MessageQueue.Instance.Insert(logInfo); + } + + Ops.Off("夹爪气缸电磁阀"); + logInfo = GetClassName() + $"夹爪气缸off"; MessageQueue.Instance.Insert(logInfo); - step = ETakeTrayFlowStep.放料盘完成后抬起; + Thread.Sleep(1000); + stopwatch.Restart(); + step = ETakeTrayFlowStep.等待夹爪气缸张开; } } else @@ -333,6 +357,24 @@ namespace Rs.MotionPlat.Flow stopwatch.Restart(); } break; + case ETakeTrayFlowStep.等待夹爪气缸张开: + if(stopwatch.ElapsedMilliseconds<5000) + { + if(Ops.IsOn("夹爪气缸原位")) + { + step = ETakeTrayFlowStep.放料盘完成后抬起; + } + } + else + { + logInfo = "夹爪气缸原位检测异常,请处理后点击确定"; + MessageQueue.Instance.Warn(GetClassName() + logInfo); + TestCenterMessageBox.Show(AlarmConstID.UpDownCylinderExceptionAlarm, logInfo, ETipButton.Ok); + TestCenterMessageBox.WaitResult(AlarmConstID.UpDownCylinderExceptionAlarm); + stopwatch.Stop(); + stopwatch.Restart(); + } + break; case ETakeTrayFlowStep.放料盘完成后抬起: Ops.Off("上下气缸电磁阀动位"); logInfo = GetClassName() + "上下气缸电磁阀动位 off"; @@ -346,7 +388,15 @@ namespace Rs.MotionPlat.Flow case ETakeTrayFlowStep.等待放料完成抬起: if (Ops.IsOn("上下气缸原位") || GlobalVar.VirtualAxis) { - step = ETakeTrayFlowStep.放料完成后真空检测; + if(GlobalVar.TakeTrayDisableVac) + { + step = ETakeTrayFlowStep.搬运完成; + } + else + { + step = ETakeTrayFlowStep.放料完成后真空检测; + } + } break; case ETakeTrayFlowStep.放料完成后真空检测: @@ -354,9 +404,7 @@ namespace Rs.MotionPlat.Flow { logInfo = GetClassName()+$"放料盘完成,料盘搬运结束"; MessageQueue.Instance.Insert(logInfo); - finisehd = true; - TakeStatus = ETakeStatus.TakeOK; - dumpTrayFinishedEvent?.Invoke(); + step = ETakeTrayFlowStep.搬运完成; //if (mLoadUnloadType == ELoadUnloadType.Load) //{ // StockManager.Instance.Load(m_toTray, EStockTrayLoadMode.AfterTakeTray); @@ -372,6 +420,11 @@ namespace Rs.MotionPlat.Flow step = ETakeTrayFlowStep.到放料盘上方; } break; + case ETakeTrayFlowStep.搬运完成: + finisehd = true; + TakeStatus = ETakeStatus.TakeOK; + dumpTrayFinishedEvent?.Invoke(); + break; } Thread.Sleep(10); } diff --git a/Rs.SkyLine/SysConfig/ClampConfig.Designer.cs b/Rs.SkyLine/SysConfig/ClampConfig.Designer.cs index 24cdceb..3da9993 100644 --- a/Rs.SkyLine/SysConfig/ClampConfig.Designer.cs +++ b/Rs.SkyLine/SysConfig/ClampConfig.Designer.cs @@ -910,7 +910,6 @@ this.groupBox5.TabIndex = 47; this.groupBox5.TabStop = false; this.groupBox5.Text = "Dist"; - this.groupBox5.Visible = false; // // btnSaveDist // diff --git a/Rs.SkyLine/SysConfig/LookCamera.cs b/Rs.SkyLine/SysConfig/LookCamera.cs index 892791c..758d98d 100644 --- a/Rs.SkyLine/SysConfig/LookCamera.cs +++ b/Rs.SkyLine/SysConfig/LookCamera.cs @@ -39,8 +39,8 @@ namespace Rs.MotionPlat.SysConfig try { ImageProcess.ClearManualTrigger(); - HikCamera.Instance.SetExposure("upCamera", GlobalVar.UpCameraExposureTime); - HikCamera.Instance.SetGain("upCamera", GlobalVar.UpCameraGain); + HikCamera.Instance.SetExposure("upCamera", float.Parse(txtUpCameraExposureTime.Text)); + HikCamera.Instance.SetGain("upCamera", float.Parse(txtUpCameraGain.Text)); HikCamera.Instance.SetTrigger("upCamera", ETriggerMode.Manual); AxisControl.LoadX.ComparePulse(2, false); HObject image = null; diff --git a/Rs.SkyLine/SysConfig/LookCamera.designer.cs b/Rs.SkyLine/SysConfig/LookCamera.designer.cs index f75d9e5..227bee8 100644 --- a/Rs.SkyLine/SysConfig/LookCamera.designer.cs +++ b/Rs.SkyLine/SysConfig/LookCamera.designer.cs @@ -35,16 +35,16 @@ this.btnDownCameraGrab = new System.Windows.Forms.Button(); this.btnUpCameraGrab = new System.Windows.Forms.Button(); this.panel2 = new System.Windows.Forms.Panel(); - this.panel3 = new System.Windows.Forms.Panel(); this.himgNozzle8 = new ChoiceTech.Halcon.Control.HWindow_Final(); - this.label4 = new System.Windows.Forms.Label(); - this.txtUpCameraExposureTime = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); + this.panel3 = new System.Windows.Forms.Panel(); + this.txtDownCameraGain = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); this.txtUpCameraGain = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); this.txtDownCameraExposureTime = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.txtDownCameraGain = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.txtUpCameraExposureTime = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); this.panel1.SuspendLayout(); this.panel2.SuspendLayout(); this.panel3.SuspendLayout(); @@ -134,6 +134,20 @@ this.panel2.Size = new System.Drawing.Size(633, 748); this.panel2.TabIndex = 4; // + // himgNozzle8 + // + this.himgNozzle8.BackColor = System.Drawing.Color.Transparent; + this.himgNozzle8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.himgNozzle8.Dock = System.Windows.Forms.DockStyle.Fill; + this.himgNozzle8.DrawModel = false; + this.himgNozzle8.ForeColor = System.Drawing.Color.White; + this.himgNozzle8.Image = null; + this.himgNozzle8.Location = new System.Drawing.Point(0, 0); + this.himgNozzle8.Margin = new System.Windows.Forms.Padding(4); + this.himgNozzle8.Name = "himgNozzle8"; + this.himgNozzle8.Size = new System.Drawing.Size(633, 701); + this.himgNozzle8.TabIndex = 15; + // // panel3 // this.panel3.Controls.Add(this.txtDownCameraGain); @@ -150,37 +164,42 @@ this.panel3.Size = new System.Drawing.Size(633, 47); this.panel3.TabIndex = 14; // - // himgNozzle8 + // txtDownCameraGain // - this.himgNozzle8.BackColor = System.Drawing.Color.Transparent; - this.himgNozzle8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.himgNozzle8.Dock = System.Windows.Forms.DockStyle.Fill; - this.himgNozzle8.DrawModel = false; - this.himgNozzle8.ForeColor = System.Drawing.Color.White; - this.himgNozzle8.Image = null; - this.himgNozzle8.Location = new System.Drawing.Point(0, 0); - this.himgNozzle8.Margin = new System.Windows.Forms.Padding(4); - this.himgNozzle8.Name = "himgNozzle8"; - this.himgNozzle8.Size = new System.Drawing.Size(633, 701); - this.himgNozzle8.TabIndex = 15; + this.txtDownCameraGain.Location = new System.Drawing.Point(556, 16); + this.txtDownCameraGain.Name = "txtDownCameraGain"; + this.txtDownCameraGain.Size = new System.Drawing.Size(65, 21); + this.txtDownCameraGain.TabIndex = 3; + this.txtDownCameraGain.Text = "8"; + this.txtDownCameraGain.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtDownCameraGain_KeyUp); // - // label4 + // label3 // - this.label4.AutoSize = true; - this.label4.ForeColor = System.Drawing.Color.White; - this.label4.Location = new System.Drawing.Point(12, 16); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(71, 12); - this.label4.TabIndex = 2; - this.label4.Text = "上相机曝光:"; + this.label3.AutoSize = true; + this.label3.ForeColor = System.Drawing.Color.White; + this.label3.Location = new System.Drawing.Point(482, 20); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(71, 12); + this.label3.TabIndex = 2; + this.label3.Text = "下相机增益:"; // - // txtUpCameraExposureTime + // txtUpCameraGain // - this.txtUpCameraExposureTime.Location = new System.Drawing.Point(86, 12); - this.txtUpCameraExposureTime.Name = "txtUpCameraExposureTime"; - this.txtUpCameraExposureTime.Size = new System.Drawing.Size(65, 21); - this.txtUpCameraExposureTime.TabIndex = 3; - this.txtUpCameraExposureTime.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtUpCameraExposureTime_KeyUp); + this.txtUpCameraGain.Location = new System.Drawing.Point(237, 13); + this.txtUpCameraGain.Name = "txtUpCameraGain"; + this.txtUpCameraGain.Size = new System.Drawing.Size(65, 21); + this.txtUpCameraGain.TabIndex = 3; + this.txtUpCameraGain.Text = "3"; + this.txtUpCameraGain.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtUpCameraGain_KeyUp); + // + // txtDownCameraExposureTime + // + this.txtDownCameraExposureTime.Location = new System.Drawing.Point(405, 15); + this.txtDownCameraExposureTime.Name = "txtDownCameraExposureTime"; + this.txtDownCameraExposureTime.Size = new System.Drawing.Size(65, 21); + this.txtDownCameraExposureTime.TabIndex = 3; + this.txtDownCameraExposureTime.Text = "50"; + this.txtDownCameraExposureTime.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtDownCameraExposureTime_KeyUp); // // label1 // @@ -192,14 +211,6 @@ this.label1.TabIndex = 2; this.label1.Text = "上相机增益:"; // - // txtUpCameraGain - // - this.txtUpCameraGain.Location = new System.Drawing.Point(237, 13); - this.txtUpCameraGain.Name = "txtUpCameraGain"; - this.txtUpCameraGain.Size = new System.Drawing.Size(65, 21); - this.txtUpCameraGain.TabIndex = 3; - this.txtUpCameraGain.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtUpCameraGain_KeyUp); - // // label2 // this.label2.AutoSize = true; @@ -210,31 +221,24 @@ this.label2.TabIndex = 2; this.label2.Text = "下相机曝光:"; // - // txtDownCameraExposureTime - // - this.txtDownCameraExposureTime.Location = new System.Drawing.Point(405, 15); - this.txtDownCameraExposureTime.Name = "txtDownCameraExposureTime"; - this.txtDownCameraExposureTime.Size = new System.Drawing.Size(65, 21); - this.txtDownCameraExposureTime.TabIndex = 3; - this.txtDownCameraExposureTime.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtDownCameraExposureTime_KeyUp); - // - // label3 + // txtUpCameraExposureTime // - this.label3.AutoSize = true; - this.label3.ForeColor = System.Drawing.Color.White; - this.label3.Location = new System.Drawing.Point(482, 20); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(71, 12); - this.label3.TabIndex = 2; - this.label3.Text = "下相机增益:"; + this.txtUpCameraExposureTime.Location = new System.Drawing.Point(86, 12); + this.txtUpCameraExposureTime.Name = "txtUpCameraExposureTime"; + this.txtUpCameraExposureTime.Size = new System.Drawing.Size(65, 21); + this.txtUpCameraExposureTime.TabIndex = 3; + this.txtUpCameraExposureTime.Text = "50"; + this.txtUpCameraExposureTime.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtUpCameraExposureTime_KeyUp); // - // txtDownCameraGain + // label4 // - this.txtDownCameraGain.Location = new System.Drawing.Point(556, 16); - this.txtDownCameraGain.Name = "txtDownCameraGain"; - this.txtDownCameraGain.Size = new System.Drawing.Size(65, 21); - this.txtDownCameraGain.TabIndex = 3; - this.txtDownCameraGain.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtDownCameraGain_KeyUp); + this.label4.AutoSize = true; + this.label4.ForeColor = System.Drawing.Color.White; + this.label4.Location = new System.Drawing.Point(12, 16); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(71, 12); + this.label4.TabIndex = 2; + this.label4.Text = "上相机曝光:"; // // LookCamera // diff --git a/Rs.SkyLine/SysConfig/StockControl.cs b/Rs.SkyLine/SysConfig/StockControl.cs index e71bc9f..226a055 100644 --- a/Rs.SkyLine/SysConfig/StockControl.cs +++ b/Rs.SkyLine/SysConfig/StockControl.cs @@ -214,8 +214,10 @@ namespace Rs.MotionPlat.SysConfig tostock = ETrayType.Empty2; StockManager.Instance.GetStock(fromstock).Load(EStockTrayLoadMode.Whole, null); TakeTrayFlow.Instance.Take(fromstock, tostock, - null, null, + () => { + StockManager.Instance.GetStock(fromstock).ChangeStatus(EStockTrayStatus.Unloaded); + }, () => { StockManager.Instance.GetStock(tostock).Unload(EStockTrayUnLoadMode.Whole, null); });