diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index 4a2e0aa6..385985dc 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs @@ -55,7 +55,7 @@ namespace BPASmartClient.JXJFoodBigStation ObservableCollection RecipeManage = new ObservableCollection(); RecipeManage.Add(new SubMenumodel() { - SubMenuName = "本地配方管理", + SubMenuName = "配方管理", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.JXJFoodBigStation", ToggleWindowPath = "View.RecipeReceiveView" @@ -67,6 +67,13 @@ namespace BPASmartClient.JXJFoodBigStation AssemblyName = "BPASmartClient.JXJFoodBigStation", ToggleWindowPath = "View.RecipeSendDownView" }); + RecipeManage.Add(new SubMenumodel() + { + SubMenuName = "西门子配方下发", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.JXJFoodBigStation", + ToggleWindowPath = "View.SiemensRecipeSendDownView" + }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", diff --git a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj index 0c148a2a..4d409438 100644 --- a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj +++ b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj @@ -28,6 +28,9 @@ $(DefaultXamlRuntime) + + $(DefaultXamlRuntime) + diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 74dd61bb..6b1edda7 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -11,6 +11,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model { public class GVL_BigStation { + /// + /// plc心跳上传 + /// + public static bool HeartBeatFromPlc { get; set; } /// /// 往输送带下发配方完成 /// @@ -35,15 +39,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 /// - public int Recipe1DosingStatus { get; set; } - public int Recipe2DosingStatus { get; set; } - public int Recipe3DosingStatus { get; set; } - public int Recipe4DosingStatus { get; set; } - public int Recipe5DosingStatus { get; set; } + public static int Recipe1DosingStatus { get; set; } + public static int Recipe2DosingStatus { get; set; } + public static int Recipe3DosingStatus { get; set; } + public static int Recipe4DosingStatus { get; set; } /// /// 是否处于手动下发配方 /// - public bool IsAllowManual { get; set; } = true; + public static bool IsUseLocalRecipe { get; set; } = false; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs index 9cc544b6..57c738b1 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Read.cs @@ -10,7 +10,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { public bool HeartBeat { get; set; } public bool IsAllowIssueRecipe1 { get; set; } - public bool IsAllowIssueRecipe2 { get; set; } public bool IsAllowIssueRecipe3 { get; set; } public bool IsAllowIssueRecipe4 { get; set; } diff --git a/BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs b/BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs deleted file mode 100644 index 52920363..00000000 --- a/BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs +++ /dev/null @@ -1,14 +0,0 @@ -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 LocalRecipeDataColl - { - public ObservableCollection Recipes { get; set; } = new ObservableCollection(); - } -} diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index 27d7ae01..58d0629c 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -24,13 +24,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); public HKDeviceStatus HKDevice = new HKDeviceStatus(); - GVL_BigStation BigStation = new GVL_BigStation(); DL_Finish_DB FinishData = new DL_Finish_DB(); /// /// 配方数据 /// - public ObservableCollection RemoteRecipes = new ObservableCollection(); + public ObservableCollection Recipes = new ObservableCollection(); /// /// 配方数据 /// @@ -46,13 +45,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model public ConcurrentQueue RecipeQueue2 = new ConcurrentQueue(); public ConcurrentQueue RecipeQueue3 = new ConcurrentQueue(); public ConcurrentQueue RecipeQueue4 = new ConcurrentQueue(); - public ConcurrentQueue RecipeQueue5 = new ConcurrentQueue(); /// /// 接收原料数据 /// public RecipeRawMaterial RawMaterial; public void Init() { + ActionManage.GetInstance.CancelRegister("SiemensSendRecipe"); ActionManage.GetInstance.Register(new Action((res) => { ObservableCollection RawMaterials = new ObservableCollection(); @@ -102,6 +101,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (SiemensDevice.IsConnected) { SiemensDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); } } catch (Exception ex) @@ -112,66 +112,66 @@ namespace BPASmartClient.JXJFoodBigStation.Model ActionManage.GetInstance.CancelRegister("ManualSendRecipe"); ActionManage.GetInstance.Register(new Action((o) => { - if (o !=null && o is RecipeData a) - { - Json.Data.Recipes.Add(a); - for (int i = 0; i < Json.Data.Recipes.Count; i++) + if (o != null && o is RecipeData a) + { + Json.Data.Recipes.Add(a); + for (int i = 0; i < Json.Data.Recipes.Count; i++) { - foreach (var item in Json.Data.Recipes.ElementAt(i).RawMaterial) + foreach (var item in Json.Data.Recipes.ElementAt(i).RawMaterial) { item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName); } } - MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败"); + MessageNotify.GetInstance.ShowAlarmLog("手动下发配方完成"); } }), "ManualSendRecipe", true); RecipeQueue1.Clear(); ThreadManage.GetInstance().StartLong(new Action(() => { + SystemStatus(); ReceviceData(); RecipeInfoToHKPLC(); Thread.Sleep(10); }), "流程处理", true); } + private void SystemStatus() + { + GVL_BigStation.HeartBeatFromPlc = HKDevice.PlcRead.HeartBeat;//读取plc心跳 + } private void ReceviceData() { - if (!BigStation.IsAllowManual && RemoteRecipes.Count == 0)//一个配方执行完成后,再获取配方数据 + if (!GVL_BigStation.IsUseLocalRecipe && Recipes.Count == 0)//一个配方执行完成后,再获取配方数据 { - RemoteRecipes = Json.Data.Recipes; + Recipes = Json.Data.Recipes; } - else if (BigStation.IsAllowManual && RemoteRecipes.Count == 0) + else if (GVL_BigStation.IsUseLocalRecipe && Recipes.Count == 0) { - RemoteRecipes = Json.Data.Recipes; + Recipes = Json.Data.Recipes; } - if (RemoteRecipes.Count > 0) + if (Recipes.Count > 0) { - foreach (var data in RemoteRecipes) + foreach (var data in Recipes) { - if (data.TrayCode == 1) + if (RecipeQueue1.Count == 0) { if (!(RecipeQueue1.Contains(data.RecipeCode))) RecipeQueue1.Enqueue(data.RecipeCode); } - else if (data.TrayCode == 2) + else if (RecipeQueue2.Count == 0) { if (!(RecipeQueue2.Contains(data.RecipeCode))) RecipeQueue2.Enqueue(data.RecipeCode); } - else if (data.TrayCode == 3) + else if (RecipeQueue3.Count == 0) { if (!(RecipeQueue3.Contains(data.RecipeCode))) RecipeQueue3.Enqueue(data.RecipeCode); } - else if (data.TrayCode == 4) + else if (RecipeQueue4.Count == 0) { if (!(RecipeQueue4.Contains(data.RecipeCode))) RecipeQueue4.Enqueue(data.RecipeCode); } - else if (data.TrayCode == 5) - { - if (!(RecipeQueue5.Contains(data.RecipeCode))) - RecipeQueue5.Enqueue(data.RecipeCode); - } } } else @@ -180,44 +180,42 @@ namespace BPASmartClient.JXJFoodBigStation.Model RecipeQueue2.Clear(); RecipeQueue3.Clear(); RecipeQueue4.Clear(); - RecipeQueue5.Clear(); - BigStation.Recipe1DosingStatus = 0; - BigStation.Recipe2DosingStatus = 0; - BigStation.Recipe3DosingStatus = 0; - BigStation.Recipe4DosingStatus = 0; - BigStation.Recipe5DosingStatus = 0; + GVL_BigStation.Recipe1DosingStatus = 0; + GVL_BigStation.Recipe2DosingStatus = 0; + GVL_BigStation.Recipe3DosingStatus = 0; + GVL_BigStation.Recipe4DosingStatus = 0; } } private void RecipeInfoToHKPLC() { if (RecipeQueue1.Count > 0) { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue1.ElementAt(0)); - if (index >= 0 && index < RemoteRecipes.Count) + int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue1.ElementAt(0)); + if (index >= 0 && index < Recipes.Count) { - string code = RemoteRecipes.ElementAt(index).RecipeCode; - int trayCode = RemoteRecipes.ElementAt(index).TrayCode; - if (HKDevice.PlcRead.IsAllowIssueRecipe1 && BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发 + string code = Recipes.ElementAt(index).RecipeCode; + int trayCode = Recipes.ElementAt(index).TrayCode; + if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0)//配方1是否允许下发配发 { - HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); + HKDevice.StockBinPar(Recipes.ElementAt(index)); HKDevice.PlcWrite.Recipe1IssuedFinish = true; - BigStation.Recipe1DosingStatus = 1; + GVL_BigStation.Recipe1DosingStatus = 1; MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } - if (HKDevice.PlcRead.ReceiveFinishRecipe1 && BigStation.Recipe1DosingStatus == 1) + if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1) { - BigStation.Recipe1DosingStatus = 2; + GVL_BigStation.Recipe1DosingStatus = 2; HKDevice.PlcWrite.Recipe1IssuedFinish = false; StockBinParReset(); MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } - if (BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) + if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) { - BigStation.Recipe1DosingStatus = 3; + GVL_BigStation.Recipe1DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe1TrayCode == 1) { - foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) + foreach (var item in Recipes.ElementAt(index).RawMaterial) { if (item.RawMaterialLocation == 1) { @@ -276,63 +274,62 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; - for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + FinishData.Order_No = Recipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = Recipes.ElementAt(index).RecipeName; + for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++) { FinishData.Material[i] = new UDT1(); - FinishData.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; } } if (SiemensDevice.IsConnected) { - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 3); + SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); } RecipeQueue1.TryDequeue(out code); - IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 - if (!BigStation.IsAllowManual) + IssuedComplete.Add(Recipes.ElementAt(index));//将配方添加到完成列表 + if (!GVL_BigStation.IsUseLocalRecipe) { Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } else { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } - BigStation.Recipe1DosingStatus = 0; + GVL_BigStation.Recipe1DosingStatus = 0; } - } } if (RecipeQueue2.Count > 0) { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue2.ElementAt(0)); - if (index >= 0 && index < RemoteRecipes.Count) + int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue2.ElementAt(0)); + if (index >= 0 && index < Recipes.Count) { - string code = RemoteRecipes.ElementAt(index).RecipeCode; - int trayCode = RemoteRecipes.ElementAt(index).TrayCode; - if (HKDevice.PlcRead.IsAllowIssueRecipe2 && BigStation.Recipe2DosingStatus == 0)//配方1是否允许下发配发 + string code = Recipes.ElementAt(index).RecipeCode; + int trayCode = Recipes.ElementAt(index).TrayCode; + if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0)//配方2是否允许下发配发 { - HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); + HKDevice.StockBinPar(Recipes.ElementAt(index)); HKDevice.PlcWrite.Recipe2IssuedFinish = true; - BigStation.Recipe2DosingStatus = 1; + GVL_BigStation.Recipe2DosingStatus = 1; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } - if (HKDevice.PlcRead.ReceiveFinishRecipe2 && BigStation.Recipe2DosingStatus == 1) + if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1) { - BigStation.Recipe2DosingStatus = 2; + GVL_BigStation.Recipe2DosingStatus = 2; HKDevice.PlcWrite.Recipe2IssuedFinish = false; StockBinParReset(); MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } - if (BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) + if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) { - BigStation.Recipe2DosingStatus = 3; + GVL_BigStation.Recipe2DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe2TrayCode > 0) { - foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) + foreach (var item in Recipes.ElementAt(index).RawMaterial) { if (item.RawMaterialLocation == 1) { @@ -391,62 +388,62 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; - for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + FinishData.Order_No = Recipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = Recipes.ElementAt(index).RecipeName; + for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++) { FinishData.Material[i] = new UDT1(); - FinishData.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; } } if (SiemensDevice.IsConnected) { - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 3); + SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); } RecipeQueue2.TryDequeue(out code); - IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 - if (!BigStation.IsAllowManual) + IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下 + if (!GVL_BigStation.IsUseLocalRecipe) { Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } else { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } - BigStation.Recipe2DosingStatus = 0; + GVL_BigStation.Recipe2DosingStatus = 0; } } } if (RecipeQueue3.Count > 0) { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue3.ElementAt(0)); - if (index >= 0 && index < RemoteRecipes.Count) + int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue3.ElementAt(0)); + if (index >= 0 && index < Recipes.Count) { - string code = RemoteRecipes.ElementAt(index).RecipeCode; - int trayCode = RemoteRecipes.ElementAt(index).TrayCode; - if (HKDevice.PlcRead.IsAllowIssueRecipe3 && BigStation.Recipe3DosingStatus == 0)//配方1是否允许下发配发 + string code = Recipes.ElementAt(index).RecipeCode; + int trayCode = Recipes.ElementAt(index).TrayCode; + if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0)//配方3是否允许下发配发 { - HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); + HKDevice.StockBinPar(Recipes.ElementAt(index)); HKDevice.PlcWrite.Recipe3IssuedFinish = true; - BigStation.Recipe3DosingStatus = 1; + GVL_BigStation.Recipe3DosingStatus = 1; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } - if (HKDevice.PlcRead.ReceiveFinishRecipe3 && BigStation.Recipe3DosingStatus == 1) + if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1) { - BigStation.Recipe3DosingStatus = 2; + GVL_BigStation.Recipe3DosingStatus = 2; StockBinParReset(); MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } - if (HKDevice.PlcRead.Recipe3DosingFinish && BigStation.Recipe3DosingStatus == 2) + if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) { - BigStation.Recipe3DosingStatus = 3; + GVL_BigStation.Recipe3DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe3TrayCode > 0) { - foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) + foreach (var item in Recipes.ElementAt(index).RawMaterial) { if (item.RawMaterialLocation == 1) { @@ -505,66 +502,64 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - - FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; - for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + FinishData.Order_No = Recipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = Recipes.ElementAt(index).RecipeName; + for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++) { FinishData.Material[i] = new UDT1(); - FinishData.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; } - } if (SiemensDevice.IsConnected) { - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 3); + SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); } HKDevice.HK_PLC_S7.Write("DB98.DBX1.1", false); RecipeQueue3.TryDequeue(out code); - IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 - if (!BigStation.IsAllowManual) + IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下 + if (!GVL_BigStation.IsUseLocalRecipe) { Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } else { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } - BigStation.Recipe3DosingStatus = 0; + GVL_BigStation.Recipe3DosingStatus = 0; } } } if (RecipeQueue4.Count > 0) { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue4.ElementAt(0)); - if (index >= 0 && index < RemoteRecipes.Count) + int index = Array.FindIndex(Recipes.ToArray(), p => p.RecipeCode == RecipeQueue4.ElementAt(0)); + if (index >= 0 && index < Recipes.Count) { - string code = RemoteRecipes.ElementAt(index).RecipeCode; - int trayCode = RemoteRecipes.ElementAt(index).TrayCode; - if (HKDevice.PlcRead.IsAllowIssueRecipe4 && BigStation.Recipe4DosingStatus == 0)//配方1是否允许下发配发 + string code = Recipes.ElementAt(index).RecipeCode; + int trayCode = Recipes.ElementAt(index).TrayCode; + if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0)//配方4是否允许下发配发 { - HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); + HKDevice.StockBinPar(Recipes.ElementAt(index)); HKDevice.PlcWrite.Recipe4IssuedFinish = true; - BigStation.Recipe4DosingStatus = 1; + GVL_BigStation.Recipe4DosingStatus = 1; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } - if (HKDevice.PlcRead.ReceiveFinishRecipe4 && BigStation.Recipe4DosingStatus == 1) + if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1) { - BigStation.Recipe4DosingStatus = 2; + GVL_BigStation.Recipe4DosingStatus = 2; HKDevice.PlcWrite.Recipe4IssuedFinish = false; StockBinParReset(); MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } - if (BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) + if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) { - BigStation.Recipe4DosingStatus = 3; + GVL_BigStation.Recipe4DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe4TrayCode > 0) { - foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) + foreach (var item in Recipes.ElementAt(index).RawMaterial) { if (item.RawMaterialLocation == 1) { @@ -623,40 +618,38 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - - FinishData.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; - for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + FinishData.Order_No = Recipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = Recipes.ElementAt(index).RecipeName; + for (int i = 0; i < Recipes.ElementAt(index).RawMaterial.Count; i++) { FinishData.Material[i] = new UDT1(); - FinishData.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + FinishData.Material[i].Material_Name = Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + FinishData.Material[i].Material_BarrelNum = (short)Recipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + FinishData.Material[i].Material_Laying_Off_Weight = Recipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; } - } if (SiemensDevice.IsConnected) { - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 3); + SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); } HKDevice.HK_PLC_S7.Write("DB98.DBX1.3", false); RecipeQueue4.TryDequeue(out code); - IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 - if (!BigStation.IsAllowManual) + IssuedComplete.Add(Recipes.ElementAt(index));//将该配方添加到下 + if (!GVL_BigStation.IsUseLocalRecipe) { Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } else { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } - BigStation.Recipe4DosingStatus = 0; + GVL_BigStation.Recipe4DosingStatus = 0; } } } } /// - /// 下发配方的数据复位 + /// 下发plc的配方数据复位 /// private void StockBinParReset() { diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs index efcaf0d1..56c74a2f 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs @@ -16,14 +16,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens /// /// 配料开始确认 /// - public bool Dosing_Confirm { get; set; } - public bool Dosing_Cancel { get; set; } - public bool Dosing_Cancel2 { get; set; } + public bool AGV_Request_Put { get; set; } + public bool AGV_Request_Get { get; set; } + public short AGV_Put_Done { get; set; } - public bool Dosing_Cancel3 { get; set; } + public short AGV_Get_Done { get; set; } - public short a { get; set; } - public short[] Standby { get; set; } = new short[3]; + public short AGV_GetPut_Pos { get; set; } + public short[] Standby { get; set; } = new short[1]; [Siemens(16)] /// /// 生产工单 @@ -39,6 +39,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens public short Dosing_Cancel8 { get; set; } + public short Dosing_Cancel9 { get; set; } + public short[] Standby2 { get; set; } = new short[4]; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index d4969c2e..4b6e425f 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -25,51 +25,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens var res1 = this.Siemens_PLC_S7.ReadClass(2331); var res2 = this.Siemens_PLC_S7.ReadClass(2361); var res3 = this.Siemens_PLC_S7.ReadClass(2391); - /*if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit)) - { - ActionManage.GetInstance.Send("SiemensSendRecipe", res); - res.Ask_For_Send_Bit = false;//接受配方信号复位 - //res.Ack_Ask_For_Send_Bit = true;//配方接受完成 - this.Siemens_PLC_S7.WriteClass(res, 1); - } - - if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.)) - { - ActionManage.GetInstance.Send("AGVToStation1Sign", res1); - //res1.Allow_AGV_Put[0] = false; - this.Siemens_PLC_S7.WriteClass(res1, 2); - } - if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1])) - { - ActionManage.GetInstance.Send("AGVToStation2Sign", res1); - res1.Allow_AGV_Put[1] = false; - this.Siemens_PLC_S7.WriteClass(res1, 2); - } - if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[2]").Start(res1.Allow_AGV_Put[2])) - { - ActionManage.GetInstance.Send("AGVToStation3Sign", res1); - res1.Allow_AGV_Put[2] = false; - this.Siemens_PLC_S7.WriteClass(res1, 2); - } - if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[3]").Start(res1.Allow_AGV_Put[3])) - { - ActionManage.GetInstance.Send("AGVToStation4Sign", res1); - res1.Allow_AGV_Put[3] = false; - this.Siemens_PLC_S7.WriteClass(res1, 2); - } - if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[4]").Start(res1.Allow_AGV_Put[4])) - { - ActionManage.GetInstance.Send("AGVToStation5Sign", res1); - res1.Allow_AGV_Put[4] = false; - this.Siemens_PLC_S7.WriteClass(res1, 2); - } - if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[5]").Start(res1.Allow_AGV_Put[5])) - { - ActionManage.GetInstance.Send("AGVToStation6Sign", res1); - res1.Allow_AGV_Put[5] = false; - this.Siemens_PLC_S7.WriteClass(res1, 2); - } -*/ if (res2 != null && res2.Ask_For_Finish_PLC) { ActionManage.GetInstance.Send("配料完成信号确认完成"); diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml index 529b6535..a41f7228 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml @@ -156,6 +156,14 @@ + { GVL_BigStation.IsUseLocalRecipe = (bool)IsUseLocalRecipe.IsChecked; }; } } } diff --git a/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml b/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml new file mode 100644 index 00000000..9ca42a87 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/View/SiemensRecipeSendDownView.xaml @@ -0,0 +1,878 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +