From 465c348df0e933f05dbf315419b4c7f21b8f2c74 Mon Sep 17 00:00:00 2001 From: nodyang Date: Thu, 17 Aug 2023 16:02:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E7=B1=BB=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FinishBatch/FinishBatchHelper.cs | 21 ++- .../FinishBatch/FinishBatchService.cs | 156 +++++++++++++++++- .../FinishBatch/GHFinshBatchHelper.cs | 19 ++- Main/MCRun/MCRun.csproj | 4 + Main/MCRun/Program.cs | 24 +++ 5 files changed, 219 insertions(+), 5 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs index fc0a40a..688930f 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchHelper.cs @@ -29,7 +29,7 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch #region 0 存盘信号读取 //if (BasePlcHelper.Instance.ChemicalWeighing_PLC_Request_Save_ShakeHand.NowValue.ToInt() == 1 && (BasePlcHelper.Instance.ChemicalWeighing_PC_Request_Save_FeedBack.NowValue.ToInt() <= 0 || BasePlcHelper.Instance.ChemicalWeighing_PC_Request_Save_FeedBack.NowValue.ToInt() == 65535 || BasePlcHelper.Instance.ChemicalWeighing_PC_Request_Save_FeedBack.NowValue.ToInt() == -1)) - if (true) + if (false) { #region 1 变量定义 @@ -359,7 +359,24 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch } #endregion - + #region 冠合存盘数据保存 + /// + /// 冠合存盘数据保存 + /// + public static void SaveGHData() + { + try + { + #region 存盘信号读取 + + #endregion + } + catch (Exception ex) + { + ICSharpCode.Core.LoggingService.Error(String.Format("生产数据存盘异常:{1}", ex.Message), ex); + } + } + #endregion } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs index d2a9449..a375f58 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/FinishBatchService.cs @@ -52,8 +52,160 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch #endregion - + #region 启动服务 - + public void Start() + { + try + { + if (this.runState) + { + return; + } + lock (String.Empty) + { + Mesnac.Equips.Factory.Instance.SetMinHZReadDataEvent(ReadData); + this.runState = true; + } + } + catch(Exception ex) + { + ICSharpCode.Core.LoggingService.Error("自动更新计划状态服务异常:" + ex.Message, ex); + } + } + + #endregion + + #region 停止服务 + + public void Stop() + { + try + { + if (!this.runState) + { + return; + } + lock (String.Empty) + { + ICSharpCode.Core.LoggingService.Debug("开始停止生产数据存盘服务..."); + Mesnac.Equips.Factory.Instance.ClearMinHZReadDataEvent(ReadData); + ICSharpCode.Core.LoggingService.Debug("停止生产数据存盘服务完毕!"); + this.runState = false; + } + + } + catch (Exception ex) + { + ICSharpCode.Core.LoggingService.Error("停止生产数据存盘业务服务异常:" + ex.Message, ex); + } + } + + #endregion + + #region 事件处理 + + private void ReadData(object sender, Mesnac.Equips.ReadEventArgs e) + { + try + { + lock(String.Empty) + { + + #region 0、实时刷新自动保存报警 + + SaveHelper.AlarmSaveHelper.Instance.Save(); + + #endregion + + + + #region 2、将等待计划数写入PLC + + //ChemicalWeighingPlc.PlcPlanHelper.WaitPlanNumToPLC(); + + #endregion + + #region 3、更新计划状态 + + //ChemicalWeighingPlc.PlcPlanHelper.UpdatePlanStateFromPlc(); + + #endregion + + #region 4、HMI配方列表请求处理 + + //ChemicalWeighingPlc.PlcRecipeHelper.DownloadRecipeNameListToPLC(); + + #endregion + + #region 5、HMI计划添加请求处理 + + //ChemicalWeighingPlc.PlcPlanHelper.AutoAddPlan(); + + #endregion + + #region 6、HMI计划修改请求处理 + + //ChemicalWeighingPlc.PlcPlanHelper.ChangePlan(); + + #endregion + + #region 7、自动存盘处理 + + //FinishBatchHelper.SaveGHData(); + + //ReportDryMixerSaveHelper.Instance.Save(); + ReportWetMixerSaveHelper.Instance.SaveWetMixerReport(); + //ReportGelDoserSaveHelper.Instance.SaveGelDoserReport(); + #endregion + + #region 8、更新物料名称 + + //ChemicalWeighingPlc.PlcPlanHelper.UpdateMaterialNameToPlc(); + + #endregion + + #region 9、修改PC心跳信号 + + //ChemicalWeighingPlc.PlcPlanHelper.HeartBeatChange(); + + #endregion + + #region 10、自动换班 + + ChemicalWeighingPlc.PlcPlanHelper.shiftIDAutoChange(); + + #endregion + } + + } + catch(Exception ex) + { + ICSharpCode.Core.LoggingService.Error(ex.Message, ex); + } + finally + { + #region 6、设置PCok信号为空闲 + + //#region 保存存盘 + + //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_MixWeight_PC_PCok, new object[] { 1 }, false); + //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_Mix_PC_PCok, new object[] { 1 }, false); + //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_MillWeight_PC_PCok, new object[] { 1 }, false); + //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.ReportSave_Mill_PC_PCok, new object[] { 1 }, false); + + //#endregion + + //#region 配方交互 + + //BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.Mix_RecipeDL_PC_PCok, new object[] { 1 }, false); + + //#endregion + + #endregion + } + } + + #endregion } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/GHFinshBatchHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/GHFinshBatchHelper.cs index 8f8e78a..63e16dd 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/GHFinshBatchHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/FinishBatch/GHFinshBatchHelper.cs @@ -8,6 +8,23 @@ namespace Mesnac.Action.ChemicalWeighing.FinishBatch { public class GHFinshBatchHelper { - + #region 冠合项目存盘数据 + /// + /// 冠合项目数据存盘 + /// + public static void SaveData() + { + try + { + + + } + catch (Exception ex) + { + ICSharpCode.Core.LoggingService.Error(String.Format("数据存盘异常:{1}", ex.Message), ex); + } + } + + #endregion } } diff --git a/Main/MCRun/MCRun.csproj b/Main/MCRun/MCRun.csproj index 302d96d..6a6ddad 100644 --- a/Main/MCRun/MCRun.csproj +++ b/Main/MCRun/MCRun.csproj @@ -236,6 +236,10 @@ + + {90cc2d8a-dec5-4d2a-82c9-f7a033060dc1} + Mesnac.Action.ChemicalWeighing + {18bcaa9f-d601-43b6-b443-e6b126adf540} Mesnac.Controls.Base diff --git a/Main/MCRun/Program.cs b/Main/MCRun/Program.cs index 67eb000..2c9b327 100644 --- a/Main/MCRun/Program.cs +++ b/Main/MCRun/Program.cs @@ -8,6 +8,7 @@ using System.Windows.Forms; using System.Xml; using ICSharpCode.Core; using ICSharpCode.Core.Services; +using Mesnac.Action.ChemicalWeighing.FinishBatch; using Mesnac.Gui.Run.Global; namespace MCRun { @@ -25,6 +26,9 @@ namespace MCRun [STAThread] static void Main(string[] args) { + + Timer timer = new Timer(); + if (Mesnac.Basic.ProcessHelper.HaveRunningInstance()) { Mesnac.Basic.MessageBoxTimeOut.Show("The application is running, Please be patient...", "Caption", 2000); @@ -121,6 +125,16 @@ namespace MCRun } //初始化连接报警器 DoControl.Instance.ComOn(); + + + // 设置触发间隔时间(以毫秒为单位) + timer.Interval = 1500; // 1000 毫秒 = 1 秒 +// 绑定 Tick 事件处理程序 + timer.Tick += new EventHandler(new Program().Timer_Tick); +// 启动 Timer + timer.Start(); + + } //if (!Mesnac.Basic.InfluxDbHelper.Instance.IsStartDbServer) @@ -137,6 +151,11 @@ namespace MCRun //Mesnac.Communication.TcpService.StartService(); //启动通信服务器 //Mesnac.Basic.SocketClient.Instance.Connect(); }; + + + + + WorkbenchSingleton.InitializeWorkbench(); ICSharpCode.Core.LoggingService.Debug("starting workbench..."); @@ -174,5 +193,10 @@ namespace MCRun } + private void Timer_Tick(object sender, EventArgs e) + { +// 定时触发的操作 + FinishBatchService.Instance.Start(); + } } }