SSPC-Tester/SSPCTester.Logic/Testing/ITestModule.cs
2026-06-30 12:10:29 +08:00

43 lines
1.2 KiB
C#

using SSPCTester.Devices.Interfaces;
using SSPCTester.Logic.Models;
namespace SSPCTester.Logic.Testing;
/// <summary>测试模块执行上下文。</summary>
public sealed class TestContext
{
public TestContext(Project project, ISspc sspc, IPowerSupply power, ILoad load, IDaq daq)
{
Project = project;
Sspc = sspc;
Power = power;
Load = load;
Daq = daq;
}
public Project Project { get; }
public ISspc Sspc { get; }
public IPowerSupply Power { get; }
public ILoad Load { get; }
public IDaq Daq { get; }
}
/// <summary>测试进度报告。</summary>
public sealed class TestProgress
{
public string ModuleName { get; init; } = "";
public int Step { get; init; }
public int TotalSteps { get; init; }
public string Message { get; init; } = "";
public TestStatus? StepStatus { get; init; }
public double PercentComplete => TotalSteps > 0 ? Step * 100.0 / TotalSteps : 0;
}
/// <summary>所有测试模块的统一接口。</summary>
public interface ITestModule
{
string Name { get; }
Task RunAsync(TestContext ctx, IProgress<TestProgress> progress, CancellationToken ct);
}