From 1d48a26b97f4c1b535c122e24e63128d718ffa11 Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Sat, 20 Aug 2022 13:40:11 +0800 Subject: [PATCH 01/13] =?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 --- .../Model/GVL_BigStation.cs | 20 +- .../Model/ProcessControl.cs | 247 +++++++++--------- .../ViewModel/RecipeReceiveViewModel.cs | 13 +- .../Model/ProcessControl.cs | 5 +- 4 files changed, 145 insertions(+), 140 deletions(-) diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 91af66e9..49d9601e 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -11,18 +11,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model { public class GVL_BigStation { - /// - /// 配方数据 - /// - public ObservableCollection RemoteRecipes = new ObservableCollection(); - /// - /// 配方数据 - /// - public ObservableCollection IssuedComplete = new ObservableCollection(); - /// - /// 配方队列 - /// - public ConcurrentQueue RecipeQueue = new ConcurrentQueue(); + /// /// 往输送带下发配方完成 /// @@ -38,13 +27,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// /// 记录AGV进站送货的指令顺序 /// - public int[] AgvDeliveryPosition { get; set; }= new int[6]; + public int AgvDeliveryPosition { get; set; } /// /// 记录AGV进站取货的指令顺序 /// - public int[] AgvPickUpPosition { get; set; } = new int[6]; - - public ConcurrentQueue AGVToWorkStationQueue = new ConcurrentQueue(); - + public int AgvPickUpPosition { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index 4ccc3506..7788c885 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -25,6 +25,23 @@ namespace BPASmartClient.JXJFoodBigStation.Model public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); public HKDeviceStatus HKDevice = new HKDeviceStatus(); GVL_BigStation BigStation = new GVL_BigStation(); + + /// + /// 配方数据 + /// + public ObservableCollection RemoteRecipes = new ObservableCollection(); + /// + /// 配方数据 + /// + public ObservableCollection IssuedComplete = new ObservableCollection(); + /// + /// 配方队列 + /// + public ConcurrentQueue RecipeQueue = new ConcurrentQueue(); + /// + /// AGV到达工站队列 + /// + public ConcurrentQueue AGVToWorkStationQueue = new ConcurrentQueue(); /// /// 接收原料数据 /// @@ -38,9 +55,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model 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); - if ((res != null && res is string recipeName) && - (res1 != null && res1 is uint recipeID) && - (res2 > 0)) + if ((res != null && res is string recipeName) && (res1 != null && res1 is uint recipeID) && (res2 > 0)) { int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == recipeID); if (index == -1) @@ -77,12 +92,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model 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) + int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == recipeId); + if (index >= 0 && index < RemoteRecipes.Count) { - Json.Data.Recipes.ElementAt(index).TrayCode = TrayLocation; + RemoteRecipes.ElementAt(index).TrayCode = TrayLocation; MessageLog.GetInstance.RunLog($"接收到AGV进站信号=>配方编码:{recipeId} 、托盘位置:{TrayLocation}"); - BigStation.AGVToWorkStationQueue.Enqueue(recipeId); + AGVToWorkStationQueue.Enqueue(recipeId); } } } @@ -106,7 +121,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model { } - BigStation.RecipeQueue.Clear(); + RecipeQueue.Clear(); Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { @@ -117,8 +132,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model ThreadManage.GetInstance().StartLong(new Action(() => { if (HKDevice.IsConnected && SiemensDevice.IsConnected) { - AgvGetInDelivery(); - //AgvGetInPickUp(); + AgvGetInOut(); } Thread.Sleep(10); @@ -126,123 +140,120 @@ namespace BPASmartClient.JXJFoodBigStation.Model ThreadManage.GetInstance().StartLong(new Action(() => { ReadSiemensCommData(); ReadHKPLCCommData(); - }), "AGV进站送取货", true); + }), "读取西门子和海科PLC的数据", true); } /// - /// AGV进站送货 + /// AGV送货 /// - private void AgvGetInDelivery() + /// + private void AGV_Delivery(int bitNum) { - //检测AGV到站信号 - if (BigStation.AGVToWorkStationQueue.Count > 0) + if ((ReadSiemens("M4002."+ bitNum) is bool) && BigStation.AgvDeliveryPosition == 0) { - int index = BigStation.AGVToWorkStationQueue.ElementAt(0); - + BigStation.AgvDeliveryPosition = 1; + WriteHKPLC("M4002."+ bitNum, true); + WriteSiemens("M4002."+ bitNum, false); } - for (int i = 0; i < 6; i++) + else if (ReadHK("M5002."+ bitNum) is bool && BigStation.AgvDeliveryPosition == 1) { - switch (BigStation.AgvDeliveryPosition[i]) - { - case 0: - if (true) - { - BigStation.AgvDeliveryPosition[i] = 1; - HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApply, true); - SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVApply,false); - } - break; - case 1: - if (HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApply) is bool) - { - BigStation.AgvDeliveryPosition[i] = 2; - SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApply, true); - } - break; - case 2: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVApplyJack) is bool)) - { - BigStation.AgvDeliveryPosition[i] = 3; - HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVApplyJack, true); - } - break; - case 3: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.DeliveryAGVIsApplyJack) is bool)) - { - BigStation.AgvDeliveryPosition[i] = 4; - SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.DeliveryAGVIsApplyJack, true); - } - break; - case 4: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.DeliveryAGVFinsih) is bool)) - { - BigStation.AgvDeliveryPosition[i] = 5; - HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.DeliveryAGVFinsih, true); - } - break; - case 5: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationHaveCargo) is bool)) - { - BigStation.AgvDeliveryPosition[i] = 0; - SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationHaveCargo, true); - } - break; - default: - break; - } - //获取工位上是否有小车 - SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.StationIsExistCar, (bool) - HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.StationIsExistCar)); + 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进站取货 + /// AGV取货 /// - private void AgvGetInPickUp() + /// + private void AGV_Pick(int bitNum) { - /*switch (BigStation.AgvPickUpPosition) + if (ReadSiemens("M4003"+ bitNum) is bool && BigStation.AgvPickUpPosition == 0) { - case 0: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickAGVApply) is bool)) - { - BigStation.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)) - { - BigStation.AgvPickUpPosition = 2; - SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVIsApply, true); - } - break; - case 2: - if (RTrig.GetInstance("").Start(SiemensDevice.Siemens_PLC_S7.Read(SiemensCommAddress.PickCargoAGVFinish) is bool)) + 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(HKPlcCommAddress.StationIsExistCar)); + //检测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 + int recipe = (int)RemoteRecipes.ElementAt(index).RecipeCode; + if (TrayLocation > 0 && TrayLocation < 7) + { + AGV_Delivery(TrayLocation - 1); + if (BigStation.AgvDeliveryPosition == 5) { - BigStation.AgvPickUpPosition = 3; - HKDevice.HK_PLC_S7.Write(HKPlcCommAddress.PickCargoAGVFinish, true); + BigStation.AgvDeliveryPosition = 0; + AGVToWorkStationQueue.TryDequeue(out recipe); } - break; - case 3: - if (RTrig.GetInstance("").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.PickAGVFinish) is bool)) + AGV_Pick(TrayLocation - 1); + if (BigStation.AgvPickUpPosition == 3) { BigStation.AgvPickUpPosition = 0; - SiemensDevice.Siemens_PLC_S7.Write(SiemensCommAddress.PickAGVFinish, true); + AGVToWorkStationQueue.TryDequeue(out recipe); } - break; - default: - break; - }*/ + } + } } private void ReceviceData() { - BigStation.RemoteRecipes = Json.Data.Recipes; - if (Json.Data.Recipes.Count > 0) + RemoteRecipes = Json.Data.Recipes; + if (RemoteRecipes.Count > 0) { - foreach (var data in Json.Data.Recipes) + foreach (var data in RemoteRecipes) { - if(!(BigStation.RecipeQueue.Contains(data.RecipeCode))) - BigStation.RecipeQueue.Enqueue(data.RecipeCode); + if(!(RecipeQueue.Contains(data.RecipeCode))) + RecipeQueue.Enqueue(data.RecipeCode); } } } @@ -251,19 +262,19 @@ namespace BPASmartClient.JXJFoodBigStation.Model ushort[] Weight = new ushort[15]; private void RecipeInfoToHKPLC() { - if (BigStation.RecipeQueue.Count > 0) + if (RecipeQueue.Count > 0) { - int index = Array.FindIndex(BigStation.RemoteRecipes.ToArray(), p => p.RecipeCode == BigStation.RecipeQueue.ElementAt(0)); - if (index >= 0 && index <= BigStation.RemoteRecipes.Count) + int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0)); + if (index >= 0 && index <= RemoteRecipes.Count) { - long code = BigStation.RemoteRecipes.ElementAt(index).RecipeCode; + long code = RemoteRecipes.ElementAt(index).RecipeCode; if (HKDevice.HK_PLC_S7.Read("M5001.0") is bool)//配方1是否允许下发配发 { - for (int i = 0; i < BigStation.RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) + for (int i = 0; i < RemoteRecipes.ElementAt(index).RawMaterial.Count; i++) { - BarrelNum[i] = (ushort)BigStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - Location[i] = (ushort)BigStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialLocation; - Weight[i] = (ushort)BigStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialWeight; + 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; } HKDevice.StockBinPar(BarrelNum, Location, Weight); HKDevice.HK_PLC_S7.Write("M4001.0", 1);//配发下发完成,to plc @@ -273,9 +284,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model if (RTrig.GetInstance("StockState").Start(HKDevice.HK_PLC_S7.Read(HKPlcCommAddress.RecipeDosingFinish) is bool)) { HKDevice.RecipeDosingFinishReset(); - BigStation.RecipeQueue.TryDequeue(out code); - - BigStation.IssuedComplete.Add(BigStation.RemoteRecipes.ElementAt(index));//将该配方添加到下 + RecipeQueue.TryDequeue(out code); + IssuedComplete.Add(RemoteRecipes.ElementAt(index));//将该配方添加到下 Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 } } @@ -289,8 +299,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model { GetSiemensStatus("", new Action((obj) => { - - + if (obj is bool[] bools && bools.Length > 0) + { + + } })); } } @@ -298,6 +310,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (HKDevice.IsConnected) { + } } private void GetHKStatus(string key,Action action) diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs index c463d75b..74fe86f7 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeReceiveViewModel.cs @@ -45,7 +45,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel RawMaterials.Clear(); string recipeName = "配方" + (Json.Data.Recipes.Count + 1) + ""; go: - long recipeCode = new Random().Next(1000, 9999); + long recipeCode = new Random().Next(10000, 99999); foreach (var item in Recipes) { if (item.RecipeCode == recipeCode) @@ -53,13 +53,18 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel goto go; } } - int trayCode = new Random().Next(1, 3); - for (int i = 1; i < 16; i++) + int trayCode = new Random().Next(1,6); + for (int i = 1; i < 13; i++) { + int a = new Random().Next(1, 5); + if (a == 3) + { + a = 1; + } RawMaterials.Add(new RemoteRecipeRawMaterial() { RawMaterialWeight = new Random().Next(10, 1000), - RawMaterialBarrelNum = new Random().Next(1, 3), + RawMaterialBarrelNum = a, RawMaterialLocation = i, }); } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 292e5ce2..23ecc220 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -97,14 +97,15 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } SmallStation.RecipeQueue.Clear(); - Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 + //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { ReceviceData(); RecipeInfoToHKPLC(); Thread.Sleep(10); }), "流程处理", true); - ThreadManage.GetInstance().StartLong(new Action(() => { + ThreadManage.GetInstance().StartLong(new Action(() => + { if (SiemensDevice.IsConnected && HKDevice.IsConnected) { AgvGetInDelivery(); From 5b7f1976b6b67aecd597c17e320d6363abb401ec Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Wed, 24 Aug 2022 13:25:34 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E5=90=89=E9=A6=99=E5=B1=85=E5=B0=8F?= =?UTF-8?q?=E6=96=99=E7=AB=99=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 --- .../Pages/ViewModel/AlarmViewModel.cs | 4 +- .../App.xaml.cs | 43 +- .../BPASmartClient.JXJFoodSmallStation.csproj | 27 ++ .../Converter/DataTableRedundantConverter.cs | 31 ++ .../Model/Converter/RunStatusConvert.cs | 68 +++ .../Model/DeviceInquire.cs | 181 +++++-- .../Model/ProcessControl.cs | 6 +- .../Model/RawMaterial/AlarmInfo.cs | 48 ++ .../Model/RawMaterial/DeviceAddress.cs | 118 +++-- .../{ => RawMaterial}/DeviceCurrentStatus.cs | 5 +- .../Model/RawMaterial/DevicePar.cs | 15 + .../Model/RawMaterial/DeviceParModel.cs | 75 +++ .../Model/RawMaterial/GlobalData.cs | 15 + .../Model/RawMaterial/LocaPar.cs | 3 + .../RawMaterial/RawMaterialDeviceStatus.cs | 19 +- .../Model/RawMaterial/RecipeModel.cs | 1 - .../View/DeviceListView.xaml | 66 ++- .../View/DeviceMaterialParView.xaml | 369 ++++++++++++++ .../View/DeviceMaterialParView.xaml.cs | 28 ++ .../View/HardwareStatusView.xaml | 449 +++++++----------- .../View/NewMaterialView.xaml | 175 +++++++ .../View/NewMaterialView.xaml.cs | 35 ++ .../View/NewRecipeView.xaml | 20 +- .../View/RecipeControlView.xaml | 292 +++++++++++- .../View/RecipeControlView.xaml.cs | 30 +- .../View/RecipeSettingsView.xaml | 80 +--- .../View/RecipeSettingsView.xaml.cs | 19 + .../ViewModel/ChangeDeviceNameViewModel.cs | 6 +- .../ViewModel/DeviceListViewModel.cs | 5 +- .../ViewModel/DeviceMaterialParViewModel.cs | 69 +++ .../ViewModel/HardwareStatusViewModel.cs | 16 +- .../ViewModel/NewMaterialViewModel.cs | 58 +++ .../ViewModel/NewRecipeViewModel.cs | 92 ++-- .../ViewModel/RecipeControlViewModel.cs | 101 +++- .../ViewModel/RecipeSettingsViewModel.cs | 13 +- 35 files changed, 2028 insertions(+), 554 deletions(-) create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs rename BPASmartClient.JXJFoodSmallStation/Model/{ => RawMaterial}/DeviceCurrentStatus.cs (78%) create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml create mode 100644 BPASmartClient.JXJFoodSmallStation/View/DeviceMaterialParView.xaml.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/View/NewMaterialView.xaml create mode 100644 BPASmartClient.JXJFoodSmallStation/View/NewMaterialView.xaml.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/ViewModel/DeviceMaterialParViewModel.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/ViewModel/NewMaterialViewModel.cs diff --git a/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs b/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs index 65788bcb..3476f95f 100644 --- a/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs +++ b/BPASmartClient.CustomResource/Pages/ViewModel/AlarmViewModel.cs @@ -64,8 +64,8 @@ namespace BPASmartClient.CustomResource.Pages.ViewModel } }); - AlarmInfos = MessageLog.GetInstance.alarmLogs; - + //AlarmInfos = MessageLog.GetInstance.alarmLogs; + AlarmInfos = AlarmHelper.Alarms; } private void GetHistoryAlarm() diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index 92abc22f..f7904b09 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -56,21 +56,21 @@ namespace BPASmartClient.JXJFoodSmallStation #region 配方管理菜单 ObservableCollection RecipeManage = new ObservableCollection(); - /*RecipeManage.Add(new SubMenumodel() + RecipeManage.Add(new SubMenumodel() { SubMenuName = "本地配方管理", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.RecipeSettingsView" - });*/ + }); - /*RecipeManage.Add(new SubMenumodel() + RecipeManage.Add(new SubMenumodel() { SubMenuName = "本地配方下发", SubMenuPermission = new Permission[] { Permission.操作员, Permission.管理员 }, AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.RecipeControlView" - });*/ + }); RecipeManage.Add(new SubMenumodel() { SubMenuName = "服务配方管理", @@ -87,6 +87,24 @@ namespace BPASmartClient.JXJFoodSmallStation }); #endregion + #region 参数设置 + ObservableCollection ParSet = new ObservableCollection(); + ParSet.Add(new SubMenumodel() + { + SubMenuName = "原料参数设置", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.JXJFoodSmallStation", + ToggleWindowPath = "View.DeviceMaterialParView" + }); + MenuManage.GetInstance.menuModels.Add(new MenuModel() + { + MainMenuIcon = "", + MainMenuName = "参数设置", + Alias = "Parameter Set", + subMenumodels = ParSet, + }); + #endregion + #region 消息日志 ObservableCollection InfoLog = new ObservableCollection(); InfoLog.Add(new SubMenumodel() @@ -174,14 +192,21 @@ namespace BPASmartClient.JXJFoodSmallStation AssemblyName = "BPASmartClient.CustomResource", ToggleWindowPath = "Pages.View.PasswordChangeView" }); - - /* UserManager.Add(new SubMenumodel() + UserManager.Add(new SubMenumodel() { - SubMenuName = "NFC登录设置", + SubMenuName = "用户管理", SubMenuPermission = new Permission[] { Permission.管理员 }, AssemblyName = "BPASmartClient.CustomResource", - ToggleWindowPath = "Pages.View.NfcSetView" - });*/ + ToggleWindowPath = "Pages.View.UserManagerView" + }); + + /* UserManager.Add(new SubMenumodel() + { + SubMenuName = "NFC登录设置", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.CustomResource", + ToggleWindowPath = "Pages.View.NfcSetView" + });*/ MenuManage.GetInstance.menuModels.Add(new MenuModel() { diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj index b6e0a466..f033f6a2 100644 --- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj +++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj @@ -19,4 +19,31 @@ + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + $(DefaultXamlRuntime) + + + diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs b/BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs new file mode 100644 index 00000000..d3aeae3f --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Converter/DataTableRedundantConverter.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace BPASmartClient.JXJFoodSmallStation.Converter +{ + public class DataTableRedundantConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value != null && value is bool bit) + { + if (bit) + return new SolidColorBrush(Color.FromArgb(255, 245, 63, 98)); + else + return new SolidColorBrush(Color.FromArgb(255, 42, 178, 231)); + } + return default; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs b/BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs new file mode 100644 index 00000000..56a2a661 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/Converter/RunStatusConvert.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; + +namespace BPASmartClient.JXJFoodSmallStation.Converter +{ + public class RunStatusConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is ushort tempValue) + { + if (tempValue == 1) return "等待配料"; + if (tempValue == 2) return "配料中"; + if (tempValue == 3) return "配料完成"; + } + return "等待配料"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + public class EnbleConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is ushort tempValue) + { + if (tempValue == 0) return true; + if (tempValue == 1) return false; + + } + return true; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + public class IntToSourceConvert : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is ushort tempValue) + { + if (tempValue == 0) return "本地原料"; + if (tempValue == 1) return "设备原料"; + + } + return "未知"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs index 9a7fce73..afff4ad6 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/DeviceInquire.cs @@ -12,6 +12,8 @@ using System.Threading; using System.Threading.Tasks; using BPASmartClient.CustomResource.UserControls.MessageShow; using BPASmartClient.CustomResource.Pages.Model; +using System.Collections.ObjectModel; +using BPASmartClient.Model; namespace BPASmartClient.JXJFoodSmallStation.Model { @@ -27,10 +29,46 @@ namespace BPASmartClient.JXJFoodSmallStation.Model List InvalidIP = new List();//无效 IP 集合 List IPLists = new List();//启动 Ping 任务IP集合 ConcurrentQueue IPQueues = new ConcurrentQueue();//pincomplete 完成队列 - ConcurrentDictionary DeviceLocation = new ConcurrentDictionary(); + + public ObservableCollection TopDeviceCurrentStatuses { get; set; } = new ObservableCollection(); + public ObservableCollection BottomDeviceCurrentStatuses { get; set; } = new ObservableCollection(); + public ObservableCollection devices { get; set; } = new ObservableCollection(); + private void DeviceDataInit() + { + ThreadManage.GetInstance().StartLong(new Action(() => + { + for (int i = 0; i < DeviceLists.Count; i++) + { + string deviceName = DeviceLists.ElementAt(i).Value.DeviceName; + int TopIndex = Array.FindIndex(TopDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName); + int BottomIndex = Array.FindIndex(BottomDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName); + if (TopIndex >= 0 && TopIndex < TopDeviceCurrentStatuses.Count) + { + TopDeviceCurrentStatuses.ElementAt(TopIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback; + TopDeviceCurrentStatuses.ElementAt(TopIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; + } + + if (BottomIndex >= 0 && BottomIndex < BottomDeviceCurrentStatuses.Count) + { + BottomDeviceCurrentStatuses.ElementAt(BottomIndex).Weight = DeviceLists.ElementAt(i).Value.deviceStatus.WeightFeedback; + BottomDeviceCurrentStatuses.ElementAt(BottomIndex).DeviceNum = DeviceLists.ElementAt(i).Value.deviceStatus.DeviceNum; + } + + int deviceIndex = Array.FindIndex(devices.ToArray(), p => p.IpAddress == DeviceLists.ElementAt(i).Key); + if (deviceIndex >= 0 && deviceIndex < devices.Count) + { + devices.ElementAt(i).DeviceName = DeviceLists.ElementAt(i).Value.DeviceName; + } + } + Thread.Sleep(200); + }), "设备状态监听"); + } + public void Init() { + devices.Add(new Devices() { DeviceName = "测试", IpAddress = "192.168.0.1" }); IpAddressLines(); + DeviceDataInit(); ThreadManage.GetInstance().StartLong(new Action(() => { if (IPQueues.Count >= IPLists.Count) @@ -54,14 +92,14 @@ namespace BPASmartClient.JXJFoodSmallStation.Model return new DeviceStatus(); } - public DeviceStatus GetDeviceObject(int location) + public List GetDevice() { - if (location >= 1 && location <= 15) + List deviceStatuses = new List(); + foreach (var device in DeviceLists) { - var res = DeviceLists.Values.FirstOrDefault(p => p.RawMaterialLocation == location); - if (res != null) return res; + deviceStatuses.Add(device.Value); } - return new DeviceStatus(); + return deviceStatuses; } private void IpAddressLines() @@ -96,20 +134,27 @@ namespace BPASmartClient.JXJFoodSmallStation.Model DS.modbusTcp.ConnectOk = new Action(() => { - string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20);//读取设备名称 - int rawMaterialLocation = DS.modbusTcp.GetAddress(DeviceAddress.Location); + string DeviceName = DS.modbusTcp.GetString(DeviceAddress.DeviceName, 20).Trim()?.Replace(" ", "");//读取设备名称 if (DeviceName.Length > 0) { DeviceLists.TryAdd(ip, DS); - DeviceLists[ip].Init(DeviceName, rawMaterialLocation); + DeviceLists[ip].Init(DeviceName); DeviceLists[ip].modbusTcp.IsReconnect = false; App.Current.Dispatcher.Invoke(new Action(() => { - DeviceListViewModel.devices.Add(new Devices() - { - DeviceName = DeviceName, - IpAddress = ip - });//加入连接的(有名称的)设备列表 + //DeviceListViewModel.devices.Add(new Devices() + //{ + // DeviceName = DeviceName, + // IpAddress = ip + //});//加入连接的(有名称的)设备列表 + + devices.Add(new Devices() { DeviceName = DeviceName, IpAddress = ip }); + + if (TopDeviceCurrentStatuses.Count <= 8) + TopDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); + else + BottomDeviceCurrentStatuses.Add(new DeviceCurrentStatus() { DeviceName = DeviceName }); + for (int i = 0; i < Json.Data.Recipes.Count; i++) { @@ -118,12 +163,21 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).DeviceIp == ip) { Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMaterialName = DeviceName; - Json.Data.Recipes.ElementAt(i).RawMaterials.ElementAt(m).RawMateriaLocation = rawMaterialLocation; } } } - if (!NewRecipeViewModel.RawMaterialNames.Contains(DeviceName)) - NewRecipeViewModel.RawMaterialNames.Add(DeviceName); + if (Global.DeviceRawMaterials.Count > 0) + { + if (Global.DeviceRawMaterials.FirstOrDefault(p => p.RawMaterialName == DeviceName) == null) + { + Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 }); + } + } + else + { + Global.DeviceRawMaterials.Add(new RawMaterialModel() { RawMaterialName = DeviceName, DeviceIp = ip, RawMaterialSource = 1 }); + } + })); } else @@ -141,14 +195,25 @@ namespace BPASmartClient.JXJFoodSmallStation.Model DS.modbusTcp.Disconnect = new Action(() => { if (InvalidIP.Contains(ip)) InvalidIP.Remove(ip); - var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip); - if (res != null && DeviceListViewModel.devices.Contains(res)) + //var res = DeviceListViewModel.devices.FirstOrDefault(P => P.IpAddress == ip); + var res = devices.FirstOrDefault(P => P.IpAddress == ip); + //if (res != null && DeviceListViewModel.devices.Contains(res)) + if (res != null && devices.Contains(res)) + { App.Current.Dispatcher.Invoke(new Action(() => { - DeviceListViewModel.devices.Remove(res); - if (NewRecipeViewModel.RawMaterialNames.Contains(res.DeviceName)) - NewRecipeViewModel.RawMaterialNames.Remove(res.DeviceName); + //DeviceListViewModel.devices.Remove(res); + devices.Remove(res); + var item = Global.DeviceRawMaterials.FirstOrDefault(P => P.RawMaterialName == res.DeviceName); + if (item != null) Global.DeviceRawMaterials.Remove(item); + + var topRes = TopDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == res.DeviceName); + var bottomRes = BottomDeviceCurrentStatuses.FirstOrDefault(p => p.DeviceName == res.DeviceName); + if (topRes != null) TopDeviceCurrentStatuses.Remove(topRes); + if (bottomRes != null) BottomDeviceCurrentStatuses.Remove(bottomRes); })); + } + if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); }); @@ -166,35 +231,51 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public class DeviceStatus { + #region 对象属性声明 public string DeviceName = String.Empty; public string IpAddress => modbusTcp.IPAdress; - public bool IsConnected => modbusTcp.Connected; - public int RawMaterialLocation { get; set; } + /// /// 设备状态 /// public RawMaterialDeviceStatus deviceStatus { get; set; } = new RawMaterialDeviceStatus(); + + + public ModbusTcp modbusTcp = new ModbusTcp(); + + public bool IsConnected => modbusTcp.Connected; #endregion - public void Init(string DeviceName,int rawMaterialLocation) + + public void Init(string DeviceName) { this.DeviceName = DeviceName; - this.RawMaterialLocation = rawMaterialLocation; + AlarmHelper.Init(); if (modbusTcp.Connected) { ThreadManage.GetInstance().StartLong(new Action(() => { //获取设备运行状态 - var res = this.modbusTcp.Read(DeviceAddress.RunStatus); - if (res != null && res is ushort[] ushortValue) - { - if (ushortValue.Length >= 1) deviceStatus.RunStatus = ushortValue[0]; - } - //获取设备料仓剩余重量 - deviceStatus.WeightFeedback = this.modbusTcp.GetUint(DeviceAddress.WeightFeedback); - deviceStatus.CutWeightFeedback = this.modbusTcp.GetUint(DeviceAddress.CutWeightFeedback); - deviceStatus.RawMaterialType =(ushort) this.modbusTcp.GetUint(DeviceAddress.RawMaterialType); + //var res = this.modbusTcp.Read(DeviceAddress.RunStatus); + //if (res != null && res is ushort[] ushortValue) + //{ + // 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.DeviceNum = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceNum);//获取设备编号 + deviceStatus.DeviceAlarmCode = (ushort)this.modbusTcp.ReadShort(DeviceAddress.DeviceAlarmCode);//获取设备故障编码 + + AlarmHelper.Alarm.EStop1 = deviceStatus.DeviceAlarmCode.Get16bitValue(1); + AlarmHelper.Alarm.Servo = deviceStatus.DeviceAlarmCode.Get16bitValue(2); + AlarmHelper.Alarm.Inverter = deviceStatus.DeviceAlarmCode.Get16bitValue(3); + AlarmHelper.Alarm.EStop2 = deviceStatus.DeviceAlarmCode.Get16bitValue(7); + AlarmHelper.Alarm.SiloUpperLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(8); + AlarmHelper.Alarm.SiloLowerLimit = deviceStatus.DeviceAlarmCode.Get16bitValue(9); Thread.Sleep(100); }), $"{DeviceName} 开始监听", true); } @@ -205,28 +286,36 @@ namespace BPASmartClient.JXJFoodSmallStation.Model this.modbusTcp.Write(DeviceAddress.DeviceName, new ushort[20]); this.modbusTcp.SetString(DeviceAddress.DeviceName, name); } + public void StatusReset() { - this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0);//OutRawMaterialFinish复位出料完成信号 - } - public void OutRawMaterialReset() - { - this.modbusTcp.Write(DeviceAddress.OutRawMaterialFinish, (ushort)0); + this.modbusTcp.Write(DeviceAddress.RunStatus, (ushort)0); } + public void Dispose() { ThreadManage.GetInstance().StopTask($"{DeviceName} 开始监听"); } - /// - /// 设置出料重量,触发出料信号 - /// - /// - public void Start(uint Value) + + public void Start(float Value) { if (modbusTcp.Connected) { - modbusTcp.SetUint(DeviceAddress.WeightSet, Value);//写入配方量 + modbusTcp.SetReal(DeviceAddress.WeightSet, Value);//写入配方量 modbusTcp.Write(DeviceAddress.Start, (ushort)1);//设备启动写入 + //配料设备参数写入 + var res = Json.Data.deviceParModels.FirstOrDefault(p => p.MaterialName == DeviceName); + if (res != null) + { + modbusTcp.SetReal(DeviceAddress.SlowlyAddWeight, res.SlowlyAddWeight); + modbusTcp.SetReal(DeviceAddress.PreCloseValveWeight, res.PreCloseValveWeight); + modbusTcp.SetUint(DeviceAddress.RapidAcceleration, (uint)res.RapidAcceleration); + modbusTcp.SetUint(DeviceAddress.SlowAcceleration, (uint)res.SlowAcceleration); + modbusTcp.SetUint(DeviceAddress.ServoManualSpeed, (uint)res.ServoManualSpeed); + modbusTcp.SetUint(DeviceAddress.SiloUpperLimitWeight, (uint)res.SiloUpperLimitWeight); + modbusTcp.SetUint(DeviceAddress.LowerLimitWeightOfSilo, (uint)res.LowerLimitWeightOfSilo); + modbusTcp.SetUint(DeviceAddress.StirringSpeed, (uint)res.StirringSpeed); + } } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 23ecc220..c27a8b9f 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -247,13 +247,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model double weight = SmallStation.RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight; if (loc_index >= 1 && loc_index <= 15) { - DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 + //DeviceInquire.GetInstance.GetDeviceObject(loc_index)?.Start((uint)weight);//启动并写入每个原料重量 SmallStation.StockInIsWork = loc_index; HKDevice.StockStateSignReset(); } } } - if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool)) + /*if (RTrig.GetInstance("OutRawMaterialFinish").Start(DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).modbusTcp.Read(DeviceAddress.OutRawMaterialFinish) is bool)) { HKDevice.SingleDosing((uint)SmallStation.StockInIsWork); DeviceInquire.GetInstance.GetDeviceObject(SmallStation.StockInIsWork).OutRawMaterialReset(); @@ -263,7 +263,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model HKDevice.RecipeDosingFinishReset(); SmallStation.RecipeQueue.TryDequeue(out code); Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - } + }*/ } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs new file mode 100644 index 00000000..04db6341 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/AlarmInfo.cs @@ -0,0 +1,48 @@ +using BPASmartClient.CustomResource.Pages.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model +{ + public class AlarmInfo + { + /// + /// 1#急停 + /// + [Alarm("1#急停")] + public bool EStop1 { get; set; } + + /// + /// 伺服故障 + /// + [Alarm("伺服故障")] + public bool Servo { get; set; } + + /// + /// 变频器故障 + /// + [Alarm("变频器故障")] + public bool Inverter { get; set; } + + /// + /// 2#急停 + /// + [Alarm("2#急停")] + public bool EStop2 { get; set; } + + /// + /// 料仓上限 + /// + [Alarm("料仓上限")] + public bool SiloUpperLimit { get; set; } + + /// + /// 料仓下限 + /// + [Alarm("料仓下限")] + public bool SiloLowerLimit { get; set; } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs index 46afc716..85307518 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceAddress.cs @@ -8,95 +8,91 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { public class DeviceAddress { - #region 源地址 - ///// - ///// 设备名称起始地址 - ///// - //public static string DeviceName { get; set; } = "LW0"; - - ///// - ///// 料仓重量反馈起始地址 - ///// - //public static string WeightFeedback { get; set; } = "LW52";//LW204 + /// + /// 设备名称起始地址 + /// + public static string DeviceName { get; set; } = "LW0"; - ///// - ///// 重量设置地址 - ///// - //public static string WeightSet { get; set; } = "LW21";//LW200 + /// + /// 料仓重量反馈起始地址 + /// + public static string WeightFeedback { get; set; } = "LW52"; - ///// - ///// 启动信号地址 - ///// - //public static string Start { get; set; } = "LW20";//LW210 + /// + /// 重量设置地址 + /// + public static string WeightSet { get; set; } = "LW21"; - ///// - ///// 下料重量反馈地址 - ///// - //public static string CutWeightFeedback { get; set; } = "LW54";//LW202 + /// + /// 启动信号地址 + /// + public static string Start { get; set; } = "LW20"; - ///// - ///// 设备运行状态地址 - ///// - //public static string RunStatus { get; set; } = "LW55";//LW206 + /// + /// 下料重量反馈地址 + /// + public static string CutWeightFeedback { get; set; } = "LW54"; - ///// - ///// 料仓的位置 - ///// - //public static string Location { get; set; } = "LW53"; - #endregion + /// + /// 设备编号 + /// + public static string DeviceNum { get; set; } = "LW57"; - #region 上位机下发 /// - /// 原料出料重量 + /// 设备故障编码 /// - public static string WeightSet { get; set; } = "LW11"; + public static string DeviceAlarmCode { get; set; } = "LW51"; + /// - /// 启动开始配料 + /// 原料设备类型 + /// 1:膏体,2:液体,3:粉体 /// - public static string Start { get; set; } = "LW12"; - #endregion - #region 上位机读取 + public static string MaterialDeviceType { get; set; } = "LW56"; + /// /// 设备运行状态地址 /// - public static string RunStatus { get; set; } = "LW50"; + public static string RunStatus { get; set; } = "LW60"; + /// - /// 报警字 + /// 慢加重量 /// - public static string AlarmInfo { get; set; } = "LW51"; + public static string SlowlyAddWeight { get; set; } = "LW23"; + /// - /// 原料名称 + /// 提前关阀重量 /// - public static string DeviceName { get; set; } = "LW52"; + public static string PreCloseValveWeight { get; set; } = "LW25"; + /// - /// 料仓的位置 + /// 快加速度 /// - public static string Location { get; set; } = "LW53"; + public static string RapidAcceleration { get; set; } = "LW27"; + /// - /// 原料类型 + /// 慢加速度 /// - public static string RawMaterialType { get; set; } = "LW54"; + public static string SlowAcceleration { get; set; } = "LW29"; + /// - /// 出料完成信号 + /// 伺服手动速度 /// - public static string OutRawMaterialFinish { get; set; } = "LW55"; + public static string ServoManualSpeed { get; set; } = "LW31"; + /// - /// 料仓重量反馈起始地址 + /// 料仓上限重量 /// - public static string WeightFeedback { get; set; } = "LW56"; + public static string SiloUpperLimitWeight { get; set; } = "LW33"; + /// - /// 下料重量反馈地址 + /// 料仓下限重量 /// - public static string CutWeightFeedback { get; set; } = "LW57"; - #endregion - - - + public static string LowerLimitWeightOfSilo { get; set; } = "LW35"; - - - - + /// + /// 搅拌速度 + /// + public static string StirringSpeed { get; set; } = "LW37"; } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/DeviceCurrentStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs similarity index 78% rename from BPASmartClient.JXJFoodSmallStation/Model/DeviceCurrentStatus.cs rename to BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs index 299ada75..b122df2b 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/DeviceCurrentStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceCurrentStatus.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using Microsoft.Toolkit.Mvvm.ComponentModel; -namespace BPASmartClient.JXJFoodSmallStation.Model +namespace BPASmartClient.JXJFoodSmallStation { public class DeviceCurrentStatus : ObservableObject { @@ -18,6 +18,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model private bool _mRunStatus; + 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/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs new file mode 100644 index 00000000..f402a8b1 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System.Collections.ObjectModel; + +namespace BPASmartClient.JXJFoodSmallStation +{ + public class DevicePar + { + public ObservableCollection deviceParModels { get; set; } = new ObservableCollection(); + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs new file mode 100644 index 00000000..d768b403 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceParModel.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; + +namespace BPASmartClient.JXJFoodSmallStation +{ + public class DeviceParModel : ObservableObject + { + /// + /// 原料名称 + /// + public string MaterialName { get { return _mMaterialName; } set { _mMaterialName = value; OnPropertyChanged(); } } + private string _mMaterialName = string.Empty; + + /// + /// 慢加重量 + /// + public float SlowlyAddWeight { get { return _mSlowlyAddWeight; } set { _mSlowlyAddWeight = value; OnPropertyChanged(); } } + private float _mSlowlyAddWeight; + + /// + /// 提前关阀重量 + /// + public float PreCloseValveWeight { get { return _mPreCloseValveWeight; } set { _mPreCloseValveWeight = value; OnPropertyChanged(); } } + private float _mPreCloseValveWeight; + + /// + /// 快加速度 + /// + public int RapidAcceleration { get { return _mRapidAcceleration; } set { _mRapidAcceleration = value; OnPropertyChanged(); } } + private int _mRapidAcceleration; + + /// + /// 慢加速度 + /// + public int SlowAcceleration { get { return _mSlowAcceleration; } set { _mSlowAcceleration = value; OnPropertyChanged(); } } + private int _mSlowAcceleration; + + /// + /// 伺服手动速度 + /// + public int ServoManualSpeed { get { return _mServoManualSpeed; } set { _mServoManualSpeed = value; OnPropertyChanged(); } } + private int _mServoManualSpeed; + + /// + /// 料仓上限重量 + /// + public int SiloUpperLimitWeight { get { return _mSiloUpperLimitWeight; } set { _mSiloUpperLimitWeight = value; OnPropertyChanged(); } } + private int _mSiloUpperLimitWeight; + + /// + /// 料仓下限重量 + /// + public int LowerLimitWeightOfSilo { get { return _mLowerLimitWeightOfSilo; } set { _mLowerLimitWeightOfSilo = value; OnPropertyChanged(); } } + private int _mLowerLimitWeightOfSilo; + + /// + /// 搅拌速度 + /// + public int StirringSpeed { get { return _mStirringSpeed; } set { _mStirringSpeed = value; OnPropertyChanged(); } } + private int _mStirringSpeed; + + /// + /// 是否重复 + /// + [Newtonsoft.Json.JsonIgnore] + public bool IsRedundant { get { return _mIsRedundant; } set { _mIsRedundant = value; OnPropertyChanged(); } } + private bool _mIsRedundant; + + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs new file mode 100644 index 00000000..4bb2454c --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/GlobalData.cs @@ -0,0 +1,15 @@ +using BPASmartClient.Model; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model +{ + public class GlobalData + { + + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs index c293856c..1c8ced08 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/LocaPar.cs @@ -5,11 +5,14 @@ using System.Text; using System.Threading.Tasks; using System.Collections.ObjectModel; using BPASmartClient.JXJFoodSmallStation.ViewModel; +using BPASmartClient.Model; 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 6bc51f52..61b4febb 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialDeviceStatus.cs @@ -11,8 +11,8 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 原料类型 - /// 1:液体 - /// 2:膏体 + /// 1:膏体 + /// 2:液体 /// 3:粉体 /// public ushort RawMaterialType { get; set; } @@ -39,7 +39,22 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 设备运行状态 + /// 0:未知 + /// 1:等待配料 + /// 2:配料中 + /// 3:配料完成 /// public ushort RunStatus { get; set; } + + /// + /// 设备故障编码 + /// + public ushort DeviceAlarmCode { get; set; } + + /// + /// 设备料仓编号 + /// + public ushort DeviceNum { get; set; } + } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs index 8286807a..7fe70363 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RecipeModel.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using BPASmartClient.JXJFoodSmallStation.ViewModel; using BPASmartClient.Model; using Microsoft.Toolkit.Mvvm.ComponentModel; diff --git a/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml b/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml index 0d0f2cb0..2bb91f48 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/DeviceListView.xaml @@ -44,15 +44,7 @@ - - - - - - + - - - + CornerRadius="0"> + + + - + + + + + + +