2026-06-30 12:10:29 +08:00
|
|
|
using SSPCTester.Logic.Models;
|
|
|
|
|
|
|
|
|
|
namespace SSPCTester.Logic.Testing;
|
|
|
|
|
|
2026-07-02 21:38:25 +08:00
|
|
|
/// <summary>保护功能测试:刷新固定保护测试项的实测值与测量状态。</summary>
|
2026-06-30 12:10:29 +08:00
|
|
|
public sealed class ProtectTest : ITestModule
|
|
|
|
|
{
|
2026-07-02 21:38:25 +08:00
|
|
|
public const string ModuleName = "保护功能";
|
|
|
|
|
public string Name => ModuleName;
|
2026-06-30 12:10:29 +08:00
|
|
|
|
|
|
|
|
public async Task RunAsync(TestContext ctx, IProgress<TestProgress> progress, CancellationToken ct)
|
|
|
|
|
{
|
2026-07-02 21:38:25 +08:00
|
|
|
ProtectTestPlan.EnsureRows(ctx.Project);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ctx.Project.ProtectResults.Count; i++)
|
2026-06-30 12:10:29 +08:00
|
|
|
{
|
|
|
|
|
ct.ThrowIfCancellationRequested();
|
2026-07-02 21:38:25 +08:00
|
|
|
var row = ctx.Project.ProtectResults[i];
|
|
|
|
|
bool preserveManualJudgement = row.Status is TestStatus.Pass or TestStatus.Fail;
|
|
|
|
|
if (!preserveManualJudgement)
|
|
|
|
|
row.Status = TestStatus.Running;
|
|
|
|
|
ProtectTestPlan.RefreshMeasuredValues(ctx.Project, overwriteExisting: false);
|
|
|
|
|
progress.Report(new TestProgress { ModuleName = Name, Step = i, TotalSteps = ctx.Project.ProtectResults.Count, Message = $"保护项测量:{row.ProtectType}" });
|
2026-06-30 12:10:29 +08:00
|
|
|
|
|
|
|
|
await Task.Delay(150, ct).ConfigureAwait(false);
|
2026-07-02 21:38:25 +08:00
|
|
|
if (!preserveManualJudgement && row.Status == TestStatus.Running)
|
2026-07-03 14:16:15 +08:00
|
|
|
row.Status = TestStatus.Untested;
|
2026-07-02 21:38:25 +08:00
|
|
|
progress.Report(new TestProgress { ModuleName = Name, Step = i + 1, TotalSteps = ctx.Project.ProtectResults.Count, StepStatus = row.Status });
|
2026-06-30 12:10:29 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|