Skip to content

设备接入(Modbus Client) ​

这篇解决什么 ​

网关当客户端去轮询从站。读完能对上 protocol: modbus_tcp_client、iot_device_modbus_config / iot_device_modbus_point,不要让设备来连 502。

产品 protocolType 填 modbus_tcp_client。从站反过来连网关见 设备接入(Modbus Server)。

示意图:管理端配 IP 和点位。网关主动连、按功能码读,再写成属性。

从哪改 ​

名称说明仓库路径
协议主动轮询ruoyi-office/yudao-module-iot/yudao-module-iot-gateway/.../modbus/tcpclient/IotModbusTcpClientProtocol.java
连接配置/iot/device-modbus-configIotDeviceModbusConfigController
点位/iot/device-modbus-pointIotDeviceModbusPointController
详情页Modbus Tabruoyi-office-vben/.../device/detail/modules/modbus-config.vue
样例id: modbus-tcp-client-1,默认关application.yaml

yaml 里 port: 502 只给实例 serverId,不是网关监听口。真正连的是配置表 ip + port + slaveId。config-refresh-interval 默认 30 秒拉一次配置。

IotModbusModeEnum:1 云端轮询,2 边缘采集。IotModbusFrameFormatEnum:1 Modbus TCP,2 Modbus RTU。还有 timeout / retryInterval / status。

点位:functionCode 为 FC01–04(线圈、离散输入、保持寄存器、输入寄存器),加起始地址、类型、字节序,并挂 thingModelId / identifier。读上来的值按标识写属性。

轮询:IotModbusTcpClientPollScheduler。配置缓存:IotModbusTcpClientConfigCacheService。下行写寄存器走 Downstream。

字段 ​

名称说明仓库路径
ip / port / slaveId从站地址IotDeviceModbusConfigDO
mode / frameFormat轮询或边缘、TCP 或 RTU同上
functionCode / 起始地址点位IotDeviceModbusPointDO
identifier对物模型属性同上

yaml 的 502 不是听设备

Client 模式网关去连现场。现场 PLC 才听 502。把设备对准网关 502,连不上是对的。

先产品协议再配点位

产品不是 modbus_tcp_client,轮询调度不会认这台设备。点位 identifier 必须已在物模型里。

按本仓库 DO 生成的 ER。

配置与操作 ​

yaml 开 id: modbus-tcp-client-1,protocol: modbus_tcp_client。yaml 里 port: 502 不是网关监听口。真正连的是设备详情 Modbus Tab:iot_device_modbus_config 的 ip / port / slaveId,点位挂 identifier。网关主动轮询,设备不要来连 502。

产品 protocolType 填 modbus_tcp_client。配置刷新间隔默认 30 秒。开启见 IoT 功能设计。

IoT 首页

本系统截图:IoT 首页。协议实例在网关 yaml,没有「MQTT / HTTP」独立菜单。

相关篇 ​

联系我们

获取报价、演示和二开方案

微信咨询二维码

微信咨询

17156169080

添加时备注「RuoYi Office」

在线体验商业版