From 32037eada588419215661a6df573b9eac2be696b Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Sat, 6 May 2023 17:13:50 +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 --- .../Model/GVL_SmallStation.cs | 14 +- .../Model/Par/ConnectParMode.cs | 3 + .../Model/ProcessControl.cs | 130 ++++++++++++++---- .../Model/WindSend/WindSendDeviceStatus.cs | 6 + .../Model/WindSend/WindSendRawMaterial.cs | 13 ++ .../Model/WindSend/WindSend_Read.cs | 37 ++++- .../Model/WindSend/WindSend_Write.cs | 20 ++- .../View/ManualFlowView.xaml | 20 ++- .../View/RecipeInfosView.xaml | 16 +++ .../View/SystemParView.xaml | 10 ++ .../ViewModel/ManualFlowViewModel.cs | 14 +- .../ViewModel/NewLocalRecipeViewModel.cs | 8 +- .../ViewModel/RecipeInfosViewModel.cs | 4 + .../ViewModel/SystemParViewModel.cs | 8 +- 14 files changed, 260 insertions(+), 43 deletions(-) diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index dba1e0b7..47d8ffe4 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -1,6 +1,7 @@ using BPASmartClient.JXJFoodSmallStation.Model.GVL; using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; using BPASmartClient.JXJFoodSmallStation.Model.Siemens; +using BPASmartClient.JXJFoodSmallStation.Model.WindSend; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -18,6 +19,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model private GVL_SmallStation() { } public PlcReadAddressDB3 plcReadDataDB3 { get; set; } = new PlcReadAddressDB3(); + + + public WindSend_Write WindSendDB95 { get; set; } = new WindSend_Write(); + + public WindSend_Read WindSendDB94 { get; set; } = new WindSend_Read(); /// /// 配料站料仓数目 /// @@ -161,11 +167,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public bool HeartBeatToPlc { get; set; } = false; - [VarComm("Global", "来自plc的心跳")] + [VarComm("Global", "屏蔽小料站料仓不足15个报警")] public bool DisEnableStockAlarm { get; set; } = false; + [VarComm("Global", "配方制作完成数量")] + /// + /// 配方制作完成数量 + /// + public int RecipeDosingCompleNum { get; set; } = 0; + [VarComm("Global", "来自plc的心跳")] diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Par/ConnectParMode.cs b/BPASmartClient.JXJFoodSmallStation/Model/Par/ConnectParMode.cs index a9d552d9..4c57d660 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Par/ConnectParMode.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Par/ConnectParMode.cs @@ -15,6 +15,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Par private bool _mWindSendConnect; public bool HKPlcConnect { get { return _mHKPlcConnect; } set { _mHKPlcConnect = value; OnPropertyChanged(); } } private bool _mHKPlcConnect; + public bool ShieldStockbinAlarm { get { return _mShieldStockbinAlarm; } set { _mShieldStockbinAlarm = value; OnPropertyChanged(); } } + private bool _mShieldStockbinAlarm; + public short AxisLoadSpeed { get { return _mAxisLoadSpeed; } set { _mAxisLoadSpeed = value; OnPropertyChanged(); } } private short _mAxisLoadSpeed; diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index b3bfa792..0d6f4442 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -85,6 +85,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { + GVL_SmallStation.GetInstance.DisEnableStockAlarm = Json.Data.deviceConnectPar.ShieldStockbinAlarm; if (HKDevice.IsConnected) { GVL_SmallStation.GetInstance.HeartBeatToPlc = !GVL_SmallStation.GetInstance.HeartBeatToPlc; @@ -195,6 +196,59 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } + if (WindSendDevice.IsConnected) + { + foreach (PropertyInfo item in typeof(WindSend_Write).GetProperties()) + { + int index = Array.FindIndex(CommData.ToArray(), p => p.Name == item.Name); + if (index >= 0) + { + if (item.PropertyType.IsArray) + { + CommData.ElementAt(index).Value = ""; + Array array = (Array)item.GetValue(GVL_SmallStation.GetInstance.plcReadDataDB3, null); + foreach (var values in array) + { + string data = values.ToString(); + if (data.ToLower() == "false") + data = "0"; + if (data.ToLower() == "true") + data = "1"; + CommData.ElementAt(index).Value = CommData.ElementAt(index).Value + data + ","; + } + } + else + { + CommData.ElementAt(index).Value = GVL_SmallStation.GetInstance.WindSendDB95.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance.WindSendDB95, null).ToString(); + } + } + } + foreach (PropertyInfo item in typeof(WindSend_Read).GetProperties()) + { + int index = Array.FindIndex(CommData.ToArray(), p => p.Name == item.Name); + if (index >= 0) + { + if (item.PropertyType.IsArray) + { + CommData.ElementAt(index).Value = ""; + Array array = (Array)item.GetValue(GVL_SmallStation.GetInstance.plcReadDataDB3, null); + foreach (var values in array) + { + string data = values.ToString(); + if (data.ToLower() == "false") + data = "0"; + if (data.ToLower() == "true") + data = "1"; + CommData.ElementAt(index).Value = CommData.ElementAt(index).Value + data + ","; + } + } + else + { + CommData.ElementAt(index).Value = GVL_SmallStation.GetInstance.WindSendDB94.GetType().GetProperty(item.Name).GetValue(GVL_SmallStation.GetInstance.WindSendDB94, null).ToString(); + } + } + } + } foreach (PropertyInfo item in typeof(GVL_SmallStation).GetProperties()) { int index = Array.FindIndex(ProcessVar.ToArray(), p => p.Name == item.Name); @@ -701,60 +755,42 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (GVL_SmallStation.GetInstance.WindSendDosingStatus == 1) { - WindSendReset(); - WindSendData.TargetRecipeCode = code; - WindSendData.IsAllowDosing = true; + WindSend_Write WindSendData111 = new WindSend_Write(); + WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData111, 95); + Thread.Sleep(200); + WindSendData111.TargetRecipeCode = code; + WindSendData111.IsAllowDosing = true; foreach (var item in RemoteRecipes.ElementAt(index).WindSend) { if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(0).RawMaterialName || item.Location == 1) { - WindSendData.RawMaterial1_SetWeight = item.RawMaterialWeight; + WindSendData111.RawMaterial1_SetWeight = item.RawMaterialWeight; MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); } - else - { - WindSendData.RawMaterial1_SetWeight = 0; - } if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(1).RawMaterialName || item.Location == 2) { - WindSendData.RawMaterial2_SetWeight = item.RawMaterialWeight; + WindSendData111.RawMaterial2_SetWeight = item.RawMaterialWeight; MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); } - else - { - WindSendData.RawMaterial2_SetWeight = 0; - } if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(2).RawMaterialName || item.Location == 3) { - WindSendData.RawMaterial3_SetWeight = item.RawMaterialWeight; + WindSendData111.RawMaterial3_SetWeight = item.RawMaterialWeight; MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); } - else - { - WindSendData.RawMaterial3_SetWeight = 0; - } if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(3).RawMaterialName || item.Location == 4) { - WindSendData.RawMaterial4_SetWeight = item.RawMaterialWeight; + WindSendData111.RawMaterial4_SetWeight = item.RawMaterialWeight; MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); } - else - { - WindSendData.RawMaterial4_SetWeight = 0; - } if (item.RawMaterialName == Json.Data.windSendRawMaterial.ElementAt(4).RawMaterialName || item.Location == 5) { - WindSendData.RawMaterial5_SetWeight = item.RawMaterialWeight; + WindSendData111.RawMaterial5_SetWeight = item.RawMaterialWeight; MessageNotify.GetInstance.ShowRunLog($"风送料仓{item.RawMaterialName},设定重量{item.RawMaterialWeight}"); } - else - { - WindSendData.RawMaterial5_SetWeight = 0; - } } GVL_SmallStation.GetInstance.WindSendDosing = true; GVL_SmallStation.GetInstance.WindSendDosingStatus = 2; - WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData, 95); + WindSendDevice.Siemens_PLC_S7.WriteClass(WindSendData111, 95); } } else @@ -891,6 +927,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model bool DosingComple = HKDevice.HK_PLC_S7.Read("DB3.DBX6." + recipeNum); if ((RTrig.GetInstance("配方配料完成").Start(DosingComple)) || (GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] > 0 && DosingComple)) { + GVL_SmallStation.GetInstance.RecipeDosingCompleNum = GVL_SmallStation.GetInstance.RecipeDosingCompleNum + 1; GVL_SmallStation.GetInstance.StockBinDosingIssue[recipeNum] = 0; if (GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] > 0) { @@ -1008,6 +1045,40 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } + foreach (PropertyInfo item in typeof(WindSend_Read).GetProperties()) + { + if (Attribute.IsDefined(item, typeof(VarCommAttribute))) + { + string type = item.PropertyType.ToString(); + CommData.Add(new PlcInfos() + { + Count = CommData.Count + 1, + Name = item.Name, + Address = item.GetCustomAttribute().Address, + Type = type.Substring(type.IndexOf(".") + 1), + Describe = item.GetCustomAttribute().Describe, + Value = item.GetValue(GVL_SmallStation.GetInstance.WindSendDB94).ToString(), + }); + } + } + + foreach (PropertyInfo item in typeof(WindSend_Write).GetProperties()) + { + if (Attribute.IsDefined(item, typeof(VarCommAttribute))) + { + string type = item.PropertyType.ToString(); + CommData.Add(new PlcInfos() + { + Count = CommData.Count + 1, + Name = item.Name, + Address = item.GetCustomAttribute().Address, + Type = type.Substring(type.IndexOf(".") + 1), + Describe = item.GetCustomAttribute().Describe, + Value = item.GetValue(GVL_SmallStation.GetInstance.WindSendDB95).ToString(), + }); + } + } + foreach (PropertyInfo item in typeof(GVL_SmallStation).GetProperties()) { if (Attribute.IsDefined(item, typeof(VarCommAttribute))) @@ -1518,6 +1589,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model WindSendDevice.Siemens_PLC_S7.Write("DB95.DBD4", weight); WindSendDevice.Siemens_PLC_S7.Write("DB95.DBD8", weight); WindSendDevice.Siemens_PLC_S7.Write("DB95.DBD12", weight); + WindSendDevice.Siemens_PLC_S7.Write("DB95.DBD16", weight); WindSendDevice.Siemens_PLC_S7.Write("DB95.DBX38.1", false); } public void RawMaterialNameWithCode() diff --git a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs index 7ea4b6ac..c209bf98 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendDeviceStatus.cs @@ -24,9 +24,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (IsConnected) { + var res0 = this.Siemens_PLC_S7.ReadClass(95); + if (res0 != null && res0 is WindSend_Write WriteData) + { + GVL_SmallStation.GetInstance.WindSendDB95 = WriteData; + } var res1 = this.Siemens_PLC_S7.ReadClass(94); if (res1 != null && res1 is WindSend_Read readData) { + GVL_SmallStation.GetInstance.WindSendDB94 = readData; GVL_SmallStation.GetInstance.WindSendAllowAGVPutGet = readData.HoodLiftInPlace; Siemens_PLC_S7.Write("DB95.DBX38.2", GVL_SmallStation.GetInstance.Station1HaveTray);//工站1有托盘 switch (GVL_SmallStation.GetInstance.WindSendDosingStatus) diff --git a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs index 7d48cee8..2b9f1a54 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSendRawMaterial.cs @@ -30,5 +30,18 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public float DosingCompleWeight { get { return _mDosingCompleWeight; } set { _mDosingCompleWeight = value; OnPropertyChanged(); } } private float _mDosingCompleWeight; + + + /// + /// 原料对应的桶号 + /// + 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; } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs index 222a2f6c..64d134d7 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Read.cs @@ -1,4 +1,5 @@ -using BPASmartClient.S7Net; +using BPASmartClient.JXJFoodSmallStation.Model.GVL; +using BPASmartClient.S7Net; using System; using System.Collections.Generic; using System.Linq; @@ -7,74 +8,106 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodSmallStation.Model.WindSend { - internal class WindSend_Read + public class WindSend_Read { + [VarComm("DB94.DBX0.0", "吸风罩提升到位")] /// /// 吸风罩提升到位 /// public bool HoodLiftInPlace { get; set; } + + [VarComm("DB94.DBX0.1", "配方接收完成")] /// /// 配方接收完成 /// public bool RecipeReceiveFinish { get; set; } + + [VarComm("DB94.DBX0.2", "制作完成信号")] /// /// 制作完成信号 /// public bool CurrentCompleteSign { get; set; } + + [VarComm("DB94.DBX0.3", "允许下发信号")] /// /// 允许下发信号 /// public bool IsAllowIssue { get; set; } + + [VarComm("DB94.DBX0.4", "排料完成信号")] /// /// 排料完成信号 /// public bool DisChargeComple { get; set; } + + [VarComm("DB94.DBW2", "当前配方编码")] /// /// 当前配方编码 /// [Siemens(16)] public string CurrentRecipeCode { get; set; } = ""; + + [VarComm("DB94.DBW20", "系统状态")] /// /// 系统状态 /// public short SystemRunStatus { get; set; } + + [VarComm("DB94.DBD22", "原料1下料完成重量")] /// /// 原料1下料完成重量 /// public float RawMaterial1_FinishWeight { get; set; } + + [VarComm("DB94.DBD26", "原料2下料完成重量")] /// /// 原料2下料完成重量 /// public float RawMaterial2_FinishWeight { get; set; } + + [VarComm("DB94.DBD30", "原料3下料完成重量")] /// /// 原料3下料完成重量 /// public float RawMaterial3_FinishWeight { get; set; } + + [VarComm("DB94.DBD34", "原料4下料完成重量")] /// /// 原料4下料完成重量 /// public float RawMaterial4_FinishWeight { get; set; } + + [VarComm("DB94.DBD38", "原料5下料完成重量")] /// /// 原料5下料完成重量 /// public float RawMaterial5_FinishWeight { get; set; } + [VarComm("DB94.DBD42", "原料1料仓重量")] /// /// 原料1料仓重量 /// public float RawMaterial1_StockBinWeight { get; set; } + + [VarComm("DB94.DBD46", "原料2料仓重量")] /// /// 原料2料仓重量 /// public float RawMaterial2_StockBinWeight { get; set; } + + [VarComm("DB94.DBD50", "原料3料仓重量")] /// /// 原料3料仓重量 /// public float RawMaterial3_StockBinWeight { get; set; } + + [VarComm("DB94.DBD54", "原料4料仓重量")] /// /// 原料4料仓重量 /// public float RawMaterial4_StockBinWeight { get; set; } + + [VarComm("DB94.DBD58", "原料5料仓重量")] /// /// 原料5料仓重量 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Write.cs b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Write.cs index fd619b57..bf7edf6d 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Write.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/WindSend/WindSend_Write.cs @@ -1,4 +1,5 @@ -using BPASmartClient.S7Net; +using BPASmartClient.JXJFoodSmallStation.Model.GVL; +using BPASmartClient.S7Net; using System; using System.Collections.Generic; using System.Linq; @@ -9,39 +10,56 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.WindSend { public class WindSend_Write { + [VarComm("DB95.DBD0", "原料1设定重量")] /// /// 原料1设定重量 /// public float RawMaterial1_SetWeight { get; set; } + + [VarComm("DB95.DBD4", "原料2设定重量")] /// /// 原料2设定重量 /// public float RawMaterial2_SetWeight { get; set; } + + [VarComm("DB95.DBD8", "原料3设定重量")] /// /// 原料3设定重量 /// public float RawMaterial3_SetWeight { get; set; } + + [VarComm("DB95.DBD12", "原料4设定重量")] /// /// 原料4设定重量 /// public float RawMaterial4_SetWeight { get; set; } + + [VarComm("DB95.DBD16", "原料5设定重量")] /// /// 原料5设定重量 /// public float RawMaterial5_SetWeight { get; set; } + + [VarComm("DB95.DBW20", "目标配方编码")] /// /// 目标配方编码 /// [Siemens(16)] public string TargetRecipeCode { get; set; } = ""; + + [VarComm("DB95.DBX38.0", "允许配料")] /// /// 允许配料 /// public bool IsAllowDosing { get; set; } + + [VarComm("DB95.DBX38.1", "配方制作完成接收")] /// /// 配方制作完成接收 /// public bool RecipeCompleRec { get; set; } + + [VarComm("DB95.DBX38.2", "工位1有信号")] /// /// 工位1有信号 /// diff --git a/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml b/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml index 4b6e9284..9fcc8066 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml @@ -66,7 +66,7 @@ VerticalAlignment="Center" FontSize="25" Foreground="#FF2AB2E7" /> -