72b4b0943c
Replace task/batch shorthand IDs and residual layer labels in human-facing docs with semantic phrases. Add the new cleanup policy to docs/编号规范.md and update the entry docs. Machine keys (TC/CODE-RULE/MENU-STATE/TRAP/FR), hardware designators/pins/MAC, protocol/version numbers and frozen historical evidence are intentionally kept. Docs only; no code behavior change. Verified with check_doc_links.py --all and git diff --check.
31 lines
1.9 KiB
Markdown
31 lines
1.9 KiB
Markdown
# App/cfg/ — 配置引擎
|
||
|
||
> **`/config.ini` 配置引擎**:分层解析、持久化(原子写)。
|
||
> 属主 = **defaultTask**(单任务收敛,静态态);其它任务不得直接触碰。
|
||
|
||
## 文件一览
|
||
|
||
| 文件 | 作用 |
|
||
|---|---|
|
||
| `cfg_file.c/h` | **配置引擎核心**:解析 / 查询 / 保存 / 2s 周期 `cfg_file_poll` |
|
||
| `cfg_file_store.h` | **存储后端抽象接口**(MCU=FreeRTOS 堆 / 模拟器=宿主堆,共享核心零分配符号) |
|
||
| `cfg_file_store_mcu.c` | **MCU 端后端实现**:`/config.ini`(临时名由目标路径同目录推导 + `f_rename` 原子写) |
|
||
| `prot_set_store.c/h` | **保护定值持久化胶水**:`/prot_set.bin` blob 读写(blob 格式/校验/原子装载在 `App/algo/prot_set.c` 纯逻辑层);装载 = storage bring-up(屏障前),落盘 = defaultTask 消费 `SYS_EVT_PROT_SET_SAVE` |
|
||
|
||
## 设计要点
|
||
|
||
- **单任务收敛**:`cfg_file` 为静态态,只有 defaultTask 操作;UI 保存请求经
|
||
`SYS_EVT_CFG_SAVE` 事件唤醒 defaultTask 执行(netTask/uiTask 不得直接调用);
|
||
定值落盘同构——iec104Task 只置事件位(`SYS_EVT_PROT_SET_SAVE`),不碰文件系统
|
||
- **零分配共享核心**:核心逻辑不含任何分配符号,动态内存收进平台后端
|
||
(`cfg_store_alloc/free`:MCU→`pvPortMalloc`,模拟器→宿主堆)
|
||
- **原子写**:写 `/config.TMP` 后 `f_rename` 替换,避免掉电损坏
|
||
- **旧档迁移已删除(2026-10-10)**:旧格式 `/cfg/netcfg.bin` 不再读取——存在则被忽略(不读、
|
||
不删、不迁移),配置回落工厂默认;`net_cfg_legacy.c/h` 与 `cfg_store_legacy_path()` 已移除
|
||
- **自研代码禁用 C 库堆分配**:MicroLIB 堆仅 512B(`malloc` 必返回 NULL)
|
||
|
||
## 相关文档
|
||
|
||
- `docs/子系统设计/配置文件设计说明.md` — 完整设计(分层/解析/持久化)
|
||
- `docs/子系统设计/网络配置说明.md` — 网络段
|