From 24a7495fb68da6017ae417ac0b2aa26886e34380 Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Wed, 15 Feb 2023 19:35:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BPASmartClient.JAKA/JakaMachine.cs | 20 +- .../Model/GVL_BigStation.cs | 2 + .../Model/HK_PLC/HKDeviceStatus.cs | 1 + .../Model/ProcessControl.cs | 340 +++++-- .../Model/RawMaterial/RecipeData.cs | 10 + .../View/RecipeInfosView.xaml | 2 +- .../View/RecipeReceiveView.xaml | 114 ++- .../View/RecipeSendDownView.xaml | 127 ++- .../View/SiemensRecipeSendDownView.xaml | 4 +- .../View/StockBinRawMaterialView.xaml | 1 - .../ViewModel/ManualFlowViewModel.cs | 1 + .../ViewModel/RecipeInfosViewModel.cs | 31 +- .../SiemensRecipeSendDownViewModel.cs | 1 - .../ViewModel/StockBinRawMaterialViewModel.cs | 4 + .../App.xaml.cs | 8 +- .../BPASmartClient.JXJFoodSmallStation.csproj | 7 + .../Model/GVL_SmallStation.cs | 4 + .../Model/HK_PLC/PlcReadAddressDB3.cs | 15 + .../Model/ProcessControl.cs | 90 +- .../Model/RawMaterial/DevicePar.cs | 2 + .../Model/RawMaterial/RawMaterialStockBin.cs | 29 + .../View/ManualFlowView.xaml | 44 +- .../View/StockBinRawMaterialView.xaml | 138 +++ .../View/StockBinRawMaterialView.xaml.cs | 28 + .../ViewModel/ManualFlowViewModel.cs | 53 ++ .../ViewModel/StockBinRawMaterialViewModel.cs | 55 ++ .../BPASmartClient.JakaRobot.csproj | 1 + BPASmartClient.JakaRobot/JaKaHelper.cs | 69 +- .../BPASmartClient.MilkTeaCube.csproj | 14 + .../MilkTeaCubeMachine.cs | 90 ++ .../BPASmartClient.MilkTeaCubeHelper.csproj | 9 + BPASmartClient.MilkTeaCubeHelper/Class1.cs | 8 + .../奶茶味魔方/MilkTeaCubeEvent.cs | 13 + .../电夹爪/GripperEvent.cs | 10 + .../电夹爪/WriteGripper.cs | 14 + .../节卡机器人/JakaModel.cs | 107 ++- BPASmartClient.MorkBF/Control_MorkBF.cs | 433 +++++---- BPASmartClient.MorkBF/GVL_MorkBF.cs | 8 +- BPASmartClient.MorkS3/Alarm.cs | 204 ++++ .../BPASmartClient.MorkS3.csproj | 28 + BPASmartClient.MorkS3/Control_Morks.cs | 891 ++++++++++++++++++ BPASmartClient.MorkS3/DataServer.cs | 52 + BPASmartClient.MorkS3/GVL_MORKS.cs | 376 ++++++++ .../Model/Global.cs | 6 +- BPASmartClient.MorkS3/Model/MorksPar.cs | 16 + BPASmartClient.MorkS3/Model/ParSet.cs | 29 + BPASmartClient.MorkS3/Model/WritePar.cs | 14 + BPASmartClient.MorkS3/OrderLocInfo.cs | 23 + BPASmartClient.MorkS3/View/Debug.xaml | 117 +++ BPASmartClient.MorkS3/View/Debug.xaml.cs | 30 + BPASmartClient.MorkS3/View/Monitor.xaml | 242 +++++ BPASmartClient.MorkS3/View/Monitor.xaml.cs | 28 + BPASmartClient.MorkS3/View/ParSet.xaml | 130 +++ BPASmartClient.MorkS3/View/ParSet.xaml.cs | 28 + .../ViewModel/DebugViewModel.cs | 79 ++ .../ViewModel/MonitorViewModel.cs | 25 + .../ViewModel/ParSetViewModel.cs | 49 + BPASmartClient.MorkS3/VoiceAPI.cs | 42 + .../BPASmartClient.MorkT_BarCounter.csproj | 5 + .../Control_MorkT_BarCounter.cs | 862 ++++++----------- BPASmartClient.MorkT_BarCounter/GVL_MorkT.cs | 26 +- .../PolymerBatching.cs | 25 +- .../View/DebugView.xaml | 506 ++-------- .../View/TestView.xaml | 439 +++++++++ .../View/TestView.xaml.cs | 37 + .../ViewModel/DebugViewModel.cs | 404 ++------ .../ViewModel/TestViewModel.cs | 386 ++++++++ .../Control_MorkT_Container.cs | 2 +- .../Control_MORKJC.cs | 16 +- .../BPASmartClient.RobotGripper.csproj | 15 + .../RobotGripperMachine.cs | 50 + .../ScreenSplitMealsControl1ViewModel.cs | 2 +- .../ScreenALLControlViewModel.cs | 1 + .../RobotGripperHelper.cs | 77 ++ DosingSystem/App.xaml.cs | 4 +- DosingSystem/Model/DeviceInquire.cs | 17 +- .../Model/par/{LocaPar.cs => LocalRecipe.cs} | 2 +- DosingSystem/View/NewRecipeView.xaml.cs | 2 +- DosingSystem/View/RecipeSettingsView.xaml.cs | 2 +- .../ViewModel/ChangeDeviceNameViewModel.cs | 6 +- DosingSystem/ViewModel/NewRecipeViewModel.cs | 24 +- .../ViewModel/RecipeControlViewModel.cs | 12 +- .../ViewModel/RecipeSettingsViewModel.cs | 12 +- SmartClient.sln | 71 +- 84 files changed, 5536 insertions(+), 1785 deletions(-) create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialStockBin.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml create mode 100644 BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/ViewModel/StockBinRawMaterialViewModel.cs create mode 100644 BPASmartClient.MilkTeaCube/BPASmartClient.MilkTeaCube.csproj create mode 100644 BPASmartClient.MilkTeaCube/MilkTeaCubeMachine.cs create mode 100644 BPASmartClient.MilkTeaCubeHelper/BPASmartClient.MilkTeaCubeHelper.csproj create mode 100644 BPASmartClient.MilkTeaCubeHelper/Class1.cs create mode 100644 BPASmartClient.Model/奶茶味魔方/MilkTeaCubeEvent.cs create mode 100644 BPASmartClient.Model/电夹爪/GripperEvent.cs create mode 100644 BPASmartClient.Model/电夹爪/WriteGripper.cs create mode 100644 BPASmartClient.MorkS3/Alarm.cs create mode 100644 BPASmartClient.MorkS3/BPASmartClient.MorkS3.csproj create mode 100644 BPASmartClient.MorkS3/Control_Morks.cs create mode 100644 BPASmartClient.MorkS3/DataServer.cs create mode 100644 BPASmartClient.MorkS3/GVL_MORKS.cs rename BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs => BPASmartClient.MorkS3/Model/Global.cs (52%) create mode 100644 BPASmartClient.MorkS3/Model/MorksPar.cs create mode 100644 BPASmartClient.MorkS3/Model/ParSet.cs create mode 100644 BPASmartClient.MorkS3/Model/WritePar.cs create mode 100644 BPASmartClient.MorkS3/OrderLocInfo.cs create mode 100644 BPASmartClient.MorkS3/View/Debug.xaml create mode 100644 BPASmartClient.MorkS3/View/Debug.xaml.cs create mode 100644 BPASmartClient.MorkS3/View/Monitor.xaml create mode 100644 BPASmartClient.MorkS3/View/Monitor.xaml.cs create mode 100644 BPASmartClient.MorkS3/View/ParSet.xaml create mode 100644 BPASmartClient.MorkS3/View/ParSet.xaml.cs create mode 100644 BPASmartClient.MorkS3/ViewModel/DebugViewModel.cs create mode 100644 BPASmartClient.MorkS3/ViewModel/MonitorViewModel.cs create mode 100644 BPASmartClient.MorkS3/ViewModel/ParSetViewModel.cs create mode 100644 BPASmartClient.MorkS3/VoiceAPI.cs create mode 100644 BPASmartClient.MorkT_BarCounter/View/TestView.xaml create mode 100644 BPASmartClient.MorkT_BarCounter/View/TestView.xaml.cs create mode 100644 BPASmartClient.MorkT_BarCounter/ViewModel/TestViewModel.cs create mode 100644 BPASmartClient.RobotGripper/BPASmartClient.RobotGripper.csproj create mode 100644 BPASmartClient.RobotGripper/RobotGripperMachine.cs create mode 100644 BPASmartClient.SerialPort/RobotGripperHelper.cs rename DosingSystem/Model/par/{LocaPar.cs => LocalRecipe.cs} (93%) diff --git a/BPASmartClient.JAKA/JakaMachine.cs b/BPASmartClient.JAKA/JakaMachine.cs index a93c39cb..e45b477d 100644 --- a/BPASmartClient.JAKA/JakaMachine.cs +++ b/BPASmartClient.JAKA/JakaMachine.cs @@ -17,18 +17,22 @@ namespace BPASmartClient.JAKA ThreadManage.GetInstance().StartLong(new Action(() => { IsConnected = jaKaHelper.IsConnected; - if (!IsConnected) IsWork = false; - while (IsConnected) + if (!IsConnected) + { + IsWork = false; + } + if (IsConnected) { IsWork = true; if (status != null) { - SetStatus("GetProgramStatus", (int)jaKaHelper.GetProgramStatus()); - SetStatus("Get_RobotAO1", jaKaHelper.Get_RobotAO1()); - SetStatus("Get_RobotDI0", jaKaHelper.Get_RobotDI(0)); - SetStatus("Get_RobotDI1", jaKaHelper.Get_RobotDI(1)); - SetStatus("Get_RobotDI2", jaKaHelper.Get_RobotDI(2)); - SetStatus("Get_RobotDI3", jaKaHelper.Get_RobotDI(3)); + SetStatus("Get_JakaRobotProgramStatus", (int)jaKaHelper.GetProgramStatus()); + SetStatus("Get_JakaRobotAO1", Convert.ToInt32(jaKaHelper.Get_RobotAO1())); + SetStatus("Get_JakaRobotDI0", jaKaHelper.Get_RobotDI(0)); + SetStatus("Get_JakaRobotDI1", jaKaHelper.Get_RobotDI(1)); + SetStatus("Get_JakaRobotDI2", jaKaHelper.Get_RobotDI(2)); + SetStatus("Get_JakaRobotDI3", jaKaHelper.Get_RobotDI(3)); + SetStatus("Get_JakaRobotDI5", jaKaHelper.Get_RobotDI(5)); } Thread.Sleep(500); } diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 6e2d1570..476ffcf6 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -47,6 +47,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// 是否处于手动下发配方 /// public static bool IsUseLocalRecipe { get; set; } = false; + + public static bool BarrelWasherSign { get; set; } /// /// 订单请求 /// diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index 74f34914..aa60f2d7 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -64,6 +64,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC { HK_PLC_S7.Write("DB99.DBW2.0",Convert.ToInt16(recipe.TrayCode)); HK_PLC_S7.Write("DB99.DBW4.0", Convert.ToInt16(recipe.TrayCode)); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{recipe.RecipeCode},托盘编号DB99.DBW2.0:{recipe.TrayCode},下发完成"); for (int barrel = 1; barrel < 6; barrel++) { if (barrel != 3)//桶的编号不为3 只为1,2,4,5号桶 diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index 843db9cb..52566728 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -261,28 +261,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model { foreach (var data in LocalRecipes) { - if (LocalRecipeQueue1.Count == 0 && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode)) + if (LocalRecipeQueue1.Count == 0 && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1) { if (!(LocalRecipeQueue1.Contains(data.RecipeCode))) { LocalRecipeQueue1.Enqueue(data.RecipeCode); } } - else if (LocalRecipeQueue2.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode)) + else if (LocalRecipeQueue2.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe2) { if (!(LocalRecipeQueue2.Contains(data.RecipeCode))) { LocalRecipeQueue2.Enqueue(data.RecipeCode); } } - else if (LocalRecipeQueue3.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode)) + else if (LocalRecipeQueue3.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3) { if (!(LocalRecipeQueue3.Contains(data.RecipeCode))) { LocalRecipeQueue3.Enqueue(data.RecipeCode); } } - else if (LocalRecipeQueue4.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode)) + else if (LocalRecipeQueue4.Count == 0 && !LocalRecipeQueue1.Contains(data.RecipeCode) && !LocalRecipeQueue2.Contains(data.RecipeCode) && !LocalRecipeQueue3.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe4) { if (!(LocalRecipeQueue4.Contains(data.RecipeCode))) { @@ -297,6 +297,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model LocalRecipeQueue2.Clear(); LocalRecipeQueue3.Clear(); LocalRecipeQueue4.Clear(); + GVL_BigStation.BarrelWasherSign = false; GVL_BigStation.Recipe1DosingStatus = 0; GVL_BigStation.Recipe2DosingStatus = 0; GVL_BigStation.Recipe3DosingStatus = 0; @@ -340,20 +341,43 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发 { - HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); - GVL_BigStation.Recipe1DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + if (!GVL_BigStation.BarrelWasherSign) + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); + GVL_BigStation.Recipe1DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + else + { + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); + GVL_BigStation.Recipe1DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } } if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1) { - GVL_BigStation.Recipe1DosingStatus = 2; HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", false); StockBinParReset(); + GVL_BigStation.Recipe1DosingStatus = 2; MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) { + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); + } GVL_BigStation.Recipe1DosingStatus = 3; switch (trayCode) { @@ -480,10 +504,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 &&Inplace)//配方2是否允许下发配发 { - HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); - GVL_BigStation.Recipe2DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + if (!GVL_BigStation.BarrelWasherSign) + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); + GVL_BigStation.Recipe2DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } + } + else + { + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); + GVL_BigStation.Recipe2DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } } if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1) { @@ -494,6 +535,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) { + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); + } switch (trayCode) { case 1: @@ -620,10 +667,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0 && Inplace)//配方3是否允许下发配发 { - HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); - GVL_BigStation.Recipe3DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + if (!GVL_BigStation.BarrelWasherSign) + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); + GVL_BigStation.Recipe3DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } + } + else + { + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); + GVL_BigStation.Recipe3DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } } if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1) { @@ -634,6 +698,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) { + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); + } switch (trayCode) { case 1: @@ -761,10 +831,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0 && Inplace)//配方4是否允许下发配发 { - HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); - HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); - GVL_BigStation.Recipe4DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + if (!GVL_BigStation.BarrelWasherSign) + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); + GVL_BigStation.Recipe4DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } + } + else + { + HKDevice.StockBinPar(LocalRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); + GVL_BigStation.Recipe4DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + } } if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1) { @@ -775,6 +862,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) { + if (LocalRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶复位 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶信号复位"); + } switch (trayCode) { case 1: @@ -875,7 +968,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model { foreach (var data in SiemensRecipes) { - if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode)) + if (SiemensRecipeQueue1.Count == 0 && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe1) { if (!(SiemensRecipeQueue1.Contains(data.RecipeCode))) { @@ -910,7 +1003,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - else if (SiemensRecipeQueue2.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode)) + else if (SiemensRecipeQueue2.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe2) { if (!(SiemensRecipeQueue2.Contains(data.RecipeCode))) { @@ -945,7 +1038,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode)) + else if (SiemensRecipeQueue3.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue4.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe3) { if (!(SiemensRecipeQueue3.Contains(data.RecipeCode))) { @@ -980,7 +1073,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model } } } - else if (SiemensRecipeQueue4.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode)) + else if (SiemensRecipeQueue4.Count == 0 && !SiemensRecipeQueue1.Contains(data.RecipeCode) && !SiemensRecipeQueue2.Contains(data.RecipeCode) && !SiemensRecipeQueue3.Contains(data.RecipeCode) && HKDevice.PlcRead.IsAllowIssueRecipe4) { if (!(SiemensRecipeQueue4.Contains(data.RecipeCode))) { @@ -1023,6 +1116,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model SiemensRecipeQueue2.Clear(); SiemensRecipeQueue3.Clear(); SiemensRecipeQueue4.Clear(); + GVL_BigStation.BarrelWasherSign = false; GVL_BigStation.Recipe1DosingStatus = 0; GVL_BigStation.Recipe2DosingStatus = 0; GVL_BigStation.Recipe3DosingStatus = 0; @@ -1057,14 +1151,16 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); } GVL_BigStation.Recipe1DosingStatus = 0; - SiemensRecipeQueue1.TryDequeue(out code); - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX320.2", false); SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false ) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + SiemensRecipeQueue1.TryDequeue(out code); + MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); + } } if (SiemensRecipeQueue2.Contains(code)) { - GVL_BigStation.Recipe2DosingStatus = 0; App.Current.Dispatcher.Invoke(() => { Json.Data.Recipes.RemoveAt(index); @@ -1080,10 +1176,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); } GVL_BigStation.Recipe2DosingStatus = 0; - SiemensRecipeQueue2.TryDequeue(out code); - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX320.2", false); SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - MessageNotify.GetInstance.ShowRunLog($"队列2,西门子取消订单完成,订单号:{code}"); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + SiemensRecipeQueue2.TryDequeue(out code); + MessageNotify.GetInstance.ShowRunLog($"队列2,西门子取消订单完成,订单号:{code}"); + } } if (SiemensRecipeQueue3.Contains(code)) { @@ -1102,11 +1201,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model { MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); } - GVL_BigStation.Recipe3DosingStatus = 0; - SiemensRecipeQueue3.TryDequeue(out code); - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX320.2", false); + GVL_BigStation.Recipe3DosingStatus = 0; SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - MessageNotify.GetInstance.ShowRunLog($"队列3,西门子取消订单完成,订单号:{code}"); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + SiemensRecipeQueue3.TryDequeue(out code); + MessageNotify.GetInstance.ShowRunLog($"队列3,西门子取消订单完成,订单号:{code}"); + } } if (SiemensRecipeQueue4.Contains(code)) { @@ -1126,10 +1228,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); } GVL_BigStation.Recipe4DosingStatus = 0; - SiemensRecipeQueue4.TryDequeue(out code); - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX320.2", false); SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); - MessageNotify.GetInstance.ShowRunLog($"队列4,西门子取消订单完成,订单号:{code}"); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + SiemensRecipeQueue4.TryDequeue(out code); + MessageNotify.GetInstance.ShowRunLog($"队列4,西门子取消订单完成,订单号:{code}"); + } } GVL_BigStation.Order_Cancel = false; GVL_BigStation.Order_CancelRecipeCode = ""; @@ -1149,19 +1254,24 @@ namespace BPASmartClient.JXJFoodBigStation.Model { MessageNotify.GetInstance.ShowRunLog($"订单取消异常,订单号:{GVL_BigStation.Order_CancelRecipeCode}"); } - GVL_BigStation.Order_Cancel = false; GVL_BigStation.Order_CancelRecipeCode = ""; - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX320.2", false); SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + } } } else { GVL_BigStation.Order_Cancel = false; GVL_BigStation.Order_CancelRecipeCode = ""; - SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX320.2", false); SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX320.2") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", false); + } MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{GVL_BigStation.Order_CancelRecipeCode}"); } } @@ -1180,7 +1290,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model switch (trayCode) { case 1: - Inplace = HKDevice.PlcRead.Tray1InPlace; + Inplace = HKDevice.PlcRead.Tray1InPlace;//上位机给plc发送AGV到位信号,plc固定托盘后反馈托盘是否到位 break; case 2: Inplace = HKDevice.PlcRead.Tray2InPlace; @@ -1199,16 +1309,31 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发 { - GVL_BigStation.DosingRecipe1Time = DateTime.Now; - HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); - if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + if (!GVL_BigStation.BarrelWasherSign) + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + GVL_BigStation.DosingRecipe1Time = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); + GVL_BigStation.Recipe1DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + else + { + GVL_BigStation.DosingRecipe1Time = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); + GVL_BigStation.Recipe1DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } - HKDevice.HK_PLC_S7.Write("DB99.DBX0.3", true); - GVL_BigStation.Recipe1DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } if (HKDevice.PlcRead.ReceiveFinishRecipe1 && GVL_BigStation.Recipe1DosingStatus == 1) { @@ -1219,6 +1344,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } GVL_BigStation.Recipe1DosingFinish = true; GVL_BigStation.Recipe1DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); @@ -1350,28 +1481,47 @@ namespace BPASmartClient.JXJFoodBigStation.Model default: break; } - if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 && Inplace)//配方2是否允许下发配发 + if (HKDevice.PlcRead.IsAllowIssueRecipe2 && GVL_BigStation.Recipe2DosingStatus == 0 && Inplace )//配方2是否允许下发配发 { - GVL_BigStation.DosingRecipe2Time = DateTime.Now; - HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + if (!GVL_BigStation.BarrelWasherSign) + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + + GVL_BigStation.DosingRecipe2Time = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); + GVL_BigStation.Recipe2DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + else + { + GVL_BigStation.DosingRecipe2Time = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); + GVL_BigStation.Recipe2DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } - HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); - GVL_BigStation.Recipe2DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe2 && GVL_BigStation.Recipe2DosingStatus == 1) { - GVL_BigStation.Recipe2DosingStatus = 2; HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", false); StockBinParReset(); + GVL_BigStation.Recipe2DosingStatus = 2; MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } GVL_BigStation.Recipe2DosingFinish = true; GVL_BigStation.Recipe2DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); @@ -1505,26 +1655,44 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe3 && GVL_BigStation.Recipe3DosingStatus == 0 && Inplace)//配方3是否允许下发配发 { - GVL_BigStation.DosingRecipe3Time = DateTime.Now; - HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据 + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + GVL_BigStation.DosingRecipe3Time = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); + GVL_BigStation.Recipe3DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + else + { + GVL_BigStation.DosingRecipe3Time = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); + GVL_BigStation.Recipe3DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } - HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); - GVL_BigStation.Recipe3DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe3 && GVL_BigStation.Recipe3DosingStatus == 1) { - GVL_BigStation.Recipe3DosingStatus = 2; HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", false); StockBinParReset(); + GVL_BigStation.Recipe3DosingStatus = 2; MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } GVL_BigStation.Recipe3DosingFinish = true; GVL_BigStation.Recipe3DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); @@ -1658,16 +1826,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe4 && GVL_BigStation.Recipe4DosingStatus == 0 && Inplace)//配方4是否允许下发配发 { - GVL_BigStation.DosingRecipe4Time = DateTime.Now; - HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); if (SiemensRecipes.ElementAt(index).IsWashingBarrel) { - HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + if (!GVL_BigStation.BarrelWasherSign)//其他配方在洗桶时,等待其他配方洗完,在发送数据 + { + GVL_BigStation.BarrelWasherSign = true; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", true);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},订单类型为洗桶"); + GVL_BigStation.DosingRecipe4Time = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); + GVL_BigStation.Recipe4DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); + } + } + else + { + GVL_BigStation.DosingRecipe4Time = DateTime.Now; + HKDevice.StockBinPar(SiemensRecipes.ElementAt(index)); + HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); + GVL_BigStation.Recipe4DosingStatus = 1; + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } - HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); - GVL_BigStation.Recipe4DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1) { @@ -1678,6 +1858,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) { + if (SiemensRecipes.ElementAt(index).IsWashingBarrel) + { + GVL_BigStation.BarrelWasherSign = false; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.1", false);//洗桶 + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},洗桶复位"); + } GVL_BigStation.Recipe1DosingFinish = true; GVL_BigStation.Recipe4DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); @@ -1803,8 +1989,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0005", RawMaterialLocation = 3 });//榨菜丁 RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0018", RawMaterialLocation = 4 });//炸豌豆 RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0019", RawMaterialLocation = 5 });//高水分糍粑海椒 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0033", RawMaterialLocation = 6 });//辣豆瓣*/ - /*RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0030", RawMaterialLocation = 11 });//备用生姜 + RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0033", RawMaterialLocation = 6 });//辣豆瓣 + RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0030", RawMaterialLocation = 11 });//备用生姜 RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0012", RawMaterialLocation = 12 });//豆豉细粒*/ foreach (var material in RawMaterialsInfo) { diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs index 873e398e..dc05bc4f 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs @@ -28,8 +28,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } private int _mTrayCode; + /// + /// 配方类型是否为洗桶 + /// + public string OrderType { get { return _mOrderType; } set { _mOrderType = value; OnPropertyChanged(); } } + private string _mOrderType; + + /// + /// 配方类型是否为洗桶 + /// public bool IsWashingBarrel { get { return _mIsWashingBarrel; } set { _mIsWashingBarrel = value; OnPropertyChanged(); } } private bool _mIsWashingBarrel; + /// /// 原料数据 /// diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml index 63e35bc1..0d22968d 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeInfosView.xaml @@ -289,8 +289,8 @@ + - diff --git a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml index ef78e4b8..1c3603c8 100644 --- a/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/RecipeReceiveView.xaml @@ -226,36 +226,116 @@ Margin="5"> - - + + + + + - + + + + + + + + + Text="配方编号:" /> - + + + + + + + + + + - - + + + + + + + + + + Grid.RowSpan="8" + Grid.ColumnSpan="2" + Source="/BPASmartClient.CustomResource;component/Image/配方背景/竖背景框.png" + Stretch="Fill" /> + Grid.Row="0" + Grid.ColumnSpan="2" + FontSize="14" + Margin="5,0,0,0" + HorizontalAlignment="Center" + VerticalAlignment="Center" + Foreground="#FF2AB2E7" + Text="配方信息" /> + Grid.Row="1" + Grid.Column="0" + Margin="2,5,0,0" + HorizontalAlignment="Center" + VerticalAlignment="Center" + FontSize="12" + Foreground="#FF2AB2E7" + Text="配方名称:" /> - + + + + + + + + + + + + + + - - + + { Json.Data.Recipes.Clear(); + GVL_BigStation.SiemensSendRecipeStatus = 0; }); ThreadManage.GetInstance().StartLong(new Action(() => { diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs index 34da58d1..9c1ecc13 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/RecipeInfosViewModel.cs @@ -11,6 +11,8 @@ using BPASmartClient.JXJFoodBigStation.Model; using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.JXJFoodBigStation.Model.Siemens; using System.Windows.Forms; +using BPASmartClient.CustomResource.UserControls; +using BPASmartClient.CustomResource.UserControls.MessageShow; namespace BPASmartClient.JXJFoodBigStation.ViewModel { @@ -29,7 +31,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel RecipeName = rm.RecipeName; RecipeCode = rm.RecipeCode; TrayCode = rm.TrayCode; - + IsWashingBarrel = rm.IsWashingBarrel; foreach (var item in rm.RawMaterial) { item.RawMaterialCount = (short)Array.FindIndex(ProcessControl.GetInstance.RawMaterialsInfo.ToArray(), p => p.RawMaterialName == item.RawMaterialName); @@ -65,8 +67,18 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel var res = Json.Data.Recipes.FirstOrDefault(p => p.RecipeCode == recipeCode); if (res == null) { - Json.Data.Recipes.Add(new RecipeData { RecipeCode = recipeCode, RawMaterial= RawMaterialsInfo,RecipeName=RecipeName,TrayCode=TrayCode}); + if (IsWashingBarrel) + { + Json.Data.Recipes.Add(new RecipeData { RecipeCode = recipeCode,RecipeName = RecipeName, TrayCode = TrayCode, IsWashingBarrel = IsWashingBarrel }); + if (RawMaterialsInfo.Count > 0) + NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, App.MainWindow, "提示", $"订单类型为洗桶,不保存原料信息"); + } + else + { + Json.Data.Recipes.Add(new RecipeData { RecipeCode = recipeCode, RawMaterial = RawMaterialsInfo, RecipeName = RecipeName, TrayCode = TrayCode, IsWashingBarrel = IsWashingBarrel }); + } Json.Save(); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"配方保存完成"); } else { @@ -88,15 +100,16 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel } bom.RecipeName = RecipeName; bom.TrayCode = TrayCode; + bom.IsWashingBarrel = IsWashingBarrel; + if (IsWashingBarrel) + { + bom.RawMaterial.Clear(); + } Json.Save(); ActionManage.GetInstance.Send("CloseRecipeInfosView"); } }); - ClearRawMaterial = new RelayCommand(() => { - RawMaterialsInfo.Clear(); - }); - RemoveRecipe = new RelayCommand((index) => { var res = RawMaterialsInfo.FirstOrDefault(p => p.RawMaterialCount == index); if (res != null) @@ -114,16 +127,16 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public int SelectIndex { get { return _mSelectIndex; } set { _mSelectIndex = value; OnPropertyChanged(); } } private int _mSelectIndex; - + public bool IsWashingBarrel { get { return _mIsWashingBarrel; } set { _mIsWashingBarrel = value; OnPropertyChanged(); } } + private bool _mIsWashingBarrel; + public RelayCommand ReturnPage { get; set; } public RelayCommand AddRecipe { get; set; } public RelayCommand Comfirm { get; set; } - public RelayCommand ClearRawMaterial { get; set; } - public RelayCommand RemoveRecipe { get; set; } public ObservableCollection RawMaterialsInfo { get; set; } = new ObservableCollection() ; diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/SiemensRecipeSendDownViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/SiemensRecipeSendDownViewModel.cs index bb7da1f3..fd2f38f0 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/SiemensRecipeSendDownViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/SiemensRecipeSendDownViewModel.cs @@ -17,7 +17,6 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public ObservableCollection Recipes { get; set; } = Json.Data.Recipes; public SiemensRecipeSendDownViewModel() { - } } } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs index ba4fdc95..f5ade366 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs @@ -34,6 +34,10 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel SaveRawMaterialPara = new RelayCommand(() => { Json.Save(); + foreach (var item in Json.Data.RawMaterial) + { + MessageNotify.GetInstance.ShowUserLog($"料仓位置:"+ item.RawMaterialLocation+ ",物料编码:" + item.RawMaterialName); + } MessageNotify.GetInstance.ShowUserLog($"原料与料仓对应关系保存成功"); NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功"); }); diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index 1015cbd3..191917d2 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -138,7 +138,13 @@ namespace BPASmartClient.JXJFoodSmallStation AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.SystemParView" }); - + ParSet.Add(new SubMenumodel() + { + SubMenuName = "原料与料仓对应设置", + SubMenuPermission = new Permission[] { Permission.管理员 }, + AssemblyName = "BPASmartClient.JXJFoodSmallStation", + ToggleWindowPath = "View.StockBinRawMaterialView" + }); MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj index 113ea061..17229774 100644 --- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj +++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj @@ -32,6 +32,9 @@ Code + + Code + @@ -57,6 +60,10 @@ $(DefaultXamlRuntime) Designer + + $(DefaultXamlRuntime) + Designer + $(DefaultXamlRuntime) Designer diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index 5625b98f..6e50873a 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -142,6 +142,10 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// 系统运行状态 /// public static bool SystemRunStatus { get; set; } = false; + /// + /// 系统运行状态 + /// + public static int Time { get; set; } = 1000; #endregion } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs new file mode 100644 index 00000000..ec42c683 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcReadAddressDB3.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC +{ + public class PlcReadAddressDB3 + { + public bool[] VarBool { get; set; } =new bool[17]; + public Single[] BarrelPos { get; set; } = new Single[8]; + public bool[] IsAllowDosing { get; set; } = new bool[8]; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index ae9b499f..bf45b196 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -1,6 +1,7 @@ using BPASmartClient.CustomResource.Pages.Model; using BPASmartClient.Helper; using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; +using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial; using BPASmartClient.JXJFoodSmallStation.Model.Siemens; using BPASmartClient.JXJFoodSmallStation.Model.WindSend; using BPASmartClient.Modbus; @@ -30,6 +31,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// 原料的名称和料仓的位置对应 /// public Dictionary RawMaterialsNamePos = new Dictionary(); + public ObservableCollection RawMaterialsInfo => Json.Data.rawMaterialStockBin; /// /// 配方队列 /// @@ -51,7 +53,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public void Init() { testData(); - for (int i = 0; i < 16; i++) + /*for (int i = 0; i < 16; i++) { if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null) { @@ -60,7 +62,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model RawMaterialsNamePos.Add(DeviceInquire.GetInstance.GetDevice(i).DeviceName, (short)DeviceInquire.GetInstance.GetDevice(i).deviceStatus.DeviceNum); } } - } + }*/ ActionManage.GetInstance.CancelRegister("SiemensRecipeRecive"); ActionManage.GetInstance.Register(new Action((res) => { @@ -88,6 +90,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { + MessageNotify.GetInstance.ShowRunLog($"原料:{recipe.Material[i].Material_Name},不在配料表"); //MessageNotify.GetInstance.AlarmLog("配方名称与本地不符合"); } } @@ -170,6 +173,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { Json.Data.Recipes.Clear(); GVL_SmallStation.SiemensSendRecipeStatus = 0; + MessageNotify.GetInstance.ShowRunLog("系统流程复位,等待西门子重新下发订单"); }), "BPASystemReset",true); @@ -347,7 +351,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model }), "西门子配发下发流程处理", true); ThreadManage.GetInstance().StartLong(new Action(() => { - if (!HKDevice.IsConnected) + if (HKDevice.IsConnected) { ManualOpen(); ManualClose(); @@ -380,6 +384,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1); if (index == 8) address = "DB5.DBX0.7"; HKDevice.HK_PLC_S7.Write(address, true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:true"); } } else if (o.ToString().Contains("阻挡气缸")) @@ -409,18 +414,22 @@ namespace BPASmartClient.JXJFoodSmallStation.Model else if (o.ToString().Contains("进料桶顶升气缸")) { HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", false);//默认顶升 + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:false"); } else if (o.ToString().Contains("出料桶顶升气缸1")) { HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:true"); } else if (o.ToString().Contains("出料桶顶升气缸2")) { HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:true"); } else if (o.ToString().Contains("出料桶顶升气缸3")) { HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:true"); } else if (o.ToString().Contains("托盘气缸1_1")) { @@ -455,6 +464,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1); if (index == 8) address = "DB5.DBX0.7"; HKDevice.HK_PLC_S7.Write(address, false); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:{address},值:false"); } } else if (o.ToString().Contains("阻挡气缸")) @@ -484,18 +494,22 @@ namespace BPASmartClient.JXJFoodSmallStation.Model else if (o.ToString().Contains("进料桶顶升气缸")) { HKDevice.HK_PLC_S7.Write("DB5.DBX3.6", true); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.6,值:true"); } else if (o.ToString().Contains("出料桶顶升气缸1")) { HKDevice.HK_PLC_S7.Write("DB5.DBX3.7", false); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX3.7,值:false"); } else if (o.ToString().Contains("出料桶顶升气缸2")) { HKDevice.HK_PLC_S7.Write("DB5.DBX4.0", false); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.0,值:false"); } else if (o.ToString().Contains("出料桶顶升气缸3")) { HKDevice.HK_PLC_S7.Write("DB5.DBX4.1", false); + MessageNotify.GetInstance.ShowUserLog($"手动操作气缸,地址:DB5.DBX4.1,值:false"); } else if (o.ToString().Contains("托盘气缸1_1")) { @@ -524,11 +538,11 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (HKDevice.IsConnected) { GVL_SmallStation.Station1HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX0.7");//工站1 有货架 - GVL_SmallStation.Station2HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX1.0");//工站1 有货架 - if (RTrig.GetInstance("WindSendDosingCompleToHKPLC").Start(GVL_SmallStation.WindSendDosingComple)) + GVL_SmallStation.Station2HaveTray = HKDevice.HK_PLC_S7.Read("DB3.DBX1.0");//工站2 有货架 + if (GVL_SmallStation.WindSendDosingComple) { - GVL_SmallStation.WindSendDosingComple = false; HKDevice.HK_PLC_S7.Write("DB4.DBX1.7", true); + GVL_SmallStation.WindSendDosingComple = false; MessageNotify.GetInstance.ShowRunLog("风送配料完成信号,发给产线plc信号"); } if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.1")) @@ -787,10 +801,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); } GVL_SmallStation.GetInstance.RecipeStatusID = 0; - RecipeQueueTray1.TryDequeue(out code); - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX440.1", false); SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX440.1") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + RecipeQueueTray1.TryDequeue(out code); + MessageNotify.GetInstance.ShowRunLog($"队列1,西门子取消订单完成,订单号:{code}"); + } } else if (RecipeQueueTray2.Contains(code)) { @@ -817,10 +834,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); } GVL_SmallStation.GetInstance.RecipeStatusID = 0; - RecipeQueueTray2.TryDequeue(out code); - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX440.1", false); SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); - MessageNotify.GetInstance.ShowRunLog($"队列2,西门子取消订单完成,订单号:{code}"); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2301.DBX440.1") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + RecipeQueueTray2.TryDequeue(out code); + MessageNotify.GetInstance.ShowRunLog($"队列2,西门子取消订单完成,订单号:{code}"); + } } GVL_SmallStation.Order_Cancel = false; GVL_SmallStation.Order_CancelRecipeCode = ""; @@ -843,16 +863,22 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.Order_Cancel = false; GVL_SmallStation.Order_CancelRecipeCode = ""; - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX440.1", false); - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + } } } else { GVL_SmallStation.Order_Cancel = false; GVL_SmallStation.Order_CancelRecipeCode = ""; - SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX440.1", false); SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", true); + while (SiemensDevice.Siemens_PLC_S7.Read("DB2201.DBX440.1") == false) + { + SiemensDevice.Siemens_PLC_S7.Write("DB2201.DBX450.1", false); + } MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{code}"); } } @@ -1003,6 +1029,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model int i = GVL_SmallStation.GetInstance.DosingTray1Loc; if (DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3) { + Thread.Sleep(GVL_SmallStation.Time); MessageNotify.GetInstance.ShowRunLog($"柔性味魔方,托盘1,配方:{recipeName},{i}号仓,配料完成"); 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.NowWeightFeedback; @@ -1186,6 +1213,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } if (GVL_SmallStation.GetInstance.DosingTray2 == true && GVL_SmallStation.GetInstance.DosingTray1 == false && GVL_SmallStation.GetInstance.DosingTray2Loc > 0 && GVL_SmallStation.GetInstance.DosingTray2Loc < 16) { + Thread.Sleep(GVL_SmallStation.Time); int i = GVL_SmallStation.GetInstance.DosingTray2Loc; if (RTrig.GetInstance("Tray2StatusDevice" + i).Start(DeviceInquire.GetInstance.GetDevice(i).deviceStatus.RunStatus == 3)) { @@ -1274,19 +1302,29 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } } - private void testData() + public void testData() { - RawMaterialsNamePos.Add("0051", 3); - RawMaterialsNamePos.Add("0052", 4); - RawMaterialsNamePos.Add("0054", 5); - RawMaterialsNamePos.Add("0057", 6); - RawMaterialsNamePos.Add("0050", 8); - RawMaterialsNamePos.Add("0048", 13); - - RawMaterialsNamePos.Add("0036", 13);//I+G - RawMaterialsNamePos.Add("0037", 13);//味精 - RawMaterialsNamePos.Add("0038", 13);//白糖 + //RawMaterialsNamePos.Add("0051", 3); + //RawMaterialsNamePos.Add("0052", 4); + //RawMaterialsNamePos.Add("0054", 5); + //RawMaterialsNamePos.Add("0057", 6); + //RawMaterialsNamePos.Add("0050", 8); + //RawMaterialsNamePos.Add("0048", 13); + //RawMaterialsNamePos.Add("0036", 13);//I+G + //RawMaterialsNamePos.Add("0037", 13);//味精 + //RawMaterialsNamePos.Add("0038", 13);//白糖 + RawMaterialsNamePos.Clear(); + foreach (var material in RawMaterialsInfo) + { + if (!string.IsNullOrEmpty(material.RawMaterialName)) + { + if (!RawMaterialsNamePos.ContainsKey(material.RawMaterialName)) + { + RawMaterialsNamePos.Add(material.RawMaterialName, (short)material.RawMaterialLocation); + } + } + } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs index 3e686249..bf29ce35 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DevicePar.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Microsoft.Toolkit.Mvvm.ComponentModel; using System.Collections.ObjectModel; using BPASmartClient.JXJFoodSmallStation.Model.Par; +using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial; namespace BPASmartClient.JXJFoodSmallStation.Model { @@ -14,5 +15,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public ObservableCollection deviceParModels { get; set; } = new ObservableCollection(); public ConnectParMode deviceConnectPar { get { return _mdeviceConnectPar; } set { _mdeviceConnectPar = value; OnPropertyChanged(); } } private ConnectParMode _mdeviceConnectPar = new ConnectParMode(); + public ObservableCollection rawMaterialStockBin { get; set; } = new ObservableCollection(); } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialStockBin.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialStockBin.cs new file mode 100644 index 00000000..1cd90b17 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/RawMaterialStockBin.cs @@ -0,0 +1,29 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model.RawMaterial +{ + public class RawMaterialStockBin : ObservableObject + { + + public short RawMaterialCount { get { return _mRawMaterialCount; } set { _mRawMaterialCount = value; OnPropertyChanged(); } } + private short _mRawMaterialCount; + + /// + /// 原料名称 + /// + public string RawMaterialName { get { return _mRawMaterialName; } set { _mRawMaterialName = value; OnPropertyChanged(); } } + private string _mRawMaterialName; + + + /// + /// 原料对应料仓的位置 + /// + public int RawMaterialLocation { get { return _mRawMaterialLocation; } set { _mRawMaterialLocation = value; OnPropertyChanged(); } } + private int _mRawMaterialLocation; + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml b/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml index 16f0baa0..7c145c99 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/ManualFlowView.xaml @@ -94,7 +94,7 @@ Height="40" Margin="5,0,5,0" Command="{Binding SystemReset}" - Content="系统复位" + Content="PLC系统复位" FontSize="20" Panel.ZIndex="0" Style="{StaticResource ImageButtonStyle}"> @@ -112,10 +112,44 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml b/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml new file mode 100644 index 00000000..87c2680a --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml.cs b/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml.cs new file mode 100644 index 00000000..fe3e6909 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/View/StockBinRawMaterialView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BPASmartClient.JXJFoodSmallStation.View +{ + /// + /// HKPlcCommMonitor.xaml 的交互逻辑 + /// + public partial class StockBinRawMaterialView : UserControl + { + public StockBinRawMaterialView() + { + InitializeComponent(); + } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs index fa79e115..9322b444 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs @@ -16,6 +16,7 @@ using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; using System.Threading; using System.ComponentModel; using System.Runtime.CompilerServices; +using BPASmartClient.CustomResource.Pages.Model; namespace BPASmartClient.JXJFoodSmallStation.ViewModel { @@ -23,47 +24,93 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { public ManualFlowViewModel() { + time = GVL_SmallStation.Time; Test1Command = new RelayCommand(() => { GVL_SmallStation.AGV_PutTray1Finish = true; + MessageNotify.GetInstance.ShowUserLog("手动点击按钮,AGV送托盘完成"); }); Test2Command = new RelayCommand(() => { GVL_SmallStation.WindSendDosingComple = true; + MessageNotify.GetInstance.ShowUserLog("手动点击按钮,粉料仓配料完成"); }); Test3Command = new RelayCommand(() => { GVL_SmallStation.AGV_GetTray1Finish = true; + MessageNotify.GetInstance.ShowUserLog("手动点击按钮,AGV取托盘完成"); }); Test4Command = new RelayCommand(() => { GVL_SmallStation.CylinderReset = true; + MessageNotify.GetInstance.ShowUserLog("手动点击按钮,气缸收紧错位复位"); }); Test5Command = new RelayCommand(() => { GVL_SmallStation.WindSendAllowAGVPutGet = true; + MessageNotify.GetInstance.ShowUserLog("手动点击按钮,粉料仓提升到位"); }); Test6Command = new RelayCommand(() => { ActionManage.GetInstance.Send("AGVPutTrayFinish"); + MessageNotify.GetInstance.ShowUserLog("手动点击按钮,AGV放货架流程完成"); }); CLearRecipeInfo = new RelayCommand(() => { ActionManage.GetInstance.Send("CLearRecipeInfo"); + MessageNotify.GetInstance.ShowUserLog("手动点击按钮,配方清零"); }); SystemReset = new RelayCommand(() => { ActionManage.GetInstance.Send("ManualSystemReset"); + MessageNotify.GetInstance.ShowUserLog("手动点击按钮,PLC系统复位"); }); BPAResetCommand = new RelayCommand(() => { ActionManage.GetInstance.Send("BPASystemReset"); + MessageNotify.GetInstance.ShowUserLog("手动点击按钮,上位机初始化"); }); ThreadManage.GetInstance().StartLong(new Action(() => { Heartbeat = GVL_SmallStation.GetInstance.HeartBeatFromPlc; + switch (GVL_SmallStation.SiemensSendRecipeStatus) + { + case 0: + OrderStatus = "初始状态"; + break; + case 1: + OrderStatus = "向西门子请求配方"; + break; + case 2: + OrderStatus = "上位机接收到配方"; + break; + case 3: + OrderStatus = "西门子确认上位机接收到配方"; + break; + case 4: + OrderStatus = "上位机向西门子请求配料"; + break; + case 5: + OrderStatus = "西门子确认配料"; + break; + case 6: + OrderStatus = "上位机将配方进行配料"; + break; + case 7: + OrderStatus = "配料完成"; + break; + default: + OrderStatus = "无意义"; + break; + } Thread.Sleep(100); }), "流程手动设备状态读取",true); + TimeSet = new RelayCommand(() => + { + GVL_SmallStation.Time = time; + MessageNotify.GetInstance.ShowUserLog($"设置柔性味魔方复位时间:{time}s"); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"{time.ToString()}:设置成功!"); + }); } public RelayCommand Test1Command { get; set; } public RelayCommand Test2Command { get; set; } @@ -71,9 +118,15 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public RelayCommand Test4Command { get; set; } public RelayCommand Test5Command { get; set; } public RelayCommand Test6Command { get; set; } + public RelayCommand TimeSet { get; set; } public static bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnStaticPropertyChanged(); } } private static bool _mHeartbeat; + public int time { get { return _mtime; } set { _mtime = value; OnStaticPropertyChanged(); } } + private int _mtime; + public static string OrderStatus { get { return _mOrderStatus; } set { _mOrderStatus = value; OnStaticPropertyChanged(); } } + private static string _mOrderStatus = "无意义"; + public static event EventHandler StaticPropertyChanged; public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "") { diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/StockBinRawMaterialViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/StockBinRawMaterialViewModel.cs new file mode 100644 index 00000000..c7ecea4d --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/StockBinRawMaterialViewModel.cs @@ -0,0 +1,55 @@ +using BPASmartClient.CustomResource.Pages.Model; +using BPASmartClient.CustomResource.UserControls; +using BPASmartClient.CustomResource.UserControls.MessageShow; +using BPASmartClient.Helper; +using BPASmartClient.JXJFoodSmallStation.Model; +using BPASmartClient.JXJFoodSmallStation.Model.RawMaterial; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using Microsoft.Toolkit.Mvvm.Input; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.ViewModel +{ + public class StockBinRawMaterialViewModel : ObservableObject + { + public StockBinRawMaterialViewModel() + { + RawMaterialInfo = Json.Data.rawMaterialStockBin; + RemoveCommand = new RelayCommand((loc) => + { + if (loc is int pos) + { + var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialLocation == pos); + if (res != null) RawMaterialInfo.Remove(res); + } + }); + SaveRawMaterialPara = new RelayCommand(() => + { + Json.Save(); + ProcessControl.GetInstance.testData(); + foreach (var item in Json.Data.rawMaterialStockBin) + { + MessageNotify.GetInstance.ShowUserLog($"料仓位置:"+ item.RawMaterialLocation+ ",物料编码:" + item.RawMaterialName); + } + MessageNotify.GetInstance.ShowUserLog($"原料与料仓对应关系保存成功"); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功"); + }); + UpdateRawMaterial = new RelayCommand(() => + { + RawMaterialInfo.Add(new RawMaterialStockBin() { RawMaterialCount = (short)(RawMaterialInfo.Count + 1)}); + }); + } + public ObservableCollection RawMaterialInfo { get; set; } = new ObservableCollection(); + public RelayCommand RemoveCommand { get; set; } + public RelayCommand SaveRawMaterialPara { get; set; } + public RelayCommand UpdateRawMaterial { get; set; } + } +} diff --git a/BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj b/BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj index ef6914fa..a21a359c 100644 --- a/BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj +++ b/BPASmartClient.JakaRobot/BPASmartClient.JakaRobot.csproj @@ -7,6 +7,7 @@ + diff --git a/BPASmartClient.JakaRobot/JaKaHelper.cs b/BPASmartClient.JakaRobot/JaKaHelper.cs index b6f259c4..1402fff6 100644 --- a/BPASmartClient.JakaRobot/JaKaHelper.cs +++ b/BPASmartClient.JakaRobot/JaKaHelper.cs @@ -1,4 +1,5 @@ -using BPASmartClient.Message; +using BPASmartClient.Helper; +using BPASmartClient.Message; using System.Text; namespace BPASmartClient.JakaRobot @@ -72,44 +73,50 @@ namespace BPASmartClient.JakaRobot //private JaKaHelper() { } public bool IsIdle { get; set; } = false; public bool IsConnected { get { return login; } } + public bool IsDeviceFirstInit { get; set; } public void Connect(string ip) { bool ErrorFlag = false; - while (rshd == -1 || login == false) + ThreadManage.GetInstance().StartLong(new Action(() => { - try + if (rshd == -1 || login == false) { - jakaAPI.create_handler(ip.ToCharArray(), ref rshd); - - login = true; + try + { + jakaAPI.create_handler(ip.ToCharArray(), ref rshd); + login = true; - } - catch (Exception ex) - { - if (!ErrorFlag) + } + catch (Exception ex) { - MessageLog.GetInstance.ShowEx(ex.ToString()); - ErrorFlag = true; - login = false; + if (!ErrorFlag) + { + MessageLog.GetInstance.ShowEx(ex.ToString()); + ErrorFlag = true; + login = false; + } + Thread.Sleep(3000); } - Thread.Sleep(3000); - } - } - if (login) - { - try - { - Power_On();//打开机器人电源 - Thread.Sleep(1000); - Enable_robot();//机器人上使能 - MessageLog.GetInstance.Show("机器人已上电使能"); - } - catch (Exception ex) + } + if (login && IsDeviceFirstInit==false) { - MessageLog.GetInstance.ShowEx("机器人未完成上电和使能"); + try + { + Power_On();//打开机器人电源 + Thread.Sleep(1000); + Enable_robot();//机器人上使能 + IsDeviceFirstInit = true; + MessageLog.GetInstance.Show("机器人已上电使能"); + } + catch (Exception ex) + { + MessageLog.GetInstance.ShowEx("机器人未完成上电和使能"); + } } - } + Thread.Sleep(5000); + }), $"节卡机器人连接", true); + } public void Power_On() { @@ -319,13 +326,14 @@ namespace BPASmartClient.JakaRobot try { //加载 - file = Programname.ToCharArray(); + p: file = Programname.ToCharArray(); MessageLog.GetInstance.Show($"调用文件名:{Programname}"); status = new JKTYPE.ProgramState(); jakaAPI.get_program_state(ref rshd, ref status); if (status != JKTYPE.ProgramState.PROGRAM_IDLE) { MessageLog.GetInstance.Show($"程序运行中,无法加载程序!!!"); + goto p; } else { @@ -336,11 +344,13 @@ namespace BPASmartClient.JakaRobot else { MessageLog.GetInstance.Show($"加载程序失败!!!"); + goto p; } } if (status == JKTYPE.ProgramState.PROGRAM_RUNNING) { MessageLog.GetInstance.Show($"程序处于已处于启动状态!!!"); + goto p; } else if (status == JKTYPE.ProgramState.PROGRAM_IDLE) { @@ -349,6 +359,7 @@ namespace BPASmartClient.JakaRobot if (jakafile.Length == 0) { MessageLog.GetInstance.Show($"未加载程序,无法运行!!!"); + goto p; } else { diff --git a/BPASmartClient.MilkTeaCube/BPASmartClient.MilkTeaCube.csproj b/BPASmartClient.MilkTeaCube/BPASmartClient.MilkTeaCube.csproj new file mode 100644 index 00000000..fda73f31 --- /dev/null +++ b/BPASmartClient.MilkTeaCube/BPASmartClient.MilkTeaCube.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/BPASmartClient.MilkTeaCube/MilkTeaCubeMachine.cs b/BPASmartClient.MilkTeaCube/MilkTeaCubeMachine.cs new file mode 100644 index 00000000..33c678a4 --- /dev/null +++ b/BPASmartClient.MilkTeaCube/MilkTeaCubeMachine.cs @@ -0,0 +1,90 @@ +using BPASmartClient.Peripheral; +using System; +using BPASmartClient.Modbus; +using BPASmartClient.Helper; +using System.Threading; +using BPASmartClient.Model.̲ζħ; +using BPASmartClient.EventBus; +using static BPASmartClient.EventBus.EventBus; + +namespace BPASmartClient.MilkTeaCube +{ + public class MilkTeaCubeMachine: BasePeripheral + { + public ModbusTcp modbus =new ModbusTcp(); + public override void Init() + { + modbus.ModbusTcpConnect(communicationPar.IPAddress); + ThreadManage.GetInstance().StartLong(new Action(() => + { + IsConnected = modbus.Connected; + if (!IsConnected) IsWork = false; + if (IsConnected) + { + IsWork = true; + if (status != null) + { + var a = modbus.Read("LB0"); + var b = modbus.Read("LB13"); + if (a is bool[] a1 && b is bool[] b1) + { + SetStatus("Get_MilkTeaCubeStatus", a1[0]); + SetStatus("Get_MilkTeaCubeDosingStatus", b1[0]); + } + } + Thread.Sleep(500); + } + Thread.Sleep(1000); + }), $"̲ζħ豸", true); + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) + { + if (@event == null) return; + var par = @event as MilkTea_MakeMilkTeaEvent; + switch (par?.TagName) + { + case "Start": + modbus.Write("LB14",true); + break; + case "ParameterSet": + modbus.Write("LB14", false); + Thread.Sleep(500); + modbus.Write("LW1002", par.MilkTeaKind[0]); + modbus.Write("LW1006", par.MilkTeaKind[1]); + modbus.Write("LW1008", par.MilkTeaKind[2]); + modbus.Write("LW1010", par.MilkTeaKind[3]); + modbus.Write("LW1012", par.MilkTeaKind[4]); + modbus.Write("LW1014", par.MilkTeaKind[5]); + modbus.Write("LW1016", par.MilkTeaKind[6]); + modbus.Write("LW1018", par.MilkTeaKind[7]); + modbus.Write("LW1020", par.MilkTeaKind[8]); + modbus.Write("LW1022", par.MilkTeaKind[9]); + modbus.Write("LW1024", par.MilkTeaKind[10]); + modbus.Write("LW1026", par.MilkTeaKind[11]); + + break; + case "StartSignReset": + modbus.Write("LB14", false); + break; + default: + break; + } + }); + } + public override void Start() + { + } + + public override void Stop() + { + } + + public override void WriteData(string address, object value) + { + + } + + protected override void InitStatus() + { + } + } +} diff --git a/BPASmartClient.MilkTeaCubeHelper/BPASmartClient.MilkTeaCubeHelper.csproj b/BPASmartClient.MilkTeaCubeHelper/BPASmartClient.MilkTeaCubeHelper.csproj new file mode 100644 index 00000000..9a7c06f1 --- /dev/null +++ b/BPASmartClient.MilkTeaCubeHelper/BPASmartClient.MilkTeaCubeHelper.csproj @@ -0,0 +1,9 @@ + + + + net6.0-windows + enable + true + + + diff --git a/BPASmartClient.MilkTeaCubeHelper/Class1.cs b/BPASmartClient.MilkTeaCubeHelper/Class1.cs new file mode 100644 index 00000000..360d0ef4 --- /dev/null +++ b/BPASmartClient.MilkTeaCubeHelper/Class1.cs @@ -0,0 +1,8 @@ +using System; + +namespace BPASmartClient.MilkTeaCubeHelper +{ + public class Class1 + { + } +} diff --git a/BPASmartClient.Model/奶茶味魔方/MilkTeaCubeEvent.cs b/BPASmartClient.Model/奶茶味魔方/MilkTeaCubeEvent.cs new file mode 100644 index 00000000..bdf075a3 --- /dev/null +++ b/BPASmartClient.Model/奶茶味魔方/MilkTeaCubeEvent.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.奶茶味魔方 +{ + public class MilkTea_MakeMilkTeaEvent : BaseEvent + { + public ushort[] MilkTeaKind { get; set; } = new ushort[12]; + } +} diff --git a/BPASmartClient.Model/电夹爪/GripperEvent.cs b/BPASmartClient.Model/电夹爪/GripperEvent.cs new file mode 100644 index 00000000..bbe03d78 --- /dev/null +++ b/BPASmartClient.Model/电夹爪/GripperEvent.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.电夹爪 +{ + public class Wrtie : WriteGripper { } +} diff --git a/BPASmartClient.Model/电夹爪/WriteGripper.cs b/BPASmartClient.Model/电夹爪/WriteGripper.cs new file mode 100644 index 00000000..18c12702 --- /dev/null +++ b/BPASmartClient.Model/电夹爪/WriteGripper.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model.电夹爪 +{ + public class WriteGripper:BaseEvent + { + public string CH_Number { get; set; } + public string PWMOutput { get; set; } + } +} diff --git a/BPASmartClient.Model/节卡机器人/JakaModel.cs b/BPASmartClient.Model/节卡机器人/JakaModel.cs index 00d4702f..5ac5aace 100644 --- a/BPASmartClient.Model/节卡机器人/JakaModel.cs +++ b/BPASmartClient.Model/节卡机器人/JakaModel.cs @@ -8,31 +8,82 @@ namespace BPASmartClient.Model { public class JakaModel { - public const string SENCE_取杯 = "10000"; - public const string SENCE_放杯位检测 = "10100"; - public const string SENCE_取杯检测 = "11000"; - - public const string SENCE_接咖啡 = "12000"; - public const string SENCE_接果汁1 = "12001"; - public const string SENCE_接果汁2 = "12002"; - public const string SENCE_接果汁3 = "12003"; - public const string SENCE_接果汁4 = "12004"; - public const string SENCE_接茶 = "12005"; - public const string SENCE_接水 = "12006"; - public const string SENCE_接茶_接水 = "12007"; - - public const string SENCE_放咖啡杯 = "13000";//接饮料位---放饮料过渡位 - public const string SENCE_放果汁杯1 = "13001"; - public const string SENCE_放果汁杯2 = "13002"; - public const string SENCE_放果汁杯3 = "13003"; - public const string SENCE_放果汁杯4 = "13004"; - public const string SENCE_放茶水杯 = "13005"; - - public const string SENCE_放杯 = "14000";//放杯过渡位到-放杯 - - public const string SENCE_放杯检测 = "15000"; - - public const string SENCE_初始位 = "20000"; + public const string SENCE_初始位 = "1000"; + + public const string SENCE_初始位_取杯位 = "1010"; + + public const string SENCE_取杯位_取杯放杯检测位 = "1011"; + + public const string SENCE_取杯放杯检测位_取杯位 = "1012"; + + public const string SENCE_取杯位_接咖啡位 = "1020"; + + public const string SENCE_取杯位_接奶茶位 = "1021"; + + public const string SENCE_等奶茶_接奶茶位 = "1022"; + + public const string SENCE_接咖啡位_放咖啡位 = "1030"; + + public const string SENCE_接奶茶位_放奶茶位 = "1031"; + + public const string SENCE_落杯 = "1100"; + + public const string SENCE_初始位_取杯位检测 = "1200"; + + public const string SENCE_取杯位检测_取杯位 = "1300"; + + public const string SENCE_取杯位_接咖啡 = "1400"; + + public const string SENCE_取杯位_接奶茶 = "1500"; + + public const string SENCE_初始位_放杯位检测 = "1600"; + + public const string SENCE_放杯位检测_接咖啡 = "1610"; + + public const string SENCE_放杯位检测_接奶茶 = "1620"; + + public const string SENCE_接咖啡_放杯位 = "1700"; + + public const string SENCE_接奶茶_放杯位 = "1800"; + + public const string SENCE_异常回初始位 = "1900"; + + public const string SENCE_接咖啡_初始位 = "1910"; + + public const string SENCE_接奶茶_初始位 = "1920"; + + public const string SENCE_放杯位_初始位 = "2000"; + + + + public const string SENCE_初始位_落杯位 = "100"; + + public const string SENCE_落杯位_接咖啡位 = "110"; + + public const string SENCE_接咖啡位_初始位 = "120"; + + public const string SENCE_落杯位_接奶茶等待位 = "150"; + + public const string SENCE_接奶茶等待位_初始位 = "160"; + + + public const string SENCE_接咖啡_放咖啡杯 = ""; + public const string SENCE_接水 = ""; + public const string SENCE_放茶水杯 = ""; + public const string SENCE_接茶_接水 = ""; + public const string SENCE_接果汁1 = ""; + public const string SENCE_接果汁2 = ""; + public const string SENCE_接果汁3 = ""; + public const string SENCE_接果汁4 = ""; + public const string SENCE_放果汁杯1 = ""; + public const string SENCE_放果汁杯2 = ""; + public const string SENCE_放果汁杯3 = ""; + public const string SENCE_放果汁杯4 = ""; + public const string SENCE_取杯检测 = ""; + public const string SENCE_放杯 = ""; + public const string SENCE_放杯检测 = ""; + public const string SENCE_接茶 = ""; + } public class WriteJaka : BaseEvent @@ -48,6 +99,10 @@ namespace BPASmartClient.Model public ushort Length { get; set; } public object ReadPar { get; set; } } - + public enum Kind:int + { + 咖啡 = 1, + 奶茶 = 2 + } } diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index 91fef0bb..d720c09a 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -37,7 +37,7 @@ namespace BPASmartClient.MorkBF ActionManage.GetInstance.Register(new Action(() => { GlobalFoodMenu.LocalFoodMenus.Clear(); - if(BPASmartClient.Helper.Json.Data.FryPotMessage.Count>0) + if (BPASmartClient.Helper.Json.Data.FryPotMessage.Count > 0) { foreach (var item in BPASmartClient.Helper.Json.Data.FryPotMessage) { @@ -50,7 +50,8 @@ namespace BPASmartClient.MorkBF DataParse();//数据解析 ScreenDataServer();//大屏数据上报 ActionManage.GetInstance.Send("更新菜单"); - //ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程"); + ThreadManage.GetInstance().Start(FirePot1_Process, "炒锅1流程"); + ThreadManage.GetInstance().Start(FirePot2_Process, "炒锅2流程"); DeviceProcessLogShow("MORKF 设备初始化完成"); } @@ -97,23 +98,26 @@ namespace BPASmartClient.MorkBF private void CommandRegist() { #region 炒锅 - ActionManage.GetInstance.Register(FirePot_SetFireGear, "FirePot_SetFireGear");//炒锅设定加热挡位 + ActionManage.GetInstance.Register(FirePot_SetFireGear, "FirePot_SetFireGear");//炒锅设定加热挡位1-5 + ActionManage.GetInstance.Register(FirePot_SetStirGear, "FirePot_SetStirGear");//炒锅设定搅拌挡位1-5 + ActionManage.GetInstance.Register(FirePot_SetTurnSpeed, "FirePot_SetTurnSpeed");//炒锅翻转速度0-800 + ActionManage.GetInstance.Register(FirePot_SetPotAngle, "FirePot_SetPotAngle");//设定炒锅角度挡位1-4 + ActionManage.GetInstance.Register(FirePot_StartPassWay, "FirePot_StartPassWay");//通道出料需求值+启动 + ActionManage.GetInstance.Register(FirePot_StartFire, "FirePot_StartFire");//炒锅加热启动 ActionManage.GetInstance.Register(FirePot_StartFire, "FirePot_StopFire");//炒锅关闭加热 - ActionManage.GetInstance.Register(FirePot_SetStirGear, "FirePot_SetStirGear");//炒锅设定搅拌挡位 ActionManage.GetInstance.Register(FirePot_StartStir, "FirePot_StartStir");//炒锅搅拌启动 ActionManage.GetInstance.Register(FirePot_StartStir, "FirePot_StopStir");//炒锅搅拌停止 - ActionManage.GetInstance.Register(FirePot_SetTurnSpeed, "FirePot_SetTurnSpeed");//炒锅翻转频率设定 - ActionManage.GetInstance.Register(FirePot_SetPotAngle, "FirePot_SetPotAngle");//设定炒锅角度 - ActionManage.GetInstance.Register(FirePot_StartPassWay, "FirePot_StartPassWay");//炒锅翻转频率设定 - ActionManage.GetInstance.Register(FirePot_Reset, "FirePot_Reset");//复位; ActionManage.GetInstance.Register(FirePot_PotGotoOrigin, "FirePot_PotGotoOrigin");//炒锅回原点 - ActionManage.GetInstance.Register(FirePot_PotGotoInFoodPosition, "FirePot_PotGotoInFoodPosition");//炒锅去投料位置 ActionManage.GetInstance.Register(FirePot_StartOutFood, "FirePot_StartOutFood");//出餐启动 ActionManage.GetInstance.Register(FirePot_Clean, "FirePot_Clean");//清洗 + + ActionManage.GetInstance.Register(FirePot_Reset, "FirePot_Reset");//复位; ActionManage.GetInstance.Register(FirePot_StartPumpWater, "FirePot_StartPumpWater");//抽水启动 ActionManage.GetInstance.Register(FirePot_StartPumpWater, "FirePot_StopPumpWater");//抽水关闭 + ActionManage.GetInstance.Register(FirePot_PotGotoInFoodPosition, "FirePot_PotGotoInFoodPosition");//炒锅去投料位置 + ActionManage.GetInstance.Register(FirePot_PushReach, "FirePot_PushReach");//推杆伸出 ActionManage.GetInstance.Register(FirePot_PushRetract, "FirePot_PushRetract");//推杆缩回 ActionManage.GetInstance.Register(FirePot_PotForward, "FirePot_PotForward");//翻转正转 @@ -129,12 +133,11 @@ namespace BPASmartClient.MorkBF public override void MainTask() { - if(morkBF.RobotActinQueue.Count>0&&! morkBF.Robot_Start)//机器人启动 { if( morkBF.RobotActinQueue.TryDequeue(out RobotAction_Pot robotAction)) { - morkBF.Robot_IsBusy =true; + morkBF.Robot_IsBusy = true; RobotProcess(robotAction); } } @@ -142,11 +145,10 @@ namespace BPASmartClient.MorkBF private void FirePot1_Process() { - if (morkBF.FirePan1_Order.Count > 0 && morkBF.FirePot1_InitCompleted && morkBF.FirePot2_IsAuto && !morkBF.FirePan1_Busy) + if (morkBF.FirePan1_Order.Count > 0 && morkBF.FryPan1_InitComplete && morkBF.FryPan1_ManualOrAutoMode && !morkBF.FirePan1_Busy) { if (morkBF.FirePan1_Order.TryDequeue(out FryPotMessages result)) { - morkBF.FirePan1_Busy = true; morkBF.FryPot1_CurrentProcess = result.fryPotProcesses; foreach (var item in result.fryPotProcesses) @@ -178,17 +180,56 @@ namespace BPASmartClient.MorkBF } } FirePot_StartFire(new object[] { 1, false });//关火 - Thread.Sleep(result.FryOffStirTime*1000);//关火翻炒时间 + Thread.Sleep(result.FryOffStirTime * 1000);//关火翻炒时间 FirePot_StartStir(new object[] { 1, false });//关闭搅拌 Message.MessageLog.GetInstance.Show($"炒锅1炒制{result.GoodName}完成"); } } } - private void FirePot2_Process() { - + if (morkBF.FirePan2_Order.Count > 0 && morkBF.FryPan2_InitComplete && morkBF.FryPan2_ManualOrAutoMode && !morkBF.FirePan2_Busy) + { + if (morkBF.FirePan2_Order.TryDequeue(out FryPotMessages result)) + { + morkBF.FirePan2_Busy = true; + morkBF.FryPot2_CurrentProcess = result.fryPotProcesses; + foreach (var item in result.fryPotProcesses) + { + switch (item.fryActions) + { + case FryAction.冷锅加热: + FirePot_PotPerHeat(item, 2); + MessageLog.GetInstance.Show("炒锅2---冷锅加热完成"); + break; + case FryAction.热油: + FirePot_HeatOil(item, 2); + MessageLog.GetInstance.Show("炒锅2---热油完成"); + break; + case FryAction.机器人加调料: + FirePot_RobotGetSeasoning(item, 2); + MessageLog.GetInstance.Show("炒锅2---机器人加调料完成"); + break; + case FryAction.通道出调料: + FirePot_PasswayOutSeasoning(item, 2); + MessageLog.GetInstance.Show("炒锅2---通道出调料完成"); + break; + case FryAction.炒制菜品: + FirePot_FryFood(item, 2); + MessageLog.GetInstance.Show("炒锅2---炒制菜品完成"); + break; + default: + break; + } + } + FirePot_StartFire(new object[] { 1, false });//关火 + Thread.Sleep(result.FryOffStirTime * 1000);//关火翻炒时间 + FirePot_StartStir(new object[] { 1, false });//关闭搅拌 + Message.MessageLog.GetInstance.Show($"炒锅1炒制{result.GoodName}完成"); + + } + } } @@ -223,7 +264,7 @@ namespace BPASmartClient.MorkBF private void FirePot_PotPerHeat(FryPotProcess item,int i) { bool isRobotWork = false; - + FirePot_SetFireGear(new object[]{ i, item.FryGear});//设定加热挡位 FirePot_StartFire(new object[] { i, true }); isRobotWork = IsRobotNextWork(i,item.FryTime);//下个流程动作是否需要机器人 @@ -318,7 +359,7 @@ namespace BPASmartClient.MorkBF { Thread.Sleep(300); } - if((int)robotAction.subTask1>0&& (int)robotAction.subTask1<16)//任务1 + if ((int)robotAction.subTask1 > 0 && (int)robotAction.subTask1 < 16)//任务1 { Robot_Write("GI1", (int)robotAction.subTask1); Thread.Sleep(1000); @@ -327,7 +368,7 @@ namespace BPASmartClient.MorkBF Thread.Sleep(300); } } - if((int)robotAction.subTask1>15) //出餐 + if ((int)robotAction.subTask1 > 15) //出餐 { } @@ -368,104 +409,85 @@ namespace BPASmartClient.MorkBF MessageLog.GetInstance.Show($"机器人完成[{robotAction.MainTask.ToString()}]任务"); } + /// + /// PLC——>上位机(PLC反馈的数据) + /// public override void ReadData() { - GetStatus("M20.0",new Action((o)=> + GetStatus("M40.0",new Action((o)=> { if (o == null) return; - if(o is bool[] values&&values.Length == 19) - { - morkBF.FirePot1_InitCompleted = values[0]; - morkBF.FirePot1_IsAuto = values[1]; - morkBF.FirePot1_Emergencystop = values[2]; - morkBF.FirePot1_MealTubExist = values[3]; - morkBF.FirePot1_VegetablesTub1Exist = values[4]; - morkBF.FirePot1_VegetablesTub2Exist = values[5]; - morkBF.FirePot1_Seasoning1Exist = values[6]; - morkBF.FirePot1_Seasoning2Exist = values[7]; - morkBF.FirePot1_Accessories1Exist = values[8]; - morkBF.FirePot1_Accessories2Exist = values[9]; - morkBF.FirePot1_OutFoodTubExist = values[10]; - morkBF.FirePot1_OnOrigin = values[11]; - morkBF.FirePot1_FirePosition1 = values[12]; - morkBF.FirePot1_FirePosition2 = values[13]; - morkBF.FirePot1_FirePosition3 = values[14]; - morkBF.FirePot1_FirePosition4 = values[15]; - morkBF.FirePot1_PotOnOutFoodPosition = values[16]; - morkBF.FirePot1_PotOnIntoFoodPosition = values[17]; - morkBF.FirePot1_PotOnCleanPosition = values[18]; - - } - }),0); - - GetStatus("VW120", new Action((o) => - { - if (o == null) return; - if (o is int[] values&&values.Length == 2) + if(o is bool[] values&&values.Length == 18) { - morkBF.FirePot1_Temperature = values[0]; - morkBF.FirePot1_Pulse = values[1]; - + morkBF.FryPan1_InitComplete = values[0]; + morkBF.FryPan1_ManualOrAutoMode = values[1]; + morkBF.FryPan1_EStop = values[2]; + morkBF.FryPan1_InPosition1 = values[3]; + morkBF.FryPan1_InPosition2 = values[4]; + morkBF.FryPan1_InPosition3 = values[5]; + morkBF.FryPan1_InPosition4 = values[6]; + morkBF.FryPan1_InPositionUnload = values[7]; + morkBF.FryPan1_InPositionload = values[8]; + morkBF.FryPan1_InPositionWashPot = values[9]; + morkBF.FryPan1_UnloadFinishCH1 = values[10]; + morkBF.FryPan1_UnloadFinishCH2 = values[11]; + morkBF.FryPan1_UnloadFinishCH3 = values[12]; + morkBF.FryPan1_UnloadFinishCH4 = values[13]; + morkBF.FryPan1_UnloadFinishCH5 = values[14]; + morkBF.FryPan1_UnloadFinishCH6 = values[15]; + morkBF.FryPan1_UnloadFinishCH7 = values[16]; + morkBF.FryPan1_UnloadFinishCH8 = values[17]; } - }), 0); - - GetStatus("M25.0", new Action((o) => - { - if (o == null) return; - if (o is bool[] values&& values.Length == 19) - { - morkBF.FirePot2_InitCompleted = values[0]; - morkBF.FirePot2_IsAuto = values[1]; - morkBF.FirePot2_Emergencystop = values[2]; - morkBF.FirePot2_MealTubExist = values[3]; - morkBF.FirePot2_VegetablesTub1Exist = values[4]; - morkBF.FirePot2_VegetablesTub2Exist = values[5]; - morkBF.FirePot2_Seasoning1Exist = values[6]; - morkBF.FirePot2_Seasoning2Exist = values[7]; - morkBF.FirePot2_Accessories1Exist = values[8]; - morkBF.FirePot2_Accessories2Exist = values[9]; - morkBF.FirePot2_OutFoodTubExist = values[10]; - morkBF.FirePot2_OnOrigin = values[11]; - morkBF.FirePot2_FirePosition1 = values[12]; - morkBF.FirePot2_FirePosition2 = values[13]; - morkBF.FirePot2_FirePosition3 = values[14]; - morkBF.FirePot2_FirePosition4 = values[15]; - morkBF.FirePot2_PotOnOutFoodPosition = values[16]; - morkBF.FirePot2_PotOnIntoFoodPosition = values[17]; - morkBF.FirePot2_PotOnCleanPosition = values[18]; - - } - }), 0); + }),0); - GetStatus("VW150", new Action((o) => + GetStatus("VW200", new Action((o) => { if (o == null) return; - if (o is int[] values&& values.Length == 2) + if (o is short[] values&&values.Length == 4) { - morkBF.FirePot2_Temperature = values[0]; - morkBF.FirePot2_Pulse = values[1]; - + morkBF.FryPan1_TemperatureNow = values[0]; + morkBF.FryPan1_MixingSpeedNow = values[1]; + morkBF.FryPan1_FryAngle = values[2]; + morkBF.FryPan1_HeatingGearNow = values[3]; } }), 0); - - - GetStatus("VW2250", new Action((o) => + GetStatus("M40.0", new Action((o) => { if (o == null) return; - if (o is int[] values && values.Length == 1) + if (o is bool[] values && values.Length == 18) { - dataReport.FirePot1_PotState = values[0]; + morkBF.FryPan2_InitComplete = values[0]; + morkBF.FryPan2_ManualOrAutoMode = values[1]; + morkBF.FryPan2_EStop = values[2]; + morkBF.FryPan2_InPosition1 = values[3]; + morkBF.FryPan2_InPosition2 = values[4]; + morkBF.FryPan2_InPosition3 = values[5]; + morkBF.FryPan2_InPosition4 = values[6]; + morkBF.FryPan2_InPositionUnload = values[7]; + morkBF.FryPan2_InPositionload = values[8]; + morkBF.FryPan2_InPositionWashPot = values[9]; + morkBF.FryPan2_UnloadFinishCH1 = values[10]; + morkBF.FryPan2_UnloadFinishCH2 = values[11]; + morkBF.FryPan2_UnloadFinishCH3 = values[12]; + morkBF.FryPan2_UnloadFinishCH4 = values[13]; + morkBF.FryPan2_UnloadFinishCH5 = values[14]; + morkBF.FryPan2_UnloadFinishCH6 = values[15]; + morkBF.FryPan2_UnloadFinishCH7 = values[16]; + morkBF.FryPan2_UnloadFinishCH8 = values[17]; } }), 1); - GetStatus("VW2350", new Action((o) => + + GetStatus("VW200", new Action((o) => { if (o == null) return; - if (o is int[] values && values.Length == 1) + if (o is short[] values && values.Length == 4) { - dataReport.FirePot2_PotState = values[0]; + morkBF.FryPan2_TemperatureNow = values[0]; + morkBF.FryPan2_MixingSpeedNow = values[1]; + morkBF.FryPan2_FryAngle = values[2]; + morkBF.FryPan2_HeatingGearNow = values[3]; } }), 1); - } public override void ResetProgram() @@ -538,133 +560,130 @@ namespace BPASmartClient.MorkBF Thread.Sleep(200); } /// - /// 炒锅1加热启停 + /// 炒锅1设置搅拌挡位 /// - /// - private void FirePot_StartFire(object[] o) + /// + private void FirePot_SetStirGear(object[] o) { if (o == null) return; - if (o.Length == 2 && o[0] is int fryNo && o[1] is bool value) + if (o.Length == 2 && o[0] is int fryNo && o[1] is int value) { if (fryNo == 1) { - FirePot1_Write("M10.0", value); + FirePot1_Write("VW102", (ushort)value); } else if (fryNo == 2) { - FirePot2_Write("M10.0", value); + FirePot2_Write("VW102", (ushort)value); } } Thread.Sleep(200); - } + } /// - /// 炒锅1设置搅拌挡位 + /// 设置炒锅翻转速度 /// /// - private void FirePot_SetStirGear(object[] o) + private void FirePot_SetTurnSpeed(object[] o) { if (o == null) return; if (o.Length == 2 && o[0] is int fryNo && o[1] is int value) { if (fryNo == 1) { - FirePot1_Write("VW102", (ushort)value); + FirePot1_Write("VW104", (ushort)value); } else if (fryNo == 2) { - FirePot2_Write("VW102", (ushort)value); + FirePot2_Write("VW104", (ushort)value); } } Thread.Sleep(200); } /// - /// 炒锅1搅拌启停 + /// 设定炒锅角度 /// /// - private void FirePot_StartStir(object[] o) + private void FirePot_SetPotAngle(object[] o) { if (o == null) return; - if (o.Length == 2 && o[0] is int fryNo && o[1] is bool value) + if (o.Length == 2 && o[0] is int fryNo && o[1] is int value) { if (fryNo == 1) { - FirePot1_Write("M10.1", value); + FirePot1_Write("VW106", (ushort)value); } else if (fryNo == 2) { - FirePot2_Write("M10.1", value); + FirePot2_Write("VW106", (ushort)value); } } Thread.Sleep(200); } /// - /// 设置炒锅1翻转速度 + /// 通道出料启动 /// /// - private void FirePot_SetTurnSpeed(object[] o) + private void FirePot_StartPassWay(object[] o) { if (o == null) return; - if (o.Length == 2 && o[0] is int fryNo && o[1] is int value) + if (o.Length == 3 && o[0] is int fryNo && o[1] is int value1 && o[2] is int value2) { if (fryNo == 1) { - FirePot1_Write("VW104", (ushort)value); + FirePot1_Write(morkBF.Fire_PasswayValue[value1], (ushort)value2);//写入需求值 + Thread.Sleep(200); + FirePot1_Write(morkBF.Fire_PasswayWrite[value1], true);//启动通道 } else if (fryNo == 2) { - FirePot2_Write("VW104", (ushort)value); + FirePot2_Write(morkBF.Fire_PasswayValue[value1], (ushort)value2); + Thread.Sleep(200); + FirePot2_Write(morkBF.Fire_PasswayWrite[value1], true); } } Thread.Sleep(200); } /// - /// 设定炒锅角度 + /// 炒锅1加热启停 /// - /// - private void FirePot_SetPotAngle(object[] o) + /// + private void FirePot_StartFire(object[] o) { if (o == null) return; - if (o.Length == 2 && o[0] is int fryNo && o[1] is int value) + if (o.Length == 2 && o[0] is int fryNo && o[1] is bool value) { if (fryNo == 1) { - FirePot1_Write("VW106", (ushort)value); + FirePot1_Write("M10.0", value); } else if (fryNo == 2) { - FirePot2_Write("VW106", (ushort)value); + FirePot2_Write("M10.0", value); } } Thread.Sleep(200); - } - + } + /// - /// 通道出料启动 + /// 炒锅搅拌启停 /// /// - private void FirePot_StartPassWay(object[] o) + private void FirePot_StartStir(object[] o) { if (o == null) return; - if (o.Length == 3 && o[0] is int fryNo && o[1] is int value1&& o[2] is int value2) + if (o.Length == 2 && o[0] is int fryNo && o[1] is bool value) { if (fryNo == 1) { - FirePot1_Write(morkBF.Fire_PasswayValue[value1], (ushort)value2);//写入需求值 - Thread.Sleep(200); - FirePot1_Write(morkBF.Fire_PasswayWrite[value1], true);//启动通道哦 + FirePot1_Write("M10.1", value); } else if (fryNo == 2) { - FirePot2_Write(morkBF.Fire_PasswayValue[value1], (ushort)value2); - Thread.Sleep(200); - FirePot2_Write(morkBF.Fire_PasswayWrite[value1], true); + FirePot2_Write("M10.1", value); } } Thread.Sleep(200); } - - - /// /// 炒锅复位 /// @@ -683,46 +702,103 @@ namespace BPASmartClient.MorkBF } } - - } /// - /// 炒锅回原点 + /// 炒锅设定加热挡位 锁定 /// /// - private void FirePot_PotGotoOrigin(object o) + private void FirePot_SetFireGearLock(object[] o) { if (o == null) return; - if (o is int i) + if (o.Length == 2 && o[0] is int fryNo && o[1] is int value) { - if (i == 1) + if (fryNo == 1) { - FirePot1_Write("M10.5", true); + FirePot1_Write("M10.2", value); } - else if (i == 2) + else if (fryNo == 2) { - FirePot2_Write("M10.5", true); + FirePot2_Write("M10.2", value); } } Thread.Sleep(200); } - /// - /// 炒锅去投料位置 + /// 炒锅1设置搅拌挡位锁定 /// /// - private void FirePot_PotGotoInFoodPosition(object o) + private void FirePot_SetStirGearLock(object[] o) + { + if (o == null) return; + if (o.Length == 2 && o[0] is int fryNo && o[1] is int value) + { + if (fryNo == 1) + { + FirePot1_Write("M10.3", value); + } + else if (fryNo == 2) + { + FirePot1_Write("M10.3", value); + } + } + Thread.Sleep(200); + } + /// + /// 设置炒锅翻转速度锁定 + /// + /// + private void FirePot_SetTurnSpeedLock(object[] o) + { + if (o == null) return; + if (o.Length == 2 && o[0] is int fryNo && o[1] is int value) + { + if (fryNo == 1) + { + FirePot1_Write("M10.4", value); + } + else if (fryNo == 2) + { + FirePot1_Write("M10.4", value); + } + } + Thread.Sleep(200); + } + /// + /// 设定炒锅角度值锁定 + /// + /// + private void FirePot_SetPotAngleLock(object[] o) + { + if (o == null) return; + if (o.Length == 2 && o[0] is int fryNo && o[1] is int value) + { + if (fryNo == 1) + { + FirePot1_Write("M11.1", value); + } + else if (fryNo == 2) + { + FirePot1_Write("M11.1", value); + } + } + Thread.Sleep(200); + } + /// + /// 炒锅回原点 + /// + /// + private void FirePot_PotGotoOrigin(object o) { if (o == null) return; if (o is int i) { if (i == 1) { - FirePot1_Write("M11.2", true); + FirePot1_Write("M10.5", true); } else if (i == 2) { - FirePot2_Write("M11.2", true); + FirePot2_Write("M10.5", true); } } Thread.Sleep(200); @@ -758,7 +834,7 @@ namespace BPASmartClient.MorkBF { if (i == 1) { - FirePot1_Write("M10.7", true); + FirePot1_Write("M10.7", true); } else if (i == 2) @@ -768,8 +844,9 @@ namespace BPASmartClient.MorkBF } Thread.Sleep(200); } + /// - /// 抽水启动 + /// 抽洗锅水启动 /// /// private void FirePot_StartPumpWater(object[] o) @@ -788,6 +865,26 @@ namespace BPASmartClient.MorkBF } Thread.Sleep(200); } + /// + /// 炒锅去投料位置 + /// + /// + private void FirePot_PotGotoInFoodPosition(object o) + { + if (o == null) return; + if (o is int i) + { + if (i == 1) + { + FirePot1_Write("M11.2", true); + } + else if (i == 2) + { + FirePot2_Write("M11.2", true); + } + } + Thread.Sleep(200); + } /// /// 推杆伸出 @@ -922,8 +1019,8 @@ namespace BPASmartClient.MorkBF ScreenModelMaxWok maxWok = new ScreenModelMaxWok { IsRun = IsHealth ? IsRun.运行 : IsRun.停止, - WorkStatus_1 = morkBF.FirePot1_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, - WorkStatus_2 = morkBF.FirePot2_Temperature > 0 ? WorkStatus.工作 : WorkStatus.待机, + WorkStatus_1 = morkBF.FryPan1_TemperatureNow > 0 ? WorkStatus.工作 : WorkStatus.待机, + WorkStatus_2 = morkBF.FryPan2_TemperatureNow > 0 ? WorkStatus.工作 : WorkStatus.待机, RobotStatu = WorkStatus.工作, Alarm = new List(), FailuresCount = 0, @@ -934,12 +1031,12 @@ namespace BPASmartClient.MorkBF MaxWok_Task_2 = ((PotState)dataReport.FirePot2_PotState).ToString(), MaxWok_Process_1 = SetFirePotPorcess(new Random().Next(0,11)), MaxWok_Process_2 = SetFirePotPorcess(new Random().Next(0, 11)), - MaxWok_HeatGear_1 = morkBF.FirePot1_FireGear.ToString(), - MaxWok_HeatGear_2 = morkBF.FirePot2_FireGear.ToString(), - MaxWok_StirGear_1 = morkBF.FirePot1_StirGear.ToString(), - MaxWok_StirGear_2 = morkBF.FirePot2_StirGear.ToString(), - MaxWok_FlipSpeed_1 = morkBF.FirePot1_FlipSpeed.ToString(), - MaxWok_FlipSpeed_2 = morkBF.FirePot2_FlipSpeed.ToString(), + MaxWok_HeatGear_1 = morkBF.FryPan1_HeatingGearNow.ToString(), + MaxWok_HeatGear_2 = morkBF.FryPan2_HeatingGearNow.ToString(), + MaxWok_StirGear_1 = morkBF.FryPan1_FryAngle.ToString(), + MaxWok_StirGear_2 = morkBF.FryPan2_FryAngle.ToString(), + MaxWok_FlipSpeed_1 = morkBF.FryPan1_MixingSpeedNow.ToString(), + MaxWok_FlipSpeed_2 = morkBF.FryPan2_MixingSpeedNow.ToString(), MaxWok_Temp_1 = new Random().Next(250, 450).ToString(), MaxWok_Temp_2 = new Random().Next(250, 450).ToString(), MaxWok_OrderCount_1 = 2, @@ -959,17 +1056,17 @@ namespace BPASmartClient.MorkBF { if (potState > 0) { - if(potState <=3) + if (potState <= 3) { SetState(2); } - else if(potState>3&&potState < 9) SetState(3); - else if(potState == 9) SetState(4); + else if (potState > 3 && potState < 9) SetState(3); + else if (potState == 9) SetState(4); else if (potState == 10) SetState(5); } - else - { - foreach(var item in dataReport.processModels) + else + { + foreach (var item in dataReport.processModels) { item.Status = ProcessStatus.未执行; } @@ -987,8 +1084,8 @@ namespace BPASmartClient.MorkBF { dataReport.processModels[i].Status = ProcessStatus.正在执行; } - else if( i c ) dataReport.processModels[i].Status = ProcessStatus.未执行; + else if (i < c) dataReport.processModels[i].Status = ProcessStatus.执行完成; + else if (i > c) dataReport.processModels[i].Status = ProcessStatus.未执行; } } } diff --git a/BPASmartClient.MorkBF/GVL_MorkBF.cs b/BPASmartClient.MorkBF/GVL_MorkBF.cs index 0fd64e11..33ce20b4 100644 --- a/BPASmartClient.MorkBF/GVL_MorkBF.cs +++ b/BPASmartClient.MorkBF/GVL_MorkBF.cs @@ -41,8 +41,8 @@ namespace BPASmartClient.MorkBF /// public List FryPot2_CurrentProcess; - - #region 炒锅1读取数据 + #region 旧数据 + /*#region 炒锅1读取数据 /// /// 炒锅1锅低温度 /// @@ -155,7 +155,6 @@ namespace BPASmartClient.MorkBF public int FirePot1_FlipSpeed { get; set; } = 0; #endregion - #region 炒锅2读取数据 /// /// 炒锅2锅低温度 @@ -325,6 +324,7 @@ namespace BPASmartClient.MorkBF //[VariableMonitor("机器人动作反馈GI4", "GI4", "4")] //public int Robot_GI4ActionCallback { get; set; } + #endregion*/ #endregion //新版大炒的通讯协议 2023/01/15 #region 炒锅1读取数据 @@ -480,7 +480,7 @@ namespace BPASmartClient.MorkBF public Dictionary FirePot2_CompleteSingle { get; set; } - + public GVL_MorkBF() { diff --git a/BPASmartClient.MorkS3/Alarm.cs b/BPASmartClient.MorkS3/Alarm.cs new file mode 100644 index 00000000..895427e0 --- /dev/null +++ b/BPASmartClient.MorkS3/Alarm.cs @@ -0,0 +1,204 @@ +using BPASmartClient.Device; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkS3 +{ + public class Alarm : IAlarm + { + /// + /// 煮面机左侧低温报警 + /// PLC ---> M230.0 + /// ModbusTcp --> 1570 + /// + [Alarm("煮面机左侧低温报警")] + public bool MachineLeftLowTemperature { get; set; } + + /// + /// 煮面机左侧低温报警 + /// PLC ---> M230.1 + /// ModbusTcp --> 1571 + /// + [Alarm("煮面机右侧低温报警")] + public bool MachineRightLowTemperature { get; set; } + + /// + /// 供碗1缺碗 + /// PLC ---> 230.2 + /// ModbusTcp --> 1572 + /// + [Alarm("供碗1缺碗")] + public bool Supply1_LossBowl { get; set; } + + /// + /// 供碗2缺碗 + /// PLC ---> M230.3 + /// ModbusTcp --> 1573 + /// + [Alarm("供碗2缺碗")] + public bool Supply2_LossBowl { get; set; } + + /// + /// 供碗1出碗检测异常 + /// PLC ---> M230.4 + /// ModbusTcp --> 1574 + /// + [Alarm("供碗1出碗检测异常")] + public bool Supply1_ErrorOutBowl { get; set; } + + /// + /// 供碗2出碗检测异常 + /// PLC ---> M230.5 + /// ModbusTcp --> 1575 + /// + [Alarm("供碗2出碗检测异常")] + public bool Supply2_ErrorOutBowl { get; set; } + + /// + /// 推碗气缸故障 + /// PLC ---> M230.6 + /// ModbusTcp --> 1576 + /// + [Alarm("推碗气缸故障")] + public bool PushBowlCylinderError { get; set; } + + /// + /// 煮面机通讯异常 + /// PLC ---> M230.7 + /// ModbusTcp --> 1577 + /// + [Alarm("煮面机通讯异常")] + public bool NoodleMacCommunicateError { get; set; } + + /// + /// 配料机通讯异常 + /// PLC ---> M231.0 + /// ModbusTcp --> 1580 + /// + [Alarm("配料机通讯异常")] + public bool DosingMacCommunicateError { get; set; } + + /// + /// 机器人通讯异常 + /// PLC ---> M231.1 + /// ModbusTcp --> 1581 + /// + [Alarm("机器人通讯异常")] + public bool RobotMacCommunicateError { get; set; } + + /// + /// 机器人通讯异常 + /// PLC ---> M231.2 + /// ModbusTcp --> 1581 + /// + [Alarm("设备急停")] + public bool DeviceEstop { get; set; } + + /// + /// PLC电池电压低 + /// PLC ---> M231.3 + /// ModbusTcp --> 1583 + /// + [Alarm("PLC电池电压低")] + public bool RobotInitError { get; set; } + + /// + /// 机器人急停 + /// PLC ---> M231.4 + /// ModbusTcp --> 1584 + /// + [Alarm("机器人急停")] + public bool RobotUrgentStop { get; set; } + + /// + /// 机器人不在远程模式 + /// PLC ---> M231.5 + /// ModbusTcp --> 1585 + /// + [Alarm("机器人不在远程模式")] + public bool RobotNotInRemoteMode { get; set; } + + /// + /// 机器人伺服未就绪 + /// PLC ---> M231.6 + /// ModbusTcp --> 1586 + /// + [Alarm("机器人伺服未就绪")] + public bool RobotNotInReady { get; set; } + + /// + /// 机器人本体异常 + /// PLC ---> M231.7 + /// ModbusTcp --> 1587 + /// + [Alarm("机器人本体异常")] + public bool RobotSelfInException { get; set; } + + /// + /// 煮面机左侧缺水 + /// PLC ---> M232.0 + /// ModbusTcp --> 1570 + /// + [Alarm("煮面机左侧缺水报警")] + public bool LeftLackWater { get; set; } + + /// + /// 煮面机右侧缺水 + /// PLC ---> M232.1 + /// ModbusTcp --> 1571 + /// + [Alarm("煮面机右侧缺水报警")] + public bool RightLackWater { get; set; } + + /// + /// 丝杆初始化失败 + /// PLC ---> M232.2 + /// ModbusTcp --> 1571 + /// + [Alarm("丝杆初始化失败")] + public bool SvrewInitFail { get; set; } + + /// + /// 转盘初始化失败 + /// PLC ---> M232.3 + /// ModbusTcp --> 1571 + /// + [Alarm("转盘初始化失败")] + public bool TurntableInitFail { get; set; } + + /// + /// 机器人初始化失败 + /// PLC ---> M232.4 + /// ModbusTcp --> 1571 + /// + [Alarm("机器人初始化失败")] + public bool RobotInitFail { get; set; } + + /// + /// 煮面机初始化失败 + /// PLC ---> M232.5 + /// ModbusTcp --> 1571 + /// + [Alarm("煮面机初始化失败")] + public bool NoodleCookerInitFail { get; set; } + + /// + /// 推碗1步进推杆初始化失败 + /// PLC ---> M232.6 + /// ModbusTcp --> 1571 + /// + [Alarm("推碗1步进推杆初始化失败")] + public bool PushBowlInitFail1 { get; set; } + + /// + /// 推碗2步进推杆初始化失败 + /// PLC ---> M232.7 + /// ModbusTcp --> 1571 + /// + [Alarm("推碗2步进推杆初始化失败")] + public bool PushBowlInitFail2 { get; set; } + } +} diff --git a/BPASmartClient.MorkS3/BPASmartClient.MorkS3.csproj b/BPASmartClient.MorkS3/BPASmartClient.MorkS3.csproj new file mode 100644 index 00000000..c781b773 --- /dev/null +++ b/BPASmartClient.MorkS3/BPASmartClient.MorkS3.csproj @@ -0,0 +1,28 @@ + + + + net6.0-windows + enable + true + bin\ + portable + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.MorkS3/Control_Morks.cs b/BPASmartClient.MorkS3/Control_Morks.cs new file mode 100644 index 00000000..3ca33215 --- /dev/null +++ b/BPASmartClient.MorkS3/Control_Morks.cs @@ -0,0 +1,891 @@ +using System; +using System.Collections.Generic; +using BPA.Message.Enum; +using BPASmartClient.Device; +using BPASmartClient.EventBus; +using BPASmartClient.Model; +using BPASmartClient.Peripheral; +using static BPASmartClient.EventBus.EventBus; +using BPASmartClient.Helper; +using System.Threading; +using BPASmartClient.Message; +using BPA.Message; +using System.Linq; +using BPASmartClient.Model.PLC; +using System.Threading.Tasks; +using System.Reflection; +using BPASmartClient.MorkS3.Model; +using System.Collections.ObjectModel; +using BPASmartClient.MorkS3.ViewModel; +using BPASmartClient.Business; +using BPASmartClient.Model.小炒机; +using BPA.Models; +using System.Speech.Synthesis; +using System.Windows.Forms; +using System.Media; + +namespace BPASmartClient.MorkS3 +{ + public class Control_Morks : BaseDevice + { + public override DeviceClientType DeviceType => DeviceClientType.MORKS; + GVL_MORKS mORKS = new GVL_MORKS(); + Alarm alarm = new Alarm(); + + public override void DoMain() + { + MonitorViewModel.DeviceId = DeviceId; + ServerInit(); + DataParse(); + Json.Read(); + Json.Read(); + if (Json.Data.parSets == null) Json.Data.parSets = new ObservableCollection(); + if (Json.Data.parSets.Count < 6) + { + Json.Data.parSets.Clear(); + for (int i = 0; i < 6; i++) + { + Json.Data.parSets.Add(new ParSet() + { + CheckBoxContext = $"煮面口{i + 1}屏蔽", + Minute = 1, + Second = 0, + IsShield = false, + TextBlockContext = $"煮面口{i + 1}时间设定" + }); + } + } + + ActionManage.GetInstance.Register(new Action((o) => + { + if (o.Length > 0) + { + Random rd = new Random(); + ThreadManage.GetInstance().StartLong(new Action(() => + { + int NoodleLoc = (int)o[0] == 0 ? rd.Next(1, 6) : (int)o[0]; + int BowlLoc = (int)o[1] == 0 ? rd.Next(10, 12) : (int)o[1]; + + string guid = new Guid().ToString(); + + mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)NoodleLoc, SuborderId = guid }); + MessageLog.GetInstance.Show($"添加订单:面条位置【{NoodleLoc}】"); + + mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)BowlLoc, SuborderId = guid }); + MessageLog.GetInstance.Show($"添加订单:碗位置【{BowlLoc}】"); + Thread.Sleep(60000); + }), "ForOrder"); + } + }), "EnableForOrder"); + + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value); + }), "WriteVW"); + ActionManage.GetInstance.Register(new Action((o) => + { + if (o != null && o is WritePar writePar) WriteData(writePar.Address, writePar.Value); + }), "WriteBools"); + ActionManage.GetInstance.Register(new Action(() => { DeviceInit(); }), "InitDevice"); + } + + public override void ResetProgram() + { + mORKS = null; + mORKS = new GVL_MORKS(); + } + + public override void Stop() + { + + } + + private void ServerInit() + { + //物料信息 + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) + { + if (@event == null) return; + if (@event is MaterialDeliveryEvent material) + { + orderMaterialDelivery = material.orderMaterialDelivery; + } + }); + + //配方数据信息 + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack) + { + if (@event == null) return; + if (@event is RecipeBomEvent recipe) + { + recipeBoms = recipe.recipeBoms; + WriteRecipeBoms(); + } + }); + + + } + + private void OrderChange(string subid, ORDER_STATUS oRDER_STATUS) + { + var res = mORKS.doOrderEvents.FirstOrDefault(p => p.MorkOrder.SuborderId == subid); + string goodName = string.Empty; + string SortNum = string.Empty; + if (res != null) + { + goodName = res.MorkOrder.GoodsName; + SortNum = res.MorkOrder.SortNum.ToString(); + } + + EventBus.EventBus.GetInstance().Publish(new OrderStatusChangedEvent() { SortNum = SortNum, GoodName = goodName, Status = oRDER_STATUS, SubOrderId = subid, deviceClientType = DeviceType }); + + var index = DataServer.GetInstance.morkS.MakeOrder.FindIndex(p => p.SortNum == SortNum); + if (index >= 0 && index < DataServer.GetInstance.morkS.MakeOrder.Count) + { + if (oRDER_STATUS == ORDER_STATUS.COMPLETED_COOK) + { + DataServer.GetInstance.morkS.MakeOrder.RemoveAt(index); + DataServer.GetInstance.morkS.MakeOrderOver.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StopTime = DateTime.Now.ToString("HH:mm:ss") + }); + } + else if (oRDER_STATUS == ORDER_STATUS.COMPLETED_TAKE) + { + var temp = DataServer.GetInstance.morkS.MakeOrderOver.FirstOrDefault(p => p.SortNum == SortNum); + if (temp != null) DataServer.GetInstance.morkS.MakeOrderOver.Remove(temp); + } + else + { + DataServer.GetInstance.morkS.MakeOrder.ElementAt(index).Status = oRDER_STATUS; + } + } + else + { + DataServer.GetInstance.morkS.MakeOrder.Add(new OrderMakeModel() + { + Status = oRDER_STATUS, + GoodName = goodName, + SortNum = SortNum, + StartTime = DateTime.Now.ToString("HH:mm:ss") + }); + } + } + + private void GetStatus(string key, Action action) + { + if (peripheralStatus.ContainsKey(key)) + { + if (peripheralStatus[key] != null) + { + action?.Invoke(peripheralStatus[key]); + } + } + } + + public override void ReadData() + { + DataServer.GetInstance.morkS.Alarm.Clear(); + alarms.ForEach(item => + { + DataServer.GetInstance.morkS.Alarm.Add(new AlarmModel() + { + AlarmTime = $"{item.Date} {item.Time}", + AlarmMs = item.Info + }); + }); + + GetStatus("M230.0", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 24) + { + alarm.MachineLeftLowTemperature = bools[0]; + alarm.MachineRightLowTemperature = bools[1]; + alarm.Supply1_LossBowl = bools[2]; + alarm.Supply2_LossBowl = bools[3]; + alarm.Supply1_ErrorOutBowl = bools[4]; + alarm.Supply2_ErrorOutBowl = bools[5]; + alarm.PushBowlCylinderError = bools[6]; + alarm.NoodleMacCommunicateError = bools[7]; + alarm.DosingMacCommunicateError = bools[8]; + alarm.RobotMacCommunicateError = bools[9]; + alarm.DeviceEstop = bools[10]; + alarm.RobotInitError = bools[11]; + alarm.RobotUrgentStop = bools[12]; + alarm.RobotNotInRemoteMode = bools[13]; + alarm.RobotNotInReady = bools[14]; + alarm.RobotSelfInException = bools[15]; + alarm.LeftLackWater = bools[16]; + alarm.RightLackWater = bools[17]; + alarm.SvrewInitFail = bools[18]; + alarm.TurntableInitFail = bools[19]; + alarm.RobotInitFail = bools[20]; + alarm.NoodleCookerInitFail = bools[21]; + alarm.PushBowlInitFail1 = bools[22]; + alarm.PushBowlInitFail2 = bools[23]; + } + })); + + GetStatus("M0.3", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 3) + { + mORKS.RobotTakeNoodle = bools[0]; + mORKS.RobotOutMeal = bools[1]; + mORKS.MoveTurntable = bools[2]; + } + })); + + GetStatus("M100.0", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 16) + { + mORKS.InitComplete = bools[0]; + mORKS.TakeBowlIdle = bools[1]; + mORKS.TemperatureReached = bools[2]; + mORKS.AllowFallNoodle = bools[3]; + mORKS.RbTakeNoodleComplete = bools[4]; + mORKS.RbFallNoodleComplete = bools[5]; + mORKS.RbOutMealComplete = bools[6]; + mORKS.RobotIdle = bools[7]; + mORKS.TakeMealDetect = bools[8]; + mORKS.MissingBowl = bools[9]; + Initing = bools[10]; + mORKS.TurntableLowerLimit = bools[11]; + mORKS.MissingBowlSignal2 = bools[12]; + mORKS.TurntableUpLimit = bools[13]; + mORKS.FeedComplete = bools[14]; + mORKS.TurntableMoveInPlace = bools[15]; + DataServer.GetInstance.morkS.MorkS_Temp = mORKS.TemperatureReached; + DataServer.GetInstance.morkS.Morks_SiloMeasUp = mORKS.TurntableUpLimit; + DataServer.GetInstance.morkS.Morks_SiloMeasDown = mORKS.TurntableLowerLimit; + DataServer.GetInstance.morkS.MorkS_NoBowMeas1 = mORKS.MissingBowl; + DataServer.GetInstance.morkS.MorkS_NoBowMeas2 = mORKS.MissingBowlSignal2; + } + + })); + + GetStatus("M235.0", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 1) + { + mORKS.Error = bools[0]; + } + })); + + + GetStatus("M102.0", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 7) + { + for (int i = 0; i < 6; i++) + { + mORKS.NoodleCookerStatus[i] = bools[i]; + } + mORKS.Feeding = bools[6]; + } + })); + + GetStatus("M103.0", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 6) + { + for (int i = 0; i < 6; i++) + { + mORKS.CookNoodlesComplete[i] = bools[i]; + DataServer.GetInstance.morkS.Morks_NoodleUpOrDown[i] = bools[i]; + } + } + + })); + + GetStatus("VW372", new Action((obj) => + { + if (obj is ushort[] UshortValue && UshortValue.Length > 0 && UshortValue.Length <= 1) + mORKS.TurntableFeedbackloc = UshortValue[0]; + DataServer.GetInstance.morkS.MorkS_BinLocation = mORKS.TurntableFeedbackloc; + })); + + GetStatus("M0.1", new Action((obj) => + { + if (obj is bool[] bools && bools.Length > 0 && bools.Length <= 8) + { + for (int i = 0; i < 8; i++) + { + mORKS.InitComplete = bools[0]; + } + } + + })); + } + + /// + /// 数据解析 + /// + private void DataParse() + { + EventBus.EventBus.GetInstance().Subscribe(DeviceId, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + if (@event == null) return; + if (@event is DoOrderEvent order) + { + mORKS.doOrderEvents.Add(order); + if (order.MorkOrder.GoodBatchings == null) return; + if (mORKS.HistorySuborderId.Contains(order.MorkOrder.SuborderId)) return; + OrderCount++; + if (DateTime.Now.Subtract(Json.Data.StatisticsTime).Days != 0) + Json.Data.Count = 0; + Json.Data.StatisticsTime = DateTime.Now; + Json.Data.Count++; + Json.Save(); + OrderChange(order.MorkOrder.SuborderId, ORDER_STATUS.WAIT); + DeviceProcessLogShow($"接收到{OrderCount}次订单,订单ID:{order.MorkOrder.SuborderId}"); + mORKS.HistorySuborderId.Add(order.MorkOrder.SuborderId); + foreach (var item in order.MorkOrder.GoodBatchings) + { + var res = orderMaterialDelivery?.BatchingInfo?.FirstOrDefault(p => p.BatchingId == item.BatchingId); + if (res != null) + { + if (ushort.TryParse(res.BatchingLoc, out ushort loc)) + { + if (loc >= 1 && loc <= 5) + { + if (mORKS.RBTakeNoodleTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) + mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { GoodName = order.MorkOrder.GoodsName, Loc = ushort.Parse(res.BatchingLoc), SuborderId = order.MorkOrder.SuborderId, BatchingId = res.BatchingId }); + } + else if (loc >= 10 && loc <= 11) + { + int index = 0; + if (recipeBoms != null) + { + index = Array.FindIndex(recipeBoms.RecipeIds?.ToArray(), p => p.RecipeId == order.MorkOrder.RecipeId); + index++; + } + if (mORKS.TakeBowlTask.FirstOrDefault(p => p.SuborderId == order.MorkOrder.SuborderId) == null) + mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() + { + BatchingId = res.BatchingId, + GoodName = order.MorkOrder.GoodsName, + Loc = ushort.Parse(res.BatchingLoc), + SuborderId = order.MorkOrder.SuborderId, + RecipeNumber = (index >= 1 && index <= 10) ? (ushort)index : (ushort)0 + }); + } + } + } + } + } + }); + } + + public override void MainTask() + { + mORKS.AllowRun = mORKS.InitComplete; + if (Json.Data.IsVerify) + IsHealth = mORKS.Error && mORKS.InitComplete; + else + IsHealth = true; + + TakeBowlTask(); + + TakeNoodleTask(); + + OutNoodleTask(); + + SingleDetect(); + + TurntableControl(); + + var data = new List(); + for (int i = 0; i < Json.Data.parSets.Count; i++) + { + data.Add(Json.Data.parSets.ElementAt(i).IsShield); + } + + WriteControl("M260.0", data.ToArray()); + + } + + private void BowlControl(OrderLocInfo orderLocInfo) + { + if (orderLocInfo.Loc >= 10 && orderLocInfo.Loc <= 11) + { + mORKS.TakeBowlId = orderLocInfo.SuborderId; + mORKS.TakeBowName = orderLocInfo.GoodName; + TakeBowlControl(orderLocInfo.Loc); + SetRecipeNumber(orderLocInfo.RecipeNumber); + OrderChange(mORKS.TakeBowlId, ORDER_STATUS.COOKING); + DeviceProcessLogShow($"订单【{ mORKS.TakeBowlId}】执行取碗控制,位置:[{orderLocInfo.Loc}]"); + mORKS.TakeBowlInterlock = true; + } + } + + /// + /// 取碗控制 + /// + private void TakeBowlTask() + { + if (mORKS.AllowRun && mORKS.TakeBowlTask.Count > 0 && !mORKS.TakeBowlIdle && !mORKS.TakeBowlInterlock) + { + DeviceProcessLogShow("开始取碗流程"); + ushort BowLoc = 0; + var res = orderMaterialDelivery?.BatchingInfo?.Where(p => p.BatchingId == mORKS.TakeBowlTask.ElementAt(0).BatchingId).ToList(); + if (res == null || res?.Count == 0) + { + if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo)) BowlControl(orderLocInfo); + } + else + { + foreach (var item in res) + { + if (ushort.TryParse(item.BatchingLoc, out ushort loc)) + { + //DeviceProcessLogShow($"位置:={loc},检测开关1:{alarm.Supply1_LossBowl},检测开关1:{alarm.Supply2_LossBowl}"); + if (loc == 10 && !alarm.Supply1_LossBowl) + { + BowLoc = loc; + break; + } + else if (loc == 11 && !alarm.Supply2_LossBowl) + { + BowLoc = loc; + break; + } + } + } + + if (BowLoc >= 10 && BowLoc <= 11) + { + if (mORKS.TakeBowlTask.TryDequeue(out OrderLocInfo orderLocInfo)) + { + orderLocInfo.Loc = BowLoc; + BowlControl(orderLocInfo); + } + } + } + } + } + + /// + /// 转台控制 + /// + private void TurntableControl() + { + if (Global.EnableLocalSimOrder) + { + //不做轮询,直接取面,模拟订单使用 + if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) + { + if (mORKS.TurntableLowerLimit) + { + TurntableStart(mORKS.RBTakeNoodleTask.ElementAt(0).Loc); + mORKS.TurntableLocLists.Clear(); + mORKS.AllowTakeNoodle = true; + DeviceProcessLogShow($"控制机器人去转台【{mORKS.RBTakeNoodleTask.ElementAt(0).Loc}】号位置取面"); + } + } + } + else + { + //正常轮询 + if (mORKS.TurntableMoveInPlace && !mORKS.Feeding && mORKS.InitComplete && !mORKS.AllowTakeNoodle && mORKS.RBTakeNoodleTask.Count > 0) + { + var result = orderMaterialDelivery.BatchingInfo.Where(p => p.BatchingId == mORKS.RBTakeNoodleTask.ElementAt(0).BatchingId).ToList(); + if (result != null) + { + var res = result.FirstOrDefault(P => P.BatchingLoc == mORKS.TurntableFeedbackloc.ToString()); + if (mORKS.TurntableLowerLimit && res != null) + { + TurntableStart(mORKS.TurntableFeedbackloc); + mORKS.TurntableLocLists.Clear(); + mORKS.AllowTakeNoodle = true; + DeviceProcessLogShow($"控制机器人去转台【{mORKS.TurntableFeedbackloc}】号位置取面"); + } + else + { + if (!mORKS.TurntableInterlock) + { + foreach (var item in result) + { + if (ushort.TryParse(item.BatchingLoc, out ushort loc)) + { + if (mORKS.TurntableFeedbackloc != loc && !mORKS.TurntableLocLists.Contains(loc)) + { + if (!mORKS.TurntableLowerLimit) + { + WriteData("M32.7", false); + DeviceProcessLogShow($"执行了转台启动互锁信号复位"); + } + TurntableStart(loc); + DeviceProcessLogShow($"没有物料检测的启动转台控制,转台位置:[{loc}]"); + break; + } + else if (mORKS.TurntableFeedbackloc == loc && !mORKS.TurntableLocLists.Contains(loc)) mORKS.TurntableLocLists.Add(loc); + } + } + } + } + } + else DeviceProcessLogShow("未找到可用的物料信息"); + } + } + + //if (DelayRTrig.GetInstance("互锁信号复位").Start(!mORKS.TurntableLowerLimit && mORKS.TurntableMoveInPlace, 2)) + //{ + // if (!mORKS.TurntableLowerLimit) + // { + // WriteData("M32.7", false); + // DeviceProcessLogShow($"执行了转台启动互锁信号复位"); + // } + //} + + //补料中检测 + if (RTrig.GetInstance("mORKS.Feeding").Start(mORKS.Feeding)) + { + mORKS.AllowTakeNoodle = false; + mORKS.TakeNoodleInterlock = false; + } + + //转台到位检测 + if (RTrig.GetInstance("TurntableInPlace").Start(mORKS.TurntableMoveInPlace && mORKS.CurrentLoc == mORKS.TurntableFeedbackloc)) + { + mORKS.CurrentLoc = 0; + mORKS.TurntableInterlock = false; + DeviceProcessLogShow("转台到位检测"); + } + + //补料完成检测 + if (RTrig.GetInstance("FeedComplete").Start(mORKS.FeedComplete)) + { + if (!mORKS.AllowTakeNoodle && mORKS.TurntableLocLists.Count > 0) + { + mORKS.TurntableLocLists.Clear(); + mORKS.TurntableInterlock = false; + DeviceProcessLogShow("补料完成检测"); + } + } + + } + + /// + /// 取面任务 + /// + private void TakeNoodleTask() + { + //取面控制 + if (mORKS.AllowRun && mORKS.RobotIdle && !mORKS.Feeding && !mORKS.RobotTaskInterlock && mORKS.AllowTakeNoodle && mORKS.TurntableMoveInPlace && !mORKS.TakeNoodleInterlock && !mORKS.OutNoodleing && mORKS.RBTakeNoodleTask.Count > 0) + { + int loc = Array.FindIndex(mORKS.NoodleCookerStatus, p => p == false);//查找煮面炉空闲位置 + if (loc >= 0 && loc <= 5) + { + if (mORKS.RBTakeNoodleTask.TryDequeue(out OrderLocInfo orderLocInfo)) + { + mORKS.CookNodelId[loc] = orderLocInfo.SuborderId; + SetFallNoodleLoc((ushort)(loc + 1)); + //机器人开始取面 + RobotTakeNoodle(); + OrderChange(orderLocInfo.SuborderId, ORDER_STATUS.COOKING); + DeviceProcessLogShow($"订单【{orderLocInfo.SuborderId}】,机器人倒面至【{loc + 1}】号煮面栏"); + //写入煮面时间 + List values = new List(); + values.Add(Json.Data.parSets.ElementAt(loc).Minute); + values.Add(Json.Data.parSets.ElementAt(loc).Second); + WriteData($"VW{116 + (loc * 6)}", values.ToArray()); + mORKS.TakeNoodleInterlock = true; + } + } + } + } + + /// + /// 出餐控制 + /// + private void OutNoodleTask() + { + if (mORKS.AllowFallNoodle && mORKS.RobotTaskInterlock && !mORKS.TakeNoodleInterlock && mORKS.RobotIdle && !mORKS.TakeMealDetect) + { + int loc = Array.FindIndex(mORKS.CookNodelId, p => p == mORKS.IngredientsCompleteId && p.Length > 0); + if (loc >= 0 && loc <= 5) + { + if (mORKS.CookNoodlesComplete[loc]) + { + SetTakeNoodleLoc((ushort)(loc + 1)); + RobotOutMeal(); + CookNoodleStatusReset((ushort)(loc + 1)); + ResetAllowFallNoodle(); + + + //新增,待测试 + if (mORKS.RbOutMealComplete) + { + ResetCookComplete(); + mORKS.CookCompleteFlatBit = false; + DeviceProcessLogShow("取餐过程中复位出餐完成信号"); + } + + if (!string.IsNullOrEmpty(mORKS.OutMealId)) OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE); + mORKS.OutMealId = mORKS.IngredientsCompleteId; + mORKS.OutMealName = mORKS.IngredientsCompleteName; + mORKS.IngredientsCompleteId = string.Empty; + mORKS.CookNodelId[loc] = string.Empty; + DeviceProcessLogShow($"{loc + 1} 号位置出餐控制,订单ID:{ mORKS.OutMealId}"); + + mORKS.OutNoodleing = true; + } + } + } + } + + /// + /// 信号检测 + /// + private void SingleDetect() + { + //允许倒面信号检测 + if (RTrig.GetInstance("AllowFallNoodle").Start(mORKS.AllowFallNoodle)) + { + mORKS.IngredientsCompleteId = mORKS.TakeBowlId; + mORKS.IngredientsCompleteName = mORKS.TakeBowName; + mORKS.TakeBowlId = string.Empty; + mORKS.TakeBowName = string.Empty; + DeviceProcessLogShow($"碗到位,允许到面,{mORKS.IngredientsCompleteId}"); + mORKS.TakeBowlInterlock = false; + } + + //出餐完成信号检测 + if (RTrig.GetInstance("CompleteChange").Start(mORKS.RbOutMealComplete)) + { + OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_COOK); + DeviceProcessLogShow($"订单【{mORKS.OutMealId}】制作完成"); + mORKS.CookCompleteFlatBit = true; + mORKS.OutNoodleing = false; + WaitMeaLSpeak(mORKS.OutMealName); + } + + //取餐完成逻辑处理 + if (Delay.GetInstance("CompleteChange1").Start(!mORKS.TakeMealDetect, 1) && mORKS.CookCompleteFlatBit == true) + { + OrderChange(mORKS.OutMealId, ORDER_STATUS.COMPLETED_TAKE); + DeviceProcessLogShow($"订单【{mORKS.OutMealId}】取餐完成"); + ResetCookComplete(); + mORKS.CookCompleteFlatBit = false; + mORKS.OutMealId = string.Empty; + mORKS.OutMealName = string.Empty; + } + + //机器人取面完成信号检测 + if (RTrig.GetInstance("TakeNoodleComplete").Start(mORKS.RbTakeNoodleComplete)) + { + mORKS.TakeNoodleInterlock = false; + mORKS.AllowTakeNoodle = false; + mORKS.TurntableInterlock = false; + DeviceProcessLogShow("机器人取面完成信号检测"); + TakeNoodleCompleteReset(); + } + + int OutMealRequstCount = mORKS.CookNoodlesComplete.Where(p => p == true).ToList().Count; + int mlCount = mORKS.NoodleCookerStatus.Where(p => p == true).ToList().Count; + int index = Array.FindIndex(mORKS.CookNodelId, p => p == mORKS.IngredientsCompleteId); + + bool isok = index >= 0 && index < mORKS.CookNoodlesComplete.Length && mORKS.CookNoodlesComplete[index]; + + mORKS.PriorityJudgment = Delay.GetInstance("取餐优先级判断").Start(mORKS.TurntableLocLists.Count > 0 && !mORKS.TurntableLowerLimit, 4); + //mORKS.RobotTaskInterlock = OutMealRequstCount > 0 && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment); + mORKS.RobotTaskInterlock = isok && mORKS.AllowFallNoodle && (mlCount >= 2 || mORKS.RBTakeNoodleTask.Count == 0 || mORKS.PriorityJudgment); + + + } + /// + /// 语音提醒取餐 + /// + /// + private void WaitMeaLSpeak(string meal) + { + VoiceAPI.m_SystemPlayWav(@"Vioce\电子提示音.wav"); + Thread.Sleep(1000); + if (meal != null) mORKS.speech.Speak(meal); + VoiceAPI.m_SystemPlayWav(@"Vioce\取餐通知.wav"); + } + + #region PLC 控制函数 + + private void WriteData(string address, object value) + { + EventBus.EventBus.GetInstance().Publish(new WriteModel() { DeviceId = DeviceId, Address = address, Value = value }); + } + + /// + /// 写入配方数据到 PLC + /// + private void WriteRecipeBoms() + { + List recipeBoms = new List(); + if (this.recipeBoms == null) return; + foreach (var item in this.recipeBoms.RecipeIds) + { + foreach (var rec in item.Recipes) + { + recipeBoms.Add((ushort)rec); + } + } + if (recipeBoms.Count > 0) + { + //配方数据地址范围:VW2000 - VW2278 + WriteData("VW2000", recipeBoms.ToArray()); + DeviceProcessLogShow("写配方成功"); + } + else { DeviceProcessLogShow("配方数据为空"); } + } + + + /// + /// 取面完成复位 + /// + private void TakeNoodleCompleteReset() + { + WriteData("M100.4", false); + + } + + /// + /// 指定煮面口状态复位 + /// + /// + private void CookNoodleStatusReset(int num) + { + if (num >= 1 && num <= 6) + { + WriteData($"102.{num - 1}", false); + DeviceProcessLogShow($"{num}号煮面口占用复位"); + } + + } + + /// + /// 写配方编号 + /// + /// + private void SetRecipeNumber(ushort num) + { + WriteData("VW0", num); + } + + /// + /// 启动转台 + /// + /// + private void TurntableStart(ushort loc) + { + mORKS.CurrentLoc = loc; + mORKS.TurntableInterlock = true; + mORKS.TurntableLocLists.Add(loc); + WriteData("VW2", loc); + WriteData("M0.5", true); + } + + /// + /// 设置倒面位置 + /// + /// + private void SetFallNoodleLoc(ushort loc) + { + WriteData("VW4", loc); + } + + /// + /// 设置取面位置 + /// + /// + private void SetTakeNoodleLoc(ushort loc) + { + WriteData("VW6", loc); + } + + /// + /// 取碗控制 + /// + /// + private void TakeBowlControl(ushort loc) + { + if (loc == 10)//小碗 + { + WriteData("M0.1", true); + } + else if (loc == 11)//大碗 + { + WriteData("M0.2", true); + } + } + + /// + /// 机器人取面 + /// + private void RobotTakeNoodle() + { + WriteData("M0.3", true); + } + + /// + /// 机器人取餐 + /// + private void RobotOutMeal() + { + WriteData("M0.4", true); + } + + /// + /// 制作完成信号复位 + /// + private void ResetCookComplete() + { + WriteData("M100.6", false); + } + + /// + /// 复位允许取面信号 + /// + private void ResetAllowFallNoodle() + { + WriteData("M100.3", false); + } + + /// + /// 设备初始化 + /// + public async void DeviceInit() + { + WriteData("M0.0", true); + await Task.Delay(1000); + WriteData("M0.0", false); + } + + public override void SimOrder() + { + EventBus.EventBus.GetInstance().Subscribe(0, delegate (IEvent @event, EventCallBackHandle callBackHandle) + { + if (@event != null && @event is MorksSimorderModel msm) + { + string guid = Guid.NewGuid().ToString(); + if (msm.NoodleLoc >= 1 && msm.NoodleLoc <= 5) + { + mORKS.RBTakeNoodleTask.Enqueue(new OrderLocInfo() { Loc = (ushort)msm.NoodleLoc, SuborderId = guid }); + MessageLog.GetInstance.Show($"添加订单:面条位置【{(ushort)msm.NoodleLoc}】"); + } + + if (msm.Bowloc >= 10 && msm.Bowloc <= 11) + { + mORKS.TakeBowlTask.Enqueue(new OrderLocInfo() { Loc = (ushort)msm.Bowloc, SuborderId = guid }); + MessageLog.GetInstance.Show($"添加订单:碗位置【{(ushort)msm.Bowloc}】"); + } + + } + }); + } + #endregion + + + } +} diff --git a/BPASmartClient.MorkS3/DataServer.cs b/BPASmartClient.MorkS3/DataServer.cs new file mode 100644 index 00000000..22062658 --- /dev/null +++ b/BPASmartClient.MorkS3/DataServer.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using BPA.Helper; +using BPASmartClient.MQTT; +using BPA.Message; +using BPASmartClient.Model; + +namespace BPASmartClient.MorkS3 +{ + public class DataServer + { + + private volatile static DataServer _Instance; + public static DataServer GetInstance => _Instance ?? (_Instance = new DataServer()); + private DataServer() { } + + public ScreenModelMorkS morkS { get; set; } = new ScreenModelMorkS(); + + MQTTProxy mQTTProxy = new MQTTProxy(); + public void Init() + { + mQTTProxy.Connected = new Action(() => + { + mQTTProxy.Subscrib(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机)); + ThreadManage.GetInstance().StartLong(new Action(() => + { + morkS.MorkS_OrderCount = Json.Data.Count; + SendScreenDataModel sendScreenDataModel = new SendScreenDataModel(); + sendScreenDataModel.Name = ScreenDeviceType.煮面机; + sendScreenDataModel.Value = morkS.ToJSON(); + mQTTProxy.Publish(ScreenTOPIC.GetInstance.GetTopic(ScreenDeviceType.煮面机), sendScreenDataModel.ToJSON()); + Thread.Sleep(100); + }), "海科食堂大屏监听"); + }); + mQTTProxy.Connect("UserName", "Password", "Host", 1883, $"MORKS 设备监听数据{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); + } + + //订单信息(正在制作,等待制作,制作完成) + //煮面炉上下状态(6个煮面炉上或下) + //温度状态(煮面炉温度是否到达) + //料仓位置(当前料仓在几号位置) + //料仓上下物料检测 + //落碗机构缺碗检测 + //机器人状态 + //当日订单总量 + //报警信息 + } +} diff --git a/BPASmartClient.MorkS3/GVL_MORKS.cs b/BPASmartClient.MorkS3/GVL_MORKS.cs new file mode 100644 index 00000000..9176e7be --- /dev/null +++ b/BPASmartClient.MorkS3/GVL_MORKS.cs @@ -0,0 +1,376 @@ +using BPASmartClient.Device; +using BPASmartClient.Model; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Speech.Synthesis; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkS3 +{ + public class GVL_MORKS : IStatus + { + public List HistorySuborderId { get; set; } = new List(); + /// + /// 机器人取面 + /// PLC -> M0.3 + /// ModbusTcp -> 323 + /// + public bool RobotTakeNoodle { get; set; } + + /// + /// 机器人出餐 + /// PLC -> M0.4 + /// ModbusTcp -> 324 + /// + public bool RobotOutMeal { get; set; } + + /// + /// 移动转台 + /// PLC -> M0.5 + /// ModbusTcp -> 325 + /// + public bool MoveTurntable { get; set; } + + + #region 临时变量 + /// + /// 允许运行 + /// + //[Circuit(new string[] { "机器人取面", "取碗控制" }, "允许运行")] + [VariableMonitor("允许运行")] + public bool AllowRun { get; set; } + + /// + /// 优先级判断 + /// + [VariableMonitor("优先级判断条件")] + public bool PriorityJudgment { get; set; } + + /// + /// 机器人任务互锁信号,false:取面,true:出餐 + /// + //[Circuit(new string[] { "机器人取面", "出面控制" }, "机器人互锁", new bool[] { true, false })] + [VariableMonitor("机器人任务互锁信号")] + public bool RobotTaskInterlock { get; set; } + + /// + /// 取碗互锁信号 + /// + //[Circuit("取碗控制", "取碗互锁", true)] + [VariableMonitor("取碗互锁信号")] + public bool TakeBowlInterlock { get; set; } + + /// + /// 取面互锁信号 + /// + //[Circuit(new string[] { "机器人取面", "出面控制" }, "取面互锁信号", new bool[] { true, true })] + [VariableMonitor("取面互锁信号")] + public bool TakeNoodleInterlock { get; set; } + + /// + /// 出面中 + /// + //[Circuit("机器人取面", "出面中", true)] + [VariableMonitor("出面中")] + public bool OutNoodleing { get; set; } + + /// + /// 允许取面 + /// + //[Circuit(new string[] { "转台控制", "机器人取面" }, "允许取面", new bool[] { true, false })] + [VariableMonitor("允许取面")] + public bool AllowTakeNoodle { get; set; } + + /// + /// 转台互锁信号 + /// + [VariableMonitor("转台互锁信号")] + public bool TurntableInterlock { get; set; } + #endregion + + /// + /// 初始化完成 + /// PLC -> M100.0 + /// ModbusTcp -> 1120 + /// + //[Circuit(new string[] { "允许运行", "转台控制", "转台控制" }, "初始化完成")] + [VariableMonitor("初始化完成", "M100.0", "1120")] + public bool InitComplete { get; set; } + + /// + /// 取碗机构空闲,True:忙碌,false:空闲 + /// PLC -> M100.1 + /// ModbusTcp -> 1121 + /// + //[Circuit("取碗控制", "取碗机构空闲", true)] + [VariableMonitor("取碗机构空闲", "M100.1", "1121")] + public bool TakeBowlIdle { get; set; } + + /// + /// 温度到达,True:表示到达,false:未到达 + /// PLC -> M100.2 + /// ModbusTcp -> 1122 + /// + //[Circuit("允许运行", "温度到达")] + [VariableMonitor("温度到达", "M100.2", "1122")] + public bool TemperatureReached { get; set; } + + /// + /// 允许到面,配料完成 + /// PLC -> M100.3 + /// ModbusTcp -> 1123 + /// + //[Circuit("出面控制", "允许到面")] + [VariableMonitor("允许到面", "M100.3", "1123")] + public bool AllowFallNoodle { get; set; } + + /// + /// 机器人取面完成 + /// PLC -> M100.4 + /// ModbusTcp -> 1124 + /// + [VariableMonitor("机器人取面完成", "M100.4", "1124")] + public bool RbTakeNoodleComplete { get; set; } + + /// + /// 机器人倒面完成 + /// PLC -> M100.5 + /// ModbusTcp -> 1125 + /// + [VariableMonitor("机器人倒面完成", "M100.5", "1125")] + public bool RbFallNoodleComplete { get; set; } + + /// + /// 机器人出餐完成,上报取餐完成 + /// PLC -> M100.6 + /// ModbusTcp -> 1126 + /// + [VariableMonitor("机器人出餐完成", "M100.6", "1126")] + public bool RbOutMealComplete { get; set; } + + /// + /// 机器人空闲 + /// PLC -> M100.7 + /// ModbusTcp -> 1127 + /// + //[Circuit(new string[] { "机器人取面", "出面控制" }, "机器人空闲")] + [VariableMonitor("机器人空闲", "M100.7", "1127")] + public bool RobotIdle { get; set; } + + /// + /// 取餐口检测 + /// PLC -> M101.0 + /// ModbusTcp -> 1128 + /// + //[Circuit("出面控制", "取餐口检测", true)] + [VariableMonitor("取餐口检测", "M101.0", "1128")] + public bool TakeMealDetect { get; set; } + + /// + /// 缺碗信号,false:缺碗,true:有碗 + /// PLC -> M101.1 + /// ModbusTcp -> 1129 + /// + [VariableMonitor("缺碗信号", "M101.1", "1129")] + public bool MissingBowl { get; set; } + + /// + /// 设备初始化中,执行中等于1,2秒后复位 + /// PLC -> M101.2 + /// ModbusTcp -> 1130 + /// + [VariableMonitor("设备初始化中", "M101.2", "1130")] + public bool DeviceIniting { get; set; } + + /// + /// 转台下限检测 + /// PLC -> M101.3 + /// ModbusTcp -> 1131 + /// + //[Circuit("转台控制", "转台下限检测有物料")] + [VariableMonitor("转台下限检测", "M101.3", "1131")] + public bool TurntableLowerLimit { get; set; } + + /// + /// 缺碗信号 2 + /// PLC -> M101.4 + /// ModbusTcp -> 1132 + /// + [VariableMonitor("缺碗信号 2", "M101.4", "1132")] + public bool MissingBowlSignal2 { get; set; } + + /// + /// 转台上限检测 + /// PLC -> M101.5 + /// ModbusTcp -> 1133 + /// + [VariableMonitor("转台上限检测", "M101.5", "1133")] + public bool TurntableUpLimit { get; set; } + + /// + /// 补料完成 + /// PLC -> M101.6 + /// ModbusTcp -> 1134 + /// + [VariableMonitor("补料完成", "M101.6", "1134")] + public bool FeedComplete { get; set; } + + /// + /// 转台移动到位 + /// PLC -> M101.7 + /// ModbusTcp -> 1135 + /// + //[Circuit(new string[] { "转台控制", "机器人取面" }, "转台移动到位")] + [VariableMonitor("转台移动到位", "M101.7", "1135")] + public bool TurntableMoveInPlace { get; set; } + + /// + /// 煮面炉状态,True:忙碌,false:空闲 + /// M102.0 - M102.5 + /// 1136 - 1141 + /// + [VariableMonitor("煮面炉状态", "M102.0", "1136")] + public bool[] NoodleCookerStatus { get; set; } = new bool[6] { false, false, false, false, false, false }; + + /// + /// 补料中 + /// M102.6 + /// 1142 + /// + [VariableMonitor("补料中", "M102.6", "1142")] + public bool Feeding { get; set; } + + /// + /// 煮面完成,上升后给信号 + /// M103.0 - M103.5 + /// 1144 - 1149 + /// + [VariableMonitor("煮面完成", "M103.0", "1144")] + public bool[] CookNoodlesComplete { get; set; } = new bool[6] { false, false, false, false, false, false }; + + /// + /// 硬件设备异常 + /// PLC -> M235.0 + /// True:设备正常,False:设备异常 + /// + [VariableMonitor("硬件设备异常", "M235.0", "")] + public bool Error { get; set; } = false; + + /// + /// 配方编号 + /// PLC -> VW0 + /// ModbusTcp -> 100 + /// + [VariableMonitor("配方编号", "VW0", "100")] + public ushort RecipeNumber { get; set; } + + /// + /// 转台设置位置 + /// PLC -> VW2 + /// ModbusTcp -> 101 + /// + [VariableMonitor("转台设置位置", "VW2", "101")] + public ushort TurntableLoc { get; set; } + + /// + /// 到面至煮面炉位置 + /// PLC -> VW4 + /// ModbusTcp -> 102 + /// + [VariableMonitor("到面至煮面炉位置", "VW4", "102")] + public ushort FallNoodleLoc { get; set; } + + /// + /// 取面位置 + /// PLC -> VW6 + /// ModbusTcp -> 103 + /// + [VariableMonitor("取面位置", "VW6", "103")] + public ushort TakeNoodleLoc { get; set; } + + /// + /// 转台反馈位置 + /// PLC -> VW372 + /// ModbusTcp -> 286 + /// + [VariableMonitor("转台反馈位置", "VW372", "286")] + public ushort TurntableFeedbackloc { get; set; } + + /// + /// 机器人取面位置队列 + /// + //[Circuit(new string[] { "转台控制", "机器人取面" }, "有机器人取面队列")] + public ConcurrentQueue RBTakeNoodleTask { get; set; } = new ConcurrentQueue(); + + /// + /// 出碗队列 + /// + //[Circuit("取碗控制", "有取碗队列数量")] + public ConcurrentQueue TakeBowlTask { get; set; } = new ConcurrentQueue(); + + public List doOrderEvents { get; set; } = new List(); + + /// + /// 是否有面条 + /// + public bool IsNoodles { get; set; } = true; + + /// + /// 制作完成标志 + /// + [VariableMonitor("制作完成标志")] + public bool CookCompleteFlatBit { get; set; } + + + #region 订单ID记录 + /// + /// 取碗订单ID + /// + public string TakeBowlId = string.Empty; + /// + /// 取碗订单名称 + /// + public string TakeBowName = string.Empty; + + /// + /// 配料完成订单ID + /// + public string IngredientsCompleteId = string.Empty; + /// + /// 配料完成订单名称 + /// + public string IngredientsCompleteName = string.Empty; + + /// + /// 煮面口对应的订单ID + /// + public string[] CookNodelId = new string[6] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, }; + + /// + /// 出餐订单ID + /// + public string OutMealId = string.Empty; + /// + /// 出餐订单名称 + /// + public string OutMealName = string.Empty; + + /// + /// 转台位置轮询 + /// + public List TurntableLocLists = new List(); + + /// + /// 转台当前启动位置 + /// + [VariableMonitor("转台当前启动位置")] + public ushort CurrentLoc { get; set; } = 0; + + public SpeechSynthesizer speech = new SpeechSynthesizer(); + + #endregion + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs b/BPASmartClient.MorkS3/Model/Global.cs similarity index 52% rename from BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs rename to BPASmartClient.MorkS3/Model/Global.cs index e083e60c..35819695 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/HK_PLC/PlcWriteAddressDB7.cs +++ b/BPASmartClient.MorkS3/Model/Global.cs @@ -4,10 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC +namespace BPASmartClient.MorkS3.Model { - public class PlcWriteAddressDB7 + public class Global { - + public static bool EnableLocalSimOrder { get; set; } } } diff --git a/BPASmartClient.MorkS3/Model/MorksPar.cs b/BPASmartClient.MorkS3/Model/MorksPar.cs new file mode 100644 index 00000000..5d499d39 --- /dev/null +++ b/BPASmartClient.MorkS3/Model/MorksPar.cs @@ -0,0 +1,16 @@ +using BPASmartClient.Model; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; + +namespace BPASmartClient.MorkS3.Model +{ + internal class MorksPar + { + public ObservableCollection parSets { get; set; } = new ObservableCollection(); + } +} diff --git a/BPASmartClient.MorkS3/Model/ParSet.cs b/BPASmartClient.MorkS3/Model/ParSet.cs new file mode 100644 index 00000000..03261db1 --- /dev/null +++ b/BPASmartClient.MorkS3/Model/ParSet.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.Model +{ + public class ParSet + { + public ushort Minute { get { return _mMinute; } set { _mMinute = value; } } + private ushort _mMinute; + + public ushort Second { get { return _mSecond; } set { _mSecond = value; } } + private ushort _mSecond; + + + public bool IsShield { get { return _mIsShield; } set { _mIsShield = value; } } + private bool _mIsShield; + + + public string TextBlockContext { get { return _mTextBlockContext; } set { _mTextBlockContext = value; } } + private string _mTextBlockContext; + + public string CheckBoxContext { get { return _mCheckBoxContext; } set { _mCheckBoxContext = value; } } + private string _mCheckBoxContext; + + } +} diff --git a/BPASmartClient.MorkS3/Model/WritePar.cs b/BPASmartClient.MorkS3/Model/WritePar.cs new file mode 100644 index 00000000..24210bd8 --- /dev/null +++ b/BPASmartClient.MorkS3/Model/WritePar.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkS3.Model +{ + public class WritePar + { + public string Address { get; set; } + public object Value { get; set; } + } +} diff --git a/BPASmartClient.MorkS3/OrderLocInfo.cs b/BPASmartClient.MorkS3/OrderLocInfo.cs new file mode 100644 index 00000000..da71841a --- /dev/null +++ b/BPASmartClient.MorkS3/OrderLocInfo.cs @@ -0,0 +1,23 @@ +using BPA.Message; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.MorkS3 +{ + public class OrderLocInfo + { + public string SuborderId { get; set; } + public ushort Loc { get; set; } + public ushort RecipeNumber { get; set; } + public int BatchingId { get; set; } + public string GoodName { get; set; } + + public int RecipeId { get; set; } + + public List Recipes { get; set; } + + } +} diff --git a/BPASmartClient.MorkS3/View/Debug.xaml b/BPASmartClient.MorkS3/View/Debug.xaml new file mode 100644 index 00000000..2f29c0ab --- /dev/null +++ b/BPASmartClient.MorkS3/View/Debug.xaml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +