diff --git a/Rs.SkyLine/Flow/NormalFlow/DischargeFlow.cs b/Rs.SkyLine/Flow/NormalFlow/DischargeFlow.cs index 808a616..0c538c0 100644 --- a/Rs.SkyLine/Flow/NormalFlow/DischargeFlow.cs +++ b/Rs.SkyLine/Flow/NormalFlow/DischargeFlow.cs @@ -589,39 +589,45 @@ namespace Rs.MotionPlat.Flow HikCamera.Instance.SetExposure("locationCamera", GlobalVar.FlyGrabExposureTime); HikCamera.Instance.SetGain("locationCamera", GlobalVar.FlyGrabGain); } - - if(NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload)[0].ToType== TurnoverType.Turnover) + if(NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count>0) { - needGrabNum = NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count(); - errCode = AxisControl.LoadX.MovePos(SysConfigParam.GetValue($"Nozzle{needGrabNum}CenterX") - 30, GlobalVar.WholeSpeed); - if(errCode== ErrorCode.Ok || GlobalVar.VirtualAxis) + if (NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload)[0].ToType == TurnoverType.Turnover) { - errCode= AxisControl.LoadY.MovePos(SysConfigParam.GetValue($"Nozzle8CenterY"), GlobalVar.WholeSpeed); - if(errCode== ErrorCode.Ok|| GlobalVar.VirtualAxis) + needGrabNum = NozzleManager.GetNozzlesByStatus(ENozzleStatus.ToUnload).Count(); + errCode = AxisControl.LoadX.MovePos(SysConfigParam.GetValue($"Nozzle{needGrabNum}CenterX") - 30, GlobalVar.WholeSpeed); + if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis) { - flowStep = EDischargeFlowStep.等待到下相机拍照起始位; + errCode = AxisControl.LoadY.MovePos(SysConfigParam.GetValue($"Nozzle8CenterY"), GlobalVar.WholeSpeed); + if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis) + { + flowStep = EDischargeFlowStep.等待到下相机拍照起始位; + } } } - } - else - { - errCode = AxisControl.LoadX.MovePos(SysConfigParam.GetValue("Nozzle1CenterX") + 30, GlobalVar.WholeSpeed); - if(errCode== ErrorCode.Ok || GlobalVar.VirtualAxis) + else { - errCode = AxisControl.LoadY.MovePos(SysConfigParam.GetValue("Nozzle1CenterY"), GlobalVar.WholeSpeed); - if(errCode== ErrorCode.Ok || GlobalVar.VirtualAxis) + errCode = AxisControl.LoadX.MovePos(SysConfigParam.GetValue("Nozzle1CenterX") + 30, GlobalVar.WholeSpeed); + if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis) { - flowStep = EDischargeFlowStep.等待到下相机拍照起始位; + errCode = AxisControl.LoadY.MovePos(SysConfigParam.GetValue("Nozzle1CenterY"), GlobalVar.WholeSpeed); + if (errCode == ErrorCode.Ok || GlobalVar.VirtualAxis) + { + flowStep = EDischargeFlowStep.等待到下相机拍照起始位; + } + else + { + MsgBox.ShowAxisAlarmDialog(AxisControl.LoadY, errCode); + } } else { - MsgBox.ShowAxisAlarmDialog(AxisControl.LoadY, errCode); + MsgBox.ShowAxisAlarmDialog(AxisControl.LoadX, errCode); } } - else - { - MsgBox.ShowAxisAlarmDialog(AxisControl.LoadX, errCode); - } + } + else + { + flowStep = EDischargeFlowStep.任务结束到安全位; } } @@ -940,7 +946,7 @@ namespace Rs.MotionPlat.Flow { //如果吸嘴是1,并且最后一列 downSlot = GlobalTray.MultiTray.GetSlot(ESlotStatus.NotHave); - #region 为了解决第一个吸嘴到不了最后两列的问题,新的料盘已经不存在这个问题 + #region 为了解决第一个吸嘴到不了最后一列的问题 if (curNozzle.NozzleIndex == 1 && downSlot != null && (downSlot.Column == 0)) { if (downSlot.Column == 0) @@ -1307,6 +1313,8 @@ namespace Rs.MotionPlat.Flow } else { + logInfo = GetClassName() + $"排料吸嘴{curNozzle.NozzleIndex}号SN={curNozzle.SN}放{WitchTrayWitchSlot(curNozzle.ToType, curNozzle.ToIndex)}"; + MessageQueue.Instance.Insert(logInfo); curNozzle.VacSuction(EIoOperate.Close); flowStep = EDischargeFlowStep.放料真空检测; } @@ -1507,7 +1515,7 @@ namespace Rs.MotionPlat.Flow } else { - OnShowGrabResult?.Invoke(new VisionResult(),false); + OnShowGrabResult?.Invoke(vr,false); } } //OnUpCameraGrabResult?.Invoke(result); @@ -1568,7 +1576,7 @@ namespace Rs.MotionPlat.Flow } else { - OnShowGrabResult?.Invoke(new VisionResult(),false); + OnShowGrabResult?.Invoke(vr,false); } } //OnUpCameraGrabResult?.Invoke(result); diff --git a/Rs.SkyLine/Flow/SubFlow/FiberWarningPressFlow.cs b/Rs.SkyLine/Flow/SubFlow/FiberWarningPressFlow.cs new file mode 100644 index 0000000..d1f5161 --- /dev/null +++ b/Rs.SkyLine/Flow/SubFlow/FiberWarningPressFlow.cs @@ -0,0 +1,194 @@ +using Rs.Controls; +using Rs.Framework; +using Rs.Motion; +using Rs.MotionPlat.Commom; +using Rs.MotionPlat.Entitys.Trays; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Rs.MotionPlat.Flow.SubFlow +{ + enum EFiberWarningPressFlowStep + { + 到测试放料位上方, + 等待运动到测试放料位上方, + 到测试放料位下方1, + 等待运动到到测试放料位下方1, + 到测试放料位下方2, + 等待运动到到测试放料位下方2, + 测试位下压完成抬起, + 等待测试位下压完成抬起 + } + /// + /// + /// 当光纤报警时,主动去压一次 + /// + public class FiberWarningPressFlow + { + private static FiberWarningPressFlow instance; + public static FiberWarningPressFlow Instance + { + get + { + if (instance == null) + instance = new FiberWarningPressFlow(); + return instance; + } + } + + private string logInfo = string.Empty; + private EFiberWarningPressFlowStep step = EFiberWarningPressFlowStep.到测试放料位上方; + private double targetPos = 0.0; + ErrorCode errCode = ErrorCode.Ok; + bool finished = true; + + /// + /// 当出现光纤异常时,下嘴下压一次 + /// + public void Press() + { + if (finished) + { + finished = false; + } + else + { + return; + } + targetPos = 0.0; + step = EFiberWarningPressFlowStep.到测试放料位上方; + while (!finished) + { + if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop) + { + Thread.Sleep(10); + continue; + } + switch (step) + { + case EFiberWarningPressFlowStep.到测试放料位上方: + targetPos = SysConfigParam.GetValue("PressDumpX"); + errCode = AxisControl.TurnoverX.MovePos(targetPos, GlobalVar.WholeSpeed); + if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis) + { + targetPos = SysConfigParam.GetValue("PressDumpY"); + errCode = AxisControl.TurnoverY.MovePos(targetPos, GlobalVar.WholeSpeed); + if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis) + { + if (GlobalVar.VirtualAxis) + { + Thread.Sleep(GlobalVar.VirtualAxisMoveTime); + } + logInfo = GetClassName() + $"到测试放料位上方"; + MessageQueue.Instance.Insert(logInfo); + step = EFiberWarningPressFlowStep.等待运动到测试放料位上方; + } + else + { + MsgBox.ShowAxisAlarmDialog(AxisControl.TurnoverY, errCode); + } + } + else + { + MsgBox.ShowAxisAlarmDialog(AxisControl.TurnoverX, errCode); + } + + break; + case EFiberWarningPressFlowStep.等待运动到测试放料位上方: + if (Ops.IsStop(AxisControl.TurnoverX, AxisControl.TurnoverY) || GlobalVar.VirtualAxis) + { + step = EFiberWarningPressFlowStep.到测试放料位下方1; + } + break; + case EFiberWarningPressFlowStep.到测试放料位下方1: + targetPos = SysConfigParam.GetValue("PressDumpZ") + GlobalVar.PressLowSpeedOffset; + errCode = AxisControl.TurnoverZ.MovePos(targetPos, GlobalVar.WholeSpeed); + if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis) + { + if (GlobalVar.VirtualAxis) + { + Thread.Sleep(GlobalVar.VirtualAxisMoveTime); + } + logInfo = GetClassName() + $"到测试放料位下方1"; + MessageQueue.Instance.Insert(logInfo); + step = EFiberWarningPressFlowStep.等待运动到到测试放料位下方1; + } + else + { + MsgBox.ShowAxisAlarmDialog(AxisControl.TurnoverZ, errCode); + } + break; + case EFiberWarningPressFlowStep.等待运动到到测试放料位下方1: + if (Ops.IsStop(AxisControl.TurnoverZ) || GlobalVar.VirtualAxis) + { + logInfo = GetClassName() + $"已运动到到测试放料位下方1 TurnoverZ at:{Ops.GetCurPosition(AxisAlias.TurnoverZ)}"; + MessageQueue.Instance.Insert(logInfo); + step = EFiberWarningPressFlowStep.到测试放料位下方2; + } + break; + case EFiberWarningPressFlowStep.到测试放料位下方2: + targetPos = SysConfigParam.GetValue("PressDumpZ"); + errCode = AxisControl.TurnoverZ.MovePos(targetPos, GlobalVar.PressLowSpeed); + if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis) + { + if (GlobalVar.VirtualAxis) + { + Thread.Sleep(GlobalVar.VirtualAxisMoveTime); + } + logInfo = GetClassName() + $"到测试放料位下方2"; + MessageQueue.Instance.Insert(logInfo); + LogHelper.Debug(logInfo); + step = EFiberWarningPressFlowStep.等待运动到到测试放料位下方2; + } + else + { + MsgBox.ShowAxisAlarmDialog(AxisControl.TurnoverZ, errCode); + } + break; + case EFiberWarningPressFlowStep.等待运动到到测试放料位下方2: + if (Ops.IsStop(AxisControl.TurnoverZ) || GlobalVar.VirtualAxis) + { + Thread.Sleep(1000); + step = EFiberWarningPressFlowStep.测试位下压完成抬起; + } + break; + case EFiberWarningPressFlowStep.测试位下压完成抬起: + targetPos = SysConfigParam.GetValue("PressSafeZ"); + errCode = AxisControl.TurnoverZ.MovePos(targetPos, GlobalVar.WholeSpeed); + if (errCode == Motion.ErrorCode.Ok || GlobalVar.VirtualAxis) + { + if (GlobalVar.VirtualAxis) + { + Thread.Sleep(GlobalVar.VirtualAxisMoveTime); + } + logInfo = GetClassName() + $"测试位下压完成抬起"; + MessageQueue.Instance.Insert(logInfo); + step = EFiberWarningPressFlowStep.等待测试位下压完成抬起; + } + else + { + MsgBox.ShowAxisAlarmDialog(AxisControl.TurnoverZ, errCode); + } + break; + case EFiberWarningPressFlowStep.等待测试位下压完成抬起: + if (Ops.IsStop(AxisControl.TurnoverZ) || GlobalVar.VirtualAxis) + { + logInfo = GetClassName() + $"测试位下压完成抬起完成"; + MessageQueue.Instance.Insert(logInfo); + finished = true; + } + break; + } + } + } + + private string GetClassName() + { + return "FiberWarningPressFlow-"; + } + } +} diff --git a/Rs.SkyLine/Rs.SkyLine.csproj b/Rs.SkyLine/Rs.SkyLine.csproj index d2548ce..1e2e3b7 100644 --- a/Rs.SkyLine/Rs.SkyLine.csproj +++ b/Rs.SkyLine/Rs.SkyLine.csproj @@ -189,6 +189,7 @@ + diff --git a/Rs.SkyLine/TestFrm.Designer.cs b/Rs.SkyLine/TestFrm.Designer.cs index 3487e21..4fa912f 100644 --- a/Rs.SkyLine/TestFrm.Designer.cs +++ b/Rs.SkyLine/TestFrm.Designer.cs @@ -33,6 +33,7 @@ this.btnSocketExceptionGoSafePoint = new System.Windows.Forms.Button(); this.btnTransiteNozzleExceptionGoSafePoint = new System.Windows.Forms.Button(); this.btnTurnoverTrayExceptionGoSafePoint = new System.Windows.Forms.Button(); + this.btnTransitNozzlePress = new System.Windows.Forms.Button(); this.SuspendLayout(); // // btnTurnoverSlotException @@ -85,11 +86,22 @@ this.btnTurnoverTrayExceptionGoSafePoint.UseVisualStyleBackColor = true; this.btnTurnoverTrayExceptionGoSafePoint.Click += new System.EventHandler(this.btnTurnoverTrayExceptionGoSafePoint_Click); // + // btnTransitNozzlePress + // + this.btnTransitNozzlePress.Location = new System.Drawing.Point(12, 96); + this.btnTransitNozzlePress.Name = "btnTransitNozzlePress"; + this.btnTransitNozzlePress.Size = new System.Drawing.Size(152, 37); + this.btnTransitNozzlePress.TabIndex = 0; + this.btnTransitNozzlePress.Text = "周转吸嘴下压"; + this.btnTransitNozzlePress.UseVisualStyleBackColor = true; + this.btnTransitNozzlePress.Click += new System.EventHandler(this.btnTransitNozzlePress_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.btnTransitNozzlePress); this.Controls.Add(this.btnTurnoverTrayExceptionGoSafePoint); this.Controls.Add(this.btnTransiteNozzleExceptionGoSafePoint); this.Controls.Add(this.btnSocketExceptionGoSafePoint); @@ -108,5 +120,6 @@ private System.Windows.Forms.Button btnSocketExceptionGoSafePoint; private System.Windows.Forms.Button btnTransiteNozzleExceptionGoSafePoint; private System.Windows.Forms.Button btnTurnoverTrayExceptionGoSafePoint; + private System.Windows.Forms.Button btnTransitNozzlePress; } } \ No newline at end of file diff --git a/Rs.SkyLine/TestFrm.cs b/Rs.SkyLine/TestFrm.cs index 9d66a54..66db8bf 100644 --- a/Rs.SkyLine/TestFrm.cs +++ b/Rs.SkyLine/TestFrm.cs @@ -1,5 +1,6 @@ using Rs.MotionPlat.Flow.NgFlow; using Rs.MotionPlat.Flow.SafePosFlow; +using Rs.MotionPlat.Flow.SubFlow; using System; using System.Collections.Generic; using System.ComponentModel; @@ -45,5 +46,10 @@ namespace Rs.MotionPlat { TransitModuleSafePosFlow.Instance.GoSafePostion(Commom.EExceptionSafePos.TurnoverTray); } + + private void btnTransitNozzlePress_Click(object sender, EventArgs e) + { + FiberWarningPressFlow.Instance.Press(); + } } }