feat(qfod): 添加FieldF字段支持第6个数字解析

This commit is contained in:
ssss
2026-07-06 13:36:52 +08:00
parent 52435ab8cd
commit eaac759a3f
4 changed files with 20 additions and 5 deletions

View File

@@ -8,7 +8,7 @@
**表名**`qfod_record`
**描述**:存储 Qfod 格式解析数据,对应日志格式 `X#:Q A->B C D E`
**描述**:存储 Qfod 格式解析数据,对应日志格式 `X#:Q A->B C D E F`
---
@@ -24,6 +24,7 @@
| current_q | FLOAT | NOT NULL | 当前实时 Q值 |
| raw_q | FLOAT | NOT NULL | 原始 Q值 |
| fod_type | TINYINT | NOT NULL | 异物类型编码 |
| field_f | TINYINT | NOT NULL, DEFAULT 0 | 第6个数字预留字段当前取值0业务含义待确认 |
| is_deleted | BOOLEAN | NOT NULL, DEFAULT FALSE | 软删除标记 |
| created_at | TIMESTAMP | NOT NULL, DEFAULT NOW() | 创建时间 |
@@ -77,6 +78,7 @@ public class QfodRecord
public float CurrentQ { get; set; }
public float RawQ { get; set; }
public byte FodType { get; set; }
public byte FieldF { get; set; }
public bool IsDeleted { get; set; } = false;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
@@ -132,6 +134,11 @@ public class QfodRecordConfiguration : IEntityTypeConfiguration<QfodRecord>
.IsRequired()
.HasColumnName("fod_type");
builder.Property(e => e.FieldF)
.IsRequired()
.HasDefaultValue((byte)0)
.HasColumnName("field_f");
builder.Property(e => e.IsDeleted)
.IsRequired()
.HasDefaultValue(false)

View File

@@ -45,6 +45,11 @@ public class QfodRecordConfiguration : IEntityTypeConfiguration<QfodRecord>
.IsRequired()
.HasColumnName("fod_type");
builder.Property(e => e.FieldF)
.IsRequired()
.HasDefaultValue((byte)0)
.HasColumnName("field_f");
builder.Property(e => e.IsDeleted)
.IsRequired()
.HasDefaultValue(false)

View File

@@ -13,6 +13,7 @@ public class QfodRecord
public float CurrentQ { get; set; }
public float RawQ { get; set; }
public byte FodType { get; set; }
public byte FieldF { get; set; }
public bool IsDeleted { get; set; } = false;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

View File

@@ -5,13 +5,14 @@ namespace WCTDataMiner.Core.Parsers;
/// <summary>
/// Qfod日志解析器
/// 格式: X#:Q A->B C D E
/// 示例: 0#:Q 1->25 45.5 20.5 2
/// 格式: X#:Q A->B C D E F
/// 字段映射: X=ChargerIndex, A=CoilIndex, B=DeltaQ, C=CurrentQ, D=RawQ, E=FodType, F=FieldF
/// 示例: 0#:Q 1->25 45.5 20.5 2 0
/// </summary>
public class QfodParser : IParser<QfodRecord>
{
private static readonly Regex QfodPattern = new(
@"^(\d)#:Q\s+(\d+)->(-?\d+)\s+([-\d.]+)\s+([-\d.]+)\s+(\d+)$",
@"^(\d)#:Q\s+(\d+)->(-?\d+)\s+([-\d.]+)\s+([-\d.]+)\s+(\d+)\s+(\d+)$",
RegexOptions.Compiled
);
@@ -38,7 +39,8 @@ public class QfodParser : IParser<QfodRecord>
DeltaQ = int.Parse(match.Groups[3].Value),
CurrentQ = float.Parse(match.Groups[4].Value),
RawQ = float.Parse(match.Groups[5].Value),
FodType = byte.Parse(match.Groups[6].Value)
FodType = byte.Parse(match.Groups[6].Value),
FieldF = byte.Parse(match.Groups[7].Value)
};
return ParseResult<QfodRecord>.Success(record);