Files
STM32F4-Base/IEC60870-Slave/README.md
T
STF 7596f3371a
CI / L0 静态门禁 (pre-commit) (push) Failing after 44s
CI / L0.5 主机侧单测 (MSVC) (push) Failing after 42s
补充总召唤的广播地址,电度召唤+时钟同步业务的实现
2026-10-29 03:20:19 -07:00

71 lines
4.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# IEC60870-Slave
IEC 60870 子站协议库,当前提供 IEC104 子站、Windows TCP 后端、总召、计数量召唤和Type 103时钟同步。101/104 可复用的 ASDU、信息对象、时间工具及子站应答接口集中在公共目录。
## 目录结构
按职责归档,同一模块的 `.c` 和 `.h` 放在一起:
```text
IEC60870-Slave/
├── 104/ # IEC104 专用协议代码
│ ├── IEC104_Slave.c/h # 子站统一入口
│ ├── business/ # 104业务模块
│ │ ├── IEC104_Interrogation.c/h # 共用召唤引擎
│ │ ├── IEC104_Interrogation_Internal.h # 引擎与种类规则的私有接口
│ │ ├── IEC104_GeneralInterrogation.c/h # 站总召、分组总召规则
│ │ ├── IEC104_CounterInterrogation.c/h # 计数量读取、冻结与复位
│ │ └── IEC104_ClockSynchronization.c/h # 校时校验、显式动作与确认
│ ├── IEC104_TcpServer.c/h # TCP 服务与事件调度
│ ├── IEC104_Connection.c/h # 连接协调
│ ├── IEC104_Link*.c/h # 链路、主站/子站启停
│ ├── IEC104_Send*.c/h # 发送管理与缓冲
│ ├── IEC104_AsduQueue.c/h # ASDU 队列
│ ├── IEC104_Receiver.c/h # 流式接收
│ ├── IEC104_Codec.c/h # APCI 编解码
│ ├── IEC104_Net.h / IEC104_Net_Windows.c # 网络接口与 Windows 后端
│ └── IEC104*.c/h # 类型、容量配置、日志及旧接收入口
├── common/ # 101/104 公共代码
│ ├── IEC60870_Types.h # 公共类型及应用层参数
│ ├── IEC60870_Codec.c/h # ASDU 公共头编解码
│ ├── IEC60870_Asdu.c/h # ASDU 容器
│ ├── IEC60870_InformationObjects*.c/h # 信息对象
│ ├── IEC60870_Slave.c/h # 公共子站应答接口
│ └── IEC60870_Time.c/h / IEC60870_Clock.c/h # 时间工具与时钟接口
├── examples/ # 应用示例
│ └── iec104_slave_example.c # 模拟点表、业务分派与程序入口
├── test/ # 测试源码与主机脚本
│ ├── iec104_*_test.c # 104 传输、调度、子站与总召测试
│ ├── iec60870_*_test.c # 公共 ASDU 与信息对象测试
│ └── slave_example_loopback_test.cjs # 真实 TCP 回环测试
├── docs/ # 设计、接口、示例及测试说明
│ ├── README.md # 文档索引与推荐阅读顺序
│ ├── 104/ # 104 设计及接口说明
│ ├── common/ # 公共模块说明
│ ├── examples/ # 示例使用说明
│ └── test/ # 测试说明与验证记录
├── scripts/ # 构建脚本
│ └── build.ps1 # 构建示例,-Test 同时运行示例回归
├── .build/ # 本地构建及验证产物(运行脚本后生成)
└── README.md # 项目总览
```
## 构建与测试
在项目根目录的 PowerShell 中执行,需要 MinGW GCC;`-Test` 还需要 Node.js:
```powershell
./scripts/build.ps1
./.build/slave-example/iec104_slave_example.exe
# 运行示例业务回归和真实 TCP 回环测试
./scripts/build.ps1 -Test
```
脚本按自身位置定位项目,可从其他工作目录调用。构建产物统一写入项目根目录的 `.build/`。
接入自己的工程时,将 `104/` 和 `common/` 加入头文件搜索路径,使用总召、计数量或校时业务时再加入 `104/business/`;按所用模块选择源文件,仅使用公共模块时只需 `common/`。Windows 网络后端需链接 `Ws2_32`。统一入口为 `IEC104_Slave.h`,总召使用 `IEC104_Interrogation.h`(编译 `104/business/` 下的引擎和GeneralInterrogation.c),计数量使用 `IEC104_CounterInterrogation.h`,校时使用独立的 `IEC104_ClockSynchronization.c/h`。接入约定见[计数量设计](docs/104/IEC104_CounterInterrogation_设计架构.md)和[时钟同步设计](docs/104/IEC104_ClockSynchronization_设计架构.md)。
子站示例默认使用模拟时钟;收到校时命令只更新模拟值。需要修改Windows系统时钟时显式选择`--clock system`,默认模式及自动测试均不修改系统时间。
详细资料见[文档索引](docs/README.md)、[模块说明与接入示例](docs/104/README.md)、[子站示例说明](docs/examples/IEC104子站示例.md)和[完整测试命令](docs/test/IEC104测试文档.md#2-编译与运行)。