using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CapMachine.Wpf.Models { public class QuickRunTime { public delegate void RunTimeCallSglDelegate(string ProName, string MeterName, int MeterStep); public event RunTimeCallSglDelegate RunTimeCallSglEvent; /// /// 是否启用 /// public bool RunEnable { get; set; } = false; /// /// RunTimeCallSglEvent 是否注册关联方法 /// public bool EventRegister { get; set; } = false; /// /// 当前仪表名称 /// public string MeterName { get; set; } /// /// 当前程序段名称 /// public string ProName { get; set; } /// /// 当前仪表程序步骤 /// public int MeterStep { get; set; } /// /// 当前步骤开始运行时间 /// public DateTime StartDateTime { get; set; } /// /// 当前步骤结束运行时间 /// public DateTime EndDateTime { get; set; } private DateTime currentDateTime; /// /// 当前时间 /// public DateTime CurrentDateTime { get { return currentDateTime; } set { //value.ToString("yyyy-MM-dd HH:mm:ss") == EndDateTime.ToString("yyyy-MM-dd HH:mm:ss") if (RunEnable == true && value >= EndDateTime) { currentDateTime = value; RunEnable = false; //时间到了触发下载新的步骤 //RunTimeCallSglEvent(ProName, MeterName, MeterStep); RunTimeCallSglEvent.BeginInvoke(ProName, MeterName, MeterStep, null, null); //RunEnable = false; } else { currentDateTime = value; RunTime = (int)(currentDateTime - StartDateTime).TotalSeconds; } } } /// /// 当前步骤已经运行时长-秒 /// public int RunTime { get; set; } } }