From 52e6aac717517fb02b8d6ddadb5f7f521ab989ca Mon Sep 17 00:00:00 2001 From: pengliangyang <1406009520@qq.com> Date: Sun, 15 Jan 2023 17:16:06 +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.JXJFoodBigStation/App.config | 2 + BPASmartClient.JXJFoodBigStation/App.xaml.cs | 6 + .../BPASmartClient.JXJFoodBigStation.csproj | 1 + .../Model/GVL_BigStation.cs | 31 +- .../Model/HK_PLC/DB_Write.cs | 5 +- .../Model/HK_PLC/HKDeviceStatus.cs | 12 +- .../Model/ProcessControl.cs | 494 ++++++++++++++---- .../Model/RawMaterial/RawMaterialData.cs | 16 + .../Model/RawMaterial/RecipeData.cs | 2 + .../Model/Siemens/DL_Start_DB.cs | 8 + .../Model/Siemens/SiemensDeviceStatus.cs | 92 +++- .../View/ManualFlowView.xaml | 12 +- .../View/StockBinRawMaterialView.xaml | 22 +- .../ViewModel/HKPlcCommMonitorViewModel.cs | 4 +- .../ViewModel/HardwareStatusViewModel.cs | 1 - .../ViewModel/ManualFlowViewModel.cs | 6 + .../ViewModel/StockBinRawMaterialViewModel.cs | 36 +- .../App.xaml.cs | 21 +- .../BPASmartClient.JXJFoodSmallStation.csproj | 7 + .../Model/GVL_SmallStation.cs | 3 + .../Model/ProcessControl.cs | 484 +++++++++-------- .../Model/RawMaterial/DeviceInquire.cs | 2 +- .../Model/Siemens/SiemensDeviceStatus.cs | 9 +- .../Model/Siemens/XL_Start_DB.cs | 2 + .../Model/VarMonitor.cs | 32 ++ .../View/ManualCommView.xaml | 25 +- .../View/ManualFlowView.xaml | 9 + .../View/RobotView.xaml | 349 +++++++++++++ .../View/RobotView.xaml.cs | 28 + .../ViewModel/ManualCommViewModel.cs | 28 +- .../ViewModel/ManualControlViewModel.cs | 2 +- .../ViewModel/ManualFlowViewModel.cs | 6 +- .../ViewModel/RecipeControlViewModel.cs | 2 +- .../ViewModel/RobotViewModel.cs | 45 ++ BPASmartClient.MorkBF/Control_MorkBF.cs | 2 - BPASmartClient.MorkBF/GVL_MorkBF.cs | 160 +++++- BPASmartClient.S7Net/EntityClassResolution.cs | 7 +- DosingSystem/App.xaml.cs | 6 +- DosingSystem/App1.config | 6 + DosingSystem/Model/DeviceInquire.cs | 19 +- DosingSystem/Model/RecipeModel.cs | 1 - DosingSystem/Service/SiemensDevice.cs | 46 +- .../ViewModel/DeviceMaterialParViewModel.cs | 50 +- .../ViewModel/HardwareStatusViewModel.cs | 2 +- .../ViewModel/ManualControlViewModel.cs | 2 +- .../ViewModel/RecipeControlViewModel.cs | 459 +++++++++------- 46 files changed, 1861 insertions(+), 703 deletions(-) create mode 100644 BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialData.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/Model/VarMonitor.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml create mode 100644 BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml.cs create mode 100644 BPASmartClient.JXJFoodSmallStation/ViewModel/RobotViewModel.cs create mode 100644 DosingSystem/App1.config diff --git a/BPASmartClient.JXJFoodBigStation/App.config b/BPASmartClient.JXJFoodBigStation/App.config index 3559a687..35b80a6d 100644 --- a/BPASmartClient.JXJFoodBigStation/App.config +++ b/BPASmartClient.JXJFoodBigStation/App.config @@ -3,5 +3,7 @@ + + \ No newline at end of file diff --git a/BPASmartClient.JXJFoodBigStation/App.xaml.cs b/BPASmartClient.JXJFoodBigStation/App.xaml.cs index 6c3282c2..fc562273 100644 --- a/BPASmartClient.JXJFoodBigStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodBigStation/App.xaml.cs @@ -13,6 +13,7 @@ using BPASmartClient.CustomResource.Pages.View; using BPASmartClient.CustomResource.Pages.ViewModel; using BPASmartClient.Helper; using BPASmartClient.JXJFoodBigStation.Model; +using BPASmartClient.JXJFoodBigStation.Model.Siemens; namespace BPASmartClient.JXJFoodBigStation { @@ -53,6 +54,9 @@ namespace BPASmartClient.JXJFoodBigStation protected override void OnExit(ExitEventArgs e) { + Json.Save(); + Json.Save(); + Json.Save(); base.OnExit(e); MessageNotify.GetInstance.LogSave(); ThreadManage.GetInstance().Dispose(); @@ -217,6 +221,8 @@ namespace BPASmartClient.JXJFoodBigStation //Config.GetInstance.Init(); //Json.Read(); Json.Read(); + Json.Read(); + Json.Read(); } } diff --git a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj index bbf2290a..6a9d7c00 100644 --- a/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj +++ b/BPASmartClient.JXJFoodBigStation/BPASmartClient.JXJFoodBigStation.csproj @@ -5,6 +5,7 @@ net6.0-windows enable true + hbl.ico diff --git a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs index 2cd82517..6e2d1570 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/GVL_BigStation.cs @@ -16,8 +16,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// plc心跳上传 /// public static bool HeartBeatFromPlc { get; set; } + public static bool Order_Cancel { get; set; } - public static DateTime DosingTime { get; set; } + public static string Order_CancelRecipeCode { get; set; } = ""; + public static DateTime DosingRecipe1Time { get; set; } + public static DateTime DosingRecipe2Time { get; set; } + public static DateTime DosingRecipe3Time { get; set; } + public static DateTime DosingRecipe4Time { get; set; } /// /// plc心跳下发 /// @@ -58,5 +63,29 @@ namespace BPASmartClient.JXJFoodBigStation.Model public static DB_Read HKPlc_Read = new DB_Read(); public static bool IsUseLocalName { get; set; } = true; + + public static bool IsAllowHKPlcConnect { get; set; } + public static bool IsAllowSiemensConnect { get; set; } + /// + /// 海科plc初始化完成标志 + /// + public static bool HKPlcInitComple { get; set; } + /// + /// 西门子plc初始化完成标志 + /// + public static bool SiemensInitComple { get; set; } + + /// + /// + /// + public static bool Recipe1DosingFinish { get; set; } = false; + public static bool Recipe2DosingFinish { get; set; } = false; + public static bool Recipe3DosingFinish { get; set; } = false; + public static bool Recipe4DosingFinish { get; set; } = false; + + /// + /// 订单是否是洗桶 + /// + public static bool Order_IsWashingBarrel { get; set; } = false; } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs index b311851b..82c4d8dd 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/DB_Write.cs @@ -1,4 +1,5 @@ -using System; +using BPASmartClient.S7Net; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -123,5 +124,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public float Bareel5Bin12SetWeight { get; set; } public float Bareel5Bin13SetWeight { get; set; } public float Bareel5Bin14SetWeight { get; set; } + public bool OrderCancel_Sign { get; set; } + public short OrderCancel_TrayCode { get; set; } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs index cb36ab25..74f34914 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/HK_PLC/HKDeviceStatus.cs @@ -21,8 +21,14 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC public StockBinName StockBinName = new StockBinName(); public void Init() { - DB_Write PlcWrite = new DB_Write(); - HK_PLC_S7.WriteClass(PlcWrite, 99); + try + { + DB_Write PlcWrite = new DB_Write(); + HK_PLC_S7.WriteClass(PlcWrite, 99); + } + catch (Exception ex) { + MessageNotify.GetInstance.ShowRunLog("DB99块初始化值 失败"); + } ThreadManage.GetInstance().StartLong(new Action(() => { if (IsConnected) @@ -45,7 +51,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.HK_PLC } } Thread.Sleep(10); - }),"信号收发处理",true); + }),"海科数据交互",true); } /// /// 下发配方数据 diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index 23dbd280..843db9cb 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -47,7 +47,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model /// 原料的名称和料仓的位置对应 /// public Dictionary RawMaterialsNamePos = new Dictionary(); - public ObservableCollection RawMaterialsInfo = new ObservableCollection(); + public ObservableCollection RawMaterialsInfo => Json.Data.RawMaterial; /// /// 西门子配方队列 /// @@ -99,6 +99,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model RecipeCode = recipe.RecipeCode, RawMaterial = RawMaterials, TrayCode = recipe.Job_No, + IsWashingBarrel = recipe.Order_Type }); }); } @@ -106,33 +107,56 @@ namespace BPASmartClient.JXJFoodBigStation.Model }), "SiemensSendRecipe", true); string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; + GVL_BigStation.IsAllowHKPlcConnect = ConfigurationManager.AppSettings["HKPlc_Connect"].ToLower() == "true" ? true : false; + GVL_BigStation.IsAllowSiemensConnect = ConfigurationManager.AppSettings["Siemens_Connect"].ToLower() == "true" ? true : false; try { - HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); - if (HKDevice.IsConnected) + if (GVL_BigStation.IsAllowHKPlcConnect) + { + HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); + } + } + catch (Exception ex) + { + MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败,等待重新连接"); + } + finally + { + HKDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("海科plc初始化"); + if (HKDevice.IsConnected && GVL_BigStation.IsAllowHKPlcConnect) { - HKDevice.Init(); MessageNotify.GetInstance.ShowRunLog("海科plc连接成功"); } - if (SiemensDevice.IsConnected) + } + try + { + if (GVL_BigStation.IsAllowSiemensConnect) { - SiemensDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); + SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); } } catch (Exception ex) { - + MessageNotify.GetInstance.ShowAlarmLog("西门子plc连接失败,等待重新连接"); + } + finally + { + SiemensDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("西门子plc初始化"); + if (SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect) + { + MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); + } } ThreadManage.GetInstance().StartLong(new Action(() => { - if (!HKDevice.IsConnected) + if (!HKDevice.IsConnected && GVL_BigStation.IsAllowHKPlcConnect) { HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71500, HK_PLC_IP); MessageNotify.GetInstance.ShowRunLog("海科plc重新连接成功"); } - if (!SiemensDevice.IsConnected) + if (!SiemensDevice.IsConnected && GVL_BigStation.IsAllowSiemensConnect) { SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); MessageNotify.GetInstance.ShowRunLog("西门子plc重新连接"); @@ -203,10 +227,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.AGVGetTray = SiemensDevice.DL_Status.AGV_Get_Done; SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW30", GVL_BigStation.TraySensor); SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW32", GVL_BigStation.TrayCylinder); - SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW34", (ushort)13); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBW34", (ushort)15); } Thread.Sleep(10); - }),"设备连接",true); + }),"海科plc和西门子数据交互",true); LocalRecipeQueue1.Clear(); LocalRecipeQueue2.Clear(); LocalRecipeQueue3.Clear(); @@ -217,6 +241,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model SiemensRecipeQueue4.Clear(); ThreadManage.GetInstance().StartLong(new Action(() => { + testRawMaterialNameData();//自定义料仓名称 if (GVL_BigStation.IsUseLocalRecipe) { LocalRecipeRecevice(); @@ -228,7 +253,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model RecipeInfoToHKPLC(); } Thread.Sleep(10); - }), "西门子配方执行流程", true); + }), "配方数据执行流程", true); } private void LocalRecipeRecevice() { @@ -292,18 +317,23 @@ namespace BPASmartClient.JXJFoodBigStation.Model { case 1: Inplace = HKDevice.PlcRead.Tray1InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); break; case 2: Inplace = HKDevice.PlcRead.Tray2InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); break; case 3: Inplace = HKDevice.PlcRead.Tray3InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); break; case 4: Inplace = HKDevice.PlcRead.Tray4InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); break; case 5: Inplace = HKDevice.PlcRead.Tray5InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); break; default: break; @@ -427,18 +457,23 @@ namespace BPASmartClient.JXJFoodBigStation.Model { case 1: Inplace = HKDevice.PlcRead.Tray1InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", GVL_BigStation.AGVPutTray.GetBitValue(1)); break; case 2: Inplace = HKDevice.PlcRead.Tray2InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", GVL_BigStation.AGVPutTray.GetBitValue(2)); break; case 3: Inplace = HKDevice.PlcRead.Tray3InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", GVL_BigStation.AGVPutTray.GetBitValue(3)); break; case 4: Inplace = HKDevice.PlcRead.Tray4InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", GVL_BigStation.AGVPutTray.GetBitValue(4)); break; case 5: Inplace = HKDevice.PlcRead.Tray5InPlace; + HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); break; default: break; @@ -459,6 +494,26 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) { + switch (trayCode) + { + case 1: + HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); + break; + case 2: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); + break; + case 3: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); + break; + case 4: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); + break; + case 5: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); + break; + default: + break; + } GVL_BigStation.Recipe2DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) @@ -579,6 +634,26 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) { + switch (trayCode) + { + case 1: + HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); + break; + case 2: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); + break; + case 3: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); + break; + case 4: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); + break; + case 5: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); + break; + default: + break; + } GVL_BigStation.Recipe3DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) @@ -700,6 +775,26 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) { + switch (trayCode) + { + case 1: + HKDevice.HK_PLC_S7.Write("DB99.DBX0.7", false); + break; + case 2: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.0", false); + break; + case 3: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.1", false); + break; + case 4: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.2", false); + break; + case 5: + HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", false); + break; + default: + break; + } GVL_BigStation.Recipe4DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); foreach (var item in LocalRecipes.ElementAt(index).RawMaterial) @@ -788,25 +883,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (GVL_BigStation.SiemensSendRecipeStatus == 3) { - GVL_BigStation.SiemensSendRecipeStatus = 4; SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"配方1,发送配方编号和请求配料标志给西门子"); + GVL_BigStation.SiemensSendRecipeStatus = 4; } if (GVL_BigStation.SiemensSendRecipeStatus == 4) { if (SiemensDevice.DL_Status.Dosing_Start_ACK) { - GVL_BigStation.SiemensSendRecipeStatus = 5; SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + MessageNotify.GetInstance.ShowRunLog($"配方1,西门子确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; } } if (GVL_BigStation.SiemensSendRecipeStatus == 5) { if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) { - GVL_BigStation.SiemensSendRecipeStatus = 6; SiemensRecipeQueue1.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方1,配方:{data.RecipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; } } } @@ -820,25 +918,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (GVL_BigStation.SiemensSendRecipeStatus == 3) { - GVL_BigStation.SiemensSendRecipeStatus = 4; SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"配方2,发送配方编号和请求配料标志给西门子"); + GVL_BigStation.SiemensSendRecipeStatus = 4; } if (GVL_BigStation.SiemensSendRecipeStatus == 4) { if (SiemensDevice.DL_Status.Dosing_Start_ACK) { - GVL_BigStation.SiemensSendRecipeStatus = 5; SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); - SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + MessageNotify.GetInstance.ShowRunLog($"配方2,西门子确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; } } if (GVL_BigStation.SiemensSendRecipeStatus == 5) { if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) { - GVL_BigStation.SiemensSendRecipeStatus = 6; SiemensRecipeQueue2.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方2,配方:{data.RecipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; } } } @@ -852,25 +953,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (GVL_BigStation.SiemensSendRecipeStatus == 3) { - GVL_BigStation.SiemensSendRecipeStatus = 4; SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"配方3,发送配方编号和请求配料标志给西门子"); + GVL_BigStation.SiemensSendRecipeStatus = 4; } if (GVL_BigStation.SiemensSendRecipeStatus == 4) { if (SiemensDevice.DL_Status.Dosing_Start_ACK) { - GVL_BigStation.SiemensSendRecipeStatus = 5; SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); - SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + MessageNotify.GetInstance.ShowRunLog($"配方3,西门子确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; } } if (GVL_BigStation.SiemensSendRecipeStatus == 5) { if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) { - GVL_BigStation.SiemensSendRecipeStatus = 6; SiemensRecipeQueue3.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方3,配方:{data.RecipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; } } } @@ -884,25 +988,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (GVL_BigStation.SiemensSendRecipeStatus == 3) { - GVL_BigStation.SiemensSendRecipeStatus = 4; SiemensDevice.Siemens_PLC_S7.WriteString(2331, data.RecipeCode, 10); SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", true); + MessageNotify.GetInstance.ShowRunLog($"配方4,发送配方编号和请求配料标志给西门子"); + GVL_BigStation.SiemensSendRecipeStatus = 4; } if (GVL_BigStation.SiemensSendRecipeStatus == 4) { if (SiemensDevice.DL_Status.Dosing_Start_ACK) { - GVL_BigStation.SiemensSendRecipeStatus = 5; SiemensDevice.Siemens_PLC_S7.WriteString(2331, "", 10); - SiemensDevice.Siemens_PLC_S7.Write("DB3231.DBX28.0", false); + SiemensDevice.Siemens_PLC_S7.Write("DB2331.DBX28.0", false); + MessageNotify.GetInstance.ShowRunLog($"配方4,西门子确认开始配料"); + GVL_BigStation.SiemensSendRecipeStatus = 5; } } if (GVL_BigStation.SiemensSendRecipeStatus == 5) { if (SiemensDevice.DL_Status.Dosing_Start_ACK == false) { - GVL_BigStation.SiemensSendRecipeStatus = 6; SiemensRecipeQueue4.Enqueue(data.RecipeCode); + MessageNotify.GetInstance.ShowRunLog($"配方4,配方:{data.RecipeCode},加入队列"); + GVL_BigStation.SiemensSendRecipeStatus = 0; } } } @@ -921,6 +1028,144 @@ namespace BPASmartClient.JXJFoodBigStation.Model GVL_BigStation.Recipe3DosingStatus = 0; GVL_BigStation.Recipe4DosingStatus = 0; } + + if (GVL_BigStation.Order_Cancel) //订单取消 + { + if (!string.IsNullOrEmpty(GVL_BigStation.Order_CancelRecipeCode)) + { + int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == GVL_BigStation.Order_CancelRecipeCode); + if (index >= 0) + { + string code = GVL_BigStation.Order_CancelRecipeCode; + short TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode; + if (SiemensRecipeQueue1.Contains(code) || SiemensRecipeQueue2.Contains(code) || SiemensRecipeQueue3.Contains(code) || SiemensRecipeQueue4.Contains(code)) + { + if (SiemensRecipeQueue1.Contains(code)) + { + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + if (GVL_BigStation.Recipe1DosingStatus != 0) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + else + { + 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}"); + } + if (SiemensRecipeQueue2.Contains(code)) + { + GVL_BigStation.Recipe2DosingStatus = 0; + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + if (GVL_BigStation.Recipe2DosingStatus != 0) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + else + { + 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}"); + } + if (SiemensRecipeQueue3.Contains(code)) + { + GVL_BigStation.Recipe3DosingStatus = 0; + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + if (GVL_BigStation.Recipe3DosingStatus != 0) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + else + { + MessageNotify.GetInstance.ShowRunLog($"AGV未到达工站前,未给plc下发配方,取消订单:{code}"); + } + GVL_BigStation.Recipe3DosingStatus = 0; + SiemensRecipeQueue3.TryDequeue(out code); + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX320.2", false); + SiemensDevice.Siemens_PLC_S7.Write("DB2301.DBX330.1", true); + MessageNotify.GetInstance.ShowRunLog($"队列3,西门子取消订单完成,订单号:{code}"); + } + if (SiemensRecipeQueue4.Contains(code)) + { + GVL_BigStation.Recipe4DosingStatus = 0; + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + if (GVL_BigStation.Recipe4DosingStatus != 0) + { + HKDevice.HK_PLC_S7.Write("DB99.DBX230.0", true); + HKDevice.HK_PLC_S7.Write("DB99.DBW232", (short)TrayCode); + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + else + { + 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}"); + } + GVL_BigStation.Order_Cancel = false; + GVL_BigStation.Order_CancelRecipeCode = ""; + } + else + { + if (GVL_BigStation.SiemensSendRecipeStatus != 0 || GVL_BigStation.SiemensSendRecipeStatus != 1) + { + GVL_BigStation.SiemensSendRecipeStatus = 0; + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + MessageNotify.GetInstance.ShowRunLog($"正在执行请求订单流程,配方还未到PLC,订单号:{GVL_BigStation.Order_CancelRecipeCode}"); + } + else + { + 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); + } + } + 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); + MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{GVL_BigStation.Order_CancelRecipeCode}"); + } + } + } } private void RecipeInfoToHKPLC() { @@ -954,21 +1199,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model } if (HKDevice.PlcRead.IsAllowIssueRecipe1 && GVL_BigStation.Recipe1DosingStatus == 0 && Inplace)//配方1是否允许下发配发 { - GVL_BigStation.DosingTime = DateTime.Now; + GVL_BigStation.DosingRecipe1Time = 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},订单类型为洗桶"); + } 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(); MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); + GVL_BigStation.Recipe1DosingStatus = 2; } if (GVL_BigStation.Recipe1DosingStatus == 2 && HKDevice.PlcRead.Recipe1DosingFinish) { + GVL_BigStation.Recipe1DosingFinish = true; GVL_BigStation.Recipe1DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) @@ -1043,13 +1294,13 @@ namespace BPASmartClient.JXJFoodBigStation.Model { FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); } FinishData.Ask_For_Finish = true; - GVL_BigStation.SiemensSendRecipeStatus = 7; - double a = DateTime.Now.Subtract(GVL_BigStation.DosingTime).TotalSeconds; + double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe1Time).TotalSeconds; FinishData.ProcessTime = Convert.ToInt16(a); SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); } SiemensRecipeQueue1.TryDequeue(out code); RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将配方添加到完成列表 @@ -1101,20 +1352,27 @@ namespace BPASmartClient.JXJFoodBigStation.Model } 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},订单类型为洗桶"); + } HKDevice.HK_PLC_S7.Write("DB99.DBX0.4", true); GVL_BigStation.Recipe2DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + 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(); - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (GVL_BigStation.Recipe2DosingStatus == 2 && HKDevice.PlcRead.Recipe2DosingFinish) { + GVL_BigStation.Recipe2DosingFinish = true; GVL_BigStation.Recipe2DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) @@ -1175,8 +1433,12 @@ namespace BPASmartClient.JXJFoodBigStation.Model { item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } + } + if (SiemensDevice.IsConnected) + { FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; for (int i = 0; i < FinishData.Material.Length; i++) { FinishData.Material[i] = new UDT1(); @@ -1185,25 +1447,31 @@ namespace BPASmartClient.JXJFoodBigStation.Model { FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); } - if (SiemensDevice.IsConnected) - { - SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); - } - SiemensRecipeQueue2.TryDequeue(out code); - RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index)); - if (!GVL_BigStation.IsUseLocalRecipe) + FinishData.Ask_For_Finish = true; + double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe2Time).TotalSeconds; + FinishData.ProcessTime = Convert.ToInt16(a); + SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); + } + SiemensRecipeQueue2.TryDequeue(out code); + RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index)); + if (!GVL_BigStation.IsUseLocalRecipe) + { + App.Current.Dispatcher.Invoke(() => { Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - } - else + }); + } + else + { + App.Current.Dispatcher.Invoke(() => { Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 - } - GVL_BigStation.Recipe2DosingStatus = 0; + }); } + GVL_BigStation.Recipe2DosingStatus = 0; } } } @@ -1237,26 +1505,30 @@ 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},订单类型为洗桶"); + } HKDevice.HK_PLC_S7.Write("DB99.DBX0.5", true); GVL_BigStation.Recipe3DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + 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(); - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (HKDevice.PlcRead.Recipe3DosingFinish && GVL_BigStation.Recipe3DosingStatus == 2) { + GVL_BigStation.Recipe3DosingFinish = true; GVL_BigStation.Recipe3DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); - if (HKDevice.PlcRead.Recipe3TrayCode > 0) - { - foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) + foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) { if (item.RawMaterialLocation == 1) { @@ -1315,8 +1587,11 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } + if (SiemensDevice.IsConnected) + { FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; for (int i = 0; i < FinishData.Material.Length; i++) { FinishData.Material[i] = new UDT1(); @@ -1325,23 +1600,29 @@ namespace BPASmartClient.JXJFoodBigStation.Model { FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; + FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); } - } - if (SiemensDevice.IsConnected) - { + FinishData.Ask_For_Finish = true; + double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe3Time).TotalSeconds; + FinishData.ProcessTime = Convert.ToInt16(a); SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); } - HKDevice.HK_PLC_S7.Write("DB98.DBX1.1", false); SiemensRecipeQueue3.TryDequeue(out code); RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下 if (!GVL_BigStation.IsUseLocalRecipe) { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); } else { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); } GVL_BigStation.Recipe3DosingStatus = 0; } @@ -1371,27 +1652,33 @@ namespace BPASmartClient.JXJFoodBigStation.Model break; case 5: Inplace = HKDevice.PlcRead.Tray5InPlace; - HKDevice.HK_PLC_S7.Write("DB99.DBX1.3", GVL_BigStation.AGVPutTray.GetBitValue(5)); break; default: break; } 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},订单类型为洗桶"); + } HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", true); GVL_BigStation.Recipe4DosingStatus = 1; - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}下发完成"); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},下发完成"); } if (HKDevice.PlcRead.ReceiveFinishRecipe4 && GVL_BigStation.Recipe4DosingStatus == 1) { GVL_BigStation.Recipe4DosingStatus = 2; HKDevice.HK_PLC_S7.Write("DB99.DBX0.6", false); StockBinParReset(); - MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配方配料"); + MessageNotify.GetInstance.ShowRunLog($"配方编号:{code},托盘编号:{trayCode},PLC接收配方完成"); } if (GVL_BigStation.Recipe4DosingStatus == 2 && HKDevice.PlcRead.Recipe4DosingFinish) { + GVL_BigStation.Recipe1DosingFinish = true; GVL_BigStation.Recipe4DosingStatus = 3; MessageNotify.GetInstance.ShowRunLog($"配方状态:{code}配料完成"); foreach (var item in SiemensRecipes.ElementAt(index).RawMaterial) @@ -1453,32 +1740,42 @@ namespace BPASmartClient.JXJFoodBigStation.Model item.Laying_Off_Weight = HKDevice.PlcRead.StockBin14ActualWeight; } } - FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; - FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; - for (int i = 0; i < FinishData.Material.Length; i++) - { - FinishData.Material[i] = new UDT1(); - } - for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) - { - FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; - FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; - FinishData.Material[i].Material_Laying_Off_Weight = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight; - } if (SiemensDevice.IsConnected) { + FinishData.Order_No = SiemensRecipes.ElementAt(index).RecipeCode; + FinishData.Product_Code = SiemensRecipes.ElementAt(index).RecipeName; + FinishData.job_No = (short)SiemensRecipes.ElementAt(index).TrayCode; + for (int i = 0; i < FinishData.Material.Length; i++) + { + FinishData.Material[i] = new UDT1(); + } + for (int i = 0; i < SiemensRecipes.ElementAt(index).RawMaterial.Count; i++) + { + FinishData.Material[i].Material_Name = SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialName; + FinishData.Material[i].Material_BarrelNum = (short)SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).RawMaterialBarrelNum; + FinishData.Material[i].Material_Laying_Off_Weight = Math.Abs(SiemensRecipes.ElementAt(index).RawMaterial.ElementAt(i).Laying_Off_Weight); + } + FinishData.Ask_For_Finish = true; + double a = DateTime.Now.Subtract(GVL_BigStation.DosingRecipe4Time).TotalSeconds; + FinishData.ProcessTime = Convert.ToInt16(a); SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + MessageNotify.GetInstance.ShowRunLog($"配方配料完成,将信号反馈给西门子"); } - HKDevice.HK_PLC_S7.Write("DB98.DBX1.3", false); SiemensRecipeQueue4.TryDequeue(out code); RecipeExecuteComple.Add(SiemensRecipes.ElementAt(index));//将该配方添加到下 if (!GVL_BigStation.IsUseLocalRecipe) { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); } else { - Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index);//制作完成,移除当前配方 + }); } GVL_BigStation.Recipe4DosingStatus = 0; } @@ -1500,32 +1797,25 @@ namespace BPASmartClient.JXJFoodBigStation.Model } private void testRawMaterialNameData() { - RawMaterialsNamePos.Clear(); - RawMaterialsInfo.Clear(); - if (GVL_BigStation.IsUseLocalName) + /* RawMaterialsInfo.Clear(); + RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0007", RawMaterialLocation = 1 });//备料大蒜 + RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0015", RawMaterialLocation = 2 });//花椒酱 + 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 = "0012", RawMaterialLocation = 12 });//豆豉细粒*/ + foreach (var material in RawMaterialsInfo) { - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0007", RawMaterialLocation = 1 });//香菇丁 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0015", RawMaterialLocation = 2 });//竹笋丁 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0005", RawMaterialLocation = 3 });//卤牛肉丁 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0014", RawMaterialLocation = 4 });//野山椒粒 - - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0031", RawMaterialLocation = 1 });//备料大蒜 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0040", RawMaterialLocation = 2 });//花椒酱 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0018", RawMaterialLocation = 4 });//榨菜丁 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0033", RawMaterialLocation = 5 });//炸豌豆 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0008", RawMaterialLocation = 8 });//高水分糍粑海椒 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0010", RawMaterialLocation = 9 });//辣豆瓣 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0030", RawMaterialLocation = 11 });//备用生姜 - RawMaterialsInfo.Add(new RawMaterial() { RawMaterialName = "0012", RawMaterialLocation = 12 });//豆豉细粒 - foreach (var material in RawMaterialsInfo) + if (!string.IsNullOrEmpty(material.RawMaterialName)) { - RawMaterialsNamePos.Add(material.RawMaterialName,(short)material.RawMaterialLocation); + if (!RawMaterialsNamePos.ContainsKey(material.RawMaterialName)) + { + RawMaterialsNamePos.Add(material.RawMaterialName, (short)material.RawMaterialLocation); + } } } - else - { - if ((!string.IsNullOrEmpty(HKDevice.StockBinName.RawMaterialName1)) && !RawMaterialsNamePos.ContainsKey(HKDevice.StockBinName.RawMaterialName1)) RawMaterialsNamePos.Add(HKDevice.StockBinName.RawMaterialName1, 1); - } } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialData.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialData.cs new file mode 100644 index 00000000..ac8e0844 --- /dev/null +++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RawMaterialData.cs @@ -0,0 +1,16 @@ +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodBigStation.Model +{ + public class RawMaterialData + { + public ObservableCollection RawMaterial { get; set; } = new ObservableCollection(); + + } +} diff --git a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs index aa3f42fa..873e398e 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/RawMaterial/RecipeData.cs @@ -28,6 +28,8 @@ namespace BPASmartClient.JXJFoodBigStation.Model public int TrayCode { get { return _mTrayCode; } set { _mTrayCode = value; OnPropertyChanged(); } } private int _mTrayCode; + public bool IsWashingBarrel { get { return _mIsWashingBarrel; } set { _mIsWashingBarrel = value; OnPropertyChanged(); } } + private bool _mIsWashingBarrel; /// /// 原料数据 /// diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs index c90f5442..87a4e144 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/DL_Start_DB.cs @@ -40,6 +40,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens /// public bool Order_Request_Ack { get; set; } /// + /// 订单取消 + /// + public bool Order_Cancel { get; set; } + /// /// 备用 /// public short[] Standby { get; set; } = new short[4]; @@ -48,6 +52,10 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens /// public bool Order_Request { get; set; } /// + /// 订单取消回复 + /// + public bool Order_Cancel_Ack { get; set; } + /// /// 备用 /// public short[] Standby1 { get; set; } = new short[4]; diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index d84885f9..ff22a4a4 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using BPASmartClient.S7Net; using System.Threading; +using BPASmartClient.CustomResource.Pages.Model; namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { @@ -31,19 +32,28 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { if (GVL_BigStation.Order_Request && GVL_BigStation.SiemensSendRecipeStatus == 0) { - GVL_BigStation.SiemensSendRecipeStatus = 1; this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true); + MessageNotify.GetInstance.ShowRunLog($"向西门子请求订单"); + GVL_BigStation.SiemensSendRecipeStatus = 1; } if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 1) { - GVL_BigStation.SiemensSendRecipeStatus = 2; ActionManage.GetInstance.Send("SiemensSendRecipe", start); this.Siemens_PLC_S7.Write("DB2301.DBX330.0", false); + MessageNotify.GetInstance.ShowRunLog($"西门子下发订单:{start.RecipeCode}"); + GVL_BigStation.SiemensSendRecipeStatus = 2; } if (TTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 2) { - GVL_BigStation.SiemensSendRecipeStatus = 3; GVL_BigStation.Order_Request = false; + MessageNotify.GetInstance.ShowRunLog($"西门子确认上位机接收到订单:{start.RecipeName}"); + GVL_BigStation.SiemensSendRecipeStatus = 3; + } + if (RTrig.GetInstance("Order_Cancel").Start(start.Order_Cancel)) //订单取消 + { + GVL_BigStation.Order_Cancel = true; + GVL_BigStation.Order_CancelRecipeCode = start.RecipeCode; + MessageNotify.GetInstance.ShowRunLog($"西门子下发取消工单指令:{start.RecipeName}"); } } if (res1 != null && res1 is DL_Status_DB status) @@ -52,19 +62,73 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens } if (res2 != null && res2 is DL_Finish_DB finish) { - if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC) && GVL_BigStation.SiemensSendRecipeStatus == 7) + if (GVL_BigStation.Recipe1DosingFinish == true) + { + if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC)) + { + finish.Order_No = ""; + finish.Product_Code = ""; + finish.job_No = 0; + for (int i = 0; i < 20; i++) + { + finish.Material[i] = new UDT1(); + } + finish.Ask_For_Finish = false; + finish.ProcessTime = 0; + this.Siemens_PLC_S7.WriteClass(finish, 2361); + GVL_BigStation.Recipe1DosingFinish = false; + } + } + else if (GVL_BigStation.Recipe2DosingFinish == true) + { + if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC)) + { + finish.Order_No = ""; + finish.Product_Code = ""; + finish.job_No = 0; + for (int i = 0; i < 20; i++) + { + finish.Material[i] = new UDT1(); + } + finish.Ask_For_Finish = false; + finish.ProcessTime = 0; + this.Siemens_PLC_S7.WriteClass(finish, 2361); + GVL_BigStation.Recipe2DosingFinish = false; + } + } + else if (GVL_BigStation.Recipe3DosingFinish == true) + { + if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC)) + { + finish.Order_No = ""; + finish.Product_Code = ""; + finish.job_No = 0; + for (int i = 0; i < 20; i++) + { + finish.Material[i] = new UDT1(); + } + finish.Ask_For_Finish = false; + finish.ProcessTime = 0; + this.Siemens_PLC_S7.WriteClass(finish, 2361); + GVL_BigStation.Recipe3DosingFinish = false; + } + } + else if (GVL_BigStation.Recipe4DosingFinish == true) { - finish.Order_No = ""; - finish.Product_Code = ""; - finish.job_No = 0; - for (int i = 0; i < 20; i++) + if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC)) { - finish.Material[i] = new UDT1(); + finish.Order_No = ""; + finish.Product_Code = ""; + finish.job_No = 0; + for (int i = 0; i < 20; i++) + { + finish.Material[i] = new UDT1(); + } + finish.Ask_For_Finish = false; + finish.ProcessTime = 0; + this.Siemens_PLC_S7.WriteClass(finish, 2361); + GVL_BigStation.Recipe4DosingFinish = false; } - GVL_BigStation.SiemensSendRecipeStatus = 0; - finish.Ask_For_Finish = false; - finish.ProcessTime = 0; - this.Siemens_PLC_S7.WriteClass(finish, 2361); } } Thread.Sleep(10); @@ -75,7 +139,7 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens } } Thread.Sleep(10); - }), "监听服务数据"); + }), "西门子数据交互",true); } } } diff --git a/BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml b/BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml index a47509bc..98100d7f 100644 --- a/BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/ManualFlowView.xaml @@ -69,11 +69,19 @@ Height="40" Margin="5,0,5,0" Command="{Binding ClearTrayInPlace}" - Content="清楚AGV到位信号" + Content="清除AGV到位信号" + FontSize="20" + Panel.ZIndex="0" + Style="{StaticResource ImageButtonStyle}"> + - diff --git a/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml b/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml index ef94f4c8..1b7d9435 100644 --- a/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml +++ b/BPASmartClient.JXJFoodBigStation/View/StockBinRawMaterialView.xaml @@ -82,8 +82,10 @@ - @@ -93,7 +95,8 @@ - - p.Address == address); if (index != -1) { - if(ProcessControl.GetInstance.HKDevice.IsConnected) ProcessControl.GetInstance.HKDevice.HK_PLC_S7.Write(address , PlcInfo.ElementAt(index).SetValue); + if (ProcessControl.GetInstance.HKDevice.IsConnected) ProcessControl.GetInstance.HKDevice.HK_PLC_S7.Write(address, PlcInfo.ElementAt(index).SetValue); } }*/ }); @@ -121,7 +121,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel Type type = typeof(T); }*/ - public ObservableCollection PlcInfo { get; set; } = new ObservableCollection(); + public static ObservableCollection PlcInfo { get; set; } = new ObservableCollection(); public RelayCommand SetValueCommand { get; set; } } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs index 8407a73e..2118adfb 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/HardwareStatusViewModel.cs @@ -83,7 +83,6 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel int cnt = Array.FindIndex(TopDeviceCurrentStatuses.ToArray(), p => p.DeviceName == deviceName); if (cnt >= 0) { - int index = Array.FindIndex(BottomDeviceCurrentStatuses.ToArray(), p => p.DeviceName == newName); int index1 = Array.FindIndex(TopDeviceCurrentStatuses.ToArray(), p => p.DeviceName == newName); if (index == -1 && index1 == -1) diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs index 3eab5687..53f9bf86 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/ManualFlowViewModel.cs @@ -1,6 +1,7 @@ using BPASmartClient.Helper; using BPASmartClient.JXJFoodBigStation.Model; using BPASmartClient.JXJFoodBigStation.Model.HK_PLC; +using BPASmartClient.JXJFoodBigStation.Model.Siemens; using Microsoft.Toolkit.Mvvm.ComponentModel; using Microsoft.Toolkit.Mvvm.Input; using System; @@ -43,6 +44,10 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel { GVL_BigStation.AGVPutTray = 0; }); + ClearAllRecipe = new RelayCommand(() => + { + Json.Data.Recipes.Clear(); + }); ThreadManage.GetInstance().StartLong(new Action(() => { Heartbeat = GVL_BigStation.HeartBeatFromPlc; @@ -55,6 +60,7 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel public RelayCommand Tray4InPlace { get; set; } public RelayCommand Tray5InPlace { get; set; } public RelayCommand ClearTrayInPlace { get; set; } + public RelayCommand ClearAllRecipe { get; set; } public bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnPropertyChanged(); } } private bool _mHeartbeat; } diff --git a/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs b/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs index 5a39a510..ba4fdc95 100644 --- a/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs +++ b/BPASmartClient.JXJFoodBigStation/ViewModel/StockBinRawMaterialViewModel.cs @@ -1,4 +1,7 @@ -using BPASmartClient.Helper; +using BPASmartClient.CustomResource.Pages.Model; +using BPASmartClient.CustomResource.UserControls; +using BPASmartClient.CustomResource.UserControls.MessageShow; +using BPASmartClient.Helper; using BPASmartClient.JXJFoodBigStation.Model; using BPASmartClient.JXJFoodBigStation.Model.HK_PLC; using Microsoft.Toolkit.Mvvm.ComponentModel; @@ -19,24 +22,29 @@ namespace BPASmartClient.JXJFoodBigStation.ViewModel { public StockBinRawMaterialViewModel() { - RawMaterialInfo = ProcessControl.GetInstance.RawMaterialsInfo; - int serialNum = 0; - foreach (var rawMaterialInfo in RawMaterialInfo) + RawMaterialInfo = Json.Data.RawMaterial; + RemoveCommand = new RelayCommand((loc) => { - serialNum = serialNum + 1; - rawMaterialInfo.RawMaterialCount = (short)serialNum; - } - 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(); + MessageNotify.GetInstance.ShowUserLog($"原料与料仓对应关系保存成功"); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "成功", $"原料与料仓对应关系保存成功"); + }); + UpdateRawMaterial = new RelayCommand(() => { - var res = RawMaterialInfo.FirstOrDefault(p => p.RawMaterialLocation == loc); - if(res!= null) RawMaterialInfo.Remove(res); + RawMaterialInfo.Add(new RawMaterial() { RawMaterialCount = (short)(RawMaterialInfo.Count + 1)}); }); } public ObservableCollection RawMaterialInfo { get; set; } = new ObservableCollection(); - - public RelayCommand DetailsCommand { get; set; } - public RelayCommand RemoveCommand { get; set; } + public RelayCommand RemoveCommand { get; set; } public RelayCommand SaveRawMaterialPara { get; set; } - public RelayCommand UpdateMaterial { get; set; } + public RelayCommand UpdateRawMaterial { get; set; } } } diff --git a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs index 312b269d..1015cbd3 100644 --- a/BPASmartClient.JXJFoodSmallStation/App.xaml.cs +++ b/BPASmartClient.JXJFoodSmallStation/App.xaml.cs @@ -39,9 +39,8 @@ namespace BPASmartClient.JXJFoodSmallStation base.OnStartup(e); MenuInit(); DataInit(); - DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 + Init(); MainView mv = new MainView(); - ProcessControl.GetInstance.Init(); LoginView lv = new LoginView(); var res = lv.ShowDialog(); if (res != null && res == true) @@ -53,6 +52,14 @@ namespace BPASmartClient.JXJFoodSmallStation mv.Close(); MainWindow = mv; } + private async void Init() + { + await Task.Run(new Action(() => + { + DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 + ProcessControl.GetInstance.Init(); + })); + } protected override void OnExit(ExitEventArgs e) { @@ -165,8 +172,16 @@ namespace BPASmartClient.JXJFoodSmallStation AssemblyName = "BPASmartClient.JXJFoodSmallStation", ToggleWindowPath = "View.ManualFlowView" + }); + ManualControl.Add(new SubMenumodel() + { + SubMenuName = "机器人设备控制", + SubMenuPermission = new Permission[] { Permission.管理员, Permission.操作员, Permission.技术员 }, + AssemblyName = "BPASmartClient.JXJFoodSmallStation", + ToggleWindowPath = "View.RobotView" + }); - + MenuManage.GetInstance.menuModels.Add(new MenuModel() { MainMenuIcon = "", diff --git a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj index 65130edf..113ea061 100644 --- a/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj +++ b/BPASmartClient.JXJFoodSmallStation/BPASmartClient.JXJFoodSmallStation.csproj @@ -26,6 +26,9 @@ + + Code + Code @@ -42,6 +45,10 @@ $(DefaultXamlRuntime) Designer + + $(DefaultXamlRuntime) + Designer + $(DefaultXamlRuntime) Designer diff --git a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs index 72e17586..5625b98f 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/GVL_SmallStation.cs @@ -14,6 +14,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model private volatile static GVL_SmallStation SmallStation; public static GVL_SmallStation GetInstance => SmallStation ?? (SmallStation = new GVL_SmallStation()); private GVL_SmallStation() { } + + public static bool Order_Cancel { get; set; } + public static string Order_CancelRecipeCode { get; set; } = ""; /// /// 托盘1托盘到位 逻辑完成 /// diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 189889f9..ae9b499f 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -33,7 +33,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model /// /// 配方队列 /// - public ConcurrentQueue RecipeQueue = new ConcurrentQueue(); + public ConcurrentQueue RecipeQueueTray1 = new ConcurrentQueue(); public ConcurrentQueue RecipeQueueTray2 = new ConcurrentQueue(); public SiemensDeviceStatus SiemensDevice = new SiemensDeviceStatus(); @@ -51,7 +51,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model public void Init() { testData(); - //Json.Data.Recipes = Json.Data.Recipes; for (int i = 0; i < 16; i++) { if (DeviceInquire.GetInstance.GetDevice(i).DeviceName != null) @@ -166,65 +165,106 @@ namespace BPASmartClient.JXJFoodSmallStation.Model Json.Data.Recipes.Add(recipe); } }), "LocalSimulationRecipeIssue", true); + + ActionManage.GetInstance.Register(new Action(() => + { + Json.Data.Recipes.Clear(); + GVL_SmallStation.SiemensSendRecipeStatus = 0; + MessageNotify.GetInstance.ShowRunLog("系统流程复位,等待西门子重新下发订单"); + }), "BPASystemReset",true); + string HK_PLC_IP = ConfigurationManager.AppSettings["HKPlc_IP"]; string Siemens_PLC_IP = ConfigurationManager.AppSettings["Siemens_IP"]; string WindSend_PLC_IP = ConfigurationManager.AppSettings["WindSend_IP"]; - try { if (Json.Data.deviceConnectPar.HKPlcConnect) { HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); + if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科plc连接成功"); } + } + catch (Exception ex) + { + MessageNotify.GetInstance.ShowAlarmLog("海科plc连接失败,等待重新连接"); + } + finally + { + HKDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("海科plc初始化完成"); + } + try + { if (Json.Data.deviceConnectPar.SiemensConnect) { SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功"); } + } + catch (Exception ex) + { + MessageNotify.GetInstance.ShowAlarmLog("西门子plc连接失败,等待重新连接"); + } + finally + { + SiemensDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("西门子plc初始化完成"); + } + try + { if (Json.Data.deviceConnectPar.WindSendConnect) { WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP); + if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc连接成功"); } - if (HKDevice.IsConnected) + } + catch (Exception ex) + { + MessageNotify.GetInstance.ShowAlarmLog("粉料plc连接失败,等待重新连接"); + } + finally + { + WindSendDevice.Init(); + MessageNotify.GetInstance.ShowRunLog("风送粉料plc初始化完成"); + } + ThreadManage.GetInstance().StartLong(new Action(() => + { + try { - HKDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("海科plc连接成功,并初始化完成"); + if (!HKDevice.IsConnected && Json.Data.deviceConnectPar.HKPlcConnect) + { + HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); + if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功"); + } } - if (SiemensDevice.IsConnected) + catch (Exception ex) { - SiemensDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("西门子plc连接成功,并初始化完成"); } - if (WindSendDevice.IsConnected) + try { - WindSendDevice.Init(); - MessageNotify.GetInstance.ShowRunLog("风送plc连接成功,并初始化完成"); + if (!SiemensDevice.IsConnected && Json.Data.deviceConnectPar.SiemensConnect) + { + SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); + if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("西门子PLC重新连接成功"); + } } - } - catch (Exception ex) - { - } - ThreadManage.GetInstance().StartLong(new Action(() => - { - if (!HKDevice.IsConnected && Json.Data.deviceConnectPar.HKPlcConnect) + catch (Exception ex) { - HKDevice.HK_PLC_S7.Connect(S7.Net.CpuType.S71200, HK_PLC_IP); - MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接"); - if (HKDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功"); } - if (!SiemensDevice.IsConnected && Json.Data.deviceConnectPar.SiemensConnect) + try { - SiemensDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71500, Siemens_PLC_IP); - MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接"); - if (SiemensDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("海科PLC重新连接成功"); + if (!WindSendDevice.IsConnected && Json.Data.deviceConnectPar.WindSendConnect) + { + WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP); + if (WindSendDevice.IsConnected) MessageNotify.GetInstance.ShowRunLog("风送plc重新连接成功"); + } } - if (!WindSendDevice.IsConnected && Json.Data.deviceConnectPar.WindSendConnect) + catch (Exception ex) { - WindSendDevice.Siemens_PLC_S7.Connect(S7.Net.CpuType.S71200, WindSend_PLC_IP); - MessageNotify.GetInstance.ShowRunLog("风送plc重新连接成功"); } Thread.Sleep(50); }), "设备连接", true); - RecipeQueue.Clear(); + RecipeQueueTray1.Clear(); //手动控制系统模式 ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", true); }), "SystemStart", true); ActionManage.GetInstance.Register(new Action(() => { HKDevice.HK_PLC_S7.Write("DB44.DBX0.0", false); }), "SystemStop", true); @@ -283,7 +323,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model HKDevice.HK_PLC_S7.Write("DB47.DBD4", value); } }), "Axis2SpeedSet", true); - RecipeQueue.Clear(); //Json.Data.Recipes = TestData.GetInstance.Recipes;//添加测试数据 ThreadManage.GetInstance().StartLong(new Action(() => { @@ -308,7 +347,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model }), "西门子配发下发流程处理", true); ThreadManage.GetInstance().StartLong(new Action(() => { - if (HKDevice.IsConnected) + if (!HKDevice.IsConnected) { ManualOpen(); ManualClose(); @@ -335,110 +374,36 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (o.ToString().Contains("升降气缸")) { - int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); - switch (index) + int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); + if (index >= 1 && index <= 15) { - case 1: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.0", true); - break; - case 2: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.1", true); - break; - case 3: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.2", true); - break; - case 4: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.3", true); - break; - case 5: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.4", true); - break; - case 6: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.5", true); - break; - case 7: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.6", true); - break; - case 8: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.7", true); - break; - case 9: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.0", true); - break; - case 10: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.1", true); - break; - case 11: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.2", true); - break; - case 12: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.3", true); - break; - case 13: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.4", true); - break; - case 14: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.5", true); - break; - case 15: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.6", true); - break; - default: - break; + string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1); + if (index == 8) address = "DB5.DBX0.7"; + HKDevice.HK_PLC_S7.Write(address, true); } } else if (o.ToString().Contains("阻挡气缸")) { - int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); - switch (index) + int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); + if (index >= 1 && index <= 15) { - case 1: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.7", true); - break; - case 2: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.0", true); - break; - case 3: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.1", true); - break; - case 4: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.2", true); - break; - case 5: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.3", true); - break; - case 6: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.4", true); - break; - case 7: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.5", true); - break; - case 8: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.6", true); - break; - case 9: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.7", true); - break; - case 10: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.0", true); - break; - case 11: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.1", true); - break; - case 12: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.2", true); - break; - case 13: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.3", true); - break; - case 14: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.4", true); - break; - case 15: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.5", true); - break; - default: - break; + string address = ""; + if (index == 1) address = "DB5.DBX1.7"; + if (index == 2) address = "DB5.DBX2.0"; + if (index == 3) address = "DB5.DBX2.1"; + if (index == 4) address = "DB5.DBX2.2"; + if (index == 5) address = "DB5.DBX2.3"; + if (index == 6) address = "DB5.DBX2.4"; + if (index == 7) address = "DB5.DBX2.5"; + if (index == 8) address = "DB5.DBX2.6"; + if (index == 9) address = "DB5.DBX2.7"; + if (index == 10) address = "DB5.DBX3.0"; + if (index == 11) address = "DB5.DBX3.1"; + if (index == 12) address = "DB5.DBX3.2"; + if (index == 13) address = "DB5.DBX3.3"; + if (index == 14) address = "DB5.DBX3.4"; + if (index == 15) address = "DB5.DBX3.5"; + HKDevice.HK_PLC_S7.Write(address, true); } } else if (o.ToString().Contains("进料桶顶升气缸")) @@ -484,112 +449,36 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (o.ToString().Contains("升降气缸")) { - int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); - switch (index) + int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); + if (index >= 1 && index <= 15) { - case 1: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.0", false); - break; - case 2: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.1", false); - break; - case 3: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.2", false); - break; - case 4: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.3", false); - break; - case 5: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.4", false); - break; - case 6: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.5", false); - break; - case 7: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.6", false); - break; - case 8: - HKDevice.HK_PLC_S7.Write("DB5.DBX0.7", false); - break; - case 9: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.0", false); - break; - case 10: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.1", false); - break; - case 11: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.2", false); - break; - case 12: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.3", false); - break; - case 13: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.4", false); - break; - case 14: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.5", false); - break; - case 15: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.6", false); - break; - default: - break; - + string address = "DB5.DBX" + (index / 8) + "." + (index % 8 - 1); + if (index == 8) address = "DB5.DBX0.7"; + HKDevice.HK_PLC_S7.Write(address, false); } } else if (o.ToString().Contains("阻挡气缸")) { - int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 1)); - switch (index) + int index = Convert.ToInt16(o.ToString().Substring(o.ToString().Length - 2)); + if (index >= 1 && index <= 15) { - case 1: - HKDevice.HK_PLC_S7.Write("DB5.DBX1.7", false); - break; - case 2: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.0", false); - break; - case 3: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.1", false); - break; - case 4: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.2", false); - break; - case 5: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.3", false); - break; - case 6: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.4", false); - break; - case 7: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.5", false); - break; - case 8: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.6", false); - break; - case 9: - HKDevice.HK_PLC_S7.Write("DB5.DBX2.7", false); - break; - case 10: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.0", false); - break; - case 11: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.1", false); - break; - case 12: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.2", false); - break; - case 13: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.3", false); - break; - case 14: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.4", false); - break; - case 15: - HKDevice.HK_PLC_S7.Write("DB5.DBX3.5", false); - break; - default: - break; - + string address = ""; + if (index == 1) address = "DB5.DBX1.7"; + if (index == 2) address = "DB5.DBX2.0"; + if (index == 3) address = "DB5.DBX2.1"; + if (index == 4) address = "DB5.DBX2.2"; + if (index == 5) address = "DB5.DBX2.3"; + if (index == 6) address = "DB5.DBX2.4"; + if (index == 7) address = "DB5.DBX2.5"; + if (index == 8) address = "DB5.DBX2.6"; + if (index == 9) address = "DB5.DBX2.7"; + if (index == 10) address = "DB5.DBX3.0"; + if (index == 11) address = "DB5.DBX3.1"; + if (index == 12) address = "DB5.DBX3.2"; + if (index == 13) address = "DB5.DBX3.3"; + if (index == 14) address = "DB5.DBX3.4"; + if (index == 15) address = "DB5.DBX3.5"; + HKDevice.HK_PLC_S7.Write(address, false); } } else if (o.ToString().Contains("进料桶顶升气缸")) @@ -624,7 +513,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { HKDevice.HK_PLC_S7.Write("DB5.DBX4.5", true); } - } }), "ManualClose", true);//根据下发的配方ID将 托盘的位置信息添加到配方中 } @@ -650,7 +538,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (HKDevice.HK_PLC_S7.Read("DB3.DBX1.7"))//允许下配方1或者允许下配方2 { GVL_SmallStation.IsAllowSiemensSendRecipe = true; - //MessageNotify.GetInstance.ShowRunLog("Plc允许下发配方"); } GVL_SmallStation.Station1Sensor = HKDevice.HK_PLC_S7.Read("DB3.DBX2.1"); @@ -699,7 +586,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.AGV_GetTray1Finish = false; } } - } } if (SiemensDevice.IsConnected) @@ -750,7 +636,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (data.TrayCode == 1) { - if (!(RecipeQueue.Contains(data.RecipeCode))) + if (!(RecipeQueueTray1.Contains(data.RecipeCode))) { if (SiemensDevice.XL_Status is XL_Status_DB status) { @@ -766,7 +652,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (SiemensDevice.XL_Status.Dosing_Confirm) { GVL_SmallStation.SiemensSendRecipeStatus = 5; - SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10); + SiemensDevice.Siemens_PLC_S7.WriteString(2231, "", 10);//复位字符串 SiemensDevice.Siemens_PLC_S7.Write("DB2231.DBX28.0", false); MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},配料信号复位"); } @@ -776,7 +662,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},西门子确认配料"); if (SiemensDevice.XL_Status.Dosing_Confirm == false) { - RecipeQueue.Enqueue(data.RecipeCode); + RecipeQueueTray1.Enqueue(data.RecipeCode); GVL_SmallStation.SiemensSendRecipeStatus = 6; MessageNotify.GetInstance.ShowRunLog($"配方{data.RecipeCode},加入队列"); } @@ -820,7 +706,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { - RecipeQueue.Clear(); + RecipeQueueTray1.Clear(); RecipeQueueTray2.Clear(); GVL_SmallStation.GetInstance.RecipeStatusID = 0; GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; @@ -835,9 +721,9 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { if (data.TrayCode == 1) { - if (!(RecipeQueue.Contains(data.RecipeCode))) + if (!(RecipeQueueTray1.Contains(data.RecipeCode))) { - RecipeQueue.Enqueue(data.RecipeCode); + RecipeQueueTray1.Enqueue(data.RecipeCode); } } else if (data.TrayCode == 2) @@ -852,7 +738,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } else { - RecipeQueue.Clear(); + RecipeQueueTray1.Clear(); RecipeQueueTray2.Clear(); GVL_SmallStation.GetInstance.DosingTray1 = false; @@ -865,15 +751,121 @@ namespace BPASmartClient.JXJFoodSmallStation.Model GVL_SmallStation.GetInstance.RecipeStatusIDTray2 = 0; } } + if (GVL_SmallStation.Order_Cancel) //订单取消 + { + if (!string.IsNullOrEmpty(GVL_SmallStation.Order_CancelRecipeCode)) + { + string code = GVL_SmallStation.Order_CancelRecipeCode; + int index = Array.FindIndex(Json.Data.Recipes.ToArray(), p => p.RecipeCode == code); + if (index >= 0) + { + short TrayCode = (short)Json.Data.Recipes.ElementAt(index).TrayCode; + if (RecipeQueueTray1.Contains(code) || RecipeQueueTray1.Contains(code)) + { + if (RecipeQueueTray1.Contains(code)) + { + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + if (GVL_SmallStation.GetInstance.RecipeStatusID != 0) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX2.1", true); + DateTime dateTime = DateTime.Now; + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}"); + while (!(HKDevice.HK_PLC_S7.Read("DB3.DBX2.5") || DateTime.Now.Subtract(dateTime).TotalSeconds >= 10)) + { + if (DateTime.Now.Subtract(dateTime).TotalSeconds > 1) + { + MessageNotify.GetInstance.ShowRunLog($"等待PLC取消订单完成:{code}"); + } + } + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,取消订单:{code}"); + } + else + { + 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}"); + } + else if (RecipeQueueTray2.Contains(code)) + { + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + if (GVL_SmallStation.GetInstance.RecipeStatusID != 0) + { + HKDevice.HK_PLC_S7.Write("DB4.DBX2.2", true); + DateTime dateTime = DateTime.Now; + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,正在取消订单:{code}"); + while (!(HKDevice.HK_PLC_S7.Read("DB3.DBX2.6") || DateTime.Now.Subtract(dateTime).TotalSeconds >= 10)) + { + if (DateTime.Now.Subtract(dateTime).TotalSeconds > 1) + { + MessageNotify.GetInstance.ShowRunLog($"等待PLC取消订单完成:{code}"); + } + } + MessageNotify.GetInstance.ShowRunLog($"PLC正在执行配料流程,已经取消订单:{code}"); + } + else + { + 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}"); + } + GVL_SmallStation.Order_Cancel = false; + GVL_SmallStation.Order_CancelRecipeCode = ""; + } + else + { + if (GVL_SmallStation.SiemensSendRecipeStatus != 0 || GVL_SmallStation.SiemensSendRecipeStatus != 1) + { + GVL_SmallStation.SiemensSendRecipeStatus = 0; + App.Current.Dispatcher.Invoke(() => + { + Json.Data.Recipes.RemoveAt(index); + }); + MessageNotify.GetInstance.ShowRunLog($"正在执行请求订单流程,配方还未到PLC,订单号:{code}"); + } + else + { + MessageNotify.GetInstance.ShowRunLog($"订单取消异常,订单号:{code}"); + } + + 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); + } + } + 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); + MessageNotify.GetInstance.ShowRunLog($"西门子取消订单,但未找到订单:{code}"); + } + } + } } /// /// 执行配方队列中的第一个配方 /// private void RecipeInfoToHKPLC() { - if (RecipeQueue.Count > 0 && GVL_SmallStation.TrayLogicFinish) + if (RecipeQueueTray1.Count > 0 && GVL_SmallStation.TrayLogicFinish) { - int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueue.ElementAt(0)); + int index = Array.FindIndex(RemoteRecipes.ToArray(), p => p.RecipeCode == RecipeQueueTray1.ElementAt(0)); if (index >= 0 && index < RemoteRecipes.Count) { string code = RemoteRecipes.ElementAt(index).RecipeCode; @@ -955,7 +947,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { var res = HKDevice.HK_PLC_S7.Read("DB3.DBD14"); MessageNotify.GetInstance.ShowRunLog($"托盘1,配方:{recipeName},2号桶,{res}料仓,允许配料"); - if (res > 0 && res is float loc) + if (res > 0 && res is float loc) { int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; @@ -976,7 +968,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (res > 0 && res is float loc) { int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight*1000; + float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; if (loc_index >= 0) { DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量 @@ -994,7 +986,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (res > 0 && res is float loc) { int loc_index = Array.FindIndex(RemoteRecipes.ElementAt(index).RawMaterial.ToArray(), p => p.RawMaterialLocation == loc); - float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight*1000; + float weight = RemoteRecipes.ElementAt(index).RawMaterial.ElementAt(loc_index).RawMaterialWeight * 1000; if (loc_index >= 0) { DeviceInquire.GetInstance.GetDevice((int)loc)?.Start(weight);//启动并写入每个原料重量 @@ -1082,7 +1074,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { Json.Data.Recipes.Remove(res); }); - RecipeQueue.TryDequeue(out code); + RecipeQueueTray1.TryDequeue(out code); HKDevice.HK_PLC_S7.Write("DB3.DBX1.1", false); GVL_SmallStation.GetInstance.RecipeStatusID = 0; } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs index dade7066..c945af8a 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/RawMaterial/DeviceInquire.cs @@ -60,7 +60,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model } } Thread.Sleep(200); - }), "设备状态监听"); + }), "设备状态监听",true); } private void TestData() { diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index 15fdd74d..70b95a09 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using BPASmartClient.S7Net; using System.Threading; +using BPASmartClient.CustomResource.Pages.Model; namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { @@ -47,6 +48,12 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens GVL_SmallStation.IsAllowSiemensSendRecipe = false; GVL_SmallStation.SiemensSendRecipeStatus = 3; } + if (RTrig.GetInstance("Order_Cancel").Start(st.Order_Cancel)) //订单取消 + { + GVL_SmallStation.Order_Cancel = true; + GVL_SmallStation.Order_CancelRecipeCode = st.RecipeCode; + MessageNotify.GetInstance.ShowRunLog($"西门子下发取消工单指令:{st.RecipeName}"); + } } if (Finish != null && Finish is XL_Finish_DB FinishData) { @@ -76,8 +83,6 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens XL_Status.Powder[i] = new PowderStatus(); } XL_Status = state; - - } var res = ProcessControl.GetInstance.HKDevice.DeviceStatus; diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs index 3746f978..dc4f5e41 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/XL_Start_DB.cs @@ -37,11 +37,13 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens /// 西门子下发订单 /// public bool Order_Request_ACK { get; set; } + public bool Order_Cancel { get; set; } public short[] Standby { get; set; } = new short[4]; /// /// 上位机订单请求 /// public bool Order_Request { get; set; } + public bool Order_Cancel_ACK { get; set; } public short[] Standby1 { get; set; } = new short[4]; } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/VarMonitor.cs b/BPASmartClient.JXJFoodSmallStation/Model/VarMonitor.cs new file mode 100644 index 00000000..3755818c --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/Model/VarMonitor.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BPASmartClient.JXJFoodSmallStation.Model +{ + public class VarMonitor + { + /// + /// 序号 + /// + public int SerialNum { get; set; } + /// + /// 变量地址 + /// + public string Address { get; set; } + /// + /// 变量描述 + /// + public string Describe { get; set; } + /// + /// 变量值当前值 + /// + public string NowValue { get; set; } + /// + /// 变量值设定值 + /// + public string SetValue { get; set; } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml b/BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml index c8f573bc..5763c30c 100644 --- a/BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml +++ b/BPASmartClient.JXJFoodSmallStation/View/ManualCommView.xaml @@ -66,11 +66,11 @@ - - - - - + + + + + @@ -96,12 +96,12 @@ - - - - - - + + + + + + + diff --git a/BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml b/BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml new file mode 100644 index 00000000..acba7e18 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml.cs b/BPASmartClient.JXJFoodSmallStation/View/RobotView.xaml.cs new file mode 100644 index 00000000..f8b3817b --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/View/RobotView.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 RobotView : UserControl + { + public RobotView() + { + InitializeComponent(); + } + } +} diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs index e4d3853f..1de388e5 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualCommViewModel.cs @@ -20,36 +20,18 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { public ManualCommViewModel() { - for (int i = 0; i < 8; i++) + PlcDataColl.Add(new VarMonitor() { SerialNum = PlcDataColl.Count , Address="",}); + SetParCommand = new RelayCommand((o) => { - if (i < 4) - { - PlcInfo.Add(new PlcManualComm() - { - SerialNum = PlcInfo.Count + 1, - Address = "DB3.DBD" + (10 + 4 * i), - Describe = $"托盘1_{i + 1}#桶位置反馈", - }); - } - else + if (o != null && o is string address) { - PlcInfo.Add(new PlcManualComm() - { - SerialNum = PlcInfo.Count + 1, - Address = "DB3.DBD" + (10 + 4 * i), - Describe = $"托盘2_{i-3}#桶位置反馈", - }); + var res = PlcDataColl.FirstOrDefault(p =>p.Address == address); } - } - SetParCommand = new RelayCommand((o) => - { }); - } - public ObservableCollection PlcInfo { get; set; } = new ObservableCollection(); + public static ObservableCollection PlcDataColl { get; set; } = new ObservableCollection(); public RelayCommand SetParCommand { get; set; } - public RelayCommand Connect { get; set; } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs index 3f4f7320..ad281348 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualControlViewModel.cs @@ -20,7 +20,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { ThreadManage.GetInstance().StartLong(new Action(() => { - SystemMode = GVL_SmallStation.SystemMode ? "自动" : "手动"; + SystemMode = GVL_SmallStation.SystemMode ? "手动" : "自动"; if (GVL_SmallStation.SystemStatus) { if (GVL_SmallStation.SystemRunStatus) diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs index a31bdecb..fa79e115 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/ManualFlowViewModel.cs @@ -55,6 +55,10 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel { ActionManage.GetInstance.Send("ManualSystemReset"); }); + BPAResetCommand = new RelayCommand(() => + { + ActionManage.GetInstance.Send("BPASystemReset"); + }); ThreadManage.GetInstance().StartLong(new Action(() => { Heartbeat = GVL_SmallStation.GetInstance.HeartBeatFromPlc; @@ -66,7 +70,6 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel public RelayCommand Test3Command { get; set; } public RelayCommand Test4Command { get; set; } public RelayCommand Test5Command { get; set; } - public RelayCommand Test6Command { get; set; } public static bool Heartbeat { get { return _mHeartbeat; } set { _mHeartbeat = value; OnStaticPropertyChanged(); } } private static bool _mHeartbeat; @@ -78,5 +81,6 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel } public RelayCommand CLearRecipeInfo { get; set; } public RelayCommand SystemReset { get; set; } + public RelayCommand BPAResetCommand { get; set; } } } diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs index 67a18899..4170fcea 100644 --- a/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RecipeControlViewModel.cs @@ -154,7 +154,7 @@ namespace BPASmartClient.JXJFoodSmallStation.ViewModel } } Thread.Sleep(100); - }), "RecipeControlViewModelStatusInquire"); + }), "RecipeControlViewModelStatusInquire",true); //测试数据 /* RawMaterialModel rawMaterial_1 = new RawMaterialModel { RawMaterialName = "香料_1" }; RawMaterialModel rawMaterial_2 = new RawMaterialModel { RawMaterialName = "香料_2" }; diff --git a/BPASmartClient.JXJFoodSmallStation/ViewModel/RobotViewModel.cs b/BPASmartClient.JXJFoodSmallStation/ViewModel/RobotViewModel.cs new file mode 100644 index 00000000..00e74683 --- /dev/null +++ b/BPASmartClient.JXJFoodSmallStation/ViewModel/RobotViewModel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Toolkit.Mvvm.ComponentModel; +using System.Collections.ObjectModel; +using BPASmartClient.JXJFoodSmallStation.Model; +using BPASmartClient.Helper; +using Microsoft.Toolkit.Mvvm.Input; +using BPASmartClient.CustomResource.UserControls.MessageShow; +using BPASmartClient.CustomResource.UserControls; +using System.Diagnostics; +using BPASmartClient.JXJFoodSmallStation.Model.Siemens; +using BPASmartClient.JXJFoodSmallStation.Model.HK_PLC; +using System.Threading; +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace BPASmartClient.JXJFoodSmallStation.ViewModel +{ + public class RobotViewModel : ObservableObject + { + public RobotViewModel() + { + } + + public RelayCommand SystemStart { get; set; } + public RelayCommand SystemStop { get; set; } + public RelayCommand SystemReset { get; set; } + public RelayCommand AlarmReset { get; set; } + public RelayCommand TestRobotRun { get; set; } + public RelayCommand Tray1Cylinder { get; set; } + + public short IsRunProgramNum { get { return _runProgramNum; } set { _runProgramNum = value;OnPropertyChanged(); } } + private short _runProgramNum; + public short SetProgramNum { get { return _SetProgramNum; } set { _SetProgramNum = value; OnPropertyChanged(); } } + private short _SetProgramNum; + public static event EventHandler StaticPropertyChanged; + public static void OnStaticPropertyChanged([CallerMemberName] string PropName = "") + { + StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs(PropName)); + } + } +} diff --git a/BPASmartClient.MorkBF/Control_MorkBF.cs b/BPASmartClient.MorkBF/Control_MorkBF.cs index 3f586713..91fef0bb 100644 --- a/BPASmartClient.MorkBF/Control_MorkBF.cs +++ b/BPASmartClient.MorkBF/Control_MorkBF.cs @@ -44,7 +44,6 @@ namespace BPASmartClient.MorkBF GlobalFoodMenu.LocalFoodMenus.Add(new FoodMenuModel { GoodKey = item.GoodKey, GoodName = item.GoodName }); } } - }), "更新菜单"); CommandRegist();//调试 ServerInit(); @@ -126,7 +125,6 @@ namespace BPASmartClient.MorkBF #endregion - } public override void MainTask() diff --git a/BPASmartClient.MorkBF/GVL_MorkBF.cs b/BPASmartClient.MorkBF/GVL_MorkBF.cs index 77d07805..0fd64e11 100644 --- a/BPASmartClient.MorkBF/GVL_MorkBF.cs +++ b/BPASmartClient.MorkBF/GVL_MorkBF.cs @@ -269,7 +269,156 @@ namespace BPASmartClient.MorkBF public int FirePot2_FlipSpeed { get; set; } = 0; #endregion + #region 机器人数据读取 + //public bool Robot_IsBusy; + + + ///// + ///// 机器人倒料完成 + ///// + //[VariableMonitor("机器人倒料完成", "GM500", "4596")] + //public bool Robot_OutMaterialCompleted { get; set; } + + ///// + ///// 机器人上使能 + ///// + //[VariableMonitor("机器人上使能", "GM600.0", "4596")] + //public bool Robot_Enable { get; set; } + ///// + ///// 机器人复位 + ///// + //[VariableMonitor("机器人复位", "GM600.1", "4597")] + //public bool Robot_Reset { get; set; } + ///// + ///// 机器人启动 + ///// + //[VariableMonitor("机器人启动", "GM600.2", "4598")] + //public bool Robot_Start { get; set; } + ///// + ///// 机器人停止 + ///// + //[VariableMonitor("机器人停止", "GM600.3", "4599")] + //public bool Robot_Stop { get; set; } + ///// + ///// 机器人动作反馈GI0 + ///// + //[VariableMonitor("机器人动作反馈GI0", "GI0", "0")] + //public int Robot_GI0ActionCallback { get; set; } + ///// + ///// 机器人动作反馈GI1 + ///// + //[VariableMonitor("机器人动作反馈GI1", "GI1", "1")] + //public int Robot_GI1ActionCallback { get; set; } + ///// + ///// 机器人动作反馈GI2 + ///// + //[VariableMonitor("机器人动作反馈GI2", "GI2", "2")] + //public int Robot_GI2ActionCallback { get; set; } + ///// + ///// 机器人动作反馈GI3 + ///// + //[VariableMonitor("机器人动作反馈GI3", "GI3", "3")] + //public int Robot_GI3ActionCallback { get; set; } + ///// + ///// 机器人动作反馈GI4 + ///// + //[VariableMonitor("机器人动作反馈GI4", "GI4", "4")] + //public int Robot_GI4ActionCallback { get; set; } + #endregion + //新版大炒的通讯协议 2023/01/15 + #region 炒锅1读取数据 + [VariableMonitor("1#炒锅初始化完成", "M40.0")] + public bool FryPan1_InitComplete { get; set; } + [VariableMonitor("1#炒锅手动/自动模式切换", "M40.1")] + public bool FryPan1_ManualOrAutoMode { get; set; } + [VariableMonitor("1#炒锅急停", "M40.2")] + public bool FryPan1_EStop { get; set; } + [VariableMonitor("1#炒锅在位置1反馈", "M40.3")] + public bool FryPan1_InPosition1 { get; set; } + [VariableMonitor("1#炒锅在位置2反馈", "M40.4")] + public bool FryPan1_InPosition2 { get; set; } + [VariableMonitor("1#炒锅在位置3反馈", "M40.5")] + public bool FryPan1_InPosition3 { get; set; } + [VariableMonitor("1#炒锅在位置4反馈", "M40.6")] + public bool FryPan1_InPosition4 { get; set; } + [VariableMonitor("1#炒锅在出餐口倒料位置", "M40.7")] + public bool FryPan1_InPositionUnload { get; set; } + [VariableMonitor("1#炒锅在进料口位置", "M41.0")] + public bool FryPan1_InPositionload { get; set; } + [VariableMonitor("1#炒锅在洗锅位置", "M41.1")] + public bool FryPan1_InPositionWashPot { get; set; } + [VariableMonitor("1#炒锅通道1出料完成", "M41.2")] + public bool FryPan1_UnloadFinishCH1 { get; set; } + [VariableMonitor("1#炒锅通道2出料完成", "M41.3")] + public bool FryPan1_UnloadFinishCH2 { get; set; } + [VariableMonitor("1#炒锅通道3出料完成", "M41.4")] + public bool FryPan1_UnloadFinishCH3 { get; set; } + [VariableMonitor("1#炒锅通道4出料完成", "M41.5")] + public bool FryPan1_UnloadFinishCH4 { get; set; } + [VariableMonitor("1#炒锅通道5出料完成", "M41.6")] + public bool FryPan1_UnloadFinishCH5 { get; set; } + [VariableMonitor("1#炒锅通道6出料完成", "M41.7")] + public bool FryPan1_UnloadFinishCH6 { get; set; } + [VariableMonitor("1#炒锅通道7出料完成", "M42.0")] + public bool FryPan1_UnloadFinishCH7 { get; set; } + [VariableMonitor("1#炒锅通道8出料完成", "M42.1")] + public bool FryPan1_UnloadFinishCH8 { get; set; } + [VariableMonitor("1#炒锅当前温度", "VM200")] + public short FryPan1_TemperatureNow { get; set; } + [VariableMonitor("1#炒锅当前搅拌转速", "VM202")] + public short FryPan1_MixingSpeedNow { get; set; } + [VariableMonitor("1#炒锅当前炒制角度", "VM204")] + public short FryPan1_FryAngle{ get; set; } + [VariableMonitor("1#炒锅当前加热挡位", "VM206")] + public short FryPan1_HeatingGearNow{ get; set; } + #endregion + #region 炒锅2读取数据 + [VariableMonitor("2#炒锅初始化完成", "M40.0")] + public bool FryPan2_InitComplete { get; set; } + [VariableMonitor("2#炒锅手动/自动模式切换", "M40.1")] + public bool FryPan2_ManualOrAutoMode { get; set; } + [VariableMonitor("2#炒锅急停", "M40.2")] + public bool FryPan2_EStop { get; set; } + [VariableMonitor("2#炒锅在位置1反馈", "M40.3")] + public bool FryPan2_InPosition1 { get; set; } + [VariableMonitor("2#炒锅在位置2反馈", "M40.4")] + public bool FryPan2_InPosition2 { get; set; } + [VariableMonitor("2#炒锅在位置3反馈", "M40.5")] + public bool FryPan2_InPosition3 { get; set; } + [VariableMonitor("2#炒锅在位置4反馈", "M40.6")] + public bool FryPan2_InPosition4 { get; set; } + [VariableMonitor("2#炒锅在出餐口倒料位置", "M40.7")] + public bool FryPan2_InPositionUnload { get; set; } + [VariableMonitor("2#炒锅在进料口位置", "M41.0")] + public bool FryPan2_InPositionload { get; set; } + [VariableMonitor("2#炒锅在洗锅位置", "M41.1")] + public bool FryPan2_InPositionWashPot { get; set; } + [VariableMonitor("2#炒锅通道1出料完成", "M41.2")] + public bool FryPan2_UnloadFinishCH1 { get; set; } + [VariableMonitor("2#炒锅通道2出料完成", "M41.3")] + public bool FryPan2_UnloadFinishCH2 { get; set; } + [VariableMonitor("2#炒锅通道3出料完成", "M41.4")] + public bool FryPan2_UnloadFinishCH3 { get; set; } + [VariableMonitor("2#炒锅通道4出料完成", "M41.5")] + public bool FryPan2_UnloadFinishCH4 { get; set; } + [VariableMonitor("2#炒锅通道5出料完成", "M41.6")] + public bool FryPan2_UnloadFinishCH5 { get; set; } + [VariableMonitor("2#炒锅通道6出料完成", "M41.7")] + public bool FryPan2_UnloadFinishCH6 { get; set; } + [VariableMonitor("2#炒锅通道7出料完成", "M42.0")] + public bool FryPan2_UnloadFinishCH7 { get; set; } + [VariableMonitor("2#炒锅通道8出料完成", "M42.1")] + public bool FryPan2_UnloadFinishCH8 { get; set; } + [VariableMonitor("2#炒锅当前温度", "VM200")] + public short FryPan2_TemperatureNow { get; set; } + [VariableMonitor("2#炒锅当前搅拌转速", "VM202")] + public short FryPan2_MixingSpeedNow { get; set; } + [VariableMonitor("2#炒锅当前炒制角度", "VM204")] + public short FryPan2_FryAngle { get; set; } + [VariableMonitor("2#炒锅当前加热挡位", "VM206")] + public short FryPan2_HeatingGearNow { get; set; } + #endregion #region 机器人数据读取 public bool Robot_IsBusy; @@ -303,31 +452,30 @@ namespace BPASmartClient.MorkBF /// /// 机器人动作反馈GI0 /// - [VariableMonitor("机器人动作反馈GI0", "GI0", "0")] + [VariableMonitor("机器人动作反馈GI5", "GI5", "5")] public int Robot_GI0ActionCallback { get; set; } /// /// 机器人动作反馈GI1 /// - [VariableMonitor("机器人动作反馈GI1", "GI1", "1")] + [VariableMonitor("机器人动作反馈GI6", "GI6", "6")] public int Robot_GI1ActionCallback { get; set; } /// /// 机器人动作反馈GI2 /// - [VariableMonitor("机器人动作反馈GI2", "GI2", "2")] + [VariableMonitor("机器人动作反馈GI7", "GI7", "7")] public int Robot_GI2ActionCallback { get; set; } /// /// 机器人动作反馈GI3 /// - [VariableMonitor("机器人动作反馈GI3", "GI3", "3")] + [VariableMonitor("机器人动作反馈GI8", "GI8", "8")] public int Robot_GI3ActionCallback { get; set; } /// /// 机器人动作反馈GI4 /// - [VariableMonitor("机器人动作反馈GI4", "GI4", "4")] + [VariableMonitor("机器人动作反馈GI9", "GI9", "9")] public int Robot_GI4ActionCallback { get; set; } #endregion - public Dictionary FirePot1_CompleteSingle { get; set; } public Dictionary FirePot2_CompleteSingle { get; set; } diff --git a/BPASmartClient.S7Net/EntityClassResolution.cs b/BPASmartClient.S7Net/EntityClassResolution.cs index b9ddd591..90d60ade 100644 --- a/BPASmartClient.S7Net/EntityClassResolution.cs +++ b/BPASmartClient.S7Net/EntityClassResolution.cs @@ -27,25 +27,30 @@ namespace BPASmartClient.S7Net numBytes += 0.125; break; case "Byte": + IncrementToEven(ref numBytes); numBytes += 1.0; break; case "Int16": case "UInt16": case "Ushort": case "Short": + IncrementToEven(ref numBytes); numBytes += 2.0; break; case "Int32": case "UInt32": case "Single": case "float": + IncrementToEven(ref numBytes); numBytes += 4.0; break; case "Double": + IncrementToEven(ref numBytes); numBytes += 8.0; break; case "String": //numBytes += 256.0; + IncrementToEven(ref numBytes); double len = 256.0; if (propertyInfo.CustomAttributes.Count() > 0) { @@ -202,7 +207,7 @@ namespace BPASmartClient.S7Net //Array.Copy(bytes, (int)numBytes, sarray, 0, 256); //obj = GetGb2312()?.GetString(sarray).Trim().Replace(" ", "").Replace("\n", ""); //numBytes += 256.0; - + IncrementToEven(ref numBytes); int len = 256; if (propertyInfo.CustomAttributes.Count() > 0) { diff --git a/DosingSystem/App.xaml.cs b/DosingSystem/App.xaml.cs index bd5ab497..b051e05c 100644 --- a/DosingSystem/App.xaml.cs +++ b/DosingSystem/App.xaml.cs @@ -38,10 +38,7 @@ namespace BPASmartClient.DosingSystem BPASmartClient.Helper.SystemHelper.GetInstance.CreateDesktopShortcut(); MenuInit(); DataInit(); - ThreadManage.GetInstance().Start(new Action(() => - { - DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 - }), "设备初始化"); + DeviceInquire.GetInstance.Init();//配料机设备上线监听,设备列表初始化 MainView mv = new MainView(); mv.TitleName = "味魔方管理系统软件[简称:味魔方] 1.0.1"; LoginView lv = new LoginView(); @@ -61,6 +58,7 @@ namespace BPASmartClient.DosingSystem base.OnExit(e); Json.Save(); Json.Save(); + Json.Save(); BPASmartClient.CustomResource.Pages.Model.MessageNotify.GetInstance.LogSave(); ThreadManage.GetInstance().Dispose(); } diff --git a/DosingSystem/App1.config b/DosingSystem/App1.config new file mode 100644 index 00000000..6d2e3782 --- /dev/null +++ b/DosingSystem/App1.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DosingSystem/Model/DeviceInquire.cs b/DosingSystem/Model/DeviceInquire.cs index 1bd559d6..bcd7e89b 100644 --- a/DosingSystem/Model/DeviceInquire.cs +++ b/DosingSystem/Model/DeviceInquire.cs @@ -59,7 +59,7 @@ namespace BPASmartClient.DosingSystem } } Thread.Sleep(200); - }), "设备状态监听"); + }), "设备状态监听",true); } private void TestData() @@ -156,7 +156,7 @@ namespace BPASmartClient.DosingSystem { IPLists.Clear(); IPQueues.Clear(); - for (int i = 1; i <= 255; i++) + /*for (int i = 1; i <= 255; i++) { if (!InvalidIP.Contains($"{IPSegment}{i}") && !DeviceLists.ContainsKey($"{IPSegment}{i}")) { @@ -166,6 +166,10 @@ namespace BPASmartClient.DosingSystem IPLists.Add($"{IPSegment}{i}"); } } + }*/ + for (int i = 0; i < 15; i++) + { + IPLists.Add($"{IPSegment}{(i+1)*10}"); } IPLists.ForEach((item) => @@ -230,13 +234,13 @@ namespace BPASmartClient.DosingSystem } else { - if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); + //if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); } }); DS.modbusTcp.ConnectFail = new Action(() => { - if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); + //if (!InvalidIP.Contains(ip)) InvalidIP.Add(ip); }); DS.modbusTcp.Disconnect = new Action(() => @@ -258,7 +262,12 @@ namespace BPASmartClient.DosingSystem })); } - if (DeviceLists.ContainsKey(ip)) DeviceLists[ip].Dispose(); + if (DeviceLists.ContainsKey(ip)) + { + DeviceLists[ip].Dispose(); + var res11 = DeviceLists[ip]; + DeviceLists.TryRemove(ip, out res11); + } }); Task.Run(new Action(() => diff --git a/DosingSystem/Model/RecipeModel.cs b/DosingSystem/Model/RecipeModel.cs index d3ac46ea..d68b97c1 100644 --- a/DosingSystem/Model/RecipeModel.cs +++ b/DosingSystem/Model/RecipeModel.cs @@ -44,7 +44,6 @@ namespace BPASmartClient.DosingSystem public string RecipStatus { get { return _mRecipStatus; } set { _mRecipStatus = value; OnPropertyChanged(); } } private string _mRecipStatus; - /// /// 原料集合 /// diff --git a/DosingSystem/Service/SiemensDevice.cs b/DosingSystem/Service/SiemensDevice.cs index 2c077e3d..71ec3705 100644 --- a/DosingSystem/Service/SiemensDevice.cs +++ b/DosingSystem/Service/SiemensDevice.cs @@ -20,32 +20,33 @@ namespace BPASmartClient.DosingSystem public SiemensHelper MySiemens { get; set; } = new SiemensHelper(); private bool IsConnect { get; set; } - bool tempValue = false; + public bool tempValue = false; public void Connect(string ip) { - try + ThreadManage.GetInstance().StartLong(new Action(() => { - while (!MySiemens.IsConnected) + if (IsConnect) { - MySiemens.Connect(S7.Net.CpuType.S71200, ip); - Thread.Sleep(2000); + MySiemens.Write("DB4.DBX0.0", tempValue);//设备心跳 + tempValue = !tempValue; } - } - catch (Exception ex) - { - - } - IsConnect = MySiemens.IsConnected; - ThreadManage.GetInstance().StartLong(new Action(() => - { - if (IsConnect) MySiemens.Write("DB4.DBX0.0", tempValue);//设备心跳 - tempValue = !tempValue; - //MessageNotify.GetInstance.ShowUserLog($"心跳发送{tempValue}"); - Thread.Sleep(100); + Thread.Sleep(200); }), "设备心跳", true); - ThreadManage.GetInstance().StartLong(new Action(() => { + try + { + while (!MySiemens.IsConnected) + { + MySiemens.Connect(S7.Net.CpuType.S71200, ip); + Thread.Sleep(2000); + } + } + catch (Exception ex) + { + + } + IsConnect = MySiemens.IsConnected; if (IsConnect) { GlobalDevice.PlcData = MySiemens.ReadClass(3);//获取PLC到上位机的数据 @@ -54,13 +55,12 @@ namespace BPASmartClient.DosingSystem { GlobalDevice.MotorSpeed = ushorts; } - GlobalDevice.MotorControl = MySiemens.Read("DB5.DBD6");//获取输送带控制信号 - //GlobalDevice.MotorControlFeedback = MySiemens.Read("DB3.DBD0");//获取当前输送带运行状态 - GlobalDevice.MotorControl = (uint)(GlobalDevice.MotorControl.ToBytes(BPA.Helper.DataFormat.ABCD)).ToInt(); - Thread.Sleep(50); + uint data = MySiemens.Read("DB5.DBD6");//获取输送带控制信号 + //GlobalDevice.MotorControlFeedback = MySiemens.Read("DB3.DBD0");//获取当前输送带运行状态 + GlobalDevice.MotorControl = (uint)(data.ToBytes(BPA.Helper.DataFormat.ABCD)).ToInt(); } + Thread.Sleep(50); }), "读取输送线设备数据", true); - } /// diff --git a/DosingSystem/ViewModel/DeviceMaterialParViewModel.cs b/DosingSystem/ViewModel/DeviceMaterialParViewModel.cs index 1060dd5b..7dca646b 100644 --- a/DosingSystem/ViewModel/DeviceMaterialParViewModel.cs +++ b/DosingSystem/ViewModel/DeviceMaterialParViewModel.cs @@ -25,34 +25,34 @@ namespace BPASmartClient.DosingSystem.ViewModel AddCommand = new BPARelayCommand(() => { deviceParModels.Add(new DeviceParModel()); }); SaveCommand = new BPARelayCommand(() => - { - if (deviceParModels == null || deviceParModels.Count <= 0) - { - NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"没有可保存的参数!"); - return; - } + { + if (deviceParModels == null || deviceParModels.Count <= 0) + { + NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", $"没有可保存的参数!"); + return; + } - for (int i = 0; i < deviceParModels.Count; i++) - { - if (deviceParModels.Where(p => p.MaterialName == deviceParModels.ElementAt(i).MaterialName)?.ToList()?.Count >= 2) - deviceParModels.ElementAt(i).IsRedundant = true; - else - deviceParModels.ElementAt(i).IsRedundant = false; - } + for (int i = 0; i < deviceParModels.Count; i++) + { + if (deviceParModels.Where(p => p.MaterialName == deviceParModels.ElementAt(i).MaterialName)?.ToList()?.Count >= 2) + deviceParModels.ElementAt(i).IsRedundant = true; + else + deviceParModels.ElementAt(i).IsRedundant = false; + } - if (deviceParModels.FirstOrDefault(p => p.IsRedundant == true) != null) - { - NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", $"原料名称冲突,请检查后重试!"); - return; - } + if (deviceParModels.FirstOrDefault(p => p.IsRedundant == true) != null) + { + NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, App.MainWindow, "错误", $"原料名称冲突,请检查后重试!"); + return; + } - deviceParModels.Where(P => P.MaterialName.Length <= 0)?.ToList()?.ForEach(item => - { - Json.Data.deviceParModels.Remove(item); - }); - Json.Save(); - NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"原料参数保存成功!"); - }); + deviceParModels.Where(P => P.MaterialName.Length <= 0)?.ToList()?.ForEach(item => + { + Json.Data.deviceParModels.Remove(item); + }); + Json.Save(); + NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, App.MainWindow, "提示", $"原料参数保存成功!"); + }); } public ObservableCollection deviceParModels { get; set; } diff --git a/DosingSystem/ViewModel/HardwareStatusViewModel.cs b/DosingSystem/ViewModel/HardwareStatusViewModel.cs index 3f568d93..c1193712 100644 --- a/DosingSystem/ViewModel/HardwareStatusViewModel.cs +++ b/DosingSystem/ViewModel/HardwareStatusViewModel.cs @@ -60,7 +60,7 @@ namespace BPASmartClient.DosingSystem.ViewModel UnderDetection = GlobalDevice.PlcData.UnderDetection; ConveyerBeltStatus = GlobalDevice.MotorControlFeedback > 0; Thread.Sleep(100); - }), "输送带料仓状态监控"); + }), "输送带料仓状态监控",true); RecipeControlCommand = new BPARelayCommand((o) => { diff --git a/DosingSystem/ViewModel/ManualControlViewModel.cs b/DosingSystem/ViewModel/ManualControlViewModel.cs index 3b5084bb..e9bbdbba 100644 --- a/DosingSystem/ViewModel/ManualControlViewModel.cs +++ b/DosingSystem/ViewModel/ManualControlViewModel.cs @@ -136,7 +136,7 @@ namespace BPASmartClient.DosingSystem.ViewModel SystemMode = GlobalDevice.PlcData.HandOrAuto ? "自动" : "手动"; Thread.Sleep(100); - }), "手动气缸状态监控"); + }), "手动气缸状态监控",true); } private void Init() diff --git a/DosingSystem/ViewModel/RecipeControlViewModel.cs b/DosingSystem/ViewModel/RecipeControlViewModel.cs index 1937c2d7..0198a7da 100644 --- a/DosingSystem/ViewModel/RecipeControlViewModel.cs +++ b/DosingSystem/ViewModel/RecipeControlViewModel.cs @@ -278,7 +278,7 @@ namespace BPASmartClient.DosingSystem.ViewModel } } Thread.Sleep(100); - }), "启动配方下发"); + }), "启动配方下发",true); } /// @@ -308,100 +308,273 @@ namespace BPASmartClient.DosingSystem.ViewModel } for (int j = 0; j < GlobalDevice.PlcData.IsAllowIngredients.Length; j++) { + //if (GlobalDevice.PlcData.IsAllowIngredients[j]) + //{ + // int barrel = j + 1;//桶号 + // int cnt = GlobalDevice.PlcData.LocationFeedback[j];//允许配料的位置 0~6 + // if (RTrig.GetInstance("a").Start(GlobalDevice.PlcData.IsAllowIngredients[j])) + // { + // MessageNotify.GetInstance.ShowRunLog($"桶号:{barrel},位置:{cnt},允许配料"); + // } + // int Location1 = 0; + // int Location2 = 0; + // if (cnt == -1) + // { + // MessageNotify.GetInstance.ShowRunLog("错误"); + // return; + // } + // else + // { + // switch (cnt) + // { + // case 1: + // int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 1); + // int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 2); + // if (a1 >= 0) + // { + // Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); + // } + // if (b1 >= 0) + // { + // Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel); + // } + // break; + // case 2: + // int a2 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 3); + // int b2 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 4); + // if (a2 >= 0) + // { + // Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a2).DeviceName && p.Loc == barrel); + // } + // if (b2 >= 0) + // { + // Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b2).DeviceName && p.Loc == barrel); + // } + // break; + // case 3: + // int a3 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 5); + // int b3 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 6); + // if (a3 >= 0) + // { + // Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a3).DeviceName && p.Loc == barrel); + // } + // if (b3 >= 0) + // { + // Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b3).DeviceName && p.Loc == barrel); + // } + // break; + // case 4: + // int a4 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 7); + // int b4 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 8); + // if (a4 >= 0) + // { + // Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a4).DeviceName && p.Loc == barrel); + // } + // if (b4 >= 0) + // { + // Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b4).DeviceName && p.Loc == barrel); + // } + // break; + // case 5: + // int a5 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 9); + // int b5 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 10); + // if (a5 >= 0) + // { + // Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a5).DeviceName && p.Loc == barrel); + // } + // if (b5 >= 0) + // { + // Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b5).DeviceName && p.Loc == barrel); + // } + // break; + // case 6: + // int a6 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 11); + // int b6 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 12); + // if (a6 >= 0) + // { + // Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a6).DeviceName && p.Loc == barrel); + // } + // if (b6 >= 0) + // { + // Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b6).DeviceName && p.Loc == barrel); + // } + // break; + // default: + // break; + // } + // } + // if (Location1 >= 0) + // { + // string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialName; + // int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName); + // int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum; + // if (DeviceNum > 0) + // { + // float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialWeight; + // int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName); + // if (loc >= 0 && RawName != null && weight >= 0) + // { + // int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); + // if (St_index < 0) + // { + // StockStatus.Add(new StockStatusModel() + // { + // MaterialName = RawName, + // IssueWeight = weight, + // IssueStatus = 0, + // }); + // } + // St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); + // if (St_index >= 0) + // { + // if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0) + // { + // StockStatus.ElementAt(St_index).IssueStatus = 1; + // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); + // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); + // } + // if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) + // { + // //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 + // StockStatus.ElementAt(St_index).IssueStatus = 2; + // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); + // int a = 0.SetBitValue((byte)(DeviceNum), true); + // byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); + // int item = test1.ToInt(); + // string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item,2); + // MessageNotify.GetInstance.ShowRunLog($"{res}"); + // MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); + // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); + // } + // } + // } + // } + // } + // if (Location1 >= 0) + // { + + // string RawName111 = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialName; + // int St_index111 = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName111); + // if (Location2 >= 0 && ((Location1 >= 0 && StockStatus.ElementAt(St_index111).IssueStatus == 2))) + // { + // string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName; + // int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName); + // int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum; + // if (DeviceNum > 0) + // { + // float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight; + // int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName); + // if (loc >= 0 && RawName != null && weight >= 0) + // { + // int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); + // if (St_index < 0) + // { + // StockStatus.Add(new StockStatusModel() + // { + // MaterialName = RawName, + // IssueWeight = weight, + // IssueStatus = 0, + // }); + // } + // St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); + // if (St_index >= 0) + // { + // if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0) + // { + // StockStatus.ElementAt(St_index).IssueStatus = 1; + // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); + // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); + // } + // if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) + // { + // //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 + // StockStatus.ElementAt(St_index).IssueStatus = 2; + // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); + // int a = 0.SetBitValue((byte)(DeviceNum), true); + // byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); + // int item = test1.ToInt(); + // string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 5); + // MessageNotify.GetInstance.ShowRunLog($"{res}"); + // //MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); + // MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item}"); + // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); + // } + // } + // } + // } + // } + // } + // else + // { + // if (Location2 >= 0) + // { + // string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName; + // int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName); + // int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum; + // if (DeviceNum >= 0) + // { + // float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight; + // int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName); + // if (cnt > 0 && loc >= 0 && RawName != null && weight >= 0) + // { + // int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); + // if (St_index < 0) + // { + // StockStatus.Add(new StockStatusModel() + // { + // MaterialName = RawName, + // IssueWeight = weight, + // IssueStatus = 0, + // }); + // } + // St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); + // if (St_index >= 0) + // { + // if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0) + // { + // StockStatus.ElementAt(St_index).IssueStatus = 1; + // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); + // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); + // } + // if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) + // { + // //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 + // StockStatus.ElementAt(St_index).IssueStatus = 2; + // DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); + // int a = 0.SetBitValue((byte)(DeviceNum), true); + // byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); + // int item = test1.ToInt(); + // string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 5); + // recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).UpLimtWeightFeedback = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).deviceStatus.NowWeightFeedback; + // MessageNotify.GetInstance.ShowRunLog($"{res}"); + // MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); + // MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); + // } + // } + // } + // } + // } + // } + //} + //508配料项目代码 if (GlobalDevice.PlcData.IsAllowIngredients[j]) { int barrel = j + 1;//桶号 - int cnt = GlobalDevice.PlcData.LocationFeedback[j];//允许配料的位置 0~6 - if (RTrig.GetInstance("a").Start(GlobalDevice.PlcData.IsAllowIngredients[j])) + int cnt = GlobalDevice.PlcData.LocationFeedback[j];//允许配料的位置 1~10 + if (RTrig.GetInstance("a").Start(GlobalDevice.PlcData.IsAllowIngredients[j])) { MessageNotify.GetInstance.ShowRunLog($"桶号:{barrel},位置:{cnt},允许配料"); } int Location1 = 0; - int Location2 = 0; if (cnt == -1) { - MessageNotify.GetInstance.ShowRunLog("错误"); + MessageNotify.GetInstance.ShowRunLog("没有读取到配料的位置"); return; } else { - switch (cnt) - { - case 1: - int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 1); - int b1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 2); - if (a1 >= 0) - { - Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); - } - if (b1 >= 0) - { - Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b1).DeviceName && p.Loc == barrel); - } - break; - case 2: - int a2 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 3); - int b2 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 4); - if (a2 >= 0) - { - Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a2).DeviceName && p.Loc == barrel); - } - if (b2 >= 0) - { - Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b2).DeviceName && p.Loc == barrel); - } - break; - case 3: - int a3 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 5); - int b3 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 6); - if (a3 >= 0) - { - Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a3).DeviceName && p.Loc == barrel); - } - if (b3 >= 0) - { - Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b3).DeviceName && p.Loc == barrel); - } - break; - case 4: - int a4 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 7); - int b4 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 8); - if (a4 >= 0) - { - Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a4).DeviceName && p.Loc == barrel); - } - if (b4 >= 0) - { - Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b4).DeviceName && p.Loc == barrel); - } - break; - case 5: - int a5 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 9); - int b5 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 10); - if (a5 >= 0) - { - Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a5).DeviceName && p.Loc == barrel); - } - if (b5 >= 0) - { - Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b5).DeviceName && p.Loc == barrel); - } - break; - case 6: - int a6 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 11); - int b6 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == 12); - if (a6 >= 0) - { - Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a6).DeviceName && p.Loc == barrel); - } - if (b6 >= 0) - { - Location2 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(b6).DeviceName && p.Loc == barrel); - } - break; - default: - break; - } + int a1 = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceNum == cnt); + Location1 = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == DeviceInquire.GetInstance.devices.ElementAt(a1).DeviceName && p.Loc == barrel); } if (Location1 >= 0) { @@ -438,118 +611,28 @@ namespace BPASmartClient.DosingSystem.ViewModel //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 StockStatus.ElementAt(St_index).IssueStatus = 2; DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); - int a = 0.SetBitValue((byte)(DeviceNum), true); + /*int a = 0.SetBitValue((byte)(DeviceNum), true); byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); - int item = test1.ToInt(); - string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item,2); - MessageNotify.GetInstance.ShowRunLog($"{res}"); - MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); - } - } - } - } - } - if (Location1 >= 0) - { - - string RawName111 = Recipes.ElementAt(i).RawMaterials.ElementAt(Location1).RawMaterialName; - int St_index111 = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName111); - if (Location2 >= 0 && ((Location1 >= 0 && StockStatus.ElementAt(St_index111).IssueStatus == 2))) - { - string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName; - int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName); - int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum; - if (DeviceNum > 0) - { - float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight; - int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName); - if (loc >= 0 && RawName != null && weight >= 0) - { - int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); - if (St_index < 0) - { - StockStatus.Add(new StockStatusModel() + int item = test1.ToInt();*/ + if (DeviceNum >= 1 && DeviceNum <= 8) { - MaterialName = RawName, - IssueWeight = weight, - IssueStatus = 0, - }); - } - St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); - if (St_index >= 0) - { - if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0) + SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX130." + (DeviceNum - 1), true); + }else if (DeviceNum >= 9 && DeviceNum <= 16) { - StockStatus.ElementAt(St_index).IssueStatus = 1; - DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); + SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX131." + (DeviceNum - 9), true); } - if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) + else if (DeviceNum >=17 && DeviceNum <= 24) { - //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 - StockStatus.ElementAt(St_index).IssueStatus = 2; - DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); - int a = 0.SetBitValue((byte)(DeviceNum), true); - byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); - int item = test1.ToInt(); - string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 5); - MessageNotify.GetInstance.ShowRunLog($"{res}"); - //MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); - MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item}"); - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); - } - } - } - } - } - } - else - { - if (Location2 >= 0) - { - string RawName = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialName; - int abc = Array.FindIndex(DeviceInquire.GetInstance.devices.ToArray(), p => p.DeviceName == RawName); - int DeviceNum = DeviceInquire.GetInstance.devices.ElementAt(abc).DeviceNum; - if (DeviceNum >= 0) - { - float weight = Recipes.ElementAt(i).RawMaterials.ElementAt(Location2).RawMaterialWeight; - int loc = Array.FindIndex(Recipes.ElementAt(i).RawMaterials.ToArray(), p => p.RawMaterialName == RawName); - if (cnt > 0 && loc >= 0 && RawName != null && weight >= 0) - { - int St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); - if (St_index < 0) - { - StockStatus.Add(new StockStatusModel() + SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX132." + (DeviceNum - 17), true); + }else if (DeviceNum >= 25 && DeviceNum <= 32) { - MaterialName = RawName, - IssueWeight = weight, - IssueStatus = 0, - }); - } - St_index = Array.FindIndex(StockStatus.ToArray(), p => p.MaterialName == RawName); - if (St_index >= 0) - { - if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 1 && StockStatus.ElementAt(St_index).IssueStatus == 0) - { - StockStatus.ElementAt(St_index).IssueStatus = 1; - DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).Start(weight); - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},开始出料"); - } - if (recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).RecipeStatus == 3 && StockStatus.ElementAt(St_index).IssueStatus == 1) - { - //GlobalDevice.PlcData.IsAllowIngredients[j] = false;//测试使用 - StockStatus.ElementAt(St_index).IssueStatus = 2; - DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).StatusReset(); - int a = 0.SetBitValue((byte)(DeviceNum), true); - byte[] test1 = a.ToBytes(BPA.Helper.DataFormat.ABCD); - int item = test1.ToInt(); - string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 5); - recipeProcesses.ElementAt(recIndex).RawMaterials.ElementAt(loc).UpLimtWeightFeedback = DeviceInquire.GetInstance.GetDevice(Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp).deviceStatus.NowWeightFeedback; - MessageNotify.GetInstance.ShowRunLog($"{res}"); - MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}"); - MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); + SiemensDevice.GetInstance.MySiemens.Write("DB4.DBX133." + (DeviceNum - 25), true); } + MessageNotify.GetInstance.ShowRunLog($"料仓:{DeviceNum},配料完成"); + /*string res = SiemensDevice.GetInstance.MySiemens.Write("DB4.DBD130", item, 2); + MessageNotify.GetInstance.ShowRunLog($"{res}"); + MessageNotify.GetInstance.ShowRunLog($"DB4.DBD130:{item.ToBinString()}");*/ + MessageNotify.GetInstance.ShowRunLog($"柔性味魔方{Recipes.ElementAt(i).RawMaterials.ElementAt(loc).DeviceIp},出料完成,状态复位"); } } } @@ -580,7 +663,7 @@ namespace BPASmartClient.DosingSystem.ViewModel } } Thread.Sleep(100); - }), "RecipeControlViewModelStatusInquire"); + }), "RecipeControlViewModelStatusInquire",true); } public BPARelayCommand StartCommand { get; set; }