diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index 6d206609..c4591952 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -53,6 +53,40 @@ namespace BPASmartClient.JXJFoodBigStation.Model public void Init() { ActionManage.GetInstance.Register(new Action((res) => + { + if (SiemensDevice.IsConnected) + { + if (res != null) + { + RawMaterials.Clear(); + for (int i = 0; i < 15; i++) + { + if (RawMaterialsNamePos.ContainsKey(res.RecipeName) + { + RawMaterials.Add(new RemoteRecipeRawMaterial() + { + RawMaterialName = res.Material[i].Material_Name, + RawMaterialBarrelNum = res.Material[i].Material_BarrelNum, + RawMaterialWeight = res.Material[i].Material_Weight, + RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name] + }); + } + else + { + //报警,配方的原料名称下发和设备不一致 + } + } + Json.Data.Recipes.Add(new RemoteRecipeData() + { + RecipeName = res.RecipeName, + RecipeCode = res.RecipeCode, + RawMaterial = RawMaterials, + TrayCode = res.TrayCode + }); + } + } + }), "西门子下发配方", true); + ActionManage.GetInstance.Register(new Action((res) => { if (SiemensDevice.IsConnected) { @@ -76,7 +110,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model //报警,配方的原料名称下发和设备不一致 } } - Json.Data.Recipes.Add(new RemoteRecipeData() + Json.Data.Recipes.Add(new RemoteRecipeData() { RecipeName = res.RecipeName, RecipeCode = res.RecipeCode, diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs index bdbd7869..881e20c3 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialModel.cs @@ -14,6 +14,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model { private int _mIp; public int DeviceIp { get { return _mIp; } set { _mIp = value; } } + /// + /// 原料名称 + /// + public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } + private string _mRawMaterialName; /// /// 原料对应的桶号 @@ -28,72 +33,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model private double _mRawMaterialWeight; /// - /// 原料对应料仓的位置 - /// - public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } } - private int _mRawMaterialLocation; - - /// - /// 原料名称 - /// - public string RawMaterialName { get { return _rawMaterNmae; } set { _rawMaterNmae = value;OnPropertyChanged(); } } - - private string _rawMaterNmae; - - - /// - /// 原料类型 MW18 - /// 1:液体 - /// 2:膏体 - /// 3:粉体 - /// - [Newtonsoft.Json.JsonIgnore] - public ushort RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } - private ushort _mRawMaterialType; - - /// - /// 料仓重量反馈 MD40 + /// 实际的下料中重量 /// - [Newtonsoft.Json.JsonIgnore] - public float WeightFeedback { get { return _mWeightFeedback; } set { _mWeightFeedback = value; OnPropertyChanged(); } } - private float _mWeightFeedback; + public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } } + private float _mLaying_Off_Weight; /// - /// 上限反馈 + /// 原料对应料仓的位置/名称 /// - [Newtonsoft.Json.JsonIgnore] - public bool UpLimtFeedback { get { return _mUpLimtFeedback; } set { _mUpLimtFeedback = value; OnPropertyChanged(); } } - private bool _mUpLimtFeedback; - - /// - /// 下限反馈 - /// - [Newtonsoft.Json.JsonIgnore] - public bool DownLimtFeedback { get { return _mDownLimtFeedback; } set { _mDownLimtFeedback = value; OnPropertyChanged(); } } - private bool _mDownLimtFeedback; - - /// - /// 下料重量反馈 MD52 - /// - [Newtonsoft.Json.JsonIgnore] - public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } } - private float _mUpLimtWeightFeedback; - - - /// - /// 原料ID - /// - public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } } - private string _mRawMaterialId; - - /// - /// 原料设备执行状态 - /// 1:空闲状态 - /// 2:下料中 - /// 3:下料完成 - /// - [Newtonsoft.Json.JsonIgnore] - public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } } - private ushort _mRecipeStatus = 1; + public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } } + private int _mRawMaterialLocation; + } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs index 63e1a8bf..d73f5fb2 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeModel.cs @@ -15,16 +15,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// public class RecipeModel : ObservableObject { - [Newtonsoft.Json.JsonIgnore] - public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } - private bool _mIsEnable = true; - - /// - /// 序号 - /// - public int SerialNum { get { return _mSerialNum; } set { _mSerialNum = value; OnPropertyChanged(); } } - private int _mSerialNum; - /// /// 配方名称 /// @@ -32,9 +22,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model private string _mRecipeName; /// - /// 配方编码 + /// 配方ID /// - public string RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } } + public string RecipeCode { get { return _mRecipCode; } set { _mRecipCode = value; OnPropertyChanged(); } } private string _mRecipCode; /// diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs index 383a0d10..5623d108 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs @@ -1,5 +1,4 @@ - -using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs index 56c353ca..35010f84 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs @@ -62,14 +62,11 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel } else { - MessageBox.Show("配方名称重复,请重命名!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } - } else//编辑已有配方 { - bom.RawMaterial.Clear(); foreach (var item in RawMaterialsInfo) { @@ -91,15 +88,15 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel prop: string recipeCode = new Random().Next(10000, 99999).ToString();//配方唯一ID,后期根据实际要求更改 var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode); - if (res == null) - { - Json.Data.Recipes.Add(new RecipeModel { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode });//配方添加 - Json.Save(); + if (res == null) + { + Json.Data.Recipes.Add(new RecipeModel { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode });//配方添加 + Json.Save(); + } + else + { + goto prop; } - else - { - goto prop; - } ActionManage.GetInstance.Send("CloseRecipeInfosView"); } else @@ -115,10 +112,6 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel if (res != null) RawMaterialsInfo.Remove(res); }); - //ReturnPage = new RelayCommand(() => - //{ - // ActionManage.GetInstance.Send("CloseRecipeInfosView"); - //}); } public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs index 06cdd6af..a2fee385 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeSendDownViewModel.cs @@ -18,7 +18,6 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel /// /// 当前正在制作的配方 /// - public static ObservableCollection recipeProcesses { get; set; } = new ObservableCollection(); /// /// 等待制作的配方 @@ -37,11 +36,9 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel if (recipeName != null) { //配方下发逻辑 - var res= Recipes.FirstOrDefault(p=>p.RecipeName==recipeName); + var res = Recipes.FirstOrDefault(p => p.RecipeName == recipeName); if (res != null) - { - - } + ActionManage.GetInstance.Send("手动下发本地配方", res); } }); diff --git a/BPASmartClient.JXJFoodSmallStation/App.config b/BPASmartClient.JXJFoodSmallStation/App.config index 5b550290..624631a9 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.config +++ b/BPASmartClient.JXJFoodSmallStation/App.config @@ -1,7 +1,7 @@  - + \ No newline at end of file diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs index 3466f7a5..ac5f51d3 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using BPASmartClient.S7Net; +using BPASmartClient.CustomResource.Pages.Model; namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC { @@ -61,54 +62,115 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC /// /// 单个桶的编号 /// 单个桶对应的料仓位置 - public void StockBinPar(uint BarrelNum, ushort StockBinLocation) + public void StockBinPar(uint BarrelNum, ushort StockBinLocation, int TrayNum = 1) { if (IsConnected) { - if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15) + if (TrayNum == 1) { - if (BarrelNum == 1) + if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15) { - if (StockBinLocation >= 1 && StockBinLocation <= 8) + if (BarrelNum == 1) { - HK_PLC_S7.Write("DB4.DBX10." + (StockBinLocation - 1), true); + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX10." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX11." + (StockBinLocation - 9), true); + } + MessageLog.GetInstance.ShowRunLog($"托盘1—1号桶在料仓{StockBinLocation}配料"); } - else if (StockBinLocation >= 9 && StockBinLocation <= 15) + else if (BarrelNum == 2) { - HK_PLC_S7.Write("DB4.DBX11." + (StockBinLocation - 9), true); + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX12." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX13." + (StockBinLocation - 9), true); + } + MessageLog.GetInstance.ShowRunLog($"托盘1—2号桶在料仓{StockBinLocation}配料"); } - } - else if (BarrelNum == 2) - { - if (StockBinLocation >= 1 && StockBinLocation <= 8) + else if (BarrelNum == 3) { - HK_PLC_S7.Write("DB4.DBX12." + (StockBinLocation - 1), true); + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX14." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX15." + (StockBinLocation - 9), true); + } + MessageLog.GetInstance.ShowRunLog($"托盘1—3号桶在料仓{StockBinLocation}配料"); } - else if (StockBinLocation >= 9 && StockBinLocation <= 15) + else if (BarrelNum == 4) { - HK_PLC_S7.Write("DB4.DBX13." + (StockBinLocation - 9), true); + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX16." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX17." + (StockBinLocation - 9), true); + } + MessageLog.GetInstance.ShowRunLog($"托盘1—4号桶在料仓{StockBinLocation}配料"); } } - else if (BarrelNum == 3) + } + else if (TrayNum == 2) + { + if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15) { - if (StockBinLocation >= 1 && StockBinLocation <= 8) + if (BarrelNum == 1) { - HK_PLC_S7.Write("DB4.DBX14." + (StockBinLocation - 1), true); + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX18." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX19." + (StockBinLocation - 9), true); + } + MessageLog.GetInstance.ShowRunLog($"托盘2—1号桶在料仓{StockBinLocation}配料"); } - else if (StockBinLocation >= 9 && StockBinLocation <= 15) + else if (BarrelNum == 2) { - HK_PLC_S7.Write("DB4.DBX15." + (StockBinLocation - 9), true); + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX20." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX21." + (StockBinLocation - 9), true); + } + MessageLog.GetInstance.ShowRunLog($"托盘2—2号桶在料仓{StockBinLocation}配料"); } - } - else if (BarrelNum == 4) - { - if (StockBinLocation >= 1 && StockBinLocation <= 8) + else if (BarrelNum == 3) { - HK_PLC_S7.Write("DB4.DBX16." + (StockBinLocation - 1), true); + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX22." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX23." + (StockBinLocation - 9), true); + } + MessageLog.GetInstance.ShowRunLog($"托盘2—3号桶在料仓{StockBinLocation}配料"); } - else if (StockBinLocation >= 9 && StockBinLocation <= 15) + else if (BarrelNum == 4) { - HK_PLC_S7.Write("DB4.DBX17." + (StockBinLocation - 9), true); + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX24." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX25." + (StockBinLocation - 9), true); + } + MessageLog.GetInstance.ShowRunLog($"托盘2—4号桶在料仓{StockBinLocation}配料"); } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index abd7e42c..b2ee5cce 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -56,8 +56,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } - - ActionManage.GetInstance.Register(new Action((res) => { if (SiemensDevice.IsConnected) @@ -96,7 +94,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; try { - //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S7200Smart, HK_PLC_IP); + HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); if (HKDevice.IsConnected) { @@ -123,8 +121,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (SiemensDevice.IsConnected && HKDevice.IsConnected) { - AgvGetInDelivery(); - AgvGetInPickUp(); + /*AgvGetInDelivery(); + AgvGetInPickUp();*/ } Thread.Sleep(10); }), "AGV进站送取货", true); @@ -527,14 +525,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (RecipeQueue.Count > 0) { + int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0)); if (index >= 0 && index < RemoteRecipes.Count) { string code = RemoteRecipes.ElementAt(index).RecipeCode; int trayCode = RemoteRecipes.ElementAt(index).TrayCode; - if (trayCode == 1 && SmallStation.RecipeStatusID == 0) + string recipeName = RemoteRecipes.ElementAt(index).RecipeName; + //MessageLog.GetInstance.ShowRunLog($"开始执行配方{recipeName}"); + if ( true) /*trayCode == 1 &&*/ { - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") && SmallStation.RecipeStatusID == 0) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") || SmallStation.RecipeStatusID == 0) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) { @@ -543,18 +544,23 @@ namespace BPASmartClient.JXJFoodSmallStation.Model HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false); HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true); SmallStation.RecipeStatusID = 1; + MessageLog.GetInstance.ShowRunLog($"{recipeName}配方下发完成"); + HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", true); } + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") && SmallStation.RecipeStatusID == 1) { HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false); SmallStation.RecipeStatusID = 2; + MessageLog.GetInstance.ShowRunLog($"{recipeName}plc端 配方接收完成"); } if (SmallStation.RecipeStatusID == 2) { - if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.0")) + if (RTrig.GetInstance("DB3.DBX50.0").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.0"))) { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10"); - if (res != null && res is float loc) + var res1= HKDevice.HK_PLC_S7.Read("DB4.DBD26"); + var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10"); + if (res > 0 && res is UInt32 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; @@ -564,13 +570,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model SmallStation.StockInIsWork = loc_index; HKDevice.HK_PLC_S7.Write("DB3.DBX50.0", false); } + MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_1号桶允许配料"); } } - else if(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1")) + else if(RTrig.GetInstance("DB3.DBX50.1").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1"))) { var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14"); - if (res != null && res is float loc) + if (res > 0 && res is float loc) { + ushort a = (ushort)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 >= 1 && loc_index <= 15) @@ -579,27 +587,33 @@ namespace BPASmartClient.JXJFoodSmallStation.Model SmallStation.StockInIsWork = loc_index; HKDevice.HK_PLC_S7.Write("DB3.DBX50.1", false); } + MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_2号桶允许配料"); } } - else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.2")) + else if (RTrig.GetInstance("DB3.DBX50.2").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.2"))) { var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18"); - if (res != null && res is float loc) + 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 >= 1 && loc_index <= 15) { - DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 - SmallStation.StockInIsWork = loc_index; - HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false); + double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; + if (loc_index >= 1 && loc_index <= 15) + { + DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 + SmallStation.StockInIsWork = loc_index; + HKDevice.HK_PLC_S7.Write("DB3.DBX50.2", false); + } + MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_3号桶允许配料"); } + } } - else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.3")) + else if (RTrig.GetInstance("DB3.DBX50.3").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX50.3"))) { var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22"); - if (res != null && res is float loc) + 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; @@ -609,11 +623,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model SmallStation.StockInIsWork = loc_index; HKDevice.HK_PLC_S7.Write("DB3.DBX50.3", false); } + MessageLog.GetInstance.ShowRunLog($"{recipeName}托盘1_4号桶允许配料"); } } for (int i = 1; i < 16; i++) { - if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) + if (RTrig.GetInstance("柔性味魔方配料完成").Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)) { 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.CutWeightFeedback; @@ -628,7 +643,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")) + if (RTrig.GetInstance("配方配料完成").Start(HKDevice.HK_PLC_S7.Read("DB3.DBX1.1"))) { var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); MessageLog.GetInstance.ShowRunLog($"配方{res.RecipeName}配料完成"); diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index 16ac5f45..8d217006 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -96,7 +96,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } public void Init() { - TestData(); + //TestData(); IpAddressLines(); DeviceDataInit(); ThreadManage.GetInstance().StartLong(new Action(() => diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialColl.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialColl.cs new file mode 100644 index 00000000..6202116d --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialColl.cs @@ -0,0 +1,99 @@ +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.RawMaterial +{ + public class RawMaterialColl : ObservableObject + { + /// + /// 原料设备IP + /// + public string DeviceIp { get; set; } + + /// + /// 原料名称 + /// + public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } + private string _mRawMaterialName; + + /// + /// 原料重量设置 + /// + public uint RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; OnPropertyChanged(); } } + private uint _mRawMaterialWeight; + + + /// + /// 原料来源 + /// 0:本地 + /// 1:设备 + /// + public ushort RawMaterialSource { get { return _mRawMaterialSource; } set { _mRawMaterialSource = value; OnPropertyChanged(); } } + private ushort _mRawMaterialSource; + + /// + /// 原料类型 MW18 + /// 1:液体 + /// 2:膏体 + /// 3:粉体 + /// + [Newtonsoft.Json.JsonIgnore] + public ushort RawMaterialType { get { return _mRawMaterialType; } set { _mRawMaterialType = value; OnPropertyChanged(); } } + private ushort _mRawMaterialType; + + /// + /// 料仓重量反馈 MD40 + /// + [Newtonsoft.Json.JsonIgnore] + public float WeightFeedback { get { return _mWeightFeedback; } set { _mWeightFeedback = value; OnPropertyChanged(); } } + private float _mWeightFeedback; + + /// + /// 上限反馈 + /// + [Newtonsoft.Json.JsonIgnore] + public bool UpLimtFeedback { get { return _mUpLimtFeedback; } set { _mUpLimtFeedback = value; OnPropertyChanged(); } } + private bool _mUpLimtFeedback; + + /// + /// 下限反馈 + /// + [Newtonsoft.Json.JsonIgnore] + public bool DownLimtFeedback { get { return _mDownLimtFeedback; } set { _mDownLimtFeedback = value; OnPropertyChanged(); } } + private bool _mDownLimtFeedback; + + /// + /// 下料重量反馈 MD52 + /// + [Newtonsoft.Json.JsonIgnore] + public float UpLimtWeightFeedback { get { return _mUpLimtWeightFeedback; } set { _mUpLimtWeightFeedback = value; OnPropertyChanged(); } } + private float _mUpLimtWeightFeedback; + + + /// + /// 原料ID + /// + public string RawMaterialId { get { return _mRawMaterialId; } set { _mRawMaterialId = value; OnPropertyChanged(); } } + private string _mRawMaterialId; + + /// + /// 原料设备执行状态 + /// 1:等待配料 + /// 2:下料中 + /// 3:下料完成 + /// + [Newtonsoft.Json.JsonIgnore] + public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } } + private ushort _mRecipeStatus = 1; + + /// + /// 原料对应的桶号 + /// + public ushort BarrelNum { get { return _mBarrelNum; } set { _mBarrelNum = value; OnPropertyChanged(); } } + private ushort _mBarrelNum = 1; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs index 7fe70363..c9569711 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial; using BPASmartClient.Model; using Microsoft.Toolkit.Mvvm.ComponentModel; @@ -40,6 +41,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model [Newtonsoft.Json.JsonIgnore] public AutoResetEvent Are { get; set; } = new AutoResetEvent(false); + /// + /// 托盘编号 + /// + public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } + private int _mTrayCode; + /// /// 原料集合 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs index 359c1eda..586a7f0e 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs @@ -13,6 +13,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } private string _mRawMaterialName; + /// /// 原料对应的桶号 /// @@ -31,6 +32,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } } private float _mLaying_Off_Weight; + /// + /// 料仓剩余重量 + /// + public double StockBinRemainingWeight { get { return _mStockBinRemainingWeight; } set { _mStockBinRemainingWeight = value; } } + private double _mStockBinRemainingWeight; + /// /// 原料对应料仓的位置 /// diff --git a/BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml b/BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml index 293aa879..b3e5e4f2 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/NewRecipeView.xaml @@ -87,38 +87,67 @@ + - - - - - - - + + + + + + + + + + +