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.
90 lines
2.2 KiB
C#
90 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace Mesnac.Action.Feeding.Qingquan.LockScales
|
|
{
|
|
/// <summary>
|
|
/// 锁秤业务服务
|
|
/// </summary>
|
|
public class LockScaleService
|
|
{
|
|
#region 字段定义
|
|
|
|
private System.Timers.Timer _timer = null;
|
|
|
|
#endregion
|
|
|
|
#region 单例实现
|
|
|
|
private static LockScaleService _instance = null;
|
|
|
|
private LockScaleService() { }
|
|
|
|
public static LockScaleService Instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance == null)
|
|
{
|
|
_instance = new LockScaleService();
|
|
}
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 启动定时器运行服务
|
|
/// <summary>
|
|
/// 启动定时器运行服务
|
|
/// </summary>
|
|
public void Start()
|
|
{
|
|
if (this._timer == null)
|
|
{
|
|
Global.PublicVar.Instance.G_DownloadSL = 1; //下传送胶信号标志
|
|
this._timer = new System.Timers.Timer();
|
|
this._timer.Interval = 2000;
|
|
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)
|
|
{
|
|
CheckBarcodeHelper.CheckBarcode(); //检查条码
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|