49 lines
1.8 KiB
C#
49 lines
1.8 KiB
C#
using SSPCTester.Logic.Models;
|
|
|
|
namespace SSPCTester.Logic.Testing;
|
|
|
|
/// <summary>
|
|
/// 保护功能测试:当前阶段仅生成框架占位结果,不真正触发故障。
|
|
/// </summary>
|
|
public sealed class ProtectTest : ITestModule
|
|
{
|
|
public string Name => "保护功能";
|
|
|
|
private static readonly (string Type, string Trigger)[] _items = new[]
|
|
{
|
|
("跳闸", "1.5×额定电流"),
|
|
("短路", "输出短路"),
|
|
("过温", "≥85℃"),
|
|
("过压", "≥32V"),
|
|
("欠压", "≤22V"),
|
|
("限流", "≥1.2A"),
|
|
};
|
|
|
|
public async Task RunAsync(TestContext ctx, IProgress<TestProgress> progress, CancellationToken ct)
|
|
{
|
|
ctx.Project.ProtectResults.Clear();
|
|
var latestPower = ctx.Project.PowerResults.LastOrDefault();
|
|
for (int i = 0; i < _items.Length; i++)
|
|
{
|
|
ct.ThrowIfCancellationRequested();
|
|
var row = new ProtectRow
|
|
{
|
|
Index = i + 1,
|
|
ProtectType = _items[i].Type,
|
|
Trigger = _items[i].Trigger,
|
|
MeasuredValue = ProtectRow.BuildMeasuredValue(_items[i].Type, latestPower?.Vin, latestPower?.Iin),
|
|
JudgeMode = "人工判别",
|
|
Status = TestStatus.Running
|
|
};
|
|
ctx.Project.ProtectResults.Add(row);
|
|
progress.Report(new TestProgress { ModuleName = Name, Step = i, TotalSteps = _items.Length, Message = $"框架占位:{row.ProtectType}" });
|
|
|
|
await Task.Delay(150, ct).ConfigureAwait(false);
|
|
// 框架占位:固定演示数据
|
|
row.TripTimeMs = 2.0 + i * 0.3;
|
|
row.Status = TestStatus.Pass;
|
|
progress.Report(new TestProgress { ModuleName = Name, Step = i + 1, TotalSteps = _items.Length, StepStatus = row.Status });
|
|
}
|
|
}
|
|
}
|