From 8eef58973585492ba315d22a0b03eb6e84ccd578 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq,com> Date: 星期六, 29 八月 2020 09:41:44 +0800 Subject: [PATCH] 水冷修改 --- WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_rt.java | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 47 insertions(+), 1 deletions(-) diff --git a/WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_rt.java b/WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_rt.java index ce07ea0..d65717a 100644 --- a/WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_rt.java +++ b/WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_rt.java @@ -2,6 +2,11 @@ import java.io.Serializable; +import com.modbus.data.MyModbusMaster; +import com.modbus.data.MyModbusUtils; +import com.serotonin.modbus4j.BatchRead; +import com.serotonin.modbus4j.BatchResults; + public class Water_rt implements Serializable{ public int num;//'主键', public int water_id ;//'水冷系统id', @@ -122,5 +127,46 @@ + ", External_tmp=" + External_tmp + ", External_pre=" + External_pre + ", note=" + note + "]"; } - + /** + * 创建读取数据集合 + * @param master + * @return + */ + public BatchRead<Integer> createBatchRead(MyModbusMaster master){ + BatchRead<Integer> batch = new BatchRead<Integer>(); + batch.addLocator(0,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Cooling_flow ,master));//'冷却水流量', + batch.addLocator(1,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Supply_tmp ,master));//'供水温度', + batch.addLocator(2,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Supply_pre , master));//'供水压力', + batch.addLocator(3,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.back_tem, master));//'回水温度', + batch.addLocator(4,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.back_pre, master));//'回水压力', + batch.addLocator(5,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Cooling_ser, master));//'冷却水电导率', + batch.addLocator(6,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Buffer_tank_level, master));//'缓冲罐液位' + batch.addLocator(7,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Buffer_tank_pre, master)); //'缓冲罐压力', + batch.addLocator(8,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Humidity_chamber, master));//'阀厅湿度', + batch.addLocator(9,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Tem_chamber, master)); //'阀厅温度', + batch.addLocator(10,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.External_tmp, master));//'外水温度', + batch.addLocator(11,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.External_pre,master));//'外水压力', + return batch; + } + /** + * 解析返回请求 + * @param res + */ + public void putBatchResult(BatchResults<Integer> res) { + if(res != null) { + this.cooling_flow = MyModbusUtils.readShortToFloat(res.getValue(0)); + this.supply_tmp = MyModbusUtils.readShortToFloat(res.getValue(1)); + this.Supply_pre = MyModbusUtils.readShortToFloat(res.getValue(2)); + this.back_tem = MyModbusUtils.readShortToFloat(res.getValue(3)); + this.back_pre = MyModbusUtils.readShortToFloat(res.getValue(4)); + this.Cooling_ser = MyModbusUtils.readShortToFloat(res.getValue(5)); + this.Buffer_tank_level = MyModbusUtils.readShortToFloat(res.getValue(6)); + this.Buffer_tank_pre = MyModbusUtils.readShortToFloat(res.getValue(7)); + this.Humidity_chamber = MyModbusUtils.readShortToFloat(res.getValue(8)); + this.Tem_chamber= MyModbusUtils.readShortToFloat(res.getValue(9)); + this.External_tmp= MyModbusUtils.readShortToFloat(res.getValue(10)); + this.External_pre = MyModbusUtils.readShortToFloat(res.getValue(11)); + + } + } } -- Gitblit v1.9.1