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_state.java |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_state.java b/WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_state.java
index 6d8f796..39036fa 100644
--- a/WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_state.java
+++ b/WaterSystem_MonitorServer/src/com/watersystem/monitor/Water_state.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_state implements Serializable{
 	  public int num;//'主键',
 	  public int water_id;//'水冷系统id',
@@ -164,5 +169,42 @@
 				+ ", Water_system_function=" + Water_system_function + ", note=" + note + "]";
 	}
 	
-	  
+	/**
+	 * 创建读取数据集合
+	 * @param master
+	 * @return
+	 */
+	public BatchRead<Integer> createBatchRead(MyModbusMaster master){
+		BatchRead<Integer> batch = new BatchRead<Integer>();		
+		batch.addLocator(0,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Watersystem_All_Operation ,master));//水冷系统各部件运行情况
+		batch.addLocator(1,MyModbusUtils.createBaseLocator(Watersystem_ModbusAddress.Watersystem_All_State ,master));//故障复位信号	
+		return batch;
+	}
+	/**
+	 * 解析返回请求
+	 * @param res
+	 */
+	public void putBatchResult(BatchResults<Integer> res) {
+		if(res != null) {
+			int Watersystem_All_Operation= MyModbusUtils.readShortToInt(res.getValue(0));	
+			this.P01_main_pump=(Watersystem_All_Operation>>8&1);
+			this.P11_replenish_pump=(Watersystem_All_Operation>>9&1);
+			this.P12_pretest_pump=(Watersystem_All_Operation>>10&1);
+			this.P13_replenish_pump=(Watersystem_All_Operation>>11&1);
+			this.H01_electric_heater=(Watersystem_All_Operation>>12&1);
+			this.H02_electric_heater=(Watersystem_All_Operation>>13&1);
+			this.Solenoid_openflag=(Watersystem_All_Operation>>14&1);
+			this.Solenoid_shutflag=(Watersystem_All_Operation>>15&1);
+			this.valve_start=(Watersystem_All_Operation>>0&1);
+			this.Exhaust_start=(Watersystem_All_Operation>>8&1);
+			this.remote_start=(Watersystem_All_Operation>>8&5);
+			this.remote_stop=(Watersystem_All_Operation>>8&6);
+			this.Operation_ooled_devices=(Watersystem_All_Operation>>8&7);
+			int Watersystem_All_State = MyModbusUtils.readShortToInt(res.getValue(1));	
+			this.Auto_control_state=(Watersystem_All_State>>8&1);
+			this.Manual_control_state=(Watersystem_All_State>>9&1);
+			this.remote_control_state=(Watersystem_All_State>>10&1);
+			this.Water_system_function=(Watersystem_All_State>>11&1);
+		}
+	}
 }

--
Gitblit v1.9.1