189 lines
4.8 KiB
Markdown
189 lines
4.8 KiB
Markdown
|
|
# ploss_record 实体
|
|||
|
|
|
|||
|
|
> 所属模块:[数据模型概览](../概览.md)
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 1. 表定义
|
|||
|
|
|
|||
|
|
**表名**:`ploss_record`
|
|||
|
|
|
|||
|
|
**描述**:存储 Ploss FOD 格式解析数据,对应日志格式 `FOD-> (1)...(13)`
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 2. 字段定义
|
|||
|
|
|
|||
|
|
| 列名 | 类型 | 约束 | 说明 |
|
|||
|
|
|------|------|------|------|
|
|||
|
|
| id | UUID | PK, NOT NULL | 主键 |
|
|||
|
|
| scenario_id | UUID | FK, NOT NULL | 关联测试场景 |
|
|||
|
|
| rx_type | TINYINT | NOT NULL | 接收端类型标识 |
|
|||
|
|
| rx_power | SMALLINT | NOT NULL | 接收端功率(mW) |
|
|||
|
|
| tx_power | SMALLINT | NOT NULL | 发射端功率(mW) |
|
|||
|
|
| vcoil | SMALLINT | NOT NULL | 发射线圈电压 |
|
|||
|
|
| vin | SMALLINT | NOT NULL | 输入电压 |
|
|||
|
|
| isns | SMALLINT | NOT NULL | 输入电流采样值 |
|
|||
|
|
| ploss | INT | NOT NULL | **核心值**:计算损耗(负数=安全) |
|
|||
|
|
| threshold | INT | NOT NULL | **安全红线**:当前功率段阈值 |
|
|||
|
|
| trigger_count | SMALLINT | NOT NULL, DEFAULT 0 | 触发计数器 |
|
|||
|
|
| fod_result | SMALLINT | NOT NULL, DEFAULT 0 | FOD判定结果 |
|
|||
|
|
| protocol_type | TINYINT | NOT NULL | 充电协议类型 |
|
|||
|
|
| pwm_duty | SMALLINT | NOT NULL | PWM占空比 |
|
|||
|
|
| coil_index | TINYINT | NOT NULL | 充电线圈索引 |
|
|||
|
|
| is_deleted | BOOLEAN | NOT NULL, DEFAULT FALSE | 软删除标记 |
|
|||
|
|
| created_at | TIMESTAMP | NOT NULL, DEFAULT NOW() | 创建时间 |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 3. 外键
|
|||
|
|
|
|||
|
|
| 外键 | 引用表 | 说明 |
|
|||
|
|
|------|--------|------|
|
|||
|
|
| scenario_id | test_scenario.id | 关联测试场景(必需) |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 4. 派生字段
|
|||
|
|
|
|||
|
|
> **注意**:以下字段不落库,查询时动态计算
|
|||
|
|
|
|||
|
|
| 字段 | 计算公式 | 说明 |
|
|||
|
|
|------|----------|------|
|
|||
|
|
| margin | threshold - ploss | 安全余量(>0 安全,<0 危险) |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 5. 索引
|
|||
|
|
|
|||
|
|
| 索引名 | 字段 | 用途 |
|
|||
|
|
|--------|------|------|
|
|||
|
|
| idx_ploss_scenario | scenario_id | 按测试场景查询 |
|
|||
|
|
| idx_ploss_rx_power | rx_power | 阈值表匹配 |
|
|||
|
|
| idx_ploss_ploss | ploss | 损耗值查询 |
|
|||
|
|
| idx_ploss_threshold | threshold | 阈值查询 |
|
|||
|
|
| idx_ploss_fod_result | fod_result | FOD结果筛选 |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 6. EF Core 模型
|
|||
|
|
|
|||
|
|
```csharp
|
|||
|
|
// Models/PlossRecord.cs
|
|||
|
|
using System.ComponentModel.DataAnnotations;
|
|||
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|||
|
|
|
|||
|
|
namespace WCTDataMiner.Models;
|
|||
|
|
|
|||
|
|
[Table("ploss_record")]
|
|||
|
|
[Index(nameof(ScenarioId), Name = "idx_ploss_scenario")]
|
|||
|
|
[Index(nameof(RxPower), Name = "idx_ploss_rx_power")]
|
|||
|
|
[Index(nameof(Ploss), Name = "idx_ploss_ploss")]
|
|||
|
|
[Index(nameof(Threshold), Name = "idx_ploss_threshold")]
|
|||
|
|
[Index(nameof(FodResult), Name = "idx_ploss_fod_result")]
|
|||
|
|
public class PlossRecord
|
|||
|
|
{
|
|||
|
|
[Key]
|
|||
|
|
[Column("id")]
|
|||
|
|
public Guid Id { get; set; } = Guid.NewGuid();
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("scenario_id")]
|
|||
|
|
public Guid ScenarioId { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("rx_type")]
|
|||
|
|
public byte RxType { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("rx_power")]
|
|||
|
|
public short RxPower { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("tx_power")]
|
|||
|
|
public short TxPower { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("vcoil")]
|
|||
|
|
public short Vcoil { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("vin")]
|
|||
|
|
public short Vin { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("isns")]
|
|||
|
|
public short Isns { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>核心判定值:负数表示安全</summary>
|
|||
|
|
[Required]
|
|||
|
|
[Column("ploss")]
|
|||
|
|
public int Ploss { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>安全红线:当前功率段阈值</summary>
|
|||
|
|
[Required]
|
|||
|
|
[Column("threshold")]
|
|||
|
|
public int Threshold { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("trigger_count")]
|
|||
|
|
public short TriggerCount { get; set; } = 0;
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("fod_result")]
|
|||
|
|
public short FodResult { get; set; } = 0;
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("protocol_type")]
|
|||
|
|
public byte ProtocolType { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("pwm_duty")]
|
|||
|
|
public short PwmDuty { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("coil_index")]
|
|||
|
|
public byte CoilIndex { get; set; }
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("is_deleted")]
|
|||
|
|
public bool IsDeleted { get; set; } = false;
|
|||
|
|
|
|||
|
|
[Required]
|
|||
|
|
[Column("created_at")]
|
|||
|
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|||
|
|
|
|||
|
|
[ForeignKey(nameof(ScenarioId))]
|
|||
|
|
public TestScenario Scenario { get; set; } = null!;
|
|||
|
|
|
|||
|
|
/// <summary>派生属性:安全余量</summary>
|
|||
|
|
[NotMapped]
|
|||
|
|
public int Margin => Threshold - Ploss;
|
|||
|
|
}
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 7. 动态阈值表
|
|||
|
|
|
|||
|
|
> 阈值根据 RxPower 动态查表(不落库)
|
|||
|
|
|
|||
|
|
| Rx Power 区间 | Threshold | 备注 |
|
|||
|
|
|---------------|-----------|------|
|
|||
|
|
| 0-5000 mW | 350 mW | 低功率最敏感 |
|
|||
|
|
| 5000-10000 mW | 500 mW | |
|
|||
|
|
| 10000-15000 mW | 750 mW | |
|
|||
|
|
| 15000-30000 mW | 1000 mW | |
|
|||
|
|
| 30000-50000 mW | 1250 mW | 高功率 |
|
|||
|
|
|
|||
|
|
```csharp
|
|||
|
|
// Services/ThresholdCalculator.cs
|
|||
|
|
public static int GetThresholdByPower(int rxPower)
|
|||
|
|
{
|
|||
|
|
if (rxPower <= 5000) return 350;
|
|||
|
|
if (rxPower <= 10000) return 500;
|
|||
|
|
if (rxPower <= 15000) return 750;
|
|||
|
|
if (rxPower <= 30000) return 1000;
|
|||
|
|
return 1250;
|
|||
|
|
}
|
|||
|
|
```
|