Files
WCTDataMiner/tests/Gpulse.WCT.DataAnalyzer.Tests/TestFixtures.cs
Scottxjw 7a8a1e9a87 test: 更新分析功能和迁移测试用例
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-25 11:30:16 +08:00

81 lines
3.2 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 Gpulse.WCT.DataAnalyzer.Tests;
/// <summary>
/// 构造 CLI 测试用的日志 fixture 文件。文件名符合 FileNameParser 约定的
/// `车厂-车型-TX面板类型-TX硬件-TX软件-RX类型-异物类型-测试目的-年月日测试次数` 格式。
/// </summary>
public static class TestFixtures
{
/// <summary>
/// 新格式文件名示例:
/// 车厂-车型-TX面板类型-TX硬件-TX软件-RX类型-异物类型-测试目的-年月日测试次数
/// </summary>
public const string PlossFileName = "奇瑞-E5-singleMold-A00-V001-iPhone15-无-ploss_test-2026071001.dat";
public const string QfodFileName = "奇瑞-E5-singleMold-A00-V001-iPhone15-无-qfod_test-2026071001.dat";
/// <summary>
/// 两行 Ploss 记录header + FOD 16 字段)。
/// 默认值让恒等式成立Field5 - Field4 - PowLoss - ploss == DeltaP且余量 > 2000。
/// Field10 为功率段,默认 350。
/// </summary>
/// <param name="Field1AsHex">
/// 当不为 null 时,覆写 Field1按十六进制字面量写入日志如 "0C" = 十进制 12
/// 用于验证解析器对 Field1 十六进制格式的支持。
/// </param>
public sealed record PlossTwoLineRow(
int PowLoss = 2200,
int DeltaP = 2500,
int Field1 = 1,
string? Field1AsHex = null,
int Field2 = 0,
int Field3 = 0,
int Field4 = 800, // RX power
int Field5 = 6000, // TX power
int Field6 = 0,
int Field7 = 0,
int Field8 = 0,
int Field9 = 500, // ploss
int Field10 = 350, // threshold/power segment (350/500/750/1000/1250/1500/1750/2000/2250)
int Field11 = 0,
int Field12 = 0, // FOD 标志
int Field13 = 0,
int Field14 = 0,
int Field15 = 0,
int Field16 = 0);
/// <summary>写两行格式 Ploss 日志文件。</summary>
public static string WritePlossLog(string dir, string fileName, params PlossTwoLineRow[] rows)
{
var path = Path.Combine(dir, fileName);
var lines = new List<string>(rows.Length * 2);
foreach (var r in rows)
{
lines.Add($"pow_loss = {r.PowLoss}, delta_p = {r.DeltaP}");
var field1 = r.Field1AsHex ?? r.Field1.ToString();
lines.Add(
$"FOD-> {field1} {r.Field2} {r.Field3} {r.Field4} {r.Field5} {r.Field6} " +
$"{r.Field7} {r.Field8} {r.Field9} {r.Field10} {r.Field11} {r.Field12} " +
$"{r.Field13} {r.Field14} {r.Field15} {r.Field16}");
}
File.WriteAllLines(path, lines);
return path;
}
/// <summary>写 Qfod 日志文件,每行 DeltaQ 一个。</summary>
public static string WriteQfodLog(string dir, string fileName, params int[] deltaQs)
{
var path = Path.Combine(dir, fileName);
var lines = deltaQs
.Select((d, i) =>
{
var charger = i % 2;
var coil = i % 3;
var currentQ = 40 + d;
return $"{charger}#:Q {coil}->{d} {currentQ}.0 20.0 0 0";
})
.ToArray();
File.WriteAllLines(path, lines);
return path;
}
}