From a53e32297d028de1809c2343de5cc48900952b71 Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Thu, 13 Apr 2023 13:36:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/Model/AlarmHelper.cs | 1 - BPASmartClient.Device/BaseDevice.cs | 2 +- BPASmartClient.Helper/ExpandMethod.cs | 120 ++ BPASmartClient.Helper/ThreadManage.cs | 1 - .../Model/GVL_BigStation.cs | 10 + .../Model/HK_PLC/DB_Write.cs | 19 + .../Model/HK_PLC/HKPlcCommAddress.cs | 13 + .../Model/ProcessControl.cs | 1133 ++++++----- .../Model/RawMaterial/RecipeData.cs | 8 + .../Model/RecipeDosing.cs | 25 + .../Model/Siemens/SiemensDeviceStatus.cs | 23 +- .../View/HardwareStatusView.xaml | 17 +- .../View/ManualFlowView.xaml | 111 +- .../View/RecipeReceiveView.xaml | 14 +- .../View/RecipeSendDownView.xaml | 9 +- .../View/RecipeSendDownView.xaml.cs | 16 +- .../ViewModel/HardwareStatusViewModel.cs | 107 +- .../ViewModel/ManualFlowViewModel.cs | 64 +- .../ViewModel/RecipeReceiveViewModel.cs | 24 + .../ViewModel/RecipeSendDownViewModel.cs | 6 +- .../App.xaml.cs | 49 +- .../BPASmartClient.JXJFoodSmallStation.csproj | 7 + .../Model/Bom/BomMaterial.cs | 21 + .../Model/Bom/BomMaterialData.cs | 16 + ...lcCommAttribute.cs => VarCommAttribute.cs} | 4 +- .../Model/GVL_SmallStation.cs | 230 ++- .../Model/HK_PLC/DataComm.cs | 41 + .../Model/HK_PLC/HKDeviceStatus.cs | 3 +- .../Model/HK_PLC/HKDeviceWrite.cs | 23 + .../Model/HK_PLC/PlcReadAddressDB3.cs | 156 +- .../Model/HK_PLC/PlcWriteAddressDB7.cs | 13 + .../Model/ProcessControl.cs | 1650 ++++++++++------- .../Model/RawMaterial/DeviceInquire.cs | 1 - .../Model/RawMaterial/DevicePar.cs | 2 + .../Model/Siemens/SiemensDeviceStatus.cs | 23 +- .../Model/WindSend/WindSendDeviceStatus.cs | 7 +- .../Model/WindSend/WindSendRawMaterial.cs | 4 +- .../View/BomOfMaterialView.xaml | 250 +++ .../View/BomOfMaterialView.xaml.cs | 28 + .../View/ManualFlowView.xaml | 51 +- .../View/ManualFlowView.xaml.cs | 5 + .../View/PlcVarMonitorView.xaml | 7 +- .../View/ProcessMonitorView.xaml | 90 + .../View/ProcessMonitorView.xaml.cs | 28 + .../View/RecipeReceiveView.xaml | 20 +- .../View/RecipeReceiveView.xaml.cs | 2 + .../View/RobotView.xaml | 4 +- .../View/StockBinRawMaterialView.xaml | 14 +- .../View/WindSendParView.xaml | 6 +- .../View/WindSendParView.xaml.cs | 3 +- .../ViewModel/BomOfMaterialViewModel.cs | 85 + .../ViewModel/HardwareStatusViewModel.cs | 4 +- .../ViewModel/ManualControlViewModel.cs | 216 ++- .../ViewModel/ManualFlowViewModel.cs | 41 +- .../ViewModel/ProcessMonitorViewModel.cs | 23 + .../ViewModel/RecipeReceiveViewModel.cs | 12 + .../ViewModel/RobotViewModel.cs | 24 +- .../ViewModel/SystemParViewModel.cs | 17 +- .../ViewModel/WindSendParViewModel.cs | 5 +- BPASmartClient.MorkS/Control_Morks.cs | 9 +- BPASmartClient.MorkS/GVL_MORKS.cs | 3 + BPASmartClient.MorkS/Model/MorksPar.cs | 4 + BPASmartClient.MorkS/View/ParSet.xaml | 27 +- .../ViewModel/ParSetViewModel.cs | 4 + BPASmartClient/App.config | 8 +- DosingSystem/Model/par/LocaPar.cs | 18 + .../ViewModel/RecipeControlViewModel.cs | 536 +++--- 67 files changed, 3589 insertions(+), 1928 deletions(-) create mode 100644 BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs create mode 100644 BPASmartClient.JXJFoodBigStation/Model/RecipeDosing.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterial.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs rename BPASmartClient.JXJFoodSmallStation/Model/GVL/{PlcCommAttribute.cs => VarCommAttribute.cs} (78%) create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceWrite.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/View/BomOfMaterialView.xaml create mode 100644 BPASmartClient.JXJFoodSmallStation/View/BomOfMaterialView.xaml.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/View/ProcessMonitorView.xaml create mode 100644 BPASmartClient.JXJFoodSmallStation/View/ProcessMonitorView.xaml.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/ViewModel/BomOfMaterialViewModel.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/ViewModel/ProcessMonitorViewModel.cs create mode 100644 DosingSystem/Model/par/LocaPar.cs diff --git a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs index a1aa60c6..e504cf29 100644 --- a/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs +++ b/BPASmartClient.CustomResource/Pages/Model/AlarmHelper.cs @@ -67,7 +67,6 @@ namespace BPASmartClient.CustomResource.Pages.Model } Thread.Sleep(100); }), $"{typeof(AlarmT).Name},报警通用模块监听"); - } /// diff --git a/BPASmartClient.Device/BaseDevice.cs b/BPASmartClient.Device/BaseDevice.cs index e5b10552..be2eea4b 100644 --- a/BPASmartClient.Device/BaseDevice.cs +++ b/BPASmartClient.Device/BaseDevice.cs @@ -284,7 +284,7 @@ namespace BPASmartClient.Device foreach (var faces in res) { if (faces.Name == "IStatus") - { + { InterfaceStatus = item.GetValue(this) as IStatus; GetMonitorData(InterfaceStatus); } diff --git a/BPASmartClient.Helper/ExpandMethod.cs b/BPASmartClient.Helper/ExpandMethod.cs index e3df2666..050ca1c3 100644 --- a/BPASmartClient.Helper/ExpandMethod.cs +++ b/BPASmartClient.Helper/ExpandMethod.cs @@ -185,6 +185,126 @@ namespace BPASmartClient.Helper return false; } + public static string ToBinString(this object value) + { + int num = 0; + int num2 = 0; + int num3 = 0; + string text = ""; + long num4 = 0L; + try + { + if (value.GetType().Name.IndexOf("[]") < 0) + { + string a = value.GetType().Name; + switch (a) + { + case "Byte": + num3 = 7; + num4 = (byte)value; + break; + case "UInt16": + num3 = 15; + num4 = (ushort)value; + break; + case "Int16": + num3 = 15; + num4 = (short)value; + break; + case "UInt32": + num3 = 31; + num4 = (uint)value; + break; + case "Int32": + num3 = 31; + num4 = (int)value; + break; + case "Int64": + num3 = 63; + num4 = (long)value; + break; + default: + throw new Exception(); + } + + for (num = num3; num >= 0; num += -1) + { + if ((num + 1) % 4 == 0) text = text + " "; + text = (((num4 & (long)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1")); + } + } + else + { + switch (value.GetType().Name) + { + case "Byte[]": + { + num3 = 7; + byte[] array4 = (byte[])value; + for (num2 = 0; num2 <= array4.Length - 1; num2++) + { + for (num = num3; num >= 0; num += -1) + { + text = (((array4[num2] & (byte)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1")); + } + } + + break; + } + case "Int16[]": + { + num3 = 15; + short[] array2 = (short[])value; + for (num2 = 0; num2 <= array2.Length - 1; num2++) + { + for (num = num3; num >= 0; num += -1) + { + text = (((array2[num2] & (byte)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1")); + } + } + + break; + } + case "Int32[]": + { + num3 = 31; + int[] array3 = (int[])value; + for (num2 = 0; num2 <= array3.Length - 1; num2++) + { + for (num = num3; num >= 0; num += -1) + { + text = (((array3[num2] & (byte)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1")); + } + } + + break; + } + case "Int64[]": + { + num3 = 63; + byte[] array = (byte[])value; + for (num2 = 0; num2 <= array.Length - 1; num2++) + { + for (num = num3; num >= 0; num += -1) + { + text = (((array[num2] & (byte)Math.Pow(2.0, num)) <= 0) ? (text + "0") : (text + "1")); + } + } + + break; + } + default: + throw new Exception(); + } + } + + return text; + } + catch + { + return ""; + } + } diff --git a/BPASmartClient.Helper/ThreadManage.cs b/BPASmartClient.Helper/ThreadManage.cs index 25f0cd24..33d37d20 100644 --- a/BPASmartClient.Helper/ThreadManage.cs +++ b/BPASmartClient.Helper/ThreadManage.cs @@ -201,5 +201,4 @@ namespace BPASmartClient.Helper return false; } } - } diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 624df1bd..ff7f543e 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -62,6 +62,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 /// public static int Recipe4DosingStatus { get; set; } + + + public static int[] RecipeDosingStatus { get; set; } = new int[4] { 0, 0, 0, 0 }; + public static bool[] AllowIssueRecipe { get; set; } = new bool[4] { false, false, false, false }; + public static bool[] ReceviceFinishRecipe { get; set; } = new bool[4] { false, false, false, false }; + public static bool[] DosingFinishRecipe { get; set; } = new bool[4] { false, false, false, false }; + + public static bool[] IsTrayArrive { get; set; } = new bool[5] { false, false, false, false,false }; + public static DateTime[] RecipeDosingTime { get; set; } = new DateTime[4] { DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now }; + /// /// 是否处于手动下发配方 /// diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs index 82c4d8dd..4d12381e 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs @@ -58,6 +58,25 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC /// public bool Tray5InPlace { get; set; } /// + /// 配方1配料完成 + /// + public bool Recipe1DoisngFinish { get; set; } + + /// + /// 配方2配料完成 + /// + public bool Recipe2DoisngFinish { get; set; } + + /// + /// 配方3配料完成 + /// + public bool Recipe3DoisngFinish { get; set; } + + /// + /// 配方4配料完成 + /// + public bool Recipe4DoisngFinish { get; set; } + /// /// 配方编码 /// public short RecipeCode { get; set; } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs new file mode 100644 index 00000000..b571013d --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKPlcCommAddress.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC +{ + public class HKPlcCommAddress + { + + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index b5f1a742..b1962f34 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -27,27 +27,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 西门子配方数据 /// - public ObservableCollection SiemensRecipes = new ObservableCollection(); + public ObservableCollection SiemensRecipes { get; set; } = new ObservableCollection(); /// /// 本地配方数据 /// - public ObservableCollection LocalRecipes = new ObservableCollection(); + public ObservableCollection LocalRecipes { get; set; } = new ObservableCollection(); /// /// 配方等待执行 /// - public ObservableCollection RecipeWaitExecute = new ObservableCollection(); + public ObservableCollection RecipeWaitExecute { get; set; } = new ObservableCollection(); /// /// 配方正在执行 /// - public ObservableCollection RecipeExecuting = new ObservableCollection(); + public ObservableCollection RecipeExecuting { get; set; } = new ObservableCollection(); /// /// 配方执行完成 /// - public ObservableCollection RecipeExecuteComple = new ObservableCollection(); + public ObservableCollection RecipeExecuteComple { get; set; } = new ObservableCollection(); /// /// 原料的名称和料仓的位置对应 /// - public ConcurrentDictionary RawMaterialsNamePos = new ConcurrentDictionary(); + public ConcurrentDictionary RawMaterialsNamePos { get; set; } = new ConcurrentDictionary(); /// /// 硬件料仓的原料信息 /// @@ -60,6 +60,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model public ConcurrentQueue SiemensRecipeQueue2 = new ConcurrentQueue(); public ConcurrentQueue SiemensRecipeQueue3 = new ConcurrentQueue(); public ConcurrentQueue SiemensRecipeQueue4 = new ConcurrentQueue(); + + public ConcurrentDictionary> SiemensRecipeQueue = new ConcurrentDictionary>(); + public ObservableCollection recipe = new ObservableCollection(); /// /// 本地配方队列 /// @@ -89,7 +92,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model 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 (index >= 0) { RawMaterials.Add(new RawMaterial() { @@ -101,7 +104,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model } else { - MessageNotify.GetInstance.ShowAlarmLog($"本地原料名称和西门子下发的原料名称无法对应,原料名称:{recipe.Material[i].Material_Name},"); + MessageNotify.GetInstance.ShowAlarmLog($"本地缺少原料{recipe.Material[i].Material_Name},和西门子下发的原料名称无法对应,"); } } App.Current.Dispatcher.Invoke(() => @@ -118,11 +121,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } }), "SiemensSendRecipe", true); - //testRawMaterialNameData();//自定义料仓名称 DeviceConnectInit();//设备连接初始化 ThreadInit();//线程初始化 VarResetInit();//变量初始化 } + #region 本地配方--暂时不使用 private void LocalRecipeRecevice() { if (LocalRecipes.Count > 0) @@ -223,7 +226,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } } - else + else { HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); @@ -249,7 +252,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model { GVL_BigStation.BarrelWasherSign = false; } - GVL_BigStation.Recipe1DosingStatus = 3; + GVL_BigStation.Recipe1DosingStatus = 3; switch (trayCode) { case 1: @@ -331,7 +334,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } LocalRecipeQueue1.TryDequeue(out code); - RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将配方添加到完成列表 //App.Current.Dispatcher.Invoke(() => { // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 //}); @@ -373,7 +375,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model default: break; } - if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 &&Inplace)//配方2是否允许下发配发 + if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 && Inplace)//配方2是否允许下发配发 { if (LocalRecipes.ElementAt(index).IsWashingBarrel) { @@ -497,10 +499,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } LocalRecipeQueue2.TryDequeue(out code); - RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下 - //App.Current.Dispatcher.Invoke(() => { - // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - //}); LocalRecipes.RemoveAt(index); GVL_BigStation.Recipe2DosingStatus = 0; } @@ -555,7 +553,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } } - else + else { HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); @@ -664,10 +662,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model } HKDevice.HK_PLC_S7.Write("DB98.DBX1.1", false); LocalRecipeQueue3.TryDequeue(out code); - RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下 - //App.Current.Dispatcher.Invoke(() => { - // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - //}); LocalRecipes.RemoveAt(index); GVL_BigStation.Recipe3DosingStatus = 0; } @@ -722,7 +716,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } } - else + else { HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); @@ -828,19 +822,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model { item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } - } + } HKDevice.HK_PLC_S7.Write("DB98.DBX1.3", false); LocalRecipeQueue4.TryDequeue(out code); - RecipeExecuteComple.Add(LocalRecipes.ElementAt(index));//将该配方添加到下 - //App.Current.Dispatcher.Invoke(() => { - // Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - //}); LocalRecipes.RemoveAt(index); GVL_BigStation.Recipe4DosingStatus = 0; } } } } + #endregion private void ReceviceData() { SiemensRecipes = Json.Data.Recipes; @@ -848,151 +839,178 @@ namespace BPASmartClient.JXJFoodBigStation.Model { foreach (var data in SiemensRecipes) { - if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1) + if (data.RecipesSource == RecipeSource.远程) { - if (!(SiemensRecipeQueue1.Contains(data.RecipeCode))) + if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1) { - if (SiemensDevice.DL_Status is DL_Status_DB status) + if (!(SiemensRecipeQueue1.Contains(data.RecipeCode))) { - switch (GVL_BigStation.SiemensSendRecipeStatus) + if (SiemensDevice.DL_Status is DL_Status_DB status) { - case 3: + switch (GVL_BigStation.SiemensSendRecipeStatus) + { + case 3: + SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给西门子"); + GVL_BigStation.SiemensSendRecipeStatus = 4; + break; + case 4: + if (SiemensDevice.DL_Status.Dosing_Start_ACK) + { + SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + MessageNotify.GetInstance.ShowRunLog($"配方1,西门子确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; + } + break; + case 5: + if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + { + SiemensRecipeQueue1.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; + } + break; + default: + break; + } + } + } + } + else if (SiemensRecipeQueue2.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe2) + { + if (!(SiemensRecipeQueue2.Contains(data.RecipeCode))) + { + if (SiemensDevice.DL_Status is DL_Status_DB status) + { + if (GVL_BigStation.SiemensSendRecipeStatus == 3) + { SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); - MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给西门子"); + MessageNotify.GetInstance.ShowRunLog($"配方2,发送配方编号和请求配料标志给西门子"); GVL_BigStation.SiemensSendRecipeStatus = 4; - break; - case 4: + } + if (GVL_BigStation.SiemensSendRecipeStatus == 4) + { if (SiemensDevice.DL_Status.Dosing_Start_ACK) { SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); - MessageNotify.GetInstance.ShowRunLog($"配方1,西门子确认开始配料"); + MessageNotify.GetInstance.ShowRunLog($"配方2,西门子确认开始配料"); GVL_BigStation.SiemensSendRecipeStatus = 5; } - break; - case 5: + } + if (GVL_BigStation.SiemensSendRecipeStatus == 5) + { if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) { - SiemensRecipeQueue1.Enqueue(data.RecipeCode); - MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列"); + SiemensRecipeQueue2.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方:{data.RecipeCode},加入队列"); GVL_BigStation.SiemensSendRecipeStatus = 0; } - break; - default: - break; + } } } } - } - else if (SiemensRecipeQueue2.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe2) - { - if (!(SiemensRecipeQueue2.Contains(data.RecipeCode))) + else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3) { - if (SiemensDevice.DL_Status is DL_Status_DB status) + if (!(SiemensRecipeQueue3.Contains(data.RecipeCode))) { - if (GVL_BigStation.SiemensSendRecipeStatus == 3) + if (SiemensDevice.DL_Status is DL_Status_DB status) { - SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); - MessageNotify.GetInstance.ShowRunLog($"配方2,发送配方编号和请求配料标志给西门子"); - GVL_BigStation.SiemensSendRecipeStatus = 4; - } - if (GVL_BigStation.SiemensSendRecipeStatus == 4) - { - if (SiemensDevice.DL_Status.Dosing_Start_ACK) + if (GVL_BigStation.SiemensSendRecipeStatus == 3) + { + SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"配方3,发送配方编号和请求配料标志给西门子"); + GVL_BigStation.SiemensSendRecipeStatus = 4; + } + if (GVL_BigStation.SiemensSendRecipeStatus == 4) { - SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); - MessageNotify.GetInstance.ShowRunLog($"配方2,西门子确认开始配料"); - GVL_BigStation.SiemensSendRecipeStatus = 5; + if (SiemensDevice.DL_Status.Dosing_Start_ACK) + { + SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + MessageNotify.GetInstance.ShowRunLog($"配方3,西门子确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; + } } - } - if (GVL_BigStation.SiemensSendRecipeStatus == 5) - { - if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + if (GVL_BigStation.SiemensSendRecipeStatus == 5) { - SiemensRecipeQueue2.Enqueue(data.RecipeCode); - MessageNotify.GetInstance.ShowRunLog($"配方2,配方:{data.RecipeCode},加入队列"); - GVL_BigStation.SiemensSendRecipeStatus = 0; + if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + { + SiemensRecipeQueue3.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方3,配方:{data.RecipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; + } } } } } - } - else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3) - { - if (!(SiemensRecipeQueue3.Contains(data.RecipeCode))) + else if (SiemensRecipeQueue4.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe4) { - if (SiemensDevice.DL_Status is DL_Status_DB status) + if (!(SiemensRecipeQueue4.Contains(data.RecipeCode))) { - if (GVL_BigStation.SiemensSendRecipeStatus == 3) - { - SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); - MessageNotify.GetInstance.ShowRunLog($"配方3,发送配方编号和请求配料标志给西门子"); - GVL_BigStation.SiemensSendRecipeStatus = 4; - } - if (GVL_BigStation.SiemensSendRecipeStatus == 4) + if (SiemensDevice.DL_Status is DL_Status_DB status) { - if (SiemensDevice.DL_Status.Dosing_Start_ACK) + if (GVL_BigStation.SiemensSendRecipeStatus == 3) { - SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); - MessageNotify.GetInstance.ShowRunLog($"配方3,西门子确认开始配料"); - GVL_BigStation.SiemensSendRecipeStatus = 5; + SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"配方4,发送配方编号和请求配料标志给西门子"); + GVL_BigStation.SiemensSendRecipeStatus = 4; } - } - if (GVL_BigStation.SiemensSendRecipeStatus == 5) - { - if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + if (GVL_BigStation.SiemensSendRecipeStatus == 4) + { + if (SiemensDevice.DL_Status.Dosing_Start_ACK) + { + SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + MessageNotify.GetInstance.ShowRunLog($"配方4,西门子确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; + } + } + if (GVL_BigStation.SiemensSendRecipeStatus == 5) { - SiemensRecipeQueue3.Enqueue(data.RecipeCode); - MessageNotify.GetInstance.ShowRunLog($"配方3,配方:{data.RecipeCode},加入队列"); - GVL_BigStation.SiemensSendRecipeStatus = 0; + if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + { + SiemensRecipeQueue4.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方4,配方:{data.RecipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; + } } } } } } - else if (SiemensRecipeQueue4.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe4) + else { - if (!(SiemensRecipeQueue4.Contains(data.RecipeCode))) + if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1) { - if (SiemensDevice.DL_Status is DL_Status_DB status) - { - if (GVL_BigStation.SiemensSendRecipeStatus == 3) - { - SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); - MessageNotify.GetInstance.ShowRunLog($"配方4,发送配方编号和请求配料标志给西门子"); - GVL_BigStation.SiemensSendRecipeStatus = 4; - } - if (GVL_BigStation.SiemensSendRecipeStatus == 4) - { - if (SiemensDevice.DL_Status.Dosing_Start_ACK) - { - SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); - MessageNotify.GetInstance.ShowRunLog($"配方4,西门子确认开始配料"); - GVL_BigStation.SiemensSendRecipeStatus = 5; - } - } - if (GVL_BigStation.SiemensSendRecipeStatus == 5) - { - if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) - { - SiemensRecipeQueue4.Enqueue(data.RecipeCode); - MessageNotify.GetInstance.ShowRunLog($"配方4,配方:{data.RecipeCode},加入队列"); - GVL_BigStation.SiemensSendRecipeStatus = 0; - } - } - } + SiemensRecipeQueue1.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"本地配方,配方:{data.RecipeCode},加入队列1"); + } + else if (SiemensRecipeQueue2.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe2) + { + SiemensRecipeQueue2.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"本地配方,配方:{data.RecipeCode},加入队列2"); + } + else if(SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3) + { + SiemensRecipeQueue3.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"本地配方,配方:{data.RecipeCode},加入队列3"); + } + else if (SiemensRecipeQueue4.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe4) + { + SiemensRecipeQueue4.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"本地配方,配方:{data.RecipeCode},加入队列4"); + } } } } - else + else { SiemensRecipeQueue1.Clear(); SiemensRecipeQueue2.Clear(); @@ -1004,10 +1022,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.Recipe3DosingStatus = 0; GVL_BigStation.Recipe4DosingStatus = 0; } - - } - public void Order_Cancel() + public void Order_Cancel() { if (GVL_BigStation.Order_Cancel) //订单取消 { @@ -1126,6 +1142,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model }); SiemensRecipeQueue1.TryDequeue(out code); GVL_BigStation.Order_CancelStep = 0; + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); } break; @@ -1158,6 +1176,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model }); SiemensRecipeQueue2.TryDequeue(out code); GVL_BigStation.Order_CancelStep = 0; + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; MessageNotify.GetInstance.ShowRunLog($"队列2,西门子取消订单完成,订单号:{code}"); } break; @@ -1190,6 +1210,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model }); SiemensRecipeQueue3.TryDequeue(out code); GVL_BigStation.Order_CancelStep = 0; + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; MessageNotify.GetInstance.ShowRunLog($"队列3,西门子取消订单完成,订单号:{code}"); } break; @@ -1222,6 +1244,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model }); SiemensRecipeQueue4.TryDequeue(out code); GVL_BigStation.Order_CancelStep = 0; + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; MessageNotify.GetInstance.ShowRunLog($"队列4,西门子取消订单完成,订单号:{code}"); } break; @@ -1263,42 +1287,42 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发 { - + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { if (!GVL_BigStation.BarrelWasherSign) { GVL_BigStation.BarrelWasherSign = true; HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); - + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + GVL_BigStation.DosingRecipe1Time = DateTime.Now; HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); GVL_BigStation.Recipe1DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); } } - else + else { GVL_BigStation.DosingRecipe1Time = DateTime.Now; HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); GVL_BigStation.Recipe1DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},下发完成"); } - + } if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1) { if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},洗桶复位"); } HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false); StockBinParReset(); - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); GVL_BigStation.Recipe1DosingStatus = 2; } if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) @@ -1309,67 +1333,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model } GVL_BigStation.Recipe1DosingFinish = true; GVL_BigStation.Recipe1DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); - foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) - { - if (item.RawMaterialLocation == 1) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; - } - else if (item.RawMaterialLocation == 2) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; - } - else if (item.RawMaterialLocation == 3) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; - } - else if (item.RawMaterialLocation == 4) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; - } - else if (item.RawMaterialLocation == 5) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; - } - else if (item.RawMaterialLocation == 6) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; - } - else if (item.RawMaterialLocation == 7) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; - } - else if (item.RawMaterialLocation == 8) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; - } - else if (item.RawMaterialLocation == 9) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; - } - else if (item.RawMaterialLocation == 10) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; - } - else if (item.RawMaterialLocation == 11) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; - } - else if (item.RawMaterialLocation == 12) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; - } - else if (item.RawMaterialLocation == 13) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; - } - else if (item.RawMaterialLocation == 14) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; - } - } - if (SiemensDevice.IsConnected) + MessageNotify.GetInstance.ShowRunLog($"配方1,配方状态:{code}配料完成"); + ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) { FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; @@ -1383,30 +1349,27 @@ 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"); } FinishData.Ask_For_Finish = true; double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe1Time).TotalSeconds; FinishData.ProcessTime = Convert.ToInt16(a); SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); + MessageNotify.GetInstance.ShowRunLog($"配方1,{code}配方配料完成,将信号反馈给西门子"); } + HKDevice.HK_PLC_S7.Write("DB99.DBX1.4", true); + GVL_BigStation.Recipe1DosingStatus = 3; + } + if (GVL_BigStation.Recipe1DosingStatus == 3 && HKDevice.PlcRead.Recipe1DosingFinish == false) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.4", false); SiemensRecipeQueue1.TryDequeue(out code); - RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将配方添加到完成列表 - if (!GVL_BigStation.IsUseLocalRecipe) - { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } - else + App.Current.Dispatcher.Invoke(() => { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); GVL_BigStation.Recipe1DosingStatus = 0; + MessageNotify.GetInstance.ShowRunLog($"配方1,{code}配方配料完成,复位plc配料完成信号"); } } } @@ -1438,7 +1401,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model default: break; } - if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 && Inplace )//配方2是否允许下发配发 + if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 && Inplace)//配方2是否允许下发配发 { if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { @@ -1446,22 +1409,22 @@ namespace BPASmartClient.JXJFoodBigStation.Model { GVL_BigStation.BarrelWasherSign = true; HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); GVL_BigStation.DosingRecipe2Time = DateTime.Now; HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); GVL_BigStation.Recipe2DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},下发完成"); } } - else + else { GVL_BigStation.DosingRecipe2Time = DateTime.Now; HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); GVL_BigStation.Recipe2DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},下发完成"); } } if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1) @@ -1469,12 +1432,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},洗桶复位"); } HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", false); StockBinParReset(); GVL_BigStation.Recipe2DosingStatus = 2; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) { @@ -1483,105 +1446,44 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.BarrelWasherSign = false; } GVL_BigStation.Recipe2DosingFinish = true; - GVL_BigStation.Recipe2DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); - foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) + MessageNotify.GetInstance.ShowRunLog($"配方2,配方状态:{code}配料完成"); + ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) { - if (item.RawMaterialLocation == 1) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; - } - else if (item.RawMaterialLocation == 2) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; - } - else if (item.RawMaterialLocation == 3) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; - } - else if (item.RawMaterialLocation == 4) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; - } - else if (item.RawMaterialLocation == 5) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; - } - else if (item.RawMaterialLocation == 6) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; - } - else if (item.RawMaterialLocation == 7) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; - } - else if (item.RawMaterialLocation == 8) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; - } - else if (item.RawMaterialLocation == 9) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; - } - else if (item.RawMaterialLocation == 10) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; - } - else if (item.RawMaterialLocation == 11) + FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; + for (int i = 0; i < FinishData.Material.Length; i++) { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + FinishData.Material[i] = new UDT1(); } - else if (item.RawMaterialLocation == 12) + for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; - } - else if (item.RawMaterialLocation == 13) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; - } - else if (item.RawMaterialLocation == 14) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; - } - } - if (SiemensDevice.IsConnected) - { - FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; - FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; - for (int i = 0; i < FinishData.Material.Length; i++) - { - FinishData.Material[i] = new UDT1(); - } - for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) - { - 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); + 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"); } FinishData.Ask_For_Finish = true; double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe2Time).TotalSeconds; FinishData.ProcessTime = Convert.ToInt16(a); SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); + MessageNotify.GetInstance.ShowRunLog($"配方2,{code}配方配料完成,将信号反馈给西门子"); } + HKDevice.HK_PLC_S7.Write("DB99.DBX1.5", true); + GVL_BigStation.Recipe2DosingStatus = 3; + } + if (GVL_BigStation.Recipe2DosingStatus == 3 && HKDevice.PlcRead.Recipe2DosingFinish == false) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.5", false); SiemensRecipeQueue2.TryDequeue(out code); RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index)); - if (!GVL_BigStation.IsUseLocalRecipe) - { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } - else + App.Current.Dispatcher.Invoke(() => { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); GVL_BigStation.Recipe2DosingStatus = 0; + MessageNotify.GetInstance.ShowRunLog($"配方2,{code}配方配料完成,复位plc配料完成信号"); } } } @@ -1621,21 +1523,21 @@ namespace BPASmartClient.JXJFoodBigStation.Model { GVL_BigStation.BarrelWasherSign = true; HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); GVL_BigStation.DosingRecipe3Time = DateTime.Now; HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); GVL_BigStation.Recipe3DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},下发完成"); } } - else + else { GVL_BigStation.DosingRecipe3Time = DateTime.Now; HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); GVL_BigStation.Recipe3DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},下发完成"); } } if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1) @@ -1643,12 +1545,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},洗桶复位"); } HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", false); StockBinParReset(); GVL_BigStation.Recipe3DosingStatus = 2; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) { @@ -1658,67 +1560,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model } GVL_BigStation.Recipe3DosingFinish = true; GVL_BigStation.Recipe3DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); - foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) - { - if (item.RawMaterialLocation == 1) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; - } - else if (item.RawMaterialLocation == 2) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; - } - else if (item.RawMaterialLocation == 3) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; - } - else if (item.RawMaterialLocation == 4) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; - } - else if (item.RawMaterialLocation == 5) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; - } - else if (item.RawMaterialLocation == 6) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; - } - else if (item.RawMaterialLocation == 7) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; - } - else if (item.RawMaterialLocation == 8) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; - } - else if (item.RawMaterialLocation == 9) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; - } - else if (item.RawMaterialLocation == 10) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; - } - else if (item.RawMaterialLocation == 11) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; - } - else if (item.RawMaterialLocation == 12) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; - } - else if (item.RawMaterialLocation == 13) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; - } - else if (item.RawMaterialLocation == 14) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; - } - } - if (SiemensDevice.IsConnected) + MessageNotify.GetInstance.ShowRunLog($"配方3,配方状态:{code}配料完成"); + ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) { FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; @@ -1732,30 +1576,27 @@ 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($"配方3,配方编号:{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.DosingRecipe3Time).TotalSeconds; FinishData.ProcessTime = Convert.ToInt16(a); SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); + MessageNotify.GetInstance.ShowRunLog($"配方3,{code}配方配料完成,将信号反馈给西门子"); } + HKDevice.HK_PLC_S7.Write("DB99.DBX1.6", true); + GVL_BigStation.Recipe3DosingStatus = 3; + } + if (GVL_BigStation.Recipe3DosingStatus == 3 && HKDevice.PlcRead.Recipe3DosingFinish == false) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.6", false); SiemensRecipeQueue3.TryDequeue(out code); - RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下 - if (!GVL_BigStation.IsUseLocalRecipe) - { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } - else + App.Current.Dispatcher.Invoke(() => { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); GVL_BigStation.Recipe3DosingStatus = 0; + MessageNotify.GetInstance.ShowRunLog($"配方3,{code}配方配料完成,复位plc配料完成信号"); } } } @@ -1795,12 +1636,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model { GVL_BigStation.BarrelWasherSign = true; HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); GVL_BigStation.DosingRecipe4Time = DateTime.Now; HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); GVL_BigStation.Recipe4DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},下发完成"); } } else @@ -1809,7 +1650,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); GVL_BigStation.Recipe4DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},下发完成"); } } if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1) @@ -1817,12 +1658,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},洗桶复位"); } GVL_BigStation.Recipe4DosingStatus = 2; HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", false); StockBinParReset(); - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) { @@ -1832,67 +1673,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model } GVL_BigStation.Recipe4DosingFinish = true; GVL_BigStation.Recipe4DosingStatus = 3; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); - foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) - { - if (item.RawMaterialLocation == 1) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; - } - else if (item.RawMaterialLocation == 2) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; - } - else if (item.RawMaterialLocation == 3) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; - } - else if (item.RawMaterialLocation == 4) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; - } - else if (item.RawMaterialLocation == 5) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; - } - else if (item.RawMaterialLocation == 6) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; - } - else if (item.RawMaterialLocation == 7) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; - } - else if (item.RawMaterialLocation == 8) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; - } - else if (item.RawMaterialLocation == 9) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; - } - else if (item.RawMaterialLocation == 10) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; - } - else if (item.RawMaterialLocation == 11) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; - } - else if (item.RawMaterialLocation == 12) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; - } - else if (item.RawMaterialLocation == 13) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; - } - else if (item.RawMaterialLocation == 14) - { - item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; - } - } - if (SiemensDevice.IsConnected) + MessageNotify.GetInstance.ShowRunLog($"配方4,配方状态:{code}配料完成"); + ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + if (SiemensDevice.IsConnected && !GVL_BigStation.IsUseLocalRecipe) { FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; @@ -1906,30 +1689,27 @@ 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"); } FinishData.Ask_For_Finish = true; double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe4Time).TotalSeconds; FinishData.ProcessTime = Convert.ToInt16(a); SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); + MessageNotify.GetInstance.ShowRunLog($"配方4,{code}配方配料完成,将信号反馈给西门子"); } + HKDevice.HK_PLC_S7.Write("DB99.DBX1.7", true); + GVL_BigStation.Recipe4DosingStatus = 3; + } + if (GVL_BigStation.Recipe4DosingStatus == 3 && HKDevice.PlcRead.Recipe4DosingFinish == false) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX1.7", false); SiemensRecipeQueue4.TryDequeue(out code); - RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下 - if (!GVL_BigStation.IsUseLocalRecipe) - { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } - else + App.Current.Dispatcher.Invoke(() => { - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - }); - } + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); GVL_BigStation.Recipe4DosingStatus = 0; + MessageNotify.GetInstance.ShowRunLog($"配方4,{code}配方配料完成,复位plc配料完成信号"); } } } @@ -1950,39 +1730,25 @@ namespace BPASmartClient.JXJFoodBigStation.Model private void testRawMaterialNameData() { //RawMaterialsInfo = Json.Data.RawMaterial; - //foreach (var material in RawMaterialsInfo) - //{ - // if (!string.IsNullOrEmpty(material.RawMaterialName)) - // { - // if (!RawMaterialsNamePos.ContainsKey(material.RawMaterialName)) - // { - // RawMaterialsNamePos.Add(material.RawMaterialName, (short)material.RawMaterialLocation); - // } - // } - //} + /*foreach (var material in RawMaterialsInfo) + { + if (!string.IsNullOrEmpty(material.RawMaterialName)) + { + if (!RawMaterialsNamePos.ContainsKey(material.RawMaterialName)) + { + RawMaterialsNamePos.Add(material.RawMaterialName, (short)material.RawMaterialLocation); + } + } + }*/ if (RawMaterialsNamePos.Count == 14) { - for (int i = 0; i < typeof(StockBinName).GetProperties().Length; i++) + for (int i = 0; i < typeof(StockBinName).GetProperties().Length; i++) { PropertyInfo pro = GVL_BigStation.stockBinName.GetType().GetProperty(typeof(StockBinName).GetProperties()[i].Name); - RawMaterialsNamePos[i+1] = pro.GetValue(GVL_BigStation.stockBinName, null).ToString(); + RawMaterialsNamePos[i + 1] = pro.GetValue(GVL_BigStation.stockBinName, null).ToString(); } - /* RawMaterialsNamePos[1] = GVL_BigStation.stockBinName.RawMaterialName1; - RawMaterialsNamePos[2] = GVL_BigStation.stockBinName.RawMaterialName2; - RawMaterialsNamePos[3] = GVL_BigStation.stockBinName.RawMaterialName3; - RawMaterialsNamePos[4] = GVL_BigStation.stockBinName.RawMaterialName4; - RawMaterialsNamePos[5] = GVL_BigStation.stockBinName.RawMaterialName5; - RawMaterialsNamePos[6] = GVL_BigStation.stockBinName.RawMaterialName6; - RawMaterialsNamePos[7] = GVL_BigStation.stockBinName.RawMaterialName7; - RawMaterialsNamePos[8] = GVL_BigStation.stockBinName.RawMaterialName8; - RawMaterialsNamePos[9] = GVL_BigStation.stockBinName.RawMaterialName9; - RawMaterialsNamePos[10] = GVL_BigStation.stockBinName.RawMaterialName10; - RawMaterialsNamePos[11] = GVL_BigStation.stockBinName.RawMaterialName11; - RawMaterialsNamePos[12] = GVL_BigStation.stockBinName.RawMaterialName12; - RawMaterialsNamePos[13] = GVL_BigStation.stockBinName.RawMaterialName13; - RawMaterialsNamePos[14] = GVL_BigStation.stockBinName.RawMaterialName14;*/ } - else + else { RawMaterialsNamePos.TryAdd(1, GVL_BigStation.stockBinName.RawMaterialName1); RawMaterialsNamePos.TryAdd(2, GVL_BigStation.stockBinName.RawMaterialName2); @@ -2018,13 +1784,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model HardWareRawMaterialInfo.ElementAt(index).RawMaterialName = item.Value; HardWareRawMaterialInfo.ElementAt(index).RawMaterialChineseName = name; } - else if (num == -1) + else if (num == -1) { HardWareRawMaterialInfo.ElementAt(index).RawMaterialLocation = item.Key; HardWareRawMaterialInfo.ElementAt(index).RawMaterialName = ""; HardWareRawMaterialInfo.ElementAt(index).RawMaterialChineseName = ""; } } + + RawMaterialsInfo = HardWareRawMaterialInfo; } /// /// MES的物料名称和物料编码对应 @@ -2095,7 +1863,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 设备连接 西门子和海科PLC /// - public void DeviceConnectInit() + public void DeviceConnectInit() { GVL_BigStation.IsAllowHKPlcConnect = ConfigurationManager.AppSettings["HKPlc_Connect"].ToLower() == "true" ? true : false; GVL_BigStation.IsAllowSiemensConnect = ConfigurationManager.AppSettings["Siemens_Connect"].ToLower() == "true" ? true : false; @@ -2141,7 +1909,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } - public void ThreadInit() + public void ThreadInit() { ThreadManage.GetInstance().StartLong(new Action(() => { @@ -2238,16 +2006,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model } else { - if (GVL_BigStation.IsUseLocalRecipe) + /*if (GVL_BigStation.IsUseLocalRecipe) { LocalRecipeRecevice(); LocalRecipeDosing(); } else - { + {*/ ReceviceData(); RecipeInfoToHKPLC(); - } + /* }*/ } Thread.Sleep(10); }), "配方数据执行流程", true); @@ -2255,7 +2023,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 初始化变量复位 /// - public void VarResetInit() + public void VarResetInit() { LocalRecipeQueue1.Clear(); LocalRecipeQueue2.Clear(); @@ -2266,5 +2034,364 @@ namespace BPASmartClient.JXJFoodBigStation.Model SiemensRecipeQueue3.Clear(); SiemensRecipeQueue4.Clear(); } + public void RecipeDosing() + { + GVL_BigStation.AllowIssueRecipe[0] = HKDevice.PlcRead.IsAllowIssueRecipe1; + GVL_BigStation.AllowIssueRecipe[1] = HKDevice.PlcRead.IsAllowIssueRecipe2; + GVL_BigStation.AllowIssueRecipe[2] = HKDevice.PlcRead.IsAllowIssueRecipe3; + GVL_BigStation.AllowIssueRecipe[3] = HKDevice.PlcRead.IsAllowIssueRecipe4; + GVL_BigStation.ReceviceFinishRecipe[0] = HKDevice.PlcRead.ReceiveFinishRecipe1; + GVL_BigStation.ReceviceFinishRecipe[1] = HKDevice.PlcRead.ReceiveFinishRecipe2; + GVL_BigStation.ReceviceFinishRecipe[2] = HKDevice.PlcRead.ReceiveFinishRecipe3; + GVL_BigStation.ReceviceFinishRecipe[3] = HKDevice.PlcRead.ReceiveFinishRecipe4; + GVL_BigStation.DosingFinishRecipe[0] = HKDevice.PlcRead.Recipe1DosingFinish; + GVL_BigStation.DosingFinishRecipe[1] = HKDevice.PlcRead.Recipe2DosingFinish; + GVL_BigStation.DosingFinishRecipe[2] = HKDevice.PlcRead.Recipe3DosingFinish; + GVL_BigStation.DosingFinishRecipe[3] = HKDevice.PlcRead.Recipe4DosingFinish; + GVL_BigStation.IsTrayArrive[0] = HKDevice.PlcRead.Tray1InPlace; + GVL_BigStation.IsTrayArrive[1] = HKDevice.PlcRead.Tray2InPlace; + GVL_BigStation.IsTrayArrive[2] = HKDevice.PlcRead.Tray3InPlace; + GVL_BigStation.IsTrayArrive[3] = HKDevice.PlcRead.Tray4InPlace; + GVL_BigStation.IsTrayArrive[4] = HKDevice.PlcRead.Tray5InPlace; + #region 接收配方 + SiemensRecipes = Json.Data.Recipes; + if (SiemensRecipes.Count > 0) + { + foreach (var data in SiemensRecipes) + { + foreach (var item in SiemensRecipeQueue) + { + if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key-1]) + { + if (SiemensDevice.DL_Status is DL_Status_DB status) + { + switch (GVL_BigStation.SiemensSendRecipeStatus) + { + case 3: + SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给西门子"); + GVL_BigStation.SiemensSendRecipeStatus = 4; + break; + case 4: + if (SiemensDevice.DL_Status.Dosing_Start_ACK) + { + SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + MessageNotify.GetInstance.ShowRunLog($"配方1,西门子确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; + } + break; + case 5: + if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) + { + item.Value.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; + } + break; + default: + break; + } + } + } + } + } + } + else + { + SiemensRecipeQueue.Clear(); + GVL_BigStation.BarrelWasherSign = false; + for (int i = 0; i < GVL_BigStation.RecipeDosingStatus.Length; i++) + { + GVL_BigStation.RecipeDosingStatus[i] = 0; + } + } + #endregion + #region 取消配方 + if (GVL_BigStation.Order_Cancel) //订单取消 + { + if (!string.IsNullOrEmpty(GVL_BigStation.Order_CancelRecipeCode)) + { + string code = GVL_BigStation.Order_CancelRecipeCode; + int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == GVL_BigStation.Order_CancelRecipeCode); + short TrayCode = 0; + if (index >= 0) + { + TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode; + } + switch (GVL_BigStation.Order_CancelStep) + { + case 0: + if (index == -1) + { + GVL_BigStation.Order_CancelStep = 10; + } + else + { + GVL_BigStation.Order_CancelStep = 20; + foreach (var item in SiemensRecipeQueue) + { + if (item.Value.Contains(code)) + { + GVL_BigStation.Order_CancelStep = 30; + } + } + } + break; + case 10: + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + GVL_BigStation.Order_CancelStep = 11; + break; + case 11: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + GVL_BigStation.Order_CancelStep = 12; + } + break; + case 12: + MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{GVL_BigStation.Order_CancelRecipeCode}"); + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; + GVL_BigStation.Order_CancelStep = 0; + break; + + case 20: + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + GVL_BigStation.Order_CancelStep = 21; + break; + case 21: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + GVL_BigStation.Order_CancelStep = 22; + } + break; + case 22: + GVL_BigStation.SiemensSendRecipeStatus = 0; + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + MessageNotify.GetInstance.ShowRunLog($"正在执行请求订单流程,配方还未到PLC,订单号:{GVL_BigStation.Order_CancelRecipeCode}"); + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; + GVL_BigStation.Order_CancelStep = 0; + break; + + case 30: + foreach (var item in SiemensRecipeQueue) + { + if (item.Value.Contains(code)) + { + if (GVL_BigStation.RecipeDosingStatus[item.Key-1] != 0) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); + GVL_BigStation.RecipeDosingStatus[item.Key - 1] = 0; + item.Value.TryDequeue(out code); + GVL_BigStation.Order_CancelStep = 32; + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + else + { + GVL_BigStation.Order_CancelStep = 32; + MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); + } + } + } + break; + case 32: + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + GVL_BigStation.Order_CancelStep = 33; + break; + case 33: + if (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + GVL_BigStation.Order_CancelStep = 0; + MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); + } + break; + default: + break; + } + } + } + #endregion + #region 配料 + foreach (var data in SiemensRecipeQueue) + { + int index = Array.FindIndex(SiemensRecipes.ToArray(), p => p.RecipeCode == data.Value.ElementAt(0)); + if (index >= 0 && index < SiemensRecipes.Count) + { + string code = SiemensRecipes.ElementAt(index).RecipeCode; + int trayCode = SiemensRecipes.ElementAt(index).TrayCode; + if (GVL_BigStation.RecipeDosingStatus[data.Key] == 0 && GVL_BigStation.AllowIssueRecipe[data.Key] && GVL_BigStation.IsTrayArrive[trayCode - 1])//配方4是否允许下发配发 + { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据 + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true); + GVL_BigStation.RecipeDosingStatus[data.Key] = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + else + { + GVL_BigStation.RecipeDosingTime[data.Key] = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true); + GVL_BigStation.RecipeDosingStatus[data.Key] = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + if (GVL_BigStation.RecipeDosingStatus[data.Key] == 1 && GVL_BigStation.ReceviceFinishRecipe[data.Key]) + { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } + GVL_BigStation.RecipeDosingStatus[data.Key] = 2; + HKDevice.HK_PLC_S7.Write($"DB99.DBX0.{2 + data.Key}", true); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + } + if (GVL_BigStation.RecipeDosingStatus[data.Key] == 2 && GVL_BigStation.DosingFinishRecipe[data.Key]) + { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + } + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + ReadStockBinDosingWeight(SiemensRecipes.ElementAt(index)); + if (SiemensDevice.IsConnected) + { + FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; + for (int i = 0; i < FinishData.Material.Length; i++) + { + FinishData.Material[i] = new UDT1(); + } + for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + { + 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($"配方{data.Key},配方编号:{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.RecipeDosingTime[data.Key]).TotalSeconds; + FinishData.ProcessTime = Convert.ToInt16(a); + SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + MessageNotify.GetInstance.ShowRunLog($"{code}配方配料完成,将信号反馈给西门子"); + } + data.Value.TryDequeue(out code); + if (!GVL_BigStation.IsUseLocalRecipe) + { + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); + } + else + { + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); + } + HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", true); + GVL_BigStation.RecipeDosingStatus[data.Key] = 3; + } + if (GVL_BigStation.RecipeDosingStatus[data.Key] == 3 && GVL_BigStation.DosingFinishRecipe[data.Key] == false) + { + HKDevice.HK_PLC_S7.Write($"DB99.DBX1.{data.Key + 3}", false); + GVL_BigStation.RecipeDosingStatus[data.Key] = 0; + } + } + } + #endregion + } + /// + /// 读取配料完成时,每个料仓的配料重量 + /// + /// + public void ReadStockBinDosingWeight(RecipeData recipes) + { + foreach (var item in recipes.RawMaterial) + { + if (item.RawMaterialLocation == 1) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin1ActualWeight; + } + else if (item.RawMaterialLocation == 2) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin2ActualWeight; + } + else if (item.RawMaterialLocation == 3) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin3ActualWeight; + } + else if (item.RawMaterialLocation == 4) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin4ActualWeight; + } + else if (item.RawMaterialLocation == 5) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin5ActualWeight; + } + else if (item.RawMaterialLocation == 6) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin6ActualWeight; + } + else if (item.RawMaterialLocation == 7) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin7ActualWeight; + } + else if (item.RawMaterialLocation == 8) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin8ActualWeight; + } + else if (item.RawMaterialLocation == 9) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin9ActualWeight; + } + else if (item.RawMaterialLocation == 10) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin10ActualWeight; + } + else if (item.RawMaterialLocation == 11) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin11ActualWeight; + } + else if (item.RawMaterialLocation == 12) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin12ActualWeight; + } + else if (item.RawMaterialLocation == 13) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin13ActualWeight; + } + else if (item.RawMaterialLocation == 14) + { + item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; + } + } + } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs index dc05bc4f..9d1a21c9 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs @@ -44,5 +44,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// 原料数据 /// public ObservableCollection RawMaterial { get; set; } = new ObservableCollection(); + + public RecipeSource RecipesSource { get { return _mRecipesSource; } set { _mRecipesSource = value; OnPropertyChanged(); } } + private RecipeSource _mRecipesSource = RecipeSource.远程; + } + public enum RecipeSource + { + 本地, + 远程 } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/RecipeDosing.cs b/BPASmartClient.JXJFoodBigStation/Model/RecipeDosing.cs new file mode 100644 index 00000000..d55082c1 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/RecipeDosing.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model +{ + public class RecipeDosing + { + public string RecipeCode { get; set; } + public int RecipeTray { get; set; } + public int DosingStatus { get; set; } + + + public bool IsAllowIssue { get; set; } + public bool IsAGVArrive { get; set; } + public bool IsReceviceFinish { get; set; } + public bool IsDosingFinish { get; set; } + + public DateTime DosingStartTime { get; set; } + + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index 1456067a..2bc9ba0b 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -17,7 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens public bool IsConnected => Siemens_PLC_S7.IsConnected; public DL_Status_DB DL_Status = new DL_Status_DB(); - bool a = false; + bool printFirstLog = false; public void Init() { ThreadManage.GetInstance().StartLong(new Action(() => @@ -30,14 +30,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens //var res3 = this.Siemens_PLC_S7.ReadClass(2391); if (res != null && res is DL_Start_DB start) { - if (GVL_BigStation.Order_Request && GVL_BigStation.SiemensSendRecipeStatus == 0) + if (GVL_BigStation.SiemensSendRecipeStatus == 0) { - this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true); - MessageNotify.GetInstance.ShowRunLog($"向西门子请求订单"); - GVL_BigStation.SiemensSendRecipeStatus = 1; + if (GVL_BigStation.Order_Request) + { + this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true); + MessageNotify.GetInstance.ShowRunLog($"向西门子请求订单"); + GVL_BigStation.SiemensSendRecipeStatus = 1; + } + else + { + this.Siemens_PLC_S7.Write("DB2301.DBX330.0", false); + if (!printFirstLog) + { + printFirstLog = true; + MessageNotify.GetInstance.ShowRunLog($"plc不允许下发订单"); + } + } } if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 1) { + printFirstLog = false; ActionManage.GetInstance.Send("SiemensSendRecipe", start); this.Siemens_PLC_S7.Write("DB2301.DBX330.0", false); MessageNotify.GetInstance.ShowRunLog($"西门子下发订单:{start.RecipeCode}"); diff --git a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml index ae8c420d..e0d3a366 100644 --- a/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/HardwareStatusView.xaml @@ -374,7 +374,7 @@ @@ -386,7 +386,7 @@ - + @@ -568,7 +568,6 @@ - @@ -637,7 +636,7 @@ Foreground="#FF0084FF" Text=" 号仓" /> - + Style="{StaticResource ImageButtonStyle}">--> + + @@ -23,7 +25,8 @@ Width="200" Height="40" Margin="5,0,5,0" - Command="{Binding Tray1InPlace}" + Command="{Binding TrayInPlace}" + CommandParameter="1" Content="AGV到达工位1" FontSize="20" Panel.ZIndex="0" @@ -32,7 +35,8 @@ Width="200" Height="40" Margin="5,0,5,0" - Command="{Binding Tray2InPlace}" + Command="{Binding TrayInPlace}" + CommandParameter="2" Content="AGV到达工位2" FontSize="20" Panel.ZIndex="0" @@ -41,7 +45,8 @@ Width="200" Height="40" Margin="5,0,5,0" - Command="{Binding Tray3InPlace}" + Command="{Binding TrayInPlace}" + CommandParameter="3" Content="AGV到达工位3" FontSize="20" Panel.ZIndex="0" @@ -50,7 +55,8 @@ Width="200" Height="40" Margin="5,0,5,0" - Command="{Binding Tray4InPlace}" + Command="{Binding TrayInPlace}" + CommandParameter="4" Content="AGV到达工位4" FontSize="20" Panel.ZIndex="0" @@ -59,11 +65,71 @@ Width="200" Height="40" Margin="5,0,5,0" - Command="{Binding Tray5InPlace}" + Command="{Binding TrayInPlace}" + CommandParameter="5" Content="AGV到达工位5" FontSize="20" Panel.ZIndex="0" Style="{StaticResource ImageButtonStyle}"> + + + + + + + + + + + + + + - + + @@ -100,66 +167,66 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml index 1c3603c8..3c220ef4 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml @@ -159,11 +159,23 @@ + + + - @@ -822,7 +821,7 @@ - @@ -924,11 +923,11 @@ - - + diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml.cs b/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml.cs index a5099747..66464759 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeSendDownView.xaml.cs @@ -28,24 +28,24 @@ namespace BPASmartClient.JXJFoodBigStation.View private void RadioButtonCompelete_Click(object sender, RoutedEventArgs e) { - repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeCompelete; - repiceList.Visibility = Visibility.Visible; - repiceListMaking.Visibility = Visibility.Hidden; + //repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeCompelete; + //repiceList.Visibility = Visibility.Visible; + //repiceListMaking.Visibility = Visibility.Hidden; } private void RadioButtonWait_Click(object sender, RoutedEventArgs e) { - repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeWait; - repiceList.Visibility = Visibility.Visible; - repiceListMaking.Visibility = Visibility.Hidden; + //repiceList.ItemsSource = RecipeSendDownViewModel.UserTreeWait; + //repiceList.Visibility = Visibility.Visible; + //repiceListMaking.Visibility = Visibility.Hidden; } private void RadioButtonMaking_Click(object sender, RoutedEventArgs e) { - repiceListMaking.Visibility = Visibility.Visible; - repiceList.Visibility = Visibility.Hidden; + //repiceListMaking.Visibility = Visibility.Visible; + //repiceList.Visibility = Visibility.Hidden; } } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs index 2118adfb..cd1e96f6 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs @@ -12,6 +12,8 @@ using Microsoft.Toolkit.Mvvm.Input; using BPASmartClient.JXJFoodBigStation.Model; using BPASmartClient.JXJFoodBigStation.View; using System.Windows.Forms; +using BPASmartClient.JXJFoodBigStation.Model.HK_PLC; +using System.Reflection; namespace BPASmartClient.JXJFoodBigStation.ViewModel { @@ -19,101 +21,30 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel { public HardwareStatusViewModel() { - - for (int i = 6; i > 0; i--) - { - TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() - { - DeviceName = i.ToString(), - DeviceNum = i, - RunStatus = true, - Weight = new Random().Next(0, 100) - }); - } - for (int i = 7; i < 13; i++) + foreach (PropertyInfo mi in typeof(StockBinName).GetProperties()) { - BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() + object ab = GVL_BigStation.stockBinName.GetType().GetProperty(mi.Name).GetValue(GVL_BigStation.stockBinName, null); + if (mi.Name=="RawMaterialName1" || mi.Name == "RawMaterialName2" || mi.Name == "RawMaterialName3" || mi.Name == "RawMaterialName4" || mi.Name == "RawMaterialName5" || mi.Name == "RawMaterialName6" || mi.Name == "RawMaterialName7") { - DeviceName = i.ToString(), - DeviceNum = i, - RunStatus = false, - Weight = new Random().Next(0, 100) - }); - } - StartCommand = new RelayCommand((deviceName) => - { - if (deviceName != null) - { - var top = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); - if (top != null) - { - ActionManage.GetInstance.Send("StartTopDevice", deviceName); - } - var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); - if (bottom != null) + TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { - ActionManage.GetInstance.Send("StartBottomDevice", deviceName); - } + DeviceName = ab.ToString(), + DeviceNum = TopDeviceCurrentStatuses.Count + 1, + RunStatus = true, + Weight = new Random().Next(0, 100) + }); } - }); - StopCommand = new RelayCommand((deviceName) => - { - if (deviceName != null) + else { - var top = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); - if (top != null) - { - ActionManage.GetInstance.Send("StopTopDevice", deviceName); - } - var bottom = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); - if (bottom != null) + BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { - ActionManage.GetInstance.Send("StopBottomDevice", deviceName); - } + DeviceName = ab.ToString(), + DeviceNum = BottomDeviceCurrentStatuses.Count + 8, + RunStatus = false, + Weight = new Random().Next(0, 100) + }); } - }); - - UpdateRawMaterName = new RelayCommand((deviceName) => - { - ActionManage.GetInstance.CancelRegister("UpdateDeviceName"); - ActionManage.GetInstance.Register(new Action((res) => - { - if (res != null && res is string newName) - { - int cnt = Array.FindIndex(TopDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName); - if (cnt >= 0) - { - int index = Array.FindIndex(BottomDeviceCurrentStatuses.ToArray(), p => p.DeviceName == newName); - int index1 = Array.FindIndex(TopDeviceCurrentStatuses.ToArray(), p => p.DeviceName == newName); - if (index == -1 && index1 == -1) - { - var obj = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); - obj.DeviceName = newName; - } - else - { - System.Windows.Forms.MessageBox.Show("设备名称与其他名称冲突", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - else - { - int index = Array.FindIndex(TopDeviceCurrentStatuses.ToArray(), p => p.DeviceName == newName); - int index1 = Array.FindIndex(BottomDeviceCurrentStatuses.ToArray(), p => p.DeviceName == newName); - if (index == -1 && index1 == -1) - { - var obj = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == deviceName); - obj.DeviceName = newName; - } - else - { - System.Windows.Forms.MessageBox.Show("设备名称与其他名称冲突", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - } - }), "UpdateDeviceName"); - ChangeDeviceNameView view = new ChangeDeviceNameView(); - view.ShowDialog(); - }); + } } public ObservableCollection TopDeviceCurrentStatuses { get; set; } = new ObservableCollection(); public ObservableCollection BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection(); diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs index 44d109e2..4b9201b8 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs @@ -21,25 +21,21 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel { public ManualFlowViewModel() { - Tray1InPlace = new RelayCommand(() => + TrayInPlace = new RelayCommand((o) => { - GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(1, true); - }); - Tray2InPlace = new RelayCommand(() => - { - GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(2, true); - }); - Tray3InPlace = new RelayCommand(() => - { - GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(3, true); - }); - Tray4InPlace = new RelayCommand(() => - { - GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(4, true); + if (o != null) + { + byte loc = Convert.ToByte(o); + GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(loc, true); + } }); - Tray5InPlace = new RelayCommand(() => + TrayLeave = new RelayCommand((o) => { - GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(5, true); + if (o!=null) + { + byte loc = Convert.ToByte(o); + GVL_BigStation.AGVPutTray = GVL_BigStation.AGVPutTray.SetBitValue(loc, false); + } }); ClearTrayInPlace = new RelayCommand(() => { @@ -82,11 +78,8 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel StockBin14Name = GVL_BigStation.stockBinName.RawMaterialName14; }), "设备状态读取",true); } - public RelayCommand Tray1InPlace { get; set; } - public RelayCommand Tray2InPlace { get; set; } - public RelayCommand Tray3InPlace { get; set; } - public RelayCommand Tray4InPlace { get; set; } - public RelayCommand Tray5InPlace { get; set; } + public RelayCommand TrayInPlace { get; set; } + public RelayCommand TrayLeave { get; set; } public RelayCommand ClearTrayInPlace { get; set; } public RelayCommand ClearAllRecipe { get; set; } public static bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnStaticPropertyChanged(); } } @@ -94,34 +87,35 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public string CancelRecipeCode { get { return _CancelRecipeCode; } set { _CancelRecipeCode = value; OnPropertyChanged(); } } public string _CancelRecipeCode { get; set; } + public static string StockBin1Name { get { return _StockBin1Name; } set { _StockBin1Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin1Name { get; set; } + private static string _StockBin1Name { get; set; } public static string StockBin2Name { get { return _StockBin2Name; } set { _StockBin2Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin2Name { get; set; } + private static string _StockBin2Name { get; set; } public static string StockBin3Name { get { return _StockBin3Name; } set { _StockBin3Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin3Name { get; set; } + private static string _StockBin3Name { get; set; } public static string StockBin4Name { get { return _StockBin4Name; } set { _StockBin4Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin4Name { get; set; } + private static string _StockBin4Name { get; set; } public static string StockBin5Name { get { return _StockBin5Name; } set { _StockBin5Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin5Name { get; set; } + private static string _StockBin5Name { get; set; } public static string StockBin6Name { get { return _StockBin6Name; } set { _StockBin6Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin6Name { get; set; } + private static string _StockBin6Name { get; set; } public static string StockBin7Name { get { return _StockBin7Name; } set { _StockBin7Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin7Name { get; set; } + private static string _StockBin7Name { get; set; } public static string StockBin8Name { get { return _StockBin8Name; } set { _StockBin8Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin8Name { get; set; } + private static string _StockBin8Name { get; set; } public static string StockBin9Name { get { return _StockBin9Name; } set { _StockBin9Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin9Name { get; set; } + private static string _StockBin9Name { get; set; } public static string StockBin10Name { get { return _StockBin10Name; } set { _StockBin10Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin10Name { get; set; } + private static string _StockBin10Name { get; set; } public static string StockBin11Name { get { return _StockBin11Name; } set { _StockBin11Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin11Name { get; set; } + private static string _StockBin11Name { get; set; } public static string StockBin12Name { get { return _StockBin12Name; } set { _StockBin12Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin12Name { get; set; } + private static string _StockBin12Name { get; set; } public static string StockBin13Name { get { return _StockBin13Name; } set { _StockBin13Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin13Name { get; set; } + private static string _StockBin13Name { get; set; } public static string StockBin14Name { get { return _StockBin14Name; } set { _StockBin14Name = value; OnStaticPropertyChanged(); } } - public static string _StockBin14Name { get; set; } + private static string _StockBin14Name { get; set; } public RelayCommand CancelRecipeCommand { get; set; } public static event EventHandler StaticPropertyChanged; diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs index b1eaec92..f4e90230 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs @@ -46,6 +46,27 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel RecipeInfosView nrv = new RecipeInfosView(); nrv.ShowDialog(); }); + + //RefreshRecipe = new RelayCommand(() => + //{ + // foreach (var item in ProcessControl.GetInstance.RawMaterialsInfo) + // { + // RawMaterialNames.Add(item.RawMaterialName); + // } + + // foreach (var item in Json.Data.Recipes) + // { + // foreach (var tep in item.RawMaterial) + // { + // if (RawMaterialNames.Contains(tep.RawMaterialName)) + // { + // int index = Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == tep.RawMaterialName); + // tep.RawMaterialLocation = ProcessControl.GetInstance.RawMaterialsInfo.ElementAt(index).RawMaterialLocation; + // } + // } + // } + //}); + //模拟配方 //NewSimulateRecipe = new RelayCommand(() => //{ @@ -104,9 +125,12 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel // public RelayCommand NewSimulateRecipe { get; set; } public RelayCommand ClearAllRecipe { get; set; } public RelayCommand NewRecipe { get; set; } + public RelayCommand RefreshRecipe { get; set; } public bool IsUseLocalRecipe { get { return _isUseLocalRecipe; } set { _isUseLocalRecipe = value; OnPropertyChanged(); } } public bool _isUseLocalRecipe { get; set; } public RelayCommand RemoveCommand { get; set; } public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + + public ObservableCollection RawMaterialNames { get; set; } = new ObservableCollection(); } } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs index 4f9acbb1..0a6fc51b 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs @@ -3,6 +3,7 @@ using BPASmartClient.CustomResource.UserControls; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.Helper; using BPASmartClient.JXJFoodBigStation.Model; +using BPASmartClient.JXJFoodBigStation.Model.Siemens; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using System; @@ -44,9 +45,10 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName); if (res != null) { - if (!ProcessControl.GetInstance.LocalRecipes.Contains(res)) + if (!Json.Data.Recipes.Contains(res)) { - ProcessControl.GetInstance.LocalRecipes.Add(res); + res.RecipesSource = RecipeSource.本地; + Json.Data.Recipes.Add(res); MessageNotify.GetInstance.ShowRunLog($"手动下发配方:{recipeName}完成"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"配方下发完成"); } diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index 70aafb9e..249d610c 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -78,21 +78,21 @@ namespace BPASmartClient.JXJFoodSmallStation #region 配方管理菜单 ObservableCollection RecipeManage = new ObservableCollection(); - RecipeManage.Add(new SubMenumodel() - { - SubMenuName = "味魔方配方管理", - SubMenuPermission = new Permission[] { Permission.管理员 }, - AssemblyName = "BPASmartClient.JXJFoodSmallStation", - ToggleWindowPath = "View.RecipeSettingsView" - }); + //RecipeManage.Add(new SubMenumodel() + //{ + // SubMenuName = "味魔方配方管理", + // SubMenuPermission = new Permission[] { Permission.管理员 }, + // AssemblyName = "BPASmartClient.JXJFoodSmallStation", + // ToggleWindowPath = "View.RecipeSettingsView" + //}); - RecipeManage.Add(new SubMenumodel() - { - SubMenuName = "味魔方配方下发", - SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 }, - AssemblyName = "BPASmartClient.JXJFoodSmallStation", - ToggleWindowPath = "View.RecipeControlView" - }); + //RecipeManage.Add(new SubMenumodel() + //{ + // SubMenuName = "味魔方配方下发", + // SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 }, + // AssemblyName = "BPASmartClient.JXJFoodSmallStation", + // ToggleWindowPath = "View.RecipeControlView" + //}); RecipeManage.Add(new SubMenumodel() { SubMenuName = "本地配方管理", @@ -120,7 +120,7 @@ namespace BPASmartClient.JXJFoodSmallStation ObservableCollection ParSet = new ObservableCollection(); ParSet.Add(new SubMenumodel() { - SubMenuName = "柔性味魔方参数设置", + SubMenuName = "味魔方参数设置", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.DeviceMaterialParView" @@ -141,11 +141,19 @@ namespace BPASmartClient.JXJFoodSmallStation }); ParSet.Add(new SubMenumodel() { - SubMenuName = "原料与料仓对应设置", + SubMenuName = "原料与料仓管理", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.StockBinRawMaterialView" }); + ParSet.Add(new SubMenumodel() + { + SubMenuName = "西门子物料管理", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.JXJFoodSmallStation", + ToggleWindowPath = "View.BomOfMaterialView" + }); + MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", @@ -252,12 +260,19 @@ namespace BPASmartClient.JXJFoodSmallStation }); DeviceMonitor.Add(new SubMenumodel() { - SubMenuName = "变量监控", + SubMenuName = "Plc变量监控", SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.PlcVarMonitorView" }); DeviceMonitor.Add(new SubMenumodel() + { + SubMenuName = "流程变量监控", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.JXJFoodSmallStation", + ToggleWindowPath = "View.ProcessMonitorView" + }); + DeviceMonitor.Add(new SubMenumodel() { SubMenuName = "设备状态", SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj index f14324ad..6c3c8aaa 100644 --- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj +++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj @@ -26,6 +26,9 @@ + + Code + Code @@ -38,6 +41,10 @@ + + $(DefaultXamlRuntime) + Designer + $(DefaultXamlRuntime) diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterial.cs new file mode 100644 index 00000000..56606358 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterial.cs @@ -0,0 +1,21 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.Bom +{ + public class BomMaterial:ObservableObject + { + public int Count { get { return _count; } set { _count = value; OnPropertyChanged(); } } + public int _count { get; set; } + + public string MaterialCode { get { return _materialCode; }set { _materialCode = value;OnPropertyChanged(); } } + private string _materialCode=""; + + public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } } + private string _materialName=""; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs b/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs new file mode 100644 index 00000000..d7cacf1b --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Bom/BomMaterialData.cs @@ -0,0 +1,16 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.Bom +{ + public class BomMaterialData + { + public ObservableCollection Materials { get; set; } = new ObservableCollection(); + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcCommAttribute.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL/VarCommAttribute.cs similarity index 78% rename from BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcCommAttribute.cs rename to BPASmartClient.JXJFoodSmallStation/Model/GVL/VarCommAttribute.cs index 8d72460d..1e23d1d9 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL/PlcCommAttribute.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL/VarCommAttribute.cs @@ -7,9 +7,9 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodSmallStation.Model.GVL { [AttributeUsage(AttributeTargets.Property)] - public sealed class PlcCommAttribute:Attribute + public sealed class VarCommAttribute:Attribute { - public PlcCommAttribute(string address,string des) + public VarCommAttribute(string address,string des) { Address = address; Describe = des; diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index 3313406a..a35d57c1 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -1,4 +1,5 @@ -using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; +using BPASmartClient.JXJFoodSmallStation.Model.GVL; +using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; using BPASmartClient.JXJFoodSmallStation.Model.Siemens; using System; using System.Collections.Concurrent; @@ -16,181 +17,270 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public static GVL_SmallStation GetInstance => SmallStation ?? (SmallStation = new GVL_SmallStation()); private GVL_SmallStation() { } - public static PlcReadAddressDB3 plcReadDataDB3 { get; set; } = new PlcReadAddressDB3(); + public PlcReadAddressDB3 plcReadDataDB3 { get; set; } = new PlcReadAddressDB3(); + /// + /// 配料站料仓数目 + /// + public const int Max_DosingSotckBinNum = 15; + /// + /// 风送料仓数目 + /// + public const int Max_PowderSotckBinNum = 5; + + [VarComm("Global", "订单取消")] /// /// 订单取消 /// - public static bool Order_Cancel { get; set; } + public bool NotUseSmallDosing { get; set; } + + + [VarComm("Global", "订单取消")] /// - /// 取消订单的编号 + /// 订单取消 /// - public static string Order_CancelRecipeCode { get; set; } = ""; + public bool Order_Cancel { get; set; } + + [VarComm("Global", "订单取消的配方编号")] /// - /// 托盘1托盘到位 逻辑完成 + /// 订单取消的配方编号 /// - public static int Tray1LogicFinish { get; set; } = 0; + public string Order_CancelRecipeCode { get; set; } = ""; + + + [VarComm("Global", "柔性配料料仓配料情况")] /// - /// 托盘2托盘到位 逻辑完成 + /// 料仓配料情况 /// - public static int Tray2LogicFinish { get; set; } = 0; + public ushort StockBinDosing { get; set; } = 0; + + [VarComm("Global", "托盘1托盘到位情况0:未到位,1=AGV到位,2=托盘有货架,3=AGV取托盘完成")] /// - /// 托盘1有货架 + /// 托盘1托盘到位情况 /// - public static bool Station1HaveTray { get; set; } + public int Tray1LogicFinish { get; set; } = 0; + + [VarComm("Global", "托盘2托盘到位情况0:未到位,1=AGV到位,2=托盘有货架,3=AGV取托盘完成")] /// - /// 托盘2有货架 + /// 托盘2托盘到位 逻辑完成 + /// + public int Tray2LogicFinish { get; set; } = 0; + + [VarComm("Global", "托盘1有货架")] + /// + /// 托盘1有货架 /// - public static bool Station2HaveTray { get; set; } + public bool Station1HaveTray { get; set; } + + + [VarComm("Global", "托盘2有货架")] /// /// 托盘2有货架 /// - public static int nStep { get; set; } + public bool Station2HaveTray { get; set; } + + + [VarComm("Global", "托盘1传感器信号")] /// /// 托盘1传感器信号 /// - public static bool Station1Sensor { get; set; } + public bool Station1Sensor { get; set; } + + [VarComm("Global", "托盘2传感器信号")] /// /// 托盘2传感器信号 /// - public static bool Station2Sensor { get; set; } + public bool Station2Sensor { get; set; } + + + [VarComm("Global", "托盘1气缸信号")] /// /// 托盘1气缸信号 /// - public static bool Station1Cylinder { get; set; } + public bool Station1Cylinder { get; set; } + + [VarComm("Global", "托盘2气缸信号")] /// /// 托盘2气缸信号 /// - public static bool Station2Cylinder { get; set; } + public bool Station2Cylinder { get; set; } + + [VarComm("Global", "AGV放托盘1完成")] /// /// AGV放托盘1完成 /// - public static bool AGV_PutTray1Finish { get; set; } + public bool AGV_PutTray1Finish { get; set; } + + [VarComm("Global", "AGV取托盘1完成")] /// /// AGV取托盘1完成 /// - public static bool AGV_GetTray1Finish { get; set; } + public bool AGV_GetTray1Finish { get; set; } + [VarComm("Global", "AGV放托盘2完成")] + /// + /// AGV放托盘1完成 + /// + public bool AGV_PutTray2Finish { get; set; } - public static bool AGV_PutTray2Finish { get; set; } - public static bool AGV_GetTray2Finish { get; set; } + [VarComm("Global", "AGV取托盘2完成")] + /// + /// AGV取托盘2完成 + /// + public bool AGV_GetTray2Finish { get; set; } - public static bool CylinderReset { get; set; } + [VarComm("Global", "托盘1气缸复位")] /// - /// 配料站料仓数目 + /// 托盘1气缸复位 /// - public const int Max_DosingSotckBinNum = 15; + public bool CylinderReset { get; set; } + + [VarComm("Global", "发送给plc的心跳")] /// - /// 风送料仓数目 + /// 发送给plc的心跳 /// - public const int Max_PowderSotckBinNum = 5; public bool HeartBeatToPlc { get; set; } = false; + + [VarComm("Global", "来自plc的心跳")] + /// + /// 来自plc的心跳 + /// public bool HeartBeatFromPlc { get; set; } = false; + + [VarComm("Global", "是否允许西门子下发配方")] /// /// 是否允许西门子下发配方 /// - public static bool IsAllowSiemensSendRecipe { get; set; } = false; + public bool IsAllowSiemensSendRecipe { get; set; } = false; + + [VarComm("Global", "西门子下发配方状态0=等待下发配方 1=请求下发配方 2=接收配方 3=配方接收配方完成 4=请求配料 5=西门子确认开始配料 6=西门子确认开始配料信号复位")] /// /// 西门子下发配方状态 0:等待下发配方 1:请求下发配方 2:上位机接收配方 3:配方接收配方完成 4:上位机向西门子请求配料 5:西门子确认开始配料 6:西门子确认开始配料 信号复位 /// - public static int SiemensSendRecipeStatus { get; set; } = 0; + public int SiemensSendRecipeStatus { get; set; } = 0; + + [VarComm("Global", "配方1下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] /// - /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 + /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料 /// public int RecipeStatusIDTray1 { get; set; } = 0; - /// - /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 - /// - public int RecipeStatusIDTray2 { get; set; } = 0; + [VarComm("Global", "配方2下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料")] /// - /// Tray1的柔性味魔方配料标志(下发配方时,若柔性味魔方的状态=3,复位该状态) - /// - public bool DosingTray1 { get; set; } = false;//默认为true,初始时,判断柔性味魔方的状态。 - /// - /// Tray2的柔性味魔方配料标志 + /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方,正在配料 /// - public bool DosingTray2 { get; set; } = false; + public int RecipeStatusIDTray2 { get; set; } = 0; - public int DosingTray1Loc { get; set; } = 0; - public int DosingTray2Loc { get; set; } = 0; + [VarComm("Global", "当前配方正在配料位置")] /// /// 当前料仓的位置 /// public int StockInIsWork { get; set; } = 0; + + [VarComm("Global", "是否使用粉仓配料")] /// - /// 记录AGV进站送货的指令顺序 - /// - public int AgvDeliveryPosition { get; set; }= 0; - /// - /// 记录AGV进站取货的指令顺序 + /// 是否使用粉仓配料 /// - public int AgvPickUpPosition { get; set; } = 0; + public bool RequestOrder { get; set; } = false; + + [VarComm("Global", "是否使用粉仓配料")] /// - /// 是否使用粉仓 + /// 是否使用粉仓配料 /// public bool IsUseWindSend { get; set; } = false; + + [VarComm("Global", "粉仓正在配料")] /// - /// 风送配料完成标志 + /// 粉仓正在配料 /// - public bool WindSendDosingFinish { get; set; } = false; + public bool WindSendDosing { get; set; } = false; + /// - /// 顶升气缸的信号 + /// 所有气缸的信号 /// - public bool[] Cylinder_JackInfo = new bool[15]; + public bool[] Cylinder_JackInfo { get; set; } = new bool[30]; #region 本地模拟配方 + + [VarComm("Global", "是否使用本地模拟配方")] /// /// 是否使用本地模拟配方 /// public bool IsUseLocalRecipe { get; set; } + /// - /// 是否使用本地模拟订单+风送配方 + /// 配料时间 /// - public bool IsUseWindSendDosing { get; set; } - public static int test1 = 1; public DateTime time1; + + /// + /// 原料的名称和原料编号对应,Mes提供的信息 + /// + public ConcurrentDictionary RawMaterialsNameCode { get; set; } = new ConcurrentDictionary(); + + [VarComm("Global", "风送是否允许AGV到工站")] /// /// 风送是否允许AGV到工站 /// - public static bool WindSendAllowAGVPutGet { get; set; } = false; + public bool WindSendAllowAGVPutGet { get; set; } = false; + + [VarComm("Global", "粉料仓配料完成")] /// /// 粉料仓配料完成 /// - public static bool WindSendDosingComple { get; set; } = false; + public bool WindSendDosingComple { get; set; } = false; + + [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")] /// - /// 系统模式 + /// PLC的系统模式 DB44.DBX0.1 /// - public static bool SystemMode { get; set; } = false; + public bool PlcSystemMode { get; set; } = false; + + [VarComm("Global", "PLC的系统模式 DB44.DBX0.1")] /// - /// 系统状态 + /// 不使用15个料仓报警 /// - public static bool SystemStatus { get; set; } = false; + public bool DisEnableStockBinAlarm { get; set; } = false; + + [VarComm("Global", "PLC的系统自动启停 DB44.DBX0.0")] /// - /// 系统运行状态 + /// PLC的系统自动启停 DB44.DBX0.0 /// - public static bool SystemRunStatus { get; set; } = false; + public bool PlcSystemIsAutoRun { get; set; } = false; + + [VarComm("Global", "PLC的系统自动暂停/开始 DB44.DBX0.2")] /// - /// 系统运行状态 + /// PLC的系统自动暂停/开始 DB44.DBX0.2 /// - public static int Time { get; set; } = 1000; + public bool PlcSystemIsPause { get; set; } = false; + + [VarComm("Global", "延迟采集料仓的配料完成重量")] + /// + /// 延迟采集料仓的配料完成重量 + /// + public int Time { get; set; } = 1000; + + [VarComm("Global", "取消订单的步骤号")] /// /// 取消订单的步骤: 1-9:配料过程中配方1取消配方 10-19:配料过程中配方2取消配方 20-29:下发订单的过程中取消订单(订单未到达上位机) 30-39:下发订单的过程中取消订单(订单未到达PLC) /// - public static int OrderCancelStep = 0; + public int OrderCancelStep { get; set; } = 0; + [VarComm("Global", "机器人的状态")] /// /// 机器人的状态 /// - public static ushort RobotStatus = 0; + public ushort RobotStatus { get; set; } = 0; + + [VarComm("Global", "机器人的程序号")] /// - /// 机器人的状态 + /// 机器人的程序号 /// - public static byte RobotProgramNum = 0; + public byte RobotProgramNum { get; set; } = 0; #endregion } public enum IssueRecipeCondition diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs new file mode 100644 index 00000000..f47bd894 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/DataComm.cs @@ -0,0 +1,41 @@ +using BPASmartClient.Helper; +using BPASmartClient.Modbus; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC +{ + public class DataComm + { + public volatile static DataComm Instance; + public static DataComm GetInstance => Instance ?? (new DataComm()); + public DataComm() { } + /// + /// 是否允许配料 + /// + public bool IsAllowDosing { get { return _mIsAllowDosing; } set { _mIsAllowDosing = value; } } + private bool _mIsAllowDosing; + + public bool DosingFinishToPLC { get { return _mDosingFinishToPLC; } set { _mDosingFinishToPLC = value; } } + private bool _mDosingFinishToPLC; + + private int _mStockBinLocationToPLC; + public int StockBinLocationToPLC { get { return _mStockBinLocationToPLC; } set { _mStockBinLocationToPLC = value; } } + + public bool StatusSignToBPA { get { return _mStatusSignToBPA; } set { _mStatusSignToBPA = value; } } + private bool _mStatusSignToBPA; + + private int _mStockBinLocationToBPA; + public int StockBinLocationToBPA { get { return _mStockBinLocationToBPA; } set { _mStockBinLocationToBPA = value; } } + + private int _mBarrelNumToPLC; + public int BarrelNumToPLC { get { return _mBarrelNumToPLC; } set { _mBarrelNumToPLC = value; } } + + /*public ConcurrentDictionary DeviceLists = new ConcurrentDictionary();*/ + } + +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs index 6ccc889a..f03fda0e 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs @@ -30,9 +30,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC var res1 = this.HK_PLC_S7.ReadClass(3); if (res1 != null && res1 is PlcReadAddressDB3 data1) { - GVL_SmallStation.plcReadDataDB3 = data1; + GVL_SmallStation.GetInstance.plcReadDataDB3 = data1; } } + Thread.Sleep(10); }),"海科PLC设备状态",true); } ///// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceWrite.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceWrite.cs new file mode 100644 index 00000000..5ca62ab8 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceWrite.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC +{ + public class HKDeviceWrite + { + public string Address { get; set; } + public PlcVarType PlcVarType { get; set; } = PlcVarType.Bool; + public object Value { get; set; } + } + public enum PlcVarType + { + Bool, + Byte, + Int, + Dint, + Real, + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs index 3f025d9e..26f141b4 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs @@ -9,170 +9,170 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC { public class PlcReadAddressDB3 { - [PlcComm("DB3.DBX0.0","心跳")] + [VarComm("DB3.DBX0.0","心跳")] public bool HeartBeat { get; set; } - [PlcComm("DB3.DBX0.1", "备用1")] + [VarComm("DB3.DBX0.1", "备用1")] public bool Standby1 { get; set; } - [PlcComm("DB3.DBX0.2", "备用2")] + [VarComm("DB3.DBX0.2", "备用2")] public bool Standby2 { get; set; } - [PlcComm("DB3.DBX0.3", "备用3")] + [VarComm("DB3.DBX0.3", "备用3")] public bool Standby3 { get; set; } - [PlcComm("DB3.DBX0.4", "备用4")] + [VarComm("DB3.DBX0.4", "备用4")] public bool Standby4 { get; set; } - [PlcComm("DB3.DBX0.5", "备用5")] + [VarComm("DB3.DBX0.5", "备用5")] public bool Standby5 { get; set; } - [PlcComm("DB3.DBX0.6", "备用6")] + [VarComm("DB3.DBX0.6", "备用6")] public bool Standby6 { get; set; } - [PlcComm("DB3.DBX0.7", "工站1有托盘")] + [VarComm("DB3.DBX0.7", "工站1有托盘")] public bool WorkStation1HaveTray { get; set; } - [PlcComm("DB3.DBX1.0", "工站2有托盘")] + [VarComm("DB3.DBX1.0", "工站2有托盘")] public bool WorkStation2HaveTray { get; set; } - [PlcComm("DB3.DBX1.1", "工站1配料完成")] + [VarComm("DB3.DBX1.1", "工站1配料完成")] public bool WorkStation1DosingComplete { get; set; } - [PlcComm("DB3.DBX1.2", "工站2配料完成")] + [VarComm("DB3.DBX1.2", "工站2配料完成")] public bool WorkStation2DosingComplete { get; set; } - [PlcComm("DB3.DBX1.3", "工站1接收配方完成")] + [VarComm("DB3.DBX1.3", "工站1接收配方完成")] public bool WorkStation1ReceviceRecipeComplete { get; set; } - [PlcComm("DB3.DBX1.4", "工站2接收配方完成")] + [VarComm("DB3.DBX1.4", "工站2接收配方完成")] public bool WorkStation2ReceviceRecipeComplete { get; set; } - [PlcComm("DB3.DBX1.5", "工站1气缸报警")] + [VarComm("DB3.DBX1.5", "工站1气缸报警")] public bool WorkStation1CylinderAlarm { get; set; } - [PlcComm("DB3.DBX1.6", "工站2气缸报警")] + [VarComm("DB3.DBX1.6", "工站2气缸报警")] public bool WorkStation2CylinderAlarm { get; set; } - [PlcComm("DB3.DBX1.7", "允许配方1下发配方")] + [VarComm("DB3.DBX1.7", "允许配方1下发配方")] public bool AllowRecipe1Issue { get; set; } - [PlcComm("DB3.DBX2.0", "允许配方2下发配方")] + [VarComm("DB3.DBX2.0", "允许配方2下发配方")] public bool AllowRecipe2Issue { get; set; } - [PlcComm("DB3.DBX2.1", "工站1传感器信号")] + [VarComm("DB3.DBX2.1", "工站1传感器信号")] public bool WorkStation1Sensor { get; set; } - [PlcComm("DB3.DBX2.2", "工站2传感器信号")] + [VarComm("DB3.DBX2.2", "工站2传感器信号")] public bool WorkStation2Sensor { get; set; } - [PlcComm("DB3.DBX2.3", "工站1气缸信号,false=伸出")] + [VarComm("DB3.DBX2.3", "工站1气缸信号,false=伸出")] public bool WorkStation1Cylinder { get; set; } - [PlcComm("DB3.DBX2.4", "工站2气缸信号,false=伸出")] + [VarComm("DB3.DBX2.4", "工站2气缸信号,false=伸出")] public bool WorkStation2Cylinder { get; set; } - [PlcComm("DB3.DBX2.5", "工站1取消订单")] + [VarComm("DB3.DBX2.5", "工站1取消订单")] public bool WorkStation1OrderCancel { get; set; } - [PlcComm("DB3.DBX2.6", "工站2取消订单")] + [VarComm("DB3.DBX2.6", "工站2取消订单")] public bool WorkStation2OrderCancel { get; set; } - [PlcComm("DB3.DBX2.7", "备用7")] + [VarComm("DB3.DBX2.7", "备用7")] public bool Standby7 { get; set; } - [PlcComm("DB3.DBB3", "备用")] + [VarComm("DB3.DBB3", "备用")] public byte Standby81 { get; set; } - [PlcComm("DB3.DBB4", "备用")] + [VarComm("DB3.DBB4", "备用")] public byte Standby82 { get; set; } - [PlcComm("DB3.DBB5", "备用")] + [VarComm("DB3.DBB5", "备用")] public byte Standby83 { get; set; } - [PlcComm("DB3.DBW6", "备用")] + [VarComm("DB3.DBW6", "备用")] public int Standby9 { get; set; } - [PlcComm("DB3.DBD10", "工站1_1号桶的位置")] + [VarComm("DB3.DBD10", "工站1_1号桶的位置")] public float WorkStation1Barrel1Pos { get; set; } - [PlcComm("DB3.DBD14", "工站1_2号桶的位置")] + [VarComm("DB3.DBD14", "工站1_2号桶的位置")] public float WorkStation1Barrel2Pos { get; set; } - [PlcComm("DB3.DBD18", "工站1_3号桶的位置")] + [VarComm("DB3.DBD18", "工站1_3号桶的位置")] public float WorkStation1Barrel3Pos { get; set; } - [PlcComm("DB3.DBD22", "工站1_4号桶的位置")] + [VarComm("DB3.DBD22", "工站1_4号桶的位置")] public float WorkStation1Barrel4Pos { get; set; } - [PlcComm("DB3.DBD26", "工站2_1号桶的位置")] + [VarComm("DB3.DBD26", "工站2_1号桶的位置")] public float WorkStation2Barrel1Pos { get; set; } - [PlcComm("DB3.DBD30", "工站2_2号桶的位置")] + [VarComm("DB3.DBD30", "工站2_2号桶的位置")] public float WorkStation2Barrel2Pos { get; set; } - [PlcComm("DB3.DBD34", "工站2_3号桶的位置")] + [VarComm("DB3.DBD34", "工站2_3号桶的位置")] public float WorkStation2Barrel3Pos { get; set; } - [PlcComm("DB3.DBD38", "工站2_4号桶的位置")] + [VarComm("DB3.DBD38", "工站2_4号桶的位置")] public float WorkStation2Barrel4Pos { get; set; } - [PlcComm("DB3.DBD42", "备用")] + [VarComm("DB3.DBD42", "备用")] public int StandBy42 { get; set; } - [PlcComm("DB3.DBD46", "备用")] + [VarComm("DB3.DBD46", "备用")] public int StandBy46 { get; set; } - [PlcComm("DB3.DBX50.0", "工站1_1号桶允许配料")] + [VarComm("DB3.DBX50.0", "工站1_1号桶允许配料")] public bool WorkStation1Barrel1AllowDosing { get; set; } - [PlcComm("DB3.DB50.1", "工站1_2号桶允许配料")] + [VarComm("DB3.DB50.1", "工站1_2号桶允许配料")] public bool WorkStation1Barrel2AllowDosing { get; set; } - [PlcComm("DB3.DB50.2", "工站1_3号桶允许配料")] + [VarComm("DB3.DB50.2", "工站1_3号桶允许配料")] public bool WorkStation1Barrel3AllowDosing { get; set; } - [PlcComm("DB3.DB50.3", "工站1_4号桶允许配料")] + [VarComm("DB3.DB50.3", "工站1_4号桶允许配料")] public bool WorkStation1Barrel4AllowDosing { get; set; } - [PlcComm("DB3.DB50.4", "工站2_1号桶允许配料")] + [VarComm("DB3.DB50.4", "工站2_1号桶允许配料")] public bool WorkStation2Barrel1AllowDosing { get; set; } - [PlcComm("DB3.DB50.5", "工站2_2号桶允许配料")] + [VarComm("DB3.DB50.5", "工站2_2号桶允许配料")] public bool WorkStation2Barrel2AllowDosing { get; set; } - [PlcComm("DB3.DB50.6", "工站2_3号桶允许配料")] + [VarComm("DB3.DB50.6", "工站2_3号桶允许配料")] public bool WorkStation2Barrel3AllowDosing { get; set; } - [PlcComm("DB3.DB50.7", "工站2_4号桶允许配料")] + [VarComm("DB3.DB50.7", "工站2_4号桶允许配料")] public bool WorkStation2Barrel4AllowDosing { get; set; } - [PlcComm("DB3.DBD52", "备用")] + [VarComm("DB3.DBD52", "备用")] public int Standby15 { get; set; } - [PlcComm("DB3.DBD56", "备用")] + [VarComm("DB3.DBD56", "备用")] public int Standby16 { get; set; } - [PlcComm("DB3.DBD60", "备用")] + [VarComm("DB3.DBD60", "备用")] public int Standby17 { get; set; } - [PlcComm("DB3.DBD64", "备用")] + [VarComm("DB3.DBD64", "备用")] public int Standby18 { get; set; } - [PlcComm("DB3.DBD68", "备用")] + [VarComm("DB3.DBD68", "备用")] public int Standby19 { get; set; } - [PlcComm("DB3.DBD72", "备用")] + [VarComm("DB3.DBD72", "备用")] public int Standby20 { get; set; } - [PlcComm("DB3.DBD76", "备用")] + [VarComm("DB3.DBD76", "备用")] public int Standby21 { get; set; } - [PlcComm("DB3.DBD80", "备用")] + [VarComm("DB3.DBD80", "备用")] public int Standby22 { get; set; } - [PlcComm("DB3.DBD84", "备用")] + [VarComm("DB3.DBD84", "备用")] public int Standby23 { get; set; } - [PlcComm("DB3.DBD88", "备用")] + [VarComm("DB3.DBD88", "备用")] public int Standby24 { get; set; } - [PlcComm("DB3.DBD92", "备用")] + [VarComm("DB3.DBD92", "备用")] public int Standby25 { get; set; } - [PlcComm("DB3.DBD96", "备用")] + [VarComm("DB3.DBD96", "备用")] public int Standby26 { get; set; } - [PlcComm("DB3.DBX100.0", "机器人运行模式")] + [VarComm("DB3.DBX100.0", "机器人运行模式")] public bool RobotRunMode { get; set; } - [PlcComm("DB3.DBX100.1", "机器人自动运行")] + [VarComm("DB3.DBX100.1", "机器人自动运行")] public bool RobotAutoRun { get; set; } - [PlcComm("DB3.DBX100.2", "机器人停止")] + [VarComm("DB3.DBX100.2", "机器人停止")] public bool RobotStop { get; set; } - [PlcComm("DB3.DBX100.3", "机器人运行")] + [VarComm("DB3.DBX100.3", "机器人运行")] public bool RobotRun { get; set; } - [PlcComm("DB3.DBX100.4", "机器人运行报警")] + [VarComm("DB3.DBX100.4", "机器人运行报警")] public bool RobotRunAlarm { get; set; } - [PlcComm("DB3.DBX100.5", "机器人在原点")] + [VarComm("DB3.DBX100.5", "机器人在原点")] public bool RobotInHomed { get; set; } - [PlcComm("DB3.DBX100.6", "机器人备用")] + [VarComm("DB3.DBX100.6", "机器人备用")] public bool Standby30 { get; set; } - [PlcComm("DB3.DBX100.7", "机器人取空桶完成")] + [VarComm("DB3.DBX100.7", "机器人取空桶完成")] public bool RobotGetEmptyBarrelComplete { get; set; } - [PlcComm("DB3.DBX101.0", "机器人放空桶完成")] + [VarComm("DB3.DBX101.0", "机器人放空桶完成")] public bool RobotPutEmptyBarrelComplete { get; set; } - [PlcComm("DB3.DBX101.1", "机器人取满桶完成")] + [VarComm("DB3.DBX101.1", "机器人取满桶完成")] public bool RobotGetFullBarrelComplete { get; set; } - [PlcComm("DB3.DBX101.2", "机器人放满桶完成")] + [VarComm("DB3.DBX101.2", "机器人放满桶完成")] public bool RobotPutFullBarrelComplete { get; set; } - [PlcComm("DB3.DBX101.3", "备用")] + [VarComm("DB3.DBX101.3", "备用")] public bool Standby31 { get; set; } - [PlcComm("DB3.DBX101.4", "备用")] + [VarComm("DB3.DBX101.4", "备用")] public bool Standby32 { get; set; } - [PlcComm("DB3.DBX101.5", "备用")] + [VarComm("DB3.DBX101.5", "备用")] public bool Standby33 { get; set; } - [PlcComm("DB3.DBX101.6", "备用")] + [VarComm("DB3.DBX101.6", "备用")] public bool Standby34 { get; set; } - [PlcComm("DB3.DBX101.7", "备用")] + [VarComm("DB3.DBX101.7", "备用")] public bool Standby35 { get; set; } - [PlcComm("DB3.DBB102", "机器人运行的程序号")] + [VarComm("DB3.DBB102", "机器人运行的程序号")] public byte RobotProgramNum { get; set; } - [PlcComm("DB3.DBB103", "备用")] + [VarComm("DB3.DBB103", "备用")] public byte Standby36 { get; set; } - [PlcComm("DB3.DBB104", "备用")] + [VarComm("DB3.DBB104", "备用")] public byte Standby37 { get; set; } - [PlcComm("DB3.DBB105", "备用")] + [VarComm("DB3.DBB105", "备用")] public byte Standby38 { get; set; } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs new file mode 100644 index 00000000..e083e60c --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC +{ + public class PlcWriteAddressDB7 + { + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index ae5dbfd4..258093e6 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -43,6 +43,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); public HKDeviceStatus HKDevice = new HKDeviceStatus(); public WindSendDeviceStatus WindSendDevice = new WindSendDeviceStatus(); + + public ObservableCollection CommData { get; set; } = new ObservableCollection(); + public ObservableCollection ProcessVar { get; set; } = new ObservableCollection(); XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB(); /// /// 风送PLC的DB块 @@ -52,6 +55,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// 接收原料数据 /// public RecipeRawMaterial RawMaterial; + public DateTime StockBinAlarmTime = DateTime.Now; public string? HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; public string? Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; @@ -59,8 +63,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public void Init() { - plcVarMonitor(); + PlcVarMonitor(); StockBinNameWithPos(); + RawMaterialNameWithCode(); RegisterInit(); DeviceConnect(); //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 @@ -71,14 +76,24 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc; HKDevice.HK_PLC_S7.Write("DB4.DBX0.0", GVL_SmallStation.GetInstance.HeartBeatToPlc); GVL_SmallStation.GetInstance.HeartBeatFromPlc = HKDevice.HK_PLC_S7.Read("DB45.DBX0.0"); + if (DeviceInquire.GetInstance.devices.Count < 15 && HKDevice.IsConnected && Json.Data.Recipes.Count > 0 && GVL_SmallStation.GetInstance.DisEnableStockBinAlarm == false && DateTime.Now.Subtract(StockBinAlarmTime).TotalSeconds >= 60) + { + HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true); + App.Current.Dispatcher.Invoke(() => + { + MessageNotify.GetInstance.ShowDialog($"未读取到15个柔性味魔方料仓", DialogType.Error); + StockBinAlarmTime = DateTime.Now; + }); + HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false); + } } Thread.Sleep(200); }), "海科plc通信心跳", true); ThreadManage.GetInstance().StartLong(new Action(() => { - if (GVL_SmallStation.Order_Cancel) + if (GVL_SmallStation.GetInstance.Order_Cancel) { - CancelOrder();//订单取消 + CancelOrder();//订单取消,不执行配方流程 } else { @@ -89,20 +104,30 @@ namespace BPASmartClient.JXJFoodSmallStation.Model }), "小料站流程控制", true); ThreadManage.GetInstance().StartLong(new Action(() => { - Real_Time_Data(); + RealTimeData(); + foreach (var item in Json.Data.windSendRawMaterial) + { + if (GVL_SmallStation.GetInstance.RawMaterialsNameCode.ContainsKey(item.RawMaterialName)) + { + item.RawMaterialChineseName = GVL_SmallStation.GetInstance.RawMaterialsNameCode[item.RawMaterialName]; + } + else + { + item.RawMaterialChineseName = ""; + } + } Thread.Sleep(10); - }), "西门子PLC和小料站PLC的实时数据", true); + }), "西门子PLC和小料站PLC的实时数据交互流程", true); ThreadManage.GetInstance().StartLong(new Action(() => { - if (HKDevice.IsConnected) - { - ManualOpen(); - ManualClose(); - HKPlcRead(); - } + HKPlcRead(); + GetStatus(); Thread.Sleep(10); - }), "手动操作", true); + }), "海科PLC实时数据", true); } + /// + /// 气缸的传感器值 + /// private void GetStatus() { for (int i = 0; i < 8; i++) @@ -111,222 +136,83 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } for (int i = 0; i < 7; i++) { - GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read("DB5.DBX0." + i); + GVL_SmallStation.GetInstance.Cylinder_JackInfo[i + 8] = HKDevice.HK_PLC_S7.Read("DB5.DBX1." + i); } + GVL_SmallStation.GetInstance.Cylinder_JackInfo[20] = HKDevice.HK_PLC_S7.Read("DB5.DBX3.6");//进料桶气缸 + GVL_SmallStation.GetInstance.Cylinder_JackInfo[21] = HKDevice.HK_PLC_S7.Read("DB5.DBX3.7");//出料筒气缸1 + GVL_SmallStation.GetInstance.Cylinder_JackInfo[22] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.0");//出料筒气缸2 + GVL_SmallStation.GetInstance.Cylinder_JackInfo[23] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.1");//出料筒气缸3 + + GVL_SmallStation.GetInstance.Cylinder_JackInfo[24] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.2");//托盘1_1气缸 + GVL_SmallStation.GetInstance.Cylinder_JackInfo[25] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.3");//托盘1_2气缸 + GVL_SmallStation.GetInstance.Cylinder_JackInfo[26] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.4");//托盘2_1气缸 + GVL_SmallStation.GetInstance.Cylinder_JackInfo[27] = HKDevice.HK_PLC_S7.Read("DB5.DBX4.5");//托盘2_2气缸 } - private void ManualOpen() - { - ActionManage.GetInstance.Register(new Action((o) => - { - if (o != null) - { - if (o.ToString().Contains("升降气缸")) - { - int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); - if (index >= 1 && index <= 15) - { - string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1); - if (index == 8) address = "DB5.DBX0.7"; - HKDevice.HK_PLC_S7.Write(address, true); - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:true"); - } - } - else if (o.ToString().Contains("阻挡气缸")) - { - int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); - if (index >= 1 && index <= 15) - { - string address = ""; - if (index == 1) address = "DB5.DBX1.7"; - if (index == 2) address = "DB5.DBX2.0"; - if (index == 3) address = "DB5.DBX2.1"; - if (index == 4) address = "DB5.DBX2.2"; - if (index == 5) address = "DB5.DBX2.3"; - if (index == 6) address = "DB5.DBX2.4"; - if (index == 7) address = "DB5.DBX2.5"; - if (index == 8) address = "DB5.DBX2.6"; - if (index == 9) address = "DB5.DBX2.7"; - if (index == 10) address = "DB5.DBX3.0"; - if (index == 11) address = "DB5.DBX3.1"; - if (index == 12) address = "DB5.DBX3.2"; - if (index == 13) address = "DB5.DBX3.3"; - if (index == 14) address = "DB5.DBX3.4"; - if (index == 15) address = "DB5.DBX3.5"; - HKDevice.HK_PLC_S7.Write(address, true); - } - } - else if (o.ToString().Contains("进料桶顶升气缸")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", false);//默认顶升 - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:false"); - } - else if (o.ToString().Contains("出料桶顶升气缸1")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", true); - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:true"); - } - else if (o.ToString().Contains("出料桶顶升气缸2")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", true); - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:true"); - } - else if (o.ToString().Contains("出料桶顶升气缸3")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", true); - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:true"); - } - else if (o.ToString().Contains("托盘气缸1_1")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", false);//默认伸出 - } - else if (o.ToString().Contains("托盘气缸1_2")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", false); - } - else if (o.ToString().Contains("托盘气缸2_1")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", false); - } - else if (o.ToString().Contains("托盘气缸2_2")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", false); - } - } - }), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 - } - private void ManualClose() + /// + /// DB块的变量实时值 + /// + private void HKPlcRead() { - ActionManage.GetInstance.Register(new Action((o) => + if (HKDevice.IsConnected) { - if (o != null) + foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties()) { - if (o.ToString().Contains("升降气缸")) - { - int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); - if (index >= 1 && index <= 15) - { - string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1); - if (index == 8) address = "DB5.DBX0.7"; - HKDevice.HK_PLC_S7.Write(address, false); - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:false"); - } - } - else if (o.ToString().Contains("阻挡气缸")) - { - int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); - if (index >= 1 && index <= 15) - { - string address = ""; - if (index == 1) address = "DB5.DBX1.7"; - if (index == 2) address = "DB5.DBX2.0"; - if (index == 3) address = "DB5.DBX2.1"; - if (index == 4) address = "DB5.DBX2.2"; - if (index == 5) address = "DB5.DBX2.3"; - if (index == 6) address = "DB5.DBX2.4"; - if (index == 7) address = "DB5.DBX2.5"; - if (index == 8) address = "DB5.DBX2.6"; - if (index == 9) address = "DB5.DBX2.7"; - if (index == 10) address = "DB5.DBX3.0"; - if (index == 11) address = "DB5.DBX3.1"; - if (index == 12) address = "DB5.DBX3.2"; - if (index == 13) address = "DB5.DBX3.3"; - if (index == 14) address = "DB5.DBX3.4"; - if (index == 15) address = "DB5.DBX3.5"; - HKDevice.HK_PLC_S7.Write(address, false); - } - } - else if (o.ToString().Contains("进料桶顶升气缸")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", true); - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:true"); - } - else if (o.ToString().Contains("出料桶顶升气缸1")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", false); - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:false"); - } - else if (o.ToString().Contains("出料桶顶升气缸2")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", false); - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:false"); - } - else if (o.ToString().Contains("出料桶顶升气缸3")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", false); - MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:false"); - } - else if (o.ToString().Contains("托盘气缸1_1")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", true); - } - else if (o.ToString().Contains("托盘气缸1_2")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", true); - } - else if (o.ToString().Contains("托盘气缸2_1")) - { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", true); - } - else if (o.ToString().Contains("托盘气缸2_2")) + int index = Array.FindIndex(CommData.ToArray(), p => p.Name == item.Name); + if (index >= 0) { - HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", true); + CommData.ElementAt(index).Value = GVL_SmallStation.GetInstance.plcReadDataDB3.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance.plcReadDataDB3, null).ToString(); } } - }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 - } - public ObservableCollection CommData = new ObservableCollection(); - private void HKPlcRead() - { - foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties()) + } + foreach (PropertyInfo item in typeof(GVL_SmallStation).GetProperties()) { - int index = Array.FindIndex(CommData.ToArray(), p => p.Name == item.Name); + int index = Array.FindIndex(ProcessVar.ToArray(), p => p.Name == item.Name); if (index >= 0) { - CommData.ElementAt(index).Value = GVL_SmallStation.plcReadDataDB3.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.plcReadDataDB3, null).ToString(); + ProcessVar.ElementAt(index).Value = GVL_SmallStation.GetInstance.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance, null).ToString(); } } } /// /// 小料站和西门子PLC之间的实时数据 /// - private void Real_Time_Data() + private void RealTimeData() { if (HKDevice.IsConnected) { //获取系统状态 - GVL_SmallStation.SystemStatus = HKDevice.HK_PLC_S7.Read("DB44.DBX0.0");//系统启停 - GVL_SmallStation.SystemMode = HKDevice.HK_PLC_S7.Read("DB44.DBX0.1");//系统模式 - GVL_SmallStation.SystemRunStatus = HKDevice.HK_PLC_S7.Read("DB44.DBX0.2");//系统暂停 + GVL_SmallStation.GetInstance.PlcSystemIsAutoRun = HKDevice.HK_PLC_S7.Read("DB44.DBX0.0");//系统启停 + GVL_SmallStation.GetInstance.PlcSystemMode = HKDevice.HK_PLC_S7.Read("DB44.DBX0.1");//系统模式 + GVL_SmallStation.GetInstance.PlcSystemIsPause = HKDevice.HK_PLC_S7.Read("DB44.DBX0.2");//系统暂停 - GVL_SmallStation.Station1HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX0.7");//工站1 有货架 - GVL_SmallStation.Station2HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX1.0");//工站2 有货架 - if (GVL_SmallStation.WindSendDosingComple) + GVL_SmallStation.GetInstance.Station1HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX0.7");//工站1 有货架 + GVL_SmallStation.GetInstance.Station2HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX1.0");//工站2 有货架 + if (GVL_SmallStation.GetInstance.WindSendDosingComple) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.7", true); - GVL_SmallStation.WindSendDosingComple = false; + GVL_SmallStation.GetInstance.WindSendDosingComple = false; MessageNotify.GetInstance.ShowRunLog("风送配料完成信号,发给产线plc信号"); } if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.7", false); } - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7"))//允许下配方1或者允许下配方2 + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7") || GVL_SmallStation.GetInstance.RequestOrder)//允许下配方1或者允许下配方2 { - GVL_SmallStation.IsAllowSiemensSendRecipe = true; + GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe = true; } - GVL_SmallStation.Station1Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.1"); - GVL_SmallStation.Station2Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.2"); - GVL_SmallStation.Station1Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.3"); - GVL_SmallStation.Station2Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.4"); - GVL_SmallStation.RobotStatus = HKDevice.HK_PLC_S7.Read("DB3.DBW100"); - GVL_SmallStation.RobotProgramNum = HKDevice.HK_PLC_S7.Read("DB3.DBB102"); - + GVL_SmallStation.GetInstance.Station1Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.1"); + GVL_SmallStation.GetInstance.Station2Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.2"); + GVL_SmallStation.GetInstance.Station1Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.3"); + GVL_SmallStation.GetInstance.Station2Cylinder = HKDevice.HK_PLC_S7.Read("DB3.DBX2.4"); + GVL_SmallStation.GetInstance.RobotStatus = HKDevice.HK_PLC_S7.Read("DB3.DBW100"); + GVL_SmallStation.GetInstance.RobotProgramNum = HKDevice.HK_PLC_S7.Read("DB3.DBB102"); } if (SiemensDevice.IsConnected) { ushort TrayCylinder = 0; ushort TraySensor = 0; - if (GVL_SmallStation.Station1Sensor) + if (GVL_SmallStation.GetInstance.Station1Sensor) { TraySensor = TraySensor.SetBitValue(1, true); } @@ -334,7 +220,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { TraySensor = TraySensor.SetBitValue(0, false); } - if (!GVL_SmallStation.Station1Cylinder) + if (!GVL_SmallStation.GetInstance.Station1Cylinder) { TrayCylinder = TrayCylinder.SetBitValue(1, true); } @@ -342,63 +228,59 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { TrayCylinder = TrayCylinder.SetBitValue(0, false); } - this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.4", GVL_SmallStation.WindSendAllowAGVPutGet); + this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.4", GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet); this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW190", TraySensor);//添加工位传感器的信号 this.SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBW192", TrayCylinder);//添加工位气缸的信号 ushort AGV_Put = (ushort)SiemensDevice.XL_Status.AgvFinishPut; if (AGV_Put.Get16bitValue(1)) { - GVL_SmallStation.AGV_PutTray1Finish = true; + GVL_SmallStation.GetInstance.AGV_PutTray1Finish = true; } else { - GVL_SmallStation.AGV_PutTray1Finish = false; + GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false; } - - ushort AGV_Get = (ushort)SiemensDevice.XL_Status.AgvFinishGet; - - if (AGV_Get.Get16bitValue(1)) + if (AGV_Get.Get16bitValue(1)) { - GVL_SmallStation.AGV_GetTray1Finish = true; + GVL_SmallStation.GetInstance.AGV_GetTray1Finish = true; } - else + else { - GVL_SmallStation.AGV_GetTray1Finish = false; + GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false; } } } public void CancelOrder() { - if (GVL_SmallStation.Order_Cancel) //订单取消 + if (GVL_SmallStation.GetInstance.Order_Cancel) //订单取消 { - if (!string.IsNullOrEmpty(GVL_SmallStation.Order_CancelRecipeCode)) + if (!string.IsNullOrEmpty(GVL_SmallStation.GetInstance.Order_CancelRecipeCode)) { - string code = GVL_SmallStation.Order_CancelRecipeCode; + string code = GVL_SmallStation.GetInstance.Order_CancelRecipeCode; int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == code); - - switch (GVL_SmallStation.OrderCancelStep) + switch (GVL_SmallStation.GetInstance.OrderCancelStep) { case 0://前提条件判断 if (index == -1) { - GVL_SmallStation.OrderCancelStep = 30; + GVL_SmallStation.GetInstance.OrderCancelStep = 30; MessageNotify.GetInstance.ShowRunLog($"配方中并未找到订单{code}"); } else { - if (RecipeQueueTray1.Contains(GVL_SmallStation.Order_CancelRecipeCode)) + if (RecipeQueueTray1.Contains(GVL_SmallStation.GetInstance.Order_CancelRecipeCode)) { - GVL_SmallStation.OrderCancelStep = 1; + GVL_SmallStation.GetInstance.OrderCancelStep = 1; } - else if (RecipeQueueTray2.Contains(GVL_SmallStation.Order_CancelRecipeCode)) + else if (RecipeQueueTray2.Contains(GVL_SmallStation.GetInstance.Order_CancelRecipeCode)) { - GVL_SmallStation.OrderCancelStep = 10; + GVL_SmallStation.GetInstance.OrderCancelStep = 10; } else { - GVL_SmallStation.OrderCancelStep = 20; + GVL_SmallStation.GetInstance.OrderCancelStep = 20; } } break; @@ -410,34 +292,34 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; HKDevice.HK_PLC_S7.Write("DB4.DBX2.1", true); MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}"); - GVL_SmallStation.OrderCancelStep = 2; + GVL_SmallStation.GetInstance.OrderCancelStep = 2; } else { MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); - GVL_SmallStation.OrderCancelStep = 3; + GVL_SmallStation.GetInstance.OrderCancelStep = 3; } break; case 2: if (HKDevice.HK_PLC_S7.Read("DB3.DBX2.5")) { - if (GVL_SmallStation.Station1Cylinder == false) + if (GVL_SmallStation.GetInstance.Station1Cylinder == false) { GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; - GVL_SmallStation.OrderCancelStep = 3; + GVL_SmallStation.GetInstance.OrderCancelStep = 3; MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); } } break; case 3: SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - GVL_SmallStation.OrderCancelStep = 4; + GVL_SmallStation.GetInstance.OrderCancelStep = 4; break; case 4: if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) { SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); - GVL_SmallStation.OrderCancelStep = 9; + GVL_SmallStation.GetInstance.OrderCancelStep = 9; MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); } break; @@ -447,34 +329,32 @@ namespace BPASmartClient.JXJFoodSmallStation.Model Json.Data.Recipes.RemoveAt(index); }); RecipeQueueTray1.TryDequeue(out code); - GVL_SmallStation.Tray1LogicFinish = 0; - GVL_SmallStation.Order_Cancel = false; - GVL_SmallStation.Order_CancelRecipeCode = ""; - GVL_SmallStation.OrderCancelStep = 0; + GVL_SmallStation.GetInstance.Tray1LogicFinish = 0; + GVL_SmallStation.GetInstance.Order_Cancel = false; + GVL_SmallStation.GetInstance.Order_CancelRecipeCode = ""; + GVL_SmallStation.GetInstance.OrderCancelStep = 0; break; - - case 10: if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 != 0) { GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; HKDevice.HK_PLC_S7.Write("DB4.DBX2.2", true); MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}"); - GVL_SmallStation.OrderCancelStep = 11; + GVL_SmallStation.GetInstance.OrderCancelStep = 11; } else { MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); - GVL_SmallStation.OrderCancelStep = 12; + GVL_SmallStation.GetInstance.OrderCancelStep = 12; } break; case 11: if (HKDevice.HK_PLC_S7.Read("DB3.DBX2.6")) { - if (GVL_SmallStation.Station2Cylinder == false) + if (GVL_SmallStation.GetInstance.Station2Cylinder == false) { GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; - GVL_SmallStation.OrderCancelStep = 12; + GVL_SmallStation.GetInstance.OrderCancelStep = 12; MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); } } @@ -482,13 +362,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model case 12: SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - GVL_SmallStation.OrderCancelStep = 13; + GVL_SmallStation.GetInstance.OrderCancelStep = 13; break; case 13: if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) { SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); - GVL_SmallStation.OrderCancelStep = 14; + GVL_SmallStation.GetInstance.OrderCancelStep = 14; MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); } break; @@ -498,22 +378,22 @@ namespace BPASmartClient.JXJFoodSmallStation.Model Json.Data.Recipes.RemoveAt(index); }); RecipeQueueTray2.TryDequeue(out code); - GVL_SmallStation.Order_Cancel = false; - GVL_SmallStation.Tray2LogicFinish = 0; - GVL_SmallStation.Order_CancelRecipeCode = ""; - GVL_SmallStation.OrderCancelStep = 0; + GVL_SmallStation.GetInstance.Order_Cancel = false; + GVL_SmallStation.GetInstance.Tray2LogicFinish = 0; + GVL_SmallStation.GetInstance.Order_CancelRecipeCode = ""; + GVL_SmallStation.GetInstance.OrderCancelStep = 0; break; //20-29为订单还未下发至PLC case 20: SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - GVL_SmallStation.OrderCancelStep = 21; + GVL_SmallStation.GetInstance.OrderCancelStep = 21; break; case 21: if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) { SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); - GVL_SmallStation.OrderCancelStep = 29; + GVL_SmallStation.GetInstance.OrderCancelStep = 29; MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); } break; @@ -522,29 +402,29 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { Json.Data.Recipes.RemoveAt(index); }); - GVL_SmallStation.Order_Cancel = false; - GVL_SmallStation.Order_CancelRecipeCode = ""; - GVL_SmallStation.SiemensSendRecipeStatus = 0; - GVL_SmallStation.OrderCancelStep = 0; + GVL_SmallStation.GetInstance.Order_Cancel = false; + GVL_SmallStation.GetInstance.Order_CancelRecipeCode = ""; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0; + GVL_SmallStation.GetInstance.OrderCancelStep = 0; break; //30-39为订单还未下发至上位机 case 30: SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - GVL_SmallStation.OrderCancelStep = 31; + GVL_SmallStation.GetInstance.OrderCancelStep = 31; break; case 31: if (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) { SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); - GVL_SmallStation.OrderCancelStep = 39; + GVL_SmallStation.GetInstance.OrderCancelStep = 39; MessageNotify.GetInstance.ShowRunLog($"西门子取消订单完成,订单号:{code}"); } break; case 39: - GVL_SmallStation.Order_Cancel = false; - GVL_SmallStation.Order_CancelRecipeCode = ""; - GVL_SmallStation.OrderCancelStep = 0; + GVL_SmallStation.GetInstance.Order_Cancel = false; + GVL_SmallStation.GetInstance.Order_CancelRecipeCode = ""; + GVL_SmallStation.GetInstance.OrderCancelStep = 0; break; } } @@ -568,12 +448,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (SiemensDevice.XL_Status is XL_Status_DB status) { - switch (GVL_SmallStation.SiemensSendRecipeStatus) + switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus) { case 3: SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); - GVL_SmallStation.SiemensSendRecipeStatus = 4; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料"); break; case 4: @@ -581,20 +461,20 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串 SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); - GVL_SmallStation.SiemensSendRecipeStatus = 5; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料"); } break; case 5: if (SiemensDevice.XL_Status.Dosing_Confirm == false) { - GVL_SmallStation.SiemensSendRecipeStatus = 6; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成"); } break; case 6: RecipeQueueTray1.Enqueue(data.RecipeCode); - GVL_SmallStation.SiemensSendRecipeStatus = 0; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列"); break; default: @@ -609,12 +489,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (SiemensDevice.XL_Status is XL_Status_DB status) { - switch (GVL_SmallStation.SiemensSendRecipeStatus) + switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus) { case 3: SiemensDevice.Siemens_PLC_S7.WriteString(2231, data.RecipeCode, 10); SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", true); - GVL_SmallStation.SiemensSendRecipeStatus = 4; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 4; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},请求配料"); break; case 4: @@ -622,20 +502,20 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串 SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); - GVL_SmallStation.SiemensSendRecipeStatus = 5; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 5; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料"); } break; case 5: if (SiemensDevice.XL_Status.Dosing_Confirm == false) { - GVL_SmallStation.SiemensSendRecipeStatus = 6; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 6; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料信号复位完成"); } break; case 6: RecipeQueueTray2.Enqueue(data.RecipeCode); - GVL_SmallStation.SiemensSendRecipeStatus = 0; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列"); break; default: @@ -650,8 +530,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { RecipeQueueTray1.Clear(); RecipeQueueTray2.Clear(); - /*GVL_SmallStation.Tray1LogicFinish = 0; - GVL_SmallStation.Tray2LogicFinish = 0;*/ + /*GVL_SmallStation.GetInstance.Tray1LogicFinish = 0; + GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;*/ GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; } @@ -683,14 +563,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { RecipeQueueTray1.Clear(); RecipeQueueTray2.Clear(); - /*GVL_SmallStation.Tray1LogicFinish = 0; - GVL_SmallStation.Tray2LogicFinish = 0;*/ - - GVL_SmallStation.GetInstance.DosingTray1 = false; - GVL_SmallStation.GetInstance.DosingTray1Loc = 0; - - GVL_SmallStation.GetInstance.DosingTray2 = false; - GVL_SmallStation.GetInstance.DosingTray2Loc = 0; + /*GVL_SmallStation.GetInstance.Tray1LogicFinish = 0; + GVL_SmallStation.GetInstance.Tray2LogicFinish = 0;*/ GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; @@ -702,29 +576,29 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// private void RecipeInfoToHKPLC() { - switch (GVL_SmallStation.Tray1LogicFinish) + switch (GVL_SmallStation.GetInstance.Tray1LogicFinish) { case 0: - if (GVL_SmallStation.AGV_PutTray1Finish && RecipeQueueTray1.Count > 0) + if (GVL_SmallStation.GetInstance.AGV_PutTray1Finish && RecipeQueueTray1.Count > 0 && !GVL_SmallStation.GetInstance.NotUseSmallDosing) { HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true); - GVL_SmallStation.AGV_PutTray1Finish = false; - GVL_SmallStation.Tray1LogicFinish = 1; + GVL_SmallStation.GetInstance.AGV_PutTray1Finish = false; + GVL_SmallStation.GetInstance.Tray1LogicFinish = 1; MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc"); } break; case 1: - if (GVL_SmallStation.Station1HaveTray) + if (GVL_SmallStation.GetInstance.Station1HaveTray) { HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", false); - GVL_SmallStation.Tray1LogicFinish = 2; + GVL_SmallStation.GetInstance.Tray1LogicFinish = 2; MessageNotify.GetInstance.ShowRunLog("托盘1有货架"); } else { if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") == true) { - if (GVL_SmallStation.CylinderReset) + if (GVL_SmallStation.GetInstance.CylinderReset) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", true); } @@ -732,54 +606,55 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { - GVL_SmallStation.Tray1LogicFinish = 1; + GVL_SmallStation.GetInstance.Tray1LogicFinish = 1; HKDevice.HK_PLC_S7.Write("DB4.DBX1.5", false); } } break; case 2: - if (GVL_SmallStation.AGV_GetTray1Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0) + if (GVL_SmallStation.GetInstance.AGV_GetTray1Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", true); - GVL_SmallStation.Tray1LogicFinish = 3; - MessageNotify.GetInstance.ShowRunLog("AGV取托盘完成"); + GVL_SmallStation.GetInstance.Tray1LogicFinish = 3; + MessageNotify.GetInstance.ShowRunLog("AGV取托盘1完成,发送给海科信号后1s后复位"); } break; case 3: - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7") == true) + if (HKDevice.HK_PLC_S7.Read("DB4.DBX1.1") == true) { + Thread.Sleep(1000); HKDevice.HK_PLC_S7.Write("DB4.DBX1.1", false); - GVL_SmallStation.Tray1LogicFinish = 0; - GVL_SmallStation.AGV_GetTray1Finish = false; - MessageNotify.GetInstance.ShowRunLog("plc允许下配方,复位取托盘完成信号"); + GVL_SmallStation.GetInstance.Tray1LogicFinish = 0; + GVL_SmallStation.GetInstance.AGV_GetTray1Finish = false; + MessageNotify.GetInstance.ShowRunLog("AGV取托盘1完成,信号复位"); } break; default: break; } - switch (GVL_SmallStation.Tray2LogicFinish) + switch (GVL_SmallStation.GetInstance.Tray2LogicFinish) { case 0: - if (GVL_SmallStation.AGV_PutTray2Finish) + if (GVL_SmallStation.GetInstance.AGV_PutTray2Finish) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", true); - GVL_SmallStation.AGV_PutTray2Finish = false; - GVL_SmallStation.Tray2LogicFinish = 1; + GVL_SmallStation.GetInstance.AGV_PutTray2Finish = false; + GVL_SmallStation.GetInstance.Tray2LogicFinish = 1; MessageNotify.GetInstance.ShowRunLog("AGV到位 发送到位信号给plc"); } break; case 1: - if (GVL_SmallStation.Station2HaveTray) + if (GVL_SmallStation.GetInstance.Station2HaveTray) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.0", false); - GVL_SmallStation.Tray2LogicFinish = 2; + GVL_SmallStation.GetInstance.Tray2LogicFinish = 2; MessageNotify.GetInstance.ShowRunLog("托盘1有货架"); } else { if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.6") == true) { - if (GVL_SmallStation.CylinderReset) + if (GVL_SmallStation.GetInstance.CylinderReset) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.6", true); } @@ -787,30 +662,32 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { - GVL_SmallStation.Tray2LogicFinish = 1; + GVL_SmallStation.GetInstance.Tray2LogicFinish = 1; HKDevice.HK_PLC_S7.Write("DB4.DBX1.6", false); } } break; case 2: - if (GVL_SmallStation.AGV_GetTray2Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0) + if (GVL_SmallStation.GetInstance.AGV_GetTray2Finish && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0) { HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", true); - GVL_SmallStation.Tray2LogicFinish = 3; + GVL_SmallStation.GetInstance.Tray2LogicFinish = 3; } break; case 3: - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7") == true) + if (HKDevice.HK_PLC_S7.Read("DB4.DBX1.2") == true) { + Thread.Sleep(1000); HKDevice.HK_PLC_S7.Write("DB4.DBX1.2", false); - GVL_SmallStation.Tray2LogicFinish = 0; - GVL_SmallStation.AGV_GetTray2Finish = false; + GVL_SmallStation.GetInstance.Tray2LogicFinish = 0; + GVL_SmallStation.GetInstance.AGV_GetTray2Finish = false; } break; default: break; } - if (RecipeQueueTray1.Count > 0 && GVL_SmallStation.Tray1LogicFinish == 2) + #region 托盘1配料 + if (RecipeQueueTray1.Count > 0) /*&& GVL_SmallStation.GetInstance.Tray1LogicFinish == 2*/ //不需要等待AGV到位,就给PLC下发配方 { int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray1.ElementAt(0)); if (index >= 0 && index < RemoteRecipes.Count) @@ -821,11 +698,59 @@ namespace BPASmartClient.JXJFoodSmallStation.Model string windSend = RemoteRecipes.ElementAt(index).ToString(); if (trayCode == 1) { - if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0) + if (GVL_SmallStation.GetInstance.NotUseSmallDosing) + { + if (GVL_SmallStation.GetInstance.AGV_PutTray1Finish) + { + Thread.Sleep(5000); + var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); + if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe) + { + RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; + RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; + RecipeFinishInfo.Job_No = (short)trayCode; + for (int i = 0; i < 20; i++) + { + RecipeFinishInfo.Material[i] = new UDT1(); + } + for (int i = 0; i < 10; i++) + { + RecipeFinishInfo.Powder[i] = new UDT2(); + } + for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + { + RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001; + } + for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++) + { + RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight; + } + RecipeFinishInfo.Ask_For_Finish = true; + RecipeFinishInfo.DosingTime = 0; + SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); + + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子"); + } + else + { + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方"); + } + GVL_SmallStation.GetInstance.WindSendDosing = false; + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.Remove(res); + }); + RecipeQueueTray1.TryDequeue(out code); + } + } + else { - StockBinInit(); - if (GVL_SmallStation.GetInstance.IsUseWindSend) + //粉料仓下发配方 + if (GVL_SmallStation.GetInstance.IsUseWindSend && GVL_SmallStation.GetInstance.Tray1LogicFinish == 2 && GVL_SmallStation.GetInstance.WindSendDosing == false) { + GVL_SmallStation.GetInstance.WindSendDosing = true; WindSendData.TargetRecipeCode = code; WindSendData.IsAllowDosing = true; foreach (var item in RemoteRecipes.ElementAt(index).WindSend) @@ -853,388 +778,467 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData, 95); } - foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) - { - HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation); - } - HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true); - GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1; - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成"); - GVL_SmallStation.GetInstance.time1 = DateTime.Now; - } - - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false); - GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2; - MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成"); - } - if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2) - { - if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.0"))) - { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10"); - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) - { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg - if (loc_index >= 0) - { - DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量 - GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; - } - else - { - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方"); - } - GVL_SmallStation.GetInstance.DosingTray1 = true; - GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc; - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料"); - } - } - else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1"))) + if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 0) { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14"); - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) + StockBinInit(); + GVL_SmallStation.GetInstance.StockBinDosing = 0; + foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; - if (loc_index >= 0) - { - DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量 - GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; - } - else - { - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方"); - } - GVL_SmallStation.GetInstance.DosingTray1 = true; - GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc; - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料"); + HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation); + GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)item.RawMaterialLocation, true);//哪些仓位需要配料写入 } + HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true); + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 1; + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},下发完成"); + GVL_SmallStation.GetInstance.time1 = DateTime.Now; } - else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.2"))) + bool recipeReceviceFinish = HKDevice.HK_PLC_S7.Read("DB3.DBX1.3"); + if (recipeReceviceFinish && GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 1) { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18"); - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) - { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; - if (loc_index >= 0) - { - DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量 - GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; - } - else - { - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方"); - } - GVL_SmallStation.GetInstance.DosingTray1 = true; - GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc; - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料"); - } + HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", false); + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 2; + MessageNotify.GetInstance.ShowRunLog($"托盘1,{ recipeName}plc端 配方接收完成"); } - else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.3"))) + if (GVL_SmallStation.GetInstance.RecipeStatusIDTray1 == 2) { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22"); - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) + if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.0"))) { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; - if (loc_index >= 0) + var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10"); + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{res}料仓,允许配料"); + if (res > 0 && res is float loc) { - DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量 - GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; - } - else - { - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方"); + int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); + float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000;//单位g转换kg + if (weight <= 0) + { + int i = (int)loc; + if (i >= 1 && i <= 8) + { + string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo); + } + else if (i >= 9 && i <= 15) + { + string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo1); + } + GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false + } + else + { + if (loc_index >= 0) + { + DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//根据料仓编号 启动并写入每个原料重量 + GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + } + else + { + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,错误没有找到{(int)loc}号仓的配方"); + } + } + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},1号桶,{(int)loc}号仓,正在配料"); } - GVL_SmallStation.GetInstance.DosingTray1 = true; - GVL_SmallStation.GetInstance.DosingTray1Loc = (int)loc; - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料"); } - } - /* if (GVL_SmallStation.GetInstance.DosingTray1 && GVL_SmallStation.GetInstance.DosingTray1Loc > 0 && GVL_SmallStation.GetInstance.DosingTray1Loc < 16) - { - int i = GVL_SmallStation.GetInstance.DosingTray1Loc;*/ - for (int i = 1; i < 16; i++) - { - if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) + else if (RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1"))) { - int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); - if (res >= 0) + var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14"); + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料"); + if (res > 0 && res is float loc) { - Thread.Sleep(GVL_SmallStation.Time); - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成"); - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback; - bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}"); - float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000); - int iIndex = Array.FindIndex(Json.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName); - if (iIndex >= 0) + int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); + float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; + if (weight <= 0) { - if (Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange) + int i = (int)loc; + if (i >= 1 && i <= 8) { - HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true); - App.Current.Dispatcher.Invoke(() => - { - MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning); - HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false); - }); + string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo); } - } - /*if (info) - { - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功"); + else if (i >= 9 && i <= 15) + { + string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo1); + } + GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false } else { - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败"); - }*/ - if (i >= 1 && i <= 8) - { - string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); - MessageNotify.GetInstance.ShowRunLog(commInfo); - } - else if (i >= 9 && i <= 15) - { - string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); - MessageNotify.GetInstance.ShowRunLog(commInfo1); + if (loc_index >= 0) + { + DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量 + GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + } + else + { + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,错误没有找到{(int)loc}号仓的配方"); + } } - GVL_SmallStation.GetInstance.DosingTray1 = false; - GVL_SmallStation.GetInstance.DosingTray1Loc = 0; + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{(int)loc}号仓,正在配料"); } } - } - if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")))) - { - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); - MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成"); - foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) - { - MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g"); - } - if (SiemensDevice.IsConnected) + else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.2"))) { - RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; - RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; - RecipeFinishInfo.Job_No = (short)trayCode; - for (int i = 0; i < 20; i++) - { - RecipeFinishInfo.Material[i] = new UDT1(); - } - for (int i = 0; i < 10; i++) - { - RecipeFinishInfo.Powder[i] = new UDT2(); - } - for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) - { - RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001; - } - for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++) + var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18"); + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{res}料仓,允许配料"); + if (res > 0 && res is float loc) { - RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight; + int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); + float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; + if (weight <= 0) + { + int i = (int)loc; + if (i >= 1 && i <= 8) + { + string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo); + } + else if (i >= 9 && i <= 15) + { + string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo1); + } + GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false + } + else + { + if (loc_index >= 0) + { + DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量 + GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + } + else + { + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,错误没有找到{(int)loc}号仓的配方"); + } + } + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},3号桶,{(int)loc}号仓,正在配料"); } - double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds; - RecipeFinishInfo.Ask_For_Finish = true; - RecipeFinishInfo.DosingTime = Convert.ToInt16(a); - SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); } - App.Current.Dispatcher.Invoke(() => + else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.3"))) { - Json.Data.Recipes.Remove(res); - }); - RecipeQueueTray1.TryDequeue(out code); - HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false); - GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; - } - } - } - } - } - if (RecipeQueueTray2.Count > 0 && GVL_SmallStation.Tray2LogicFinish == 2) - { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray2.ElementAt(0)); - if (index >= 0 && index < RemoteRecipes.Count) - { - string code = RemoteRecipes.ElementAt(index).RecipeCode; - int trayCode = RemoteRecipes.ElementAt(index).TrayCode; - string recipeName = RemoteRecipes.ElementAt(index).RecipeName; - if (trayCode == 2) - { - if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0) - { - StockBinInit(); - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},初始化"); - foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) - { - HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation, 2); - } - HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true); - GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 1; - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},下发完成"); - } - - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.4") && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 1) - { - HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false); - GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 2; - MessageNotify.GetInstance.ShowRunLog($"配方:{recipeName},plc端 配方接收完成"); - } - if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 2) - { - if (RTrig.GetInstance("DB3.DBX50.4").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.4"))) - { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD26"); - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) - { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; - if (loc_index >= 0) + var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22"); + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{res}料仓,允许配料"); + if (res > 0 && res is float loc) { - DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量 - GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); + float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; + if (weight <= 0) + { + int i = (int)loc; + if (i >= 1 && i <= 8) + { + string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo); + } + else if (i >= 9 && i <= 15) + { + string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo1); + } + GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false + } + else + { + if (loc_index >= 0) + { + DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量 + GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + } + else + { + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,错误没有找到{(int)loc}号仓的配方"); + } + } + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},4号桶,{(int)loc}号仓,正在配料"); } - GVL_SmallStation.GetInstance.DosingTray2 = true; - GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc; - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成"); } - } - else if (RTrig.GetInstance("DB3.DBX50.5").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.5"))) - { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD30"); - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) + for (int i = 1; i < 16; i++) { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; - if (loc_index >= 0) + if ((DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) && GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i)) { - DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量 - GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); + if (res >= 0) + { + Thread.Sleep(GVL_SmallStation.GetInstance.Time); + RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback; + bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); + MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成,下料完成重量:{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}"); + float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000); + int iIndex = Array.FindIndex(Json.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName); + if (iIndex >= 0) + { + if (Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange) + { + HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true); + App.Current.Dispatcher.Invoke(() => + { + MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning); + HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false); + }); + } + } + if (i >= 1 && i <= 8) + { + string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo); + } + else if (i >= 9 && i <= 15) + { + string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); + MessageNotify.GetInstance.ShowRunLog(commInfo1); + } + } + GVL_SmallStation.GetInstance.StockBinDosing = GVL_SmallStation.GetInstance.StockBinDosing.SetBitValue((byte)i, false);//配料完成设备写成false } - GVL_SmallStation.GetInstance.DosingTray2 = true; - GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc; - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成"); } - } - else if (RTrig.GetInstance("DB3.DBX50.6").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.6"))) - { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD34"); - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) + if ((RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")))) { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; - if (loc_index >= 0) + if (GVL_SmallStation.GetInstance.StockBinDosing > 0) { - DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量 - GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + for (int i = 1; i < 17; i++) + { + if (GVL_SmallStation.GetInstance.StockBinDosing.Get16bitValue((byte)i)) + { + MessageNotify.GetInstance.ShowRunLog($"料仓配料完成,但存在料仓未配料:{i}号仓"); + } + } } - GVL_SmallStation.GetInstance.DosingTray2 = true; - GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc; - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成"); - } - } - else if (RTrig.GetInstance("DB3.DBX50.7").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.7"))) - { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD38"); - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) - { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; - if (loc_index >= 0) + var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); + foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) { - DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量 - GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + MessageNotify.GetInstance.ShowRunLog($"{item.RawMaterialName},下料重量:{item.Laying_Off_Weight}g"); } - GVL_SmallStation.GetInstance.DosingTray2 = true; - GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc; - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成"); - } - } - if (GVL_SmallStation.GetInstance.DosingTray2 == true && GVL_SmallStation.GetInstance.DosingTray1 == false && GVL_SmallStation.GetInstance.DosingTray2Loc > 0 && GVL_SmallStation.GetInstance.DosingTray2Loc < 16) - { - Thread.Sleep(GVL_SmallStation.Time); - int i = GVL_SmallStation.GetInstance.DosingTray2Loc; - if (RTrig.GetInstance("Tray2StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)) - { - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成"); - int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback; - bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); - float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight); - int iIndex = Array.FindIndex(Json.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName); - if (iIndex >= 0) + if (SiemensDevice.IsConnected && !GVL_SmallStation.GetInstance.IsUseLocalRecipe) { - if (Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange) + RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; + RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; + RecipeFinishInfo.Job_No = (short)trayCode; + for (int i = 0; i < 20; i++) { - HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true); - MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning); - HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false); + RecipeFinishInfo.Material[i] = new UDT1(); } - } - if (info) - { - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功"); + for (int i = 0; i < 10; i++) + { + RecipeFinishInfo.Powder[i] = new UDT2(); + } + for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + { + RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight * (float)0.001; + } + for (int i = 0; i < RemoteRecipes.ElementAt(index).WindSend.Count; i++) + { + RecipeFinishInfo.Powder[i].Powder_Weight = RemoteRecipes.ElementAt(index).WindSend.ElementAt(i).DosingCompleWeight; + } + double a = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.time1).TotalSeconds; + RecipeFinishInfo.Ask_For_Finish = true; + RecipeFinishInfo.DosingTime = Convert.ToInt16(a); + SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); + + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据反馈给西门子"); } else { - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败"); + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方{res.RecipeName},配料完成,数据无法反馈给西门子,西门子设备未连接或处于本地配方"); } - if (i >= 1 && i <= 8) + GVL_SmallStation.GetInstance.WindSendDosing = false; + App.Current.Dispatcher.Invoke(() => { - string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); - MessageNotify.GetInstance.ShowRunLog(commInfo); - } - else if (i >= 9 && i <= 15) - { - string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); - MessageNotify.GetInstance.ShowRunLog(commInfo1); - } - GVL_SmallStation.GetInstance.DosingTray2 = false; - GVL_SmallStation.GetInstance.DosingTray2Loc = 0; + Json.Data.Recipes.Remove(res); + }); + RecipeQueueTray1.TryDequeue(out code); + HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false); + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; } } - if (RTrig.GetInstance("DB3.DBX1.2").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.2"))) - { - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); - MessageNotify.GetInstance.ShowRunLog($"托盘2,配方{res.RecipeName},配料完成"); - RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; - RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; - for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) - { - RecipeFinishInfo.Material[i] = new UDT1(); - RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; - } - if (SiemensDevice.IsConnected) - { - RecipeFinishInfo.Ask_For_Finish = true; - SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); - } - App.Current.Dispatcher.Invoke(() => - { - Json.Data.Recipes.Remove(res); - }); - RecipeQueueTray2.TryDequeue(out code); - HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false); - GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; - } } } } } + #endregion + #region 托盘2配料 ---硬件不具备条件,不使用 + //if (RecipeQueueTray2.Count > 0 && GVL_SmallStation.GetInstance.Tray2LogicFinish == 2) + //{ + // int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray2.ElementAt(0)); + // if (index >= 0 && index < RemoteRecipes.Count) + // { + // string code = RemoteRecipes.ElementAt(index).RecipeCode; + // int trayCode = RemoteRecipes.ElementAt(index).TrayCode; + // string recipeName = RemoteRecipes.ElementAt(index).RecipeName; + // if (trayCode == 2) + // { + // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 0) + // { + // StockBinInit(); + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},初始化"); + // foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) + // { + // HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation, 2); + // } + // HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true); + // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 1; + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},下发完成"); + // } + + // if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.4") && GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 1) + // { + // HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false); + // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 2; + // MessageNotify.GetInstance.ShowRunLog($"配方:{recipeName},plc端 配方接收完成"); + // } + // if (GVL_SmallStation.GetInstance.RecipeStatusIDTray2 == 2) + // { + // if (RTrig.GetInstance("DB3.DBX50.4").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.4"))) + // { + // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD26"); + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{res}料仓,允许配料"); + // if (res > 0 && res is float loc) + // { + // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); + // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; + // if (loc_index >= 0) + // { + // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量 + // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + // } + // GVL_SmallStation.GetInstance.DosingTray2 = true; + // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc; + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},1号桶,{(int)loc}号仓,配料完成"); + // } + // } + // else if (RTrig.GetInstance("DB3.DBX50.5").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.5"))) + // { + // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD30"); + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{res}料仓,允许配料"); + // if (res > 0 && res is float loc) + // { + // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); + // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; + // if (loc_index >= 0) + // { + // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量 + // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + // } + // GVL_SmallStation.GetInstance.DosingTray2 = true; + // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc; + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},2号桶,{(int)loc}号仓,配料完成"); + // } + // } + // else if (RTrig.GetInstance("DB3.DBX50.6").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.6"))) + // { + // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD34"); + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{res}料仓,允许配料"); + // if (res > 0 && res is float loc) + // { + // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); + // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; + // if (loc_index >= 0) + // { + // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量 + // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + // } + // GVL_SmallStation.GetInstance.DosingTray2 = true; + // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc; + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},3号桶,{(int)loc}号仓,配料完成"); + // } + // } + // else if (RTrig.GetInstance("DB3.DBX50.7").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.7"))) + // { + // var res = HKDevice.HK_PLC_S7.Read("DB3.DBD38"); + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{res}料仓,允许配料"); + // if (res > 0 && res is float loc) + // { + // int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); + // double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; + // if (loc_index >= 0) + // { + // DeviceInquire.GetInstance.GetDevice((int)loc)?.Start((uint)weight);//启动并写入每个原料重量 + // GVL_SmallStation.GetInstance.StockInIsWork = (int)loc; + // } + // GVL_SmallStation.GetInstance.DosingTray2 = true; + // GVL_SmallStation.GetInstance.DosingTray2Loc = (int)loc; + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方:{recipeName},4号桶,{(int)loc}号仓,配料完成"); + // } + // } + // if (GVL_SmallStation.GetInstance.DosingTray2 == true && GVL_SmallStation.GetInstance.DosingTray1 == false && GVL_SmallStation.GetInstance.DosingTray2Loc > 0 && GVL_SmallStation.GetInstance.DosingTray2Loc < 16) + // { + // Thread.Sleep(GVL_SmallStation.GetInstance.Time); + // int i = GVL_SmallStation.GetInstance.DosingTray2Loc; + // if (RTrig.GetInstance("Tray2StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)) + // { + // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{recipeName},{i}号仓,配料完成"); + // int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); + // RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.NowWeightFeedback; + // bool info = DeviceInquire.GetInstance.GetDevice(i).StatusReset(); + // float AlarmRange = Math.Abs(RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight - RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight); + // int iIndex = Array.FindIndex(Json.Data.deviceParModels.ToArray(), p => p.MaterialName == DeviceInquire.GetInstance.GetDevice(i).DeviceName); + // if (iIndex >= 0) + // { + // if (Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange) < AlarmRange) + // { + // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", true); + // App.Current.Dispatcher.Invoke(() => + // { + // MessageNotify.GetInstance.ShowDialog($"{i}号仓配料误差过大,设置出料重量{ RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).RawMaterialWeight * 1000}g,实际出料重量{RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight}g,相差{AlarmRange}g,允许误差为{Math.Abs(Json.Data.deviceParModels.ElementAt(iIndex).ErrorRange)}g,请联系人工处理", DialogType.Warning); + // HKDevice.HK_PLC_S7.Write("DB44.DBX3.0", false); + // }); + // } + // } + // if (info) + // { + // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送成功"); + // } + // else + // { + // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方配料完成后复位 发送失败"); + // } + // if (i >= 1 && i <= 8) + // { + // string commInfo = HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true, 4); + // MessageNotify.GetInstance.ShowRunLog(commInfo); + // } + // else if (i >= 9 && i <= 15) + // { + // string commInfo1 = HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true, 4); + // MessageNotify.GetInstance.ShowRunLog(commInfo1); + // } + // GVL_SmallStation.GetInstance.DosingTray2 = false; + // GVL_SmallStation.GetInstance.DosingTray2Loc = 0; + // } + // } + // if (RTrig.GetInstance("DB3.DBX1.2").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.2"))) + // { + // var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); + // MessageNotify.GetInstance.ShowRunLog($"托盘2,配方{res.RecipeName},配料完成"); + // RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; + // RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; + // for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + // { + // RecipeFinishInfo.Material[i] = new UDT1(); + // RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + // RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + // RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + // } + // if (SiemensDevice.IsConnected) + // { + // RecipeFinishInfo.Ask_For_Finish = true; + // SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); + // } + // App.Current.Dispatcher.Invoke(() => + // { + // Json.Data.Recipes.Remove(res); + // }); + // RecipeQueueTray2.TryDequeue(out code); + // HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false); + // GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; + // } + // } + // } + // } + //} + #endregion } private void StockBinInit() { @@ -1246,24 +1250,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - private void DosingDevice(int Index, int DeviceID) - { - if (RTrig.GetInstance("Tray2StatusDevice" + DeviceID).Start(DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.RunStatus == 3)) - { - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{RemoteRecipes.ElementAt(Index).RecipeName},{DeviceID}号仓,配料完成"); - int res = Array.FindIndex(RemoteRecipes.ElementAt(Index).RawMaterial.ToArray(), p => p.RawMaterialLocation == DeviceID); - RemoteRecipes.ElementAt(Index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.CutWeightFeedback; - DeviceInquire.GetInstance.GetDevice(DeviceID).StatusReset(); - if (DeviceID >= 1 && DeviceID <= 8) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (DeviceID - 1), true); - } - else if (DeviceID >= 9 && DeviceID <= 15) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (DeviceID - 9), true); - } - } - } /// /// 料仓的位置和原料名称的对应 /// @@ -1281,23 +1267,212 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - public void plcVarMonitor() + /// + /// PLC的DB3变量列表 + /// + public void PlcVarMonitor() { foreach (PropertyInfo item in typeof(PlcReadAddressDB3).GetProperties()) { - CommData.Add(new PlcInfos() + if (Attribute.IsDefined(item, typeof(VarCommAttribute))) { - Count = CommData.Count + 1, - Name = item.Name, - Address = GVL_SmallStation.plcReadDataDB3.GetType().GetProperty(item.Name).GetCustomAttribute().Address, - Type = item.PropertyType.ToString(), - Describe = GVL_SmallStation.plcReadDataDB3.GetType().GetProperty(item.Name).GetCustomAttribute().Describe, - Value = GVL_SmallStation.plcReadDataDB3.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.plcReadDataDB3, null).ToString() - }); + CommData.Add(new PlcInfos() + { + Count = CommData.Count + 1, + Name = item.Name, + Address = item.GetCustomAttribute().Address, + Type = item.PropertyType.ToString(), + Describe = item.GetCustomAttribute().Describe, + Value = item.GetValue(GVL_SmallStation.GetInstance.plcReadDataDB3).ToString(), + }); + } + } + + foreach (PropertyInfo item in typeof(GVL_SmallStation).GetProperties()) + { + if (Attribute.IsDefined(item, typeof(VarCommAttribute))) + { + ProcessVar.Add(new PlcInfos() + { + Count = ProcessVar.Count + 1, + Name = item.Name, + Type = item.PropertyType.ToString(), + Address = item.GetCustomAttribute().Address, + Describe = item.GetCustomAttribute().Describe, + Value = item.GetValue(GVL_SmallStation.GetInstance).ToString() + }); + } } } public void RegisterInit() { + //手动控制气缸 DB5.DBX0.0~DB5.DBX4.5 + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null) + { + if (o.ToString().Contains("升降气缸")) + { + int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); + if (index >= 1 && index <= 15) + { + string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1); + if (index == 8) address = "DB5.DBX0.7"; + HKDevice.HK_PLC_S7.Write(address, true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:true"); + } + } + else if (o.ToString().Contains("阻挡气缸")) + { + int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); + if (index >= 1 && index <= 15) + { + string address = ""; + if (index == 1) address = "DB5.DBX1.7"; + if (index == 2) address = "DB5.DBX2.0"; + if (index == 3) address = "DB5.DBX2.1"; + if (index == 4) address = "DB5.DBX2.2"; + if (index == 5) address = "DB5.DBX2.3"; + if (index == 6) address = "DB5.DBX2.4"; + if (index == 7) address = "DB5.DBX2.5"; + if (index == 8) address = "DB5.DBX2.6"; + if (index == 9) address = "DB5.DBX2.7"; + if (index == 10) address = "DB5.DBX3.0"; + if (index == 11) address = "DB5.DBX3.1"; + if (index == 12) address = "DB5.DBX3.2"; + if (index == 13) address = "DB5.DBX3.3"; + if (index == 14) address = "DB5.DBX3.4"; + if (index == 15) address = "DB5.DBX3.5"; + HKDevice.HK_PLC_S7.Write(address, true); + } + } + else if (o.ToString().Contains("进料桶顶升气缸")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", false);//默认顶升 + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:false"); + } + else if (o.ToString().Contains("出料桶顶升气缸1")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:true"); + } + else if (o.ToString().Contains("出料桶顶升气缸2")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:true"); + } + else if (o.ToString().Contains("出料桶顶升气缸3")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:true"); + } + else if (o.ToString().Contains("托盘气缸1_1")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", false);//默认伸出 + } + else if (o.ToString().Contains("托盘气缸1_2")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", false); + } + else if (o.ToString().Contains("托盘气缸2_1")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", false); + } + else if (o.ToString().Contains("托盘气缸2_2")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", false); + } + } + }), "ManualOpen", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null) + { + if (o.ToString().Contains("升降气缸")) + { + int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); + if (index >= 1 && index <= 15) + { + string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1); + if (index == 8) address = "DB5.DBX0.7"; + HKDevice.HK_PLC_S7.Write(address, false); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:false"); + } + } + else if (o.ToString().Contains("阻挡气缸")) + { + int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); + if (index >= 1 && index <= 15) + { + string address = ""; + if (index == 1) address = "DB5.DBX1.7"; + if (index == 2) address = "DB5.DBX2.0"; + if (index == 3) address = "DB5.DBX2.1"; + if (index == 4) address = "DB5.DBX2.2"; + if (index == 5) address = "DB5.DBX2.3"; + if (index == 6) address = "DB5.DBX2.4"; + if (index == 7) address = "DB5.DBX2.5"; + if (index == 8) address = "DB5.DBX2.6"; + if (index == 9) address = "DB5.DBX2.7"; + if (index == 10) address = "DB5.DBX3.0"; + if (index == 11) address = "DB5.DBX3.1"; + if (index == 12) address = "DB5.DBX3.2"; + if (index == 13) address = "DB5.DBX3.3"; + if (index == 14) address = "DB5.DBX3.4"; + if (index == 15) address = "DB5.DBX3.5"; + HKDevice.HK_PLC_S7.Write(address, false); + } + } + else if (o.ToString().Contains("进料桶顶升气缸")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:true"); + } + else if (o.ToString().Contains("出料桶顶升气缸1")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", false); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:false"); + } + else if (o.ToString().Contains("出料桶顶升气缸2")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", false); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:false"); + } + else if (o.ToString().Contains("出料桶顶升气缸3")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", false); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:false"); + } + else if (o.ToString().Contains("托盘气缸1_1")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.2", true); + } + else if (o.ToString().Contains("托盘气缸1_2")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.3", true); + } + else if (o.ToString().Contains("托盘气缸2_1")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.4", true); + } + else if (o.ToString().Contains("托盘气缸2_2")) + { + HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", true); + } + } + }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 + //手动控制电机轴 DB5.DBX4.6~DB5.DBX5.2 + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", true); }), "StartAxisLoadCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", false); }), "StopAxisLoadCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", true); }), "StartAxisMidCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", false); }), "StopAxisMidCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", true); }), "StartAxisUnLoadCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", false); }), "StopAxisUnLoadCommand", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", true); }), "StartAxis1Command", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", false); }), "StopAxis1Command", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", true); }), "StartAxis2Command", true); + ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", false); }), "StopAxis2Command", true); + //西门子配方处理 ActionManage.GetInstance.Register(new Action((res) => { @@ -1385,15 +1560,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model // RecipeFinishInfo.Powder[i].Powder_Name = recipe.RawMaterial.ElementAt(i).RawMaterialName; // RecipeFinishInfo.Powder[i].Powder_Weight = recipe.RawMaterial.ElementAt(i).Laying_Off_Weight; // } - // if (GVL_SmallStation.SiemensSendRecipeStatus == 6) + // if (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus == 6) // { - // GVL_SmallStation.SiemensSendRecipeStatus = 7; + // GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 7; // RecipeFinishInfo.Ask_For_Finish = true; // SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 2261); // } // } // } }), "SiemensRecipeFinish", true); + + //将本地配方发送到西门子配方里,执行配料 ActionManage.GetInstance.Register(new Action((res) => { if (res != null && res is RemoteRecipeData recipe) @@ -1401,12 +1578,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model Json.Data.Recipes.Add(recipe); } }), "LocalSimulationRecipeIssue", true); - ActionManage.GetInstance.Register(new Action(() => - { - Json.Data.Recipes.Clear(); - GVL_SmallStation.SiemensSendRecipeStatus = 0; - MessageNotify.GetInstance.ShowRunLog("系统流程复位,等待西门子重新下发订单"); - }), "BPASystemReset", true); + //手动控制系统模式 ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", true); }), "SystemStart", true); ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", false); }), "SystemStop", true); @@ -1418,37 +1590,78 @@ namespace BPASmartClient.JXJFoodSmallStation.Model ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.3", true); }), "ManualSystemReset", true); ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.4", true); }), "CLearRecipeInfo", true); ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB4.DBX0.7", true); }), "AGVPutTrayFinish", true); - //手动控制电机轴 - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", true); }), "StartAxisLoadCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.6", false); }), "StopAxisLoadCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", true); }), "StartAxisMidCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX4.7", false); }), "StopAxisMidCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", true); }), "StartAxisUnLoadCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.0", false); }), "StopAxisUnLoadCommand", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", true); }), "StartAxis1Command", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.1", false); }), "StopAxis1Command", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", true); }), "StartAxis2Command", true); - ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB5.DBX5.2", false); }), "StopAxis2Command", true); + ActionManage.GetInstance.Register(new Action(() => + { + Json.Data.Recipes.Clear(); + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 0; + + GVL_SmallStation.GetInstance.Order_Cancel = false; + GVL_SmallStation.GetInstance.Order_CancelRecipeCode = ""; + GVL_SmallStation.GetInstance.OrderCancelStep = 0; + + RecipeQueueTray1.Clear(); + RecipeQueueTray2.Clear(); + GVL_SmallStation.GetInstance.RecipeStatusIDTray1 = 0; + GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; + GVL_SmallStation.GetInstance.Tray1LogicFinish = 0; + GVL_SmallStation.GetInstance.Tray2LogicFinish = 0; + StockBinInit(); + MessageNotify.GetInstance.ShowRunLog("系统流程复位,等待西门子重新下发订单"); + }), "BPASystemReset", true); + + //往海科PLC写值 + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is HKDeviceWrite data) + { + if (data.PlcVarType == PlcVarType.Bool) + { + bool value = (bool)data.Value; + HKDevice.HK_PLC_S7.Write(data.Address , value); + } + else if (data.PlcVarType == PlcVarType.Byte) + { + byte value = (byte)data.Value; + HKDevice.HK_PLC_S7.Write(data.Address, value); + } + else if (data.PlcVarType == PlcVarType.Int) + { + short value = (short)data.Value; + HKDevice.HK_PLC_S7.Write(data.Address, value); + } + else if (data.PlcVarType == PlcVarType.Dint) + { + int value = (int)data.Value; + HKDevice.HK_PLC_S7.Write(data.Address, value); + } + else if (data.PlcVarType == PlcVarType.Real) + { + float value = (float)data.Value; + HKDevice.HK_PLC_S7.Write(data.Address, value); + } + } + }), "PLCWrite", true); + //电机速度 ActionManage.GetInstance.Register(new Action((o) => { if (o != null && o is short value) { - HKDevice.HK_PLC_S7.Write("DB47.DBD8", value); + HKDevice.HK_PLC_S7.Write("DB47.DBW8", value); } }), "AxisLoadSpeedSet", true); ActionManage.GetInstance.Register(new Action((o) => { if (o != null && o is short value) { - HKDevice.HK_PLC_S7.Write("DB47.DBD10", value); + HKDevice.HK_PLC_S7.Write("DB47.DBW10", value); } }), "AxisMidSpeedSet", true); ActionManage.GetInstance.Register(new Action((o) => { if (o != null && o is short value) { - HKDevice.HK_PLC_S7.Write("DB47.DBD12", value); + HKDevice.HK_PLC_S7.Write("DB47.DBW12", value); } }), "AxisUnLoadSpeedSet", true); ActionManage.GetInstance.Register(new Action((o) => @@ -1466,7 +1679,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } }), "Axis2SpeedSet", true); - + //机器人的操作 ActionManage.GetInstance.Register(new Action((o) => { if (o != null && o is string address) @@ -1581,5 +1794,88 @@ namespace BPASmartClient.JXJFoodSmallStation.Model Thread.Sleep(50); }), "设备连接", true); } + + private void DosingDevice(int Index, int DeviceID) + { + if (RTrig.GetInstance("Tray2StatusDevice" + DeviceID).Start(DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.RunStatus == 3)) + { + MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘2,配方:{RemoteRecipes.ElementAt(Index).RecipeName},{DeviceID}号仓,配料完成"); + int res = Array.FindIndex(RemoteRecipes.ElementAt(Index).RawMaterial.ToArray(), p => p.RawMaterialLocation == DeviceID); + RemoteRecipes.ElementAt(Index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(DeviceID).deviceStatus.CutWeightFeedback; + DeviceInquire.GetInstance.GetDevice(DeviceID).StatusReset(); + if (DeviceID >= 1 && DeviceID <= 8) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (DeviceID - 1), true); + } + else if (DeviceID >= 9 && DeviceID <= 15) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (DeviceID - 9), true); + } + } + } + public void RawMaterialNameWithCode() + { + GVL_SmallStation.GetInstance.RawMaterialsNameCode.Clear(); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0001", "色拉油"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0002", "一级菜油"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0003", "菜籽油"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0004", "青花椒油"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0005", "卤牛肉丁"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0006", "冻鸡肉丁"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0007", "香菇丁"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0008", "高水分糍粑海椒"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0009", "低水分糍粑海椒"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0010", "辣豆瓣"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0011", "整豆豉"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0012", "豆豉细粒"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0013", "卤黄豆"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0014", "野山椒粒"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0015", "竹笋丁"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0016", "香辣酱辣椒酱"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0017", "芽菜粒"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0018", "榨菜丁"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0019", "盐菜"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0020", "洋葱丁"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0021", "番茄酱"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0022", "甜豆瓣"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0023", "甜面酱"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0024", "芝麻酱"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0025", "炸花生"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0026", "盐渍青椒丁"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0027", "备料剁红椒"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0028", "萝卜丁"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0029", "油芝麻"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0030", "生姜"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0031", "大蒜"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0032", "榨菜酱"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0033", "炸碗豆"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0034", "大头菜丁"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0035", "酱油"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0036", "I+G"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0037", "味精"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0038", "白糖"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0039", "食盐"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0040", "花椒酱"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0041", "调味膏2"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0042", "调味膏5"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0043", "十三香调味膏"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0044", "酱香膏"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0045", "芽菜香料粉"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0046", "香料A"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0047", "香料D"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0048", "猪肉精膏"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0049", "调味膏3"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0050", "柠檬酸粉"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0051", "辣椒红"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0052", "辣椒油树脂"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0053", "水态混和酸"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0054", "加水稀释后防腐剂"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0055", "异维C钠粉"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0056", "琼脂粉"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0057", "香葱油"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0058", "水态甜味剂"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0059", "孜然粉"); + GVL_SmallStation.GetInstance.RawMaterialsNameCode.TryAdd("0060", "孜然油"); + } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index 382c3ef4..22963a6b 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -52,7 +52,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model BottomDeviceCurrentStatuses.ElementAt(BottomIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; BottomDeviceCurrentStatuses.ElementAt(BottomIndex).RunStatus = DeviceLists.ElementAt(i).Value.deviceStatus.RunStatus; } - int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key && p.DeviceName != DeviceLists.ElementAt(i).Value.DeviceName); if (deviceIndex >= 0 && deviceIndex < devices.Count) { diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs index ad7a8237..c8facaf5 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs @@ -7,6 +7,7 @@ using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.ObjectModel; using BPASmartClient.JXJFoodSmallStation.Model.Par; using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial; +using BPASmartClient.JXJFoodSmallStation.Model.Bom; namespace BPASmartClient.JXJFoodSmallStation.Model { @@ -17,6 +18,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model private ConnectParMode _mdeviceConnectPar = new ConnectParMode(); public ObservableCollection rawMaterialStockBin { get; set; } = new ObservableCollection(); public ObservableCollection windSendRawMaterial { get; set; } = new ObservableCollection(); + public ObservableCollection BomMaterial { get; set; } = new ObservableCollection(); } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index 825041db..5c2c6cea 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -29,13 +29,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens //var DataColl = this.Siemens_PLC_S7.ReadClass(2291); if (Start != null && Start is XL_Start_DB st) { - switch (GVL_SmallStation.SiemensSendRecipeStatus) + switch (GVL_SmallStation.GetInstance.SiemensSendRecipeStatus) { case 0: - if (GVL_SmallStation.IsAllowSiemensSendRecipe) + if (GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe) { this.Siemens_PLC_S7.Write("DB2201.DBX450.0", true); - GVL_SmallStation.SiemensSendRecipeStatus = 1; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 1; } break; case 1: @@ -43,7 +43,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { if (!string.IsNullOrEmpty(st.RecipeCode)) { - GVL_SmallStation.SiemensSendRecipeStatus = 2; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 2; ActionManage.GetInstance.Send("SiemensRecipeRecive", st); this.Siemens_PLC_S7.Write("DB2201.DBX450.0", false); } @@ -52,23 +52,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens case 2: if (Start.Order_Request_ACK == false) { - GVL_SmallStation.IsAllowSiemensSendRecipe = false; - GVL_SmallStation.SiemensSendRecipeStatus = 3; + GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe = false; + GVL_SmallStation.GetInstance.SiemensSendRecipeStatus = 3; } break; } if (RTrig.GetInstance("Order_Cancel").Start(st.Order_Cancel)) //订单取消 { - if (GVL_SmallStation.Order_Cancel == false) + if (GVL_SmallStation.GetInstance.Order_Cancel == false) { - GVL_SmallStation.Order_Cancel = true; - GVL_SmallStation.Order_CancelRecipeCode = st.RecipeCode; - GVL_SmallStation.OrderCancelStep = 0; + GVL_SmallStation.GetInstance.Order_Cancel = true; + GVL_SmallStation.GetInstance.Order_CancelRecipeCode = st.RecipeCode; + GVL_SmallStation.GetInstance.OrderCancelStep = 0; MessageNotify.GetInstance.ShowRunLog($"西门子下发取消工单指令:{st.RecipeName}"); } else { - MessageNotify.GetInstance.ShowRunLog($"订单正在取消,请等待订单{ GVL_SmallStation.Order_CancelRecipeCode}取消完成,再取消订单:{st.RecipeName}"); + MessageNotify.GetInstance.ShowRunLog($"订单正在取消,请等待订单{ GVL_SmallStation.GetInstance.Order_CancelRecipeCode}取消完成,再取消订单:{st.RecipeName}"); } } } @@ -101,6 +101,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens XL_Status = state; } + //从海科plc的数采 发送给西门子plc var res = ProcessControl.GetInstance.HKDevice.DeviceStatus; if (res != null) { diff --git a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs index ce06670e..2d24260c 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs @@ -27,15 +27,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model var res1 = this.Siemens_PLC_S7.ReadClass(94); if (res1 != null && res1 is WindSend_Read readData) { - GVL_SmallStation.WindSendAllowAGVPutGet = readData.HoodLiftInPlace; - Siemens_PLC_S7.Write("DB95.DBX38.2", GVL_SmallStation.Station1HaveTray);//工站1有托盘 + GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet = readData.HoodLiftInPlace; + Siemens_PLC_S7.Write("DB95.DBX38.2", GVL_SmallStation.GetInstance.Station1HaveTray);//工站1有托盘 if (res1.RecipeReceiveFinish) { Siemens_PLC_S7.Write("DB95.DBX38.0", false); } if (RTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign)) { - GVL_SmallStation.WindSendDosingComple = true; + GVL_SmallStation.GetInstance.WindSendDosingComple = true; Siemens_PLC_S7.Write("DB95.DBX38.1", true); } if (TTrig.GetInstance("CurrentCompleteSign").Start(readData.CurrentCompleteSign)) @@ -108,6 +108,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } Thread.Sleep(10);*/ } + Thread.Sleep(10); }),"监听粉料数据",true); } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs index 8878fd96..7d48cee8 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs @@ -16,10 +16,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model private int _mLocation; public string RawMaterialChineseName { get { return _mRawMaterialChineseName; } set { _mRawMaterialChineseName = value; OnPropertyChanged(); } } - private string _mRawMaterialChineseName; + private string _mRawMaterialChineseName = ""; public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } - private string _mRawMaterialName; + private string _mRawMaterialName = ""; /// /// 需要原料重量 /// diff --git a/BPASmartClient.JXJFoodSmallStation/View/BomOfMaterialView.xaml b/BPASmartClient.JXJFoodSmallStation/View/BomOfMaterialView.xaml new file mode 100644 index 00000000..a3b512d6 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/View/BomOfMaterialView.xaml @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - @@ -103,7 +101,7 @@ Height="40" Margin="5,0,5,0" Command="{Binding CLearRecipeInfo}" - Content="配方清零" + Content="PLC配方清零" FontSize="20" Panel.ZIndex="0" Style="{StaticResource ImageButtonStyle}"> @@ -114,10 +112,10 @@ - - - - + + + + @@ -127,17 +125,25 @@ - - + + - + + + + + + + + + - + @@ -151,6 +157,11 @@ Panel.ZIndex="0" Style="{StaticResource ImageButtonStyle}"> + + + + + diff --git a/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml.cs b/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml.cs index ad990fd8..3ea0ccf0 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml.cs @@ -24,5 +24,10 @@ namespace BPASmartClient.JXJFoodSmallStation.View { InitializeComponent(); } + + private void Button_Click(object sender, RoutedEventArgs e) + { + + } } } diff --git a/BPASmartClient.JXJFoodSmallStation/View/PlcVarMonitorView.xaml b/BPASmartClient.JXJFoodSmallStation/View/PlcVarMonitorView.xaml index f5cb142b..767e68be 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/PlcVarMonitorView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/PlcVarMonitorView.xaml @@ -55,7 +55,7 @@ - + @@ -89,6 +89,11 @@ + + + + + diff --git a/BPASmartClient.JXJFoodSmallStation/View/ProcessMonitorView.xaml b/BPASmartClient.JXJFoodSmallStation/View/ProcessMonitorView.xaml new file mode 100644 index 00000000..b671f871 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/View/ProcessMonitorView.xaml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.JXJFoodSmallStation/View/ProcessMonitorView.xaml.cs b/BPASmartClient.JXJFoodSmallStation/View/ProcessMonitorView.xaml.cs new file mode 100644 index 00000000..f9bf69f3 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/View/ProcessMonitorView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.JXJFoodSmallStation.View +{ + /// + /// ProcessMonitorView.xaml 的交互逻辑 + /// + public partial class ProcessMonitorView : UserControl + { + public ProcessMonitorView() + { + InitializeComponent(); + } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodSmallStation/View/RecipeReceiveView.xaml index 37d65ea5..d670c417 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/RecipeReceiveView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/RecipeReceiveView.xaml @@ -49,17 +49,33 @@ + + { GVL_SmallStation.GetInstance.RequestOrder = (bool)AskRecipeFormSiemens.IsChecked; }; this.IsUseWindSend.Click += (o, e) => { GVL_SmallStation.GetInstance.IsUseWindSend = (bool)IsUseWindSend.IsChecked; }; this.IsUseStockBin.Click += (o, e) => { GVL_SmallStation.GetInstance.IsUseLocalRecipe = (bool)IsUseStockBin.IsChecked; }; + this.NotUseSmallDosing.Click += (o, e) => { GVL_SmallStation.GetInstance.NotUseSmallDosing = (bool)NotUseSmallDosing.IsChecked; }; } } } diff --git a/BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml b/BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml index 2916d04d..3f88eec8 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml @@ -180,11 +180,9 @@ diff --git a/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml b/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml index 87c2680a..6da027df 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml @@ -20,20 +20,22 @@ - - +