using System; using System.Collections.Generic; using System.Linq; using System.Text; using Mesnac.Action.Base; namespace Mesnac.Action.Feeding.Sys { /// /// 定时器运行服务类 /// public class TimerRunService { #region 字段定义 private System.Timers.Timer _timer = null; #endregion #region 单例实现 private static TimerRunService _instance = null; private TimerRunService() { } public static TimerRunService Instance { get { if (_instance == null) { _instance = new TimerRunService(); } return _instance; } } #endregion #region 启动定时器运行服务 /// /// 启动定时器运行服务 /// public void Start() { if (this._timer == null) { this._timer = new System.Timers.Timer(); this._timer.Interval = 5000; this._timer.Elapsed += new System.Timers.ElapsedEventHandler(_timer_Elapsed); this._timer.Start(); } } #endregion #region 停止定时器运行服务 /// /// 停止定时器运行服务 /// public void Stop() { if (this._timer != null) { this._timer.Stop(); this._timer.Dispose(); this._timer = null; } } #endregion #region 定时器服务事件处理 /// /// 定时器服务事件处理 /// /// /// protected void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { lock (String.Empty) { SysVersionController.ProcessVersion(); //处理版本信息 #region 1、更新网络表中改设备的运行状态,移到计时器服务类中 FeedingPlc.UpdateEquipState updateEquipStateInstance = new FeedingPlc.UpdateEquipState(); if (updateEquipStateInstance.NetType == Mesnac.Action.Base.BaseAction.NetTypes.Net) { updateEquipStateInstance.Run(null); } #endregion } } #endregion } }