RTU_ALL_AI/config/MODBUS/modbus_m.xml

113 lines
8.1 KiB
XML
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.

<?xml version="1.0" encoding="UTF-8"?>
<!--
Modbus 主站 (Master) 配置文件
支持多通道TCP/RTU、总线多设备、FC03/04 寄存器读线圈
-->
<Root>
<!-- ============================================================
通道定义 — 支持多个 TCP 或 RTU 通道
每个通道独立连接参数,通道之间互不影响
参数说明:
id — 通道唯一标识 (0~N)
mode — "tcp" 或 "rtu"
host — TCP 目标 IP
port — TCP 目标端口 (默认 502)
device — RTU 串口设备路径
baud — RTU 波特率
parity — RTU 校验位 (N/E/O)
data_bit — RTU 数据位
stop_bit — RTU 停止位
timeout_ms — 请求超时 (ms)
retry_cnt — 失败重试次数
============================================================ -->
<Channel id="0" desc="通道0-TCP设备1" mode="tcp" host="192.168.1.100" port="502" timeout_ms="1000" retry_cnt="3" />
<Channel id="1" desc="通道1-TCP设备2" mode="tcp" host="192.168.1.101" port="502" timeout_ms="1000" retry_cnt="3" />
<Channel id="2" desc="通道2-RTU总线1" mode="rtu" device="/dev/ttyUSB0" baud="115200" parity="N" data_bit="8" stop_bit="1" timeout_ms="1000" retry_cnt="3" />
<Channel id="3" desc="通道3-RTU总线2" mode="rtu" device="/dev/ttyUSB1" baud="115200" parity="N" data_bit="8" stop_bit="1" timeout_ms="1000" retry_cnt="3" />
<!-- ============================================================
点表定义
通用属性:
no — 信号序号 (全局唯一)
type — 数据类型: 2=bit(开关量), 4=uint16, 6=float32, 7=uint32, 13=string
channel — 归属通道 ID (对应上方 Channel id)
slave — 从站地址 (1~247)
fc — Modbus 功能码:
0x01=读线圈, 0x02=读离散输入,
0x03=读保持寄存器, 0x04=读输入寄存器,
0x05=写单线圈, 0x06=写单寄存器
0x0F=写多线圈, 0x10=写多寄存器
addr — 寄存器/线圈起始地址 (0-based)
count — 连续读取数量
bit — 位位置 (0~15), 仅当 type=2 且 fc=03/04 时有效
factor — 遥测系数
offset — 遥测偏移
saddr — 内部信号地址 (数据中心关联用)
desc — 中文描述
重要: FC03/04 + type=2 表示"从寄存器中提取线圈值"
即一个寄存器的 16 个 bit 对应 16 个线圈。
bit 属性指定提取哪个位 (0~15)。
============================================================ -->
<Point desc="点表">
<!-- ========== 遥信 (St) ========== -->
<St desc="遥信">
<!-- 通道0 - TCP设备1 - 读离散输入 (FC=0x02) -->
<Item no="0" type="2" channel="0" slave="1" fc="0x02" addr="0" count="1" saddr="modbus_m.ch0.slave1.st.0" desc="通道0-设备1-遥信01" />
<Item no="1" type="2" channel="0" slave="1" fc="0x02" addr="1" count="1" saddr="modbus_m.ch0.slave1.st.1" desc="通道0-设备1-遥信02" />
<!-- 通道1 - TCP设备2 - 读线圈 (FC=0x01) -->
<Item no="2" type="2" channel="1" slave="1" fc="0x01" addr="0" count="1" saddr="modbus_m.ch1.slave1.st.0" desc="通道1-设备1-遥信01" />
<Item no="3" type="2" channel="1" slave="1" fc="0x01" addr="1" count="1" saddr="modbus_m.ch1.slave1.st.1" desc="通道1-设备1-遥信02" />
<!-- 通道2 - RTU总线1 - 从站1/2 - 读离散输入 -->
<Item no="4" type="2" channel="2" slave="1" fc="0x02" addr="0" count="1" saddr="modbus_m.ch2.slave1.st.0" desc="通道2-从站1-遥信01" />
<Item no="5" type="2" channel="2" slave="1" fc="0x02" addr="1" count="1" saddr="modbus_m.ch2.slave1.st.1" desc="通道2-从站1-遥信02" />
<Item no="6" type="2" channel="2" slave="2" fc="0x02" addr="0" count="1" saddr="modbus_m.ch2.slave2.st.0" desc="通道2-从站2-遥信01" />
<!-- 通道3 - RTU总线2 - 从站1 - 从寄存器读线圈 (FC=0x03 + type=2 + bit) -->
<Item no="7" type="2" channel="3" slave="1" fc="0x03" addr="100" count="1" bit="0" saddr="modbus_m.ch3.slave1.st.bit0" desc="通道3-从站1-寄存器100-bit0线圈" />
<Item no="8" type="2" channel="3" slave="1" fc="0x03" addr="100" count="1" bit="1" saddr="modbus_m.ch3.slave1.st.bit1" desc="通道3-从站1-寄存器100-bit1线圈" />
<Item no="9" type="2" channel="3" slave="1" fc="0x03" addr="100" count="1" bit="2" saddr="modbus_m.ch3.slave1.st.bit2" desc="通道3-从站1-寄存器100-bit2线圈" />
<Item no="10" type="2" channel="3" slave="2" fc="0x04" addr="200" count="1" bit="0" saddr="modbus_m.ch3.slave2.st.bit0" desc="通道3-从站2-输入寄存器200-bit0" />
</St>
<!-- ========== 遥测 (Mx) — 输入寄存器/保持寄存器 ========== -->
<Mx desc="遥测">
<!-- 通道0 - TCP设备1 - 读输入寄存器 (FC=0x04) -->
<Item no="0" type="6" channel="0" slave="1" fc="0x04" addr="0" count="2" saddr="modbus_m.ch0.slave1.mx.0" desc="通道0-电压A相" factor="0.01" offset="0" />
<Item no="1" type="6" channel="0" slave="1" fc="0x04" addr="2" count="2" saddr="modbus_m.ch0.slave1.mx.1" desc="通道0-电压B相" factor="0.01" offset="0" />
<Item no="2" type="7" channel="0" slave="1" fc="0x04" addr="4" count="2" saddr="modbus_m.ch0.slave1.mx.2" desc="通道0-电能" factor="1" offset="0" />
<!-- 通道1 - TCP设备2 - 读保持寄存器 (FC=0x03) -->
<Item no="3" type="6" channel="1" slave="1" fc="0x03" addr="0" count="2" saddr="modbus_m.ch1.slave1.mx.0" desc="通道1-电流A相" factor="0.001" offset="0" />
<!-- 通道2 - RTU总线1 - 从站1/2 -->
<Item no="4" type="6" channel="2" slave="1" fc="0x04" addr="0" count="2" saddr="modbus_m.ch2.slave1.mx.0" desc="通道2-从站1-电压" factor="0.01" offset="0" />
<Item no="5" type="6" channel="2" slave="2" fc="0x04" addr="0" count="2" saddr="modbus_m.ch2.slave2.mx.0" desc="通道2-从站2-电压" factor="0.01" offset="0" />
<!-- 通道3 - RTU总线2 - 从站1 -->
<Item no="6" type="4" channel="3" slave="1" fc="0x03" addr="0" count="1" saddr="modbus_m.ch3.slave1.mx.0" desc="通道3-从站1-温度" />
</Mx>
<!-- ========== 遥控 (Co) — 写线圈 ========== -->
<Co desc="遥控">
<Item no="0" type="2" channel="0" slave="1" fc="0x05" addr="0" count="1" saddr="modbus_m.ch0.slave1.co.0" desc="通道0-设备1-分闸" />
<Item no="1" type="2" channel="0" slave="1" fc="0x05" addr="1" count="1" saddr="modbus_m.ch0.slave1.co.1" desc="通道0-设备1-合闸" />
<Item no="2" type="2" channel="2" slave="1" fc="0x05" addr="0" count="1" saddr="modbus_m.ch2.slave1.co.0" desc="通道2-从站1-分闸" />
<Item no="3" type="2" channel="2" slave="2" fc="0x05" addr="0" count="1" saddr="modbus_m.ch2.slave2.co.0" desc="通道2-从站2-分闸" />
<Item no="4" type="2" channel="3" slave="1" fc="0x05" addr="0" count="1" saddr="modbus_m.ch3.slave1.co.0" desc="通道3-从站1-分闸" />
</Co>
<!-- ========== 参数 (Ao) — 保持寄存器 读写 ========== -->
<Ao desc="参数">
<Item no="0" type="4" channel="0" slave="1" fc="0x06" addr="100" count="1" saddr="modbus_m.ch0.slave1.ao.0" desc="通道0-设备1-通讯地址" />
<Item no="1" type="4" channel="0" slave="1" fc="0x06" addr="101" count="1" saddr="modbus_m.ch0.slave1.ao.1" desc="通道0-设备1-波特率" />
<Item no="2" type="4" channel="2" slave="1" fc="0x06" addr="100" count="1" saddr="modbus_m.ch2.slave1.ao.0" desc="通道2-从站1-通讯地址" />
<Item no="3" type="4" channel="3" slave="1" fc="0x06" addr="100" count="1" saddr="modbus_m.ch3.slave1.ao.0" desc="通道3-从站1-通讯地址" />
</Ao>
</Point>
</Root>