feat(iec104): 在模拟器跑通共享协议核心与标准DTU点表
引入成熟 IEC 60870-5-104 子站的只读子集(App/protocol/iec60870,28 个源文件 按原字节复制,UPSTREAM.sha256 记录来源,兼容补丁保留全部断言与容量),在其上 装配单属主共享核心(Start/Poll/Stop/Get_Status),并把标准 DTU 演示点表全量 接入为唯一真源。 - iec104_core:threadless 推进,poll 零等待,通知/交互/COV 扫描全部有界; 生命周期区分失败启动待重试、重复启动拒绝、断线保固化 RAM。 - iec104_dtu_table / iec104_source:标准 DTU 全点表注册,无数据源的点读 0, 遥控只做模拟状态可读回,不触碰实际出口。 - iec104_sim:仅窗口与独立服务模式起真实 TCP,无头黄金模式保持确定性假统计。 - test/host/iec104_dtu:独立真实 TCP 11 项、传输层 10 项、生命周期与借用负例。 验证:lvgl_sim 真实 TCP 11/11、传输 10/10,UI 像素回归未回退;AC5 单 TU 编译 0 错误 0 诊断。板端尚未切换:完整库闭包 RAM 超 92% 门禁净增预算 25730B, 结论为停止转实施,记录在 IEC104_MCU最小可行性验证.md。旧实现与 board 服务 保持原样,未提交 MDK 工程改动,未烧板。
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Independent reference extraction, never imports the production DTU model."""
|
||||
import hashlib
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[3]
|
||||
EXAMPLES = ROOT / "IEC60870-Slave" / "examples"
|
||||
|
||||
|
||||
def reference():
|
||||
text = (EXAMPLES / "iec104_dtu_profile.h").read_text(encoding="utf-8-sig")
|
||||
tables = {}
|
||||
for name in ("signals", "measurements", "energy", "commands", "parameters"):
|
||||
body = re.search(r"dtu_" + name + r"\[\]\s*=\s*\{(.*?)\n\};", text, re.S).group(1)
|
||||
tables[name] = [int(value, 16) for value in re.findall(r"\{0x([0-9A-Fa-f]+)U,", body)]
|
||||
parameters = {}
|
||||
for ioa, tag, value, configured in re.findall(
|
||||
r'\{0x([0-9A-Fa-f]+)U, (\d+)U, (NULL|"[^"]*"), (true|false),', text):
|
||||
if configured == "true":
|
||||
parameters[int(ioa, 16)] = (int(tag), value.strip('"'))
|
||||
assert [len(tables[x]) for x in tables] == [59, 30, 4, 19, 430]
|
||||
assert len(parameters) == 345
|
||||
assert set(tables["signals"]) == set(range(1, 0x42)) - set(range(0x2C, 0x32))
|
||||
assert set(tables["measurements"]) == set(range(0x4001, 0x401F))
|
||||
gi = {ioa: 1 for ioa in tables["signals"]}
|
||||
gi.update({ioa: 3 for ioa in range(0x1001, 0x1011)})
|
||||
gi.update({ioa: 13 for ioa in tables["measurements"]})
|
||||
for group in range(4):
|
||||
for index in range(30):
|
||||
gi[0x8601 + group * 0x20 + index] = 112 if group == 3 else (110 if group == 0 and index >= 4 else 111)
|
||||
read = {ioa: 30 if typ == 1 else 31 if typ == 3 else typ for ioa, typ in gi.items() if typ < 100}
|
||||
read.update({ioa: 5 for ioa in range(0x1201, 0x1209)})
|
||||
read.update({ioa: 7 for ioa in range(0x1301, 0x1309)})
|
||||
diagnostics = {ioa: 13 for ioa in range(0x9601, 0x962D) if ioa not in range(0x961C, 0x961F)}
|
||||
diagnostics.update({ioa: 30 for ioa in range(0x9141, 0x919E)})
|
||||
diagnostics.update({ioa: 30 for ioa in range(0xB100, 0xB110)})
|
||||
return {"profile": tables, "remote": parameters, "gi": gi, "read": read, "diagnostic_aliases_pending_scope": diagnostics,
|
||||
"counters": list(range(0x6401, 0x6409)),
|
||||
"hashes": {name: hashlib.sha256((EXAMPLES / name).read_bytes()).hexdigest()
|
||||
for name in ("iec104_dtu_profile.h", "iec104_example_points.h", "iec104_slave_example.c")}}
|
||||
Reference in New Issue
Block a user