whyclj
2020-10-17 e163b7b3e4d5acc63cfda2fec2dd9034864ccf7a
WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_alarm.java
@@ -3,6 +3,12 @@
import java.io.Serializable;
import java.util.Date;
import com.modbus.data.MyModbusMaster;
import com.modbus.data.MyModbusUtils;
import com.serotonin.modbus4j.BatchRead;
import com.serotonin.modbus4j.BatchResults;
import com.serotonin.modbus4j.code.DataType;
public class Water_alarm implements Serializable{
   public int num;
   public int water_id;
@@ -92,5 +98,37 @@
      return water_alarm;
   }
   
   /**
    * 创建读取数据集合
    * @param master
    * @return
    */
   public BatchRead<Integer> createBatchRead(MyModbusMaster master){
      BatchRead<Integer> batch = new BatchRead<Integer>();
      batch.addLocator(0,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Watersystem_Operation_Fault,DataType.TWO_BYTE_INT_UNSIGNED,master));//冷却系统各部件故障信息
      batch.addLocator(1,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Watersystem_BranchFlowTmp_Fault,DataType.TWO_BYTE_INT_UNSIGNED,master));//冷却系统支路流量/温度故障信息
      batch.addLocator(2,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Watersystem_Pre_Fault ,DataType.TWO_BYTE_INT_UNSIGNED, master));//冷却水压力故障
      batch.addLocator(3,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Watersystem_Operation_highorlow,DataType.TWO_BYTE_INT_UNSIGNED, master));//冷却系统各部件低/高
      batch.addLocator(4,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Watersystem_Tmp_highorlow,DataType.TWO_BYTE_INT_UNSIGNED, master));//冷却系统温度高/超高
      batch.addLocator(5,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Watersystem_TmpFlow_highorlow,DataType.TWO_BYTE_INT_UNSIGNED, master));//冷却系统支路温度/流量低/超低
      batch.addLocator(6,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Watersystem_Flow_ighorlow,DataType.TWO_BYTE_INT_UNSIGNED, master));//冷却水部分支路流量低/超低
      return batch;
   }
   /**
    * 解析返回请求
    * @param res
    */
   public void putBatchResult(BatchResults<Integer> res) {
      if(res != null) {
         this.Watersystem_Operation_Fault = MyModbusUtils.readIntergerToInt(res.getValue(0));
         this.Watersystem_BranchFlowTmp_Fault = MyModbusUtils.readIntergerToInt(res.getValue(1));
         this.Watersystem_Pre_Fault = MyModbusUtils.readIntergerToInt(res.getValue(2));
         this.Watersystem_Operation_highorlow = MyModbusUtils.readIntergerToInt(res.getValue(3));
         //System.out.println("1296:"+this.Watersystem_Operation_highorlow);
         this.Watersystem_Tmp_highorlow = MyModbusUtils.readIntergerToInt(res.getValue(4));
         this.Watersystem_TmpFlow_highorlow = MyModbusUtils.readIntergerToInt(res.getValue(5));
         this.Watersystem_Flow_ighorlow = MyModbusUtils.readIntergerToInt(res.getValue(6));
      }
   }
}