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

67 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace SSPCTester.Logic.Models;
using System.Collections.ObjectModel;
/// <summary>被测件 / 测试信息。</summary>
public sealed class DutInfo
{
public string ProductName { get; set; } = "";
public string Model { get; set; } = "";
public string SerialNumber { get; set; } = "";
public string Manufacturer { get; set; } = "";
}
public sealed class TestSiteInfo
{
public string Tester { get; set; } = "";
public DateTime TestDate { get; set; } = DateTime.Today;
public double TemperatureC { get; set; } = 25.0;
public double HumidityPct { get; set; } = 60.0;
public double PressureKpa { get; set; } = 101.3;
public string Remark { get; set; } = "";
}
/// <summary>一个测试项目:信息 + 选择 + 各模块结果。</summary>
public sealed class Project
{
public string Name { get; set; } = "新项目";
public DateTime CreatedAt { get; set; } = DateTime.Now;
public DateTime LastTestedAt { get; set; }
public DutInfo Dut { get; set; } = new();
public TestSiteInfo Site { get; set; } = new();
public TestSelection Selection { get; set; } = new();
public ReportSelection Report { get; set; } = new();
public TestFunctionNotes TestFunction { get; set; } = new();
public CurveThresholds CurveThresholds { get; set; } = new();
public ObservableCollection<ChannelResult> BasicResults { get; set; } = new();
public ObservableCollection<CurveResultRow> CurveResults { get; set; } = new();
public ObservableCollection<PowerLossRow> PowerResults { get; set; } = new();
public ObservableCollection<ProtectRow> ProtectResults { get; set; } = new();
/// <summary>项目根目录(含 project.json、curves/、report.pdf。运行时填充不持久化。</summary>
[System.Text.Json.Serialization.JsonIgnore]
public string FolderPath { get; set; } = "";
/// <summary>综合判定(取所有结果中最差状态)。</summary>
public TestStatus OverallStatus
{
get
{
var all = BasicResults.Select(r => r.Status)
.Concat(CurveResults.Select(r => r.Status))
.Concat(PowerResults.Select(r => r.Status))
.Concat(ProtectResults.Select(r => r.Status))
.ToList();
if (all.Count == 0) return TestStatus.Untested;
if (all.Any(s => s == TestStatus.Fail)) return TestStatus.Fail;
if (all.Any(s => s == TestStatus.Running)) return TestStatus.Running;
if (all.All(s => s == TestStatus.Pass)) return TestStatus.Pass;
if (all.All(s => s is TestStatus.Pass or TestStatus.Measured) &&
all.Any(s => s == TestStatus.Measured)) return TestStatus.Measured;
return TestStatus.Untested;
}
}
}