diff --git a/HBLConsole.Communication/LebaiHelper.cs b/HBLConsole.Communication/LebaiHelper.cs index f4199be..69cc9f5 100644 --- a/HBLConsole.Communication/LebaiHelper.cs +++ b/HBLConsole.Communication/LebaiHelper.cs @@ -100,6 +100,7 @@ namespace HBLConsole.Communication public void GetRobotModeStatus() { + if (robotData == null) return; int mode = robotData.RobotMode.Mode; IsIdle = mode == 5; @@ -161,7 +162,7 @@ namespace HBLConsole.Communication /// /// /// - public SignalResult SetValue(int value,int index = 0) + public SignalResult SetValue(int value, int index = 0) { if (robotData == null) return default(SignalResult); SignalValue signalValue = new SignalValue(); @@ -193,13 +194,13 @@ namespace HBLConsole.Communication public async void Scene(int id) { CancellationToken cancellationToken = default(CancellationToken); - var result = await client.GetTasks(new GetTasksInput { PageIndex = 1,PageSize = 1 },cancellationToken); + var result = await client.GetTasks(new GetTasksInput { PageIndex = 1, PageSize = 1 }, cancellationToken); var first = result?.Items?.FirstOrDefault(); var r = first == null || first.Status != Lebai.SDK.Dtos.TaskStatus.Running && first.Status != Lebai.SDK.Dtos.TaskStatus.Pause; while (!r) { Thread.Sleep(5); - result = await client.GetTasks(new GetTasksInput { PageIndex = 1,PageSize = 1 },cancellationToken); + result = await client.GetTasks(new GetTasksInput { PageIndex = 1, PageSize = 1 }, cancellationToken); first = result?.Items?.FirstOrDefault(); r = first == null || first.Status != Lebai.SDK.Dtos.TaskStatus.Running && first.Status != Lebai.SDK.Dtos.TaskStatus.Pause; } diff --git a/HBLConsole.MORKIC/Control_MORKIC.cs b/HBLConsole.MORKIC/Control_MORKIC.cs index 411acb8..df7ec67 100644 --- a/HBLConsole.MORKIC/Control_MORKIC.cs +++ b/HBLConsole.MORKIC/Control_MORKIC.cs @@ -272,12 +272,12 @@ namespace HBLConsole.MORKIC LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_取咖啡杯); Wait(); new TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 - + Thread.Sleep(500); MessageLog.GetInstance.Show("咖啡杯取杯完成"); LebaiHelper.GetInstance.SetValue(1); - p: + p: LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_咖啡杯检测); Wait(); LebaiHelper.GetInstance.SetValue(1); @@ -289,7 +289,7 @@ namespace HBLConsole.MORKIC Wait(); new TakeCupEvent() { Cup = IC_CUP.CUP_COFFEE }.Publish();//落碗控制 - + LebaiHelper.GetInstance.SetValue(1); goto p; @@ -537,16 +537,16 @@ namespace HBLConsole.MORKIC LebaiHelper.GetInstance.SetValue(0); SimpleFactory.GetInstance.OrderChanged(subOrderId, BPA.Message.Enum.ORDER_STATUS.COOKING); LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_取冰淇淋杯); - + Wait(); new TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 - + Thread.Sleep(500); MessageLog.GetInstance.Show("冰淇淋杯取杯完成"); LebaiHelper.GetInstance.SetValue(1); - p: + p: LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_冰淇淋杯检测); //Thread.Sleep(2000); //if (lebai.Value != 101) @@ -562,7 +562,7 @@ namespace HBLConsole.MORKIC //if (lebai.Value != 101) // LebaiHelper.GetInstance.Scene(LebaiHelper.SENCE_二次取冰淇淋杯); new TakeCupEvent() { Cup = IC_CUP.CUP_ICECREAM }.Publish();//落碗控制 - + Wait(); LebaiHelper.GetInstance.SetValue(1); @@ -584,7 +584,7 @@ namespace HBLConsole.MORKIC // LebaiHelper.GetInstance.Scene(scene); Wait(); new MakeIceCreamEvent() { SteeringEngine = res }.Publish(); //控制舵机 - + Thread.Sleep(500); LebaiHelper.GetInstance.SetValue(1); @@ -646,7 +646,7 @@ namespace HBLConsole.MORKIC Thread.Sleep(100); - }), "乐百机器人数据读取"); + }), "乐百机器人数据读取", true); } public void SimOrder(T simOrder) diff --git a/HBLConsole.MORKS/Control_MORKS.cs b/HBLConsole.MORKS/Control_MORKS.cs index 47cf014..0a22fae 100644 --- a/HBLConsole.MORKS/Control_MORKS.cs +++ b/HBLConsole.MORKS/Control_MORKS.cs @@ -122,11 +122,8 @@ namespace HBLConsole.MORKS mORKS.TurntableUpLimit = bools[13]; mORKS.FeedComplete = bools[14]; mORKS.TurntableMoveInPlace = bools[15]; - - })); - //Read(startAddress, ReadType.Coils, len); var errorStatus = ModbusTcpHelper.GetInstance.Read((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M235.0"), ReadType.Coils, 1); if (errorStatus != null && errorStatus is bool error) mORKS.Error = error; @@ -522,6 +519,7 @@ namespace HBLConsole.MORKS private void WriteRecipeBoms() { List recipeBoms = new List(); + if (Json.Data.recipeBoms == null) return; foreach (var item in Json.Data.recipeBoms.RecipeIds) { foreach (var rec in item.Recipes) diff --git a/HBLConsole.Service/MessageLog.cs b/HBLConsole.Service/MessageLog.cs index acb7c13..b5aa46f 100644 --- a/HBLConsole.Service/MessageLog.cs +++ b/HBLConsole.Service/MessageLog.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -17,7 +18,7 @@ namespace HBLConsole.Service /// /// 日志显示委托 /// - public Action InfoNotify { get; set; } + public Action InfoNotify { get; set; } /// /// 日志信息 @@ -28,11 +29,12 @@ namespace HBLConsole.Service /// 普通日志输出 /// /// - public void Show(string info) + public void Show(string info, Color color = default(Color)) { + if (color.A == 0 && color.R == 0 && color.G == 0 && color.B == 0) color = Color.Aqua; Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}:{info}"); LogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}:{info} \n\r {LogInfo}"; - if (InfoNotify != null) InfoNotify(info); + if (InfoNotify != null) InfoNotify(info, color); } #endregion diff --git a/HBLConsole/App.config b/HBLConsole/App.config index bcc9894..acb9fdf 100644 --- a/HBLConsole/App.config +++ b/HBLConsole/App.config @@ -10,8 +10,8 @@ - - + + diff --git a/HBLConsole/ViewModel/ViewModelBase.cs b/HBLConsole/ViewModel/ViewModelBase.cs index 7a465ea..2031ee8 100644 --- a/HBLConsole/ViewModel/ViewModelBase.cs +++ b/HBLConsole/ViewModel/ViewModelBase.cs @@ -19,6 +19,7 @@ using System.Threading; using HBLConsole.Business; using HBLConsole.GVL; using HBLConsole.Communication; +using System.Drawing; namespace HBLConsole.ViewModel { @@ -32,15 +33,16 @@ namespace HBLConsole.ViewModel public static void Init() { - MessageLog.GetInstance.InfoNotify = new Action((s) => - { - LogMessage = $"{DateTime.Now.ToString("HH:mm:ss")}:{s} \n\r {LogMessage}"; - //LogMessage = MessageLog.GetInstance.LogInfo; + MessageLog.GetInstance.InfoNotify = new Action((s, c) => + { + LogMessage = $"{DateTime.Now.ToString("HH:mm:ss")}:{s} \n\r {LogMessage}"; + //Messages.Add($"{DateTime.Now.ToString("HH:mm:ss")}:{s}"); }); MessageLog.GetInstance.ExInfoNotify = new Action((s) => { LogMessage = $"{DateTime.Now.ToString("HH:mm:ss")}:{s} \n\r {LogMessage}"; + //Messages.Add($"{DateTime.Now.ToString("HH:mm:ss")}:{s}"); IotReport.GetInstance.HttpAddLog(new BPA.Message.API请求.LogTable { ClientId = InternetInfo.ClientId.ToString(), @@ -99,6 +101,11 @@ namespace HBLConsole.ViewModel /// public static ObservableCollection WaitTakeMeal { get; set; } = new ObservableCollection(); + /// + /// 消息列表 + /// + public static ObservableCollection Messages { get; set; } = new ObservableCollection(); + /// /// 显示当前窗体名称 ///