下载耗时太久,异步操作

This commit is contained in:
2025-05-29 16:39:05 +08:00
parent a5f6a79a34
commit 4cbb3955a4
3 changed files with 2982 additions and 2940 deletions

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>

File diff suppressed because it is too large Load Diff

View File

@@ -16,6 +16,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace CapMachine.Wpf.ViewModels
@@ -2324,7 +2325,7 @@ namespace CapMachine.Wpf.ViewModels
{
if (_GenProPlcCmd == null)
{
_GenProPlcCmd = new DelegateCommand(() => GenProPlcCmdMethod());
_GenProPlcCmd = new DelegateCommand(async () => await GenProPlcCmdMethod());
}
return _GenProPlcCmd;
}
@@ -2332,17 +2333,23 @@ namespace CapMachine.Wpf.ViewModels
/// <summary>
/// 生产下载执行方法
/// </summary>
private void GenProPlcCmdMethod()
private async Task GenProPlcCmdMethod()
{
if (ProSegRunListViewItems != null && ProSegRunListViewItems.Count() > 0)
{
//当前的程序开始标记
//ProParsSongZhiHelper.Start();
if (ProRuntimeService.IsLoadProSeging)
{
MessageBox.Show("下载过程中无法操作,请下载完毕后再操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
return;
}
//返回的数据
List<PlcParsData> ReturnPlcParsData = new List<PlcParsData>();
ProRuntimeService.LoadProSegRun(ProSegRunListViewItems.ToList());
await ProRuntimeService.LoadProSegRun(ProSegRunListViewItems.ToList(), new CancellationToken());
////防止上一次下载的程序多余当前的步骤,为了清空多余的步骤数据,增加一行的数据
//ReturnPlcParsData = ProParsSongZhiHelper.AddNullData(ReturnPlcParsData);
@@ -3198,6 +3205,7 @@ namespace CapMachine.Wpf.ViewModels
SelectedProStepDto.SpeedCycle!.IsSlop = true;
SelectedProStepDto.SpeedCycle!.Cycle = SelectedProStepDto.SpeedCycle.Cycle;
//计算程序段的总时间
SumProSegTime();
//if (MeterSpeedExDto.TotalSlopTime != GetKeepTimeBySpeed())
//{
@@ -3222,7 +3230,7 @@ namespace CapMachine.Wpf.ViewModels
var SegStepTime = 0;
foreach (var itemProStep in SelectedProgramSeg.ProSteps)
{
if (itemProStep.MeterSpeeds != null && itemProStep.MeterSpeeds.Count()>0)
if (itemProStep.MeterSpeeds != null && itemProStep.MeterSpeeds.Count() > 0)
{
if (itemProStep.MeterSpeeds.FirstOrDefault()!.ValueType == ConfigValueType.Slope)
{
@@ -3259,6 +3267,7 @@ namespace CapMachine.Wpf.ViewModels
if (time.Hours > 0)
{
parts.Add($"{time.Days}天");
parts.Add($"{time.Hours}小时");
parts.Add($"{time.Minutes}分");
parts.Add($"{time.Seconds}秒");