diff --git a/BPASmartClient.CustomResource/Image/弹窗.png b/BPASmartClient.CustomResource/Image/弹窗.png index 7d4f8fdd..ce73a3c8 100644 Binary files a/BPASmartClient.CustomResource/Image/弹窗.png and b/BPASmartClient.CustomResource/Image/弹窗.png differ diff --git a/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml b/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml index 635e3b0e..43527aa4 100644 --- a/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml +++ b/BPASmartClient.CustomResource/RecDictionarys/RecToggleButton.xaml @@ -137,4 +137,83 @@ + + + + \ No newline at end of file diff --git a/BPASmartClient.Model/大炒/FryPotMessages.cs b/BPASmartClient.Model/大炒/FryPotMessages.cs new file mode 100644 index 00000000..9ab0da81 --- /dev/null +++ b/BPASmartClient.Model/大炒/FryPotMessages.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.大炒 +{ + public class FryPotMessages + { + public string GoodName { get; set; } + public string GoodKey { get; set; } + public List fryPotProcesses { get; set; } = new List(); + } + + public class FryPotProcess + { + /// + /// 步骤 + /// + public int FryTime { get; set; } + /// + /// 动作 + /// + public FryAction fryActions { get; set; } + /// + /// 加热时间 单位s + /// + public int FryDuration { get; set; } = 0; + /// + /// 加热挡位 1-5 + /// + public int FryGear { get; set; } = 0; + /// + /// 搅拌挡位 小炒1-10 大炒1-5 + /// + public int StirGear { get; set; } = 0; + /// + /// 翻转速度0到800 + /// + public int TurnSpeed { get; set; }= 0; + /// + /// 炒制位置1到4 + /// + public int FryPosition { get; set; } + /// + /// 辅料,调料,或者菜品集合 + /// + public List accessories { get; set; } = new List(); + + } + + public class Accessories + { + /// + /// 位置 + /// + public int Loc { get; set; } + /// + /// 重量 + /// + public int Qry { get; set; } + } + + public enum FryAction + { + 冷锅加热, + 热油, + 加调料, + 加辅料, + 炒制菜品, + + } + + public enum FryRepot + { + 开始, + 热锅, + 炒菜, + 出餐, + 完成, + } +} diff --git a/BPASmartClient.Model/大炒/LocalFryPotMessage.cs b/BPASmartClient.Model/大炒/LocalFryPotMessage.cs new file mode 100644 index 00000000..9f318553 --- /dev/null +++ b/BPASmartClient.Model/大炒/LocalFryPotMessage.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.大炒 +{ + public class LocalFryPotMessage + { + public ObservableCollection FryPotMessage { get; set; } = new ObservableCollection(); + } +} diff --git a/BPASmartClient.Model/大炒/RobotActionModel.cs b/BPASmartClient.Model/大炒/RobotActionModel.cs new file mode 100644 index 00000000..b614cd34 --- /dev/null +++ b/BPASmartClient.Model/大炒/RobotActionModel.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.大炒 +{ + public class RobotAction_Pot + { + public int Pot { get; set; } + public RobotActionModel robotActionModel { get; set; } + } + + public enum RobotActionModel + { + 无任务, + 取1号炒锅荤菜盆倒1号炒锅, + 取1号炒锅素菜盆1倒1号炒锅, + 取1号炒锅素菜盆2倒1号炒锅, + 取1号炒锅调料盆倒入1号炒锅, + 取1号炒锅辅料盆1倒入1号炒锅, + 取1号空盆出餐, + + 取2号炒锅荤菜盆1倒2号炒锅 = 20, + 取2号炒锅素菜盆1倒2号炒锅 = 21, + 取2号炒锅素菜盆2倒2号炒锅 =22, + 取2号炒锅调料盆倒入2号炒锅 =23, + 取2号炒锅辅料盆1倒入2号炒锅 =24, + 取2号空盆出餐 =25, + } +} diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index 76be2fdf..44c179f1 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -1,10 +1,13 @@ -using BPA.Message; +using BPA.Helper; +using BPA.Message; using BPA.Message.Enum; using BPASmartClient.Business; using BPASmartClient.Device; using BPASmartClient.EventBus; using BPASmartClient.Helper; using BPASmartClient.Model; +using BPASmartClient.Model.大炒; +using BPASmartClient.MorkBF.Model; using BPASmartClient.MorkBF.ViewModel; using System; using System.Collections.Generic; @@ -13,6 +16,9 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using static BPASmartClient.EventBus.EventBus; +using static BPASmartClient.Model.大炒.FryPotMessages; +using ActionManage = BPA.Helper.ActionManage; +using ThreadManage = BPA.Helper.ThreadManage; namespace BPASmartClient.MorkBF { @@ -24,7 +30,8 @@ namespace BPASmartClient.MorkBF public override void DoMain() { - + IsHealth = true; + BPASmartClient.Helper.Json.Read(); MonitorViewModel.DeviceId = DeviceId; CommandRegist();//调试 ServerInit(); @@ -44,8 +51,6 @@ namespace BPASmartClient.MorkBF OrderCount++; DeviceProcessLogShow($"接收到{OrderCount}次订单"); - - } }); @@ -60,7 +65,6 @@ namespace BPASmartClient.MorkBF if (@event is MaterialDeliveryEvent material) { orderMaterialDelivery = material.orderMaterialDelivery; - } }); @@ -132,11 +136,55 @@ namespace BPASmartClient.MorkBF public override void MainTask() { + if(morkBF.FirePan1_Order.Count>0&& morkBF.FirePot1_InitCompleted&&morkBF.FirePot2_IsAuto&&!morkBF.FirePan1_Busy) + { + ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程"); + } + + if(morkBF.RobotActinQueue.Count>0&&! morkBF.Robot_Origin)//机器人在原点为 + { + if( morkBF.RobotActinQueue.TryDequeue(out RobotAction_Pot robotAction)) + { + morkBF.Robot_IsBusy =true; + RobotProcess(robotAction); + } + } } private void FirePot1_Process() { + if(morkBF.FirePan1_Order.TryDequeue(out FryPotMessages result)) + { + morkBF.FirePan1_Busy = true; + foreach (var item in result.fryPotProcesses) + { + switch (item.fryActions) + { + case FryAction.冷锅加热: + FirePot_PotPerHeat(item, 1); + break; + + case FryAction.热油: + FirePot_HeatOil(item,1); + break; + + case FryAction.加调料: + FirePot_AddSeasoning(item, 1); + break; + case FryAction.加辅料: + + break; + case FryAction.炒制菜品: + FirePot_FryFood(item,1); + break; + + default: + break; + } + } + + } } private void FirePot2_Process() @@ -144,6 +192,192 @@ namespace BPASmartClient.MorkBF } + + #region 炒锅流程功能 + /// + /// 冷锅预热 + /// + private void FirePot_PotPerHeat(FryPotProcess item,int i) + { + if(i == 1)//炒锅1 + { + FirePot1_SetFireGear(item.FryGear); + FirePot1_StartFire(true); + + } + else if(i == 2)//炒锅2 + { + FirePot2_SetFireGear(item.FryGear); + FirePot2_StartFire(true); + + } + Thread.Sleep(item.FryDuration); + } + + /// + /// 热油 + /// + private void FirePot_HeatOil(FryPotProcess item, int i) + { + if (item.FryGear != 0) + { + FirePot1_SetFireGear(item.FryGear);//设定加热挡位 + FirePot1_StartFire(true);//开启加热 + } + if (item.StirGear != 0) + { + FirePot1_SetStirGear(item.StirGear);//设定搅拌挡位 + FirePot1_StartFire(true);//开启搅拌 + } + Thread.Sleep(item.FryDuration);//加热时间; + } + + /// + /// 加调料 + /// + private void FirePot_AddSeasoning(FryPotProcess item,int i) + { + if(i == 1) + { + + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot =1,robotActionModel = RobotActionModel.取1号炒锅调料盆倒入1号炒锅}); + Thread.Sleep(item.FryDuration); + + } + + else if(i == 2) + { + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅调料盆倒入2号炒锅 }); + Thread.Sleep(item.FryDuration); + } + + } + + /// + /// 加辅料 + /// + private void FirePot_AddAccessories(FryPotProcess item, int i) + { + if (i == 1) + { + + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = RobotActionModel.取1号炒锅辅料盆1倒入1号炒锅 }); + Thread.Sleep(item.FryDuration); + + } + + else if (i == 2) + { + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = RobotActionModel.取2号炒锅辅料盆1倒入2号炒锅 }); + Thread.Sleep(item.FryDuration); + } + + } + + /// + /// 炒制菜品 + /// + private void FirePot_FryFood(FryPotProcess item, int i) + { + if (i == 1) + { + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 1, robotActionModel = (RobotActionModel)item.accessories[0].Loc }); + while (!morkBF.FirePot1_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成 + { + Thread.Sleep(100); + } + Thread.Sleep(item.FryDuration); + + } + + else if (i == 2) + { + morkBF.RobotActinQueue.Enqueue(new RobotAction_Pot { Pot = 2, robotActionModel = (RobotActionModel)(item.accessories[0].Loc+19) });//炒制菜品位置 + while (!morkBF.FirePot2_CompleteSingle[item.accessories[0].Loc])//取菜信号是否完成 + { + Thread.Sleep(100); + } + Thread.Sleep(item.FryDuration); + } + } + #endregion + + /// + /// 机器人进程 + /// + /// + private void RobotProcess(RobotAction_Pot robotAction) + { + Robot_Write("GI0",(int)robotAction.robotActionModel); + while (morkBF.Robot_ActionCallback != (int)robotAction.robotActionModel)//机器人动作执行完动作反馈 + { + Thread.Sleep(100); + } + if(robotAction.Pot == 1)//炒锅1 + { + if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐) + { + Robot_Write("GM521", true);//炒锅去投料位置 + while(!morkBF.Robot_ArriveFirePot1)//机器人到位,请求1#炒锅倒菜 + { + Thread.Sleep(100); + } + FirePot_Write("M11.6", true);//炒锅去出餐倒料位置 + while (!morkBF.FirePot1_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈 + { + Thread.Sleep(1000); + } + Thread.Sleep(20 * 1000);//等待20s出餐 + + } + else + { + FirePot_Write("M11.7", true);//炒锅去投料位置 + while (!morkBF.FirePot1_PotOnIntoFoodPosition)//等待炒锅允许倒料 + { + Thread.Sleep(100); + } + Robot_Write("GM520", true);//机器人投料 + } + + } + else if (robotAction.Pot == 2) + { + if (robotAction.robotActionModel == RobotActionModel.取1号空盆出餐) + { + Robot_Write("GM531", true);//炒锅去投料位置 + while (!morkBF.Robot_ArriveFirePot2)//机器人到位,请求1#炒锅倒菜 + { + Thread.Sleep(100); + } + FirePot_Write("M16.6", true);//炒锅去出餐倒料位置 + while (!morkBF.FirePot2_PotOnOutFoodPosition)//炒锅在出餐倒料位置反馈 + { + Thread.Sleep(1000); + } + Thread.Sleep(20 * 1000);//等待20s出餐 + + } + else + { + FirePot_Write("M16.7", true); + while (!morkBF.FirePot2_PotOnIntoFoodPosition) + { + Thread.Sleep(100); + } + Robot_Write("GM530", true); + } + + } + + while(!morkBF.Robot_Origin) + { + Thread.Sleep(1000); + } + morkBF.Robot_IsBusy = false; + MessageLog.GetInstance.Show($"机器人完成[{robotAction.robotActionModel.ToString()}]任务"); + } + public override void ReadData() { GetStatus("M20.0",new Action((o)=> @@ -228,9 +462,10 @@ namespace BPASmartClient.MorkBF if (o == null) return; if (o is bool[] values && values.Length == 7) { - morkBF.Robot_FirePot1OutMeal = values[0]; - morkBF.Robot_FirePot1OutVegetables1 = values[1]; - morkBF.Robot_FirePot1OutVegetables2 = values[2]; + + morkBF.FirePot1_CompleteSingle[0] = values[0]; + morkBF.FirePot1_CompleteSingle[1] = values[1]; + morkBF.FirePot1_CompleteSingle[2] = values[2]; morkBF.Robot_FirePot1OutSeasoning = values[3]; morkBF.Robot_FirePot1OutAccessories = values[4]; morkBF.Robot_ArriveFirePot1 = values[5]; @@ -243,9 +478,9 @@ namespace BPASmartClient.MorkBF if (o == null) return; if (o is bool[] values && values.Length == 7) { - morkBF.Robot_FirePot2OutMeal = values[0]; - morkBF.Robot_FirePot2OutVegetables1 = values[1]; - morkBF.Robot_FirePot2OutVegetables2 = values[2]; + morkBF.FirePot2_CompleteSingle[0] = values[0]; + morkBF.FirePot2_CompleteSingle[1] = values[1]; + morkBF.FirePot2_CompleteSingle[2] = values[2]; morkBF.Robot_FirePot2OutSeasoning = values[3]; morkBF.Robot_FirePot2OutAccessories = values[4]; morkBF.Robot_ArriveFirePot2 = values[5]; @@ -319,7 +554,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW100", value); } - + Thread.Sleep(200); } /// /// 炒锅1加热启停 @@ -332,6 +567,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("M10.0", value); } + Thread.Sleep(200); } /// /// 炒锅1设置搅拌挡位 @@ -344,6 +580,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW102", value); } + Thread.Sleep(200); } /// /// 炒锅1搅拌启停 @@ -356,6 +593,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("M10.1", value); } + Thread.Sleep(200); } /// /// 设置炒锅1翻转速度 @@ -368,6 +606,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW104", value); } + Thread.Sleep(200); } #endregion @@ -383,7 +622,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW130", value); } - + Thread.Sleep(200); } /// /// 炒锅2加热启停 @@ -396,6 +635,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("M15.0", value); } + Thread.Sleep(200); } /// /// 炒锅2设置搅拌挡位 @@ -408,6 +648,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW132", value); } + Thread.Sleep(200); } /// /// 炒锅2搅拌启停 @@ -420,6 +661,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("M15.1", value); } + Thread.Sleep(200); } /// /// 设置炒锅2翻转速度 @@ -432,6 +674,7 @@ namespace BPASmartClient.MorkBF { FirePot_Write("VW134", value); } + Thread.Sleep(200); } #endregion @@ -476,6 +719,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M15.5", true); } } + Thread.Sleep(200); } /// /// 炒锅去位置1 @@ -495,6 +739,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.2", true); } } + Thread.Sleep(200); } /// /// 炒锅去位置2 @@ -514,6 +759,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.3", true); } } + Thread.Sleep(200); } /// /// 炒锅去位置3 @@ -533,6 +779,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.4", true); } } + Thread.Sleep(200); } /// /// 炒锅去位置4 @@ -552,6 +799,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.5", true); } } + Thread.Sleep(200); } /// /// 炒锅去出餐位置 @@ -571,6 +819,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.6", true); } } + Thread.Sleep(200); } /// /// 炒锅去投料位置 @@ -590,6 +839,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.7", true); } } + Thread.Sleep(200); } /// /// 出餐启动 @@ -610,6 +860,7 @@ namespace BPASmartClient.MorkBF } } + Thread.Sleep(200); } /// /// 清洗 @@ -622,13 +873,15 @@ namespace BPASmartClient.MorkBF { if (i == 1) { - FirePot_Write("M10.7", true); + if(morkBF.FirePot1_OnOrigin) FirePot_Write("M10.7", true); + } else if (i == 2) { - FirePot_Write("M15.7", true); + if (morkBF.FirePot2_OnOrigin) FirePot_Write("M15.7", true); } } + Thread.Sleep(200); } /// /// 抽水启动 @@ -648,6 +901,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.0", true); } } + Thread.Sleep(200); } /// /// 抽油启动 @@ -667,6 +921,7 @@ namespace BPASmartClient.MorkBF FirePot_Write("M16.1", true); } } + Thread.Sleep(200); } #endregion @@ -677,6 +932,7 @@ namespace BPASmartClient.MorkBF private void RobotStart() { Robot_Write("GM600",true); + Thread.Sleep(200); } /// /// 机器人停止 @@ -684,6 +940,7 @@ namespace BPASmartClient.MorkBF private void RobotStop() { Robot_Write("GM601", true); + Thread.Sleep(200); } /// /// 机器人复位 @@ -691,6 +948,7 @@ namespace BPASmartClient.MorkBF private void RobotReset() { Robot_Write("GM602", true); + Thread.Sleep(200); } /// /// 机器人程序重启 @@ -698,6 +956,7 @@ namespace BPASmartClient.MorkBF private void RobotProgramStart() { Robot_Write("GM603", true); + Thread.Sleep(200); } /// /// 1号炒锅允许机器人投料(炒锅在投料位给出) @@ -705,6 +964,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot1AllowInMaterail() { Robot_Write("GM520", true); + Thread.Sleep(200); } /// /// 1号炒锅出餐倒料到减速位 @@ -712,6 +972,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot1OutFoodInSlowDown() { Robot_Write("GM621", true); + Thread.Sleep(200); } /// /// 1号炒锅出餐倒料完成 @@ -719,6 +980,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot1OutFood() { Robot_Write("GM522", true); + Thread.Sleep(200); } /// /// 2号炒锅允许机器人投料(炒锅在投料位给出) @@ -726,6 +988,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot2AllowInMaterail() { Robot_Write("GM530", true); + Thread.Sleep(200); } /// /// 2号炒锅出餐倒料到减速位。开始倒菜 @@ -733,6 +996,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot2OutFoodInSlowDown() { Robot_Write("GM531", true); + Thread.Sleep(200); } /// /// 2号炒锅出餐倒料完成 @@ -740,6 +1004,7 @@ namespace BPASmartClient.MorkBF private void Robot_Pot2OutFood() { Robot_Write("GM532", true); + Thread.Sleep(200); } /// /// @@ -751,6 +1016,7 @@ namespace BPASmartClient.MorkBF { Robot_Write("GI0",value); } + Thread.Sleep(200); } #endregion diff --git a/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs b/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs new file mode 100644 index 00000000..b6c17e30 --- /dev/null +++ b/BPASmartClient.MorkBF/Convert/FryActionToVisibilityConverter.cs @@ -0,0 +1,127 @@ +using BPASmartClient.Model.大炒; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace BPASmartClient.MorkBF.Convert +{ + public class StirToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility visibility = Visibility.Visible; + if (value != null && value is FryAction fryAction) + { + switch (fryAction) + { + case FryAction.冷锅加热: + visibility = Visibility.Collapsed; + break; + case FryAction.热油: + visibility = Visibility.Visible; + break; + case FryAction.加调料: + visibility = Visibility.Collapsed; + break; + case FryAction.加辅料: + visibility = Visibility.Collapsed; + break; + case FryAction.炒制菜品: + visibility = Visibility.Visible; + break; + default: + break; + } + } + return visibility; + } + + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + public class FirePositionToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility visibility = Visibility.Visible; + if (value != null && value is FryAction fryAction) + { + switch (fryAction) + { + case FryAction.冷锅加热: + visibility = Visibility.Visible; + break; + case FryAction.热油: + visibility = Visibility.Visible; + break; + case FryAction.加调料: + visibility = Visibility.Collapsed; + break; + case FryAction.加辅料: + visibility = Visibility.Collapsed; + break; + case FryAction.炒制菜品: + visibility = Visibility.Visible; + break; + default: + break; + } + } + return visibility; + } + + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + public class AccessoriesToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility visibility = Visibility.Visible; + if (value != null && value is FryAction fryAction) + { + switch (fryAction) + { + case FryAction.冷锅加热: + visibility = Visibility.Collapsed; + break; + case FryAction.热油: + visibility = Visibility.Collapsed; + break; + case FryAction.加调料: + visibility = Visibility.Visible; + break; + case FryAction.加辅料: + visibility = Visibility.Visible; + break; + case FryAction.炒制菜品: + visibility = Visibility.Visible; + break; + default: + break; + } + } + return visibility; + } + + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} + diff --git a/BPASmartClient.MorkBF/GVL_MorkBF.cs b/BPASmartClient.MorkBF/GVL_MorkBF.cs index c802243c..f7a2bcc8 100644 --- a/BPASmartClient.MorkBF/GVL_MorkBF.cs +++ b/BPASmartClient.MorkBF/GVL_MorkBF.cs @@ -1,4 +1,5 @@ using BPASmartClient.Device; +using BPASmartClient.Model.大炒; using BPASmartClient.MorkBF.Model; using System; using System.Collections.Concurrent; @@ -14,11 +15,15 @@ namespace BPASmartClient.MorkBF /// /// 炒锅1订单队列 /// - public ConcurrentQueue FirePan1_Order { get; set; } = new ConcurrentQueue(); + public ConcurrentQueue FirePan1_Order { get; set; } = new ConcurrentQueue(); /// /// 炒锅2订单队列 /// - public ConcurrentQueue FirePan2_Order { get; set; } = new ConcurrentQueue(); + public ConcurrentQueue FirePan2_Order { get; set; } = new ConcurrentQueue(); + /// + /// 机器人队列 + /// + public ConcurrentQueue RobotActinQueue { get; set; } = new ConcurrentQueue(); /// /// 炒锅1忙碌 /// @@ -247,30 +252,39 @@ namespace BPASmartClient.MorkBF #endregion #region 机器人数据读取 + public bool Robot_IsBusy; + + + /// + /// 机器人在原点位 + /// + [VariableMonitor("机器人在原点位", "GM105", "4201")] + public bool Robot_Origin { get; set; } + /// /// 1号锅倒荤菜完成 /// - [VariableMonitor("1号锅倒荤菜完成", "GM500", "4596")] + [VariableMonitor("机器人#1号锅倒荤菜完成", "GM500", "4596")] public bool Robot_FirePot1OutMeal{ get; set; } /// /// 1号炒锅倒素菜1完成 /// - [VariableMonitor("1号炒锅倒素菜1完成", "GM501", "4597")] + [VariableMonitor("机器人#1号炒锅倒素菜1完成", "GM501", "4597")] public bool Robot_FirePot1OutVegetables1{ get; set; } /// /// 1号炒锅倒素菜2完成 /// - [VariableMonitor("1号炒锅倒素菜2完成", "GM502", "4598")] + [VariableMonitor("机器人#1号炒锅倒素菜2完成", "GM502", "4598")] public bool Robot_FirePot1OutVegetables2{ get; set; } /// /// 1号炒锅倒调料完成 /// - [VariableMonitor("1号炒锅倒调料完成", "GM503", "4599")] + [VariableMonitor("机器人#1号炒锅倒调料完成", "GM503", "4599")] public bool Robot_FirePot1OutSeasoning{ get; set; } /// /// 1号炒锅倒辅料完成 /// - [VariableMonitor("1号炒锅倒辅料完成", "GM504", "4600")] + [VariableMonitor("机器人#1号炒锅倒辅料完成", "GM504", "4600")] public bool Robot_FirePot1OutAccessories{ get; set; } /// /// 机器人到位,请求1#炒锅倒菜 @@ -280,7 +294,7 @@ namespace BPASmartClient.MorkBF /// /// 1号炒锅出餐完成 /// - [VariableMonitor("1号炒锅出餐完成", "GM506", "4602")] + [VariableMonitor("机器人#1号炒锅出餐完成", "GM506", "4602")] public bool Robot_FirePot1OutFoodComplete{ get; set; } @@ -290,12 +304,12 @@ namespace BPASmartClient.MorkBF /// /// 2号锅倒荤菜完成 /// - [VariableMonitor("2号锅倒荤菜完成", "GM510", "4606")] + [VariableMonitor("机器人#2号锅倒荤菜完成", "GM510", "4606")] public bool Robot_FirePot2OutMeal { get; set; } /// /// 2号炒锅倒素菜1完成 /// - [VariableMonitor("2号炒锅倒素菜1完成", "GM511", "4607")] + [VariableMonitor("机器人#2号炒锅倒素菜1完成", "GM511", "4607")] public bool Robot_FirePot2OutVegetables1{ get; set; } /// /// 2号炒锅倒素菜2完成 @@ -305,22 +319,22 @@ namespace BPASmartClient.MorkBF /// /// 2号炒锅倒调料完成 /// - [VariableMonitor("2号炒锅倒调料完成", "GM513", "4609")] + [VariableMonitor("机器人#2号炒锅倒调料完成", "GM513", "4609")] public bool Robot_FirePot2OutSeasoning{ get; set; } /// /// 2号炒锅倒辅料完成 /// - [VariableMonitor("2号炒锅倒辅料完成", "GM514", "4610")] + [VariableMonitor("机器人#2号炒锅倒辅料完成", "GM514", "4610")] public bool Robot_FirePot2OutAccessories{ get; set; } /// /// 机器人到位,请求1#炒锅倒菜 /// - [VariableMonitor("机器人到位,请求1#炒锅倒菜", "GM515", "4611")] + [VariableMonitor("机器人#机器人到位,请求1#炒锅倒菜", "GM515", "4611")] public bool Robot_ArriveFirePot2{ get; set; } /// /// 2号炒锅出餐完成 /// - [VariableMonitor("2号炒锅出餐完成", "GM516", "4612")] + [VariableMonitor("机器人#2号炒锅出餐完成", "GM516", "4612")] public bool Robot_FirePot2OutFoodComplete{ get; set; } /// /// 机器人动作反馈 @@ -330,7 +344,27 @@ namespace BPASmartClient.MorkBF #endregion + public Dictionary FirePot1_CompleteSingle { get; set; } + + public Dictionary FirePot2_CompleteSingle { get; set; } + + + public GVL_MorkBF() + { + FirePot1_CompleteSingle = new Dictionary + { + {1,Robot_FirePot1OutMeal }, + {2,Robot_FirePot1OutVegetables1 }, + {3,Robot_FirePot1OutVegetables2 }, + }; + FirePot2_CompleteSingle = new Dictionary + { + {1,Robot_FirePot2OutMeal }, + {2,Robot_FirePot2OutVegetables1 }, + {3,Robot_FirePot2OutVegetables2 }, + }; + } public DateTime FirePan1_Date; public DateTime FirePan2_Date; diff --git a/BPASmartClient.MorkBF/Model/BF_Food.cs b/BPASmartClient.MorkBF/Model/BF_Food.cs index 6891c445..d1d49a4e 100644 --- a/BPASmartClient.MorkBF/Model/BF_Food.cs +++ b/BPASmartClient.MorkBF/Model/BF_Food.cs @@ -17,6 +17,8 @@ namespace BPASmartClient.MorkBF.Model /// public string FoodID { get; set; } + public List PotActions { get; set; } = new List(); + } public class BF_PotAction @@ -40,7 +42,7 @@ namespace BPASmartClient.MorkBF.Model /// /// 动作 /// - public string Actions + public PotAction Actions { get; set; @@ -62,4 +64,32 @@ namespace BPASmartClient.MorkBF.Model set; } } + + + public enum PotAction + { + 加热开启, + 加热关闭, + 搅拌开启, + 搅拌关闭, + + 加调料, + 加菜品, + 加辅料, + 加热时间, + + 抽油启动, + 抽水启动, + 出餐启动, + + 炒锅回原点, + 炒制位置1, + 炒制位置2, + 炒制位置3, + 炒制位置4, + 炒锅去出餐倒料位置, + 炒锅去投料位置, + + + } } diff --git a/BPASmartClient.MorkBF/Model/Global.cs b/BPASmartClient.MorkBF/Model/Global.cs new file mode 100644 index 00000000..4c504caf --- /dev/null +++ b/BPASmartClient.MorkBF/Model/Global.cs @@ -0,0 +1,14 @@ +using BPASmartClient.Model.大炒; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkBF.Model +{ + public class Global + { + public static FryPotMessages GLoFryMessage { get; set; } = new FryPotMessages(); + } +} diff --git a/BPASmartClient.MorkBF/VIew/DebugView.xaml b/BPASmartClient.MorkBF/VIew/DebugView.xaml index 7928442d..2ac694c1 100644 --- a/BPASmartClient.MorkBF/VIew/DebugView.xaml +++ b/BPASmartClient.MorkBF/VIew/DebugView.xaml @@ -21,14 +21,40 @@ + + - - - - + private int count = 2; + // + private const int materialHigh = 40000; + + //炒锅1倒菜的xy坐标 + private const int materialPutPositionXFry1 = -30000; + private const int materialPutPositionYFry1 = -20000; + + //炒锅2倒菜的xy坐标 + private const int materialPutPositionXFry2 = -30000; + private const int materialPutPositionYFry2 = -20000; + //当前炒锅,默认为1号炒锅 private int fryIndex = 0; @@ -69,6 +82,11 @@ namespace BPASmartClient.MorkF /// private OrderLocInfo nowStirFryGood = null; + /// + /// 待取菜队列 + /// + private ConcurrentQueue materialOperationQuenes = new ConcurrentQueue(); + List resultorder = new List();//调试变量 /// @@ -91,6 +109,8 @@ namespace BPASmartClient.MorkF CommandRegist();//调试 ServerInit(); DeviceProcessLogShow("MORKF 设备初始化完成"); + ///初始化菜品库 + FoodLibInit(); } /// @@ -170,6 +190,47 @@ namespace BPASmartClient.MorkF } }), "SetArmPosition"); }), "SetArmPosition"); + ActionManage.GetInstance.Register(new Action((list) => + { + if (list is bool startOrStop) + { + ArmRunUp(startOrStop); + } + }), "ArmRunUp"); + ActionManage.GetInstance.Register(new Action((list) => + { + if (list is bool startOrStop) + { + ArmRunDown(startOrStop); + } + }), "ArmRunDown"); + ActionManage.GetInstance.Register(new Action((list) => + { + if (list is bool startOrStop) + { + ArmRunLeft(startOrStop); + } + }), "ArmRunLeft"); + ActionManage.GetInstance.Register(new Action((list) => + { + if (list is bool startOrStop) + { + ArmRunRight(startOrStop); + } + }), "ArmRunRight"); + ActionManage.GetInstance.Register(new Action((list) => + { + ThreadManage.GetInstance().Start(new Action(() => + { + if (list is List list_int) + { + if (list_int.Count == 2) + { + SetNowPosition(list_int[0], list_int[1]); + } + } + }), "SetNowPosition"); + }), "SetNowPosition"); #endregion //ActionManage.GetInstance.Register(PLCInite, "InitCommand"); #region 配料控制 @@ -622,33 +683,55 @@ namespace BPASmartClient.MorkF /// /// /// - private void MaterailLibrary_Write(string address, object value,int num) + private void MaterailLibrary_Write(string address, object value,int num = 2) { WriteControlExact(address, value, num); } /// /// 菜品库初始化 /// - public void FoodLibInit(int num = 2) + public bool FoodLibInit() { - MaterailLibrary_Write("M0.2", true, num); + MaterailLibrary_Write("M0.2", true); + + for (int i = 0; i < sleepCount && !ml_morkf.InitialComplete; i++) + { + Thread.Sleep(sleepTime); + if (i >= sleepCount - 1) + { + MessageLog.GetInstance.Show("菜品库初始化超时"); + return false; + } + } + + return true; } /// /// 电磁阀启停 /// /// 电磁阀启停:true:启动。false:停止。 - public void Electromagnetism(object o,int num = 2) + public void Electromagnetism(object o) { + if (!ml_morkf.InitialComplete) + { + return; + } + if (o == null) return; if (o is List bs && bs.Count == 1) { - MaterailLibrary_Write("M1.3", bs[0],num); + MaterailLibrary_Write("M1.3", bs[0]); } } - public bool GetDistance_1(int num = 2) + public bool GetDistance_1() { + if (!ml_morkf.InitialComplete) + { + return false; + } + MessageLog.GetInstance.Show("爪子去到1号位"); - MaterailLibrary_Write("M1.0", true, num); + MaterailLibrary_Write("M1.0", true); for (int i = 0; i < sleepCount && !ml_morkf.PawArrivePortOne; i++) { Thread.Sleep(sleepTime); @@ -658,13 +741,21 @@ namespace BPASmartClient.MorkF return false; } } + + Thread.Sleep(300); + MessageLog.GetInstance.Show("爪子去到1号位完成"); return true; } - public bool GetDistance_2(int num = 2) + public bool GetDistance_2() { + if (!ml_morkf.InitialComplete) + { + return false; + } + MessageLog.GetInstance.Show("爪子去到2号位"); - MaterailLibrary_Write("M1.1", true, num); + MaterailLibrary_Write("M1.1", true); for (int i = 0; i < sleepCount && !ml_morkf.PawArrivePortTwo; i++) { Thread.Sleep(sleepTime); @@ -674,13 +765,21 @@ namespace BPASmartClient.MorkF return false; } } + + Thread.Sleep(300); + MessageLog.GetInstance.Show("爪子去到2号位完成"); return true; } - public bool GetDistance_3(int num = 2) + public bool GetDistance_3() { + if (!ml_morkf.InitialComplete) + { + return false; + } + MessageLog.GetInstance.Show("爪子去到3号位"); - MaterailLibrary_Write("M1.2", true,num); + MaterailLibrary_Write("M1.2", true); for (int i = 0; i < sleepCount && !ml_morkf.PawArrivePortThree; i++) { Thread.Sleep(sleepTime); @@ -690,16 +789,19 @@ namespace BPASmartClient.MorkF return false; } } + + Thread.Sleep(300); + MessageLog.GetInstance.Show("爪子去到3号位完成"); return true; } - public void PawTurnFront(int num = 2) + public void PawTurnFront() { - MaterailLibrary_Write("", true, num); + MaterailLibrary_Write("", true); } - public void PawTurnBack(int num = 2) + public void PawTurnBack() { - MaterailLibrary_Write("", true, num); + MaterailLibrary_Write("", true); } /// @@ -707,20 +809,25 @@ namespace BPASmartClient.MorkF /// /// /// - public bool SetArmPosition(int x, int y, int num = 2) + public bool SetArmPosition(int x, int y) { + if(!ml_morkf.InitialComplete) + { + return false; + } + //取反 x -= 2 * x; y -= 2 * y; - MaterailLibrary_Write("VD836", x, num); + MaterailLibrary_Write("VD836", x); Thread.Sleep(100); - MaterailLibrary_Write("VD840", y, num); + MaterailLibrary_Write("VD840", y); Thread.Sleep(200); MessageLog.GetInstance.Show($"机械臂移动到[{x},{y}]"); //定位启动 - MaterailLibrary_Write("M0.0", true, num); + MaterailLibrary_Write("M0.0", true); for (int i = 0; i < sleepCount && !ml_morkf.ArriveComplete; i++) { @@ -739,15 +846,73 @@ namespace BPASmartClient.MorkF return true; } + /// + /// 设定机械臂的当前坐标 + /// + /// + /// + public void SetNowPosition(int x, int y) + { + //取反 + x -= 2 * x; + y -= 2 * y; + MessageLog.GetInstance.Show($"设置机械臂当前坐标为[{x},{y}]"); + MaterailLibrary_Write("VD828", x); + Thread.Sleep(200); + MaterailLibrary_Write("VD832", y); + Thread.Sleep(200); + } + + /// + /// 机械臂向上移动开关 + /// + /// true:开启,false:关闭 + public void ArmRunUp(bool startOrStop) + { + MaterailLibrary_Write("M5.3", startOrStop); + Thread.Sleep(200); + } + + /// + /// 机械臂向下移动开关 + /// + /// true:开启,false:关闭 + public void ArmRunDown(bool startOrStop) + { + MaterailLibrary_Write("M5.4", startOrStop); + Thread.Sleep(200); + } + + /// + /// 机械臂向左移动开关 + /// + /// true:开启,false:关闭 + public void ArmRunLeft(bool startOrStop) + { + MaterailLibrary_Write("M5.5", startOrStop); + Thread.Sleep(200); + } + + /// + /// 机械臂向右移动开关 + /// + /// true:开启,false:关闭 + public void ArmRunRight(bool startOrStop) + { + MaterailLibrary_Write("M5.6", startOrStop); + Thread.Sleep(200); + } + //菜品库锁 object lock_Materail = new object(); - private const int up = 10000; - /// - /// 获取菜品 + /// 取菜操作 /// - public void GetMaterail(int x,int y) + /// 取菜x轴坐标 + /// 取菜y轴坐标 + /// + public void GetMaterail(int x,int y,int fryNum = 0) { //设置到抓菜处 if(!SetArmPosition(x, y)) @@ -755,39 +920,72 @@ namespace BPASmartClient.MorkF return; } - //Thread.Sleep(2000); + //获取传感器的距离 + int laserHigh = ml_morkf.LaserDistance; - //关闭电磁阀 - Electromagnetism(new List { true }); - Thread.Sleep(500); + //设置到传感器感应的距离处 + if(!SetArmPosition(x+ laserHigh, y )) + { + return; + } + + ////关闭电磁阀 + //Electromagnetism(new List { true }); + //Thread.Sleep(500); //爪子去1号位抓菜 if (!GetDistance_1()) { return; } - Thread.Sleep(500); - //移动前开启电磁阀 - Electromagnetism(new List { false }); - Thread.Sleep(500); + //设置到该层菜品库最高处 + if (!SetArmPosition(x + materialHigh, y)) + { + return; + } + + ////移动前开启电磁阀 + //Electromagnetism(new List { false }); + //Thread.Sleep(500); - //设置到出菜处,都在x轴-40000处出菜 - if (!SetArmPosition(-40000, y)) + //爪子去2号位放菜 + if (!GetDistance_2()) { return; } - Thread.Sleep(500); + //根据炒锅不同设置不同的出菜处 + if (fryNum == 0) + { + //设置到炒锅1出菜处 + if (!SetArmPosition(materialPutPositionXFry1, materialPutPositionYFry1)) + { + return; + } + } + else + { + //设置到炒锅2出菜处 + if (!SetArmPosition(materialPutPositionXFry1, materialPutPositionYFry1)) + { + return; + } + } + //爪子去3号位放菜 if (!GetDistance_3()) { return; } - Thread.Sleep(500); + ////关闭电磁阀 //Electromagnetism(new List { false }); //Thread.Sleep(300); + if(morkFs.ContainsKey(fryNum)) + { + morkFs[fryNum].GetMaterialComplete = true; + } } /// @@ -836,23 +1034,9 @@ namespace BPASmartClient.MorkF { ml_morkf.MaterailIsWorking = true; } - //菜品库去指定位置 - if (!SetArmPosition(x1, y)) - { - MessageLog.GetInstance.Show("菜品库[机械臂操作失败]"); - return; - } //取菜操作 GetMaterail(x2,y); - - //机械臂去取菜放位 - if (!SetArmPosition(-30000, -20000)) - { - MessageLog.GetInstance.Show("菜品库[机械臂操作失败]"); - return; - } - //机械臂回原点 if (!SetArmPosition(0, 0)) { @@ -876,7 +1060,6 @@ namespace BPASmartClient.MorkF } #endregion - #region 炒锅PLC基本操作方法 /// /// 炒锅写寄存器方法,num为炒锅对应编号,从0开始 @@ -1036,13 +1219,39 @@ namespace BPASmartClient.MorkF { return; } + int i = 0; + //判断是否完成取菜 + for (i = 0; i < sleepCount*2 && !morkFs[num].GetMaterialComplete; i++) + { + if(i == 3) + { + //停止搅拌 + StopStir(num); + //火力设置为2档 + SetFire(new List { 2 }, num); + } + Thread.Sleep(sleepTime); + if (i >= sleepCount * 2 - 1) + { + MessageLog.GetInstance.Show($"炒锅{num}倒菜超时:未能等到取菜完成"); + return; + } + } + + if (i > 3) + { + //开启搅拌 + StartStir(num); + //火力设置回原本火力 + SetFire(new List { morkFs[num].Fire }, num); + } FirePot_Write("LB3", true, num); MessageLog.GetInstance.Show("倒菜启动"); - Thread.Sleep(400); + Thread.Sleep(200); - for (int i = 0; i < sleepCount && !morkFs[num].FryPot1_MaterialIntoPot; i++) + for (i = 0; i < sleepCount && !morkFs[num].FryPot1_MaterialIntoPot; i++) { Thread.Sleep(sleepTime); if (i >= sleepCount - 1) @@ -1178,7 +1387,6 @@ namespace BPASmartClient.MorkF #endregion - bool isInitialArrive = false; bool isInitialPaw = false; @@ -1439,7 +1647,7 @@ namespace BPASmartClient.MorkF //遍历炒锅,找到合适、空闲的炒锅 for(int i = 0;i + //设置当前炒制菜品 + nowStirFryGood = res; + //炒锅工作状态置为正在工作中 + morkFs[i].FryWorking = true; + //空闲炒锅入队列 + morkFs[i].StirFryGoodsQuenes.Enqueue(res); + //炒锅取菜状态置为未取到 + morkFs[i].GetMaterialComplete = false; + MessageLog.GetInstance.Show($"炒锅{i}开始炒制菜品{res.GoodName}"); + + //开启线程进行炒制 + ThreadManage.GetInstance().Start(new Action(() => + { + try { - try + int getMaterailNum = 0; + foreach (var potActions in res.StirPotActions) { - int getMaterailNum = 0; - foreach (var potActions in res.StirPotActions) + if (ThreadManage.GetInstance().IsCanncel(String.Format(striConst, i.ToString(), nowStirFryGood.GoodName))) { - if (ThreadManage.GetInstance().IsCanncel(String.Format(striConst, i.ToString(), nowStirFryGood.GoodName))) - { - return; - } - - switch (potActions.Actions) - { - case nameof(StirFryPotActionEnum.加热开启): - StartFire(i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位1): - SetFire(new List { 1 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位2): - SetFire(new List { 2 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位3): - SetFire(new List { 3 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位4): - SetFire(new List { 4 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位5): - SetFire(new List { 5 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位6): - SetFire(new List { 6 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位7): - SetFire(new List { 7 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位8): - SetFire(new List { 8 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位9): - SetFire(new List { 9 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置加热挡位10): - SetFire(new List { 10 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.停止加热): - StopFire(i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.加调料): - OutSeasonings(potActions.SeasoningLists, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.取原料): - GetMaterailTest(getMaterailNum); - getMaterailNum++; - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.开启搅拌): - StartStir(i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置搅拌挡位1): - SetStir(new List { 1 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置搅拌挡位2): - SetStir(new List { 2 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.设置搅拌挡位3): - SetStir(new List { 3 }, i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.关闭搅拌): - StopStir(i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.出餐启动): - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.道菜启动): - OutFood(i); - break; - case nameof(StirFryPotActionEnum.炒制菜品): - Thread.Sleep(potActions.During * 1000); - break; - case nameof(StirFryPotActionEnum.搅拌臂原点位): - StirArmGoOrigin(i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.搅拌臂炒制位): - StirArmGoWork(i); - MessageLog.GetInstance.Show(potActions.Actions); - break; - case nameof(StirFryPotActionEnum.洗锅): - MessageLog.GetInstance.Show(potActions.Actions); - break; - default: - break; - - } + return; } + switch (potActions.Actions) + { + case nameof(StirFryPotActionEnum.加热开启): + StartFire(i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位1): + morkFs[i].Fire = 1; + SetFire(new List { 1 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位2): + morkFs[i].Fire = 2; + SetFire(new List { 2 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位3): + morkFs[i].Fire = 3; + SetFire(new List { 3 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位4): + morkFs[i].Fire = 4; + SetFire(new List { 4 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位5): + morkFs[i].Fire = 5; + SetFire(new List { 5 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位6): + morkFs[i].Fire = 6; + SetFire(new List { 6 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位7): + morkFs[i].Fire = 7; + SetFire(new List { 7 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位8): + morkFs[i].Fire = 8; + SetFire(new List { 8 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位9): + morkFs[i].Fire = 9; + SetFire(new List { 9 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置加热挡位10): + morkFs[i].Fire = 10; + SetFire(new List { 10 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.停止加热): + StopFire(i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.加调料): + OutSeasonings(potActions.SeasoningLists, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.取原料): + //炒锅取菜状态置为未取到 + morkFs[i].GetMaterialComplete = false; + materialOperationQuenes.Enqueue(new MaterialOperation() { fryNum = i, x = 0, y = 0 }); + getMaterailNum++; + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.开启搅拌): + StartStir(i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置搅拌挡位1): + SetStir(new List { 1 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置搅拌挡位2): + SetStir(new List { 2 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.设置搅拌挡位3): + SetStir(new List { 3 }, i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.关闭搅拌): + StopStir(i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.出餐启动): + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.道菜启动): + OutFood(i); + break; + case nameof(StirFryPotActionEnum.炒制菜品): + Thread.Sleep(potActions.During * 1000); + break; + case nameof(StirFryPotActionEnum.搅拌臂原点位): + StirArmGoOrigin(i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.搅拌臂炒制位): + StirArmGoWork(i); + MessageLog.GetInstance.Show(potActions.Actions); + break; + case nameof(StirFryPotActionEnum.洗锅): + MessageLog.GetInstance.Show(potActions.Actions); + break; + default: + break; - Plc1Reset(i);//复位 - Thread.Sleep(3000); - //回原点位 - StirArmGoOrigin(i); + } + } - //while (!morkFs[i].ArmOnOrigin) - //{ - // Thread.Sleep(100); - //} - //出餐 - //OutMeal(i); - MessageLog.GetInstance.Show($"菜品{res.GoodName}完成"); + Plc1Reset(i);//复位 + Thread.Sleep(3000); + //回原点位 + StirArmGoOrigin(i); - } - catch (Exception ex) - { - ThreadManage.GetInstance().StopTask($"炒锅{i}{res.GoodName}炒制线程"); - MessageLog.GetInstance.Show($"炒锅{i}炒制菜品{res.GoodName}出错,错误信息:" + ex.Message); - } - finally - { - nowStirFryGood = null; - //炒完后出队列 - morkFs[i].StirFryGoodsQuenes.TryDequeue(out var orderQueue); - morkFs[i].FryWorking = false; - } - }), String.Format(striConst, i.ToString(), nowStirFryGood.GoodName)/*$"炒锅{i}炒制{res.GoodName}线程"*/); + //while (!morkFs[i].ArmOnOrigin) + //{ + // Thread.Sleep(100); + //} + //出餐 + //OutMeal(i); + MessageLog.GetInstance.Show($"菜品{res.GoodName}完成"); + + + } + catch (Exception ex) + { + ThreadManage.GetInstance().StopTask($"炒锅{i}{res.GoodName}炒制线程"); + MessageLog.GetInstance.Show($"炒锅{i}炒制菜品{res.GoodName}出错,错误信息:" + ex.Message); + } + finally + { + nowStirFryGood = null; + //炒完后出队列 + morkFs[i].StirFryGoodsQuenes.TryDequeue(out var orderQueue); + morkFs[i].FryWorking = false; + } + }), String.Format(striConst, i.ToString(), nowStirFryGood.GoodName)/*$"炒锅{i}炒制{res.GoodName}线程"*/); } } break; @@ -1610,6 +1832,30 @@ namespace BPASmartClient.MorkF } } + /// + /// 菜品库主流程 + /// + private void MainProcessMaterial() + { + if(materialOperationQuenes.Count > 0) + { + //判断是否初始化与是否在工作中 + if (ml_morkf.InitialComplete && !ml_morkf.MaterailIsWorking) + { + //待菜品库操作列出队列 + if (materialOperationQuenes.TryDequeue(out var res)) + { + ml_morkf.MaterailIsWorking = true; + MessageLog.GetInstance.Show("开始操作菜品库"); + //ThreadManage.GetInstance().Start(new Action(()=>{ + // GetMaterail(res.x, res.y, res.fryNum); + //}),"菜品库操作"); + GetMaterailTest(res.fryNum); + } + } + } + } + /// /// 信号处理 /// diff --git a/BPASmartClient.MorkF/GVL_MorkF.cs b/BPASmartClient.MorkF/GVL_MorkF.cs index 47999617..0f08aa54 100644 --- a/BPASmartClient.MorkF/GVL_MorkF.cs +++ b/BPASmartClient.MorkF/GVL_MorkF.cs @@ -18,7 +18,15 @@ namespace BPASmartClient.MorkF public bool IsAuto = true; - #region 炒锅1 + #region 炒锅 + /// + /// 炒锅上一次搅拌档位 + /// + public int Stir { set; get; } + /// + /// 炒锅上一次火力 + /// + public int Fire { get; set; } /// /// 炒锅是否在工作状态中 /// @@ -73,6 +81,11 @@ namespace BPASmartClient.MorkF /// public bool PotOnOrigin { get; set; } + /// + /// 获取菜品是否完成 + /// + public bool GetMaterialComplete { get; set; } + #endregion #region 调料通道 diff --git a/BPASmartClient.MorkF/MaterialOperation.cs b/BPASmartClient.MorkF/MaterialOperation.cs new file mode 100644 index 00000000..83b1a6d9 --- /dev/null +++ b/BPASmartClient.MorkF/MaterialOperation.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkF +{ + /// + /// 菜品库操作类 + /// + internal class MaterialOperation + { + /// + /// x轴坐标 + /// + public int x; + /// + /// y轴坐标 + /// + public int y; + /// + /// 炒锅编号 + /// + public int fryNum; + } +} diff --git a/BPASmartClient.MorkF/View/DebugView.xaml b/BPASmartClient.MorkF/View/DebugView.xaml index 63e9fecd..63ad05c5 100644 --- a/BPASmartClient.MorkF/View/DebugView.xaml +++ b/BPASmartClient.MorkF/View/DebugView.xaml @@ -22,7 +22,7 @@ - + @@ -65,6 +65,8 @@ + + @@ -94,13 +96,29 @@ + diff --git a/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs b/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs index 7f44ff3b..091de4ac 100644 --- a/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs +++ b/BPASmartClient.MorkF/ViewModel/DebugViewModel.cs @@ -50,6 +50,11 @@ namespace BPASmartClient.MorkF.ViewModel public int SettingY { get { return _settingY; } set { _settingY = value; OnPropertyChanged(); } } private int _settingY = 0; + public int SettingNowX { get { return _settingNowX; } set { _settingNowX = value; OnPropertyChanged(); } } + private int _settingNowX = 0; + public int SettingNowY { get { return _settingNowY; } set { _settingNowY = value; OnPropertyChanged(); } } + private int _settingNowY = 0; + public int MoveSpeed { get { return _moveSpeed; } set { _moveSpeed = value; OnPropertyChanged(); } } private int _moveSpeed; public string SensingDistance_1 { get { return _sensingDistance_1; } set { _sensingDistance_1 = value; OnPropertyChanged(); } } @@ -65,7 +70,21 @@ namespace BPASmartClient.MorkF.ViewModel public bool PawPositon3 { get { return _pawPositon3; } set { _pawPositon3 = value; OnPropertyChanged(); } } private bool _pawPositon3; + public bool ArmRunUp { get { return _armRunUp; } set { _armRunUp = value; OnPropertyChanged(); } } + private bool _armRunUp; + public bool ArmRunDown { get { return _armRunDown; } set { _armRunDown = value; OnPropertyChanged(); } } + private bool _armRunDown; + public bool ArmRunLeft { get { return _armRunLeft; } set { _armRunLeft = value; OnPropertyChanged(); } } + private bool _armRunLeft; + public bool ArmRunRight { get { return _armRunRight; } set { _armRunRight = value; OnPropertyChanged(); } } + private bool _armRunRight; + public bool ArmRunEnable { get { return _ArmRunEnable; } set { _ArmRunEnable = value; OnPropertyChanged(); } } + private bool _ArmRunEnable = true; + + public string ArmButtonName { get { return _ArmButtonName; } set { _ArmButtonName = value; OnPropertyChanged(); } } + private string _ArmButtonName = "启动"; + public RelayCommand SetNowPosition { get; set; }//设置机械臂当前坐标 public RelayCommand FoodLibInit { get; set; }//初始化 public RelayCommand StartElectromagnetism { get; set; }//电磁阀启动 public RelayCommand StopElectromagnetism { get; set; } @@ -76,9 +95,10 @@ namespace BPASmartClient.MorkF.ViewModel public RelayCommand PawTurnFront { get; set; }//夹爪正转 public RelayCommand PawTurnBack { get; set; }//夹爪反转 public RelayCommand SetArmPosition { get; set; }//机器臂位置设定 + public RelayCommand ArmRun { get; set; }//机械臂运动 #endregion - + #region 配料仓控制 public List PassageWays { get; set; } = new List() @@ -195,6 +215,39 @@ namespace BPASmartClient.MorkF.ViewModel PawTurnFront = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转 PawTurnBack = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转 SetArmPosition = new RelayCommand(() => { ActionManage.GetInstance.Send("SetArmPosition", new List { SettingX, SettingY }); });//设定机械臂位置 + SetNowPosition = new RelayCommand(() => { ActionManage.GetInstance.Send("SetNowPosition", new List { SettingX, SettingY }); });//设定机械臂当前位置 + ArmRun = new RelayCommand(() => { + //判断是否都未点击 + if(!ArmRunDown&&!ArmRunUp&&!ArmRunLeft&&!ArmRunRight) + { + return; + } + ArmRunEnable = !ArmRunEnable; + if(ArmRunEnable) + { + ArmButtonName = "启动"; + } + else + { + ArmButtonName = "停止"; + } + if(ArmRunUp) + { + ActionManage.GetInstance.Send("ArmRunUp", !ArmRunEnable); + } + else if(ArmRunDown) + { + ActionManage.GetInstance.Send("ArmRunDown", !ArmRunEnable); + } + else if (ArmRunLeft) + { + ActionManage.GetInstance.Send("ArmRunLeft", !ArmRunEnable); + } + else if(ArmRunRight) + { + ActionManage.GetInstance.Send("ArmRunRight", !ArmRunEnable); + } + });//设定机械臂位置 #endregion #region 配料仓控制 diff --git a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj index f94d003f..12a32132 100644 --- a/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj +++ b/BPASmartClient.MorkS/BPASmartClient.MorkS.csproj @@ -9,7 +9,7 @@ - + diff --git a/BPASmartClient.MorkS/Control_Morks.cs b/BPASmartClient.MorkS/Control_Morks.cs index 80cf1f37..868c12b2 100644 --- a/BPASmartClient.MorkS/Control_Morks.cs +++ b/BPASmartClient.MorkS/Control_Morks.cs @@ -136,7 +136,43 @@ namespace BPASmartClient.MorkS goodName = res.MorkOrder.GoodsName; SortNum = res.MorkOrder.SortNum.ToString(); } + EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); + + var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum); + if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count) + { + if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK) + { + DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index); + DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StopTime = DateTime.Now.ToString("HH:mm:ss") + }); + } + else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE) + { + var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum); + if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp); + } + else + { + DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS; + } + } + else + { + DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StartTime = DateTime.Now.ToString("HH:mm:ss") + }); + } } private void GetStatus(string key, Action action) @@ -152,6 +188,16 @@ namespace BPASmartClient.MorkS public override void ReadData() { + DataServer.GetInstance.morkS.Alarm.Clear(); + alarms.ForEach(item => + { + DataServer.GetInstance.morkS.Alarm.Add(new AlarmModel() + { + AlarmTime = $"{item.Date} {item.Time}", + AlarmMs = item.Info + }); + }); + GetStatus("M230.0", new Action((obj) => { if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 24) @@ -213,6 +259,11 @@ namespace BPASmartClient.MorkS mORKS.TurntableUpLimit = bools[13]; mORKS.FeedComplete = bools[14]; mORKS.TurntableMoveInPlace = bools[15]; + DataServer.GetInstance.morkS.MorkS_Temp = mORKS.TemperatureReached; + DataServer.GetInstance.morkS.Morks_SiloMeasUp = mORKS.TurntableUpLimit; + DataServer.GetInstance.morkS.Morks_SiloMeasDown = mORKS.TurntableLowerLimit; + DataServer.GetInstance.morkS.MorkS_NoBowMeas1 = mORKS.MissingBowl; + DataServer.GetInstance.morkS.MorkS_NoBowMeas2 = mORKS.MissingBowlSignal2; } })); @@ -245,6 +296,7 @@ namespace BPASmartClient.MorkS for (int i = 0; i < 6; i++) { mORKS.CookNoodlesComplete[i] = bools[i]; + DataServer.GetInstance.morkS.Morks_NoodleUpOrDown[i] = bools[i]; } } @@ -254,6 +306,7 @@ namespace BPASmartClient.MorkS { if (obj is ushort[] UshortValue && UshortValue.Length > 0 && UshortValue.Length <= 1) mORKS.TurntableFeedbackloc = UshortValue[0]; + DataServer.GetInstance.morkS.MorkS_BinLocation = mORKS.TurntableFeedbackloc; })); } diff --git a/BPASmartClient.MorkS/DataServer.cs b/BPASmartClient.MorkS/DataServer.cs index ff948122..6197e9b2 100644 --- a/BPASmartClient.MorkS/DataServer.cs +++ b/BPASmartClient.MorkS/DataServer.cs @@ -20,23 +20,25 @@ namespace BPASmartClient.MorkS public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS(); + MQTTProxy mQTTProxy = new MQTTProxy(); public void Init() { - MQTTProxy mQTTProxy = new MQTTProxy(); mQTTProxy.Connected = new Action(() => { mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); ThreadManage.GetInstance().StartLong(new Action(() => { morkS.MorkS_OrderCount = Json.Data.Count; - mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), morkS.ToJSON()); + SendScreenDataModel sendScreenDataModel = new SendScreenDataModel(); + sendScreenDataModel.Name = ScreenDeviceType.煮面机; + sendScreenDataModel.Value = morkS.ToJSON(); + mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), sendScreenDataModel.ToJSON()); Thread.Sleep(100); }), "海科食堂大屏监听"); }); mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); } - //订单信息(正在制作,等待制作,制作完成) //煮面炉上下状态(6个煮面炉上或下) //温度状态(煮面炉温度是否到达) diff --git a/BPASmartClient.S7Net/EntityClassResolution.cs b/BPASmartClient.S7Net/EntityClassResolution.cs index 5e720711..b9ddd591 100644 --- a/BPASmartClient.S7Net/EntityClassResolution.cs +++ b/BPASmartClient.S7Net/EntityClassResolution.cs @@ -55,9 +55,9 @@ namespace BPASmartClient.S7Net numBytes += len; break; default: - numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true); if (type.IsClass) IncrementToEven(ref numBytes); else if (!type.IsPrimitive && !type.IsEnum && type.IsValueType) IncrementToEven(ref numBytes); + numBytes = GetClassSize(Activator.CreateInstance(type), numBytes, isInnerProperty: true); break; } @@ -221,15 +221,13 @@ namespace BPASmartClient.S7Net break; default: { - object obj2 = Activator.CreateInstance(propertyType); - numBytes = FromBytes(obj2, bytes, numBytes); - numBytes = Math.Ceiling(numBytes); if (numBytes / 2.0 - Math.Floor(numBytes / 2.0) > 0.0) { numBytes += 1.0; } - + object obj2 = Activator.CreateInstance(propertyType); + numBytes = FromBytes(obj2, bytes, numBytes); obj = obj2; break; } diff --git a/BPASmartClient.S7Net/SiemensHelper.cs b/BPASmartClient.S7Net/SiemensHelper.cs index e79ad7fb..bf4b7dc9 100644 --- a/BPASmartClient.S7Net/SiemensHelper.cs +++ b/BPASmartClient.S7Net/SiemensHelper.cs @@ -2,7 +2,6 @@ using System.Net; using System.Text; using BPASmartClient.S7Net; -using System.Text; namespace BPASmartClient.S7Net { @@ -107,11 +106,11 @@ namespace BPASmartClient.S7Net } } - public void WriteString(int db,string txt, int startAddress = 0) + public void WriteString(int db, string txt, int startAddress = 0) { var temp = Encoding.ASCII.GetBytes(txt); var bytes = S7.Net.Types.S7String.ToByteArray(txt, temp.Length); - myPlc.WriteBytes(DataType.DataBlock,db, startAddress, bytes); + myPlc.WriteBytes(DataType.DataBlock, db, startAddress, bytes); } public TResult ReadClass(int db, int startByteAdr = 0) where TResult : class, new() diff --git a/BPASmartClient.ViewModel/FoodMenuViewModel.cs b/BPASmartClient.ViewModel/FoodMenuViewModel.cs index 0d7733f8..4de85018 100644 --- a/BPASmartClient.ViewModel/FoodMenuViewModel.cs +++ b/BPASmartClient.ViewModel/FoodMenuViewModel.cs @@ -19,8 +19,7 @@ namespace BPASmartClient.ViewModel public FoodMenuViewModel() { - FoodMenus.Add(new FoodMenuModel { GoodKey = "1111", GoodName = "小炒肉" }); - FoodMenus.Add(new FoodMenuModel { GoodKey = "222", GoodName = "大炒肉大炒肉大炒肉" }); + StartOrder = new RelayCommand((o) => { ActionManage.GetInstance.Send("开始下单", o); diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index 8d1787b0..93cd452e 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -197,12 +197,6 @@ namespace BPASmartClient.DosingSystem DeviceLists[ip].modbusTcp.IsReconnect = false; App.Current.Dispatcher.Invoke(new Action(() => { - //DeviceListViewModel.devices.Add(new Devices() - //{ - // DeviceName = DeviceName, - // IpAddress = ip - //});//加入连接的(有名称的)设备列表 - devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); if (TopDeviceCurrentStatuses.Count <= 7) @@ -244,20 +238,16 @@ namespace BPASmartClient.DosingSystem DS.modbusTcp.ConnectFail = new Action(() => { if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); - //MessageLog.GetInstance.ShowAlarmLog($"设备{ip}连接失败"); }); DS.modbusTcp.Disconnect = new Action(() => { if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip); - //var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip); var res = devices.FirstOrDefault(P => P.IpAddress == ip); - //if (res != null && DeviceListViewModel.devices.Contains(res)) if (res != null && devices.Contains(res)) { App.Current.Dispatcher.Invoke(new Action(() => { - //DeviceListViewModel.devices.Remove(res); devices.Remove(res); var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName); if (item != null) Global.DeviceRawMaterials.Remove(item); @@ -307,7 +297,6 @@ namespace BPASmartClient.DosingSystem modbusTcp.ShowEx = new Action((s) => { MessageNotify.GetInstance.ShowRunLog(s); }); this.DeviceName = DeviceName; AlarmHelper.Init(); - if (modbusTcp.Connected) { ThreadManage.GetInstance().StartLong(new Action(() => @@ -353,6 +342,7 @@ namespace BPASmartClient.DosingSystem { modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量 modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 + MessageNotify.GetInstance.ShowRunLog($"{DeviceName},设置重量:{Value}"); //配料设备参数写入 var res = Json.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); if (res != null) diff --git a/DosingSystem/View/CommParSetView.xaml b/DosingSystem/View/CommParSetView.xaml index e12528e4..7758d9d3 100644 --- a/DosingSystem/View/CommParSetView.xaml +++ b/DosingSystem/View/CommParSetView.xaml @@ -125,7 +125,10 @@ Text="{Binding CommBaseParModel.BlockCylinderCount, UpdateSourceTrigger=PropertyChanged}" /> - + @@ -146,7 +149,10 @@ Text="{Binding CommBaseParModel.PalletCylinderCount, UpdateSourceTrigger=PropertyChanged}" /> - + @@ -171,7 +177,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + Height="100" + Margin="0,0,0,15" + Background="Transparent"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DosingSystem/View/RecipeControlView.xaml b/DosingSystem/View/RecipeControlView.xaml index 752864c0..865f7c9f 100644 --- a/DosingSystem/View/RecipeControlView.xaml +++ b/DosingSystem/View/RecipeControlView.xaml @@ -880,7 +880,7 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="16" - Foreground="{Binding RecipStatus,Converter={StaticResource RecipeStatusConvert}}" + Foreground="{Binding RecipStatus, Converter={StaticResource RecipeStatusConvert}}" Text="{Binding RecipStatus}" /> + + + + - - + - + Stretch="Fill" />--> @@ -939,7 +942,9 @@ @@ -1011,6 +1016,27 @@ +