Files
CapMachine/CapMachine.Wpf/Models/Meter/MeterRunTime.cs
2024-07-04 17:42:03 +08:00

81 lines
2.2 KiB
C#

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