Files
ems-simulator/README.md
2026-04-03 13:26:45 +08:00

102 lines
1.8 KiB
Markdown
Raw Permalink 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.

# EMS Modbus 模拟器
一个基于 JavaFX 的 Modbus TCP 从站模拟器,监听端口固定为 `4567`
## 功能
- 图形界面查看四类数据区:
- `Holding Register`
- `Input Register`
- `Coil`
- `Discrete Input`
- 手动写入四类数据区(支持地址和值边界限制)
- 设备场景模拟(可启停):
- 温度波动
- 压力变化
- 告警联动
- 泵状态联动
- 场景脚本编辑器(界面内可配置波形、阈值、联动输出地址)
- 故障注入:
- 响应延迟
- 强制异常码(按功能码或全部功能码)
- 收到请求后断开连接
- 点位配置导入:支持 `CSV/XLSX`
- 通信日志 + 报文 HEX 明细(`RX/TX`
- 支持标准 Modbus TCP 功能码:
- `0x01` 读 Coil
- `0x02` 读离散输入
- `0x03` 读保持寄存器
- `0x04` 读输入寄存器
- `0x05` 写单个 Coil
- `0x06` 写单个保持寄存器
- `0x0F` 写多个 Coil
- `0x10` 写多个保持寄存器
## 运行
要求:
- JDK 17+
- Maven 3.9+
在项目目录执行:
```bash
mvn javafx:run
```
## 测试连接参数
- Host: `127.0.0.1`
- Port: `4567`
- Unit ID: `1`(可自定义)
## 点位导入格式
### CSV/XLSX 列
- `area`
- `address`
- `value`
### area 可用值
- `holding` / `holding_register` / `hr`
- `input` / `input_register` / `ir`
- `coil`
- `discrete` / `discrete_input` / `di`
### 示例CSV
```csv
area,address,value
holding,10,350
input,1,1015
coil,0,1
discrete,0,0
```
## 场景脚本示例
```ini
temp.base=25
temp.amplitude=12
temp.step=0.22
pressure.base=1000
pressure.amplitude=20
pressure.factor=0.8
threshold.mode=holding
threshold.holding.addr=10
# threshold.fixed.value=320
pump.margin=20
output.temp.input=0
output.temp.holding=0
output.pressure.input=1
output.pump.coil=0
output.alarm.discrete=0
```