From c569d4877c9a681ba92886fc77a0849f0eb5d5e6 Mon Sep 17 00:00:00 2001 From: Admin Date: Thu, 29 Jan 2026 23:28:00 +0800 Subject: [PATCH] 1 --- Model/FlowModel.cs | 7 + ViewModel/MainWindowVM.cs | 614 +++++++++++++++++++++++++++----------- 2 files changed, 440 insertions(+), 181 deletions(-) diff --git a/Model/FlowModel.cs b/Model/FlowModel.cs index da1c4a6..245a6e5 100644 --- a/Model/FlowModel.cs +++ b/Model/FlowModel.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Documents; namespace Model { @@ -12,6 +13,12 @@ namespace Model /// public class FlowModel : NotificationObject { + public InputSignal InSignal { get; set; } + public InputSignal OutSignal { get; set; } + public OutputSignal OutCmd { get; set; } + + public bool EnPut { get; set; } + private string myName; /// /// 流程名称 diff --git a/ViewModel/MainWindowVM.cs b/ViewModel/MainWindowVM.cs index d585fe5..0f8205f 100644 --- a/ViewModel/MainWindowVM.cs +++ b/ViewModel/MainWindowVM.cs @@ -1,36 +1,22 @@ using Community; -using ControlzEx.Theming; using DAL; -using HalconDotNet; -using LiveCharts; -using LiveCharts.Wpf; -using MahApps.Metro.Controls; using MahApps.Metro.Controls.Dialogs; -using Microsoft.Win32; using Model; using Model.HSL; using Model.MotionControl; using Model.Vision; using System; -using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Configuration; -using System.Diagnostics; using System.IO; -using System.IO.Ports; using System.Linq; -using System.Net; using System.Numerics; using System.Reflection; -using System.ServiceProcess; using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; -using System.Windows.Input; using System.Windows.Media; using System.Windows.Threading; using ViewModel.MotionControl; @@ -43,103 +29,103 @@ namespace ViewModel public partial class MainWindowVM : NotificationObject { #region IO -const int I00启动 = 0; -const int I01停止 = 1; -const int I02急停 = 2; -const int I03气压检知 = 3; -const int I04_ = 4; -const int I05_ = 5; -const int I06左测试完成 = 6; -const int I07右测试完成 = 7; -const int I08门禁1 = 8; -const int I09门禁2 = 9; -const int I10门禁3 = 10; -const int I11门禁4 = 11; -const int I12光幕检测 = 12; -const int I13_ = 13; -const int I14左投料完成 = 14; -const int I15右投料完成 = 15; -const int I16左伸缩气缸伸出 = 16; -const int I17左伸缩气缸缩回 = 17; -const int I18左顶升气缸1下位 = 18; -const int I19左顶升气缸1上位 = 19; -const int I20左顶升气缸2下位 = 20; -const int I21左顶升气缸2上位 = 21; -const int I22右伸缩气缸伸出 = 22; -const int I23右伸缩气缸缩回 = 23; -const int I24右顶升气缸1下位 = 24; -const int I25右顶升气缸1上位 = 25; -const int I26右顶升气缸2下位 = 26; -const int I27右顶升气缸2上位 = 27; -const int I28_ = 28; -const int I29_ = 29; -const int I30_ = 30; -const int I31_ = 31; -const int I32机械手真空检1 = 32; -const int I33机械手真空检2 = 33; -const int I34机械手上下气缸1上位 = 34; -const int I35机械手上下气缸1下位 = 35; -const int I36机械手上下气缸2上位 = 36; -const int I37机械手上下气缸2下位 = 37; -const int I38NG皮带检知1 = 38; -const int I39NG皮带检知2 = 39; -const int I40NG皮带检知3 = 40; -const int I41流线1皮带检知1 = 41; -const int I42流线1皮带检知2 = 42; -const int I43流线2皮带检知1 = 43; -const int I44流线2皮带检知2 = 44; -const int I45_ = 45; -const int I46_ = 46; -const int I47_ = 47; -const int O00红灯 = 0; -const int O01黄灯 = 1; -const int O02绿灯 = 2; -const int O03蜂鸣器 = 3; -const int O04_ = 4; -const int O05_ = 5; -const int O06_ = 6; -const int O07_ = 7; -const int O08左触发 = 8; -const int O09右触发 = 9; -const int O10_ = 10; -const int O11_ = 11; -const int O12_ = 12; -const int O13_ = 13; -const int O14上光源控制 = 14; -const int O15下光源控制 = 15; -const int O16左伸缩气缸伸出 = 16; -const int O17左伸缩气缸缩回 = 17; -const int O18左顶升气缸1下位 = 18; -const int O19左顶升气缸1上位 = 19; -const int O20左顶升气缸2下位 = 20; -const int O21左顶升气缸2上位 = 21; -const int O22右伸缩气缸伸出 = 22; -const int O23右伸缩气缸缩回 = 23; -const int O24右顶升气缸1下位 = 24; -const int O25右顶升气缸1上位 = 25; -const int O26右顶升气缸2下位 = 26; -const int O27右顶升气缸2上位 = 27; -const int O28_ = 28; -const int O29NG皮带控制 = 29; -const int O30流线1皮带控制 = 30; -const int O31流线2皮带控制 = 31; -const int O32机械手真空吸1 = 32; -const int O33机械手真空破1 = 33; -const int O34机械手真空吸2 = 34; -const int O35机械手真空破2 = 35; -const int O36机械手上下气缸1上位 = 36; -const int O37机械手上下气缸1下位 = 37; -const int O38机械手上下气缸2上位 = 38; -const int O39机械手上下气缸2下位 = 39; -const int O40_ = 40; -const int O41_ = 41; -const int O42_ = 42; -const int O43_ = 43; -const int O44_ = 44; -const int O45_ = 45; -const int O46_ = 46; -const int O47_ = 47; -#endregion + const int I00启动 = 0; + const int I01停止 = 1; + const int I02急停 = 2; + const int I03气压检知 = 3; + const int I04_ = 4; + const int I05_ = 5; + const int I06左测试完成 = 6; + const int I07右测试完成 = 7; + const int I08门禁1 = 8; + const int I09门禁2 = 9; + const int I10门禁3 = 10; + const int I11门禁4 = 11; + const int I12光幕检测 = 12; + const int I13_ = 13; + const int I14左投料完成 = 14; + const int I15右投料完成 = 15; + const int I16左伸缩气缸伸出 = 16; + const int I17左伸缩气缸缩回 = 17; + const int I18左顶升气缸1下位 = 18; + const int I19左顶升气缸1上位 = 19; + const int I20左顶升气缸2下位 = 20; + const int I21左顶升气缸2上位 = 21; + const int I22右伸缩气缸伸出 = 22; + const int I23右伸缩气缸缩回 = 23; + const int I24右顶升气缸1下位 = 24; + const int I25右顶升气缸1上位 = 25; + const int I26右顶升气缸2下位 = 26; + const int I27右顶升气缸2上位 = 27; + const int I28_ = 28; + const int I29_ = 29; + const int I30_ = 30; + const int I31_ = 31; + const int I32机械手真空检1 = 32; + const int I33机械手真空检2 = 33; + const int I34机械手上下气缸1上位 = 34; + const int I35机械手上下气缸1下位 = 35; + const int I36机械手上下气缸2上位 = 36; + const int I37机械手上下气缸2下位 = 37; + const int I38NG皮带检知1 = 38; + const int I39NG皮带检知2 = 39; + const int I40NG皮带检知3 = 40; + const int I41流线1皮带检知1 = 41; + const int I42流线1皮带检知2 = 42; + const int I43流线2皮带检知1 = 43; + const int I44流线2皮带检知2 = 44; + const int I45_ = 45; + const int I46_ = 46; + const int I47_ = 47; + const int O00红灯 = 0; + const int O01黄灯 = 1; + const int O02绿灯 = 2; + const int O03蜂鸣器 = 3; + const int O04_ = 4; + const int O05_ = 5; + const int O06_ = 6; + const int O07_ = 7; + const int O08左触发 = 8; + const int O09右触发 = 9; + const int O10_ = 10; + const int O11_ = 11; + const int O12_ = 12; + const int O13_ = 13; + const int O14上光源控制 = 14; + const int O15下光源控制 = 15; + const int O16左伸缩气缸伸出 = 16; + const int O17左伸缩气缸缩回 = 17; + const int O18左顶升气缸1下位 = 18; + const int O19左顶升气缸1上位 = 19; + const int O20左顶升气缸2下位 = 20; + const int O21左顶升气缸2上位 = 21; + const int O22右伸缩气缸伸出 = 22; + const int O23右伸缩气缸缩回 = 23; + const int O24右顶升气缸1下位 = 24; + const int O25右顶升气缸1上位 = 25; + const int O26右顶升气缸2下位 = 26; + const int O27右顶升气缸2上位 = 27; + const int O28_ = 28; + const int O29NG皮带控制 = 29; + const int O30流线1皮带控制 = 30; + const int O31流线2皮带控制 = 31; + const int O32机械手真空吸1 = 32; + const int O33机械手真空破1 = 33; + const int O34机械手真空吸2 = 34; + const int O35机械手真空破2 = 35; + const int O36机械手上下气缸1上位 = 36; + const int O37机械手上下气缸1下位 = 37; + const int O38机械手上下气缸2上位 = 38; + const int O39机械手上下气缸2下位 = 39; + const int O40_ = 40; + const int O41_ = 41; + const int O42_ = 42; + const int O43_ = 43; + const int O44_ = 44; + const int O45_ = 45; + const int O46_ = 46; + const int O47_ = 47; + #endregion #region 生产的Grid状态 private string gridWidth; @@ -1249,7 +1235,8 @@ const int O47_ = 47; DownVisionFlow = new FlowModel("测试盒取出"); BoxInPutFlow = new FlowModel("测试盒投入"); CarryPutOutFlow = new FlowModel("机台搬运"); - ProLineFlow = new FlowModel("良品皮带运行"); + OKLineFlow = new FlowModel("良品皮带运行"); + PassLineFlow = new FlowModel("过站皮带运行"); TestBoxFlow = new FlowModel("测试平台运行"); //把吸嘴给机器人 避免撞坏吸嘴 @@ -1642,7 +1629,7 @@ const int O47_ = 47; DualControlRun();//双控运行 GoHome(); //回原点 - + SendFrontStation();//发送信息给前站 SendNextStation();//发送消息给下一站 @@ -1726,11 +1713,11 @@ const int O47_ = 47; if (!GRRMode) { LogicDispatch(LogicDispatchFlow);//逻辑总管 - //CarryPutOutRun(CarryPutOutFlow); //机台搬运 - + //CarryPutOutRun(CarryPutOutFlow); //机台搬运 + } - ProLineRun(ProLineFlow);//良品皮带 + ProLineRun(OKLineFlow);//良品皮带 TestBoxRun(TestBoxFlow);//测试平台 //CheckXizui(); @@ -1793,6 +1780,13 @@ const int O47_ = 47; MyFlow.RunStep++; MyFlow.RunTime = DateTime.Now; BoxOutPutFlow = new FlowModel("测试盒取出"); + } + else if(PassLineFlow.EnPut ) + + { + + + } break; case GengralProcessEnum.Step4: @@ -2265,9 +2259,25 @@ const int O47_ = 47; //机器人到位 if (Robot.RcvShowInfo.Contains("runpointok")) { - CurrXizui.QiGang.Switchs = true; - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; + + if (CurrXizui.State.StatusBackground == ColorStr.Green) + { + if (OKLineFlow.EnPut) + { + + CurrXizui.QiGang.Switchs = true; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + + } + + } + else + { + CurrXizui.QiGang.Switchs = true; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } } else if (TimeOutValidation(MyFlow.RunTime, 10000, "机器人到位超时")) @@ -2314,7 +2324,7 @@ const int O47_ = 47; { if (CurrXizui.State.StatusBackground == ColorStr.Green) { - PutOk = true; + } else { @@ -2367,6 +2377,164 @@ const int O47_ = 47; #endregion + + #region 过站产品 + + FlowModel PassFlow { get; set; } + /// + /// 分选不良品 + /// + /// + /// + private bool PassRun(FlowModel MyFlow) + { + bool bl = false; + switch (MyFlow.RunStep) + { + case GengralProcessEnum.Start: + //获取需要分拣的吸嘴 + CurrXizui = XizuiLabelPaperList[1]; + + break; + case GengralProcessEnum.Step1: + + TempPoint = CurrentMachine.RobotPointList.Where(w => w.PointType == 13).FirstOrDefault(); + + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + break; + case GengralProcessEnum.Step2: + //发送坐标 + if (Robot.RunRobotPoint(TempPoint)) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step3: + //机器人到位 + if (Robot.RcvShowInfo.Contains("runpointok")) + { + + if (CurrXizui.State.StatusBackground == ColorStr.Green) + { + if (OKLineFlow.EnPut) + { + + CurrXizui.QiGang.Switchs = true; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + + } + + } + else + { + CurrXizui.QiGang.Switchs = true; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + + } + else if (TimeOutValidation(MyFlow.RunTime, 10000, "机器人到位超时")) + { + MyFlow.RunStep--; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step4: + //气缸下降到位 + if (CurrXizui.QiGangDown.LightUp) + { + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 10000, CurrXizui.QiGangDown.InputMeaning + "异常")) + { + CurrXizui.QiGang.Switchs = true; + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step5: + CurrXizui.VacuumSwitch.Switchs = false;//真空吸 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + break; + case GengralProcessEnum.Step6: + //真空捡知有 + if (!CurrXizui.VacuumCheck.LightUp && MyFlow.RunTime.AddMilliseconds(500) < DateTime.Now) + { + CurrXizui.QiGang.Switchs = false;//气缸上升 + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.VacuumCheck.InputMeaning + "超时")) + { + MyFlow.RunTime = DateTime.Now; + } + break; + case GengralProcessEnum.Step7: + //气缸上升到位 + if (CurrXizui.QiGangUp.LightUp) + { + if (CurrXizui.State.StatusBackground == ColorStr.Green) + { + + } + else + { + BadLineRun = true; + } + CurrXizui.State = new ShowInfo(); + ClearBox = false; //清料完成 + MyFlow.RunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + + //MyFlow.RunStep++; + //MyFlow.RunTime = DateTime.Now; + } + else if (TimeOutValidation(MyFlow.RunTime, 3000, CurrXizui.QiGangUp.InputMeaning + "异常")) + { + CurrXizui.QiGang.Switchs = false; + MyFlow.RunTime = DateTime.Now; + } + break; + //case GengralProcessEnum.Step8: + // //获取待机位 + // TempPoint = Coper(Robot.RobotPointList.Where(w => w.PointType == 1).FirstOrDefault()); + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // break; + //case GengralProcessEnum.Step9: + // //发送机器人点位 + // Robot.RunRobotPoint(TempPoint); + // MyFlow.RunStep++; + // MyFlow.RunTime = DateTime.Now; + // break; + //case GengralProcessEnum.Step10: + // //机器人到位 + // if (Robot.RcvShowInfo.Contains("runpointok")) + // { + // ClearBox = false; //清料完成 + // MyFlow.RunStep = GengralProcessEnum.Start; + // MyFlow.RunTime = DateTime.Now; + // } + // else if (TimeOutValidation(MyFlow.RunTime, 20000, "机器人到位超时")) + // { + // MyFlow.RunStep--; + // MyFlow.RunTime = DateTime.Now; + // } + // break; + } + + return bl; + } + + #endregion + + + #region 上视觉检查运行 /// /// 上视觉检查 @@ -3013,43 +3181,10 @@ const int O47_ = 47; /// bool RobotSafe { get; set; } - + #endregion - #region 出料运行 - /// - /// 出料流程 - /// - FlowModel ProLineFlow { get; set; } - /// - /// 流线空闲信号 - /// - public bool PutOk { get; set; } - - /// - /// 良品运行 - /// - private void ProLineRun(FlowModel MyFlow) - { - switch (MyFlow.RunStep) - { - case GengralProcessEnum.Start: - OutputList[O30流线1皮带控制].Switchs = false; - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - break; - case GengralProcessEnum.Step1: - - PutOk = false; - MyFlow.RunStep++; - MyFlow.RunTime = DateTime.Now; - break; - - - } - } - #endregion #region 检查吸嘴真空 /// @@ -3578,13 +3713,9 @@ const int O47_ = 47; /// private void DualControlRun() { - //OutputList[Y105左笔形气缸伸出].Switchs = !OutputList[Y106左笔形气缸缩回].Switchs; - //OutputList[Y107左顶升气缸下位].Switchs = !OutputList[Y108左顶升气缸上位].Switchs; - //OutputList[Y109右笔形气缸伸出].Switchs = !OutputList[Y110右笔形气缸缩回].Switchs; - //OutputList[Y111右顶升气缸下位].Switchs = !OutputList[Y112右顶升气缸上位].Switchs; - //OutputList[Y200搬运气缸上位].Switchs = !OutputList[Y201搬运气缸下位].Switchs; - OutputList[36].Switchs = !OutputList[37].Switchs; - OutputList[38].Switchs = !OutputList[39].Switchs; + + OutputList[O36机械手上下气缸1上位].Switchs = !OutputList[O37机械手上下气缸1下位].Switchs; + OutputList[O38机械手上下气缸2上位].Switchs = !OutputList[O39机械手上下气缸2下位].Switchs; } #endregion @@ -3611,18 +3742,7 @@ const int O47_ = 47; } } - //连接上一站 - //if (FrontStation != null) - //{ - // if (!FrontStation.ConnectSwitch) - // { - // FrontStation.ConnectSwitch = true; - // } - // else if (FrontStation.Showmsg.StatusBackground != ColorStr.Green) - // { - // FrontStation.ConnectSwitch = false; - // } - //} + } } #endregion @@ -3752,7 +3872,7 @@ const int O47_ = 47; } else { - + NextStation.ConnectSwitch = !NextStation.ConnectSwitch; } SendNextStationTime = DateTime.Now; @@ -3778,7 +3898,7 @@ const int O47_ = 47; } else { - + FrontStation.ConnectSwitch = !FrontStation.ConnectSwitch; } @@ -3836,7 +3956,7 @@ const int O47_ = 47; } #endregion - + #endregion #region 4、加载功能界面 @@ -4227,12 +4347,11 @@ const int O47_ = 47; DownVisionFlow = new FlowModel("测试盒取出"); BoxInPutFlow = new FlowModel("测试盒投入"); CarryPutOutFlow = new FlowModel("机台搬运"); - ProLineFlow = new FlowModel("良品皮带运行"); + OKLineFlow = new FlowModel("良品皮带运行"); TestBoxFlow = new FlowModel("测试平台运行"); - + PassLineFlow = new FlowModel("过站皮带运行"); TestFinish = false; Testing = false; - PutOk = false; //MyVehicleBox.ForEach(w => w.State.StatusBackground = ColorStr.White); @@ -4546,7 +4665,7 @@ const int O47_ = 47; { ExcepList.Add((RecordInfo)info); } - + void DelItem(object info) { @@ -4889,7 +5008,7 @@ const int O47_ = 47; } } - + /// /// 发送给后站的消息 /// @@ -4912,9 +5031,142 @@ const int O47_ = 47; } } #endregion + + + + + #endregion + #region 良品运行 + /// + /// 出料流程 + /// + FlowModel OKLineFlow { get; set; } + FlowModel PassLineFlow { get; set; } + + + /// + /// 皮带运行 + /// + private void ProLineRun(FlowModel MyFlow) + { + switch (MyFlow.RunStep) + { + case GengralProcessEnum.Start: + + MyFlow.InSignal = InputList[I41流线1皮带检知1]; + MyFlow.OutSignal = InputList[I42流线1皮带检知2]; + MyFlow.OutCmd = OutputList[O30流线1皮带控制]; + MyFlow.OutCmd.Switchs = false; + if (MyFlow.InSignal.LightUp == false && MyFlow.OutSignal.LightUp == false) + { + MyFlow.EnPut = true; + + } + else + { + + MyFlow.EnPut = false; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + + break; + case GengralProcessEnum.Step1: + + if (MyFlow.InSignal.LightUp && MyFlow.OutSignal.LightUp == false) + { + + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + + } + else if (MyFlow.InSignal.LightUp == false && MyFlow.OutSignal.LightUp) + { + MyFlow.RunStep = GengralProcessEnum.Step10; + MyFlow.RunTime = DateTime.Now; + } + else if (MyFlow.InSignal.LightUp && MyFlow.OutSignal.LightUp) + + { + + ExcepStop($" {MyFlow.InSignal.InputMeaning} 和 {MyFlow.OutSignal.InputMeaning} 不能同时有料,请取出一个 "); + + } + else + { + + MyFlow.RunStep--; + + } + break; + case GengralProcessEnum.Step2: + + MyFlow.OutCmd.Switchs = true; + if (MyFlow.OutSignal.LightUp) + { + MyFlow.OutCmd.Switchs = false; + MyFlow.RunStep = GengralProcessEnum.Step10; + MyFlow.RunTime = DateTime.Now; + + } + else if (MyFlow.RunTime.AddSeconds(20) < DateTime.Now) + { + MyFlow.OutCmd.Switchs = false; + ExcepStop($"从 {MyFlow.InSignal.InputMeaning} 到 {MyFlow.OutSignal.InputMeaning} 传递超时 "); + + } + break; + case GengralProcessEnum.Step10: + + if (NextStationReceive[0].Request) + { + + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + } + + break; + case GengralProcessEnum.Step11: + + MyFlow.OutCmd.Switchs = true; + if (MyFlow.OutSignal.LightUp == false) + { + MyFlow.OutCmd.Switchs = false; + MyFlow.RunStep++; + MyFlow.RunTime = DateTime.Now; + + } + else if (MyFlow.RunTime.AddSeconds(20) < DateTime.Now) + { + + ExcepStop($"{MyFlow.OutSignal.InputMeaning} 出料超时"); + + } + + break; + + case GengralProcessEnum.Step12: + + if (NextStationReceive[0].Request == false) + { + + MyFlow.RunStep = GengralProcessEnum.Start; + MyFlow.RunTime = DateTime.Now; + } + else if (MyFlow.RunTime.AddSeconds(20) < DateTime.Now) + { + + ExcepStop($"后站交互超时"); + + } + break; + + } + } + #endregion }