From cef3957d9d8fe5f221eca6a33d342da819a6584f Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Mon, 24 Oct 2022 14:39:44 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E5=90=89=E9=A6=99=E5=B1=85=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.JXJFoodBigStation/App.config | 2 +- .../Model/HK_PLC/DB_Write.cs | 3 +- .../Model/HK_PLC/HKDeviceStatus.cs | 12 +- .../HK_PLC/{Test1.cs => StockBinName.cs} | 2 +- .../Model/ProcessControl.cs | 396 +++++------------- .../Model/Siemens/DL_DataColl_DB.cs | 39 ++ .../Model/Siemens/DL_Finish_DB.cs | 35 +- .../Model/Siemens/DL_Start_DB.cs | 35 +- .../Model/Siemens/DL_Status_DB.cs | 66 ++- .../Model/Siemens/SiemensDeviceStatus.cs | 17 +- .../Model/ProcessControl.cs | 6 +- .../Model/Siemens/SiemensDeviceStatus.cs | 1 + .../Model/Siemens/XL_DataColl_DB.cs | 39 ++ .../Model/Siemens/XL_Finish_DB.cs | 20 +- .../Model/Siemens/XL_Start_DB.cs | 8 +- .../Model/Siemens/XL_Status_DB.cs | 29 +- 16 files changed, 306 insertions(+), 404 deletions(-) rename BPASmartClient.JXJFoodBigStation/Model/HK_PLC/{Test1.cs => StockBinName.cs} (97%) create mode 100644 BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs diff --git a/BPASmartClient.JXJFoodBigStation/App.config b/BPASmartClient.JXJFoodBigStation/App.config index e5c7f162..3559a687 100644 --- a/BPASmartClient.JXJFoodBigStation/App.config +++ b/BPASmartClient.JXJFoodBigStation/App.config @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs index f03a21f0..4edb4386 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs @@ -79,7 +79,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public float Bareel1Bin13SetWeight { get; set; } public float Bareel1Bin14SetWeight { get; set; } - public float Bareel2Bin1SetWeight { get; set; } public float Bareel2Bin2SetWeight { get; set; } public float Bareel2Bin3SetWeight { get; set; } @@ -94,7 +93,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public float Bareel2Bin12SetWeight { get; set; } public float Bareel2Bin13SetWeight { get; set; } public float Bareel2Bin14SetWeight { get; set; } - public float Bareel4Bin1SetWeight { get; set; } public float Bareel4Bin2SetWeight { get; set; } @@ -110,6 +108,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public float Bareel4Bin12SetWeight { get; set; } public float Bareel4Bin13SetWeight { get; set; } public float Bareel4Bin14SetWeight { get; set; } + public float Bareel5Bin1SetWeight { get; set; } public float Bareel5Bin2SetWeight { get; set; } public float Bareel5Bin3SetWeight { get; set; } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index 102503c9..38cd6123 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -17,7 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public bool IsConnected => HK_PLC_S7.IsConnected; public DB_Write PlcWrite = new DB_Write(); public DB_Read PlcRead = new DB_Read(); - + public StockBinName StockBinName = new StockBinName(); public void Init() { if (IsConnected) @@ -26,11 +26,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { HK_PLC_S7.WriteClass(PlcWrite, 99); var res1 = HK_PLC_S7.ReadClass(98); - var res2 = HK_PLC_S7.ReadClass(97); + var res2 = HK_PLC_S7.ReadClass(97); if (res1 != null && res1 is DB_Read data1) { PlcRead = data1; } + if (res2 != null && res2 is StockBinName data2) + { + StockBinName = data2; + } Thread.Sleep(10); }),"信号收发处理"); } @@ -264,7 +268,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC } else { - MessageLog.GetInstance.ShowRunLog($"桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号:{recipe.TrayCode},桶号:{barrel},位置:{loc},重量:{recipe.RawMaterial.ElementAt(index).RawMaterialWeight}"); switch (barrel) { case 1: @@ -470,7 +474,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC default: break; } - } + } } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/Test1.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs similarity index 97% rename from BPASmartClient.JXJFoodBigStation/Model/HK_PLC/Test1.cs rename to BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs index 0a9f0d6c..69529513 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/Test1.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/StockBinName.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { - internal class Test1 + public class StockBinName { [Siemens(6)] public string RawMaterialName1 { get; set; } diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index ee3e1e4e..27d7ae01 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -48,27 +48,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model public ConcurrentQueue RecipeQueue4 = new ConcurrentQueue(); public ConcurrentQueue RecipeQueue5 = new ConcurrentQueue(); /// - /// AGV到达工站队列 - /// - public ConcurrentQueue AGVToWorkStationQueue = new ConcurrentQueue(); - /// /// 接收原料数据 /// public RecipeRawMaterial RawMaterial; public void Init() { - RawMaterialsNamePos.Add("1", 1); - RawMaterialsNamePos.Add("2", 2); - RawMaterialsNamePos.Add("3", 3); - RawMaterialsNamePos.Add("4", 4); - RawMaterialsNamePos.Add("5", 5); - RawMaterialsNamePos.Add("6", 6); - RawMaterialsNamePos.Add("7", 7); - RawMaterialsNamePos.Add("8", 8); - RawMaterialsNamePos.Add("9", 9); - RawMaterialsNamePos.Add("10", 10); - RawMaterialsNamePos.Add("11", 11); - RawMaterialsNamePos.Add("12", 12); ActionManage.GetInstance.Register(new Action((res) => { ObservableCollection RawMaterials = new ObservableCollection(); @@ -87,7 +71,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model RawMaterialBarrelNum = recipe.Material[i].Material_BarrelNum, RawMaterialWeight = recipe.Material[i].Material_Weight, RawMaterialLocation = (int)RawMaterialsNamePos[recipe.Material[i].Material_Name] - }); + }); } else { @@ -99,7 +83,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model RecipeName = recipe.RecipeName, RecipeCode = recipe.RecipeCode, RawMaterial = RawMaterials, - TrayCode = recipe.TrayCode + //TrayCode = recipe.Order_No, }); } } @@ -108,7 +92,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; try { - HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); + //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); if (HKDevice.IsConnected) { @@ -138,136 +122,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.RawMaterialLocation = Convert.ToInt32(item.RawMaterialName); } } - + MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败"); } }), "ManualSendRecipe", true); RecipeQueue1.Clear(); - - - //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { - //ReadPLCDeviceInfo(); ReceviceData(); RecipeInfoToHKPLC(); Thread.Sleep(10); }), "流程处理", true); - ThreadManage.GetInstance().StartLong(new Action(() => - { - if (HKDevice.IsConnected && SiemensDevice.IsConnected) - { - AgvGetInOut(); - } - Thread.Sleep(10); - }), "AGV进站送取货", true); - ThreadManage.GetInstance().StartLong(new Action(() => - { - ReadSiemensCommData(); - ReadHKPLCCommData(); - Thread.Sleep(10); - }), "读取西门子和海科PLC的数据", true); - } - /// - /// AGV送货 - /// - /// - private void AGV_Delivery(int bitNum) - { - if ((ReadSiemens("M4002." + bitNum) is bool) && BigStation.AgvDeliveryPosition == 0) - { - BigStation.AgvDeliveryPosition = 1; - WriteHKPLC("M4002." + bitNum, true); - WriteSiemens("M4002." + bitNum, false); - } - else if (ReadHK("M5002." + bitNum) is bool && BigStation.AgvDeliveryPosition == 1) - { - BigStation.AgvDeliveryPosition = 2; - WriteSiemens("M5002." + bitNum, true); - WriteHKPLC("M5002." + bitNum, false); - } - else if (ReadSiemens("M4004." + bitNum) is bool && BigStation.AgvDeliveryPosition == 2) - { - BigStation.AgvDeliveryPosition = 3; - WriteHKPLC("M4004." + bitNum, true); - WriteSiemens("M4004." + bitNum, false); - } - else if (ReadHK("M5004." + bitNum) is bool && BigStation.AgvDeliveryPosition == 3) - { - BigStation.AgvDeliveryPosition = 4; - WriteSiemens("M5004." + bitNum, true); - WriteHKPLC("M5004." + bitNum, false); - } - else if (ReadSiemens("M4005." + bitNum) is bool && BigStation.AgvDeliveryPosition == 4) - { - BigStation.AgvDeliveryPosition = 5; - WriteHKPLC("M4005." + bitNum, true); - WriteSiemens("M4005." + bitNum, false); - } - else if (ReadHK("M5005." + bitNum) is bool && BigStation.AgvDeliveryPosition == 5) - { - WriteSiemens("M5005." + bitNum, true); - WriteHKPLC("M5005." + bitNum, false); - } - } - /// - /// AGV取货 - /// - /// - private void AGV_Pick(int bitNum) - { - if (ReadSiemens("M4003" + bitNum) is bool && BigStation.AgvPickUpPosition == 0) - { - BigStation.AgvPickUpPosition = 1; - WriteHKPLC("M4003." + bitNum, true); - WriteSiemens("M4003." + bitNum, false); - } - if (ReadHK("M5003" + bitNum) is bool && BigStation.AgvPickUpPosition == 1) - { - BigStation.AgvPickUpPosition = 2; - WriteSiemens("M5003" + bitNum, true); - WriteHKPLC("M5003" + bitNum, false); - } - if (ReadSiemens("M4006." + bitNum) is bool && BigStation.AgvPickUpPosition == 2) - { - BigStation.AgvPickUpPosition = 3; - WriteHKPLC("M4006." + bitNum, true); - WriteSiemens("M4006." + bitNum, false); - } - if (ReadHK("M5006." + bitNum) is bool && BigStation.AgvPickUpPosition == 3) - { - WriteSiemens("M5006." + bitNum, true); - WriteHKPLC("M5006." + bitNum, false); - } - } - /// - /// AGV进站送货 - /// - private void AgvGetInOut() - { - //获取工位上是否有小车 - SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool) - HKDevice.HK_PLC_S7.Read("M4007.0")); - //检测AGV到站信号 - if (AGVToWorkStationQueue.Count > 0) - { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == AGVToWorkStationQueue.ElementAt(0)); - int TrayLocation = RemoteRecipes.ElementAt(index).TrayCode;//根据配方编号,找到托盘的ID 托盘ID1-6 - string RecipeCode = (string)RemoteRecipes.ElementAt(index).RecipeCode; - if (TrayLocation > 0 && TrayLocation < 7) - { - AGV_Delivery(TrayLocation - 1); - if (BigStation.AgvDeliveryPosition == 5) - { - BigStation.AgvDeliveryPosition = 0; - } - AGV_Pick(TrayLocation - 1); - if (BigStation.AgvPickUpPosition == 3) - { - BigStation.AgvPickUpPosition = 0; - AGVToWorkStationQueue.TryDequeue(out RecipeCode); - } - } - } } private void ReceviceData() { @@ -318,6 +182,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model RecipeQueue4.Clear(); RecipeQueue5.Clear(); BigStation.Recipe1DosingStatus = 0; + BigStation.Recipe2DosingStatus = 0; + BigStation.Recipe3DosingStatus = 0; + BigStation.Recipe4DosingStatus = 0; + BigStation.Recipe5DosingStatus = 0; } } private void RecipeInfoToHKPLC() @@ -333,23 +201,20 @@ namespace BPASmartClient.JXJFoodBigStation.Model { HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe1IssuedFinish = true; - //HKDevice.HK_PLC_S7.Write("DB98.DBX0.1", false);//复位允许下发配方1信号 BigStation.Recipe1DosingStatus = 1; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe1 && BigStation.Recipe1DosingStatus == 1) { BigStation.Recipe1DosingStatus = 2; HKDevice.PlcWrite.Recipe1IssuedFinish = false; - HKDevice.PlcWrite.RecipeCode = 0; - HKDevice.PlcWrite.TrayCode = 0; - WeightReset(); - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) { BigStation.Recipe1DosingStatus = 3; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe1TrayCode == 1) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) @@ -425,7 +290,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model { SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 3); } - //HKDevice.HK_PLC_S7.Write("DB98.DBX1.1",false); RecipeQueue1.TryDequeue(out code); IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 if (!BigStation.IsAllowManual) @@ -453,21 +317,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe2IssuedFinish = true; BigStation.Recipe2DosingStatus = 1; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe2 && BigStation.Recipe2DosingStatus == 1) { BigStation.Recipe2DosingStatus = 2; HKDevice.PlcWrite.Recipe2IssuedFinish = false; - HKDevice.PlcWrite.RecipeCode = 0; - HKDevice.PlcWrite.TrayCode = 0; - WeightReset(); - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } if (BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) { BigStation.Recipe2DosingStatus = 3; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe2TrayCode > 0) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) @@ -529,7 +391,6 @@ 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++) @@ -539,11 +400,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model 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; } - } if (SiemensDevice.IsConnected) { SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 3); + MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); } RecipeQueue2.TryDequeue(out code); IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 @@ -556,7 +417,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } BigStation.Recipe2DosingStatus = 0; - } } } @@ -572,20 +432,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe3IssuedFinish = true; BigStation.Recipe3DosingStatus = 1; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe3 && BigStation.Recipe3DosingStatus == 1) { BigStation.Recipe3DosingStatus = 2; - HKDevice.PlcWrite.RecipeCode = 0; - HKDevice.PlcWrite.TrayCode = 0; - WeightReset(); - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } if (HKDevice.PlcRead.Recipe3DosingFinish && BigStation.Recipe3DosingStatus == 2) { BigStation.Recipe3DosingStatus = 3; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe3TrayCode > 0) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) @@ -691,21 +549,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.StockBinPar(RemoteRecipes.ElementAt(index)); HKDevice.PlcWrite.Recipe4IssuedFinish = true; BigStation.Recipe4DosingStatus = 1; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe4 && BigStation.Recipe4DosingStatus == 1) { BigStation.Recipe4DosingStatus = 2; HKDevice.PlcWrite.Recipe4IssuedFinish = false; - HKDevice.PlcWrite.RecipeCode = 0; - HKDevice.PlcWrite.TrayCode = 0; - WeightReset(); - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + StockBinParReset(); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } if (BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) { BigStation.Recipe4DosingStatus = 3; - MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); if (HKDevice.PlcRead.Recipe4TrayCode > 0) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) @@ -799,128 +655,15 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - public ConcurrentDictionary ReadHKPLCData = new ConcurrentDictionary(); - public ConcurrentDictionary ReadSiemensData = new ConcurrentDictionary(); - - - private void ReadSiemensCommData() - { - if (SiemensDevice.IsConnected) - { - GetSiemensStatus("", new Action((obj) => - { - if (obj is bool[] bools && bools.Length > 0) - { - - } - })); - } - } - private void ReadHKPLCCommData() - { - if (HKDevice.IsConnected) - { - GetHKStatus("", new Action((obj) => - { - if (obj is bool[] bools && bools.Length > 0) - { - - } - })); - } - } - private void GetHKStatus(string key, Action action) - { - if (ReadHKPLCData.ContainsKey(key)) - { - if (ReadHKPLCData[key] != null) - { - action?.Invoke(ReadHKPLCData[key]); - } - } - } - private void GetSiemensStatus(string key, Action action) - { - - if (ReadSiemensData.ContainsKey(key)) - { - if (ReadSiemensData[key] != null) - { - action?.Invoke(ReadSiemensData[key]); - } - } - } - private void WriteSiemens(string Address, object Value) - { - if (SiemensDevice.IsConnected) - { - SiemensDevice.Siemens_PLC_S7.Write(Address, Value); - } - } - private void WriteHKPLC(string Address, object Value) - { - HKDevice.HK_PLC_S7.Write(Address, Value); - } - private object ReadSiemens(string Address) - { - if (SiemensDevice.IsConnected) - { - return SiemensDevice.Siemens_PLC_S7.Read(Address); - } - else - { - return null; - } - } - private bool[] ReadBoolsSiemens(int address, int count) - { - if (SiemensDevice.IsConnected) - { - return SiemensDevice.Siemens_PLC_S7.ReadBools(address, count); - } - else - { - return null; - } - } - private object ReadHK(string Address) - { - if (HKDevice.IsConnected) - { - return HKDevice.HK_PLC_S7.Read(Address); - } - else - { - return null; - } - } - private bool[] ReadBoolsHK(int address, int count) - { - if (HKDevice.IsConnected) - { - return HKDevice.HK_PLC_S7.ReadBools(address, count); - } - else - { - return null; - } - } /// - /// 获取料仓的原料名称和原料位置 + /// 下发配方的数据复位 /// - private void ReadPLCDeviceInfo() - { - /*for (int i = 0; i < 12; i++) - { - string RawMaterialName = HKDevice.HK_PLC_S7.Read(""); - short RawMaterialLocation = HKDevice.HK_PLC_S7.Read(""); - if (RawMaterialsNamePos.ContainsKey(RawMaterialName)) - RawMaterialsNamePos.Add(RawMaterialName, RawMaterialLocation); - }*/ - - } - private void WeightReset() + private void StockBinParReset() { + + HKDevice.PlcWrite.RecipeCode = 0; + HKDevice.PlcWrite.TrayCode = 0; + HKDevice.PlcWrite.Bareel1Bin1SetWeight = 0; HKDevice.PlcWrite.Bareel1Bin2SetWeight = 0; HKDevice.PlcWrite.Bareel1Bin3SetWeight = 0; @@ -982,5 +725,82 @@ namespace BPASmartClient.JXJFoodBigStation.Model HKDevice.PlcWrite.Bareel5Bin13SetWeight = 0; HKDevice.PlcWrite.Bareel5Bin14SetWeight = 0; } + private void testData() + { + RawMaterialsNamePos.Clear(); + if (!HKDevice.IsConnected) + { + HKDevice.StockBinName.RawMaterialName1 = "1"; + HKDevice.StockBinName.RawMaterialName2 = "2"; + HKDevice.StockBinName.RawMaterialName3 = "3"; + HKDevice.StockBinName.RawMaterialName4 = "4"; + HKDevice.StockBinName.RawMaterialName5 = "5"; + HKDevice.StockBinName.RawMaterialName6 = "6"; + HKDevice.StockBinName.RawMaterialName7 = "7"; + HKDevice.StockBinName.RawMaterialName8 = "8"; + HKDevice.StockBinName.RawMaterialName9 = "9"; + HKDevice.StockBinName.RawMaterialName10 = "10"; + HKDevice.StockBinName.RawMaterialName11 = "11"; + HKDevice.StockBinName.RawMaterialName12 = "12"; + HKDevice.StockBinName.RawMaterialName13 = "13"; + HKDevice.StockBinName.RawMaterialName14 = "14"; + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName1)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName1, 1); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName2)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName2, 2); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName3)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName3, 3); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName4)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName4, 4); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName5)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName5, 5); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName6)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName6, 6); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName7)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName7, 7); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName8)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName8, 8); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName9)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName9, 9); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName10)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName10, 10); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName11)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName11, 11); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName12)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName12, 12); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName13)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName13, 13); + } + if (!RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName14)) + { + RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName14, 14); + } + } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs new file mode 100644 index 00000000..f7279b1a --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_DataColl_DB.cs @@ -0,0 +1,39 @@ +using BPASmartClient.S7Net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model.Siemens +{ + public class DL_DataColl_DB + { + [Siemens(16)] + public string RecipeCode { get; set; } + [Siemens(16)] + public string RecipeName { get; set; } + public bool var1 { get; set; } + public bool var2 { get; set; } + + public bool var3 { get; set; } + + public bool var4 { get; set; } + + public bool var5 { get; set; } + + public bool var6 { get; set; } + + public bool var7 { get; set; } + + public bool var8 { get; set; } + + public bool var9 { get; set; } + public short Mode { get; set; } + + public bool[] Alarm { get; set; } = new bool[24]; + public int Reserved1 { get; set; } + public int Reserved2 { get; set; } + + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs index 4394ac10..80e91369 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.S7Net; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,32 +9,42 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { internal class DL_Finish_DB { + + /// + /// 配料完成信号确认 + /// + public bool Ask_For_Finish_PLC { get; set; } + + public short[] StandbyFinish { get; set; } = new short[4]; + [Siemens(16)] /// /// 生产工单编码 /// - public string Order_No; + public string Order_No{get; set; } + [Siemens(16)] /// /// 产品名称 /// - public string Product_Code; + public string Product_Code { get; set; } + public short job_No { get; set; } /// /// 原料信息 /// - public UDT1[] Material = new UDT1[20]; + public UDT1[] Material { get; set; } = new UDT1[20]; + public short ProcessTime { get; set; } /// /// 配料完成信号 /// - public bool Ask_For_Finish; - /// - /// 配料完成信号确认 - /// - public bool Ask_For_Finish_PLC; + public bool Ask_For_Finish { get; set; } + + public short[] StandbyFinish1 { get; set; } = new short[4]; } public class UDT1 { - public string Material_Name; - public float Material_Laying_Off_Weight; - public short Material_BarrelNum; + [Siemens(6)] + public string Material_Name { get; set; } + public float Material_Laying_Off_Weight { get; set; } + public short Material_BarrelNum { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs index 13066a70..a4a5c592 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.S7Net; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,44 +9,46 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { internal class DL_Start_DB { + [Siemens(16)] /// /// 配方编码 /// - public string RecipeCode; + public string RecipeCode { get; set; } + [Siemens(16)] /// /// 配发名称 /// - public string RecipeName; + public string RecipeName { get; set; } + public short Order_No { get; set; } + public short Pallet_No { get; set; } /// /// 物料信息 /// - public UDT[] Material = new UDT[20]; - /// - /// 托盘编号 - /// - public int TrayCode; + public UDT[] Material { get; set; } = new UDT[20]; + public bool Order_Type { get; set; } + public bool Order_Request_Ack { get; set; } + + public short[] Standby { get; set; } = new short[4]; /// /// 配方发送请求 /// - public bool Ask_For_Send_Bit; - /// - /// 上位机确认配方接收完成 - /// - public bool Ack_Ask_For_Send_Bit; + public bool Ask_For_Send_Bit { get; set; } + public short[] Standby1 { get; set; } = new short[4]; } public class UDT { + [Siemens(6)] /// /// 原料名称 /// - public string Material_Name; + public string Material_Name { get; set; } /// /// 原料重量 /// - public float Material_Weight; + public float Material_Weight { get; set; } /// /// 原料桶号 /// - public short Material_BarrelNum; + public short Material_BarrelNum { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs index 88126d64..efcaf0d1 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.S7Net; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,53 +9,36 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { internal class DL_Status_DB { - /// - /// 生产工单 - /// - public string RecipeCode; /// /// 配料开始 /// - public bool Dosing_Start; + public bool Dosing_Start { get; set; } /// /// 配料开始确认 /// - public bool Dosing_Confirm; - /// - /// 托盘占位情况 - /// - public bool[] Pallet_Position_Occ = new bool[16]; - /// - /// 工位允许放货架 - /// - public bool[] Allow_AGV_Put = new bool[16]; - /// - /// 工位允许取货架 - /// - public bool[] Allow_AGV_Get = new bool[16]; - /// - /// AGV请求放货架 - /// - public bool[] AGV_Request_Put = new bool[16]; - /// - /// AGV请求取货架 - /// - public bool[] AGV_Request_Get = new bool[16]; - /// - /// AGV放托盘完成 - /// - public bool[] AGV_Put_Done = new bool[16]; - /// - /// 托盘号 - /// - public short[] Pan_No = new short[16]; - /// - /// 配料时间 - /// - public int DosingTime; + public bool Dosing_Confirm { get; set; } + public bool Dosing_Cancel { get; set; } + public bool Dosing_Cancel2 { get; set; } + + public bool Dosing_Cancel3 { get; set; } + + public short a { get; set; } + public short[] Standby { get; set; } = new short[3]; + [Siemens(16)] /// - /// 备用 + /// 生产工单 /// - public byte Reserve; + public string RecipeCode { get; set; } + public bool Dosing_Cancel4 { get; set; } + + public bool Dosing_Cancel5 { get; set; } + + public bool Dosing_Cancel6 { get; set; } + + public bool Dosing_Cancel7 { get; set; } + + public short Dosing_Cancel8 { 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 a3361db3..d4969c2e 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -21,21 +21,22 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { ThreadManage.GetInstance().StartLong(new Action(() => { - var res = this.Siemens_PLC_S7.ReadClass(1); - var res1 = this.Siemens_PLC_S7.ReadClass(2); - var res2 = this.Siemens_PLC_S7.ReadClass(3); - if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit)) + var res = this.Siemens_PLC_S7.ReadClass(2301); + 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;//配方接受完成 + //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.Allow_AGV_Put[0])) + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.)) { ActionManage.GetInstance.Send("AGVToStation1Sign", res1); - res1.Allow_AGV_Put[0] = false; + //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])) @@ -68,7 +69,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens 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.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index e145bf5b..4404997f 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -80,7 +80,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { - MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); + //MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); } } Json.Data.Recipes.Add(new RemoteRecipeData() @@ -112,7 +112,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model try { //HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + //SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); //WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200,WindSend_PLC_IP); if (HKDevice.IsConnected) { @@ -272,7 +272,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model break; default: break; - } } else if (o.ToString().Contains("阻挡气缸")) @@ -327,7 +326,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model break; default: break; - } } else if (o.ToString().Contains("进料桶顶升气缸")) diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index 107f2920..031c17eb 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -24,6 +24,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens var res = this.Siemens_PLC_S7.ReadClass(2201); var res1 = this.Siemens_PLC_S7.ReadClass(2231); var res2 = this.Siemens_PLC_S7.ReadClass(2261); + var res4 = this.Siemens_PLC_S7.ReadClass(2291); if (res != null && res.Order_Request_ACK == false && GVL_SmallStation.GetInstance.IsAllowSiemensSendRecipe) { res.Order_Request_ACK = true; diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs new file mode 100644 index 00000000..dabd8bde --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_DataColl_DB.cs @@ -0,0 +1,39 @@ +using BPASmartClient.S7Net; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens +{ + internal class XL_DataColl_DB + { + [Siemens(16)] + public string RecipeCode { get; set; } + [Siemens(16)] + public string RecipeName { get; set; } + public bool var1 { get; set; } + public bool var2 { get; set; } + + public bool var3 { get; set; } + + public bool var4 { get; set; } + + public bool var5 { get; set; } + + public bool var6 { get; set; } + + public bool var7 { get; set; } + + public bool var8 { get; set; } + + public bool var9 { get; set; } + public short Mode { get; set; } + + public bool[] Alarm { get; set; } = new bool[24]; + public int Reserved1 { get; set; } + public int Reserved2 { get; set; } + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs index 0e977bde..7fe9e791 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs @@ -9,33 +9,37 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { internal class XL_Finish_DB { - [Siemens(6)] + + /// + /// 配料完成信号确认 + /// + public bool Ask_For_Finish_PLC { get; set; } + public short[] StandbyFinish { get; set; }=new short[4]; + + [Siemens(16)] /// /// 生产工单编码 /// /// 产品名称 /// public string Product_Code { get; set; } public short Job_No { get; set; } - public UDT2[] Powder = new UDT2[10]; + public UDT2[] Powder { get; set; } = new UDT2[10]; /// /// 原料信息 /// - public UDT1[] Material = new UDT1[20]; + public UDT1[] Material { get; set; } = new UDT1[20]; public short DosingTime { get; set; } /// /// 配料完成信号 /// public bool Ask_For_Finish { get; set; } - /// - /// 配料完成信号确认 - /// - public bool Ask_For_Finish_PLC { get; set; } + public short[] StandbyFinish2 { get; set; } = new short[4]; } public class UDT1 { diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs index 5109c0cf..cd7e7ad2 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs @@ -23,19 +23,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens public short StockCode { get; set; } public short TrayCode { get; set; } - public UDT2Start[] Powder = new UDT2Start[10]; + public UDT2Start[] Powder { get; set; } = new UDT2Start[10]; /// /// 物料信息 /// - public UDTStart[] Material = new UDTStart[20]; + public UDTStart[] Material { get; set; } = new UDTStart[20]; /// /// plc确认配方接收完成 /// public bool Order_Request_ACK { get; set; } - public short[] Standby = new short[4]; + public short[] Standby { get; set; } = new short[4]; public bool Order_Request { get; set; } - public short[] Standby1 = new short[4]; + public short[] Standby1 { get; set; } = new short[4]; } public class UDTStart diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs index 8e454427..85ec6ebd 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs @@ -7,8 +7,16 @@ using System.Threading.Tasks; namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { - internal class XL_Status_DB + public class XL_Status_DB { + public bool Dosing_Confirm { get; set; } + public bool Agv1 { get; set; } + public bool Agv2 { get; set; } + public bool Agv3 { get; set; } + public bool Agv4 { get; set; } + public short AgvPos { get; set; } + public short[] Standby { get; set; } = new short[3]; + [Siemens(16)] /// /// 生产工单 @@ -18,23 +26,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens /// 配料开始 /// public bool Dosing_Start { get; set; } - /// - /// 配料开始确认 - /// - public bool Dosing_Confirm; - public bool Agv1 { get; set; } - public bool Agv2 { get; set; } - public bool Agv3 { get; set; } - public bool Agv4 { get; set; } - public short AgvPos { get; set; } - - public UDTStatus[] Powder = new UDTStatus[10]; - - public bool Agv5{ get; set; } + public bool Agv5 { get; set; } public bool Agv6 { get; set; } public bool Agv7 { get; set; } - public int Agv8 { get; set; } + + public UDTStatus[] Powder { get; set; } = new UDTStatus[10]; + public short AgvUse { get; set; } + public short[] StandbyStatus { get; set; } = new short[4]; } public class UDTStatus { From ca436dbf90823572200bd331989dca034e5d6eb9 Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Mon, 24 Oct 2022 14:40:50 +0800 Subject: [PATCH 02/16] 1 --- SmartClient.sln | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/SmartClient.sln b/SmartClient.sln index fd280f95..3bfb83f0 100644 --- a/SmartClient.sln +++ b/SmartClient.sln @@ -178,9 +178,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.SmallBatchin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkMOC", "BPASmartClient.MorkMOC\BPASmartClient.MorkMOC.csproj", "{D5081D7B-3EBB-42C7-8FB9-A889870D08C2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.DosingHKProject", "BPASmartClient.DosingProject\BPASmartClient.DosingHKProject.csproj", "{6763F73A-555C-41E2-91F7-ADF26C59A946}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BPASmart.MenuLoad", "BPASmart.MenuLoad\BPASmart.MenuLoad.csproj", "{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.MenuLoad", "BPASmart.MenuLoad\BPASmart.MenuLoad.csproj", "{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1676,26 +1674,6 @@ Global {D5081D7B-3EBB-42C7-8FB9-A889870D08C2}.Release|x64.Build.0 = Release|Any CPU {D5081D7B-3EBB-42C7-8FB9-A889870D08C2}.Release|x86.ActiveCfg = Release|Any CPU {D5081D7B-3EBB-42C7-8FB9-A889870D08C2}.Release|x86.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|ARM.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|ARM.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|ARM64.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|x64.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|x64.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|x86.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|x86.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|Any CPU.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|ARM.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|ARM.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|ARM64.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|ARM64.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x64.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x64.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.Build.0 = Release|Any CPU {7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.Build.0 = Debug|Any CPU {7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -1798,7 +1776,6 @@ Global {E7CC45BF-7393-4BA7-A9AD-B1A1F5B265F3} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} {BA588F22-87FB-4124-AF62-CA8DC492ED7D} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} {D5081D7B-3EBB-42C7-8FB9-A889870D08C2} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} - {6763F73A-555C-41E2-91F7-ADF26C59A946} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} {7A7547D3-F2EF-4DA4-AD45-D1B49210082B} = {06F0B369-0483-46DD-82D2-70431FB505C1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution From 7a5b242ffc66fc8f254167203a101ed23ecbaaa4 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, 24 Oct 2022 15:00:37 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E6=9F=94=E6=80=A7=E5=91=B3=E9=AD=94?= =?UTF-8?q?=E6=96=B9=E8=AE=BE=E5=A4=87=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.CustomResource.csproj | 2 + .../Image/组合边框2.png | Bin 0 -> 808 bytes BPASmartClient.Model/Status.cs | 15 + .../柔性味魔方/RawMaterialModel.cs | 21 +- DosingSystem/Model/DeviceInquire.cs | 2 + .../Model/SiemensPlc/PlcToComputer.cs | 2 +- DosingSystem/View/RecipeControlView.xaml | 257 +++++++++++++++++- DosingSystem/View/RecipeControlView.xaml.cs | 36 ++- DosingSystem/ViewModel/DeviceListViewModel.cs | 6 + .../ViewModel/RecipeControlViewModel.cs | 212 +++++++++++---- SmartClient.sln | 69 ----- 11 files changed, 463 insertions(+), 159 deletions(-) create mode 100644 BPASmartClient.CustomResource/Image/组合边框2.png create mode 100644 BPASmartClient.Model/Status.cs diff --git a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj index 81e148b7..84783f76 100644 --- a/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj +++ b/BPASmartClient.CustomResource/BPASmartClient.CustomResource.csproj @@ -201,6 +201,7 @@ + @@ -362,6 +363,7 @@ + diff --git a/BPASmartClient.CustomResource/Image/组合边框2.png b/BPASmartClient.CustomResource/Image/组合边框2.png new file mode 100644 index 0000000000000000000000000000000000000000..8ffa46c32f090c2cc3f24013dd28c250417db45e GIT binary patch literal 808 zcmeAS@N?(olHy`uVBq!ia0y~yVAKY(mvFEF$@8WhybKIX?>$`{Ln`LHy|u7wN}xo; zLw`x1*}cDz5?-amY1&#amH-P``;rp4)j#QTju z|C*-0d)Mm?jZ7PvgpP1|Sm?-os!6-Ii>n|=ZtaaXuOe*c%>3SM&uqasuhHSqNB!07 zjXz)B$Y}jJDeax?@mF`x#8{~&q;LD*X!o6m1!RDLwu0lD1{R2Eqnu$8AQm#bKP%JL z$x3f9?oWUA%p%NxuE2)ia8Qa!d^jP0o76700wcLIXWBz&$4ah#Z(O{ypf(|X-kLeb zj0HdmBC(q7-kCG&Sr7j!W__?E=l)Mo-I+6g{*~X#Au~PUMZ*DL4q)(f^>bP0l+XkK DI>Z~B literal 0 HcmV?d00001 diff --git a/BPASmartClient.Model/Status.cs b/BPASmartClient.Model/Status.cs new file mode 100644 index 00000000..b49d9064 --- /dev/null +++ b/BPASmartClient.Model/Status.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model +{ + public enum Status + { + 等待配料, + 正在配料, + 配料完成 + } +} diff --git a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs index 7efb9e6b..7e508ead 100644 --- a/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs +++ b/BPASmartClient.Model/柔性味魔方/RawMaterialModel.cs @@ -104,7 +104,26 @@ namespace BPASmartClient.Model /// 3:下料完成 /// [Newtonsoft.Json.JsonIgnore] - public ushort RecipeStatus { get { return _mRecipeStatus; } set { _mRecipeStatus = value; OnPropertyChanged(); } } + public ushort RecipeStatus + { + get { return _mRecipeStatus; } + set + { + _mRecipeStatus = value; + if (value == 1) Status = Status.等待配料; + else if (value == 2) Status = Status.正在配料; + else if (value == 3) Status = Status.配料完成; + OnPropertyChanged(); + } + } private ushort _mRecipeStatus = 1; + + /// + /// 配料状态名称 + /// + [Newtonsoft.Json.JsonIgnore] + public Status Status { get { return _mStatus; } set { _mStatus = value; OnPropertyChanged(); } } + private Status _mStatus; + } } diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index f928ba15..b7218bf7 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -81,6 +81,7 @@ namespace BPASmartClient.DosingSystem devices.Add(new Devices() { DeviceName = $"测试设备{i + 1}", + DeviceNum = i + 1, IpAddress = $"192.168.1.{i + 1}", }); } @@ -102,6 +103,7 @@ namespace BPASmartClient.DosingSystem devices.Add(new Devices() { DeviceName = $"测试设备{i + 1}", + DeviceNum = i + 1, IpAddress = $"192.168.1.{i + 1}", }); } diff --git a/DosingSystem/Model/SiemensPlc/PlcToComputer.cs b/DosingSystem/Model/SiemensPlc/PlcToComputer.cs index 0bf6dcb9..65ab0fc2 100644 --- a/DosingSystem/Model/SiemensPlc/PlcToComputer.cs +++ b/DosingSystem/Model/SiemensPlc/PlcToComputer.cs @@ -17,7 +17,7 @@ namespace BPASmartClient.DosingSystem public bool Heartbeat { get; set; } /// - /// 接收完成 + /// 接收配方完成 /// public bool ResComplete { get; set; } diff --git a/DosingSystem/View/RecipeControlView.xaml b/DosingSystem/View/RecipeControlView.xaml index 19187468..bf2c21b4 100644 --- a/DosingSystem/View/RecipeControlView.xaml +++ b/DosingSystem/View/RecipeControlView.xaml @@ -338,10 +338,6 @@ ScrollViewer.HorizontalScrollBarVisibility="Disabled"> - @@ -351,8 +347,8 @@ @@ -715,7 +711,7 @@ - @@ -777,27 +773,260 @@ - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - diff --git a/DosingSystem/View/RecipeControlView.xaml.cs b/DosingSystem/View/RecipeControlView.xaml.cs index ca107fff..701a1f1a 100644 --- a/DosingSystem/View/RecipeControlView.xaml.cs +++ b/DosingSystem/View/RecipeControlView.xaml.cs @@ -24,33 +24,39 @@ namespace BPASmartClient.DosingSystem.View public RecipeControlView() { InitializeComponent(); - RadioButtonWait_Click(null,null); + RadioButtonWait_Click(null, null); } - - - private void RadioButtonCompelete_Click(object sender, RoutedEventArgs e) { - repiceList.ItemsSource = RecipeControlViewModel.UserTreeCompelete; - repiceList.Visibility = Visibility.Visible; - repiceListMaking.Visibility = Visibility.Hidden; - - + //repiceList.ItemsSource = RecipeControlViewModel.UserTreeCompelete; + //repiceList.Visibility = Visibility.Visible; + //repiceListMaking.Visibility = Visibility.Hidden; + this.Wait.ItemsSource = RecipeControlViewModel.UserTreeCompelete; + CookingGrid.Visibility = Visibility.Collapsed; + WaitOrCompleteGrid.Visibility = Visibility.Visible; + this.Wait.Visibility = Visibility.Hidden; } private void RadioButtonWait_Click(object sender, RoutedEventArgs e) { - repiceList.ItemsSource = RecipeControlViewModel.UserTreeWait; - repiceList.Visibility = Visibility.Visible; - repiceListMaking.Visibility = Visibility.Hidden; + //repiceList.ItemsSource = RecipeControlViewModel.UserTreeWait; + //repiceList.Visibility = Visibility.Visible; + //repiceListMaking.Visibility = Visibility.Hidden; + this.Wait.ItemsSource = RecipeControlViewModel.UserTreeWait; + CookingGrid.Visibility = Visibility.Collapsed; + WaitOrCompleteGrid.Visibility = Visibility.Visible; + this.Wait.Visibility = Visibility.Visible; + } private void RadioButtonMaking_Click(object sender, RoutedEventArgs e) { - repiceListMaking.Visibility = Visibility.Visible; - repiceList.Visibility = Visibility.Hidden; - + //repiceListMaking.Visibility = Visibility.Visible; + //repiceList.Visibility = Visibility.Hidden; + WaitOrCompleteGrid.Visibility = Visibility.Collapsed; + this.Wait.Visibility = Visibility.Collapsed; + CookingGrid.Visibility = Visibility.Visible; } } } diff --git a/DosingSystem/ViewModel/DeviceListViewModel.cs b/DosingSystem/ViewModel/DeviceListViewModel.cs index 5603ea5f..947d2915 100644 --- a/DosingSystem/ViewModel/DeviceListViewModel.cs +++ b/DosingSystem/ViewModel/DeviceListViewModel.cs @@ -41,6 +41,12 @@ namespace BPASmartClient.DosingSystem.ViewModel public string IpAddress { get { return _mIpAddress; } set { _mIpAddress = value; OnPropertyChanged(); } } private string _mIpAddress; + /// + /// 设备编号 + /// + public int DeviceNum { get { return _mDeviceNum; } set { _mDeviceNum = value; OnPropertyChanged(); } } + private int _mDeviceNum; + public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } } private string _mDeviceName; diff --git a/DosingSystem/ViewModel/RecipeControlViewModel.cs b/DosingSystem/ViewModel/RecipeControlViewModel.cs index f044d5fd..f4157cee 100644 --- a/DosingSystem/ViewModel/RecipeControlViewModel.cs +++ b/DosingSystem/ViewModel/RecipeControlViewModel.cs @@ -15,6 +15,7 @@ using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.CustomResource.UserControls; using BPASmartClient.Model.柔性味魔方; using BPASmartClient.Model; +using System.Diagnostics; namespace BPASmartClient.DosingSystem.ViewModel { @@ -37,11 +38,11 @@ namespace BPASmartClient.DosingSystem.ViewModel { string ip = Recipes.ElementAt(index).RawMaterials.ElementAt(i).DeviceIp; var device = DeviceInquire.GetInstance.GetDevice(ip); - if (!device.IsConnected) - { - MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error); - return; - } + //if (!device.IsConnected) + //{ + // MessageNotify.GetInstance.ShowDialog($"设备 【{device.DeviceName}】 未连接,不允许下发此配方", DialogType.Error); + // return; + //} } } Recipes.ElementAt(index).IsEnable = false; @@ -75,27 +76,89 @@ namespace BPASmartClient.DosingSystem.ViewModel })); CurrentRecipeName = Recipes.ElementAt(index).RecipeName; + #region 配方下发到PLC操作相关 //配方数据写入到输送机 - //SiemensDevice.GetInstance.MySiemens.WriteClass - - foreach (var item in Recipes.ElementAt(index).RawMaterials) + var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeName == CurrentRecipeName); + List recipeData = new List(); + if (res != null) { - //DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量 - //var res = DeviceInquire.GetInstance.GetDevice(item.DeviceIp).deviceStatus.DeviceNum; - - - - App.Current.Dispatcher.Invoke(new Action(() => + var tInfo = res.RawMaterials.GroupBy(p => p.Loc);//获取桶号信息 + if (tInfo != null) { - recipeProcesses.Add(new RawMaterialModel() + for (int i = 0; i < tInfo.Count(); i++) { - RawMaterialName = item.RawMaterialName, - RecipeStatus = item.RecipeStatus, - RawMaterialSource = item.RawMaterialSource, - RawMaterialId = item.RawMaterialId, - }); - })); + int data = 0; + for (int m = 0; m < tInfo.ElementAt(i).Count(); m++) + { + var TempName = tInfo.ElementAt(i).ElementAt(m).RawMaterialName; + var tempDevice = DeviceInquire.GetInstance.devices.FirstOrDefault(p => p.DeviceName == TempName); + if (tempDevice != null) + { + data = data.SetBitValue((byte)tempDevice.DeviceNum, true); + } + } + recipeData.Add(data); + } + } } + if (recipeData.Count <= 0) + { + MessageNotify.GetInstance.ShowRunLog("配方数据解析失败"); + return; + } + int offset = 2; + //写入配方数据 + MessageNotify.GetInstance.ShowRunLog("开始写入配方数据"); + recipeData.ForEach(item => + { + SiemensDevice.GetInstance.MySiemens.Write($"DB4.DBD{offset}", item); + offset = offset += 4; + }); + SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD198", recipeData.Count);//配方使用桶数写入 + SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX0.1", true);//配方执行启动 + Stopwatch sw = new Stopwatch(); + App.Current.Dispatcher.Invoke(() => { recipeProcesses.Add(Recipes.ElementAt(index)); }); + sw.Restart(); + while (!GlobalDevice.PlcData.ResComplete) + { + if (sw.ElapsedMilliseconds >= 3000) + { + MessageNotify.GetInstance.ShowRunLog("获取配方下发反馈超时"); + break; + } + if (GlobalDevice.PlcData.ResComplete) SiemensDevice.GetInstance.MySiemens.Write("DB3.DBX0.1", false); + Thread.Sleep(100); + } + #endregion + + //foreach (var item in Recipes.ElementAt(index).RawMaterials) + //{ + // //DeviceInquire.GetInstance.GetDevice(item.DeviceIp)?.Start(item.RawMaterialWeight);//启动并写入每个原料重量 + // //var res = DeviceInquire.GetInstance.GetDevice(item.DeviceIp).deviceStatus.DeviceNum; + // App.Current.Dispatcher.Invoke(new Action(() => + // { + + // //ObservableCollection rawMaterialModels = new ObservableCollection(); + // //rawMaterialModels.Add(new RawMaterialModel() + // //{ + // // RawMaterialName = item.RawMaterialName, + // // RecipeStatus = item.RecipeStatus, + // // RawMaterialSource = item.RawMaterialSource, + // // RawMaterialId = item.RawMaterialId, + // //}); + + // //if (recipeProcesses.Count > 0) + // //{ + // // recipeProcesses.ElementAt(0).RawMaterials.Add(new RawMaterialModel() + // // { + // // RawMaterialName = item.RawMaterialName, + // // RecipeStatus = item.RecipeStatus, + // // RawMaterialSource = item.RawMaterialSource, + // // RawMaterialId = item.RawMaterialId, + // // }); + // //} + // })); + //} Recipes.ElementAt(index).Are.WaitOne();//阻塞,直到当前配方完成 RecipeNames.TryDequeue(out string deviceName); @@ -126,34 +189,57 @@ namespace BPASmartClient.DosingSystem.ViewModel //设备状态显示 if (Recipes.ElementAt(i).RecipeName == CurrentRecipeName) { - string deviceName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName; - int index = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == deviceName); - - if (index >= 0 && index < recipeProcesses.Count) + string tempRawMaterialName = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp).DeviceName; + //int index = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == tempRawMaterialName); + int recIndex = recipeProcesses.ToList().FindIndex(p => p.RecipeName == CurrentRecipeName); + if (recIndex >= 0 && recIndex < recipeProcesses.Count) { - App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(index).RecipeStatus = RunStatus; })); - } - } - + int index = recipeProcesses.ElementAt(recIndex).RawMaterials.ToList().FindIndex(p => p.RawMaterialName == tempRawMaterialName); + if (index >= 0 && index < recipeProcesses.ElementAt(recIndex).RawMaterials.Count) + { + App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(index).RecipeStatus = RunStatus; })); + } + //App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.ElementAt(index).RecipeStatus = RunStatus; })); - var proc = recipeProcesses.Where(p => p.RecipeStatus == 3).ToList(); - if (proc != null && proc.Count > 0 && proc.Count == recipeProcesses.Count) - { - int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName); - if (recipIndex >= 0 && recipIndex < Recipes.Count) - { - for (int n = 0; n < recipeProcesses.Count; n++) + var proc = recipeProcesses.ElementAt(recIndex).RawMaterials.Where(p => p.RecipeStatus == 3).ToList(); + if (proc != null && proc.Count > 0 && proc.Count == recipeProcesses.Count) { - DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 - MessageNotify.GetInstance.ShowRunLog(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp); + int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName); + if (recipIndex >= 0 && recipIndex < Recipes.Count) + { + for (int n = 0; n < recipeProcesses.Count; n++) + { + DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 + MessageNotify.GetInstance.ShowRunLog(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp); + } + App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); + Recipes.ElementAt(recipIndex).IsEnable = true; + Recipes.ElementAt(recipIndex).Are.Set(); + } } - App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); - Recipes.ElementAt(recipIndex).IsEnable = true; - Recipes.ElementAt(recipIndex).Are.Set(); + } } + //var proc = recipeProcesses.Where(p => p.RecipeStatus == 3).ToList(); + //var proc = recipeProcesses.Where(p => p.RecipeStatus == 3).ToList(); + //if (proc != null && proc.Count > 0 && proc.Count == recipeProcesses.Count) + //{ + // int recipIndex = Array.FindIndex(Recipes.ToArray(), p => p.RecipeName == CurrentRecipeName); + // if (recipIndex >= 0 && recipIndex < Recipes.Count) + // { + // for (int n = 0; n < recipeProcesses.Count; n++) + // { + // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp).StatusReset();//完成配料的设备运行状态地址写0 + // MessageNotify.GetInstance.ShowRunLog(Recipes.ElementAt(recipIndex).RawMaterials.ElementAt(n).DeviceIp); + // } + // App.Current.Dispatcher.Invoke(new Action(() => { recipeProcesses.Clear(); })); + // Recipes.ElementAt(recipIndex).IsEnable = true; + // Recipes.ElementAt(recipIndex).Are.Set(); + // } + //} + @@ -173,15 +259,6 @@ namespace BPASmartClient.DosingSystem.ViewModel } Thread.Sleep(100); }), "RecipeControlViewModelStatusInquire"); - //测试数据 - /* RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" }; - RawMaterialModel rawMaterial_2 = new RawMaterialModel { RawMaterialName = "香料_2" }; - RawMaterialModel rawMaterial_3 = new RawMaterialModel { RawMaterialName = "香料_3" }; - RawMaterialModel rawMaterial_4 = new RawMaterialModel { RawMaterialName = "香料_4" }; - ObservableCollection rawMaterials = new ObservableCollection { rawMaterial_1, rawMaterial_2, rawMaterial_3, rawMaterial_4 }; - UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料1", RawMaterials = rawMaterials }); - UserTreeCompelete.Add(new RecipeModel { RecipeName = "完成的香料2", RawMaterials = rawMaterials });*/ - } public RelayCommand StartCommand { get; set; } @@ -196,8 +273,9 @@ namespace BPASmartClient.DosingSystem.ViewModel /// /// 当前正在制作的配方 /// + public static ObservableCollection recipeProcesses { get; set; } = new ObservableCollection(); + //public static ObservableCollection recipeProcesses { get; set; } = new ObservableCollection(); - public static ObservableCollection recipeProcesses { get; set; } = new ObservableCollection(); /// /// 等待制作的配方 /// @@ -213,18 +291,34 @@ namespace BPASmartClient.DosingSystem.ViewModel if (o == null) return; if (o is string id) { - var res = recipeProcesses.FirstOrDefault(p => p.RawMaterialId == id); - if (res != null) + var Recipe = recipeProcesses.FirstOrDefault(p => p.RecipeName == CurrentRecipeName); + if (Recipe != null) { - if (res.RecipeStatus == 3) - { - res.RecipeStatus = 1; - } - else + var res = Recipe.RawMaterials.FirstOrDefault(p => p.RawMaterialId == id); + if (res != null) { - res.RecipeStatus = 3; + if (res.RecipeStatus == 3) + { + res.RecipeStatus = 1; + } + else + { + res.RecipeStatus = 3; + } } } + //var res = recipeProcesses.FirstOrDefault(p => p.RawMaterialId == id); + //if (res != null) + //{ + // if (res.RecipeStatus == 3) + // { + // res.RecipeStatus = 1; + // } + // else + // { + // res.RecipeStatus = 3; + // } + //} } } } diff --git a/SmartClient.sln b/SmartClient.sln index 720ca8d9..356c5e03 100644 --- a/SmartClient.sln +++ b/SmartClient.sln @@ -158,10 +158,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeDesignerSCADA", "BeDesign EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.RecipeManagement", "BPASmart.RecipeManagement\BPASmart.RecipeManagement.csproj", "{28EBFC11-184A-4B88-A7B3-84F3FD768520}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PermissionManagement", "PermissionManagement\PermissionManagement.csproj", "{BE6E7BC1-F250-4D11-8051-1B0F93AD2401}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.SmallBatchingSystem", "BPASmart.SmallBatchingSystem\BPASmart.SmallBatchingSystem.csproj", "{DB6DC970-859C-4C63-AE9B-BA415D56CECD}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.ConfigurationSoftware", "BPASmart.ConfigurationSoftware\BPASmart.ConfigurationSoftware.csproj", "{897F8379-3301-4CBE-9BCA-AF7FD2F963A9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.UserManagement", "BPASmart.UserManagement\BPASmart.UserManagement.csproj", "{06F30619-AD37-4CA0-838F-0431867E0932}" @@ -174,8 +170,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.SmallBatchin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MorkMOC", "BPASmartClient.MorkMOC\BPASmartClient.MorkMOC.csproj", "{D5081D7B-3EBB-42C7-8FB9-A889870D08C2}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.DosingHKProject", "BPASmartClient.DosingProject\BPASmartClient.DosingHKProject.csproj", "{6763F73A-555C-41E2-91F7-ADF26C59A946}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmart.MenuLoad", "BPASmart.MenuLoad\BPASmart.MenuLoad.csproj", "{7A7547D3-F2EF-4DA4-AD45-D1B49210082B}" EndProject Global @@ -1492,46 +1486,6 @@ Global {28EBFC11-184A-4B88-A7B3-84F3FD768520}.Release|x64.Build.0 = Release|Any CPU {28EBFC11-184A-4B88-A7B3-84F3FD768520}.Release|x86.ActiveCfg = Release|Any CPU {28EBFC11-184A-4B88-A7B3-84F3FD768520}.Release|x86.Build.0 = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|ARM.ActiveCfg = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|ARM.Build.0 = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|ARM64.Build.0 = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|x64.ActiveCfg = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|x64.Build.0 = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|x86.ActiveCfg = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Debug|x86.Build.0 = Debug|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|Any CPU.Build.0 = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|ARM.ActiveCfg = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|ARM.Build.0 = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|ARM64.ActiveCfg = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|ARM64.Build.0 = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|x64.ActiveCfg = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|x64.Build.0 = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|x86.ActiveCfg = Release|Any CPU - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401}.Release|x86.Build.0 = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|ARM.ActiveCfg = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|ARM.Build.0 = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|ARM64.Build.0 = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|x64.ActiveCfg = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|x64.Build.0 = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|x86.ActiveCfg = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Debug|x86.Build.0 = Debug|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|Any CPU.Build.0 = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|ARM.ActiveCfg = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|ARM.Build.0 = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|ARM64.ActiveCfg = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|ARM64.Build.0 = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|x64.ActiveCfg = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|x64.Build.0 = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|x86.ActiveCfg = Release|Any CPU - {DB6DC970-859C-4C63-AE9B-BA415D56CECD}.Release|x86.Build.0 = Release|Any CPU {897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|Any CPU.Build.0 = Debug|Any CPU {897F8379-3301-4CBE-9BCA-AF7FD2F963A9}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -1652,26 +1606,6 @@ Global {D5081D7B-3EBB-42C7-8FB9-A889870D08C2}.Release|x64.Build.0 = Release|Any CPU {D5081D7B-3EBB-42C7-8FB9-A889870D08C2}.Release|x86.ActiveCfg = Release|Any CPU {D5081D7B-3EBB-42C7-8FB9-A889870D08C2}.Release|x86.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|ARM.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|ARM.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|ARM64.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|x64.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|x64.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|x86.ActiveCfg = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Debug|x86.Build.0 = Debug|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|Any CPU.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|ARM.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|ARM.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|ARM64.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|ARM64.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x64.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x64.Build.0 = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.ActiveCfg = Release|Any CPU - {6763F73A-555C-41E2-91F7-ADF26C59A946}.Release|x86.Build.0 = Release|Any CPU {7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|Any CPU.Build.0 = Debug|Any CPU {7A7547D3-F2EF-4DA4-AD45-D1B49210082B}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -1764,15 +1698,12 @@ Global {06F0B369-0483-46DD-82D2-70431FB505C1} = {7B0175AD-BB74-4A98-B9A7-1E289032485E} {DF8B4C38-39DE-4220-AB60-885CAE6D1E47} = {06F0B369-0483-46DD-82D2-70431FB505C1} {28EBFC11-184A-4B88-A7B3-84F3FD768520} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} - {BE6E7BC1-F250-4D11-8051-1B0F93AD2401} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} - {DB6DC970-859C-4C63-AE9B-BA415D56CECD} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} {897F8379-3301-4CBE-9BCA-AF7FD2F963A9} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} {06F30619-AD37-4CA0-838F-0431867E0932} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} {2DB084E8-B951-4D71-A203-FD0902EBA2C6} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} {E7CC45BF-7393-4BA7-A9AD-B1A1F5B265F3} = {CDC1E762-5E1D-4AE1-9DF2-B85761539086} {BA588F22-87FB-4124-AF62-CA8DC492ED7D} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} {D5081D7B-3EBB-42C7-8FB9-A889870D08C2} = {9FB27073-61A0-4FE3-94DB-5FDDE062332F} - {6763F73A-555C-41E2-91F7-ADF26C59A946} = {8712125E-14CD-4E1B-A1CE-4BDE03805942} {7A7547D3-F2EF-4DA4-AD45-D1B49210082B} = {06F0B369-0483-46DD-82D2-70431FB505C1} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution From 7ca625c0f39df3e68583f96df5647ffdf447a9bf 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, 24 Oct 2022 17:15:19 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E6=89=8B=E5=8A=A8=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Converters/CountIsVisiableConvert.cs | 33 ++++ .../UserControls/ConveyBelt2.xaml | 4 +- DosingSystem/App.xaml | 1 + DosingSystem/App.xaml.cs | 14 +- .../BPASmartClient.DosingSystem.csproj | 3 +- DosingSystem/Model/CylinderStatusModel.cs | 4 +- DosingSystem/Model/DeviceCurrentStatus.cs | 4 +- DosingSystem/Model/DeviceInquire.cs | 4 +- DosingSystem/Model/OutletInfoModel.cs | 4 +- DosingSystem/Model/RecipeModel.cs | 4 +- DosingSystem/Model/RecipeProcess.cs | 4 +- DosingSystem/Model/StockStatusModel.cs | 4 +- DosingSystem/Model/ViewModelBase.cs | 6 +- DosingSystem/Model/par/BasePar.cs | 52 ++++++ DosingSystem/Model/par/DevicePar.cs | 29 +--- DosingSystem/Model/par/DeviceParModel.cs | 4 +- DosingSystem/Service/SiemensDevice.cs | 23 ++- DosingSystem/View/CommParSetView.xaml | 149 +++++++++++++++++- DosingSystem/View/CommParSetView.xaml.cs | 4 +- DosingSystem/View/ManualControlView.xaml | 13 +- DosingSystem/View/ManualControlView.xaml.cs | 3 + .../ViewModel/ChangeDeviceNameViewModel.cs | 2 - DosingSystem/ViewModel/CommparSetViewModel.cs | 16 +- DosingSystem/ViewModel/DeviceListViewModel.cs | 6 +- .../ViewModel/DeviceMaterialParViewModel.cs | 4 +- .../ViewModel/HardwareStatusViewModel.cs | 6 +- .../ViewModel/ManualControlViewModel.cs | 57 +++++-- .../ViewModel/NewMaterialViewModel.cs | 4 +- DosingSystem/ViewModel/NewOutletViewModel.cs | 14 +- DosingSystem/ViewModel/NewRecipeViewModel.cs | 4 +- .../ViewModel/OutletManagementViewModel.cs | 4 +- .../ViewModel/RecipeControlViewModel.cs | 6 +- .../ViewModel/RecipeSettingsViewModel.cs | 6 +- .../ViewModel/StockControViewModel.cs | 6 +- 34 files changed, 374 insertions(+), 127 deletions(-) create mode 100644 BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs create mode 100644 DosingSystem/Model/par/BasePar.cs diff --git a/BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs b/BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs new file mode 100644 index 00000000..9d3ba102 --- /dev/null +++ b/BPASmartClient.CustomResource/Converters/CountIsVisiableConvert.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Data; + +namespace BPASmartClient.CustomResource.Converters +{ + public class CountIsVisiableConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null) + { + var count = value?.GetType()?.GetProperty("Count")?.GetValue(value); + if (count != null && count is int tempCount) + { + if (tempCount > 0) return Visibility.Visible; + } + } + return Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml b/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml index 1b336e6d..79e65167 100644 --- a/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml +++ b/BPASmartClient.CustomResource/UserControls/ConveyBelt2.xaml @@ -12,10 +12,10 @@ + Margin="5" + Background="Transparent"> + diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs index bbb1143a..cebb3189 100644 --- a/DosingSystem/App.xaml.cs +++ b/DosingSystem/App.xaml.cs @@ -128,13 +128,13 @@ namespace BPASmartClient.DosingSystem AssemblyName = "BPASmartClient.DosingSystem", ToggleWindowPath = "View.ManualControlView" }); - ManualControl.Add(new SubMenumodel() - { - SubMenuName = "料仓控制", - SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, - AssemblyName = "BPASmartClient.DosingSystem", - ToggleWindowPath = "View.StockControlView" - }); + //ManualControl.Add(new SubMenumodel() + //{ + // SubMenuName = "料仓控制", + // SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + // AssemblyName = "BPASmartClient.DosingSystem", + // ToggleWindowPath = "View.StockControlView" + //}); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", diff --git a/DosingSystem/BPASmartClient.DosingSystem.csproj b/DosingSystem/BPASmartClient.DosingSystem.csproj index 0807292b..df8df978 100644 --- a/DosingSystem/BPASmartClient.DosingSystem.csproj +++ b/DosingSystem/BPASmartClient.DosingSystem.csproj @@ -16,9 +16,8 @@ - + - diff --git a/DosingSystem/Model/CylinderStatusModel.cs b/DosingSystem/Model/CylinderStatusModel.cs index 8e94d96b..933851a4 100644 --- a/DosingSystem/Model/CylinderStatusModel.cs +++ b/DosingSystem/Model/CylinderStatusModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class CylinderStatusModel : ObservableObject + public class CylinderStatusModel : NotifyBase { /// /// 气缸原点信号 diff --git a/DosingSystem/Model/DeviceCurrentStatus.cs b/DosingSystem/Model/DeviceCurrentStatus.cs index 37ec350b..f7473b11 100644 --- a/DosingSystem/Model/DeviceCurrentStatus.cs +++ b/DosingSystem/Model/DeviceCurrentStatus.cs @@ -4,11 +4,11 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class DeviceCurrentStatus : ObservableObject + public class DeviceCurrentStatus : NotifyBase { /// /// 当前料仓重量反馈 diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index b7218bf7..120b1252 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -111,8 +111,8 @@ namespace BPASmartClient.DosingSystem public void Init() { - if (!string.IsNullOrEmpty(Json.Data.Address)) IPSegment = Json.Data.Address; - else Json.Data.Address = IPSegment; + if (!string.IsNullOrEmpty(Json.Data.BaseParModel.NetworkSegAddress)) IPSegment = Json.Data.BaseParModel.NetworkSegAddress; + else Json.Data.BaseParModel.NetworkSegAddress = IPSegment; TestData(); IpAddressLines(); DeviceDataInit(); diff --git a/DosingSystem/Model/OutletInfoModel.cs b/DosingSystem/Model/OutletInfoModel.cs index 046e52dd..470115dc 100644 --- a/DosingSystem/Model/OutletInfoModel.cs +++ b/DosingSystem/Model/OutletInfoModel.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; using System.Collections.ObjectModel; namespace BPASmartClient.DosingSystem @@ -11,7 +11,7 @@ namespace BPASmartClient.DosingSystem /// /// 出料口信息 /// - public class OutletInfoModel : ObservableObject + public class OutletInfoModel : NotifyBase { /// /// 出料口名称 diff --git a/DosingSystem/Model/RecipeModel.cs b/DosingSystem/Model/RecipeModel.cs index df6e89b2..cbdb4c7b 100644 --- a/DosingSystem/Model/RecipeModel.cs +++ b/DosingSystem/Model/RecipeModel.cs @@ -6,14 +6,14 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using BPASmartClient.Model; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { /// /// 配方模块 /// - public class RecipeModel : ObservableObject + public class RecipeModel : NotifyBase { [Newtonsoft.Json.JsonIgnore] public bool IsEnable { get { return _mIsEnable; } set { _mIsEnable = value; OnPropertyChanged(); } } diff --git a/DosingSystem/Model/RecipeProcess.cs b/DosingSystem/Model/RecipeProcess.cs index 9de11200..d9f5c708 100644 --- a/DosingSystem/Model/RecipeProcess.cs +++ b/DosingSystem/Model/RecipeProcess.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class RecipeProcess : ObservableObject + public class RecipeProcess : NotifyBase { public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } private string _mRawMaterialName; diff --git a/DosingSystem/Model/StockStatusModel.cs b/DosingSystem/Model/StockStatusModel.cs index 531882fe..072da4e7 100644 --- a/DosingSystem/Model/StockStatusModel.cs +++ b/DosingSystem/Model/StockStatusModel.cs @@ -1,4 +1,4 @@ -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; using System; using System.Collections.Generic; using System.Linq; @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace BPASmartClient.DosingSystem { - public class StockStatusModel : ObservableObject + public class StockStatusModel : NotifyBase { /// /// 料仓物料重量 diff --git a/DosingSystem/Model/ViewModelBase.cs b/DosingSystem/Model/ViewModelBase.cs index ae5f8e17..b28647bc 100644 --- a/DosingSystem/Model/ViewModelBase.cs +++ b/DosingSystem/Model/ViewModelBase.cs @@ -3,13 +3,13 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; -using Microsoft.Toolkit.Mvvm.Input; +using BPA.Helper; + using System.Collections.ObjectModel; namespace BPASmartClient.DosingSystem { - public class ViewModelBase : ObservableObject + public class ViewModelBase : NotifyBase { public int Index { get; set; } = -1; public RelayCommand AddCommand { get; set; }//添加 diff --git a/DosingSystem/Model/par/BasePar.cs b/DosingSystem/Model/par/BasePar.cs new file mode 100644 index 00000000..f527f9a5 --- /dev/null +++ b/DosingSystem/Model/par/BasePar.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BPA.Helper; + +namespace BPASmartClient.DosingSystem +{ + /// + /// 基础参数 + /// + public class BasePar : NotifyBase + { + /// + /// 设备扫描网段 + /// + public string NetworkSegAddress { get { return _mNetworkSegAddress; } set { _mNetworkSegAddress = value; OnPropertyChanged(); } } + private string _mNetworkSegAddress = "192.168.0."; + + /// + /// 输送带设备 PLC IP 地址 + /// + public string DeviceAddress { get { return _mDeviceAddress; } set { _mDeviceAddress = value; OnPropertyChanged(); } } + private string _mDeviceAddress = "192.168.0.1"; + + /// + /// 输送带数量 + /// + public int ConveyerBeltCount { get { return _mConveyerBeltCount; } set { _mConveyerBeltCount = value; OnPropertyChanged(); } } + private int _mConveyerBeltCount = 0; + + /// + /// 升降气缸数量 + /// + public int LiftCylinderCount { get { return _mLiftCylinderCount; } set { _mLiftCylinderCount = value; OnPropertyChanged(); } } + private int _mLiftCylinderCount = 0; + + /// + /// 阻挡气缸数量 + /// + public int BlockCylinderCount { get { return _mBlockCylinderCount; } set { _mBlockCylinderCount = value; OnPropertyChanged(); } } + private int _mBlockCylinderCount = 0; + + /// + /// 托盘气缸数量 + /// + public int PalletCylinderCount { get { return _mPalletCylinderCount; } set { _mPalletCylinderCount = value; OnPropertyChanged(); } } + private int _mPalletCylinderCount = 0; + + } +} diff --git a/DosingSystem/Model/par/DevicePar.cs b/DosingSystem/Model/par/DevicePar.cs index 61e7bf74..899ec930 100644 --- a/DosingSystem/Model/par/DevicePar.cs +++ b/DosingSystem/Model/par/DevicePar.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.ObjectModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class DevicePar + public class DevicePar : NotifyBase { /// /// 配料设备参数 @@ -17,30 +17,9 @@ namespace BPASmartClient.DosingSystem public ObservableCollection OutletInfoModels { get; set; } = new ObservableCollection(); - /// - /// 设备扫描网段 - /// - public string Address { get; set; } = string.Empty; - /// - /// 设备端口号 - /// - public int Port { get; set; } = 502; - - /// - /// 升降气缸数量 - /// - public int LiftCylinderCount { get; set; } - - /// - /// 阻挡气缸数量 - /// - public int BlockCylinderCount { get; set; } - - /// - /// 托盘气缸数量 - /// - public int PalletCylinderCount { get; set; } + public BasePar BaseParModel { get { return _mBaseParModel; } set { _mBaseParModel = value; OnPropertyChanged(); } } + private BasePar _mBaseParModel = new BasePar(); } } diff --git a/DosingSystem/Model/par/DeviceParModel.cs b/DosingSystem/Model/par/DeviceParModel.cs index c9dfe67f..d7a0d5f3 100644 --- a/DosingSystem/Model/par/DeviceParModel.cs +++ b/DosingSystem/Model/par/DeviceParModel.cs @@ -3,11 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using Microsoft.Toolkit.Mvvm.ComponentModel; +using BPA.Helper; namespace BPASmartClient.DosingSystem { - public class DeviceParModel : ObservableObject + public class DeviceParModel : NotifyBase { /// /// 原料名称 diff --git a/DosingSystem/Service/SiemensDevice.cs b/DosingSystem/Service/SiemensDevice.cs index dd53f713..d3dbf086 100644 --- a/DosingSystem/Service/SiemensDevice.cs +++ b/DosingSystem/Service/SiemensDevice.cs @@ -36,12 +36,33 @@ namespace BPASmartClient.DosingSystem ThreadManage.GetInstance().StartLong(new Action(() => { - GlobalDevice.PlcData = MySiemens.ReadClass(3); + GlobalDevice.PlcData = MySiemens.ReadClass(3);//获取PLC到上位机的数据 Thread.Sleep(50); }), "读取输送线设备数据", true); } + public string GetSiemensBitSingleAdd(string Prefix, int num, int StartAdd = 0) + { + if (num > 0) + { + string Add = string.Empty; + var FirstAdd = num / 8; + var EndAdd = (num % 8); + if (EndAdd == 0) + { + FirstAdd--; + EndAdd = 7; + } + else EndAdd--; + Add = $"{Prefix}{FirstAdd + StartAdd}.{EndAdd}"; + return Add; + } + return default; + + + } + } diff --git a/DosingSystem/View/CommParSetView.xaml b/DosingSystem/View/CommParSetView.xaml index f6b2a380..bb57c734 100644 --- a/DosingSystem/View/CommParSetView.xaml +++ b/DosingSystem/View/CommParSetView.xaml @@ -22,24 +22,157 @@ - - - - + + + +