From 7393a11144a791266d25710aea02c8549470483b Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Mon, 19 Sep 2022 09:49:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=89=E9=A6=99=E5=B1=85=E9=A1=B9=E7=9B=AE?= =?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 --- BPASmartClient.JXJFoodBigStation/App.xaml.cs | 1 - .../Model/GVL_BigStation.cs | 10 +- .../Model/HK_PLC/HKDeviceStatus.cs | 8 +- .../Model/LocalRecipeDataColl.cs | 14 + .../Model/ProcessControl.cs | 171 +++++++---- .../Model/Siemens/DL_Finish_DB.cs | 39 +++ .../Model/Siemens/DL_Start_DB.cs | 51 ++++ .../Model/Siemens/DL_Status_DB.cs | 60 ++++ .../Model/Siemens/RemoteRecipeData.cs | 4 +- .../Model/Siemens/RemoteRecipeRawMaterial.cs | 12 + .../Model/Siemens/SiemensDeviceStatus.cs | 84 +++--- .../Model/TestData.cs | 16 +- .../ViewModel/HardwareStatusViewModel.cs | 10 +- .../ViewModel/RecipeInfosViewModel.cs | 4 +- .../ViewModel/RecipeReceiveViewModel.cs | 34 +-- .../Model/GVL_SmallStation.cs | 8 +- .../Model/HK_PLC/HKDeviceStatus.cs | 49 +++- .../Model/ProcessControl.cs | 267 ++++++------------ .../Model/RawMaterial/DeviceInquire.cs | 38 ++- .../Model/RawMaterial/LocaPar.cs | 2 - .../RawMaterial/RawMaterialDeviceStatus.cs | 5 + .../Model/Siemens/RemoteRecipeData.cs | 4 +- .../Model/Siemens/RemoteRecipeRawMaterial.cs | 14 +- .../Model/Siemens/SiemensDeviceStatus.cs | 60 ++-- .../Model/Siemens/XL_Finish_DB.cs | 39 +++ .../Model/Siemens/XL_Start_DB.cs | 52 ++++ .../Model/Siemens/XL_Status_DB.cs | 60 ++++ .../Model/TestData.cs | 16 +- .../ViewModel/RecipeInfosViewModel.cs | 4 +- .../ViewModel/RecipeReceiveViewModel.cs | 6 +- 30 files changed, 757 insertions(+), 385 deletions(-) create mode 100644 BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs create mode 100644 BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs create mode 100644 BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs create mode 100644 BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index 0ccdee1c..20b2b9f8 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs @@ -51,7 +51,6 @@ namespace BPASmartClient.JXJFoodBigStation private void MenuInit() { - #region 配方管理菜单 ObservableCollection RecipeManage = new ObservableCollection(); RecipeManage.Add(new SubMenumodel() diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 49d9601e..67038353 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -11,7 +11,6 @@ namespace BPASmartClient.JXJFoodBigStation.Model { public class GVL_BigStation { - /// /// 往输送带下发配方完成 /// @@ -32,5 +31,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// 记录AGV进站取货的指令顺序 /// public int AgvPickUpPosition { get; set; } + + /// + /// 配方配料的状态 0:无意义 ,1:plc允许下发配方 2:上位机下发配方 3:plc接收到配方(配料中) 4:配料完成 + /// + public int RecipeDosingStatus { get; set; } + /// + /// 是否处于手动下发配方 + /// + public bool IsAllowManual { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index 3afa9987..5397868f 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -61,13 +61,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC /// /// 单个桶的编号 /// 单个桶对应的料仓位置 - public void StockBinPar(ushort[] Num, ushort[] Location,ushort[] Weight) + public void StockBinPar(short[] Num, short[] Location,short[] Weight) { if (IsConnected) { - HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, Num); - HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, Location); - HK_PLC_S7.Write(HKPlcCommAddress.WeightToPLC, Weight); + HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, Num); + HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, Location); + HK_PLC_S7.Write(HKPlcCommAddress.WeightToPLC, Weight); } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs b/BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs new file mode 100644 index 00000000..40957ee5 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/LocalRecipeDataColl.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model +{ + public class LocalRecipeDataColl + { + public ObservableCollection Recipes { get; set; } = new ObservableCollection(); + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index f1af668f..6d206609 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -35,73 +35,57 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// public ObservableCollection IssuedComplete = new ObservableCollection(); /// + /// 原料的名称和料仓的位置对应 + /// + public Dictionary RawMaterialsNamePos = new Dictionary(); + /// /// 配方队列 /// - public ConcurrentQueue RecipeQueue = new ConcurrentQueue(); + public ConcurrentQueue RecipeQueue = new ConcurrentQueue(); /// /// AGV到达工站队列 /// - public ConcurrentQueue AGVToWorkStationQueue = new ConcurrentQueue(); + public ConcurrentQueue AGVToWorkStationQueue = new ConcurrentQueue(); /// /// 接收原料数据 /// public RecipeRawMaterial RawMaterial; public void Init() { - ActionManage.GetInstance.Register(new Action(() => + ActionManage.GetInstance.Register(new Action((res) => { if (SiemensDevice.IsConnected) { - var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeName); - var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID); - var res2 = SiemensDevice.Siemens_PLC_S7.ReadClass(0, 0); - if ((res != null && res is string recipeName) && (res1 != null && res1 is uint recipeID)) + if (res != null) { - int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == recipeID); - if (index == -1) + RawMaterials.Clear(); + for (int i = 0; i < 15; i++) { - RawMaterials.Clear(); - for (int i = 0; i < 15; i++) + if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name)) { RawMaterials.Add(new RemoteRecipeRawMaterial() { - RawMaterialBarrelNum = res2.RawMaterialBarrelNum[i], - RawMaterialLocation = res2.RawMaterialLocation[i], - RawMaterialWeight = res2.RawMaterialWeight[i] + RawMaterialName = res.Material[i].Material_Name, + RawMaterialBarrelNum = res.Material[i].Material_BarrelNum, + RawMaterialWeight = res.Material[i].Material_Weight, + RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name] }); } - Json.Data.Recipes.Add(new RemoteRecipeData() + else { - RecipeName = recipeName, - RecipeCode = recipeID, - RawMaterial = RawMaterials - }); + //报警,配方的原料名称下发和设备不一致 + } } - else + Json.Data.Recipes.Add(new RemoteRecipeData() { - MessageLog.GetInstance.AlarmLog("配方列表中存在该配方ID"); - } + RecipeName = res.RecipeName, + RecipeCode = res.RecipeCode, + RawMaterial = RawMaterials, + TrayCode = res.TrayCode + }); } } }), "西门子下发配方", true); - ActionManage.GetInstance.Register(new Action(() => - { - if (SiemensDevice.IsConnected) - { - var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.TrayLocationNum); - var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID); - if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId) - { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == recipeId); - if (index >= 0 && index < RemoteRecipes.Count) - { - RemoteRecipes.ElementAt(index).TrayCode = TrayLocation; - MessageLog.GetInstance.RunLog($"接收到AGV进站信号=>配方编码:{recipeId} 、托盘位置:{TrayLocation}"); - AGVToWorkStationQueue.Enqueue(recipeId); - } - } - } - }), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; try @@ -122,7 +106,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model } RecipeQueue.Clear(); - Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 + //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { ReceviceData(); @@ -136,12 +120,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model AgvGetInOut(); } Thread.Sleep(10); - }), "AGV进站送取货", true); ThreadManage.GetInstance().StartLong(new Action(() => { ReadSiemensCommData(); ReadHKPLCCommData(); + Thread.Sleep(10); }), "读取西门子和海科PLC的数据", true); } /// @@ -229,7 +213,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model { int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == AGVToWorkStationQueue.ElementAt(0)); int TrayLocation = RemoteRecipes.ElementAt(index).TrayCode;//根据配方编号,找到托盘的ID 托盘ID1-6 - int RecipeCode = (int)RemoteRecipes.ElementAt(index).RecipeCode; + string RecipeCode = (string)RemoteRecipes.ElementAt(index).RecipeCode; if (TrayLocation > 0 && TrayLocation < 7) { AGV_Delivery(TrayLocation - 1); @@ -249,7 +233,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model } private void ReceviceData() { - RemoteRecipes = Json.Data.Recipes; + if (!BigStation.IsAllowManual && RemoteRecipes.Count == 0)//一个配方执行完成后,再获取配方数据 + { + RemoteRecipes = Json.Data.Recipes; + } + else if (BigStation.IsAllowManual && RemoteRecipes.Count == 0) + { + RemoteRecipes = Json.Data.Recipes; + } if (RemoteRecipes.Count > 0) { foreach (var data in RemoteRecipes) @@ -259,9 +250,9 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - ushort[] BarrelNum = new ushort[15]; - ushort[] Location = new ushort[15]; - ushort[] Weight = new ushort[15]; + short[] BarrelNum = new short[15]; + short[] Location = new short[15]; + short[] Weight = new short[15]; private void RecipeInfoToHKPLC() { if (RecipeQueue.Count > 0) @@ -269,26 +260,77 @@ namespace BPASmartClient.JXJFoodBigStation.Model int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0)); if (index >= 0 && index <= RemoteRecipes.Count) { - long code = RemoteRecipes.ElementAt(index).RecipeCode; - if (HKDevice.HK_PLC_S7.Read("M5001.0") is bool)//配方1是否允许下发配发 + string code = RemoteRecipes.ElementAt(index).RecipeCode; + if (HKDevice.HK_PLC_S7.Read("M5001.0") && BigStation.RecipeDosingStatus == 0)//配方1是否允许下发配发 { + MessageLog.GetInstance.ShowRunLog($"配方状态:{code}允许下发"); + BigStation.RecipeDosingStatus = 1; for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) { - BarrelNum[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - Location[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation; - Weight[i] = (ushort)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight; + BarrelNum[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + Location[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation; + Weight[i] = (short)RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight; } HKDevice.StockBinPar(BarrelNum, Location, Weight); HKDevice.HK_PLC_S7.Write("M4001.0", 1);//配发下发完成,to plc HKDevice.HK_PLC_S7.Write("M5001.0", 0);//复位允许下发配方1信号 - //BigStation.IssueRecipeFinish = true; + BigStation.RecipeDosingStatus = 2; + MessageLog.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } + if (HKDevice.HK_PLC_S7.Read("M5001.4") && BigStation.RecipeDosingStatus == 2) + { + BigStation.RecipeDosingStatus = 3; + HKDevice.HK_PLC_S7.Write("M5001.4", 0);//复位允许下发配方1信号 + MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); } - if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.RecipeDosingFinish) is bool)) + if (BigStation.RecipeDosingStatus == 3) { - HKDevice.RecipeDosingFinishReset(); - RecipeQueue.TryDequeue(out code); - IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + for (int i = 0; i < 12; i++) + { + if (i >= 0 && i < 8) + { + if (HKDevice.HK_PLC_S7.Read("M5008." + (i)))//根据配料完成信号, + { + int a = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); + if (a >= 0) + { + int barrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).RawMaterialBarrelNum; + string address = "MD" + 5060 + i * 4 + (barrelNum - 1) * 48; + float weight = HKDevice.HK_PLC_S7.Read(address); + } + } + } + else + { + if (HKDevice.HK_PLC_S7.Read("M5009." + (i - 8))) + { + int a = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); + if (a >= 0) + { + int barrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(a).RawMaterialBarrelNum; + string address = "MD" + 5060 + i * 4 + (barrelNum - 1) * 48; + float weight = HKDevice.HK_PLC_S7.Read(address); + } + } + } + } + if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.RecipeDosingFinish)) || true) + { + BigStation.RecipeDosingStatus = 4; + MessageLog.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); + HKDevice.RecipeDosingFinishReset(); + RecipeQueue.TryDequeue(out code); + IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 + if (!BigStation.IsAllowManual) + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + } + else + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + } + BigStation.RecipeDosingStatus = 0; + } } } } @@ -399,5 +441,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model 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); + } + } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs new file mode 100644 index 00000000..4394ac10 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Finish_DB.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model.Siemens +{ + internal class DL_Finish_DB + { + /// + /// 生产工单编码 + /// + public string Order_No; + /// + /// 产品名称 + /// + public string Product_Code; + /// + /// 原料信息 + /// + public UDT1[] Material = new UDT1[20]; + /// + /// 配料完成信号 + /// + public bool Ask_For_Finish; + /// + /// 配料完成信号确认 + /// + public bool Ask_For_Finish_PLC; + + } + public class UDT1 + { + public string Material_Name; + public float Material_Laying_Off_Weight; + public short Material_BarrelNum; + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs new file mode 100644 index 00000000..13066a70 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model.Siemens +{ + internal class DL_Start_DB + { + /// + /// 配方编码 + /// + public string RecipeCode; + /// + /// 配发名称 + /// + public string RecipeName; + /// + /// 物料信息 + /// + public UDT[] Material = new UDT[20]; + /// + /// 托盘编号 + /// + public int TrayCode; + /// + /// 配方发送请求 + /// + public bool Ask_For_Send_Bit; + /// + /// 上位机确认配方接收完成 + /// + public bool Ack_Ask_For_Send_Bit; + } + public class UDT + { + /// + /// 原料名称 + /// + public string Material_Name; + /// + /// 原料重量 + /// + public float Material_Weight; + /// + /// 原料桶号 + /// + public short Material_BarrelNum; + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs new file mode 100644 index 00000000..562da3bf --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Status_DB.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model.Siemens +{ + internal class DL_Status_DB + { + /// + /// 生产工单 + /// + public string Order_No; + /// + /// 配料开始 + /// + public bool Dosing_Start; + /// + /// 配料开始确认 + /// + 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 byte Reserve; + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs index 19d26ded..4a7ed10a 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeData.cs @@ -18,8 +18,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 配方ID /// - public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } - private long _mRecipeCode; + public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } + private string _mRecipeCode; /// /// 托盘编号 diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs index 9a69a2c9..e0958228 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/RemoteRecipeRawMaterial.cs @@ -11,6 +11,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model private int _mIp; public int DeviceIp { get { return _mIp; } set { _mIp = value; }} + /// + /// 原料名称 + /// + public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } + private string _mRawMaterialName; + /// /// 原料对应的桶号 /// @@ -23,6 +29,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } } private double _mRawMaterialWeight; + /// + /// 实际的下料中重量 + /// + public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } } + private float _mLaying_Off_Weight; + /// /// 原料对应料仓的位置 /// diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index ce9fa65a..a6b9db25 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using BPASmartClient.S7Net; +using System.Threading; namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { @@ -14,51 +15,68 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); public bool IsConnected => Siemens_PLC_S7.IsConnected; - /// - /// 配方接收信号复位 - /// - public void RecipeSignReset() - { - this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0); - } - /// - /// AGV到位信号复位 - /// - public void AgvSignReset() - { - this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0); - } public void Init() { if (IsConnected) { ThreadManage.GetInstance().StartLong(new Action(() => { - var res = this.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeState); - if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig)) + 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)) + { + ActionManage.GetInstance.Send("西门子下发配方", res); + res.Ask_For_Send_Bit = false; + this.Siemens_PLC_S7.WriteClass(res, 1); + } + + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0])) + { + ActionManage.GetInstance.Send("AGV到工位1信号", res1); + res1.Allow_AGV_Put[0] = false; + this.Siemens_PLC_S7.WriteClass(res1, 2); + } + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1])) + { + ActionManage.GetInstance.Send("AGV到工位2信号", res1); + res1.Allow_AGV_Put[1] = false; + this.Siemens_PLC_S7.WriteClass(res1, 2); + } + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[2]").Start(res1.Allow_AGV_Put[2])) + { + ActionManage.GetInstance.Send("AGV到工位3信号", res1); + res1.Allow_AGV_Put[2] = false; + this.Siemens_PLC_S7.WriteClass(res1, 2); + } + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[3]").Start(res1.Allow_AGV_Put[3])) + { + ActionManage.GetInstance.Send("AGV到工位4信号", res1); + res1.Allow_AGV_Put[3] = false; + this.Siemens_PLC_S7.WriteClass(res1, 2); + } + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[4]").Start(res1.Allow_AGV_Put[4])) { - ActionManage.GetInstance.Send("西门子下发配方"); - RecipeSignReset(); + ActionManage.GetInstance.Send("AGV到工位5信号", res1); + res1.Allow_AGV_Put[4] = false; + this.Siemens_PLC_S7.WriteClass(res1, 2); } - var AgvState = this.Siemens_PLC_S7.Read(SiemensCommAddress.StateSign); - if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig)) + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[5]").Start(res1.Allow_AGV_Put[5])) { - ActionManage.GetInstance.Send("AGV到位信号"); - AgvSignReset(); + ActionManage.GetInstance.Send("AGV到工位6信号", res1); + res1.Allow_AGV_Put[5] = false; + this.Siemens_PLC_S7.WriteClass(res1, 2); } + + if (res2 != null && res2.Ask_For_Finish_PLC) + { + ActionManage.GetInstance.Send("配料完成信号确认完成"); + res2.Ask_For_Finish_PLC = false; + this.Siemens_PLC_S7.WriteClass(res2, 3); + } + Thread.Sleep(10); }), "监听服务数据"); } } - /// - /// 配方配料完成信号 - /// - /// - /// - private void DosingFinsih(int TrayLocation, int recipeID) - { - this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation); - this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1); - this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID); - } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/TestData.cs b/BPASmartClient.JXJFoodBigStation/Model/TestData.cs index b7b7c45e..44c7bfa7 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/TestData.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/TestData.cs @@ -18,19 +18,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model public TestData() { string recipeName = "配方1"; - long recipeCode = 10001; + string recipeCode = "10001"; int Traycode = 1; double RawmaterialWeight = 10; - int RawMaterialbarrelNum = 1; + short RawMaterialbarrelNum = 1; int RawMaterialLocation = 5; double RawmaterialWeight1 = 20; - int RawMaterialbarrelNum1 = 2; + short RawMaterialbarrelNum1 = 2; int RawMaterialLocation1 = 7; double RawmaterialWeight2 = 30; - int RawMaterialbarrelNum2 = 3; + short RawMaterialbarrelNum2 = 3; int RawMaterialLocation2 = 9; RawMaterials.Add(new RemoteRecipeRawMaterial() { @@ -64,19 +64,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model RawMaterials.Clear(); string recipeName_2 = "配方2"; - long recipeCode_2 = 20001; + string recipeCode_2 = "20001"; int Traycode_2 = 3; double RawmaterialWeight_2 = 10; - int RawMaterialbarrelNum_2 = 1; + short RawMaterialbarrelNum_2 = 1; int RawMaterialLocation_2 = 5; double RawmaterialWeight1_2 = 20; - int RawMaterialbarrelNum1_2 = 2; + short RawMaterialbarrelNum1_2 = 2; int RawMaterialLocation1_2 = 7; double RawmaterialWeight2_2 = 30; - int RawMaterialbarrelNum2_2 = 3; + short RawMaterialbarrelNum2_2 = 3; int RawMaterialLocation2_2 = 9; RawMaterials.Add(new RemoteRecipeRawMaterial() { diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs index 4a082b5f..75b7dcc0 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs @@ -17,15 +17,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel { public HardwareStatusViewModel() { - for (int i = 0; i < 8; i++) - { - TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() - { - DeviceName = i.ToString(), - RunStatus = false, - Weight = new Random().Next(0, 100) - }); - } + } public ObservableCollection TopDeviceCurrentStatuses { get; set; } = new ObservableCollection(); diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs index ad4390da..7265dd8f 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs @@ -42,8 +42,8 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } private string _mRecipeName; - public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } - private long _mRecipeCode; + public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } + private string _mRecipeCode; public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } private int _mTrayCode; diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs index 74fe86f7..62f4cdcc 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs @@ -27,32 +27,35 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public RecipeReceiveViewModel() { //Json.Read(); - Recipes = Json.Data.Recipes; + Recipes = Json.Data.Recipes; DetailsCommand = new RelayCommand((o) => { - if (o != null && o is long num) + if (o != null && o is string num) { ActionManage.GetInstance.CancelRegister("RecipeInfo"); RecipeInfosView nrv = new RecipeInfosView(); var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == num); - ActionManage.GetInstance.Send("RecipeInfo", res); - nrv.Show(); - MessageLog.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}"); + if (res != null) + { + ActionManage.GetInstance.Send("RecipeInfo", res); + nrv.Show(); + MessageLog.GetInstance.ShowUserLog($"查看配方——{res.RecipeName}"); + } } }); NewSimulateRecipe = new RelayCommand(() => { RawMaterials.Clear(); - string recipeName = "配方" + (Json.Data.Recipes.Count + 1) + ""; + string recipeName = "配方" + (Json.Data.Recipes.Count + 1) + ""; go: - long recipeCode = new Random().Next(10000, 99999); + string recipeCode = new Random().Next(10000, 99999).ToString(); foreach (var item in Recipes) { if (item.RecipeCode == recipeCode) { goto go; } - } + } int trayCode = new Random().Next(1,6); for (int i = 1; i < 13; i++) { @@ -68,26 +71,23 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel RawMaterialLocation = i, }); } - Json.Data.Recipes.Add(new RemoteRecipeData() + Json.Data.Recipes.Add(new RemoteRecipeData() { - RecipeName = recipeName, - RecipeCode = recipeCode, - TrayCode = trayCode, - RawMaterial = RawMaterials, + RecipeName = recipeName, + RecipeCode = recipeCode, + TrayCode = trayCode, + RawMaterial = RawMaterials, }); - }); ClearAllRecipe = new RelayCommand(() => { - Json.Data.Recipes.Clear(); + Json.Data.Recipes.Clear(); }); } public RelayCommand DetailsCommand { get; set; } - public RelayCommand NewSimulateRecipe { get; set; } public RelayCommand ClearAllRecipe { get; set; } - public ObservableCollection Recipes { get; set; } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index 198b6706..4bc409a8 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -18,13 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public bool IssueRecipeFinishStation1 { get; set; } = false; /// - /// 托盘1配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 + /// 配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 /// - public int RecipeStatusIDTray1 { get; set; } = 0; - /// - /// 托盘2配方下发状态 =0:配方未下发 ,1:配方下发给plc ,2:plc成功接收配方 - /// - public int RecipeStatusIDTray2 { get; set; } = 0; + public int RecipeStatusID { get; set; } = 0; /// /// 往输送带下发配方完成 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs index 14c9e29d..3466f7a5 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/HKDeviceStatus.cs @@ -65,8 +65,53 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC { if (IsConnected) { - HK_PLC_S7.Write(HKPlcCommAddress.BarrelNumToPLC, BarrelNum); - HK_PLC_S7.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation); + if (BarrelNum >= 1 && BarrelNum <= 4 && StockBinLocation >= 1 && StockBinLocation <= 15) + { + if (BarrelNum == 1) + { + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX10." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX11." + (StockBinLocation - 9), true); + } + } + else if (BarrelNum == 2) + { + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX12." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX13." + (StockBinLocation - 9), true); + } + } + else if (BarrelNum == 3) + { + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX14." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX15." + (StockBinLocation - 9), true); + } + } + else if (BarrelNum == 4) + { + if (StockBinLocation >= 1 && StockBinLocation <= 8) + { + HK_PLC_S7.Write("DB4.DBX16." + (StockBinLocation - 1), true); + } + else if (StockBinLocation >= 9 && StockBinLocation <= 15) + { + HK_PLC_S7.Write("DB4.DBX17." + (StockBinLocation - 9), true); + } + } + } } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 71f42208..abd7e42c 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -27,70 +27,71 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public ObservableCollection RemoteRecipes = new ObservableCollection(); /// - /// 托盘1 配方队列 + /// 原料的名称和料仓的位置对应 /// - public ConcurrentQueue RecipeTray1Queue = new ConcurrentQueue(); + public Dictionary RawMaterialsNamePos = new Dictionary(); /// - /// 托盘2 配方队列 + /// 配方队列 /// - public ConcurrentQueue RecipeTray2Queue = new ConcurrentQueue(); + public ConcurrentQueue RecipeQueue = new ConcurrentQueue(); public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); public HKDeviceStatus HKDevice = new HKDeviceStatus(); GVL_SmallStation SmallStation = new GVL_SmallStation(); + XL_Finish_DB RecipeFinishInfo = new XL_Finish_DB(); /// /// 接收原料数据 /// public RecipeRawMaterial RawMaterial; public void Init() { - ActionManage.GetInstance.Register(new Action(() => + for (int i = 0; i < 16; i++) + { + if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null) + { + if (!RawMaterialsNamePos.ContainsKey(DeviceInquire.GetInstance.GetDevice(i).DeviceName)) + { + RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum); + } + + } + } + + + ActionManage.GetInstance.Register(new Action((res) => { if (SiemensDevice.IsConnected) { - var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeName); - var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID); - //int res2 = SiemensDevice.Siemens_PLC_S7.ReadClass(RawMaterial, 0, 0 - int res2 = 0; - if ((res != null && res is string recipeName) && - (res1 != null && res1 is uint recipeID) && - (res2 > 0)) + if (res != null) { RawMaterials.Clear(); for (int i = 0; i < 15; i++) { - RawMaterials.Add(new RemoteRecipeRawMaterial() + if (RawMaterialsNamePos.ContainsKey(res.Material[i].Material_Name)) + { + RawMaterials.Add(new RemoteRecipeRawMaterial() + { + RawMaterialName = res.Material[i].Material_Name, + RawMaterialBarrelNum = res.Material[i].Material_BarrelNum, + RawMaterialWeight = res.Material[i].Material_Weight, + RawMaterialLocation = (int)RawMaterialsNamePos[res.Material[i].Material_Name] + }); + } + else { - RawMaterialBarrelNum = RawMaterial.RawMaterialBarrelNum[i], - RawMaterialLocation = RawMaterial.RawMaterialLocation[i], - RawMaterialWeight = RawMaterial.RawMaterialWeight[i] - }); + //报警,配方的原料名称下发和设备不一致 + } } Json.Data.Recipes.Add(new RemoteRecipeData() { - RecipeName = recipeName, - RecipeCode = recipeID, - RawMaterial = RawMaterials + RecipeName = res.RecipeName, + RecipeCode = res.RecipeCode, + RawMaterial = RawMaterials, + TrayCode = res.TrayCode }); } } }), "西门子下发配方", true); - ActionManage.GetInstance.Register(new Action(() => - { - if (SiemensDevice.IsConnected) - { - var res = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.TrayLocationNum); - var res1 = SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeID); - if (res != null && res is int TrayLocation && res1 != null && res1 is int recipeId) - { - int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == recipeId); - if (index >= 0 && index < Json.Data.Recipes.Count) - { - Json.Data.Recipes.ElementAt(index).TrayCode = TrayLocation; - } - } - } - }), "AGV到位信号", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; try @@ -110,7 +111,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { } - RecipeTray1Queue.Clear(); + RecipeQueue.Clear(); //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { @@ -424,7 +425,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } break; case 1: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply))) { SmallStation.AgvDeliveryPosition = 2; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true); @@ -438,7 +439,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } break; case 3: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack))) { SmallStation.AgvDeliveryPosition = 4; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true); @@ -452,7 +453,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } break; case 5: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo))) { SmallStation.AgvDeliveryPosition = 0; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true); @@ -473,14 +474,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model switch (SmallStation.AgvPickUpPosition) { case 0: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply) is bool)) + if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply))) { SmallStation.AgvPickUpPosition = 1; HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickAGVApply, true); } break; case 1: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVIsApply) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVIsApply))) { SmallStation.AgvPickUpPosition = 2; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true); @@ -494,7 +495,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } break; case 3: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish) is bool)) + if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish))) { SmallStation.AgvPickUpPosition = 0; SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true); @@ -504,6 +505,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model break; } } + /// + /// 将配方添加到配方队列中 + /// private void ReceviceData() { RemoteRecipes = Json.Data.Recipes; @@ -511,31 +515,26 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { foreach (var data in RemoteRecipes) { - if (data.TrayCode == 1) - { - if (!(RecipeTray1Queue.Contains(data.RecipeCode))) - RecipeTray1Queue.Enqueue(data.RecipeCode); - } - else if (data.TrayCode == 2) - { - if (!(RecipeTray2Queue.Contains(data.RecipeCode))) - RecipeTray2Queue.Enqueue(data.RecipeCode); - } + if (!(RecipeQueue.Contains(data.RecipeCode))) + RecipeQueue.Enqueue(data.RecipeCode); } } } + /// + /// 执行配方队列中的第一个配方 + /// private void RecipeInfoToHKPLC() { - if (RecipeTray1Queue.Count > 0) + if (RecipeQueue.Count > 0) { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray1Queue.ElementAt(0)); + int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0)); if (index >= 0 && index < RemoteRecipes.Count) { - long code = RemoteRecipes.ElementAt(index).RecipeCode; + string code = RemoteRecipes.ElementAt(index).RecipeCode; int trayCode = RemoteRecipes.ElementAt(index).TrayCode; - if (trayCode == 1 && SmallStation.RecipeStatusIDTray1 == 0) + if (trayCode == 1 && SmallStation.RecipeStatusID == 0) { - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") is bool && SmallStation.RecipeStatusIDTray1 == 0) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.5") && SmallStation.RecipeStatusID == 0) { foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) { @@ -543,16 +542,16 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } HKDevice.HK_PLC_S7.Write("DB3.DBX1.5", false); HKDevice.HK_PLC_S7.Write("DB4.DBX1.3", true); - SmallStation.RecipeStatusIDTray1 = 1; + SmallStation.RecipeStatusID = 1; } - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") is bool && SmallStation.RecipeStatusIDTray1 == 1) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.3") && SmallStation.RecipeStatusID == 1) { HKDevice.HK_PLC_S7.Write("DB3.DBX1.3", false); - SmallStation.RecipeStatusIDTray1 = 2; + SmallStation.RecipeStatusID = 2; } - if (SmallStation.RecipeStatusIDTray1 == 2) + if (SmallStation.RecipeStatusID == 2) { - if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.0") is bool) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.0")) { var res = HKDevice.HK_PLC_S7.Read("DB3.DBD10"); if (res != null && res is float loc) @@ -567,7 +566,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - else if(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1") is bool) + else if(HKDevice.HK_PLC_S7.Read("DB3.DBX50.1")) { var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14"); if (res != null && res is float loc) @@ -582,7 +581,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.2") is bool) + else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.2")) { var res = HKDevice.HK_PLC_S7.Read("DB3.DBD18"); if (res != null && res is float loc) @@ -597,7 +596,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.3") is bool) + else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.3")) { var res = HKDevice.HK_PLC_S7.Read("DB3.DBD22"); if (res != null && res is float loc) @@ -616,10 +615,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) { + int res = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == i); + RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(res).Laying_Off_Weight = DeviceInquire.GetInstance.GetDevice(i).deviceStatus.CutWeightFeedback; DeviceInquire.GetInstance.GetDevice(i).StatusReset(); if (i >= 1 && i <= 8) { - HKDevice.HK_PLC_S7.Write("DB4.DBX30."+ (i-1), true); + HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true); } else if (i >= 9 && i <= 15) { @@ -627,131 +628,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1") is bool) + if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")) { var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); - MessageLog.GetInstance.ShowRunLog($"托盘1 配方{res.RecipeName}配料完成"); - Json.Data.Recipes.Remove(res); - RecipeTray1Queue.TryDequeue(out code); - HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false); - SmallStation.RecipeStatusIDTray1 = 0; - } - } - } - } - } - if (RecipeTray2Queue.Count > 0) - { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeTray2Queue.ElementAt(0)); - if (index >= 0 && index < RemoteRecipes.Count) - { - long code = RemoteRecipes.ElementAt(index).RecipeCode; - int trayCode = RemoteRecipes.ElementAt(index).TrayCode; - if (trayCode == 2 && SmallStation.RecipeStatusIDTray2 == 0) - { - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.6") is bool && SmallStation.RecipeStatusIDTray2 == 0) - { - foreach (var item in RemoteRecipes.ElementAt(index).RawMaterial) - { - HKDevice.StockBinPar((uint)item.RawMaterialBarrelNum, (ushort)item.RawMaterialLocation); - } - HKDevice.HK_PLC_S7.Write("DB3.DBX1.6", false); - HKDevice.HK_PLC_S7.Write("DB4.DBX1.4", true); - SmallStation.RecipeStatusIDTray2 = 1; - } - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.4") is bool && SmallStation.RecipeStatusIDTray2 == 1) - { - HKDevice.HK_PLC_S7.Write("DB3.DBX1.4", false); - SmallStation.RecipeStatusIDTray2 = 2; - } - if (SmallStation.RecipeStatusIDTray2 == 2) - { - if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.4") is bool) - { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD26"); - if (res != null && res is float loc) - { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; - if (loc_index >= 1 && loc_index <= 15) - { - DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//根据料仓编号 启动并写入每个原料重量 - SmallStation.StockInIsWork = loc_index; - HKDevice.HK_PLC_S7.Write("DB3.DBX50.4", false); - } - } - } - else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.5") is bool) - { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD30"); - if (res != null && res is float loc) - { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; - if (loc_index >= 1 && loc_index <= 15) - { - DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 - SmallStation.StockInIsWork = loc_index; - HKDevice.HK_PLC_S7.Write("DB3.DBX50.5", false); - } - } - } - else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.6") is bool) - { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD34"); - if (res != null && res is float loc) - { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; - if (loc_index >= 1 && loc_index <= 15) - { - DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 - SmallStation.StockInIsWork = loc_index; - HKDevice.HK_PLC_S7.Write("DB3.DBX50.6", false); - } - } - } - else if (HKDevice.HK_PLC_S7.Read("DB3.DBX50.7") is bool) - { - var res = HKDevice.HK_PLC_S7.Read("DB3.DBD38"); - if (res != null && res is float loc) - { - int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - double weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; - if (loc_index >= 1 && loc_index <= 15) - { - DeviceInquire.GetInstance.GetDevice(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 - SmallStation.StockInIsWork = loc_index; - HKDevice.HK_PLC_S7.Write("DB3.DBX50.7", false); - } - } - } - for (int i = 1; i < 16; i++) - { - if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) + MessageLog.GetInstance.ShowRunLog($"配方{res.RecipeName}配料完成"); + RecipeFinishInfo.Order_No = RemoteRecipes.ElementAt(index).RecipeCode; + RecipeFinishInfo.Product_Code = RemoteRecipes.ElementAt(index).RecipeName; + for (int i = 0; i < 16; i++) { - DeviceInquire.GetInstance.GetDevice(i).StatusReset(); - if (i >= 1 && i <= 8) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX30." + (i - 1), true); - } - else if (i >= 9 && i <= 15) - { - HKDevice.HK_PLC_S7.Write("DB4.DBX31." + (i - 9), true); - } + RecipeFinishInfo.Material[i].Material_Name = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + RecipeFinishInfo.Material[i].Material_BarrelNum = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + RecipeFinishInfo.Material[i].Material_Laying_Off_Weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; } - } - if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.2") is bool) - { - var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == code); - MessageLog.GetInstance.ShowRunLog($"托盘2 配方{res.RecipeName}配料完成"); + SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo, 3); + RecipeFinishInfo.Ask_For_Finish = true; Json.Data.Recipes.Remove(res); - RecipeTray1Queue.TryDequeue(out code); - HKDevice.HK_PLC_S7.Write("DB3.DBX1.2", false); - SmallStation.RecipeStatusIDTray2 = 0; + RecipeQueue.TryDequeue(out code); + HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false); + SmallStation.RecipeStatusID = 0; } } - } + } } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index 9fa18cdf..16ac5f45 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -60,9 +60,43 @@ namespace BPASmartClient.JXJFoodSmallStation.Model Thread.Sleep(200); }), "设备状态监听"); } + private void TestData() + { + for (int i = 0; i < 8; i++) + { + TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() + { + DeviceName = $"测试设备{i + 1}", + DeviceNum = i + 1, + Weight = new Random().Next(100, 10000) / 100.0 + }); + + devices.Add(new Devices() + { + DeviceName = $"测试设备{i + 1}", + IpAddress = $"192.168.1.{i + 1}", + }); + } + + for (int i = 8; i < 16; i++) + { + BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() + { + DeviceName = $"测试设备{i + 1}", + DeviceNum = i + 1, + Weight = new Random().Next(100, 10000) / 100.0 + }); + devices.Add(new Devices() + { + DeviceName = $"测试设备{i + 1}", + IpAddress = $"192.168.1.{i + 1}", + }); + } + } public void Init() { + TestData(); IpAddressLines(); DeviceDataInit(); ThreadManage.GetInstance().StartLong(new Action(() => @@ -266,11 +300,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model //{ // if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; //} - - - this.DeviceName = modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", ""); deviceStatus.RunStatus = (ushort)this.modbusTcp.ReadShort(DeviceAddress.RunStatus); //获取设备运行状态 deviceStatus.WeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.WeightFeedback);//获取设备料仓剩余重量 + deviceStatus.NowWeightFeedback = (float)this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback);//获取下料重量 deviceStatus.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号 deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码 diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs index 1c8ced08..3d109842 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs @@ -12,7 +12,5 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public class LocaPar { public ObservableCollection Recipes { get; set; } = new ObservableCollection(); - - } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs index 61b4febb..fdb08d26 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs @@ -22,6 +22,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// public float WeightFeedback { get; set; } + /// + /// 当前出料重量反馈 + /// + public float NowWeightFeedback { get; set; } + /// /// 上限反馈 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs index d08b6b7b..16ae94d4 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeData.cs @@ -18,8 +18,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 配方ID /// - public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } - private long _mRecipeCode; + public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; } } + private string _mRecipeCode; /// /// 托盘编号 diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs index 2e0bbe27..359c1eda 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/RemoteRecipeRawMaterial.cs @@ -11,13 +11,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public int DeviceIp { get { return _mIp; } set { _mIp = value; }} private int _mIp; - public int RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } - private int _mRawMaterialName; + public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; } } + private string _mRawMaterialName; /// /// 原料对应的桶号 /// - public int RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } } - private int _mRawMaterialBarrelNum; + public short RawMaterialBarrelNum { get { return _mRawMaterialBarrelNum; } set { _mRawMaterialBarrelNum = value; } } + private short _mRawMaterialBarrelNum; /// /// 需要原料重量 @@ -25,6 +25,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public double RawMaterialWeight { get { return _mRawMaterialWeight; } set { _mRawMaterialWeight = value; } } private double _mRawMaterialWeight; + /// + /// 实际的下料中重量 + /// + public float Laying_Off_Weight { get { return _mLaying_Off_Weight; } set { _mLaying_Off_Weight = value; } } + private float _mLaying_Off_Weight; + /// /// 原料对应料仓的位置 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index a4e66b6a..792c9f16 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using BPASmartClient.S7Net; +using System.Threading; namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { @@ -14,51 +15,44 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); public bool IsConnected => Siemens_PLC_S7.IsConnected; - /// - /// 配方接收信号复位 - /// - public void RecipeSignReset() - { - this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0); - } - /// - /// AGV到位信号复位 - /// - public void AgvSignReset() - { - this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0); - } public void Init() { if (IsConnected) { ThreadManage.GetInstance().StartLong(new Action(() => { - var res = this.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeState); - if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig)) + 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)) + { + ActionManage.GetInstance.Send("西门子下发配方",res); + res.Ask_For_Send_Bit = false; + this.Siemens_PLC_S7.WriteClass(res, 1); + } + + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0])) { - ActionManage.GetInstance.Send("西门子下发配方"); - RecipeSignReset(); + ActionManage.GetInstance.Send("AGV到工位1信号",res1); + res1.Allow_AGV_Put[0] = false; + this.Siemens_PLC_S7.WriteClass(res1, 2); } - var AgvState = this.Siemens_PLC_S7.Read(SiemensCommAddress.StateSign); - if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig)) + if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1])) { - ActionManage.GetInstance.Send("AGV到位信号"); - AgvSignReset(); + ActionManage.GetInstance.Send("AGV到工位2信号",res1); + res1.Allow_AGV_Put[1] = false; + this.Siemens_PLC_S7.WriteClass(res1, 2); } + + if (res2 != null && res2.Ask_For_Finish_PLC) + { + ActionManage.GetInstance.Send("配料完成信号确认完成"); + res2.Ask_For_Finish_PLC = false; + this.Siemens_PLC_S7.WriteClass(res2, 3); + } + Thread.Sleep(10); }),"监听服务数据"); } } - /// - /// 配方配料完成信号 - /// - /// - /// - private void DosingFinsih(int TrayLocation,int recipeID) - { - this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation); - this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1); - this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID); - } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs new file mode 100644 index 00000000..24e7608d --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Finish_DB.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens +{ + internal class XL_Finish_DB + { + /// + /// 生产工单编码 + /// + public string Order_No; + /// + /// 产品名称 + /// + public string Product_Code; + /// + /// 原料信息 + /// + public UDT1[] Material = new UDT1[20]; + /// + /// 配料完成信号 + /// + public bool Ask_For_Finish; + /// + /// 配料完成信号确认 + /// + public bool Ask_For_Finish_PLC; + + } + public class UDT1 + { + public string Material_Name; + public float Material_Laying_Off_Weight; + public short Material_BarrelNum; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs new file mode 100644 index 00000000..9dcb5ac9 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens +{ + internal class XL_Start_DB + { + /// + /// 配方编码 + /// + public string RecipeCode; + /// + /// 配发名称 + /// + public string RecipeName; + /// + /// 物料信息 + /// + public UDT[] Material = new UDT[20]; + /// + /// 托盘编号 + /// + public int TrayCode; + /// + /// 配方发送请求 + /// + public bool Ask_For_Send_Bit; + /// + /// 上位机确认配方接收完成 + /// + public bool Ack_Ask_For_Send_Bit; + + } + public class UDT + { + /// + /// 原料名称 + /// + public string Material_Name; + /// + /// 原料重量 + /// + public float Material_Weight; + /// + /// 原料桶号 + /// + public short Material_BarrelNum; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs new file mode 100644 index 00000000..fc06a44a --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Status_DB.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens +{ + internal class XL_Status_DB + { + /// + /// 生产工单 + /// + public string Order_No; + /// + /// 配料开始 + /// + public bool Dosing_Start; + /// + /// 配料开始确认 + /// + 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 byte Reserve; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs b/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs index 6503b448..8f96ff0d 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/TestData.cs @@ -18,19 +18,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public TestData() { string recipeName = "配方1"; - long recipeCode = 10001; + string recipeCode = "10001"; int Traycode = 1; double RawmaterialWeight = 10; - int RawMaterialbarrelNum = 1; + short RawMaterialbarrelNum = 1; int RawMaterialLocation = 5; double RawmaterialWeight1 = 20; - int RawMaterialbarrelNum1 = 2; + short RawMaterialbarrelNum1 = 2; int RawMaterialLocation1 = 7; double RawmaterialWeight2 = 30; - int RawMaterialbarrelNum2 = 3; + short RawMaterialbarrelNum2 = 3; int RawMaterialLocation2 = 9; RawMaterials.Add(new RemoteRecipeRawMaterial() { @@ -64,19 +64,19 @@ namespace BPASmartClient.JXJFoodSmallStation.Model RawMaterials.Clear(); string recipeName_2 = "配方2"; - long recipeCode_2 = 20001; + string recipeCode_2 = "20001"; int Traycode_2 = 3; double RawmaterialWeight_2 = 10; - int RawMaterialbarrelNum_2 = 1; + short RawMaterialbarrelNum_2 = 1; int RawMaterialLocation_2 = 5; double RawmaterialWeight1_2 = 20; - int RawMaterialbarrelNum1_2 = 2; + short RawMaterialbarrelNum1_2 = 2; int RawMaterialLocation1_2 = 7; double RawmaterialWeight2_2 = 30; - int RawMaterialbarrelNum2_2 = 3; + short RawMaterialbarrelNum2_2 = 3; int RawMaterialLocation2_2 = 9; RawMaterials.Add(new RemoteRecipeRawMaterial() { diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs index 5cee9780..d9f689f9 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeInfosViewModel.cs @@ -42,8 +42,8 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public string RecipeName { get { return _mRecipeName; } set { _mRecipeName = value; OnPropertyChanged(); } } private string _mRecipeName; - public long RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } - private long _mRecipeCode; + public string RecipeCode { get { return _mRecipeCode; } set { _mRecipeCode = value; OnPropertyChanged(); } } + private string _mRecipeCode; public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } private int _mTrayCode; diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs index 36857a1e..b4d61bb2 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeReceiveViewModel.cs @@ -30,7 +30,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel Recipes = Json.Data.Recipes; DetailsCommand = new RelayCommand((o) => { - if (o != null && o is long num) + if (o != null && o is string num) { ActionManage.GetInstance.CancelRegister("RecipeInfo"); RecipeInfosView nrv = new RecipeInfosView(); @@ -45,7 +45,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel RawMaterials.Clear(); string recipeName = "配方" + (Json.Data.Recipes.Count + 1) + ""; go: - long recipeCode = new Random().Next(1000, 9999); + string recipeCode = new Random().Next(1000, 9999).ToString(); foreach (var item in Recipes) { if (item.RecipeCode == recipeCode) @@ -59,7 +59,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel RawMaterials.Add(new RemoteRecipeRawMaterial() { RawMaterialWeight = new Random().Next(10, 1000), - RawMaterialBarrelNum = new Random().Next(1, 3), + RawMaterialBarrelNum = (short)new Random().Next(1, 3), RawMaterialLocation = i, }); }