| | |
| | | import com.modbus.data.MyModbusUtils; |
| | | import com.serotonin.modbus4j.BatchRead; |
| | | import com.serotonin.modbus4j.BatchResults; |
| | | import com.serotonin.modbus4j.code.DataType; |
| | | |
| | | public class Water_brach implements Serializable{ |
| | | public int num;//'主键', |
| | |
| | | */ |
| | | public BatchRead<Integer> createBatchRead(MyModbusMaster master){ |
| | | BatchRead<Integer> batch = new BatchRead<Integer>(); |
| | | batch.addLocator(0,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_1 ,master));//'1#支路流量', |
| | | batch.addLocator(1,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_2,master)); |
| | | batch.addLocator(2,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_3, master)); |
| | | batch.addLocator(3,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_4, master)); |
| | | batch.addLocator(4,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_5, master)); |
| | | batch.addLocator(5,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_6, master)); |
| | | batch.addLocator(6,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_7, master)); |
| | | batch.addLocator(7,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_8, master)); |
| | | batch.addLocator(8,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_9, master));//'9#支路流量', |
| | | batch.addLocator(0,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_1 ,DataType.TWO_BYTE_INT_SIGNED,master));//'1#支路流量', |
| | | batch.addLocator(1,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_2,DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(2,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_3, DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(3,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_4,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(4,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_5, DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(5,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_6,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(6,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_7, DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(7,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_8,DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(8,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_flow_9,DataType.TWO_BYTE_INT_SIGNED, master));//'9#支路流量', |
| | | |
| | | batch.addLocator(9,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_1, master));//'1#支路温度', |
| | | batch.addLocator(10,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_2 ,master)); |
| | | batch.addLocator(11,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_3 ,master)); |
| | | batch.addLocator(12,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_4, master)); |
| | | batch.addLocator(13,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_5, master)); |
| | | batch.addLocator(14,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_6, master)); |
| | | batch.addLocator(15,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_7, master)); |
| | | batch.addLocator(16,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_8, master)); |
| | | batch.addLocator(17,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_9, master));//'9#支路温度', |
| | | batch.addLocator(9,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_1,DataType.TWO_BYTE_INT_SIGNED, master));//'1#支路温度', |
| | | batch.addLocator(10,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_2 ,DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(11,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_3 ,DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(12,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_4,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(13,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_5,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(14,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_6, DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(15,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_7, DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(16,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_8,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(17,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_tmp_9,DataType.TWO_BYTE_INT_SIGNED, master));//'9#支路温度', |
| | | |
| | | batch.addLocator(18,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_1, master));//'1#支路压力', |
| | | batch.addLocator(19,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_2, master)); |
| | | batch.addLocator(20,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_3, master)); |
| | | batch.addLocator(21,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_4, master)); |
| | | batch.addLocator(22,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_5, master)); |
| | | batch.addLocator(23,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_6, master)); |
| | | batch.addLocator(24,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_7, master)); |
| | | batch.addLocator(25,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_8, master)); |
| | | batch.addLocator(26,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_9, master));//'9#支路压力', |
| | | batch.addLocator(18,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_1,DataType.TWO_BYTE_INT_SIGNED, master));//'1#支路压力', |
| | | batch.addLocator(19,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_2, DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(20,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_3,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(21,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_4,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(22,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_5,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(23,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_6,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(24,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_7,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(25,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_8,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(26,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Branch_pre_9,DataType.TWO_BYTE_INT_SIGNED, master));//'9#支路压力', |
| | | return batch; |
| | | } |
| | | /** |
| | |
| | | */ |
| | | public void putBatchResult(BatchResults<Integer> res) { |
| | | if(res != null) { |
| | | this.Branch_flow_1 = MyModbusUtils.readShortToFloat(res.getValue(0)); |
| | | this.Branch_flow_2 = MyModbusUtils.readShortToFloat(res.getValue(1)); |
| | | this.Branch_flow_3 = MyModbusUtils.readShortToFloat(res.getValue(2)); |
| | | this.Branch_flow_4 = MyModbusUtils.readShortToFloat(res.getValue(3)); |
| | | this.Branch_flow_5 = MyModbusUtils.readShortToFloat(res.getValue(4)); |
| | | this.Branch_flow_6 = MyModbusUtils.readShortToFloat(res.getValue(5)); |
| | | this.Branch_flow_7 = MyModbusUtils.readShortToFloat(res.getValue(6)); |
| | | this.Branch_flow_8 = MyModbusUtils.readShortToFloat(res.getValue(7)); |
| | | this.Branch_flow_9 = MyModbusUtils.readShortToFloat(res.getValue(8)); |
| | | this.Branch_flow_1 = MyModbusUtils.readShortToFloat(res.getValue(0))/100; |
| | | this.Branch_flow_2 = MyModbusUtils.readShortToFloat(res.getValue(1))/100; |
| | | this.Branch_flow_3 = MyModbusUtils.readShortToFloat(res.getValue(2))/100; |
| | | this.Branch_flow_4 = MyModbusUtils.readShortToFloat(res.getValue(3))/100; |
| | | this.Branch_flow_5 = MyModbusUtils.readShortToFloat(res.getValue(4))/100; |
| | | this.Branch_flow_6 = MyModbusUtils.readShortToFloat(res.getValue(5))/100; |
| | | this.Branch_flow_7 = MyModbusUtils.readShortToFloat(res.getValue(6))/100; |
| | | this.Branch_flow_8 = MyModbusUtils.readShortToFloat(res.getValue(7))/100; |
| | | this.Branch_flow_9 = MyModbusUtils.readShortToFloat(res.getValue(8))/100; |
| | | |
| | | this.Branch_tmp_1 = MyModbusUtils.readShortToFloat(res.getValue(9)); |
| | | this.Branch_tmp_2 = MyModbusUtils.readShortToFloat(res.getValue(10)); |
| | | this.Branch_tmp_3 = MyModbusUtils.readShortToFloat(res.getValue(11)); |
| | | this.Branch_tmp_4 = MyModbusUtils.readShortToFloat(res.getValue(12)); |
| | | this.Branch_tmp_5 = MyModbusUtils.readShortToFloat(res.getValue(13)); |
| | | this.Branch_tmp_6 = MyModbusUtils.readShortToFloat(res.getValue(14)); |
| | | this.Branch_tmp_7 = MyModbusUtils.readShortToFloat(res.getValue(15)); |
| | | this.Branch_tmp_8 = MyModbusUtils.readShortToFloat(res.getValue(16)); |
| | | this.Branch_tmp_9 = MyModbusUtils.readShortToFloat(res.getValue(17)); |
| | | this.Branch_tmp_1 = MyModbusUtils.readShortToFloat(res.getValue(9),true)/10; |
| | | this.Branch_tmp_2 = MyModbusUtils.readShortToFloat(res.getValue(10),true)/10; |
| | | this.Branch_tmp_3 = MyModbusUtils.readShortToFloat(res.getValue(11),true)/10; |
| | | this.Branch_tmp_4 = MyModbusUtils.readShortToFloat(res.getValue(12),true)/10; |
| | | this.Branch_tmp_5 = MyModbusUtils.readShortToFloat(res.getValue(13),true)/10; |
| | | this.Branch_tmp_6 = MyModbusUtils.readShortToFloat(res.getValue(14),true)/10; |
| | | this.Branch_tmp_7 = MyModbusUtils.readShortToFloat(res.getValue(15),true)/10; |
| | | this.Branch_tmp_8 = MyModbusUtils.readShortToFloat(res.getValue(16),true)/10; |
| | | this.Branch_tmp_9 = MyModbusUtils.readShortToFloat(res.getValue(17),true)/10; |
| | | |
| | | this.Branch_pre_1 = MyModbusUtils.readShortToFloat(res.getValue(18)); |
| | | this.Branch_pre_2 = MyModbusUtils.readShortToFloat(res.getValue(19)); |
| | | this.Branch_pre_3 = MyModbusUtils.readShortToFloat(res.getValue(20)); |
| | | this.Branch_pre_4 = MyModbusUtils.readShortToFloat(res.getValue(21)); |
| | | this.Branch_pre_5 = MyModbusUtils.readShortToFloat(res.getValue(22)); |
| | | this.Branch_pre_6 = MyModbusUtils.readShortToFloat(res.getValue(23)); |
| | | this.Branch_pre_7 = MyModbusUtils.readShortToFloat(res.getValue(24)); |
| | | this.Branch_pre_8 = MyModbusUtils.readShortToFloat(res.getValue(25)); |
| | | this.Branch_pre_9 = MyModbusUtils.readShortToFloat(res.getValue(26)); |
| | | |
| | | this.Branch_pre_1 = MyModbusUtils.readShortToFloat(res.getValue(18),true)/100; |
| | | this.Branch_pre_2 = MyModbusUtils.readShortToFloat(res.getValue(19),true)/100; |
| | | this.Branch_pre_3 = MyModbusUtils.readShortToFloat(res.getValue(20),true)/100; |
| | | this.Branch_pre_4 = MyModbusUtils.readShortToFloat(res.getValue(21),true)/100; |
| | | this.Branch_pre_5 = MyModbusUtils.readShortToFloat(res.getValue(22),true)/100; |
| | | this.Branch_pre_6 = MyModbusUtils.readShortToFloat(res.getValue(23),true)/100; |
| | | this.Branch_pre_7 = MyModbusUtils.readShortToFloat(res.getValue(24),true)/100; |
| | | this.Branch_pre_8 = MyModbusUtils.readShortToFloat(res.getValue(25),true)/100; |
| | | this.Branch_pre_9 = MyModbusUtils.readShortToFloat(res.getValue(26),true)/100; |
| | | //System.out.println(this.Branch_pre_9+"*****"); |
| | | } |
| | | } |
| | | } |