From 80aa83113210843de9fb4782286fb4928557b5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=84=8F=20=E5=BD=AD?= <2417589739@qq.com> Date: Mon, 29 May 2023 14:29:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=A8=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.JXJFoodBigStation/App.xaml | 9 +- BPASmartClient.JXJFoodBigStation/App.xaml.cs | 3 +- .../Model/ProcessControl.cs | 37 +- .../App.xaml.cs | 1 + .../Model/Siemens/NewRemoteRecipeModel.cs | 61 ++ .../View/NewLocalRecipeView.xaml | 564 +++++++++--------- .../ViewModel/NewLocalRecipeViewModel.cs | 43 +- 7 files changed, 401 insertions(+), 317 deletions(-) create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml b/BPASmartClient.JXJFoodBigStation/App.xaml index 07a8c441..5d64b9c2 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml +++ b/BPASmartClient.JXJFoodBigStation/App.xaml @@ -1,7 +1,8 @@ - diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index 354b9dc1..4dac73f7 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs @@ -39,6 +39,7 @@ namespace BPASmartClient.JXJFoodBigStation MenuInit(); DataInit(); MainView mv = new MainView(); + mv.TitleName = "自动化产线-大料站上位机控制系统"; ProcessControl.GetInstance.Init(); LoginView lv = new LoginView(); var res = lv.ShowDialog(); @@ -186,7 +187,7 @@ namespace BPASmartClient.JXJFoodBigStation AssemblyName = "BPASmartClient.JXJFoodBigStation", ToggleWindowPath = "View.ManualFlowView" }); - + MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index fc3a26b2..e4bec208 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -35,7 +35,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 配方等待执行 /// - public ObservableCollection RecipeWaitExecute { get; set; } = new ObservableCollection(); + public ObservableCollection RecipeWaitExecute { get; set; } = new ObservableCollection(); /// /// 配方正在执行 /// @@ -91,11 +91,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model RawMaterials.Clear(); for (int i = 0; i < GVL_BigStation.Max_DosingSotckBinNum; i++) { - if (string.IsNullOrEmpty(recipe.Material[i].Material_Name)) + if (string.IsNullOrEmpty(recipe.Material[i].Material_Name)) { } - else + else { int index = RawMaterialsNamePos.Values.ToList().IndexOf(recipe.Material[i].Material_Name); if (index >= 0) @@ -829,7 +829,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model { item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } - } + } HKDevice.HK_PLC_S7.Write("DB98.DBX1.3", false); LocalRecipeQueue4.TryDequeue(out code); LocalRecipes.RemoveAt(index); @@ -994,7 +994,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - else + else { if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1 && data.TrayCode == 1) { @@ -1006,7 +1006,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model 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 && data.TrayCode == 3) + else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3 && data.TrayCode == 3) { SiemensRecipeQueue3.Enqueue(data.RecipeCode); MessageNotify.GetInstance.ShowRunLog($"本地配方,配方:{data.RecipeCode},加入队列3"); @@ -1362,7 +1362,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg"); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); } FinishData.Ask_For_Finish = true; double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe1Time).TotalSeconds; @@ -1475,7 +1475,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg"); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight}kg"); } FinishData.Ask_For_Finish = true; double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe2Time).TotalSeconds; @@ -1589,7 +1589,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方3,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg"); + 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; @@ -1702,7 +1702,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方4,配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg"); + MessageNotify.GetInstance.ShowRunLog($"配方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; @@ -1804,7 +1804,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model HardWareRawMaterialInfo.ElementAt(index).RawMaterialChineseName = ""; } } - + RawMaterialsInfo = HardWareRawMaterialInfo; } /// @@ -1938,6 +1938,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model } Thread.Sleep(10); }), "西门子和海科PLC重新连接", true); + ThreadManage.GetInstance().StartLong(new Action(() => { GVL_BigStation.HeartBeatToPlc = !GVL_BigStation.HeartBeatToPlc; @@ -2026,9 +2027,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model } else {*/ - ReceviceData(); - RecipeInfoToHKPLC(); - /* }*/ + ReceviceData(); + RecipeInfoToHKPLC(); + /* }*/ } Thread.Sleep(10); }), "配方数据执行流程", true); @@ -2074,7 +2075,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model { foreach (var item in SiemensRecipeQueue) { - if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key-1]) + if (item.Value.Count == 0 && item.Key == data.TrayCode && GVL_BigStation.AllowIssueRecipe[item.Key - 1]) { if (SiemensDevice.DL_Status is DL_Status_DB status) { @@ -2145,7 +2146,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.Order_CancelStep = 20; foreach (var item in SiemensRecipeQueue) { - if (item.Value.Contains(code)) + if (item.Value.Contains(code)) { GVL_BigStation.Order_CancelStep = 30; } @@ -2198,7 +2199,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (item.Value.Contains(code)) { - if (GVL_BigStation.RecipeDosingStatus[item.Key-1] != 0) + 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); @@ -2305,7 +2306,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); - MessageNotify.GetInstance.ShowRunLog($"配方{data.Key},配方编号:{code},托盘编号:{trayCode},原料名称:{FinishData.Material[i].Material_Name},原料桶号:{FinishData.Material[i].Material_BarrelNum},配料重量:{FinishData.Material[i].Material_Laying_Off_Weight }kg"); + 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; diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index f047bd73..e113200a 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -42,6 +42,7 @@ namespace BPASmartClient.JXJFoodSmallStation DataInit(); Init(); MainView mv = new MainView(); + mv.TitleName = "自动化产线-小料站上位机控制系统"; LoginView lv = new LoginView(); var res = lv.ShowDialog(); if (res != null && res == true) diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs new file mode 100644 index 00000000..041e009a --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/NewRemoteRecipeModel.cs @@ -0,0 +1,61 @@ +using BPA.Helper; +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 +{ + public class NewRemoteRecipeModel : ObservableObject + { + /// + /// 原料名称 + /// + public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } + private string _mRawMaterialName; + + /// + /// 原料对应的桶号 + /// + public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; OnPropertyChanged(); } } + private short _mRawMaterialBarrelNum; + + /// + /// 原料类型 + /// + public string RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } + private string _mRawMaterialType; + + /// + /// 需要原料重量 + /// + public float RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } + private float _mRawMaterialWeight; + + /// + /// 原料对应料仓的位置 + /// + public int RawMaterialLocation + { + get { return _mRawMaterialLocation; } + set + { + _mRawMaterialLocation = value; + if (RawMaterialType == "小料") + { + //Json.Data.BomMaterial + } + else if (RawMaterialType == "粉料") + { + + } + OnPropertyChanged(); + } + } + private int _mRawMaterialLocation; + + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml b/BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml index 2ecbb29d..3bcbb335 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/NewLocalRecipeView.xaml @@ -8,7 +8,7 @@ xmlns:vm="clr-namespace:BPASmartClient.JXJFoodSmallStation.ViewModel" Title="NewRemoteRecipeView" Width="900" - Height="645" + Height="700" AllowsTransparency="True" Background="{x:Null}" Topmost="True" @@ -74,12 +74,11 @@ - + - - - - + + + @@ -89,317 +88,326 @@ Foreground="DeepSkyBlue" Text="配方编辑" /> +