From 8191df39341e4711e7aaa3b8e44511b2663ad673 Mon Sep 17 00:00:00 2001 From: ZhaoGang <15196688790@163.com> Date: Fri, 25 Aug 2023 07:42:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=8C=E6=88=90=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8F=90=E4=BA=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Model/ProcessControl.cs | 49 ++++++++++++++----- .../Model/Siemens/SiemensDeviceStatus.cs | 40 +++++++-------- .../Model/ProcessControl.cs | 30 ++++++++++-- .../Model/Siemens/SiemensDeviceStatus.cs | 40 +++++++-------- 4 files changed, 105 insertions(+), 54 deletions(-) diff --git a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs index 723edca9..d9ad7759 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/ProcessControl.cs @@ -1401,15 +1401,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (SiemensDevice.Siemens_PLC_S7.Read("DB2361.DBX0.0")) { - SiemensDevice.Siemens_PLC_S7.Write("DB2361.DBX330.0", false, 5); - + //SiemensDevice.Siemens_PLC_S7.Write("DB2361.DBX330.0", false, 5); + CleanFinishData(); + if (GVL_BigStation.Recipe1DosingFinish) + GVL_BigStation.Recipe1DosingFinish = false; MessageNotify.GetInstance.ShowRunLog($"配方队列【1】,配方编号:【{code}】,托盘编号:【{trayCode}】,配料完成,已将完成数据反馈至MES系统。"); GVL_BigStation.Recipe1DosingStatus = 40; } else { SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - Thread.Sleep(3000); + Thread.Sleep(1500); } } } @@ -1542,15 +1544,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (SiemensDevice.Siemens_PLC_S7.Read("DB2361.DBX0.0")) { - SiemensDevice.Siemens_PLC_S7.Write("DB2361.DBX330.0", false, 5); - + // SiemensDevice.Siemens_PLC_S7.Write("DB2361.DBX330.0", false, 5); + CleanFinishData(); + if (GVL_BigStation.Recipe2DosingFinish) + GVL_BigStation.Recipe2DosingFinish = false; MessageNotify.GetInstance.ShowRunLog($"配方队列【2】,配方编号:【{code}】,托盘编号:【{trayCode}】,配料完成,已将完成数据反馈至MES系统。"); GVL_BigStation.Recipe2DosingStatus = 40; } else { SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - Thread.Sleep(3000); + Thread.Sleep(1500); } } } @@ -1683,15 +1687,18 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (SiemensDevice.Siemens_PLC_S7.Read("DB2361.DBX0.0")) { - SiemensDevice.Siemens_PLC_S7.Write("DB2361.DBX330.0", false, 5); + //SiemensDevice.Siemens_PLC_S7.Write("DB2361.DBX330.0", false, 5); + CleanFinishData(); + if (GVL_BigStation.Recipe3DosingFinish) + GVL_BigStation.Recipe3DosingFinish = false; MessageNotify.GetInstance.ShowRunLog($"配方队列【3】,配方编号:【{code}】,托盘编号:【{trayCode}】,配料完成,已将完成数据反馈至MES系统。"); GVL_BigStation.Recipe3DosingStatus = 40; } else { SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - Thread.Sleep(3000); + Thread.Sleep(1500); } } } @@ -1824,15 +1831,17 @@ namespace BPASmartClient.JXJFoodBigStation.Model { if (SiemensDevice.Siemens_PLC_S7.Read("DB2361.DBX0.0")) { - SiemensDevice.Siemens_PLC_S7.Write("DB2361.DBX330.0", false, 5); - + // SiemensDevice.Siemens_PLC_S7.Write("DB2361.DBX330.0", false, 5); + CleanFinishData(); + if (GVL_BigStation.Recipe4DosingFinish) + GVL_BigStation.Recipe4DosingFinish = false; MessageNotify.GetInstance.ShowRunLog($"配方队列【4】,配方编号:【{code}】,托盘编号:【{trayCode}】,配料完成,已将完成数据反馈至MES系统。"); GVL_BigStation.Recipe4DosingStatus = 40; } else { SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); - Thread.Sleep(3000); + Thread.Sleep(1500); } } } @@ -2578,5 +2587,23 @@ namespace BPASmartClient.JXJFoodBigStation.Model return isSuccess; } + + private void CleanFinishData() + { + if ((GVL_BigStation.Recipe1DosingFinish || GVL_BigStation.Recipe2DosingFinish || GVL_BigStation.Recipe3DosingFinish || GVL_BigStation.Recipe4DosingFinish)) + { + FinishData.Order_No = ""; + FinishData.Product_Code = ""; + FinishData.job_No = 0; + for (int i = 0; i < 20; i++) + { + FinishData.Material[i] = new UDT1(); + } + FinishData.Ask_For_Finish = false; + FinishData.ProcessTime = 0; + SiemensDevice.Siemens_PLC_S7.WriteClass(FinishData, 2361); + + } + } } } diff --git a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs index 2bc9ba0b..d908f136 100644 --- a/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodBigStation/Model/Siemens/SiemensDeviceStatus.cs @@ -73,26 +73,26 @@ namespace BPASmartClient.JXJFoodBigStation.Model.Siemens { DL_Status = status; } - if (res2 != null && res2 is DL_Finish_DB finish) - { - if (finish.Ask_For_Finish_PLC &&(GVL_BigStation.Recipe1DosingFinish || GVL_BigStation.Recipe2DosingFinish || GVL_BigStation.Recipe3DosingFinish || GVL_BigStation.Recipe4DosingFinish)) - { - 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); - if (GVL_BigStation.Recipe1DosingFinish) GVL_BigStation.Recipe1DosingFinish = false; - if (GVL_BigStation.Recipe2DosingFinish) GVL_BigStation.Recipe2DosingFinish = false; - if (GVL_BigStation.Recipe3DosingFinish) GVL_BigStation.Recipe3DosingFinish = false; - if (GVL_BigStation.Recipe4DosingFinish) GVL_BigStation.Recipe4DosingFinish = false; - } - } + //if (res2 != null && res2 is DL_Finish_DB finish) + //{ + // if (finish.Ask_For_Finish_PLC &&(GVL_BigStation.Recipe1DosingFinish || GVL_BigStation.Recipe2DosingFinish || GVL_BigStation.Recipe3DosingFinish || GVL_BigStation.Recipe4DosingFinish)) + // { + // 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); + // if (GVL_BigStation.Recipe1DosingFinish) GVL_BigStation.Recipe1DosingFinish = false; + // if (GVL_BigStation.Recipe2DosingFinish) GVL_BigStation.Recipe2DosingFinish = false; + // if (GVL_BigStation.Recipe3DosingFinish) GVL_BigStation.Recipe3DosingFinish = false; + // if (GVL_BigStation.Recipe4DosingFinish) GVL_BigStation.Recipe4DosingFinish = false; + // } + //} Thread.Sleep(10); var dataColl = ProcessControl.GetInstance.HKDevice.DataColl; if (dataColl != null && dataColl is DL_DataColl_DB data) diff --git a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs index 6ad92c2a..75188ab2 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/ProcessControl.cs @@ -543,7 +543,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model { foreach (var data in RemoteRecipes) { - if (data.TrayCode == 1 && IsInQueue(data.RecipeCode)) + if (data.TrayCode == 1 &&!IsInQueue(data.RecipeCode)) { if (SiemensDevice.XL_Status is XL_Status_DB status) { @@ -888,6 +888,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (RemoteRecipes.ElementAt(index).WindSend.Count==0) { HKDevice.HK_PLC_S7.Write("DB4.DBX44."+recipeNum, true); + MessageNotify.GetInstance.ShowRunLog($"托盘1,配方编号【{code}】,配方号【{recipeNum + 1}】,该配方无风送料,已向配料PLC下发信号。"); } HKDevice.HK_PLC_S7.Write("DB4.DBX2." + recipeNum, true); #endregion @@ -1053,7 +1054,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model if (RemoteRecipes.ElementAt(index).RecipesSource == RecipeSource.远程 /*!GVL_SmallStation.GetInstance.IsUseLocalRecipe*/) { double totalMakeTime = DateTime.Now.Subtract(GVL_SmallStation.GetInstance.DosingTime[recipeNum]).TotalSeconds; - + RecipeFinishInfo[recipeNum] = new(); RecipeFinishInfo[recipeNum].Order_No = RemoteRecipes.ElementAt(index).RecipeCode; RecipeFinishInfo[recipeNum].Product_Code = RemoteRecipes.ElementAt(index).RecipeName; RecipeFinishInfo[recipeNum].Job_No = (short)trayCode; @@ -1108,14 +1109,17 @@ namespace BPASmartClient.JXJFoodSmallStation.Model //TODO:多配方队列单反馈变量,不知道到时候会不会有数据抢占的现象。 if (SiemensDevice.Siemens_PLC_S7.Read("DB2261.DBX0.0")) { + CleanFinishData(recipeNum); GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 40; - SiemensDevice.Siemens_PLC_S7.Write("DB2261.DBX450.0", false); + + //SiemensDevice.Siemens_PLC_S7.Write("DB2261.DBX450.0", false); MessageNotify.GetInstance.ShowRunLog($"托盘1,配方【{code}】,MES系统确认收到完成数据。"); } else { SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo[recipeNum], 2261); Thread.Sleep(3000); + } } } @@ -1140,6 +1144,7 @@ namespace BPASmartClient.JXJFoodSmallStation.Model RecipeQueueTray[recipeNum].TryDequeue(out code); GVL_SmallStation.GetInstance.RecipeStockBinDosing[recipeNum] = 0; GVL_SmallStation.GetInstance.RecipeProcessStatus[recipeNum] = 0; + MessageNotify.GetInstance.ShowRecipeLog($"配方名称:【{res.RecipeName}】\t 配方号:【{res.RecipeCode}】"); MessageNotify.GetInstance.ShowRunLog($"配方【{code}】,配料流程完成。"); } #endregion @@ -1927,5 +1932,24 @@ namespace BPASmartClient.JXJFoodSmallStation.Model return isSuccess; } + + + private void CleanFinishData(int recipeNum) + { + RecipeFinishInfo[recipeNum].Order_No = ""; + RecipeFinishInfo[recipeNum].Product_Code = ""; + RecipeFinishInfo[recipeNum].Job_No = 0; + for (int i = 0; i < 20; i++) + { + RecipeFinishInfo[recipeNum].Material[i] = new UDT1(); + } + for (int i = 0; i < 10; i++) + { + RecipeFinishInfo[recipeNum].Powder[i] = new UDT2(); + } + RecipeFinishInfo[recipeNum].Ask_For_Finish = false; + RecipeFinishInfo[recipeNum].DosingTime = 0; + SiemensDevice.Siemens_PLC_S7.WriteClass(RecipeFinishInfo[recipeNum], 2261); + } } } diff --git a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs index abd1a854..5801fbd4 100644 --- a/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs +++ b/BPASmartClient.JXJFoodSmallStation/Model/Siemens/SiemensDeviceStatus.cs @@ -76,26 +76,26 @@ namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens } } } - if (Finish != null && Finish is XL_Finish_DB FinishData) - { - if (FinishData.Ask_For_Finish_PLC) - { - FinishData.Order_No = ""; - FinishData.Product_Code = ""; - FinishData.Job_No = 0; - for (int i = 0; i < 20; i++) - { - FinishData.Material[i] = new UDT1(); - } - for (int i = 0; i < 10; i++) - { - FinishData.Powder[i] = new UDT2(); - } - FinishData.Ask_For_Finish = false; - FinishData.DosingTime = 0; - this.Siemens_PLC_S7.WriteClass(FinishData, 2261); - } - } + //if (Finish != null && Finish is XL_Finish_DB FinishData) + //{ + // if (FinishData.Ask_For_Finish_PLC) + // { + // FinishData.Order_No = ""; + // FinishData.Product_Code = ""; + // FinishData.Job_No = 0; + // for (int i = 0; i < 20; i++) + // { + // FinishData.Material[i] = new UDT1(); + // } + // for (int i = 0; i < 10; i++) + // { + // FinishData.Powder[i] = new UDT2(); + // } + // FinishData.Ask_For_Finish = false; + // FinishData.DosingTime = 0; + // this.Siemens_PLC_S7.WriteClass(FinishData, 2261); + // } + //} if (Status != null && Status is XL_Status_DB state) { for (int i = 0; i < XL_Status.Powder.Length; i++)