feat: 完成 issue #21 点位字典 CSV schema 增加协议(protocol)维度
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""点位字典 CSV schema —— 对齐 PRD 5.1「边缘采集网关」字段规范表。
|
||||
|
||||
字段表(PRD 5.1):
|
||||
字段表(PRD 5.1 + issue #21「协议」维度):
|
||||
device_id string 必填,唯一 设备编号,如 CLF-01
|
||||
point_id string 必填,唯一 测点编号,如 CLF-01.TEMP
|
||||
name string 必填 中文名,如 炉温
|
||||
@@ -10,6 +10,14 @@
|
||||
sampleRate int 必填, >0 采集周期(ms)
|
||||
qualityCode bool 默认 true 是否启用质量码
|
||||
opcNode string 选填 OPC UA 节点路径
|
||||
protocol enum 选填 采集协议(opcua/s7/modbus/weighing/energy/simulator)。
|
||||
空 = 由 gateway.yaml drivers 段按设备前缀路由(模板级默认)。
|
||||
|
||||
协议维度说明(issue #21):
|
||||
点位字典 CSV schema 覆盖「点位/设备/量纲/采样率/协议」五维。
|
||||
protocol 列提供**点位级协议覆盖**:同一模板内混接多种协议时,
|
||||
可在 CSV 中逐点位/逐设备显式指定协议;为空时保持模板级
|
||||
(gateway.yaml drivers 段 device_prefixes)路由,向后兼容。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -24,13 +32,16 @@ VALID_UNITS: List[str] = [
|
||||
# 合法数据类型集合
|
||||
VALID_DATA_TYPES: List[str] = ["float", "int", "bool"]
|
||||
|
||||
# 合法采集协议集合(与 drivers/__init__.py 注册表对齐)
|
||||
VALID_PROTOCOLS: List[str] = ["opcua", "s7", "modbus", "weighing", "energy", "simulator"]
|
||||
|
||||
# 必填字段
|
||||
REQUIRED_FIELDS: List[str] = ["device_id", "point_id", "name", "unit", "dataType", "sampleRate"]
|
||||
|
||||
# CSV 表头(列顺序固定,便于实施工程师对照 DCS 点表填写)
|
||||
CSV_HEADERS: List[str] = [
|
||||
"device_id", "point_id", "name", "unit", "dataType", "sampleRate",
|
||||
"qualityCode", "opcNode",
|
||||
"qualityCode", "opcNode", "protocol",
|
||||
]
|
||||
|
||||
|
||||
@@ -44,3 +55,8 @@ def is_valid_unit(unit: str) -> bool:
|
||||
def is_valid_data_type(dtype: str) -> bool:
|
||||
"""数据类型合法性校验。"""
|
||||
return dtype in VALID_DATA_TYPES
|
||||
|
||||
|
||||
def is_valid_protocol(protocol: str) -> bool:
|
||||
"""采集协议合法性校验(小写,须在驱动注册表内)。"""
|
||||
return protocol in VALID_PROTOCOLS
|
||||
|
||||
Reference in New Issue
Block a user