feat(parser): 支持 Ploss Field1 十六进制解析
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,10 +13,15 @@ public static class TestFixtures
|
||||
/// 两行 Ploss 记录(header + FOD 16 字段)。
|
||||
/// 默认值让恒等式成立(Field5 - Field4 - PowLoss - ploss == DeltaP)且余量 > 2000。
|
||||
/// </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
|
||||
@@ -41,8 +46,9 @@ public static class TestFixtures
|
||||
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-> {r.Field1} {r.Field2} {r.Field3} {r.Field4} {r.Field5} {r.Field6} " +
|
||||
$"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}");
|
||||
}
|
||||
@@ -51,11 +57,18 @@ public static class TestFixtures
|
||||
}
|
||||
|
||||
/// <summary>写旧单行格式 Ploss 日志(14 字段),仅指定 ploss/threshold/FOD 三个关键字段。</summary>
|
||||
public static string WriteLegacyPlossLog(string dir, string fileName, params (int Ploss, int Threshold, int Fod)[] rows)
|
||||
/// <param name="rows">每行 FOD 记录关键字段(ploss/threshold/FOD)</param>
|
||||
/// <param name="field1Hex">若非 null 则覆盖首字段为十六进制字面量(否则固定为 "1")。</param>
|
||||
public static string WriteLegacyPlossLog(
|
||||
string dir,
|
||||
string fileName,
|
||||
(int Ploss, int Threshold, int Fod)[] rows,
|
||||
string? field1Hex = null)
|
||||
{
|
||||
var path = Path.Combine(dir, fileName);
|
||||
var head = field1Hex ?? "1";
|
||||
var lines = rows
|
||||
.Select(r => $"FOD-> 1 0 0 0 0 0 0 0 {r.Ploss} {r.Threshold} 0 {r.Fod} 0 0")
|
||||
.Select(r => $"FOD-> {head} 0 0 0 0 0 0 0 {r.Ploss} {r.Threshold} 0 {r.Fod} 0 0")
|
||||
.ToArray();
|
||||
File.WriteAllLines(path, lines);
|
||||
return path;
|
||||
|
||||
Reference in New Issue
Block a user