diff --git a/Rs.DeweyTester/Commom/BuzzerManager.cs b/Rs.DeweyTester/Commom/BuzzerManager.cs new file mode 100644 index 0000000..c195349 --- /dev/null +++ b/Rs.DeweyTester/Commom/BuzzerManager.cs @@ -0,0 +1,74 @@ +using Rs.Framework; +using Rs.MotionPlat.Flow; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Rs.MotionPlat.Commom +{ + /// + /// 蜂鸣器管理 + /// + public class BuzzerManager + { + private static BuzzerManager instance; + public static BuzzerManager Instance + { + get + { + if(instance == null) + instance = new BuzzerManager(); + return instance; + } + } + bool bexit = false; + bool bRun = false; + public void On() + { + bRun = true; + } + + public void Off() + { + bRun=false; + } + + public void Exit() + { + bexit = true; + } + + + public void Run() + { + Task.Run(() => { + + while (!bexit) + { + if(!bRun) + { + Thread.Sleep(100); + } + if (bRun) + { + if(MachineManage.Instance.MachineStatus!= EMachineStatus.Stop) + { + if(!GlobalVar.DisableBuzzer) + { + Ops.On("蜂鸣器"); + Thread.Sleep(500); + Ops.Off("蜂鸣器"); + Thread.Sleep(1000); + } + } + } + Thread.Sleep(100); + } + + }); + } + } +} diff --git a/Rs.DeweyTester/Commom/Msgbox.cs b/Rs.DeweyTester/Commom/Msgbox.cs index a05d873..bbf8c8c 100644 --- a/Rs.DeweyTester/Commom/Msgbox.cs +++ b/Rs.DeweyTester/Commom/Msgbox.cs @@ -17,28 +17,19 @@ namespace Rs.MotionPlat.Commom /// /// 显示模态弹框 /// - public static EButtonType ShowDialog(EButtonType buttons,string content,string title="") + public static EButtonType ShowDialog(EButtonType buttons,string content,string title="",bool warning=false) { - if(!GlobalVar.DisableBuzzer) + if (warning) { - Ops.On("蜂鸣器"); + BuzzerManager.Instance.On(); } - LightManger.Instance.SetStatus(ELightStatus.Red); LogHelper.Debug(content); EButtonType ret = EButtonType.None; FrmDialog fd = new FrmDialog(); ret = fd.ShowMessage(buttons, content, "",title); - if (!GlobalVar.DisableBuzzer) - { - Ops.Off("蜂鸣器"); - } - if (MachineManage.Instance.MachineStatus== EMachineStatus.Stop) + if(warning) { - LightManger.Instance.SetStatus(ELightStatus.Yellow); - } - else if(MachineManage.Instance.MachineStatus== EMachineStatus.Working) - { - LightManger.Instance.SetStatus(ELightStatus.Green); + BuzzerManager.Instance.Off(); } return ret; } @@ -51,10 +42,11 @@ namespace Rs.MotionPlat.Commom /// public static EButtonType ShowDialog(AlarmEntity alarmInfo, EButtonType buttons) { - if (!GlobalVar.DisableBuzzer) - { - Ops.On("蜂鸣器"); - } + //if (!GlobalVar.DisableBuzzer) + //{ + // Ops.On("蜂鸣器"); + //} + BuzzerManager.Instance.On(); LightManger.Instance.SetStatus(ELightStatus.Red); string logInfo = $"{alarmInfo.CN}"; LogHelper.Debug(logInfo); @@ -65,18 +57,19 @@ namespace Rs.MotionPlat.Commom boxList.Add(alarmInfo.AlarmID, fd); ret = fd.ShowMessage(buttons, alarmInfo.CN,alarmInfo.EN); boxList.Remove(alarmInfo.AlarmID); - if (!GlobalVar.DisableBuzzer) - { - Ops.Off("蜂鸣器"); - } - if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop) - { - LightManger.Instance.SetStatus(ELightStatus.Yellow); - } - else if (MachineManage.Instance.MachineStatus == EMachineStatus.Working) - { - LightManger.Instance.SetStatus(ELightStatus.Green); - } + //if (!GlobalVar.DisableBuzzer) + //{ + // Ops.Off("蜂鸣器"); + //} + //if (MachineManage.Instance.MachineStatus == EMachineStatus.Stop) + //{ + // LightManger.Instance.SetStatus(ELightStatus.Yellow); + //} + //else if (MachineManage.Instance.MachineStatus == EMachineStatus.Working) + //{ + // LightManger.Instance.SetStatus(ELightStatus.Green); + //} + BuzzerManager.Instance.Off(); } return ret; } diff --git a/Rs.DeweyTester/Commom/Ops.cs b/Rs.DeweyTester/Commom/Ops.cs index fe118dc..0ef4414 100644 --- a/Rs.DeweyTester/Commom/Ops.cs +++ b/Rs.DeweyTester/Commom/Ops.cs @@ -95,6 +95,7 @@ namespace Rs.MotionPlat.Commom SimulateTesterManager.Instance.Init(); } }); + BuzzerManager.Instance.Run(); } static void InitDb() diff --git a/Rs.DeweyTester/Commom/PositionHelper.cs b/Rs.DeweyTester/Commom/PositionHelper.cs index 3655c4b..40ab858 100644 --- a/Rs.DeweyTester/Commom/PositionHelper.cs +++ b/Rs.DeweyTester/Commom/PositionHelper.cs @@ -134,7 +134,7 @@ namespace Rs.MotionPlat.Commom if (errCode > Motion.ErrorCode.Ok) { //Msg.ShowError($"axis {axisname} move fail {errCode}"); - Msgbox.ShowDialog(EButtonType.Ok, $"axis {axisname} move fail {errCode}"); + Msgbox.ShowDialog(EButtonType.Ok, $"axis {axisname} move fail {errCode}","move",true); } } } diff --git a/Rs.DeweyTester/Entitys/TestFixtureManager.cs b/Rs.DeweyTester/Entitys/TestFixtureManager.cs index 2d678ad..e11f098 100644 --- a/Rs.DeweyTester/Entitys/TestFixtureManager.cs +++ b/Rs.DeweyTester/Entitys/TestFixtureManager.cs @@ -623,7 +623,7 @@ namespace Rs.MotionPlat.Entitys Task.Run(() => { string errInfo = $"tc{Index} test,code:{items[1]},desc:{items[2]}"; MessageQueue.Instance.Warn(errInfo); - Msgbox.ShowDialog(EButtonType.Ok, errInfo); + Msgbox.ShowDialog(EButtonType.Ok, errInfo,"testfixture error",true); }); } } diff --git a/Rs.DeweyTester/Flow/NormalFlow/CalibrationFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/CalibrationFlow.cs index 9323b3d..f3a8c24 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/CalibrationFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/CalibrationFlow.cs @@ -524,7 +524,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow } else { - Msgbox.ShowDialog(EButtonType.Retry, "Calib fail,please select retry"); + Msgbox.ShowDialog(EButtonType.Retry, "Calib fail,please select retry", "tip", true); } break; case ECalibrationCheckFlowStep.等待视觉处理结果: diff --git a/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs index 932c43b..ec2512c 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/DischargeFlow.cs @@ -212,7 +212,7 @@ namespace Rs.MotionPlat.Flow //if(Stock2Flow.Instance.GetCurrentLayer()==1) if(StockManager.GetCurrentLayer(2)==1) { - EButtonType btn = Msgbox.ShowDialog( EButtonType.Retry| EButtonType.EndInput,"请更换料盘"); + EButtonType btn = Msgbox.ShowDialog( EButtonType.Retry| EButtonType.EndInput,"请更换料盘","tip",true); if(btn== EButtonType.Retry) { //先把轴移动到安全位 @@ -330,7 +330,7 @@ namespace Rs.MotionPlat.Flow } else { - Msgbox.ShowDialog(EButtonType.Ok, "Retest料盘已放满,请更换料盘,更换完成后点击确定"); + Msgbox.ShowDialog(EButtonType.Ok, "Retest料盘已放满,请更换料盘,更换完成后点击确定","tip",true); GlobalTray.RetestTray.ChangeStatus(ESlotStatus.NotHave); ThreePointLocationFlow.Instance.Location(ETrayType.ReTest); //放料 @@ -344,7 +344,7 @@ namespace Rs.MotionPlat.Flow else if (fixtureret.Result == EOneGrabSixteenResult.Slant) { //报警弹框 - EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, $"穴位{ret.SlotIndex}定位失败,请把产品手动取走后点击跳过"); + EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Skip | EButtonType.Retry | EButtonType.EndInput, $"穴位{ret.SlotIndex}定位失败,请把产品手动取走后点击跳过","tip",true); if (buttonSelect == EButtonType.Skip) { exit = true; @@ -541,7 +541,7 @@ namespace Rs.MotionPlat.Flow else { //提示更换料盘 - Msgbox.ShowDialog(EButtonType.Ok, "NG料盘已满,请更换料盘,更换完成后点击确定"); + Msgbox.ShowDialog(EButtonType.Ok, "NG料盘已满,请更换料盘,更换完成后点击确定","tip",true); ThreePointLocationFlow.Instance.Location(ETrayType.Ng); GlobalTray.NgTray.ChangeStatus(ESlotStatus.NotHave); } diff --git a/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs index 1eb6985..4e76329 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/GrrFlow.cs @@ -557,7 +557,7 @@ namespace Rs.MotionPlat.Flow else { //取料失败报警 - Msgbox.ShowDialog(EButtonType.Retry, "治具取料失败报警"); + Msgbox.ShowDialog(EButtonType.Retry, "治具取料失败报警", "error", true); } break; case EGrrFlowStep.到治具拍照位: diff --git a/Rs.DeweyTester/Flow/NormalFlow/Stock1Flow.cs b/Rs.DeweyTester/Flow/NormalFlow/Stock1Flow.cs index 2d38044..2390e72 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/Stock1Flow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/Stock1Flow.cs @@ -80,7 +80,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow case EPrepareTray1FlowStep.料盘判断: if(HasTray() && GetCurrentLayer()>0) { - Msgbox.ShowDialog(EButtonType.Retry, "Ok料仓处有料盘,请点击重试后取走料盘"); + Msgbox.ShowDialog(EButtonType.Retry, "Ok料仓处有料盘,请点击重试后取走料盘", "error", true); OutStock(); InStock(); prepareTrayStep = EPrepareTray1FlowStep.上升一层; diff --git a/Rs.DeweyTester/Flow/NormalFlow/Stock2Flow.cs b/Rs.DeweyTester/Flow/NormalFlow/Stock2Flow.cs index c763a93..e75c863 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/Stock2Flow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/Stock2Flow.cs @@ -94,7 +94,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow } else { - Msgbox.ShowDialog(EButtonType.Retry, "Input料仓处料盘少于2盘,选择重试后弹出料仓"); + Msgbox.ShowDialog(EButtonType.Retry, "Input料仓处料盘少于2盘,选择重试后弹出料仓", "error", true); OutStock(); InStock(); prepareTrayStep = EPrepareTray2FlowStep.上升一层; diff --git a/Rs.DeweyTester/Flow/NormalFlow/Stock3Flow.cs b/Rs.DeweyTester/Flow/NormalFlow/Stock3Flow.cs index 73172d8..a98f67a 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/Stock3Flow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/Stock3Flow.cs @@ -90,7 +90,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow } else { - Msgbox.ShowDialog(EButtonType.Retry, "Input料仓处料盘少于2盘,选择重试后弹出料仓"); + Msgbox.ShowDialog(EButtonType.Retry, "Input料仓处料盘少于2盘,选择重试后弹出料仓","error",true); OutStock(); InStock(); prepareTrayStep = EPrepareTray3FlowStep.上升一层; diff --git a/Rs.DeweyTester/Flow/NormalFlow/StockFlowBase.cs b/Rs.DeweyTester/Flow/NormalFlow/StockFlowBase.cs index 8c9f69d..2b94df5 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/StockFlowBase.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/StockFlowBase.cs @@ -109,7 +109,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow } else if (stopwatch.ElapsedMilliseconds > 5000) { - Msgbox.ShowDialog(EButtonType.Retry, "抽屉锁原位异常,请处理后点击重试"); + Msgbox.ShowDialog(EButtonType.Retry, "抽屉锁原位异常,请处理后点击重试","error",true); } break; case EOutStockFlowStep.到出仓位: @@ -209,7 +209,7 @@ namespace Rs.MotionPlat.Flow.NormalFlow } else if (stopwatch.ElapsedMilliseconds > 5000) { - Msgbox.ShowDialog(EButtonType.Retry, "抽屉锁原位异常,请处理后点击重试"); + Msgbox.ShowDialog(EButtonType.Retry, "抽屉锁原位异常,请处理后点击重试","error",true); } break; case EInStockFlowStep.等待进仓信号: diff --git a/Rs.DeweyTester/Flow/NormalFlow/TakeTrayFlow.cs b/Rs.DeweyTester/Flow/NormalFlow/TakeTrayFlow.cs index f157e55..9248f13 100644 --- a/Rs.DeweyTester/Flow/NormalFlow/TakeTrayFlow.cs +++ b/Rs.DeweyTester/Flow/NormalFlow/TakeTrayFlow.cs @@ -329,7 +329,7 @@ namespace Rs.MotionPlat.Flow } if(noHasProduct.Count>0) { - EButtonType btn = Msgbox.ShowDialog(EButtonType.Retry | EButtonType.Skip, "料盘未放满,请处理"); + EButtonType btn = Msgbox.ShowDialog(EButtonType.Retry | EButtonType.Skip, "料盘未放满,请处理","tray info",true); if(btn== EButtonType.Retry) { step = ETakeTrayFlowStep.通知上料仓拍照; diff --git a/Rs.DeweyTester/Flow/SubFlow/FixtureTakeFlow.cs b/Rs.DeweyTester/Flow/SubFlow/FixtureTakeFlow.cs index 89e0892..88c8075 100644 --- a/Rs.DeweyTester/Flow/SubFlow/FixtureTakeFlow.cs +++ b/Rs.DeweyTester/Flow/SubFlow/FixtureTakeFlow.cs @@ -228,7 +228,7 @@ namespace Rs.MotionPlat.Flow.SubFlow } else { - Msgbox.ShowDialog(EButtonType.Recheck, $"治具{curFixture.Index}取料真空检测异常,请处理"); + Msgbox.ShowDialog(EButtonType.Recheck, $"治具{curFixture.Index}取料真空检测异常,请处理","vac error",true); } break; diff --git a/Rs.DeweyTester/Flow/SubFlow/ProductLocationFlow.cs b/Rs.DeweyTester/Flow/SubFlow/ProductLocationFlow.cs index 83778b4..bd5ee81 100644 --- a/Rs.DeweyTester/Flow/SubFlow/ProductLocationFlow.cs +++ b/Rs.DeweyTester/Flow/SubFlow/ProductLocationFlow.cs @@ -159,7 +159,7 @@ namespace Rs.MotionPlat.Flow.SubFlow } else { - Msgbox.ShowDialog(EButtonType.Retry, "一拍十六拍照失败,请处理后点击重试"); + Msgbox.ShowDialog(EButtonType.Retry, "一拍十六拍照失败,请处理后点击重试","grab fail",true); flowStep = EProductLocationFlowStep.到料仓拍照起始位; } break; diff --git a/Rs.DeweyTester/Rs.DeweyTester.csproj b/Rs.DeweyTester/Rs.DeweyTester.csproj index ad22af7..ccc8544 100644 --- a/Rs.DeweyTester/Rs.DeweyTester.csproj +++ b/Rs.DeweyTester/Rs.DeweyTester.csproj @@ -124,6 +124,7 @@ + diff --git a/Rs.DeweyTester/SysConfig/SelectProductFrm.cs b/Rs.DeweyTester/SysConfig/SelectProductFrm.cs index 700a683..671b516 100644 --- a/Rs.DeweyTester/SysConfig/SelectProductFrm.cs +++ b/Rs.DeweyTester/SysConfig/SelectProductFrm.cs @@ -92,7 +92,7 @@ namespace Rs.MotionPlat.SysConfig } else if (fixtureret.Result == EOneGrabSixteenResult.LocationOkScanBarcodeFail) { - EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Retry | EButtonType.Skip, $"穴位{i + 1}扫码失败"); + EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Retry | EButtonType.Skip, $"穴位{i + 1}扫码失败","scan fail",true); if (buttonSelect == EButtonType.Skip) { logInfo = $"{i + 1},NG\r\n"; @@ -106,7 +106,7 @@ namespace Rs.MotionPlat.SysConfig } else if (fixtureret.Result == EOneGrabSixteenResult.Slant) { - EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Retry | EButtonType.EndInput | EButtonType.Skip, $"穴位{i + 1}定位失败"); + EButtonType buttonSelect = Msgbox.ShowDialog(EButtonType.Retry | EButtonType.EndInput | EButtonType.Skip, $"穴位{i + 1}定位失败","location fail",true); if (buttonSelect == EButtonType.EndInput) { DischargeModuleGoSafePosFlow.Instance.GoSafePostion(); diff --git a/Rs.DeweyTester/TestFrm.Designer.cs b/Rs.DeweyTester/TestFrm.Designer.cs index a5b59a8..5b241ed 100644 --- a/Rs.DeweyTester/TestFrm.Designer.cs +++ b/Rs.DeweyTester/TestFrm.Designer.cs @@ -61,6 +61,8 @@ this.radioButton9 = new System.Windows.Forms.RadioButton(); this.radioButton1 = new System.Windows.Forms.RadioButton(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.button14 = new System.Windows.Forms.Button(); + this.button15 = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // @@ -440,11 +442,33 @@ this.groupBox2.TabStop = false; this.groupBox2.Text = "groupBox2"; // + // button14 + // + this.button14.Location = new System.Drawing.Point(493, 479); + this.button14.Name = "button14"; + this.button14.Size = new System.Drawing.Size(75, 23); + this.button14.TabIndex = 33; + this.button14.Text = "button14"; + this.button14.UseVisualStyleBackColor = true; + this.button14.Click += new System.EventHandler(this.button14_Click); + // + // button15 + // + this.button15.Location = new System.Drawing.Point(594, 479); + this.button15.Name = "button15"; + this.button15.Size = new System.Drawing.Size(75, 23); + this.button15.TabIndex = 33; + this.button15.Text = "button14"; + this.button15.UseVisualStyleBackColor = true; + this.button15.Click += new System.EventHandler(this.button15_Click_1); + // // 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.button15); + this.Controls.Add(this.button14); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.button12); @@ -503,5 +527,7 @@ private System.Windows.Forms.RadioButton radioButton9; private System.Windows.Forms.RadioButton radioButton1; private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Button button14; + private System.Windows.Forms.Button button15; } } \ No newline at end of file diff --git a/Rs.DeweyTester/TestFrm.cs b/Rs.DeweyTester/TestFrm.cs index 87edcda..bc8bc7f 100644 --- a/Rs.DeweyTester/TestFrm.cs +++ b/Rs.DeweyTester/TestFrm.cs @@ -318,5 +318,15 @@ namespace Rs.MotionPlat }); } + + private void button14_Click(object sender, EventArgs e) + { + BuzzerManager.Instance.On(); + } + + private void button15_Click_1(object sender, EventArgs e) + { + BuzzerManager.Instance.Off(); + } } }