From 104afbded21ae0acee610a1d817b058a2f6ed498 Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Sat, 15 Apr 2023 19:15:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.JXJFoodBigStation/App.config | 2 +- .../Model/HK_PLC/HKDeviceStatus.cs | 5 +- .../Model/ProcessControl.cs | 35 ++++++---- .../MilkTeaCubeMachine.cs | 68 ++++++++++--------- .../Control_MorkT_BarCounter.cs | 2 + BPASmartClient.MorkT_BarCounter/GVL_MorkT.cs | 2 +- BPASmartClient.MorkT_BarCounter/SavePar.cs | 14 ++++ .../SaveParModel.cs | 15 ++++ .../View/DebugView.xaml | 8 +-- .../ViewModel/DebugViewModel.cs | 14 ++-- BPASmartClient/App.config | 8 +-- 11 files changed, 107 insertions(+), 66 deletions(-) create mode 100644 BPASmartClient.MorkT_BarCounter/SavePar.cs create mode 100644 BPASmartClient.MorkT_BarCounter/SaveParModel.cs diff --git a/BPASmartClient.JXJFoodBigStation/App.config b/BPASmartClient.JXJFoodBigStation/App.config index 35b80a6d..b855f1a3 100644 --- a/BPASmartClient.JXJFoodBigStation/App.config +++ b/BPASmartClient.JXJFoodBigStation/App.config @@ -3,7 +3,7 @@ - + \ No newline at end of file diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index b384f96d..1aaeb292 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -103,24 +103,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC } else { - MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); switch (barrel) { case 1: string address = "DB99.DBD" + (6 + 4 * (loc - 1)); HK_PLC_S7.Write(address, recipe.RawMaterial.ElementAt(index).RawMaterialWeight); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); break; case 2: string address1 = "DB99.DBD" + (62 + 4 * (loc - 1)); HK_PLC_S7.Write(address1, recipe.RawMaterial.ElementAt(index).RawMaterialWeight); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); break; case 4: string address2 = "DB99.DBD" + (118 + 4 * (loc - 1)); HK_PLC_S7.Write(address2, recipe.RawMaterial.ElementAt(index).RawMaterialWeight); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); break; case 5: string address3 = "DB99.DBD" + (174 + 4 * (loc - 1)); HK_PLC_S7.Write(address3, recipe.RawMaterial.ElementAt(index).RawMaterialWeight); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); break; default: break; diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index b1962f34..43fc46f2 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -91,20 +91,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model RawMaterials.Clear(); for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum; i++) { - int index = RawMaterialsNamePos.Values.ToList().IndexOf(recipe.Material[i].Material_Name); - if (index >= 0) + if (string.IsNullOrEmpty(recipe.Material[i].Material_Name)) { - RawMaterials.Add(new RawMaterial() - { - RawMaterialName = recipe.Material[i].Material_Name, - RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, - RawMaterialWeight = recipe.Material[i].Material_Weight, - RawMaterialLocation = RawMaterialsNamePos.Keys.ToList()[index] - }); + } - else + else { - MessageNotify.GetInstance.ShowAlarmLog($"本地缺少原料{recipe.Material[i].Material_Name},和西门子下发的原料名称无法对应,"); + int index = RawMaterialsNamePos.Values.ToList().IndexOf(recipe.Material[i].Material_Name); + if (index >= 0) + { + RawMaterials.Add(new RawMaterial() + { + RawMaterialName = recipe.Material[i].Material_Name, + RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, + RawMaterialWeight = recipe.Material[i].Material_Weight, + RawMaterialLocation = RawMaterialsNamePos.Keys.ToList()[index] + }); + } + else + { + MessageNotify.GetInstance.ShowAlarmLog($"本地缺少原料{recipe.Material[i].Material_Name},和西门子下发的原料名称无法对应,"); + } } } App.Current.Dispatcher.Invoke(() => @@ -1287,7 +1294,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发 { - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { if (!GVL_BigStation.BarrelWasherSign) @@ -1311,7 +1317,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.Recipe1DosingStatus = 1; MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); } - } if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1) { @@ -1349,7 +1354,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg"); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg"); } FinishData.Ask_For_Finish = true; double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe1Time).TotalSeconds; @@ -1462,7 +1467,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg"); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg"); } FinishData.Ask_For_Finish = true; double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe2Time).TotalSeconds; diff --git a/BPASmartClient.MilkTeaCube/MilkTeaCubeMachine.cs b/BPASmartClient.MilkTeaCube/MilkTeaCubeMachine.cs index 33c678a4..b85c0a94 100644 --- a/BPASmartClient.MilkTeaCube/MilkTeaCubeMachine.cs +++ b/BPASmartClient.MilkTeaCube/MilkTeaCubeMachine.cs @@ -15,6 +15,41 @@ namespace BPASmartClient.MilkTeaCube public override void Init() { modbus.ModbusTcpConnect(communicationPar.IPAddress); + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) + { + if (@event == null) return; + var par = @event as MilkTea_MakeMilkTeaEvent; + switch (par?.TagName) + { + case "Start": + modbus.Write("LB14", true); + Thread.Sleep(200); + modbus.Write("LB14", false); + + break; + case "ParameterSet": + modbus.Write("LB14", false); + Thread.Sleep(500); + modbus.Write("LW1001", par.MilkTeaKind[0]); + modbus.Write("LW1003", par.MilkTeaKind[1]); + modbus.Write("LW1004", par.MilkTeaKind[2]); + modbus.Write("LW1005", par.MilkTeaKind[3]); + modbus.Write("LW1006", par.MilkTeaKind[4]); + modbus.Write("LW1007", par.MilkTeaKind[5]); + modbus.Write("LW1008", par.MilkTeaKind[6]); + modbus.Write("LW1009", par.MilkTeaKind[7]); + modbus.Write("LW1010", par.MilkTeaKind[8]); + modbus.Write("LW1011", par.MilkTeaKind[9]); + modbus.Write("LW1012", par.MilkTeaKind[10]); + modbus.Write("LW1013", par.MilkTeaKind[11]); + break; + case "StartSignReset": + modbus.Write("LB14", false); + break; + default: + break; + } + }); ThreadManage.GetInstance().StartLong(new Action(() => { IsConnected = modbus.Connected; @@ -36,39 +71,6 @@ namespace BPASmartClient.MilkTeaCube } Thread.Sleep(1000); }), $"̲ζħ豸", true); - EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) - { - if (@event == null) return; - var par = @event as MilkTea_MakeMilkTeaEvent; - switch (par?.TagName) - { - case "Start": - modbus.Write("LB14",true); - break; - case "ParameterSet": - modbus.Write("LB14", false); - Thread.Sleep(500); - modbus.Write("LW1002", par.MilkTeaKind[0]); - modbus.Write("LW1006", par.MilkTeaKind[1]); - modbus.Write("LW1008", par.MilkTeaKind[2]); - modbus.Write("LW1010", par.MilkTeaKind[3]); - modbus.Write("LW1012", par.MilkTeaKind[4]); - modbus.Write("LW1014", par.MilkTeaKind[5]); - modbus.Write("LW1016", par.MilkTeaKind[6]); - modbus.Write("LW1018", par.MilkTeaKind[7]); - modbus.Write("LW1020", par.MilkTeaKind[8]); - modbus.Write("LW1022", par.MilkTeaKind[9]); - modbus.Write("LW1024", par.MilkTeaKind[10]); - modbus.Write("LW1026", par.MilkTeaKind[11]); - - break; - case "StartSignReset": - modbus.Write("LB14", false); - break; - default: - break; - } - }); } public override void Start() { diff --git a/BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs b/BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs index 10b33a97..128d1f41 100644 --- a/BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs +++ b/BPASmartClient.MorkT_BarCounter/Control_MorkT_BarCounter.cs @@ -60,6 +60,8 @@ namespace BPASmartClient.MorkT_BarCounter { IsHealth = true; } + Json.Read(); + GVL_MorkT.MilkTeaCHValue = Json.Data.parData; IsHealth = true; serverInit(); DataParse(); diff --git a/BPASmartClient.MorkT_BarCounter/GVL_MorkT.cs b/BPASmartClient.MorkT_BarCounter/GVL_MorkT.cs index af1ebad6..2217c3c1 100644 --- a/BPASmartClient.MorkT_BarCounter/GVL_MorkT.cs +++ b/BPASmartClient.MorkT_BarCounter/GVL_MorkT.cs @@ -108,7 +108,7 @@ namespace BPASmartClient.MorkT_BarCounter /// /// 出果汁完成,是否去取果汁 /// - public static ushort[] MilkTeaCHValue = new ushort[12] {200,200,200,200,200,200,200,200,200,200,200,200 }; + public static ushort[] MilkTeaCHValue { get; set; } = new ushort[12] {200,200,200,200,200,200,200,200,200,200,200,200 }; /// /// 做茶订单队列 /// diff --git a/BPASmartClient.MorkT_BarCounter/SavePar.cs b/BPASmartClient.MorkT_BarCounter/SavePar.cs new file mode 100644 index 00000000..5b7edfa2 --- /dev/null +++ b/BPASmartClient.MorkT_BarCounter/SavePar.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkT_BarCounter +{ + public class SavePar + { + public string Name { get; set; } + public string Value { get; set; } + } +} diff --git a/BPASmartClient.MorkT_BarCounter/SaveParModel.cs b/BPASmartClient.MorkT_BarCounter/SaveParModel.cs new file mode 100644 index 00000000..12a05cfa --- /dev/null +++ b/BPASmartClient.MorkT_BarCounter/SaveParModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkT_BarCounter +{ + public class SaveParModel + { + public ObservableCollection parSets { get; set; } = new ObservableCollection(); + public ushort[] parData { get; set; } + } +} diff --git a/BPASmartClient.MorkT_BarCounter/View/DebugView.xaml b/BPASmartClient.MorkT_BarCounter/View/DebugView.xaml index 618a5389..1365753c 100644 --- a/BPASmartClient.MorkT_BarCounter/View/DebugView.xaml +++ b/BPASmartClient.MorkT_BarCounter/View/DebugView.xaml @@ -102,16 +102,10 @@ 味魔方执行程序: - - + - - 电爪执行程序: - - - diff --git a/BPASmartClient.MorkT_BarCounter/ViewModel/DebugViewModel.cs b/BPASmartClient.MorkT_BarCounter/ViewModel/DebugViewModel.cs index c49d316d..4ea1237d 100644 --- a/BPASmartClient.MorkT_BarCounter/ViewModel/DebugViewModel.cs +++ b/BPASmartClient.MorkT_BarCounter/ViewModel/DebugViewModel.cs @@ -25,6 +25,10 @@ public class DebugViewModel : ObservableObject { public DebugViewModel() { + if (Json.Data.parData != null) + { + CH_Value = Json.Data.parData; + } RobotControlCommand = new RelayCommand(() => { new WriteJaka() { DeviceId = 126, TagName = "JaKaProgramName", Value = JakaRobotProgram }.Publish(); @@ -36,7 +40,6 @@ public class DebugViewModel : ObservableObject }); MikeTeaCupControlCommand = new RelayCommand(() => { - new MilkTea_MakeMilkTeaEvent() { DeviceId = 126, TagName = "ParameterSet", MilkTeaKind = GVL_MorkT.MilkTeaCHValue }.Publish(); //写入奶茶参数 new MilkTea_MakeMilkTeaEvent() { DeviceId = 126, TagName = "Start" }.Publish(); }); GripperControlCommand = new RelayCommand(() => @@ -64,8 +67,11 @@ public class DebugViewModel : ObservableObject { for (int i = 0; i < 12; i++) { - GVL_MorkT.MilkTeaCHValue[i] = (ushort)CH_Value[i]; + GVL_MorkT.MilkTeaCHValue[i] = CH_Value[i]; } + Json.Data.parData = GVL_MorkT.MilkTeaCHValue; + Json.Save(); + new MilkTea_MakeMilkTeaEvent() { DeviceId = 126, TagName = "ParameterSet", MilkTeaKind = GVL_MorkT.MilkTeaCHValue }.Publish(); //写入奶茶参数 }); } public int JakaRobotProgram { get { return _JakaRobotProgram; } set { _JakaRobotProgram = value; OnPropertyChanged(); } } @@ -82,8 +88,8 @@ public class DebugViewModel : ObservableObject public int GripperProgam { get { return _GripperProgam; } set { _GripperProgam = value; OnPropertyChanged(); } } private int _GripperProgam { get; set; } - public int[] CH_Value { get { return _CH_Value; } set { _CH_Value = value; OnPropertyChanged(); } } - private int[] _CH_Value { get; set; } = new int[12] {200,200,200,200,200,200,200,200,200,200,200,200 }; + public ushort[] CH_Value { get { return _CH_Value; } set { _CH_Value = value; OnPropertyChanged(); } } + private ushort[] _CH_Value { get; set; } = new ushort[12] {200,200,200,200,200,200,200,200,200,200,200,200 }; public RelayCommand GripperControlCommand { get; set; } } diff --git a/BPASmartClient/App.config b/BPASmartClient/App.config index 618157de..9c45fe12 100644 --- a/BPASmartClient/App.config +++ b/BPASmartClient/App.config @@ -7,9 +7,9 @@ - + - +