From 4ae097174798e9cd679ca7cf29866ecc7ab716df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Sat, 9 Apr 2022 15:46:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E4=BB=A3=E6=9C=BA=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HBLConsole.Communication/LebaiHelper.cs | 2 - HBLConsole.Factory/SimpleFactory.cs | 1 + HBLConsole.MORKS/Alarm.cs | 127 +++++++++++++- HBLConsole.MORKS/Control_MORKS.cs | 157 ++++++++++-------- HBLConsole.MORKS/GVL_MORKS.cs | 16 +- HBLConsole/App.config | 2 +- HBLConsole/App.xaml.cs | 7 + .../ViewModel/ListDialogViewModel.cs | 2 + HBLConsole/ViewModel/ViewModelBase.cs | 6 + 9 files changed, 239 insertions(+), 81 deletions(-) diff --git a/HBLConsole.Communication/LebaiHelper.cs b/HBLConsole.Communication/LebaiHelper.cs index 76bfc71..5a4f688 100644 --- a/HBLConsole.Communication/LebaiHelper.cs +++ b/HBLConsole.Communication/LebaiHelper.cs @@ -105,8 +105,6 @@ namespace HBLConsole.Communication return 0; } - - /// /// 获取信号量 /// diff --git a/HBLConsole.Factory/SimpleFactory.cs b/HBLConsole.Factory/SimpleFactory.cs index 0916f5b..a196812 100644 --- a/HBLConsole.Factory/SimpleFactory.cs +++ b/HBLConsole.Factory/SimpleFactory.cs @@ -118,6 +118,7 @@ namespace HBLConsole.Factory ActionManage.GetInstance.Register(new Action((o) => { control?.IotBroadcast(o); }), "IotBroadcast"); ConnectHelper.GetInstance.Init(); ActionManage.GetInstance.Send("监控数据初始化"); + //ActionManage.GetInstance.Send("NoCompleteOrderInit"); //GetControlBase(); } diff --git a/HBLConsole.MORKS/Alarm.cs b/HBLConsole.MORKS/Alarm.cs index 52d904f..6e1591f 100644 --- a/HBLConsole.MORKS/Alarm.cs +++ b/HBLConsole.MORKS/Alarm.cs @@ -10,13 +10,128 @@ namespace HBLConsole.MORKS { public class Alarm : IAlarm { - [Alarm("报警测试1")] - public bool AlarmTest1 { get; set; } - [Alarm("报警测试2")] - public bool AlarmTest2 { get; set; } - [Alarm("报警测试3")] - public bool AlarmTest3 { get; set; } + /// + /// 煮面机左侧低温报警 + /// PLC ---> M550.0 + /// ModbusTcp --> 1570 + /// + [Alarm("煮面机左侧低温报警")] + public bool MachineLeftLowTemperature { get; set; } + + /// + /// 煮面机左侧低温报警 + /// PLC ---> M550.1 + /// ModbusTcp --> 1571 + /// + [Alarm("煮面机右侧低温报警")] + public bool MachineRightLowTemperature { get; set; } + + /// + /// 供碗1缺碗 + /// PLC ---> M550.2 + /// ModbusTcp --> 1572 + /// + [Alarm("供碗1缺碗")] + public bool Supply1_LossBowl { get; set; } + + /// + /// 供碗2缺碗 + /// PLC ---> M550.3 + /// ModbusTcp --> 1573 + /// + [Alarm("供碗2缺碗")] + public bool Supply2_LossBowl { get; set; } + + /// + /// 供碗1出碗检测异常 + /// PLC ---> M550.4 + /// ModbusTcp --> 1574 + /// + [Alarm("供碗1出碗检测异常")] + public bool Supply1_ErrorOutBowl { get; set; } + + /// + /// 供碗2出碗检测异常 + /// PLC ---> M550.5 + /// ModbusTcp --> 1575 + /// + [Alarm("供碗2出碗检测异常")] + public bool Supply2_ErrorOutBowl { get; set; } + + /// + /// 推碗气缸故障 + /// PLC ---> M550.6 + /// ModbusTcp --> 1576 + /// + [Alarm("推碗气缸故障")] + public bool PushBowlCylinderError { get; set; } + + /// + /// 煮面机通讯异常 + /// PLC ---> M550.7 + /// ModbusTcp --> 1577 + /// + [Alarm("煮面机通讯异常")] + public bool NoodleMacCommunicateError { get; set; } + + /// + /// 煮面机通讯异常 + /// PLC ---> M551.0 + /// ModbusTcp --> 1580 + /// + [Alarm("配料机通讯异常")] + public bool DosingMacCommunicateError { get; set; } + + /// + /// 机器人通讯异常 + /// PLC ---> M551.1 + /// ModbusTcp --> 1581 + /// + [Alarm("机器人通讯异常")] + public bool RobotMacCommunicateError { get; set; } + + /// + /// 机器人初始化失败 + /// PLC ---> M551.3 + /// ModbusTcp --> 1583 + /// + [Alarm("机器人初始化失败")] + public bool RobotInitError { get; set; } + + /// + /// 机器人急停 + /// PLC ---> M551.4 + /// ModbusTcp --> 1584 + /// + [Alarm("机器人急停")] + public bool RobotUrgentStop { get; set; } + + /// + /// 机器人不在远程模式 + /// PLC ---> M551.5 + /// ModbusTcp --> 1585 + /// + [Alarm("机器人不在远程模式")] + public bool RobotNotInRemoteMode { get; set; } + + /// + /// 机器人伺服未就绪 + /// PLC ---> M551.6 + /// ModbusTcp --> 1586 + /// + [Alarm("机器人伺服未就绪")] + public bool RobotNotInReady { get; set; } + + /// + /// 机器人本体异常 + /// PLC ---> M551.7 + /// ModbusTcp --> 1587 + /// + [Alarm("机器人本体异常")] + public bool RobotSelfInException { get; set; } + + } } diff --git a/HBLConsole.MORKS/Control_MORKS.cs b/HBLConsole.MORKS/Control_MORKS.cs index 2e649ad..fadeb5d 100644 --- a/HBLConsole.MORKS/Control_MORKS.cs +++ b/HBLConsole.MORKS/Control_MORKS.cs @@ -117,6 +117,7 @@ namespace HBLConsole.MORKS mORKS.TurntableLowerLimit = bools[11]; mORKS.MissingBowlSignal2 = bools[12]; mORKS.TurntableUpLimit = bools[13]; + mORKS.FeedComplete = bools[14]; mORKS.TurntableMoveInPlace = bools[15]; })); @@ -310,101 +311,121 @@ namespace HBLConsole.MORKS /// private void TurntableControl() { - if (mORKS.TurntableMoveInPlace && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) - { - - if (mORKS.TurntableLowerLimit) - { - TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc); - mORKS.AllowTakeNoodle = true; - mORKS.TurntableLocLists.Clear(); - MessageLog.GetInstance.Show("转台位置OK"); - mORKS.IsNoodles = true; - } - else - { - if (!mORKS.TurntableInterlock) - { - var result = Json.Data.orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); - if (result != null) - { - foreach (var item in result) - { - - if (ushort.TryParse(item.BatchingLoc, out ushort loc)) - { - if (mORKS.TurntableFeedbackloc != loc) - { - if (!mORKS.TurntableLocLists.Contains(loc)) - { - TurntableStart(loc); - MessageLog.GetInstance.Show("未检测到物料,启动转台查找"); - return; - } - } - - } - } - mORKS.IsNoodles = false; - MessageLog.GetInstance.Show("转台位置缺少物料"); - } - } - } - } - - - - #region 优化版本 //if (mORKS.TurntableMoveInPlace && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) //{ - // var result = Json.Data.orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); + // if (mORKS.TurntableLowerLimit) // { - // if (mORKS.TurntableFeedbackloc == mORKS.RBTakeNoodleTask.ElementAt(0).Loc || (result?.Count > 0 && result?.Count == mORKS.TurntableLocLists.Count)) - // { - // mORKS.TurntableLocLists.Clear(); - // mORKS.AllowTakeNoodle = true; - // MessageLog.GetInstance.Show("转台位置OK,执行机器人取面"); - // } - // else - // { - // if (!mORKS.TurntableInterlock) - // { - // TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc); - // MessageLog.GetInstance.Show($"有物料检测,反馈位置不同的转台启动控制,转台位置:[{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}]"); - // } - // } + // TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc); + // mORKS.AllowTakeNoodle = true; + // mORKS.TurntableLocLists.Clear(); + // MessageLog.GetInstance.Show("转台位置OK"); + // mORKS.IsNoodles = true; // } // else // { // if (!mORKS.TurntableInterlock) // { + // var result = Json.Data.orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); // if (result != null) // { // foreach (var item in result) // { + // if (ushort.TryParse(item.BatchingLoc, out ushort loc)) // { - // if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) + // if (mORKS.TurntableFeedbackloc != loc) // { - // TurntableStart(loc); - // MessageLog.GetInstance.Show($"没有物料检测的启动转台控制,转台位置:[{loc}]"); - // break; + // if (!mORKS.TurntableLocLists.Contains(loc)) + // { + // TurntableStart(loc); + // MessageLog.GetInstance.Show("未检测到物料,启动转台查找"); + // return; + // } // } - // else if (mORKS.TurntableFeedbackloc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc); + // } // } + // mORKS.IsNoodles = false; + // MessageLog.GetInstance.Show("转台位置缺少物料"); // } // } - // } //} + + + #region 优化版本 + if (mORKS.TurntableMoveInPlace && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) + { + var result = Json.Data.orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); + if (mORKS.TurntableLowerLimit) + { + var res = result.FirstOrDefault(P => P.BatchingLoc == mORKS.TurntableFeedbackloc.ToString()); + if (res != null) + { + mORKS.TurntableLocLists.Clear(); + mORKS.AllowTakeNoodle = true; + ModbusTcpHelper.GetInstance.Write(101, WriteType.HoldingRegisters, mORKS.TurntableFeedbackloc); + MessageLog.GetInstance.Show("转台位置OK,执行机器人取面"); + } + + //if (mORKS.TurntableFeedbackloc == mORKS.RBTakeNoodleTask.ElementAt(0).Loc || (result?.Count > 0 && result?.Count == mORKS.TurntableLocLists.Count)) + //{ + // mORKS.TurntableLocLists.Clear(); + // mORKS.AllowTakeNoodle = true; + // MessageLog.GetInstance.Show("转台位置OK,执行机器人取面"); + //} + //else + //{ + // if (!mORKS.TurntableInterlock) + // { + // //TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc); + // mORKS.AllowTakeNoodle = true; + // MessageLog.GetInstance.Show($"有物料检测,反馈位置不同的转台启动控制,转台位置:[{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}]"); + // } + //} + } + else + { + if (!mORKS.TurntableInterlock) + { + if (result != null) + { + foreach (var item in result) + { + if (ushort.TryParse(item.BatchingLoc, out ushort loc)) + { + if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) + { + TurntableStart(loc); + MessageLog.GetInstance.Show($"没有物料检测的启动转台控制,转台位置:[{loc}]"); + break; + } + else if (mORKS.TurntableFeedbackloc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc); + } + } + } + } + } + } + //转台到位检测 if (RTrig.GetInstance("TurntableInPlace").Start(mORKS.TurntableMoveInPlace)) { mORKS.TurntableInterlock = false; } + + //补料完成检测 + if (RTrig.GetInstance("FeedComplete").Start(mORKS.FeedComplete)) + { + if (!mORKS.TurntableLowerLimit && mORKS.TurntableLocLists.Count > 0 && !mORKS.AllowTakeNoodle) + { + mORKS.TurntableLocLists.Clear(); + mORKS.TurntableInterlock = false; + } + } + #endregion @@ -425,7 +446,7 @@ namespace HBLConsole.MORKS if (mORKS.RBTakeNoodleTask.TryDequeue(out OrderLocInfo orderLocInfo)) { //设置转台位置 - TurntableStart(orderLocInfo.Loc); + //TurntableStart(orderLocInfo.Loc); //设置倒面位置 mORKS.CookNodelId[loc] = orderLocInfo.SuborderId; @@ -434,7 +455,7 @@ namespace HBLConsole.MORKS //机器人开始取面 RobotTakeNoodle(); SimpleFactory.GetInstance.OrderChanged(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); - MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,转台:[{orderLocInfo}],煮面栏:[{loc + 1}]"); + MessageLog.GetInstance.Show($"订单【{orderLocInfo.SuborderId}】,转台:[{orderLocInfo.Loc}],煮面栏:[{loc + 1}]"); mORKS.TakeNoodleInterlock = true; } } diff --git a/HBLConsole.MORKS/GVL_MORKS.cs b/HBLConsole.MORKS/GVL_MORKS.cs index d854dc3..940cd0f 100644 --- a/HBLConsole.MORKS/GVL_MORKS.cs +++ b/HBLConsole.MORKS/GVL_MORKS.cs @@ -207,6 +207,14 @@ namespace HBLConsole.MORKS [VariableMonitor("转台上限检测", "M101.5", "1133")] public bool TurntableUpLimit { get; set; } + /// + /// 补料完成 + /// PLC -> M101.6 + /// ModbusTcp -> 1134 + /// + [VariableMonitor("补料完成", "M101.6", "1134")] + public bool FeedComplete { get; set; } + /// /// 转台移动到位 /// PLC -> M101.7 @@ -241,11 +249,11 @@ namespace HBLConsole.MORKS public ushort RecipeNumber { get; set; } /// - /// 转台位置 + /// 转台设置位置 /// PLC -> VW2 /// ModbusTcp -> 101 /// - [VariableMonitor("转台位置", "VW2", "101")] + [VariableMonitor("转台设置位置", "VW2", "101")] public ushort TurntableLoc { get; set; } /// @@ -265,11 +273,11 @@ namespace HBLConsole.MORKS public ushort TakeNoodleLoc { get; set; } /// - /// 转台位置 + /// 转台反馈位置 /// PLC -> VW372 /// ModbusTcp -> 286 /// - [VariableMonitor("转台位置", "VW372", "286")] + [VariableMonitor("转台反馈位置", "VW372", "286")] public ushort TurntableFeedbackloc { get; set; } /// diff --git a/HBLConsole/App.config b/HBLConsole/App.config index 19426ed..971301d 100644 --- a/HBLConsole/App.config +++ b/HBLConsole/App.config @@ -11,7 +11,7 @@ - + diff --git a/HBLConsole/App.xaml.cs b/HBLConsole/App.xaml.cs index 9a8218e..dd1dc7b 100644 --- a/HBLConsole/App.xaml.cs +++ b/HBLConsole/App.xaml.cs @@ -17,6 +17,7 @@ using HBLConsole.Business; using HBLConsole.AdvertiseWindow; using System.Windows.Forms; using System.Drawing; +using HBLConsole.ViewModel; //问题.net core项目中引用 using System.Windows.Forms; 失败 //解决方案:在 csproj 文件的 PropertyGroup里面添加 true @@ -36,6 +37,7 @@ namespace HBLConsole { base.OnStartup(e); //SystemHelper.GetInstance.AutoStart(true); + ViewModelBase.Init(); SystemHelper.GetInstance.CreateDesktopShortcut(); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; MainConsole.Main.GetInstance.DataInit(); @@ -43,7 +45,12 @@ namespace HBLConsole mainView = new MainView(); mainView.Show(); SplitScreenDisplay(); + //ActionManage.GetInstance.Register(new Action(() => + //{ + // NoCompleteOrderInit(); + //}), "NoCompleteOrderInit"); NoCompleteOrderInit(); + MainConsole.Main.GetInstance.BusinessInit(); } diff --git a/HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs b/HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs index 01813df..fe8a808 100644 --- a/HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs +++ b/HBLConsole/DialogWindow/ViewModel/ListDialogViewModel.cs @@ -31,12 +31,14 @@ namespace HBLConsole.DialogWindow.ViewModel { Json.Data.orderLists.Clear(); WeakReferenceMessenger.Default.Send("false", "Close"); + Json.Save(); }); CancelCommand = new RelayCommand(() => { Json.Data.orderLists.Clear(); WeakReferenceMessenger.Default.Send("false", "Close"); + Json.Save(); }); ConfirmCommand = new RelayCommand(() => diff --git a/HBLConsole/ViewModel/ViewModelBase.cs b/HBLConsole/ViewModel/ViewModelBase.cs index 0f91691..4ba0ae8 100644 --- a/HBLConsole/ViewModel/ViewModelBase.cs +++ b/HBLConsole/ViewModel/ViewModelBase.cs @@ -25,6 +25,11 @@ namespace HBLConsole.ViewModel { public ViewModelBase() + { + + } + + public static void Init() { MessageLog.GetInstance.InfoNotify = new Action((s) => { @@ -46,6 +51,7 @@ namespace HBLConsole.ViewModel }); } + #region 静态通知属性 public static event EventHandler StaticPropertyChanged;