# -*- coding: utf-8 -*- """点位字典 CSV schema —— 对齐 PRD 5.1「边缘采集网关」字段规范表。 字段表(PRD 5.1): device_id string 必填,唯一 设备编号,如 CLF-01 point_id string 必填,唯一 测点编号,如 CLF-01.TEMP name string 必填 中文名,如 炉温 unit enum 必填 ℃ / kPa / m³/h / % / ... dataType enum 必填 float / int / bool sampleRate int 必填, >0 采集周期(ms) qualityCode bool 默认 true 是否启用质量码 opcNode string 选填 OPC UA 节点路径 """ from __future__ import annotations from typing import List # 合法量纲集合(可按行业模板扩展;此处覆盖化工/氯化车间常用量纲) VALID_UNITS: List[str] = [ "℃", "kPa", "MPa", "m³/h", "m3/h", "%", "kg", "t", "t/h", "m³", "m3", "A", "V", "Hz", "kW", "kWh", "Pa", "bar", "mm", "L", "L/min", "m/s", ] # 合法数据类型集合 VALID_DATA_TYPES: List[str] = ["float", "int", "bool"] # 必填字段 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", ] def is_valid_unit(unit: str) -> bool: """量纲合法性校验(大小写不敏感)。""" if not unit or unit != unit.strip(): return False return unit in VALID_UNITS def is_valid_data_type(dtype: str) -> bool: """数据类型合法性校验。""" return dtype in VALID_DATA_TYPES