You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.Feeding.Sys
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 定时器运行服务类
|
|
|
|
|
/// </summary>
|
|
|
|
|
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 启动定时器运行服务
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 启动定时器运行服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
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 停止定时器运行服务
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 停止定时器运行服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Stop()
|
|
|
|
|
{
|
|
|
|
|
if (this._timer != null)
|
|
|
|
|
{
|
|
|
|
|
this._timer.Stop();
|
|
|
|
|
this._timer.Dispose();
|
|
|
|
|
this._timer = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 定时器服务事件处理
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 定时器服务事件处理
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|