运行时间计算更改
This commit is contained in:
@@ -33,14 +33,14 @@ namespace CapMachine.Wpf.Models
|
|||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private void ProRunCycleAction(object? sender, ElapsedEventArgs e)
|
private void ProRunCycleAction(object? sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
|
CycleTimer.Stop();
|
||||||
|
|
||||||
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
CalcTime();
|
CalcTime();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//CycleTimer.Stop();
|
CycleTimer.Start();
|
||||||
|
|
||||||
//CycleTimer.Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -50,14 +50,14 @@ namespace CapMachine.Wpf.Models
|
|||||||
{
|
{
|
||||||
ProEndDt = DateTime.Now;
|
ProEndDt = DateTime.Now;
|
||||||
|
|
||||||
ProRunTimeStr = ConvertSecToDHMS((int)((ProEndDt - ProStartDt).TotalSeconds - PauseTotalSecTime));
|
ProRunTimeStr = ConvertSecToDHMS((int)Math.Round((ProEndDt - ProStartDt).TotalSeconds - PauseTotalSecTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
private string ConvertSecToDHMS(int totalSeconds)
|
private string ConvertSecToDHMS(int totalSeconds)
|
||||||
{
|
{
|
||||||
// 驗證非負(可根據需求調整)
|
// 驗證非負(可根據需求調整)
|
||||||
if (totalSeconds < 0)
|
if (totalSeconds < 0)
|
||||||
return "00:00:00:00";
|
return "00天:00时:00分:00秒";
|
||||||
|
|
||||||
int days = totalSeconds / 86400; // 1天 = 86400秒
|
int days = totalSeconds / 86400; // 1天 = 86400秒
|
||||||
int remainingSeconds = totalSeconds % 86400;
|
int remainingSeconds = totalSeconds % 86400;
|
||||||
@@ -79,6 +79,8 @@ namespace CapMachine.Wpf.Models
|
|||||||
{
|
{
|
||||||
ProStartDt = DateTime.Now;
|
ProStartDt = DateTime.Now;
|
||||||
CycleTimer.Start();
|
CycleTimer.Start();
|
||||||
|
//暂停时间清零,可能是多次开始执行程序,导致PauseTotalSecTime残留到下一个程序计时中
|
||||||
|
PauseTotalSecTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -104,6 +106,8 @@ namespace CapMachine.Wpf.Models
|
|||||||
{
|
{
|
||||||
CycleTimer.Stop();
|
CycleTimer.Stop();
|
||||||
CalcTime();
|
CalcTime();
|
||||||
|
//暂停时间清零,可能是多次开始执行程序,导致PauseTotalSecTime残留到下一个程序计时中
|
||||||
|
PauseTotalSecTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -3263,7 +3263,6 @@ namespace CapMachine.Wpf.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void StartProRun()
|
public void StartProRun()
|
||||||
{
|
{
|
||||||
|
|
||||||
//开始计时
|
//开始计时
|
||||||
ProRunTimeCalcModel.StartProRunTime();
|
ProRunTimeCalcModel.StartProRunTime();
|
||||||
|
|
||||||
@@ -3320,6 +3319,8 @@ namespace CapMachine.Wpf.Services
|
|||||||
ProRunTaskScanTimeEnable = false;
|
ProRunTaskScanTimeEnable = false;
|
||||||
ProRunTimeScanTokenSource.Cancel();
|
ProRunTimeScanTokenSource.Cancel();
|
||||||
|
|
||||||
|
LogService.Info($"【时间】: {DateTime.Now.ToString()} - 程序执行暂停");
|
||||||
|
|
||||||
//斜坡打点暂定
|
//斜坡打点暂定
|
||||||
foreach (var itemProExModel in ListProExModel)
|
foreach (var itemProExModel in ListProExModel)
|
||||||
{
|
{
|
||||||
@@ -3332,12 +3333,15 @@ namespace CapMachine.Wpf.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ContinueProRun()
|
public void ContinueProRun()
|
||||||
{
|
{
|
||||||
|
ProRunTimeCalcModel.ContinueProRunTime();
|
||||||
|
|
||||||
PauseEndDt = DateTime.Now;
|
PauseEndDt = DateTime.Now;
|
||||||
|
|
||||||
//统计的暂停的时间
|
//统计的暂停的时间
|
||||||
var PauseTime = (PauseEndDt - PauseStartDt).TotalSeconds;
|
var PauseTime = (PauseEndDt - PauseStartDt).TotalSeconds;
|
||||||
ProRunTimeCalcModel.PauseTotalSecTime = ProRunTimeCalcModel.PauseTotalSecTime + (int)PauseTime;
|
ProRunTimeCalcModel.PauseTotalSecTime = ProRunTimeCalcModel.PauseTotalSecTime + (int)Math.Round(PauseTime);
|
||||||
ProRunTimeCalcModel.ContinueProRunTime();
|
|
||||||
|
LogService.Info($"【时间】: {DateTime.Now.ToString()} - 程序执行继续");
|
||||||
|
|
||||||
//斜坡打点暂定
|
//斜坡打点暂定
|
||||||
foreach (var itemProExModel in ListProExModel)
|
foreach (var itemProExModel in ListProExModel)
|
||||||
|
|||||||
Reference in New Issue
Block a user