| | |
| | | <?xml version="1.0" encoding="UTF-8"?>
|
| | | <classpath>
|
| | | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
| | | <classpathentry kind="src" path="src"/>
|
| | | <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.30-bin.jar"/>
|
| | | <classpathentry kind="lib" path="lib/c3p0-0.9.5.jar"/>
|
| | | <classpathentry kind="lib" path="lib/c3p0-oracle-thin-extras-0.9.5.jar"/>
|
| | | <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
|
| | | <classpathentry kind="lib" path="lib/commons-codec-1.9.jar"/>
|
| | | <classpathentry kind="lib" path="lib/commons-net-3.6.jar"/>
|
| | | <classpathentry kind="lib" path="lib/jakarta-oro-2.0.8.jar"/>
|
| | | <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/>
|
| | | <classpathentry kind="output" path="bin"/>
|
| | | </classpath>
|
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <classpath> |
| | | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> |
| | | <classpathentry kind="src" path="src"/> |
| | | <classpathentry kind="lib" path="lib/mysql-connector-java-5.1.30-bin.jar"/> |
| | | <classpathentry kind="lib" path="lib/c3p0-0.9.5.jar"/> |
| | | <classpathentry kind="lib" path="lib/c3p0-oracle-thin-extras-0.9.5.jar"/> |
| | | <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/> |
| | | <classpathentry kind="lib" path="lib/commons-codec-1.9.jar"/> |
| | | <classpathentry kind="lib" path="lib/commons-net-3.6.jar"/> |
| | | <classpathentry kind="lib" path="lib/jakarta-oro-2.0.8.jar"/> |
| | | <classpathentry kind="lib" path="lib/log4j-1.2.17.jar"/> |
| | | <classpathentry kind="lib" path="lib/commons-lang3-3.11.jar"/> |
| | | <classpathentry kind="lib" path="lib/commons-logging-1.1.3.jar"/> |
| | | <classpathentry kind="lib" path="lib/modbus4j-3.0.4-SNAPSHOT.jar"/> |
| | | <classpathentry kind="output" path="bin"/> |
| | | </classpath> |
| | |
| | | |
| | | <root> |
| | | <mysql_ramdb_recreate_en>false</mysql_ramdb_recreate_en> |
| | | <mysql_server_ip>127.0.0.1</mysql_server_ip> |
| | | <mysql_server_ip>118.89.139.230</mysql_server_ip> |
| | | <!--SOURCE_BATTDATA_TYPE_FBSDEV = 0--> |
| | | <!--SOURCE_BATTDATA_TYPE_SQLSERVER = 1--> |
| | | <!--SOURCE_BATTDATA_TYPE_C_INTERFACE = 2--> |
| | |
| | | package com.data;
|
| | |
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | | import java.util.Date;
|
| | |
|
| | | import com.base.Com;
|
| | | import com.dev.base.data.Dynamicload_button;
|
| | | import com.dev.base.data.Dynamicload_control;
|
| | | import com.dev.base.data.Dynamicload_state;
|
| | | import com.sql.MysqlConnPool;
|
| | | import com.sql.Sql_Mysql;
|
| | |
|
| | | public class PowerArk_ServerSocket_Thread_SQL {
|
| | |
|
| | | public static void insertOrUpdateDynamicload_ButtonTable(MysqlConnPool conn_pool,int dev_id) {
|
| | | String sql_str_sel = " SELECT * FROM " +Sql_Mysql.Tb_Dynamicload_Button_Rt+ " WHERE dev_id = " + dev_id;
|
| | | String sql_str_ins = " INSERT INTO " + Sql_Mysql.Tb_Dynamicload_Button_Rt + "(dev_id,FZ_b1,FZ_b2,FZ_b3,FZ_b4,FZ_b5,FZ_b6,FZ_b7,FZ_b8,FZ_b9,FZ_b10,FZ_b11,start_auto,stop_auto,sudden_crease,all_open,FZ_autostate1,FZ_autostate2,FZ_autostate3,FZ_autostate4,FZ_autostate5,local_control,back_control,central_control,inter_volume_M200,fan_button) "
|
| | | + " values("+dev_id+",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); ";
|
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
| | | ResultSet res = null;
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str_sel);
|
| | | if(res.next()) {
|
| | | //更新当前状态
|
| | | updateDynamicload_ButtonTable(conn_pool,new Dynamicload_button(dev_id));
|
| | | }else {
|
| | | //插入默认状态
|
| | | sql.sqlMysqlExecute(sql_str_ins);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(res != null) {
|
| | | try {
|
| | | |
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con(); |
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 插入设备控制信息记录
|
| | | * @param conn_pool
|
| | | * @param dev_id
|
| | | */
|
| | | public static void insertOrUpdateDynamicload_ControlTable(MysqlConnPool conn_pool,int dev_id) {
|
| | | String sql_str_sel = " SELECT * FROM " +Sql_Mysql.Tb_Dynamicload_Control+ " WHERE dev_id = " + dev_id;
|
| | | String sql_str_ins = " INSERT INTO " + Sql_Mysql.Tb_Dynamicload_Control + "(dev_id,FZ_b1,FZ_b2,FZ_b3,FZ_b4,FZ_b5,FZ_b6,FZ_b7,FZ_b8,FZ_b9,FZ_b10,FZ_b11,start_auto,stop_auto,sudden_crease,all_open,FZ_autostate1,FZ_autostate2,FZ_autostate3,FZ_autostate4,FZ_autostate5,local_control,back_control,central_control,inter_volume_M200,fan_button,set_power) VALUES("+dev_id+",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)";
|
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
| | | ResultSet res = null;
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str_sel);
|
| | | if(res.next()) {
|
| | | //更新当前状态
|
| | | updateDynamicload_ControlTable(conn_pool, new Dynamicload_control(dev_id));
|
| | | }else {
|
| | | //插入默认状态
|
| | | sql.sqlMysqlExecute(sql_str_ins);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(res != null) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con(); |
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 插入设备状态信息记录
|
| | | * @param conn_pool
|
| | | * @param dev_id
|
| | | */
|
| | | public static void insertOrUpdateDynamicload_StateTable(MysqlConnPool conn_pool,int dev_id) {
|
| | | String sql_str_sel = " SELECT * FROM " +Sql_Mysql.Tb_Dynamicload_State_rt+ " WHERE dev_id = " + dev_id;
|
| | | String sql_str_ins = " INSERT INTO " + Sql_Mysql.Tb_Dynamicload_State_rt + "(dev_id,record_time,start_auto,stop_auto,sudden_crease,all_open,actual_set_power,output_power,set_power,interval_time,actual_curr,actual_mov,switch_on,FZ_autostate1,FZ_autostate2,FZ_autostate3,FZ_autostate4,FZ_autostate5,react_overtem,water_overtem,water_level_low,water_pressure_high,local_control,back_control,central_control,switch_state,inter_volume_M200,fan_button,fan_output,allow_close) VALUES("+dev_id+",'"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)";
|
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
| | | ResultSet res = null;
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str_sel);
|
| | | if(res.next()) {
|
| | | //更新当前状态
|
| | | updateDynamicload_StateTable(conn_pool, new Dynamicload_state(dev_id));
|
| | | }else {
|
| | | //插入默认状态
|
| | | sql.sqlMysqlExecute(sql_str_ins);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(res != null) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con(); |
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 更新设备按钮信息
|
| | | * @param conn_pool
|
| | | * @param control
|
| | | */
|
| | | public static void updateDynamicload_ButtonTable(MysqlConnPool conn_pool,Dynamicload_button button) {
|
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Dynamicload_Button_Rt |
| | | +" SET " |
| | | +" FZ_b1=" + button.FZ_b1
|
| | | +",FZ_b2=" + button.FZ_b2
|
| | | +",FZ_b3=" + button.FZ_b3
|
| | | +",FZ_b4=" + button.FZ_b4
|
| | | +",FZ_b5=" + button.FZ_b5
|
| | | +",FZ_b6=" + button.FZ_b6
|
| | | +",FZ_b7=" + button.FZ_b7
|
| | | +",FZ_b8=" + button.FZ_b8
|
| | | +",FZ_b9=" + button.FZ_b9
|
| | | +",FZ_b10=" + button.FZ_b10
|
| | | +",FZ_b11=" + button.FZ_b11
|
| | | +",FZ_fw1=" + button.FZ_fw1
|
| | | +",FZ_fw2=" + button.FZ_fw2
|
| | | +",FZ_fw3=" + button.FZ_fw3
|
| | | +",FZ_fw4=" + button.FZ_fw4
|
| | | +",FZ_fw5=" + button.FZ_fw5
|
| | | +",FZ_fw6=" + button.FZ_fw6
|
| | | +",FZ_fw7=" + button.FZ_fw7
|
| | | +",FZ_fw8=" + button.FZ_fw8
|
| | | +",FZ_fw9=" + button.FZ_fw9
|
| | | +",FZ_fw10=" + button.FZ_fw10
|
| | | +",FZ_fw11=" + button.FZ_fw11
|
| | | +",FZ_ex1=" + button.FZ_ex1
|
| | | +",FZ_ex2=" + button.FZ_ex2
|
| | | +",FZ_ex3=" + button.FZ_ex3
|
| | | +",FZ_ex4=" + button.FZ_ex4
|
| | | +",FZ_ex5=" + button.FZ_ex5
|
| | | +",FZ_ex6=" + button.FZ_ex6
|
| | | +",FZ_ex7=" + button.FZ_ex7
|
| | | +",FZ_ex8=" + button.FZ_ex8
|
| | | +",FZ_ex9=" + button.FZ_ex9
|
| | | +",FZ_ex10=" + button.FZ_ex10
|
| | | +",FZ_ex11=" + button.FZ_ex11
|
| | | +" WHERE dev_id = " + button.dev_id;
|
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
| | | try {
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 更新设备控制信息
|
| | | * @param conn_pool
|
| | | * @param control
|
| | | */
|
| | | public static void updateDynamicload_ControlTable(MysqlConnPool conn_pool,Dynamicload_control control) {
|
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Dynamicload_Control |
| | | + " SET FZ_b1= " + control.getFZ_b1()
|
| | | + ",FZ_b2 = " + control.getFZ_b2()
|
| | | + ",FZ_b3 = " + control.getFZ_b3()
|
| | | + ",FZ_b4 = " + control.getFZ_b4()
|
| | | + ",FZ_b5 = " + control.getFZ_b5()
|
| | | + ",FZ_b6 = " + control.getFZ_b6()
|
| | | + ",FZ_b7 = " + control.getFZ_b7()
|
| | | + ",FZ_b8 = " + control.getFZ_b8()
|
| | | + ",FZ_b9 = " + control.getFZ_b9()
|
| | | + ",FZ_b10 = " + control.getFZ_b10()
|
| | | + ",FZ_b11 = " + control.getFZ_b11()
|
| | | + ",start_auto = " + control.getStart_auto()
|
| | | + ",stop_auto = " + control.getStop_auto()
|
| | | + ",sudden_crease = " + control.getSudden_crease()
|
| | | + ",all_open = " + control.getAll_open()
|
| | | + ",FZ_autostate1 = " + control.getFZ_autostate1()
|
| | | + ",FZ_autostate2 = " + control.getFZ_autostate2()
|
| | | + ",FZ_autostate3 = " + control.getFZ_autostate3()
|
| | | + ",FZ_autostate4 = " + control.getFZ_autostate4()
|
| | | + ",FZ_autostate5 = " + control.getFZ_autostate5()
|
| | | + ",local_control = " + control.getLocal_control()
|
| | | + ",back_control = " + control.getBack_control()
|
| | | + ",central_control = " + control.getCentral_control()
|
| | | + ",inter_volume_M200 = " + control.getInter_volume_M200()
|
| | | + ",fan_button = " + control.getFan_button()
|
| | | + ",interval_time = " + control.interval_time
|
| | | + ",set_power = " + control.set_power
|
| | | + " WHERE dev_id = " + control.dev_id;
|
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
| | | try {
|
| | | //System.out.println(sql_str);
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 更新设备状态信息
|
| | | * @param conn_pool
|
| | | * @param control
|
| | | */
|
| | | public static void updateDynamicload_StateTable(MysqlConnPool conn_pool,Dynamicload_state state) {
|
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Dynamicload_State_rt |
| | | + " SET "
|
| | | +" start_auto=" + state.getStart_auto()
|
| | | +",stop_auto=" + state.getStop_auto()
|
| | | +",sudden_crease=" + state.getSudden_crease()
|
| | | +",all_open=" + state.getAll_open()
|
| | | +",actual_set_power=" + state.getActual_set_power()
|
| | | +",output_power=" + state.getOutput_power()
|
| | | +",set_power=" + state.getSet_power()
|
| | | +",interval_time=" + state.getInterval_time()
|
| | | +",actual_curr=" + state.getActual_curr()
|
| | | +",actual_mov=" + state.getActual_mov()
|
| | | +",switch_on=" + state.getSwitch_on()
|
| | | +",FZ_autostate1=" + state.getFZ_autostate1()
|
| | | +",FZ_autostate2=" + state.getFZ_autostate2()
|
| | | +",FZ_autostate3=" + state.getFZ_autostate3()
|
| | | +",FZ_autostate4=" + state.getFZ_autostate4()
|
| | | +",FZ_autostate5=" + state.getFZ_autostate5()
|
| | | +",react_overtem=" + state.getReact_overtem()
|
| | | +",water_overtem=" + state.getWater_overtem()
|
| | | +",water_level_low=" + state.getWater_level_low()
|
| | | +",water_pressure_high=" + state.getWater_pressure_high()
|
| | | +",local_control=" + state.getLocal_control()
|
| | | +",back_control=" + state.getBack_control()
|
| | | +",central_control=" + state.getCentral_control()
|
| | | +",switch_state=" + state.getSwitch_state()
|
| | | +",inter_volume_M200=" + state.getInter_volume_M200()
|
| | | +",fan_button=" + state.getFan_button()
|
| | | +",fan_output=" + state.getFan_output()
|
| | | +",allow_close=" + state.allow_close
|
| | | + " WHERE dev_id = " + state.dev_id;
|
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
| | | try {
|
| | | //System.out.println(sql_str);
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | }
|
| | | package com.data; |
| | | |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | import java.util.Date; |
| | | |
| | | import com.base.Com; |
| | | import com.dev.base.data.Dynamicload_button; |
| | | import com.dev.base.data.Dynamicload_control; |
| | | import com.dev.base.data.Dynamicload_state; |
| | | import com.sql.MysqlConnPool; |
| | | import com.sql.Sql_Mysql; |
| | | |
| | | public class PowerArk_ServerSocket_Thread_SQL { |
| | | |
| | | public static void insertOrUpdateDynamicload_ButtonTable(MysqlConnPool conn_pool,int dev_id) { |
| | | String sql_str_sel = " SELECT * FROM " +Sql_Mysql.Tb_Dynamicload_Button_Rt+ " WHERE dev_id = " + dev_id; |
| | | String sql_str_ins = " INSERT INTO " + Sql_Mysql.Tb_Dynamicload_Button_Rt + "(dev_id,FZ_b1,FZ_b2,FZ_b3,FZ_b4,FZ_b5,FZ_b6,FZ_b7,FZ_b8,FZ_b9,FZ_b10,FZ_b11,start_auto,stop_auto,sudden_crease,all_open,FZ_autostate1,FZ_autostate2,FZ_autostate3,FZ_autostate4,FZ_autostate5,local_control,back_control,central_control,inter_volume_M200,fan_button) " |
| | | + " values("+dev_id+",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); "; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | ResultSet res = null; |
| | | try { |
| | | res = sql.sqlMysqlQuery(sql_str_sel); |
| | | if(res.next()) { |
| | | //更新当前状态 |
| | | updateDynamicload_ButtonTable(conn_pool,new Dynamicload_button(dev_id)); |
| | | }else { |
| | | //插入默认状态 |
| | | sql.sqlMysqlExecute(sql_str_ins); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 插入设备控制信息记录 |
| | | * @param conn_pool |
| | | * @param dev_id |
| | | */ |
| | | public static void insertOrUpdateDynamicload_ControlTable(MysqlConnPool conn_pool,int dev_id) { |
| | | String sql_str_sel = " SELECT * FROM " +Sql_Mysql.Tb_Dynamicload_Control+ " WHERE dev_id = " + dev_id; |
| | | String sql_str_ins = " INSERT INTO " + Sql_Mysql.Tb_Dynamicload_Control + "(dev_id,FZ_b1,FZ_b2,FZ_b3,FZ_b4,FZ_b5,FZ_b6,FZ_b7,FZ_b8,FZ_b9,FZ_b10,FZ_b11,start_auto,stop_auto,sudden_crease,all_open,FZ_autostate1,FZ_autostate2,FZ_autostate3,FZ_autostate4,FZ_autostate5,local_control,back_control,central_control,inter_volume_M200,fan_button,set_power) VALUES("+dev_id+",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)"; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | ResultSet res = null; |
| | | try { |
| | | res = sql.sqlMysqlQuery(sql_str_sel); |
| | | if(res.next()) { |
| | | //更新当前状态 |
| | | updateDynamicload_ControlTable(conn_pool, new Dynamicload_control(dev_id)); |
| | | }else { |
| | | //插入默认状态 |
| | | sql.sqlMysqlExecute(sql_str_ins); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 插入设备状态信息记录 |
| | | * @param conn_pool |
| | | * @param dev_id |
| | | */ |
| | | public static void insertOrUpdateDynamicload_StateTable(MysqlConnPool conn_pool,int dev_id) { |
| | | String sql_str_sel = " SELECT * FROM " +Sql_Mysql.Tb_Dynamicload_State_rt+ " WHERE dev_id = " + dev_id; |
| | | String sql_str_ins = " INSERT INTO " + Sql_Mysql.Tb_Dynamicload_State_rt + "(dev_id,record_time,start_auto,stop_auto,sudden_crease,all_open,actual_set_power,output_power,set_power,interval_time,actual_curr,actual_mov,switch_on,FZ_autostate1,FZ_autostate2,FZ_autostate3,FZ_autostate4,FZ_autostate5,react_overtem,water_overtem,water_level_low,water_pressure_high,local_control,back_control,central_control,switch_state,inter_volume_M200,fan_button,fan_output,allow_close) VALUES("+dev_id+",'"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)"; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | ResultSet res = null; |
| | | try { |
| | | res = sql.sqlMysqlQuery(sql_str_sel); |
| | | if(res.next()) { |
| | | //更新当前状态 |
| | | updateDynamicload_StateTable(conn_pool, new Dynamicload_state(dev_id,0)); |
| | | }else { |
| | | //插入默认状态 |
| | | sql.sqlMysqlExecute(sql_str_ins); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新设备按钮信息 |
| | | * @param conn_pool |
| | | * @param control |
| | | */ |
| | | public static void updateDynamicload_ButtonTable(MysqlConnPool conn_pool,Dynamicload_button button) { |
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Dynamicload_Button_Rt |
| | | +" SET " |
| | | +" FZ_b1=" + button.FZ_b1 |
| | | +",FZ_b2=" + button.FZ_b2 |
| | | +",FZ_b3=" + button.FZ_b3 |
| | | +",FZ_b4=" + button.FZ_b4 |
| | | +",FZ_b5=" + button.FZ_b5 |
| | | +",FZ_b6=" + button.FZ_b6 |
| | | +",FZ_b7=" + button.FZ_b7 |
| | | +",FZ_b8=" + button.FZ_b8 |
| | | +",FZ_b9=" + button.FZ_b9 |
| | | +",FZ_b10=" + button.FZ_b10 |
| | | +",FZ_b11=" + button.FZ_b11 |
| | | +",FZ_fw1=" + button.FZ_fw1 |
| | | +",FZ_fw2=" + button.FZ_fw2 |
| | | +",FZ_fw3=" + button.FZ_fw3 |
| | | +",FZ_fw4=" + button.FZ_fw4 |
| | | +",FZ_fw5=" + button.FZ_fw5 |
| | | +",FZ_fw6=" + button.FZ_fw6 |
| | | +",FZ_fw7=" + button.FZ_fw7 |
| | | +",FZ_fw8=" + button.FZ_fw8 |
| | | +",FZ_fw9=" + button.FZ_fw9 |
| | | +",FZ_fw10=" + button.FZ_fw10 |
| | | +",FZ_fw11=" + button.FZ_fw11 |
| | | +",FZ_ex1=" + button.FZ_ex1 |
| | | +",FZ_ex2=" + button.FZ_ex2 |
| | | +",FZ_ex3=" + button.FZ_ex3 |
| | | +",FZ_ex4=" + button.FZ_ex4 |
| | | +",FZ_ex5=" + button.FZ_ex5 |
| | | +",FZ_ex6=" + button.FZ_ex6 |
| | | +",FZ_ex7=" + button.FZ_ex7 |
| | | +",FZ_ex8=" + button.FZ_ex8 |
| | | +",FZ_ex9=" + button.FZ_ex9 |
| | | +",FZ_ex10=" + button.FZ_ex10 |
| | | +",FZ_ex11=" + button.FZ_ex11 |
| | | +" WHERE dev_id = " + button.dev_id; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新设备控制信息 |
| | | * @param conn_pool |
| | | * @param control |
| | | */ |
| | | public static void updateDynamicload_ControlTable(MysqlConnPool conn_pool,Dynamicload_control control) { |
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Dynamicload_Control |
| | | + " SET FZ_b1= " + control.getFZ_b1() |
| | | + ",FZ_b2 = " + control.getFZ_b2() |
| | | + ",FZ_b3 = " + control.getFZ_b3() |
| | | + ",FZ_b4 = " + control.getFZ_b4() |
| | | + ",FZ_b5 = " + control.getFZ_b5() |
| | | + ",FZ_b6 = " + control.getFZ_b6() |
| | | + ",FZ_b7 = " + control.getFZ_b7() |
| | | + ",FZ_b8 = " + control.getFZ_b8() |
| | | + ",FZ_b9 = " + control.getFZ_b9() |
| | | + ",FZ_b10 = " + control.getFZ_b10() |
| | | + ",FZ_b11 = " + control.getFZ_b11() |
| | | + ",start_auto = " + control.getStart_auto() |
| | | + ",stop_auto = " + control.getStop_auto() |
| | | + ",sudden_crease = " + control.getSudden_crease() |
| | | + ",all_open = " + control.getAll_open() |
| | | + ",FZ_autostate1 = " + control.getFZ_autostate1() |
| | | + ",FZ_autostate2 = " + control.getFZ_autostate2() |
| | | + ",FZ_autostate3 = " + control.getFZ_autostate3() |
| | | + ",FZ_autostate4 = " + control.getFZ_autostate4() |
| | | + ",FZ_autostate5 = " + control.getFZ_autostate5() |
| | | + ",local_control = " + control.getLocal_control() |
| | | + ",back_control = " + control.getBack_control() |
| | | + ",central_control = " + control.getCentral_control() |
| | | + ",inter_volume_M200 = " + control.getInter_volume_M200() |
| | | + ",fan_button = " + control.getFan_button() |
| | | + ",interval_time = " + control.interval_time |
| | | + ",set_power = " + control.set_power |
| | | + " WHERE dev_id = " + control.dev_id; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | try { |
| | | //System.out.println(sql_str); |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新设备状态信息 |
| | | * @param conn_pool |
| | | * @param control |
| | | */ |
| | | public static void updateDynamicload_StateTable(MysqlConnPool conn_pool,Dynamicload_state state) { |
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Dynamicload_State_rt |
| | | + " SET " |
| | | +" start_auto=" + state.getStart_auto() |
| | | +",stop_auto=" + state.getStop_auto() |
| | | +",sudden_crease=" + state.getSudden_crease() |
| | | +",all_open=" + state.getAll_open() |
| | | +",actual_set_power=" + state.getActual_set_power() |
| | | +",output_power=" + state.getOutput_power() |
| | | +",set_power=" + state.getSet_power() |
| | | +",interval_time=" + state.getInterval_time() |
| | | +",actual_curr=" + state.getActual_curr() |
| | | +",actual_mov=" + state.getActual_mov() |
| | | +",switch_on=" + state.getSwitch_on() |
| | | +",FZ_autostate1=" + state.getFZ_autostate1() |
| | | +",FZ_autostate2=" + state.getFZ_autostate2() |
| | | +",FZ_autostate3=" + state.getFZ_autostate3() |
| | | +",FZ_autostate4=" + state.getFZ_autostate4() |
| | | +",FZ_autostate5=" + state.getFZ_autostate5() |
| | | +",react_overtem=" + state.getReact_overtem() |
| | | +",water_overtem=" + state.getWater_overtem() |
| | | +",water_level_low=" + state.getWater_level_low() |
| | | +",water_pressure_high=" + state.getWater_pressure_high() |
| | | +",local_control=" + state.getLocal_control() |
| | | +",back_control=" + state.getBack_control() |
| | | +",central_control=" + state.getCentral_control() |
| | | +",switch_state=" + state.getSwitch_state() |
| | | +",inter_volume_M200=" + state.getInter_volume_M200() |
| | | +",fan_button=" + state.getFan_button() |
| | | +",fan_output=" + state.getFan_output() |
| | | +",allow_close=" + state.allow_close |
| | | + " WHERE dev_id = " + state.dev_id; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | try { |
| | | //System.out.println(sql_str); |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.data;
|
| | |
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import com.dev.base.data.Dynamicload_button;
|
| | | import com.dev.base.data.Dynamicload_control;
|
| | | import com.dev.base.data.Dynamicload_inf;
|
| | | import com.dev.base.data.Dynamicload_state;
|
| | | import com.sql.MysqlConnPool;
|
| | | import com.sql.Sql_Mysql;
|
| | |
|
| | | public class PowerArk_Task_SQL {
|
| | | |
| | | /**
|
| | | * 查询所有的设备信息
|
| | | * @param conn_pool
|
| | | * @return
|
| | | */
|
| | | public static List<Dynamicload_inf> queryAllPowerArk(MysqlConnPool conn_pool){
|
| | | List<Dynamicload_inf> dys = new ArrayList<Dynamicload_inf>();
|
| | | String sql_str = " SELECT * FROM db_dynamicsystem.tb_dynamicload_inf ";
|
| | | ResultSet res = null;
|
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str);
|
| | | Dynamicload_inf dyna = null;
|
| | | while(res.next()) {
|
| | | dyna = new Dynamicload_inf();
|
| | | dyna.setDev_id(res.getInt("dev_id"));
|
| | | dyna.setDev_ip(res.getString("dev_ip"));
|
| | | dyna.setDev_name(res.getString("dev_name"));
|
| | | dyna.setDev_type(res.getInt("dev_type"));
|
| | | dyna.setFZ_button_num(res.getInt("fZ_button_num"));
|
| | | dyna.setNote(res.getString("note"));
|
| | | |
| | | dyna.button = new Dynamicload_button(dyna.dev_id);
|
| | | dyna.control = new Dynamicload_control(dyna.dev_id);
|
| | | dyna.state = new Dynamicload_state(dyna.dev_id);
|
| | | dys.add(dyna);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(res != null) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | return dys;
|
| | | }
|
| | | |
| | | }
|
| | | package com.data; |
| | | |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.base.Com; |
| | | import com.dev.base.data.Dynamicload_button; |
| | | import com.dev.base.data.Dynamicload_control; |
| | | import com.dev.base.data.Dynamicload_inf; |
| | | import com.dev.base.data.Dynamicload_state; |
| | | import com.sql.MysqlConnPool; |
| | | import com.sql.Sql_Mysql; |
| | | |
| | | public class PowerArk_Task_SQL { |
| | | |
| | | |
| | | /** |
| | | * 初始化数据库表 |
| | | * @param pool |
| | | */ |
| | | public static void init(MysqlConnPool pool) { |
| | | |
| | | createDB_ElectricSystem(pool); |
| | | |
| | | createTb_Dynamicload_inf(pool); |
| | | |
| | | createTb_Dynamicload_Button_Rt(pool); |
| | | |
| | | createTb_Dynamicload_State_rt(pool); |
| | | |
| | | createTb_Dynamicload_Control(pool); |
| | | |
| | | } |
| | | /** |
| | | * 创建负载数据库 |
| | | * @param pool |
| | | */ |
| | | public static void createDB_ElectricSystem(MysqlConnPool pool) { |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_DynamicSystem); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | /** |
| | | * 创建负载信息表 |
| | | * @param pool |
| | | */ |
| | | public static void createTb_Dynamicload_inf(MysqlConnPool pool) { |
| | | String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_Dynamicload_inf+" (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'," + |
| | | " dev_id int(11) NOT NULL DEFAULT '1' COMMENT '设备id'," + |
| | | " dev_name varchar(126) NOT NULL DEFAULT '' COMMENT '设备名称'," + |
| | | " dev_type int(11) NOT NULL DEFAULT '0' COMMENT '设备类型 1:负载.....'," + |
| | | " FZ_button_num int(11) NOT NULL DEFAULT '10' COMMENT '负载柜上按钮个数',"+ |
| | | " dev_ip varchar(126) NOT NULL DEFAULT '' COMMENT '设备ip'," + |
| | | " note varchar(255) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (num)," + |
| | | " KEY dev_id_key (dev_id)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | /** |
| | | * 创建按钮实时信息 |
| | | * @param pool |
| | | */ |
| | | public static void createTb_Dynamicload_Button_Rt(MysqlConnPool pool) { |
| | | String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_Dynamicload_Button_Rt+" (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'," + |
| | | " dev_id int(11) NOT NULL DEFAULT '1' COMMENT '设备id'," + |
| | | " FZ_b1 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮1'," + |
| | | " FZ_b2 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮2'," + |
| | | " FZ_b3 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮3'," + |
| | | " FZ_b4 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮4'," + |
| | | " FZ_b5 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮5'," + |
| | | " FZ_b6 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮6'," + |
| | | " FZ_b7 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮7'," + |
| | | " FZ_b8 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮8'," + |
| | | " FZ_b9 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮9'," + |
| | | " FZ_b10 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮10'," + |
| | | " FZ_b11 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮11'," + |
| | | " FZ_b1_power float NOT NULL DEFAULT '37.5' COMMENT 'FZ按钮1额定功率'," + |
| | | " FZ_b2_power float NOT NULL DEFAULT '37.5' COMMENT 'FZ按钮2额定功率'," + |
| | | " FZ_b3_power float NOT NULL DEFAULT '75' COMMENT 'FZ按钮3额定功率'," + |
| | | " FZ_b4_power float NOT NULL DEFAULT '75' COMMENT 'FZ按钮4额定功率'," + |
| | | " FZ_b5_power float NOT NULL DEFAULT '75' COMMENT 'FZ按钮5额定功率'," + |
| | | " FZ_b6_power float NOT NULL DEFAULT '75' COMMENT 'FZ按钮6额定功率'," + |
| | | " FZ_b7_power float NOT NULL DEFAULT '75' COMMENT 'FZ按钮7额定功率'," + |
| | | " FZ_b8_power float NOT NULL DEFAULT '75' COMMENT 'FZ按钮8额定功率'," + |
| | | " FZ_b9_power float NOT NULL DEFAULT '112.5' COMMENT 'FZ按钮9额定功率'," + |
| | | " FZ_b10_power float NOT NULL DEFAULT '112.5' COMMENT 'FZ按钮10额定功率'," + |
| | | " FZ_b11_power float NOT NULL DEFAULT '200' COMMENT 'FZ按钮11额定功率'," + |
| | | " FZ_fw1 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮1'," + |
| | | " FZ_fw2 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮2'," + |
| | | " FZ_fw3 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮3'," + |
| | | " FZ_fw4 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮4'," + |
| | | " FZ_fw5 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮5'," + |
| | | " FZ_fw6 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮6'," + |
| | | " FZ_fw7 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮7'," + |
| | | " FZ_fw8 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮8'," + |
| | | " FZ_fw9 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮9'," + |
| | | " FZ_fw10 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮10'," + |
| | | " FZ_fw11 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ反馈按钮11'," + |
| | | " FZ_ex1 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮1'," + |
| | | " FZ_ex2 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮2'," + |
| | | " FZ_ex3 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮3'," + |
| | | " FZ_ex4 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮4'," + |
| | | " FZ_ex5 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮5'," + |
| | | " FZ_ex6 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮6'," + |
| | | " FZ_ex7 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮7'," + |
| | | " FZ_ex8 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮8'," + |
| | | " FZ_ex9 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮9'," + |
| | | " FZ_ex10 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮10'," + |
| | | " FZ_ex11 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ输出按钮11'," + |
| | | " note varchar(255) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (num)," + |
| | | " KEY dev_id_key (dev_id)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | /** |
| | | * 创建负载信息表 |
| | | * @param pool |
| | | */ |
| | | public static void createTb_Dynamicload_State_rt(MysqlConnPool pool) { |
| | | String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_Dynamicload_State_rt+" (" + |
| | | " num int(11) NOT NULL AUTO_INCREMENT COMMENT '主键'," + |
| | | " dev_id int(11) NOT NULL DEFAULT '1001' COMMENT '设备id'," + |
| | | " record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + |
| | | " start_auto int(11) NOT NULL DEFAULT '0' COMMENT '启动自动加载'," + |
| | | " stop_auto int(11) NOT NULL DEFAULT '0' COMMENT '停止自动加载'," + |
| | | " sudden_crease int(11) NOT NULL DEFAULT '0' COMMENT '突加突卸'," + |
| | | " all_open int(11) NOT NULL DEFAULT '0' COMMENT '全部分闸'," + |
| | | " actual_set_power float NOT NULL DEFAULT '0' COMMENT '实际设定功率'," + |
| | | " output_power float NOT NULL DEFAULT '0' COMMENT '已输出功率'," + |
| | | " set_power float NOT NULL DEFAULT '0' COMMENT '设定功率'," + |
| | | " interval_time float NOT NULL DEFAULT '0' COMMENT '间隔时间s'," + |
| | | " actual_curr float NOT NULL DEFAULT '0' COMMENT '实际电流'," + |
| | | " actual_mov float NOT NULL DEFAULT '0' COMMENT '实际电压'," + |
| | | " switch_on int(11) NOT NULL DEFAULT '0' COMMENT '是否合闸'," + |
| | | " FZ_autostate1 int(11) NOT NULL DEFAULT '0' COMMENT 'FZ自动状态1'," + |
| | | " FZ_autostate2 int(11) NOT NULL DEFAULT '0' COMMENT 'FZ自动状态2'," + |
| | | " FZ_autostate3 int(11) NOT NULL DEFAULT '0' COMMENT 'FZ自动状态3'," + |
| | | " FZ_autostate4 int(11) NOT NULL DEFAULT '0' COMMENT 'FZ自动状态4'," + |
| | | " FZ_autostate5 int(11) NOT NULL DEFAULT '0' COMMENT 'FZ自动状态5'," + |
| | | " react_overtem int(11) NOT NULL DEFAULT '0' COMMENT '电抗超温'," + |
| | | " water_overtem int(11) NOT NULL DEFAULT '0' COMMENT '冷却水超温'," + |
| | | " water_level_low int(11) NOT NULL DEFAULT '0' COMMENT '冷却水液位低'," + |
| | | " water_pressure_high int(11) NOT NULL DEFAULT '0' COMMENT '冷却水压高'," + |
| | | " local_control int(11) NOT NULL DEFAULT '0' COMMENT '就地控制'," + |
| | | " back_control int(11) NOT NULL DEFAULT '0' COMMENT '后台控制'," + |
| | | " central_control int(11) NOT NULL DEFAULT '0' COMMENT '中控控制'," + |
| | | " switch_state int(11) NOT NULL DEFAULT '0' COMMENT '开关柜状态'," + |
| | | " inter_volume_M200 int(11) NOT NULL DEFAULT '0' COMMENT '中间量M200'," + |
| | | " fan_button int(11) NOT NULL DEFAULT '0' COMMENT '风机按钮'," + |
| | | " fan_output int(11) NOT NULL DEFAULT '0' COMMENT '风机输出'," + |
| | | " allow_close int(11) NOT NULL DEFAULT '0' COMMENT '是否允许合闸'," + |
| | | " note varchar(255) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (num)," + |
| | | " KEY dev_id_key (dev_id)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | /** |
| | | * 创建控制表 |
| | | * @param pool |
| | | */ |
| | | public static void createTb_Dynamicload_Control(MysqlConnPool pool) { |
| | | String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_Dynamicload_Control+" (" + |
| | | " num int(11) NOT NULL AUTO_INCREMENT COMMENT '主键'," + |
| | | " dev_id int(11) NOT NULL DEFAULT '1' COMMENT '设备id'," + |
| | | " FZ_b1 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮1'," + |
| | | " FZ_b2 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮2'," + |
| | | " FZ_b3 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮3'," + |
| | | " FZ_b4 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮4'," + |
| | | " FZ_b5 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮5'," + |
| | | " FZ_b6 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮6'," + |
| | | " FZ_b7 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮7'," + |
| | | " FZ_b8 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮8'," + |
| | | " FZ_b9 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮9'," + |
| | | " FZ_b10 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮10'," + |
| | | " FZ_b11 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ按钮11'," + |
| | | " start_auto int(11) NOT NULL DEFAULT '1' COMMENT '启动自动加载'," + |
| | | " stop_auto int(11) NOT NULL DEFAULT '1' COMMENT '停止自动加载'," + |
| | | " sudden_crease int(11) NOT NULL DEFAULT '1' COMMENT '突加突卸'," + |
| | | " all_open int(11) NOT NULL DEFAULT '1' COMMENT '全部分闸'," + |
| | | " FZ_autostate1 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ自动状态1'," + |
| | | " FZ_autostate2 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ自动状态2'," + |
| | | " FZ_autostate3 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ自动状态3'," + |
| | | " FZ_autostate4 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ自动状态4'," + |
| | | " FZ_autostate5 int(11) NOT NULL DEFAULT '1' COMMENT 'FZ自动状态5'," + |
| | | " local_control int(11) NOT NULL DEFAULT '1' COMMENT '就地控制'," + |
| | | " back_control int(11) NOT NULL DEFAULT '1' COMMENT '后台控制'," + |
| | | " central_control int(11) NOT NULL DEFAULT '1' COMMENT '中控控制'," + |
| | | " inter_volume_M200 int(11) NOT NULL DEFAULT '1' COMMENT '中间量M200'," + |
| | | " fan_button int(11) NOT NULL DEFAULT '1' COMMENT '风机按钮'," + |
| | | " set_power float NOT NULL DEFAULT '0' COMMENT '设定功率'," + |
| | | " note varchar(255) NOT NULL DEFAULT ''," + |
| | | " interval_time int(11) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (num)," + |
| | | " KEY dev_id_key (dev_id)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | /** |
| | | * 插入或更新负载按钮信息表 |
| | | * @param conn_pool |
| | | * @param dev_id |
| | | */ |
| | | public static void insertOrUpdateDynamicload_ButtonTable(MysqlConnPool conn_pool,Dynamicload_button dbutton,int button_num) { |
| | | String sql_str_sel = " SELECT * FROM " +Sql_Mysql.Tb_Dynamicload_Button_Rt+ " WHERE dev_id = " + dbutton.getDev_id(); |
| | | String sql_str_ins10 = " INSERT INTO " + Sql_Mysql.Tb_Dynamicload_Button_Rt + "(dev_id,FZ_b1_power,FZ_b2_power,FZ_b3_power,FZ_b4_power,FZ_b5_power,FZ_b6_power,FZ_b7_power,FZ_b8_power,FZ_b9_power,FZ_b10_power,FZ_b11_power) VALUES("+dbutton.dev_id+",37.5,37.5,75,75,75,75,75,75,112.5,112.5,0)"; |
| | | String sql_str_ins11 = " INSERT INTO " + Sql_Mysql.Tb_Dynamicload_Button_Rt + "(dev_id,FZ_b1_power,FZ_b2_power,FZ_b3_power,FZ_b4_power,FZ_b5_power,FZ_b6_power,FZ_b7_power,FZ_b8_power,FZ_b9_power,FZ_b10_power,FZ_b11_power) VALUES("+dbutton.dev_id+",5,5,10,10,20,50,50,100,100,200,200)"; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | ResultSet res = null; |
| | | try { |
| | | res = sql.sqlMysqlQuery(sql_str_sel); |
| | | if(res.next()) { |
| | | //更新当前状态 |
| | | updateDynamicload_ButtonTable(conn_pool, new Dynamicload_button(dbutton.dev_id)); |
| | | }else { |
| | | //插入默认状态 |
| | | if(button_num==11) { |
| | | sql.sqlMysqlExecute(sql_str_ins11); |
| | | }else { |
| | | sql.sqlMysqlExecute(sql_str_ins10); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | /** |
| | | * 插入或更新负载状态信息表 |
| | | * @param conn_pool |
| | | * @param dev_id |
| | | */ |
| | | public static void insertOrUpdateDynamicload_StateTable(MysqlConnPool conn_pool,Dynamicload_state dstate) { |
| | | String sql_str_sel = " SELECT * FROM " +Sql_Mysql.Tb_Dynamicload_State_rt+ " WHERE dev_id = " + dstate.dev_id; |
| | | String sql_str_ins = " INSERT INTO " + Sql_Mysql.Tb_Dynamicload_State_rt + "(dev_id,record_time) VALUES("+dstate.dev_id+",'"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)+"')"; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | ResultSet res = null; |
| | | try { |
| | | res = sql.sqlMysqlQuery(sql_str_sel); |
| | | if(res.next()) { |
| | | //更新当前状态 |
| | | updateDynamicload_StateTable(conn_pool, new Dynamicload_state(dstate.dev_id,0)); |
| | | }else { |
| | | //插入默认状态 |
| | | sql.sqlMysqlExecute(sql_str_ins); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询所有的设备信息 |
| | | * @param conn_pool |
| | | * @return |
| | | */ |
| | | public static List<Dynamicload_inf> queryAllPowerArk(MysqlConnPool conn_pool){ |
| | | List<Dynamicload_inf> dys = new ArrayList<Dynamicload_inf>(); |
| | | String sql_str = " SELECT * FROM db_dynamicsystem.tb_dynamicload_inf "; |
| | | ResultSet res = null; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | try { |
| | | res = sql.sqlMysqlQuery(sql_str); |
| | | Dynamicload_inf dyna = null; |
| | | while(res.next()) { |
| | | dyna = new Dynamicload_inf(); |
| | | dyna.setDev_id(res.getInt("dev_id")); |
| | | dyna.setDev_ip(res.getString("dev_ip")); |
| | | dyna.setDev_name(res.getString("dev_name")); |
| | | dyna.setDev_type(res.getInt("dev_type")); |
| | | dyna.setFZ_button_num(res.getInt("fZ_button_num")); |
| | | dyna.setNote(res.getString("note")); |
| | | |
| | | dyna.button = new Dynamicload_button(dyna.dev_id); |
| | | dyna.control = new Dynamicload_control(dyna.dev_id); |
| | | dyna.state = new Dynamicload_state(dyna.dev_id,0); |
| | | dys.add(dyna); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | return dys; |
| | | } |
| | | |
| | | /** |
| | | * 更新设备按钮信息 |
| | | * @param conn_pool |
| | | * @param control |
| | | */ |
| | | public static void updateDynamicload_ButtonTable(MysqlConnPool conn_pool,Dynamicload_button button) { |
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Dynamicload_Button_Rt |
| | | +" SET " |
| | | +" FZ_b1=" + button.FZ_b1 |
| | | +",FZ_b2=" + button.FZ_b2 |
| | | +",FZ_b3=" + button.FZ_b3 |
| | | +",FZ_b4=" + button.FZ_b4 |
| | | +",FZ_b5=" + button.FZ_b5 |
| | | +",FZ_b6=" + button.FZ_b6 |
| | | +",FZ_b7=" + button.FZ_b7 |
| | | +",FZ_b8=" + button.FZ_b8 |
| | | +",FZ_b9=" + button.FZ_b9 |
| | | +",FZ_b10=" + button.FZ_b10 |
| | | +",FZ_b11=" + button.FZ_b11 |
| | | +",FZ_fw1=" + button.FZ_fw1 |
| | | +",FZ_fw2=" + button.FZ_fw2 |
| | | +",FZ_fw3=" + button.FZ_fw3 |
| | | +",FZ_fw4=" + button.FZ_fw4 |
| | | +",FZ_fw5=" + button.FZ_fw5 |
| | | +",FZ_fw6=" + button.FZ_fw6 |
| | | +",FZ_fw7=" + button.FZ_fw7 |
| | | +",FZ_fw8=" + button.FZ_fw8 |
| | | +",FZ_fw9=" + button.FZ_fw9 |
| | | +",FZ_fw10=" + button.FZ_fw10 |
| | | +",FZ_fw11=" + button.FZ_fw11 |
| | | +",FZ_ex1=" + button.FZ_ex1 |
| | | +",FZ_ex2=" + button.FZ_ex2 |
| | | +",FZ_ex3=" + button.FZ_ex3 |
| | | +",FZ_ex4=" + button.FZ_ex4 |
| | | +",FZ_ex5=" + button.FZ_ex5 |
| | | +",FZ_ex6=" + button.FZ_ex6 |
| | | +",FZ_ex7=" + button.FZ_ex7 |
| | | +",FZ_ex8=" + button.FZ_ex8 |
| | | +",FZ_ex9=" + button.FZ_ex9 |
| | | +",FZ_ex10=" + button.FZ_ex10 |
| | | +",FZ_ex11=" + button.FZ_ex11 |
| | | +" WHERE dev_id = " + button.dev_id; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新设备状态信息 |
| | | * @param conn_pool |
| | | * @param control |
| | | */ |
| | | public static void updateDynamicload_StateTable(MysqlConnPool conn_pool,Dynamicload_state state) { |
| | | String sql_str = " UPDATE " + Sql_Mysql.Tb_Dynamicload_State_rt |
| | | + " SET " |
| | | +" start_auto=" + state.getStart_auto() |
| | | +",stop_auto=" + state.getStop_auto() |
| | | +",sudden_crease=" + state.getSudden_crease() |
| | | +",all_open=" + state.getAll_open() |
| | | +",actual_set_power=" + state.getActual_set_power() |
| | | +",output_power=" + state.getOutput_power() |
| | | +",set_power=" + state.getSet_power() |
| | | +",interval_time=" + state.getInterval_time() |
| | | +",actual_curr=" + state.getActual_curr() |
| | | +",actual_mov=" + state.getActual_mov() |
| | | +",switch_on=" + state.getSwitch_on() |
| | | +",FZ_autostate1=" + state.getFZ_autostate1() |
| | | +",FZ_autostate2=" + state.getFZ_autostate2() |
| | | +",FZ_autostate3=" + state.getFZ_autostate3() |
| | | +",FZ_autostate4=" + state.getFZ_autostate4() |
| | | +",FZ_autostate5=" + state.getFZ_autostate5() |
| | | +",react_overtem=" + state.getReact_overtem() |
| | | +",water_overtem=" + state.getWater_overtem() |
| | | +",water_level_low=" + state.getWater_level_low() |
| | | +",water_pressure_high=" + state.getWater_pressure_high() |
| | | +",local_control=" + state.getLocal_control() |
| | | +",back_control=" + state.getBack_control() |
| | | +",central_control=" + state.getCentral_control() |
| | | +",switch_state=" + state.getSwitch_state() |
| | | +",inter_volume_M200=" + state.getInter_volume_M200() |
| | | +",fan_button=" + state.getFan_button() |
| | | +",fan_output=" + state.getFan_output() |
| | | +",allow_close=" + state.allow_close |
| | | + " WHERE dev_id = " + state.dev_id; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | try { |
| | | //System.out.println(sql_str); |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.dev.base.data; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.base.Com; |
| | | import com.data.PowerArk_Task_SQL; |
| | | import com.sql.MysqlConnPool; |
| | | |
| | | public class Dynamicload_ServerSocket_Thread implements Runnable{ |
| | | public List<Dynamicload_inf> dinfs; |
| | | public MysqlConnPool conn_pool; |
| | | public Map<Integer, Dynamicload_SocketClient_Thread> dinfthreads; |
| | | |
| | | public Dynamicload_ServerSocket_Thread(MysqlConnPool conn_pool,List<Dynamicload_inf> dinfs) { |
| | | this.dinfs = dinfs; |
| | | this.conn_pool = conn_pool; |
| | | this.dinfthreads = new HashMap<Integer,Dynamicload_SocketClient_Thread>(); |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | // TODO Auto-generated method stub |
| | | System.out.println(" Dynamicload_ServerSocket_Thread Start at " +Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); |
| | | for(int i = 0;i<dinfs.size();i++) { |
| | | //插入或更新负载按钮信息表 |
| | | PowerArk_Task_SQL.insertOrUpdateDynamicload_ButtonTable(conn_pool, new Dynamicload_button(dinfs.get(i).getDev_id()),dinfs.get(i).getFZ_button_num()); |
| | | //插入或更新负载状态信息表 |
| | | PowerArk_Task_SQL.insertOrUpdateDynamicload_StateTable(conn_pool, new Dynamicload_state(dinfs.get(i).getDev_id(),dinfs.get(i).getFZ_button_num())); |
| | | |
| | | |
| | | Dynamicload_SocketClient_Thread thread = new Dynamicload_SocketClient_Thread(dinfs.get(i),conn_pool); |
| | | dinfthreads.put(dinfs.get(i).dev_id, thread); |
| | | new Thread(thread).start(); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.dev.base.data; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.data.PowerArk_Task_SQL; |
| | | import com.modbus.data.MyModbusMaster; |
| | | import com.modbus.data.MyModbusUtils; |
| | | import com.serotonin.modbus4j.BatchRead; |
| | | import com.serotonin.modbus4j.BatchResults; |
| | | import com.sql.MysqlConnPool; |
| | | |
| | | public class Dynamicload_SocketClient_Thread implements Runnable { |
| | | public MysqlConnPool conn_pool; |
| | | public Dynamicload_inf dinf; |
| | | |
| | | public Dynamicload_button dbutton; |
| | | public Dynamicload_control dcontrol; |
| | | public Dynamicload_state dstate; |
| | | |
| | | public MyModbusMaster master; |
| | | |
| | | public Dynamicload_SocketClient_Thread(Dynamicload_inf dinf, MysqlConnPool conn_pool) { |
| | | this.conn_pool = conn_pool; |
| | | this.dinf = dinf; |
| | | |
| | | dbutton = new Dynamicload_button(dinf.getDev_id()); |
| | | dcontrol = new Dynamicload_control(dinf.getDev_id()); |
| | | dstate = new Dynamicload_state(dinf.getDev_id(),dinf.getFZ_button_num()); |
| | | master = new MyModbusMaster(dinf.getDev_ip(), MyModbusMaster.SLAVEID_DEFAULT); |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | // TODO Auto-generated method stub |
| | | int runCount = 0; |
| | | Date last = new Date(); |
| | | while (true) { |
| | | try { |
| | | if (runCount % 2 == 0) { |
| | | // *************************** 更新负载按钮信息******************************//* |
| | | |
| | | // Date t1 = new Date(); |
| | | readMutilElectrical_button(master, dbutton); |
| | | PowerArk_Task_SQL.updateDynamicload_ButtonTable(conn_pool, dbutton); |
| | | // System.out.println("RT:"+(new Date().getTime() - t1.getTime())); |
| | | |
| | | // Date t2 = new Date(); |
| | | // **************************** 更新负载状态信息 *****************************//* |
| | | readMutilElectrical_state(master, dstate); |
| | | PowerArk_Task_SQL.updateDynamicload_StateTable(conn_pool, dstate); |
| | | // System.out.println("State:"+(new Date().getTime() - t2.getTime())); |
| | | } |
| | | |
| | | //System.err.println(dinf.dev_id + "=====" + ((new Date()).getTime() - last.getTime())); |
| | | last = new Date(); |
| | | |
| | | if (runCount % 10 == 0) { |
| | | // 更新当前设备ip |
| | | master.setTarget_ip(dinf.dev_ip); |
| | | } |
| | | if (runCount > 999900) { |
| | | runCount = 0; |
| | | } |
| | | runCount++; |
| | | Thread.sleep(50); |
| | | } catch (Exception e) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e1) { |
| | | // e1.printStackTrace(); |
| | | } |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * 多点读取负载按钮状态 |
| | | * @param master |
| | | * @param dbutton |
| | | */ |
| | | public void readMutilElectrical_button(MyModbusMaster master, Dynamicload_button dbutton) { |
| | | BatchRead<Integer> batch = dbutton.createBatchRead(master); |
| | | BatchResults<Integer> res = MyModbusUtils.readMutilRegisters(batch, master); |
| | | dbutton.putBatchResult(res); |
| | | } |
| | | |
| | | /** |
| | | * 更新负载状态信息 |
| | | * @param master |
| | | * @param dstate |
| | | */ |
| | | public void readMutilElectrical_state(MyModbusMaster master, Dynamicload_state dstate) { |
| | | BatchRead<Integer> batch = dstate.createBatchRead(master,dstate.fz_button_num); |
| | | BatchResults<Integer> res = MyModbusUtils.readMutilRegisters(batch, master); |
| | | dstate.putBatchResult(res); |
| | | } |
| | | } |
| | |
| | | package com.dev.base.data;
|
| | |
|
| | | public class Dynamicload_button {
|
| | | |
| | | public int dev_id;
|
| | | public int FZ_b1; //FZ按钮1
|
| | | public int FZ_b2; //FZ按钮2
|
| | | public int FZ_b3; //FZ按钮3
|
| | | public int FZ_b4; //FZ按钮4
|
| | | public int FZ_b5; //FZ按钮5
|
| | | public int FZ_b6; //FZ按钮6
|
| | | public int FZ_b7; //FZ按钮7
|
| | | public int FZ_b8; //FZ按钮8
|
| | | public int FZ_b9; //FZ按钮9
|
| | | public int FZ_b10; //FZ按钮10
|
| | | public int FZ_b11; //FZ按钮11
|
| | | public int FZ_fw1; //FZ反馈按钮1
|
| | | public int FZ_fw2; //FZ反馈按钮2
|
| | | public int FZ_fw3; //FZ反馈按钮3
|
| | | public int FZ_fw4; //FZ反馈按钮4
|
| | | public int FZ_fw5; //FZ反馈按钮5
|
| | | public int FZ_fw6; //FZ反馈按钮6
|
| | | public int FZ_fw7; //FZ反馈按钮7
|
| | | public int FZ_fw8; //FZ反馈按钮8
|
| | | public int FZ_fw9; //FZ反馈按钮9
|
| | | public int FZ_fw10; //FZ反馈按钮10
|
| | | public int FZ_fw11; //FZ反馈按钮11
|
| | | public int FZ_ex1; //FZ输出按钮1
|
| | | public int FZ_ex2; //FZ输出按钮2
|
| | | public int FZ_ex3; //FZ输出按钮3
|
| | | public int FZ_ex4; //FZ输出按钮4
|
| | | public int FZ_ex5; //FZ输出按钮5
|
| | | public int FZ_ex6; //FZ输出按钮6
|
| | | public int FZ_ex7; //FZ输出按钮7
|
| | | public int FZ_ex8; //FZ输出按钮8
|
| | | public int FZ_ex9; //FZ输出按钮9
|
| | | public int FZ_ex10; //FZ输出按钮10
|
| | | public int FZ_ex11; //FZ输出按钮11
|
| | | public String note;
|
| | | |
| | | |
| | | public Dynamicload_button(int dev_id) {
|
| | | this.dev_id = dev_id;
|
| | | }
|
| | | |
| | | public int getDev_id() {
|
| | | return dev_id;
|
| | | }
|
| | | public int getFZ_b1() {
|
| | | return FZ_b1;
|
| | | }
|
| | | public int getFZ_b2() {
|
| | | return FZ_b2;
|
| | | }
|
| | | public int getFZ_b3() {
|
| | | return FZ_b3;
|
| | | }
|
| | | public int getFZ_b4() {
|
| | | return FZ_b4;
|
| | | }
|
| | | public int getFZ_b5() {
|
| | | return FZ_b5;
|
| | | }
|
| | | public int getFZ_b6() {
|
| | | return FZ_b6;
|
| | | }
|
| | | public int getFZ_b7() {
|
| | | return FZ_b7;
|
| | | }
|
| | | public int getFZ_b8() {
|
| | | return FZ_b8;
|
| | | }
|
| | | public int getFZ_b9() {
|
| | | return FZ_b9;
|
| | | }
|
| | | public int getFZ_b10() {
|
| | | return FZ_b10;
|
| | | }
|
| | | public int getFZ_b11() {
|
| | | return FZ_b11;
|
| | | }
|
| | | public int getFZ_fw1() {
|
| | | return FZ_fw1;
|
| | | }
|
| | | public int getFZ_fw2() {
|
| | | return FZ_fw2;
|
| | | }
|
| | | public int getFZ_fw3() {
|
| | | return FZ_fw3;
|
| | | }
|
| | | public int getFZ_fw4() {
|
| | | return FZ_fw4;
|
| | | }
|
| | | public int getFZ_fw5() {
|
| | | return FZ_fw5;
|
| | | }
|
| | | public int getFZ_fw6() {
|
| | | return FZ_fw6;
|
| | | }
|
| | | public int getFZ_fw7() {
|
| | | return FZ_fw7;
|
| | | }
|
| | | public int getFZ_fw8() {
|
| | | return FZ_fw8;
|
| | | }
|
| | | public int getFZ_fw9() {
|
| | | return FZ_fw9;
|
| | | }
|
| | | public int getFZ_fw10() {
|
| | | return FZ_fw10;
|
| | | }
|
| | | public int getFZ_fw11() {
|
| | | return FZ_fw11;
|
| | | }
|
| | | public int getFZ_ex1() {
|
| | | return FZ_ex1;
|
| | | }
|
| | | public int getFZ_ex2() {
|
| | | return FZ_ex2;
|
| | | }
|
| | | public int getFZ_ex3() {
|
| | | return FZ_ex3;
|
| | | }
|
| | | public int getFZ_ex4() {
|
| | | return FZ_ex4;
|
| | | }
|
| | | public int getFZ_ex5() {
|
| | | return FZ_ex5;
|
| | | }
|
| | | public int getFZ_ex6() {
|
| | | return FZ_ex6;
|
| | | }
|
| | | public int getFZ_ex7() {
|
| | | return FZ_ex7;
|
| | | }
|
| | | public int getFZ_ex8() {
|
| | | return FZ_ex8;
|
| | | }
|
| | | public int getFZ_ex9() {
|
| | | return FZ_ex9;
|
| | | }
|
| | | public int getFZ_ex10() {
|
| | | return FZ_ex10;
|
| | | }
|
| | | public int getFZ_ex11() {
|
| | | return FZ_ex11;
|
| | | }
|
| | | public String getNote() {
|
| | | return note;
|
| | | }
|
| | | public void setDev_id(int dev_id) {
|
| | | this.dev_id = dev_id;
|
| | | }
|
| | | public void setFZ_b1(int fZ_b1) {
|
| | | FZ_b1 = fZ_b1;
|
| | | }
|
| | | public void setFZ_b2(int fZ_b2) {
|
| | | FZ_b2 = fZ_b2;
|
| | | }
|
| | | public void setFZ_b3(int fZ_b3) {
|
| | | FZ_b3 = fZ_b3;
|
| | | }
|
| | | public void setFZ_b4(int fZ_b4) {
|
| | | FZ_b4 = fZ_b4;
|
| | | }
|
| | | public void setFZ_b5(int fZ_b5) {
|
| | | FZ_b5 = fZ_b5;
|
| | | }
|
| | | public void setFZ_b6(int fZ_b6) {
|
| | | FZ_b6 = fZ_b6;
|
| | | }
|
| | | public void setFZ_b7(int fZ_b7) {
|
| | | FZ_b7 = fZ_b7;
|
| | | }
|
| | | public void setFZ_b8(int fZ_b8) {
|
| | | FZ_b8 = fZ_b8;
|
| | | }
|
| | | public void setFZ_b9(int fZ_b9) {
|
| | | FZ_b9 = fZ_b9;
|
| | | }
|
| | | public void setFZ_b10(int fZ_b10) {
|
| | | FZ_b10 = fZ_b10;
|
| | | }
|
| | | public void setFZ_b11(int fZ_b11) {
|
| | | FZ_b11 = fZ_b11;
|
| | | }
|
| | | public void setFZ_fw1(int fZ_fw1) {
|
| | | FZ_fw1 = fZ_fw1;
|
| | | }
|
| | | public void setFZ_fw2(int fZ_fw2) {
|
| | | FZ_fw2 = fZ_fw2;
|
| | | }
|
| | | public void setFZ_fw3(int fZ_fw3) {
|
| | | FZ_fw3 = fZ_fw3;
|
| | | }
|
| | | public void setFZ_fw4(int fZ_fw4) {
|
| | | FZ_fw4 = fZ_fw4;
|
| | | }
|
| | | public void setFZ_fw5(int fZ_fw5) {
|
| | | FZ_fw5 = fZ_fw5;
|
| | | }
|
| | | public void setFZ_fw6(int fZ_fw6) {
|
| | | FZ_fw6 = fZ_fw6;
|
| | | }
|
| | | public void setFZ_fw7(int fZ_fw7) {
|
| | | FZ_fw7 = fZ_fw7;
|
| | | }
|
| | | public void setFZ_fw8(int fZ_fw8) {
|
| | | FZ_fw8 = fZ_fw8;
|
| | | }
|
| | | public void setFZ_fw9(int fZ_fw9) {
|
| | | FZ_fw9 = fZ_fw9;
|
| | | }
|
| | | public void setFZ_fw10(int fZ_fw10) {
|
| | | FZ_fw10 = fZ_fw10;
|
| | | }
|
| | | public void setFZ_fw11(int fZ_fw11) {
|
| | | FZ_fw11 = fZ_fw11;
|
| | | }
|
| | | public void setFZ_ex1(int fZ_ex1) {
|
| | | FZ_ex1 = fZ_ex1;
|
| | | }
|
| | | public void setFZ_ex2(int fZ_ex2) {
|
| | | FZ_ex2 = fZ_ex2;
|
| | | }
|
| | | public void setFZ_ex3(int fZ_ex3) {
|
| | | FZ_ex3 = fZ_ex3;
|
| | | }
|
| | | public void setFZ_ex4(int fZ_ex4) {
|
| | | FZ_ex4 = fZ_ex4;
|
| | | }
|
| | | public void setFZ_ex5(int fZ_ex5) {
|
| | | FZ_ex5 = fZ_ex5;
|
| | | }
|
| | | public void setFZ_ex6(int fZ_ex6) {
|
| | | FZ_ex6 = fZ_ex6;
|
| | | }
|
| | | public void setFZ_ex7(int fZ_ex7) {
|
| | | FZ_ex7 = fZ_ex7;
|
| | | }
|
| | | public void setFZ_ex8(int fZ_ex8) {
|
| | | FZ_ex8 = fZ_ex8;
|
| | | }
|
| | | public void setFZ_ex9(int fZ_ex9) {
|
| | | FZ_ex9 = fZ_ex9;
|
| | | }
|
| | | public void setFZ_ex10(int fZ_ex10) {
|
| | | FZ_ex10 = fZ_ex10;
|
| | | }
|
| | | public void setFZ_ex11(int fZ_ex11) {
|
| | | FZ_ex11 = fZ_ex11;
|
| | | }
|
| | | public void setNote(String note) {
|
| | | this.note = note;
|
| | | }
|
| | | @Override
|
| | | public String toString() {
|
| | | return "Dynamicload_button [dev_id=" + dev_id + ", FZ_b1=" + FZ_b1 + ", FZ_b2=" + FZ_b2 + ", FZ_b3=" + FZ_b3
|
| | | + ", FZ_b4=" + FZ_b4 + ", FZ_b5=" + FZ_b5 + ", FZ_b6=" + FZ_b6 + ", FZ_b7=" + FZ_b7 + ", FZ_b8=" + FZ_b8
|
| | | + ", FZ_b9=" + FZ_b9 + ", FZ_b10=" + FZ_b10 + ", FZ_b11=" + FZ_b11 + ", FZ_fw1=" + FZ_fw1 + ", FZ_fw2="
|
| | | + FZ_fw2 + ", FZ_fw3=" + FZ_fw3 + ", FZ_fw4=" + FZ_fw4 + ", FZ_fw5=" + FZ_fw5 + ", FZ_fw6=" + FZ_fw6
|
| | | + ", FZ_fw7=" + FZ_fw7 + ", FZ_fw8=" + FZ_fw8 + ", FZ_fw9=" + FZ_fw9 + ", FZ_fw10=" + FZ_fw10
|
| | | + ", FZ_fw11=" + FZ_fw11 + ", FZ_ex1=" + FZ_ex1 + ", FZ_ex2=" + FZ_ex2 + ", FZ_ex3=" + FZ_ex3
|
| | | + ", FZ_ex4=" + FZ_ex4 + ", FZ_ex5=" + FZ_ex5 + ", FZ_ex6=" + FZ_ex6 + ", FZ_ex7=" + FZ_ex7
|
| | | + ", FZ_ex8=" + FZ_ex8 + ", FZ_ex9=" + FZ_ex9 + ", FZ_ex10=" + FZ_ex10 + ", FZ_ex11=" + FZ_ex11
|
| | | + ", note=" + note + "]";
|
| | | }
|
| | | }
|
| | | package com.dev.base.data; |
| | | |
| | | 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 Dynamicload_button { |
| | | |
| | | public int dev_id; |
| | | public int FZ_b1; //FZ按钮1 |
| | | public int FZ_b2; //FZ按钮2 |
| | | public int FZ_b3; //FZ按钮3 |
| | | public int FZ_b4; //FZ按钮4 |
| | | public int FZ_b5; //FZ按钮5 |
| | | public int FZ_b6; //FZ按钮6 |
| | | public int FZ_b7; //FZ按钮7 |
| | | public int FZ_b8; //FZ按钮8 |
| | | public int FZ_b9; //FZ按钮9 |
| | | public int FZ_b10; //FZ按钮10 |
| | | public int FZ_b11; //FZ按钮11 |
| | | public int FZ_fw1; //FZ反馈按钮1 |
| | | public int FZ_fw2; //FZ反馈按钮2 |
| | | public int FZ_fw3; //FZ反馈按钮3 |
| | | public int FZ_fw4; //FZ反馈按钮4 |
| | | public int FZ_fw5; //FZ反馈按钮5 |
| | | public int FZ_fw6; //FZ反馈按钮6 |
| | | public int FZ_fw7; //FZ反馈按钮7 |
| | | public int FZ_fw8; //FZ反馈按钮8 |
| | | public int FZ_fw9; //FZ反馈按钮9 |
| | | public int FZ_fw10; //FZ反馈按钮10 |
| | | public int FZ_fw11; //FZ反馈按钮11 |
| | | public int FZ_ex1; //FZ输出按钮1 |
| | | public int FZ_ex2; //FZ输出按钮2 |
| | | public int FZ_ex3; //FZ输出按钮3 |
| | | public int FZ_ex4; //FZ输出按钮4 |
| | | public int FZ_ex5; //FZ输出按钮5 |
| | | public int FZ_ex6; //FZ输出按钮6 |
| | | public int FZ_ex7; //FZ输出按钮7 |
| | | public int FZ_ex8; //FZ输出按钮8 |
| | | public int FZ_ex9; //FZ输出按钮9 |
| | | public int FZ_ex10; //FZ输出按钮10 |
| | | public int FZ_ex11; //FZ输出按钮11 |
| | | public String note; |
| | | |
| | | |
| | | public Dynamicload_button(int dev_id) { |
| | | this.dev_id = dev_id; |
| | | } |
| | | |
| | | public int getDev_id() { |
| | | return dev_id; |
| | | } |
| | | public int getFZ_b1() { |
| | | return FZ_b1; |
| | | } |
| | | public int getFZ_b2() { |
| | | return FZ_b2; |
| | | } |
| | | public int getFZ_b3() { |
| | | return FZ_b3; |
| | | } |
| | | public int getFZ_b4() { |
| | | return FZ_b4; |
| | | } |
| | | public int getFZ_b5() { |
| | | return FZ_b5; |
| | | } |
| | | public int getFZ_b6() { |
| | | return FZ_b6; |
| | | } |
| | | public int getFZ_b7() { |
| | | return FZ_b7; |
| | | } |
| | | public int getFZ_b8() { |
| | | return FZ_b8; |
| | | } |
| | | public int getFZ_b9() { |
| | | return FZ_b9; |
| | | } |
| | | public int getFZ_b10() { |
| | | return FZ_b10; |
| | | } |
| | | public int getFZ_b11() { |
| | | return FZ_b11; |
| | | } |
| | | public int getFZ_fw1() { |
| | | return FZ_fw1; |
| | | } |
| | | public int getFZ_fw2() { |
| | | return FZ_fw2; |
| | | } |
| | | public int getFZ_fw3() { |
| | | return FZ_fw3; |
| | | } |
| | | public int getFZ_fw4() { |
| | | return FZ_fw4; |
| | | } |
| | | public int getFZ_fw5() { |
| | | return FZ_fw5; |
| | | } |
| | | public int getFZ_fw6() { |
| | | return FZ_fw6; |
| | | } |
| | | public int getFZ_fw7() { |
| | | return FZ_fw7; |
| | | } |
| | | public int getFZ_fw8() { |
| | | return FZ_fw8; |
| | | } |
| | | public int getFZ_fw9() { |
| | | return FZ_fw9; |
| | | } |
| | | public int getFZ_fw10() { |
| | | return FZ_fw10; |
| | | } |
| | | public int getFZ_fw11() { |
| | | return FZ_fw11; |
| | | } |
| | | public int getFZ_ex1() { |
| | | return FZ_ex1; |
| | | } |
| | | public int getFZ_ex2() { |
| | | return FZ_ex2; |
| | | } |
| | | public int getFZ_ex3() { |
| | | return FZ_ex3; |
| | | } |
| | | public int getFZ_ex4() { |
| | | return FZ_ex4; |
| | | } |
| | | public int getFZ_ex5() { |
| | | return FZ_ex5; |
| | | } |
| | | public int getFZ_ex6() { |
| | | return FZ_ex6; |
| | | } |
| | | public int getFZ_ex7() { |
| | | return FZ_ex7; |
| | | } |
| | | public int getFZ_ex8() { |
| | | return FZ_ex8; |
| | | } |
| | | public int getFZ_ex9() { |
| | | return FZ_ex9; |
| | | } |
| | | public int getFZ_ex10() { |
| | | return FZ_ex10; |
| | | } |
| | | public int getFZ_ex11() { |
| | | return FZ_ex11; |
| | | } |
| | | public String getNote() { |
| | | return note; |
| | | } |
| | | public void setDev_id(int dev_id) { |
| | | this.dev_id = dev_id; |
| | | } |
| | | public void setFZ_b1(int fZ_b1) { |
| | | FZ_b1 = fZ_b1; |
| | | } |
| | | public void setFZ_b2(int fZ_b2) { |
| | | FZ_b2 = fZ_b2; |
| | | } |
| | | public void setFZ_b3(int fZ_b3) { |
| | | FZ_b3 = fZ_b3; |
| | | } |
| | | public void setFZ_b4(int fZ_b4) { |
| | | FZ_b4 = fZ_b4; |
| | | } |
| | | public void setFZ_b5(int fZ_b5) { |
| | | FZ_b5 = fZ_b5; |
| | | } |
| | | public void setFZ_b6(int fZ_b6) { |
| | | FZ_b6 = fZ_b6; |
| | | } |
| | | public void setFZ_b7(int fZ_b7) { |
| | | FZ_b7 = fZ_b7; |
| | | } |
| | | public void setFZ_b8(int fZ_b8) { |
| | | FZ_b8 = fZ_b8; |
| | | } |
| | | public void setFZ_b9(int fZ_b9) { |
| | | FZ_b9 = fZ_b9; |
| | | } |
| | | public void setFZ_b10(int fZ_b10) { |
| | | FZ_b10 = fZ_b10; |
| | | } |
| | | public void setFZ_b11(int fZ_b11) { |
| | | FZ_b11 = fZ_b11; |
| | | } |
| | | public void setFZ_fw1(int fZ_fw1) { |
| | | FZ_fw1 = fZ_fw1; |
| | | } |
| | | public void setFZ_fw2(int fZ_fw2) { |
| | | FZ_fw2 = fZ_fw2; |
| | | } |
| | | public void setFZ_fw3(int fZ_fw3) { |
| | | FZ_fw3 = fZ_fw3; |
| | | } |
| | | public void setFZ_fw4(int fZ_fw4) { |
| | | FZ_fw4 = fZ_fw4; |
| | | } |
| | | public void setFZ_fw5(int fZ_fw5) { |
| | | FZ_fw5 = fZ_fw5; |
| | | } |
| | | public void setFZ_fw6(int fZ_fw6) { |
| | | FZ_fw6 = fZ_fw6; |
| | | } |
| | | public void setFZ_fw7(int fZ_fw7) { |
| | | FZ_fw7 = fZ_fw7; |
| | | } |
| | | public void setFZ_fw8(int fZ_fw8) { |
| | | FZ_fw8 = fZ_fw8; |
| | | } |
| | | public void setFZ_fw9(int fZ_fw9) { |
| | | FZ_fw9 = fZ_fw9; |
| | | } |
| | | public void setFZ_fw10(int fZ_fw10) { |
| | | FZ_fw10 = fZ_fw10; |
| | | } |
| | | public void setFZ_fw11(int fZ_fw11) { |
| | | FZ_fw11 = fZ_fw11; |
| | | } |
| | | public void setFZ_ex1(int fZ_ex1) { |
| | | FZ_ex1 = fZ_ex1; |
| | | } |
| | | public void setFZ_ex2(int fZ_ex2) { |
| | | FZ_ex2 = fZ_ex2; |
| | | } |
| | | public void setFZ_ex3(int fZ_ex3) { |
| | | FZ_ex3 = fZ_ex3; |
| | | } |
| | | public void setFZ_ex4(int fZ_ex4) { |
| | | FZ_ex4 = fZ_ex4; |
| | | } |
| | | public void setFZ_ex5(int fZ_ex5) { |
| | | FZ_ex5 = fZ_ex5; |
| | | } |
| | | public void setFZ_ex6(int fZ_ex6) { |
| | | FZ_ex6 = fZ_ex6; |
| | | } |
| | | public void setFZ_ex7(int fZ_ex7) { |
| | | FZ_ex7 = fZ_ex7; |
| | | } |
| | | public void setFZ_ex8(int fZ_ex8) { |
| | | FZ_ex8 = fZ_ex8; |
| | | } |
| | | public void setFZ_ex9(int fZ_ex9) { |
| | | FZ_ex9 = fZ_ex9; |
| | | } |
| | | public void setFZ_ex10(int fZ_ex10) { |
| | | FZ_ex10 = fZ_ex10; |
| | | } |
| | | public void setFZ_ex11(int fZ_ex11) { |
| | | FZ_ex11 = fZ_ex11; |
| | | } |
| | | public void setNote(String note) { |
| | | this.note = note; |
| | | } |
| | | @Override |
| | | public String toString() { |
| | | return "Dynamicload_button [dev_id=" + dev_id + ", FZ_b1=" + FZ_b1 + ", FZ_b2=" + FZ_b2 + ", FZ_b3=" + FZ_b3 |
| | | + ", FZ_b4=" + FZ_b4 + ", FZ_b5=" + FZ_b5 + ", FZ_b6=" + FZ_b6 + ", FZ_b7=" + FZ_b7 + ", FZ_b8=" + FZ_b8 |
| | | + ", FZ_b9=" + FZ_b9 + ", FZ_b10=" + FZ_b10 + ", FZ_b11=" + FZ_b11 + ", FZ_fw1=" + FZ_fw1 + ", FZ_fw2=" |
| | | + FZ_fw2 + ", FZ_fw3=" + FZ_fw3 + ", FZ_fw4=" + FZ_fw4 + ", FZ_fw5=" + FZ_fw5 + ", FZ_fw6=" + FZ_fw6 |
| | | + ", FZ_fw7=" + FZ_fw7 + ", FZ_fw8=" + FZ_fw8 + ", FZ_fw9=" + FZ_fw9 + ", FZ_fw10=" + FZ_fw10 |
| | | + ", FZ_fw11=" + FZ_fw11 + ", FZ_ex1=" + FZ_ex1 + ", FZ_ex2=" + FZ_ex2 + ", FZ_ex3=" + FZ_ex3 |
| | | + ", FZ_ex4=" + FZ_ex4 + ", FZ_ex5=" + FZ_ex5 + ", FZ_ex6=" + FZ_ex6 + ", FZ_ex7=" + FZ_ex7 |
| | | + ", FZ_ex8=" + FZ_ex8 + ", FZ_ex9=" + FZ_ex9 + ", FZ_ex10=" + FZ_ex10 + ", FZ_ex11=" + FZ_ex11 |
| | | + ", note=" + note + "]"; |
| | | } |
| | | |
| | | /** |
| | | * 创建读取数据集合 |
| | | * @param master |
| | | * @return |
| | | */ |
| | | public BatchRead<Integer> createBatchRead(MyModbusMaster master){ |
| | | BatchRead<Integer> batch = new BatchRead<Integer>(); |
| | | batch.addLocator(0,MyModbusUtils.createBaseLocator(80 ,master));//按钮1 |
| | | batch.addLocator(1,MyModbusUtils.createBaseLocator(81 ,master)); |
| | | batch.addLocator(2,MyModbusUtils.createBaseLocator(82 , master)); |
| | | batch.addLocator(3,MyModbusUtils.createBaseLocator(83, master)); |
| | | batch.addLocator(4,MyModbusUtils.createBaseLocator(84, master)); |
| | | batch.addLocator(5,MyModbusUtils.createBaseLocator(85, master)); |
| | | batch.addLocator(6,MyModbusUtils.createBaseLocator(86, master)); |
| | | batch.addLocator(7,MyModbusUtils.createBaseLocator(87, master)); |
| | | batch.addLocator(8,MyModbusUtils.createBaseLocator(88, master)); |
| | | batch.addLocator(9,MyModbusUtils.createBaseLocator(89, master)); |
| | | batch.addLocator(10,MyModbusUtils.createBaseLocator(90, master));//按钮11 |
| | | |
| | | batch.addLocator(11,MyModbusUtils.createBaseLocator(4020,master));//反馈1 |
| | | batch.addLocator(12,MyModbusUtils.createBaseLocator(4021,master)); |
| | | batch.addLocator(13,MyModbusUtils.createBaseLocator(4022, master)); |
| | | batch.addLocator(14,MyModbusUtils.createBaseLocator(4023, master)); |
| | | batch.addLocator(15,MyModbusUtils.createBaseLocator(4024, master)); |
| | | batch.addLocator(16,MyModbusUtils.createBaseLocator(4025, master)); |
| | | batch.addLocator(17,MyModbusUtils.createBaseLocator(4026, master)); |
| | | batch.addLocator(18,MyModbusUtils.createBaseLocator(4027, master)); |
| | | batch.addLocator(19,MyModbusUtils.createBaseLocator(4028, master)); |
| | | batch.addLocator(20,MyModbusUtils.createBaseLocator(4029, master)); |
| | | batch.addLocator(21,MyModbusUtils.createBaseLocator(4030, master));//反馈11 |
| | | |
| | | batch.addLocator(22,MyModbusUtils.createBaseLocator(8000,master));//输出1 |
| | | batch.addLocator(23,MyModbusUtils.createBaseLocator(8001 ,master)); |
| | | batch.addLocator(24,MyModbusUtils.createBaseLocator(8002 ,master)); |
| | | batch.addLocator(25,MyModbusUtils.createBaseLocator(8003, master)); |
| | | batch.addLocator(26,MyModbusUtils.createBaseLocator(8004, master)); |
| | | batch.addLocator(27,MyModbusUtils.createBaseLocator(8005, master)); |
| | | batch.addLocator(28,MyModbusUtils.createBaseLocator(8006, master)); |
| | | batch.addLocator(29,MyModbusUtils.createBaseLocator(8007, master)); |
| | | batch.addLocator(30,MyModbusUtils.createBaseLocator(8008, master)); |
| | | batch.addLocator(31,MyModbusUtils.createBaseLocator(8009, master)); |
| | | batch.addLocator(32,MyModbusUtils.createBaseLocator(8010, master));//输出11 |
| | | |
| | | return batch; |
| | | } |
| | | /** |
| | | * 解析返回请求 |
| | | * @param res |
| | | */ |
| | | public void putBatchResult(BatchResults<Integer> res) { |
| | | if(res != null) { |
| | | this.FZ_b1 = MyModbusUtils.readBooleanToInt(res.getValue(0)); //按钮1 |
| | | this.FZ_b2 = MyModbusUtils.readBooleanToInt(res.getValue(1)); |
| | | this.FZ_b3 = MyModbusUtils.readBooleanToInt(res.getValue(2)); |
| | | this.FZ_b4 = MyModbusUtils.readBooleanToInt(res.getValue(3)); |
| | | this.FZ_b5 = MyModbusUtils.readBooleanToInt(res.getValue(4)); |
| | | this.FZ_b6 = MyModbusUtils.readBooleanToInt(res.getValue(5)); |
| | | this.FZ_b7 = MyModbusUtils.readBooleanToInt(res.getValue(6)); |
| | | this.FZ_b8 = MyModbusUtils.readBooleanToInt(res.getValue(7)); |
| | | this.FZ_b9 = MyModbusUtils.readBooleanToInt(res.getValue(8)); |
| | | this.FZ_b10= MyModbusUtils.readBooleanToInt(res.getValue(9)); |
| | | this.FZ_b11= MyModbusUtils.readBooleanToInt(res.getValue(10)); //按钮11 |
| | | |
| | | this.FZ_fw1 = MyModbusUtils.readBooleanToInt(res.getValue(11)); //反馈1 |
| | | this.FZ_fw2 = MyModbusUtils.readBooleanToInt(res.getValue(12)); //反馈2 |
| | | this.FZ_fw3 = MyModbusUtils.readBooleanToInt(res.getValue(13)); //反馈3 |
| | | this.FZ_fw4 = MyModbusUtils.readBooleanToInt(res.getValue(14)); //反馈4 |
| | | this.FZ_fw5 = MyModbusUtils.readBooleanToInt(res.getValue(15)); //反馈5 |
| | | this.FZ_fw6 = MyModbusUtils.readBooleanToInt(res.getValue(16)); //反馈6 |
| | | this.FZ_fw7 = MyModbusUtils.readBooleanToInt(res.getValue(17)); //反馈7 |
| | | this.FZ_fw8 = MyModbusUtils.readBooleanToInt(res.getValue(18)); //反馈8 |
| | | this.FZ_fw9 = MyModbusUtils.readBooleanToInt(res.getValue(19)); //反馈9 |
| | | this.FZ_fw10= MyModbusUtils.readBooleanToInt(res.getValue(20)); //反馈10 |
| | | this.FZ_fw11= MyModbusUtils.readBooleanToInt(res.getValue(21)); //反馈11 |
| | | |
| | | this.FZ_ex1 = MyModbusUtils.readBooleanToInt(res.getValue(22)); //输出1 |
| | | this.FZ_ex2 = MyModbusUtils.readBooleanToInt(res.getValue(23)); //输出2 |
| | | this.FZ_ex3 = MyModbusUtils.readBooleanToInt(res.getValue(24)); //输出3 |
| | | this.FZ_ex4 = MyModbusUtils.readBooleanToInt(res.getValue(25)); //输出4 |
| | | this.FZ_ex5 = MyModbusUtils.readBooleanToInt(res.getValue(26)); //输出5 |
| | | this.FZ_ex6 = MyModbusUtils.readBooleanToInt(res.getValue(27)); //输出6 |
| | | this.FZ_ex7 = MyModbusUtils.readBooleanToInt(res.getValue(28)); //输出7 |
| | | this.FZ_ex8 = MyModbusUtils.readBooleanToInt(res.getValue(29)); //输出8 |
| | | this.FZ_ex9 = MyModbusUtils.readBooleanToInt(res.getValue(30)); //输出9 |
| | | this.FZ_ex10= MyModbusUtils.readBooleanToInt(res.getValue(31)); //输出10 |
| | | this.FZ_ex11= MyModbusUtils.readBooleanToInt(res.getValue(32)); //输出11 |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | package com.dev.base.data;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | public class Dynamicload_state {
|
| | | |
| | | public int dev_id;
|
| | | public Date record_time; //记录时间
|
| | | public int start_auto; //启动自动加载
|
| | | public int stop_auto; //停止自动加载
|
| | | public int sudden_crease; //突加突卸
|
| | | public int all_open; //全部分闸
|
| | | public float actual_set_power; //实际设定功率
|
| | | public float output_power; //已输出功率
|
| | | public float set_power; //设定功率
|
| | | public float interval_time; //间隔时间s
|
| | | public float actual_curr; //实际电流
|
| | | public float actual_mov; //实际电压
|
| | | public int switch_on; //是否合闸
|
| | | public int FZ_autostate1; //FZ自动状态1
|
| | | public int FZ_autostate2; //FZ自动状态2
|
| | | public int FZ_autostate3; //FZ自动状态3
|
| | | public int FZ_autostate4; //FZ自动状态4
|
| | | public int FZ_autostate5; //FZ自动状态5
|
| | | public int react_overtem; //电抗超温
|
| | | public int water_overtem; //冷却水超温
|
| | | public int water_level_low; //冷却水液位低
|
| | | public int water_pressure_high; //冷却水压高
|
| | | public int local_control; //就地控制
|
| | | public int back_control; //后台控制
|
| | | public int central_control; //中控控制
|
| | | public int switch_state; //开关柜状态
|
| | | public int inter_volume_M200; //中间量M200
|
| | | public int fan_button; //风机按钮
|
| | | public int fan_output; //风机输出
|
| | | public int allow_close; //是否允许合闸
|
| | | public String note;
|
| | | |
| | | public Dynamicload_state(int dev_id) {
|
| | | this.dev_id = dev_id;
|
| | | }
|
| | | |
| | | public int getDev_id() {
|
| | | return dev_id;
|
| | | }
|
| | | public Date getRecord_time() {
|
| | | return record_time;
|
| | | }
|
| | | public int getStart_auto() {
|
| | | return start_auto;
|
| | | }
|
| | | public int getStop_auto() {
|
| | | return stop_auto;
|
| | | }
|
| | | public int getSudden_crease() {
|
| | | return sudden_crease;
|
| | | }
|
| | | public int getAll_open() {
|
| | | return all_open;
|
| | | }
|
| | | public float getActual_set_power() {
|
| | | return actual_set_power;
|
| | | }
|
| | | public float getOutput_power() {
|
| | | return output_power;
|
| | | }
|
| | | public float getSet_power() {
|
| | | return set_power;
|
| | | }
|
| | | public float getInterval_time() {
|
| | | return interval_time;
|
| | | }
|
| | | public float getActual_curr() {
|
| | | return actual_curr;
|
| | | }
|
| | | public float getActual_mov() {
|
| | | return actual_mov;
|
| | | }
|
| | | public int getSwitch_on() {
|
| | | return switch_on;
|
| | | }
|
| | | public int getFZ_autostate1() {
|
| | | return FZ_autostate1;
|
| | | }
|
| | | public int getFZ_autostate2() {
|
| | | return FZ_autostate2;
|
| | | }
|
| | | public int getFZ_autostate3() {
|
| | | return FZ_autostate3;
|
| | | }
|
| | | public int getFZ_autostate4() {
|
| | | return FZ_autostate4;
|
| | | }
|
| | | public int getFZ_autostate5() {
|
| | | return FZ_autostate5;
|
| | | }
|
| | | public int getReact_overtem() {
|
| | | return react_overtem;
|
| | | }
|
| | | public int getWater_overtem() {
|
| | | return water_overtem;
|
| | | }
|
| | | public int getWater_level_low() {
|
| | | return water_level_low;
|
| | | }
|
| | | public int getWater_pressure_high() {
|
| | | return water_pressure_high;
|
| | | }
|
| | | public int getLocal_control() {
|
| | | return local_control;
|
| | | }
|
| | | public int getBack_control() {
|
| | | return back_control;
|
| | | }
|
| | | public int getCentral_control() {
|
| | | return central_control;
|
| | | }
|
| | | public int getSwitch_state() {
|
| | | return switch_state;
|
| | | }
|
| | | public int getInter_volume_M200() {
|
| | | return inter_volume_M200;
|
| | | }
|
| | | public int getFan_button() {
|
| | | return fan_button;
|
| | | }
|
| | | public int getFan_output() {
|
| | | return fan_output;
|
| | | }
|
| | | public String getNote() {
|
| | | return note;
|
| | | }
|
| | | public void setDev_id(int dev_id) {
|
| | | this.dev_id = dev_id;
|
| | | }
|
| | | public void setRecord_time(Date record_time) {
|
| | | this.record_time = record_time;
|
| | | }
|
| | | public void setStart_auto(int start_auto) {
|
| | | this.start_auto = start_auto;
|
| | | }
|
| | | public void setStop_auto(int stop_auto) {
|
| | | this.stop_auto = stop_auto;
|
| | | }
|
| | | public void setSudden_crease(int sudden_crease) {
|
| | | this.sudden_crease = sudden_crease;
|
| | | }
|
| | | public void setAll_open(int all_open) {
|
| | | this.all_open = all_open;
|
| | | }
|
| | | public void setActual_set_power(float actual_set_power) {
|
| | | this.actual_set_power = actual_set_power;
|
| | | }
|
| | | public void setOutput_power(float output_power) {
|
| | | this.output_power = output_power;
|
| | | }
|
| | | public void setSet_power(float set_power) {
|
| | | this.set_power = set_power;
|
| | | }
|
| | | public void setInterval_time(float interval_time) {
|
| | | this.interval_time = interval_time;
|
| | | }
|
| | | public void setActual_curr(float actual_curr) {
|
| | | this.actual_curr = actual_curr;
|
| | | }
|
| | | public void setActual_mov(float actual_mov) {
|
| | | this.actual_mov = actual_mov;
|
| | | }
|
| | | public void setSwitch_on(int switch_on) {
|
| | | this.switch_on = switch_on;
|
| | | }
|
| | | public void setFZ_autostate1(int fZ_autostate1) {
|
| | | FZ_autostate1 = fZ_autostate1;
|
| | | }
|
| | | public void setFZ_autostate2(int fZ_autostate2) {
|
| | | FZ_autostate2 = fZ_autostate2;
|
| | | }
|
| | | public void setFZ_autostate3(int fZ_autostate3) {
|
| | | FZ_autostate3 = fZ_autostate3;
|
| | | }
|
| | | public void setFZ_autostate4(int fZ_autostate4) {
|
| | | FZ_autostate4 = fZ_autostate4;
|
| | | }
|
| | | public void setFZ_autostate5(int fZ_autostate5) {
|
| | | FZ_autostate5 = fZ_autostate5;
|
| | | }
|
| | | public void setReact_overtem(int react_overtem) {
|
| | | this.react_overtem = react_overtem;
|
| | | }
|
| | | public void setWater_overtem(int water_overtem) {
|
| | | this.water_overtem = water_overtem;
|
| | | }
|
| | | public void setWater_level_low(int water_level_low) {
|
| | | this.water_level_low = water_level_low;
|
| | | }
|
| | | public void setWater_pressure_high(int water_pressure_high) {
|
| | | this.water_pressure_high = water_pressure_high;
|
| | | }
|
| | | public void setLocal_control(int local_control) {
|
| | | this.local_control = local_control;
|
| | | }
|
| | | public void setBack_control(int back_control) {
|
| | | this.back_control = back_control;
|
| | | }
|
| | | public void setCentral_control(int central_control) {
|
| | | this.central_control = central_control;
|
| | | }
|
| | | public void setSwitch_state(int switch_state) {
|
| | | this.switch_state = switch_state;
|
| | | }
|
| | | public void setInter_volume_M200(int inter_volume_M200) {
|
| | | this.inter_volume_M200 = inter_volume_M200;
|
| | | }
|
| | | public void setFan_button(int fan_button) {
|
| | | this.fan_button = fan_button;
|
| | | }
|
| | | public void setFan_output(int fan_output) {
|
| | | this.fan_output = fan_output;
|
| | | }
|
| | | public void setNote(String note) {
|
| | | this.note = note;
|
| | | }
|
| | | @Override
|
| | | public String toString() {
|
| | | return "Dynamic_State [dev_id=" + dev_id + ", record_time=" + record_time + ", start_auto=" + start_auto
|
| | | + ", stop_auto=" + stop_auto + ", sudden_crease=" + sudden_crease + ", all_open=" + all_open
|
| | | + ", actual_set_power=" + actual_set_power + ", output_power=" + output_power + ", set_power="
|
| | | + set_power + ", interval_time=" + interval_time + ", actual_curr=" + actual_curr + ", actual_mov="
|
| | | + actual_mov + ", switch_on=" + switch_on + ", FZ_autostate1=" + FZ_autostate1 + ", FZ_autostate2="
|
| | | + FZ_autostate2 + ", FZ_autostate3=" + FZ_autostate3 + ", FZ_autostate4=" + FZ_autostate4
|
| | | + ", FZ_autostate5=" + FZ_autostate5 + ", react_overtem=" + react_overtem + ", water_overtem="
|
| | | + water_overtem + ", water_level_low=" + water_level_low + ", water_pressure_high="
|
| | | + water_pressure_high + ", local_control=" + local_control + ", back_control=" + back_control
|
| | | + ", central_control=" + central_control + ", switch_state=" + switch_state + ", inter_volume_M200="
|
| | | + inter_volume_M200 + ", fan_button=" + fan_button + ", fan_output=" + fan_output + ", note=" + note
|
| | | + "]";
|
| | | } |
| | | }
|
| | | package com.dev.base.data; |
| | | |
| | | 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 Dynamicload_state { |
| | | |
| | | public int dev_id; |
| | | public Date record_time; //记录时间 |
| | | public int start_auto; //启动自动加载 |
| | | public int stop_auto; //停止自动加载 |
| | | public int sudden_crease; //突加突卸 |
| | | public int all_open; //全部分闸 |
| | | public float actual_set_power; //实际设定功率 |
| | | public float output_power; //已输出功率 |
| | | public float set_power; //设定功率 |
| | | public float interval_time; //间隔时间s |
| | | public float actual_curr; //实际电流 |
| | | public float actual_mov; //实际电压 |
| | | public int switch_on; //是否合闸 |
| | | public int FZ_autostate1; //FZ自动状态1 |
| | | public int FZ_autostate2; //FZ自动状态2 |
| | | public int FZ_autostate3; //FZ自动状态3 |
| | | public int FZ_autostate4; //FZ自动状态4 |
| | | public int FZ_autostate5; //FZ自动状态5 |
| | | public int react_overtem; //电抗超温 |
| | | public int water_overtem; //冷却水超温 |
| | | public int water_level_low; //冷却水液位低 |
| | | public int water_pressure_high; //冷却水压高 |
| | | public int local_control; //就地控制 |
| | | public int back_control; //后台控制 |
| | | public int central_control; //中控控制 |
| | | public int switch_state; //开关柜状态 |
| | | public int inter_volume_M200; //中间量M200 |
| | | public int fan_button; //风机按钮 |
| | | public int fan_output; //风机输出 |
| | | public int allow_close; //是否允许合闸 |
| | | public String note; |
| | | |
| | | public int fz_button_num;//负载按钮个数 |
| | | public Dynamicload_state(int dev_id,int fz_button_num) { |
| | | this.dev_id = dev_id; |
| | | this.fz_button_num=fz_button_num; |
| | | } |
| | | |
| | | public int getDev_id() { |
| | | return dev_id; |
| | | } |
| | | public Date getRecord_time() { |
| | | return record_time; |
| | | } |
| | | public int getStart_auto() { |
| | | return start_auto; |
| | | } |
| | | public int getStop_auto() { |
| | | return stop_auto; |
| | | } |
| | | public int getSudden_crease() { |
| | | return sudden_crease; |
| | | } |
| | | public int getAll_open() { |
| | | return all_open; |
| | | } |
| | | public float getActual_set_power() { |
| | | return actual_set_power; |
| | | } |
| | | public float getOutput_power() { |
| | | return output_power; |
| | | } |
| | | public float getSet_power() { |
| | | return set_power; |
| | | } |
| | | public float getInterval_time() { |
| | | return interval_time; |
| | | } |
| | | public float getActual_curr() { |
| | | return actual_curr; |
| | | } |
| | | public float getActual_mov() { |
| | | return actual_mov; |
| | | } |
| | | public int getSwitch_on() { |
| | | return switch_on; |
| | | } |
| | | public int getFZ_autostate1() { |
| | | return FZ_autostate1; |
| | | } |
| | | public int getFZ_autostate2() { |
| | | return FZ_autostate2; |
| | | } |
| | | public int getFZ_autostate3() { |
| | | return FZ_autostate3; |
| | | } |
| | | public int getFZ_autostate4() { |
| | | return FZ_autostate4; |
| | | } |
| | | public int getFZ_autostate5() { |
| | | return FZ_autostate5; |
| | | } |
| | | public int getReact_overtem() { |
| | | return react_overtem; |
| | | } |
| | | public int getWater_overtem() { |
| | | return water_overtem; |
| | | } |
| | | public int getWater_level_low() { |
| | | return water_level_low; |
| | | } |
| | | public int getWater_pressure_high() { |
| | | return water_pressure_high; |
| | | } |
| | | public int getLocal_control() { |
| | | return local_control; |
| | | } |
| | | public int getBack_control() { |
| | | return back_control; |
| | | } |
| | | public int getCentral_control() { |
| | | return central_control; |
| | | } |
| | | public int getSwitch_state() { |
| | | return switch_state; |
| | | } |
| | | public int getInter_volume_M200() { |
| | | return inter_volume_M200; |
| | | } |
| | | public int getFan_button() { |
| | | return fan_button; |
| | | } |
| | | public int getFan_output() { |
| | | return fan_output; |
| | | } |
| | | public String getNote() { |
| | | return note; |
| | | } |
| | | public void setDev_id(int dev_id) { |
| | | this.dev_id = dev_id; |
| | | } |
| | | public void setRecord_time(Date record_time) { |
| | | this.record_time = record_time; |
| | | } |
| | | public void setStart_auto(int start_auto) { |
| | | this.start_auto = start_auto; |
| | | } |
| | | public void setStop_auto(int stop_auto) { |
| | | this.stop_auto = stop_auto; |
| | | } |
| | | public void setSudden_crease(int sudden_crease) { |
| | | this.sudden_crease = sudden_crease; |
| | | } |
| | | public void setAll_open(int all_open) { |
| | | this.all_open = all_open; |
| | | } |
| | | public void setActual_set_power(float actual_set_power) { |
| | | this.actual_set_power = actual_set_power; |
| | | } |
| | | public void setOutput_power(float output_power) { |
| | | this.output_power = output_power; |
| | | } |
| | | public void setSet_power(float set_power) { |
| | | this.set_power = set_power; |
| | | } |
| | | public void setInterval_time(float interval_time) { |
| | | this.interval_time = interval_time; |
| | | } |
| | | public void setActual_curr(float actual_curr) { |
| | | this.actual_curr = actual_curr; |
| | | } |
| | | public void setActual_mov(float actual_mov) { |
| | | this.actual_mov = actual_mov; |
| | | } |
| | | public void setSwitch_on(int switch_on) { |
| | | this.switch_on = switch_on; |
| | | } |
| | | public void setFZ_autostate1(int fZ_autostate1) { |
| | | FZ_autostate1 = fZ_autostate1; |
| | | } |
| | | public void setFZ_autostate2(int fZ_autostate2) { |
| | | FZ_autostate2 = fZ_autostate2; |
| | | } |
| | | public void setFZ_autostate3(int fZ_autostate3) { |
| | | FZ_autostate3 = fZ_autostate3; |
| | | } |
| | | public void setFZ_autostate4(int fZ_autostate4) { |
| | | FZ_autostate4 = fZ_autostate4; |
| | | } |
| | | public void setFZ_autostate5(int fZ_autostate5) { |
| | | FZ_autostate5 = fZ_autostate5; |
| | | } |
| | | public void setReact_overtem(int react_overtem) { |
| | | this.react_overtem = react_overtem; |
| | | } |
| | | public void setWater_overtem(int water_overtem) { |
| | | this.water_overtem = water_overtem; |
| | | } |
| | | public void setWater_level_low(int water_level_low) { |
| | | this.water_level_low = water_level_low; |
| | | } |
| | | public void setWater_pressure_high(int water_pressure_high) { |
| | | this.water_pressure_high = water_pressure_high; |
| | | } |
| | | public void setLocal_control(int local_control) { |
| | | this.local_control = local_control; |
| | | } |
| | | public void setBack_control(int back_control) { |
| | | this.back_control = back_control; |
| | | } |
| | | public void setCentral_control(int central_control) { |
| | | this.central_control = central_control; |
| | | } |
| | | public void setSwitch_state(int switch_state) { |
| | | this.switch_state = switch_state; |
| | | } |
| | | public void setInter_volume_M200(int inter_volume_M200) { |
| | | this.inter_volume_M200 = inter_volume_M200; |
| | | } |
| | | public void setFan_button(int fan_button) { |
| | | this.fan_button = fan_button; |
| | | } |
| | | public void setFan_output(int fan_output) { |
| | | this.fan_output = fan_output; |
| | | } |
| | | public void setNote(String note) { |
| | | this.note = note; |
| | | } |
| | | @Override |
| | | public String toString() { |
| | | return "Dynamic_State [dev_id=" + dev_id + ", record_time=" + record_time + ", start_auto=" + start_auto |
| | | + ", stop_auto=" + stop_auto + ", sudden_crease=" + sudden_crease + ", all_open=" + all_open |
| | | + ", actual_set_power=" + actual_set_power + ", output_power=" + output_power + ", set_power=" |
| | | + set_power + ", interval_time=" + interval_time + ", actual_curr=" + actual_curr + ", actual_mov=" |
| | | + actual_mov + ", switch_on=" + switch_on + ", FZ_autostate1=" + FZ_autostate1 + ", FZ_autostate2=" |
| | | + FZ_autostate2 + ", FZ_autostate3=" + FZ_autostate3 + ", FZ_autostate4=" + FZ_autostate4 |
| | | + ", FZ_autostate5=" + FZ_autostate5 + ", react_overtem=" + react_overtem + ", water_overtem=" |
| | | + water_overtem + ", water_level_low=" + water_level_low + ", water_pressure_high=" |
| | | + water_pressure_high + ", local_control=" + local_control + ", back_control=" + back_control |
| | | + ", central_control=" + central_control + ", switch_state=" + switch_state + ", inter_volume_M200=" |
| | | + inter_volume_M200 + ", fan_button=" + fan_button + ", fan_output=" + fan_output + ", note=" + note |
| | | + "]"; |
| | | } |
| | | |
| | | /** |
| | | * 创建读取数据集合 |
| | | * @param master |
| | | * @return |
| | | */ |
| | | public BatchRead<Integer> createBatchRead(MyModbusMaster master,int fz_button_num){ |
| | | BatchRead<Integer> batch = new BatchRead<Integer>(); |
| | | batch.addLocator(0,MyModbusUtils.createBaseLocator(8,master));//启动自动加载 |
| | | batch.addLocator(1,MyModbusUtils.createBaseLocator(9 ,master)); |
| | | batch.addLocator(2,MyModbusUtils.createBaseLocator(10 , master)); |
| | | batch.addLocator(3,MyModbusUtils.createBaseLocator(11, master));//全部分闸 |
| | | if(fz_button_num==11){ |
| | | batch.addLocator(4,MyModbusUtils.createBaseLocator(1,DataType.TWO_BYTE_INT_SIGNED, master));//实际设定功率4 |
| | | batch.addLocator(5,MyModbusUtils.createBaseLocator(2,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(6,MyModbusUtils.createBaseLocator(4,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(7,MyModbusUtils.createBaseLocator(6,DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(8,MyModbusUtils.createBaseLocator(7,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(9,MyModbusUtils.createBaseLocator(8,DataType.TWO_BYTE_INT_SIGNED, master));//实际电压4 |
| | | |
| | | }else { |
| | | batch.addLocator(4,MyModbusUtils.createBaseLocator(2,DataType.TWO_BYTE_INT_SIGNED, master));//实际设定功率4 |
| | | batch.addLocator(5,MyModbusUtils.createBaseLocator(4,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(6,MyModbusUtils.createBaseLocator(8,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(7,MyModbusUtils.createBaseLocator(16,DataType.TWO_BYTE_INT_SIGNED,master)); |
| | | batch.addLocator(8,MyModbusUtils.createBaseLocator(17,DataType.TWO_BYTE_INT_SIGNED, master)); |
| | | batch.addLocator(9,MyModbusUtils.createBaseLocator(18,DataType.TWO_BYTE_INT_SIGNED, master));//实际电压4 |
| | | } |
| | | |
| | | batch.addLocator(10,MyModbusUtils.createBaseLocator(8011, master));//是否合闸 |
| | | |
| | | batch.addLocator(11,MyModbusUtils.createBaseLocator(1,master));//自动状态1 |
| | | batch.addLocator(12,MyModbusUtils.createBaseLocator(2,master)); |
| | | batch.addLocator(13,MyModbusUtils.createBaseLocator(3, master)); |
| | | batch.addLocator(14,MyModbusUtils.createBaseLocator(4, master)); |
| | | batch.addLocator(15,MyModbusUtils.createBaseLocator(5, master));//自动状态5 |
| | | |
| | | batch.addLocator(16,MyModbusUtils.createBaseLocator(4013, master));//电抗超温 |
| | | batch.addLocator(17,MyModbusUtils.createBaseLocator(4014, master)); |
| | | batch.addLocator(18,MyModbusUtils.createBaseLocator(4015, master)); |
| | | batch.addLocator(19,MyModbusUtils.createBaseLocator(4016, master)); |
| | | batch.addLocator(20,MyModbusUtils.createBaseLocator(40, master)); |
| | | batch.addLocator(21,MyModbusUtils.createBaseLocator(41, master)); |
| | | batch.addLocator(22,MyModbusUtils.createBaseLocator(42,master)); |
| | | batch.addLocator(23,MyModbusUtils.createBaseLocator(4018 ,master)); |
| | | batch.addLocator(24,MyModbusUtils.createBaseLocator(160 ,master)); |
| | | batch.addLocator(25,MyModbusUtils.createBaseLocator(12, master)); |
| | | batch.addLocator(26,MyModbusUtils.createBaseLocator(8013, master));//风机输出 |
| | | |
| | | |
| | | return batch; |
| | | } |
| | | /** |
| | | * 解析返回请求 |
| | | * @param res |
| | | */ |
| | | public void putBatchResult(BatchResults<Integer> res) { |
| | | if(res != null) { |
| | | this.start_auto = MyModbusUtils.readBooleanToInt(res.getValue(0)); |
| | | this.stop_auto = MyModbusUtils.readBooleanToInt(res.getValue(1)); |
| | | this.sudden_crease = MyModbusUtils.readBooleanToInt(res.getValue(2)); |
| | | this.all_open = MyModbusUtils.readBooleanToInt(res.getValue(3)); |
| | | |
| | | this.actual_set_power = MyModbusUtils.readShortToFloat(res.getValue(4)); |
| | | this.output_power = MyModbusUtils.readShortToFloat(res.getValue(5)); |
| | | this.set_power = MyModbusUtils.readShortToFloat(res.getValue(6)); |
| | | this.interval_time = MyModbusUtils.readShortToFloat(res.getValue(7)); |
| | | this.actual_curr = MyModbusUtils.readShortToFloat(res.getValue(8)); |
| | | this.actual_mov= MyModbusUtils.readShortToFloat(res.getValue(9)); |
| | | |
| | | this.allow_close= MyModbusUtils.readBooleanToInt(res.getValue(10)); |
| | | |
| | | this.FZ_autostate1 = MyModbusUtils.readBooleanToInt(res.getValue(11)); |
| | | this.FZ_autostate2 = MyModbusUtils.readBooleanToInt(res.getValue(12)); |
| | | this.FZ_autostate3 = MyModbusUtils.readBooleanToInt(res.getValue(13)); |
| | | this.FZ_autostate4 = MyModbusUtils.readBooleanToInt(res.getValue(14)); |
| | | this.FZ_autostate5 = MyModbusUtils.readBooleanToInt(res.getValue(15)); |
| | | |
| | | this.react_overtem = MyModbusUtils.readBooleanToInt(res.getValue(16)); |
| | | this.water_overtem = MyModbusUtils.readBooleanToInt(res.getValue(17)); |
| | | this.water_level_low = MyModbusUtils.readBooleanToInt(res.getValue(18)); |
| | | this.water_pressure_high = MyModbusUtils.readBooleanToInt(res.getValue(19)); |
| | | this.local_control= MyModbusUtils.readBooleanToInt(res.getValue(20)); |
| | | this.back_control= MyModbusUtils.readBooleanToInt(res.getValue(21)); |
| | | this.central_control = MyModbusUtils.readBooleanToInt(res.getValue(22)); |
| | | this.switch_state = MyModbusUtils.readBooleanToInt(res.getValue(23)); |
| | | this.inter_volume_M200 = MyModbusUtils.readBooleanToInt(res.getValue(24)); |
| | | this.fan_button = MyModbusUtils.readBooleanToInt(res.getValue(25)); |
| | | this.fan_output = MyModbusUtils.readBooleanToInt(res.getValue(26)); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.modbus.data; |
| | | |
| | | import com.serotonin.modbus4j.ModbusFactory; |
| | | import com.serotonin.modbus4j.ModbusMaster; |
| | | import com.serotonin.modbus4j.exception.ModbusInitException; |
| | | import com.serotonin.modbus4j.ip.IpParameters; |
| | | |
| | | public class MyModbusFactory { |
| | | private static final int SERVER_PORT = 502; //服务端口 |
| | | |
| | | static ModbusFactory modbusFactory; |
| | | |
| | | static { |
| | | if (modbusFactory == null) { |
| | | modbusFactory = new ModbusFactory(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取master |
| | | * |
| | | * @return |
| | | * @throws ModbusInitException |
| | | */ |
| | | public static ModbusMaster getMaster(IpParameters params){ |
| | | // modbusFactory.createRtuMaster(wapper); //RTU 协议 |
| | | // modbusFactory.createUdpMaster(params); //UDP 协议 |
| | | // modbusFactory.createAsciiMaster(wrapper); //ASCII 协议 |
| | | params.setPort(SERVER_PORT); |
| | | //false:短连接 true:长连接 |
| | | ModbusMaster master = modbusFactory.createTcpMaster(params, true);// TCP 协议 |
| | | try { |
| | | //设置超时时间 |
| | | master.setTimeout(100); |
| | | //设置重连次数 |
| | | master.setRetries(3); |
| | | //初始化 |
| | | master.init(); |
| | | } catch (ModbusInitException e) { |
| | | //e.printStackTrace(); |
| | | } |
| | | return master; |
| | | } |
| | | } |
New file |
| | |
| | | package com.modbus.data; |
| | | |
| | | import java.text.NumberFormat; |
| | | |
| | | import com.base.ComBase; |
| | | import com.serotonin.modbus4j.ModbusMaster; |
| | | import com.serotonin.modbus4j.ip.IpParameters; |
| | | |
| | | public class MyModbusMaster { |
| | | public final static int SLAVEID_DEFAULT = 2; |
| | | |
| | | public final static int MAX_ERROR_COUNT = 2; //最大连续错误计数 |
| | | private ModbusMaster master; |
| | | private int errcount; //错误计数 错误连续超过三个时重新获取master |
| | | private int totalerr; //总的错误计数 //用于判别设备是否掉线 |
| | | private String target_ip; //目标ip |
| | | private int slaveId; //设备ID |
| | | |
| | | public MyModbusMaster(String target_ip,int slaveId) { |
| | | this.target_ip = target_ip; |
| | | this.slaveId = slaveId; |
| | | IpParameters params = new IpParameters(); |
| | | params.setHost(target_ip); |
| | | this.master = MyModbusFactory.getMaster(params); |
| | | } |
| | | |
| | | public void addErrorCount() { |
| | | this.errcount++; |
| | | if(this.errcount > MAX_ERROR_COUNT) { |
| | | reConnect(); |
| | | } |
| | | if(this.totalerr > 99999999) { |
| | | this.totalerr = 5; |
| | | } |
| | | this.totalerr ++; |
| | | } |
| | | |
| | | //清空错误计数 |
| | | public void clearError() { |
| | | errcount = 0; |
| | | totalerr = 0; |
| | | } |
| | | |
| | | public void reConnect() { |
| | | IpParameters params = new IpParameters(); |
| | | params.setHost(target_ip); |
| | | if(this.master != null) { |
| | | //清空上一个master |
| | | this.master.destroy(); |
| | | } |
| | | this.errcount = 0; |
| | | this.master = MyModbusFactory.getMaster(params); |
| | | } |
| | | |
| | | /** |
| | | * 判断获取到的值是否为空 |
| | | * @param target |
| | | * @param source |
| | | * @return |
| | | */ |
| | | public static Object checkNullData(Object target,Object source) { |
| | | if(null == target) { |
| | | return source; |
| | | } |
| | | try { |
| | | if(target instanceof Number) { |
| | | if(source instanceof Integer) { |
| | | return ((Number) target).intValue(); |
| | | }else if(source instanceof Float) { |
| | | return ((Number) target).floatValue(); |
| | | } |
| | | } |
| | | if(target instanceof Boolean) { |
| | | //判断Boolean类型数据 |
| | | if((Boolean)target) { |
| | | target = 1; |
| | | }else { |
| | | target = 0; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return target; |
| | | |
| | | } |
| | | |
| | | public int getTotalerr() { |
| | | return totalerr; |
| | | } |
| | | |
| | | public void setTotalerr(int totalerr) { |
| | | this.totalerr = totalerr; |
| | | } |
| | | |
| | | public ModbusMaster getMaster() { |
| | | return master; |
| | | } |
| | | public int getErrcount() { |
| | | return errcount; |
| | | } |
| | | public void setMaster(ModbusMaster master) { |
| | | this.master = master; |
| | | } |
| | | public void setErrcount(int errcount) { |
| | | this.errcount = errcount; |
| | | } |
| | | |
| | | public String getTarget_ip() { |
| | | return target_ip; |
| | | } |
| | | |
| | | public void setTarget_ip(String target_ip) { |
| | | this.target_ip = target_ip; |
| | | } |
| | | |
| | | public int getSlaveId() { |
| | | return slaveId; |
| | | } |
| | | |
| | | public void setSlaveId(int slaveId) { |
| | | this.slaveId = slaveId; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "MyModbusMaster [SLAVEID_DEFAULT=" + SLAVEID_DEFAULT + ", master=" + master + ", errcount=" + errcount |
| | | + ", target_ip=" + target_ip + ", slaveId=" + slaveId + "]"; |
| | | } |
| | | } |
New file |
| | |
| | | package com.modbus.data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | import com.base.ComBase; |
| | | import com.serotonin.modbus4j.BatchRead; |
| | | import com.serotonin.modbus4j.BatchResults; |
| | | import com.serotonin.modbus4j.ModbusMaster; |
| | | import com.serotonin.modbus4j.code.DataType; |
| | | import com.serotonin.modbus4j.exception.ErrorResponseException; |
| | | import com.serotonin.modbus4j.exception.ModbusTransportException; |
| | | import com.serotonin.modbus4j.locator.BaseLocator; |
| | | import com.serotonin.modbus4j.msg.ModbusResponse; |
| | | import com.serotonin.modbus4j.msg.WriteCoilRequest; |
| | | import com.serotonin.modbus4j.msg.WriteCoilResponse; |
| | | import com.serotonin.modbus4j.msg.WriteCoilsRequest; |
| | | import com.serotonin.modbus4j.msg.WriteCoilsResponse; |
| | | import com.serotonin.modbus4j.msg.WriteRegisterRequest; |
| | | import com.serotonin.modbus4j.msg.WriteRegisterResponse; |
| | | import com.serotonin.modbus4j.msg.WriteRegistersRequest; |
| | | |
| | | public class MyModbusUtils { |
| | | |
| | | /** |
| | | * 读取[01 Coil Status 0x]类型 开关数据 |
| | | * |
| | | * @param slaveId |
| | | * slaveId |
| | | * @param offset |
| | | * 位置 |
| | | * @return 读取值 |
| | | */ |
| | | public static Boolean readCoilStatus(int offset,MyModbusMaster master){ |
| | | // 01 Coil Status |
| | | BaseLocator<Boolean> loc = BaseLocator.coilStatus(master.getSlaveId(), offset); |
| | | Boolean value = null; |
| | | boolean isSuccess = true; |
| | | try { |
| | | value = master.getMaster().getValue(loc); |
| | | } catch (ModbusTransportException | ErrorResponseException e) { |
| | | //e.printStackTrace(); |
| | | isSuccess = false; |
| | | } finally { |
| | | if(isSuccess) { |
| | | master.clearError(); |
| | | }else { |
| | | master.addErrorCount(); |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * 读取[02 Input Status 1x]类型 开关数据 |
| | | * |
| | | * @param slaveId |
| | | * @param offset |
| | | * @return |
| | | */ |
| | | public static Boolean readInputStatus(int offset,MyModbusMaster master){ |
| | | // 02 Input Status |
| | | BaseLocator<Boolean> loc = BaseLocator.inputStatus(master.getSlaveId(), offset); |
| | | Boolean value = null;; |
| | | boolean isSuccess = true; |
| | | try { |
| | | value = master.getMaster().getValue(loc); |
| | | } catch (ModbusTransportException | ErrorResponseException e) { |
| | | //e.printStackTrace(); |
| | | isSuccess = false; |
| | | } finally { |
| | | if(isSuccess) { |
| | | master.clearError(); |
| | | }else { |
| | | master.addErrorCount(); |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * 读取[03 Holding Register类型 2x]模拟量数据 |
| | | * |
| | | * @param slaveId |
| | | * slave Id |
| | | * @param offset |
| | | * 位置 |
| | | * @param dataType |
| | | * 数据类型,来自com.serotonin.modbus4j.code.DataType |
| | | * @return |
| | | */ |
| | | public static Number readHoldingRegister(int offset, int dataType,MyModbusMaster master){ |
| | | // 03 Holding Register类型数据读取 |
| | | BaseLocator<Number> loc = BaseLocator.holdingRegister(master.getSlaveId(), offset, dataType); |
| | | Number value = null; |
| | | boolean isSuccess = true; |
| | | try { |
| | | value = master.getMaster().getValue(loc); |
| | | } catch (ModbusTransportException | ErrorResponseException e) { |
| | | //e.printStackTrace(); |
| | | isSuccess = false; |
| | | } finally { |
| | | if(isSuccess) { |
| | | master.clearError(); |
| | | }else { |
| | | master.addErrorCount(); |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * 读取[04 Input Registers 3x]类型 模拟量数据 |
| | | * |
| | | * @param slaveId |
| | | * slaveId |
| | | * @param offset |
| | | * 位置 |
| | | * @param dataType |
| | | * 数据类型,来自com.serotonin.modbus4j.code.DataType |
| | | * @return 返回结果 |
| | | * @throws ModbusTransportException |
| | | * 异常 |
| | | * @throws ErrorResponseException |
| | | * 异常 |
| | | * @throws ModbusInitException |
| | | * 异常 |
| | | */ |
| | | public static Number readInputRegisters(int offset, int dataType,MyModbusMaster master){ |
| | | // 04 Input Registers类型数据读取 |
| | | BaseLocator<Number> loc = BaseLocator.inputRegister(master.getSlaveId(), offset, dataType); |
| | | Number value = null; |
| | | boolean isSuccess = true; |
| | | try { |
| | | value = master.getMaster().getValue(loc); |
| | | } catch (ModbusTransportException | ErrorResponseException e) { |
| | | //e.printStackTrace(); |
| | | isSuccess = false; |
| | | } finally { |
| | | if(isSuccess) { |
| | | master.clearError(); |
| | | }else { |
| | | master.addErrorCount(); |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | public static BatchResults<Integer> readMutilRegisters(BatchRead<Integer> batch,MyModbusMaster master){ |
| | | batch.setContiguousRequests(false); |
| | | try { |
| | | return master.getMaster().send(batch); |
| | | } catch (ModbusTransportException | ErrorResponseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 批量读取使用方法 |
| | | * |
| | | * @throws ModbusTransportException |
| | | * @throws ErrorResponseException |
| | | * @throws ModbusInitException |
| | | */ |
| | | public static void batchRead() { |
| | | // BatchRead<Integer> batch = new BatchRead<Integer>(); |
| | | // |
| | | // batch.addLocator(0, BaseLocator.holdingRegister(1, 1, DataType.FOUR_BYTE_FLOAT)); |
| | | // batch.addLocator(1, BaseLocator.inputStatus(1, 0)); |
| | | // |
| | | // ModbusMaster master = getMaster(); |
| | | // |
| | | // batch.setContiguousRequests(false); |
| | | // BatchResults<Integer> results = master.send(batch); |
| | | // System.out.println(results.getValue(0)); |
| | | // System.out.println(results.getValue(1)); |
| | | } |
| | | |
| | | /** |
| | | * 构造线圈读取节点 |
| | | * @param offset |
| | | * @param master |
| | | * @return |
| | | */ |
| | | public static BaseLocator<?> createBaseLocator(int offset,MyModbusMaster master) { |
| | | return BaseLocator.coilStatus(master.getSlaveId(), offset); |
| | | } |
| | | |
| | | /** |
| | | * 构造读取节点 |
| | | * @param offset |
| | | * @param master |
| | | * @return |
| | | */ |
| | | public static BaseLocator<?> createBaseLocator(int offset,int datatype,MyModbusMaster master) { |
| | | return BaseLocator.holdingRegister(master.getSlaveId(), offset, datatype); |
| | | } |
| | | |
| | | /** |
| | | * 写 [01 Coil Status(0x)]写一个 function ID = 5 |
| | | * |
| | | * @param slaveId |
| | | * slave的ID |
| | | * @param writeOffset |
| | | * 位置 |
| | | * @param writeValue |
| | | * ֵ |
| | | * @return 是否写入成功 |
| | | */ |
| | | public static boolean writeCoil(int writeOffset, boolean writeValue,MyModbusMaster master){ |
| | | // 获取master |
| | | ModbusMaster tcpMaster = master.getMaster(); |
| | | // 创建请求 |
| | | // 发送请求并获取响应对象 |
| | | WriteCoilResponse response = null; |
| | | try { |
| | | WriteCoilRequest request = new WriteCoilRequest(master.getSlaveId(), writeOffset, writeValue); |
| | | response = (WriteCoilResponse) tcpMaster.send(request); |
| | | } catch (ModbusTransportException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (response == null || response.isException()) { |
| | | master.addErrorCount(); |
| | | return false; |
| | | } else { |
| | | master.clearError(); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 写[01 Coil Status(0x)] 写多个 function ID = 15 |
| | | * |
| | | * @param slaveId |
| | | * slaveId |
| | | * @param startOffset |
| | | * 开始位置 |
| | | * @param bdata |
| | | * 写入的数据 |
| | | * @return 是否写入成功 |
| | | */ |
| | | public static boolean writeCoils(int startOffset, boolean[] bdata,MyModbusMaster master) { |
| | | // 获取master |
| | | ModbusMaster tcpMaster = master.getMaster(); |
| | | // 创建请求 |
| | | WriteCoilsRequest request; |
| | | WriteCoilsResponse response = null; |
| | | try { |
| | | request = new WriteCoilsRequest(master.getSlaveId(), startOffset, bdata); |
| | | response = (WriteCoilsResponse) tcpMaster.send(request); |
| | | } catch (ModbusTransportException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // 发送请求并获取响应对象 |
| | | if (response == null || response.isException()) { |
| | | master.addErrorCount(); |
| | | return false; |
| | | } else { |
| | | master.clearError(); |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | /*** |
| | | * 写[03 Holding Register(4x)] 写一个 function ID = 6 |
| | | * |
| | | * @param slaveId |
| | | * @param writeOffset |
| | | * @param writeValue |
| | | * @return |
| | | */ |
| | | public static boolean writeRegister(int writeOffset, short writeValue,MyModbusMaster master){ |
| | | // 获取master |
| | | ModbusMaster tcpMaster = master.getMaster(); |
| | | // 创建请求对象 |
| | | WriteRegisterRequest request; |
| | | WriteRegisterResponse response = null; |
| | | try { |
| | | request = new WriteRegisterRequest(master.getSlaveId(), writeOffset, writeValue); |
| | | response = (WriteRegisterResponse) tcpMaster.send(request); |
| | | } catch (ModbusTransportException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (response == null || response.isException()) { |
| | | master.addErrorCount(); |
| | | return false; |
| | | } else { |
| | | master.clearError(); |
| | | return true; |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * 写入[03 Holding Register(4x)]写多个 function ID=16 |
| | | * |
| | | * @param slaveId |
| | | * modbus的slaveID |
| | | * @param startOffset |
| | | * 起始位置偏移量值 |
| | | * @param sdata |
| | | * 写入的数据 |
| | | * @return 返回是否写入成功 |
| | | */ |
| | | public static boolean writeRegisters(int startOffset, short[] sdata,MyModbusMaster master){ |
| | | // 获取master |
| | | ModbusMaster tcpMaster = master.getMaster(); |
| | | // 创建请求对象 |
| | | WriteRegistersRequest request; |
| | | // 发送请求并获取响应对象 |
| | | ModbusResponse response = null; |
| | | try { |
| | | request = new WriteRegistersRequest(master.getSlaveId(), startOffset, sdata); |
| | | response = tcpMaster.send(request); |
| | | } catch (ModbusTransportException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (response.isException()) { |
| | | //log.error(response.getExceptionMessage()); |
| | | master.addErrorCount(); |
| | | return false; |
| | | } else { |
| | | master.clearError(); |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 写入数字类型的模拟量(如:写入Float类型的模拟量、Double类型模拟量、整数类型Short、Integer、Long) |
| | | * |
| | | * @param slaveId |
| | | * @param offset |
| | | * @param value |
| | | * 写入值,Number的子类,例如写入Float浮点类型,Double双精度类型,以及整型short,int,long |
| | | * @param registerCount |
| | | * ,com.serotonin.modbus4j.code.DataType |
| | | */ |
| | | public static void writeHoldingRegister(int offset, Number value, int dataType,MyModbusMaster master){ |
| | | // 获取master |
| | | ModbusMaster tcpMaster = master.getMaster(); |
| | | // 类型 |
| | | BaseLocator<Number> locator = BaseLocator.holdingRegister(master.getSlaveId(), offset, dataType); |
| | | boolean isSuccess = true; |
| | | try { |
| | | tcpMaster.setValue(locator, value); |
| | | } catch (ModbusTransportException | ErrorResponseException e) { |
| | | //e.printStackTrace(); |
| | | isSuccess = true; |
| | | } finally { |
| | | if(isSuccess) { |
| | | master.clearError(); |
| | | }else { |
| | | master.addErrorCount(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | BatchRead<Integer> batch = new BatchRead<Integer>(); |
| | | |
| | | batch.addLocator(0, BaseLocator.holdingRegister(1, 1, DataType.TWO_BYTE_INT_SIGNED)); |
| | | batch.addLocator(1, BaseLocator.coilStatus(1, 1)); |
| | | batch.setContiguousRequests(true); |
| | | |
| | | MyModbusMaster m = new MyModbusMaster("192.168.10.221", 2); |
| | | |
| | | ModbusMaster master = m.getMaster(); |
| | | |
| | | BatchResults<Integer> results = new BatchResults<>(); |
| | | try { |
| | | results = master.send(batch); |
| | | } catch (ModbusTransportException | ErrorResponseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println(results.getValue(0)); |
| | | //System.out.println(results.getValue(1)); |
| | | } |
| | | |
| | | /** |
| | | * 读取float类型数据 |
| | | * @param obj Short类型 |
| | | * @return |
| | | */ |
| | | public static float readShortToFloat(Object obj) { |
| | | return (float)ComBase.changeShortToInt((Short)obj); |
| | | } |
| | | |
| | | /** |
| | | * 读取int类型数据 |
| | | * @param obj Short类型 |
| | | * @return |
| | | */ |
| | | public static int readShortToInt(Object obj) { |
| | | return ComBase.changeShortToInt((Short)obj); |
| | | } |
| | | |
| | | /** |
| | | * 读取Boolean类型数据 |
| | | * @param obj Boolean类型 |
| | | * @return |
| | | */ |
| | | public static int readBooleanToInt(Object obj) { |
| | | return ((Boolean)obj?1:0); |
| | | } |
| | | } |
| | |
| | | package main;
|
| | | import java.sql.Connection;
|
| | | import java.sql.SQLException;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.base.Com;
|
| | | import com.config.AppConfig;
|
| | | import com.config.AppParam;
|
| | | import com.data.PowerArk_ServerSocket_Thread;
|
| | | import com.data.PowerArk_ServerSocket_Thread_SQL;
|
| | | import com.data.PowerArk_SocketCliet_Thread;
|
| | | import com.data.PowerArk_Task_SQL;
|
| | | import com.dev.base.data.Dynamicload_inf;
|
| | | import com.sql.MysqlConnPool;
|
| | |
|
| | | public class main_MonitorServer_Dynamicload {
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | public final static boolean app_debug = false;
|
| | | public final static double m_VersionNum = 1.101;
|
| | | public final static String m_Version = "Welcome To Use main_MonitorServer_Dynamicload V" |
| | | + m_VersionNum ;
|
| | | /**************************************************************************/
|
| | | |
| | | |
| | | /**************************************************************************/
|
| | | public static final int MysqlServer_Port = 3360;
|
| | | |
| | | private static AppConfig m_AppConfig;
|
| | | |
| | | private static MysqlConnPool GB_MysqlConnPool;
|
| | | public static AppParam GB_App_Param;
|
| | | |
| | | public static List<Dynamicload_inf> GB_DevData;
|
| | | |
| | | /*********************************************************************************************/
|
| | | /*********************************************************************************************/
|
| | | public static void main(String[] args) {
|
| | | String ver = m_Version;
|
| | | |
| | | System.out.println("MonitorServer_Dynamicload Server Started At DateTime: " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
| | | //创建config.xml文件
|
| | | m_AppConfig = new AppConfig();
|
| | | |
| | | System.out.println("SQLserver IP:" + m_AppConfig.getMysqlServerIp() + ", port: "+MysqlServer_Port);
|
| | | //初始化连接池中的各种参数信息
|
| | | GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, |
| | | 100);
|
| | | |
| | | /*
|
| | | //在连接池中获取连接
|
| | | Sql_Mysql sql_ck = new Sql_Mysql(GB_MysqlConnPool.getConn());
|
| | | try {
|
| | | //创建大多数据库以及数据库中的表格,并给某些表格设值
|
| | | sql_ck.checkAndCreateDB();
|
| | | } catch (SQLException e1) {
|
| | | e1.printStackTrace();
|
| | | } f999+inally {
|
| | | sql_ck.close_con();
|
| | | }
|
| | | */
|
| | | |
| | | //创建tb_app_param表,并且设置表中的数据
|
| | | GB_App_Param = new AppParam(GB_MysqlConnPool);
|
| | | |
| | | checkingMySQLServerStart(); //检测数据库服务是否启动
|
| | | /*********************************************************************************/
|
| | | /*********************************************************************************/
|
| | | GB_DevData = PowerArk_Task_SQL.queryAllPowerArk(GB_MysqlConnPool);
|
| | | |
| | | PowerArk_ServerSocket_Thread power_thread = new PowerArk_ServerSocket_Thread(GB_MysqlConnPool,GB_DevData);
|
| | | new Thread(power_thread).start();
|
| | | |
| | | /*********************************************************************************/
|
| | | }
|
| | | |
| | | public static void checkingMySQLServerStart(){
|
| | | int MysqlServer_Port = 3360;
|
| | | System.out.println("IP:"+m_AppConfig.getMysqlServerIp()+"port"+MysqlServer_Port); |
| | | //初始化连接池中的各种参数信息 m_AppConfig.getMysqlServerIp()
|
| | | GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, 5);
|
| | | while(true){
|
| | | Connection conn = null;
|
| | | try {
|
| | | System.out.println(" 开始检测数据库连接 "+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
| | | conn = GB_MysqlConnPool.getConn();
|
| | | if(conn != null){
|
| | | System.out.println("检测数据库连接成功");
|
| | | break;
|
| | | }
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | | } catch (InterruptedException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | System.out.println(" MySQL_FBSDEV not Start ... ");
|
| | | } finally {
|
| | | if(conn != null) {
|
| | | try {
|
| | | conn.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | package main; |
| | | import java.sql.Connection; |
| | | import java.sql.SQLException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.base.Com; |
| | | import com.config.AppConfig; |
| | | import com.config.AppParam; |
| | | import com.data.PowerArk_ServerSocket_Thread; |
| | | import com.data.PowerArk_ServerSocket_Thread_SQL; |
| | | import com.data.PowerArk_SocketCliet_Thread; |
| | | import com.data.PowerArk_Task_SQL; |
| | | import com.dev.base.data.Dynamicload_ServerSocket_Thread; |
| | | import com.dev.base.data.Dynamicload_inf; |
| | | import com.sql.MysqlConnPool; |
| | | |
| | | public class main_MonitorServer_Dynamicload { |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | public final static boolean app_debug = false; |
| | | public final static double m_VersionNum = 1.101; |
| | | public final static String m_Version = "Welcome To Use main_MonitorServer_Dynamicload V" |
| | | + m_VersionNum ; |
| | | /**************************************************************************/ |
| | | |
| | | |
| | | /**************************************************************************/ |
| | | public static final int MysqlServer_Port = 3360; |
| | | |
| | | private static AppConfig m_AppConfig; |
| | | |
| | | private static MysqlConnPool GB_MysqlConnPool; |
| | | public static AppParam GB_App_Param; |
| | | |
| | | public static List<Dynamicload_inf> GB_DevData; |
| | | |
| | | /*********************************************************************************************/ |
| | | /*********************************************************************************************/ |
| | | public static void main(String[] args) { |
| | | String ver = m_Version; |
| | | |
| | | System.out.println("MonitorServer_Dynamicload Server Started At DateTime: " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); |
| | | //创建config.xml文件 |
| | | m_AppConfig = new AppConfig(); |
| | | |
| | | System.out.println("SQLserver IP:" + m_AppConfig.getMysqlServerIp() + ", port: "+MysqlServer_Port); |
| | | //初始化连接池中的各种参数信息 |
| | | GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, |
| | | 100); |
| | | |
| | | /* |
| | | //在连接池中获取连接 |
| | | Sql_Mysql sql_ck = new Sql_Mysql(GB_MysqlConnPool.getConn()); |
| | | try { |
| | | //创建大多数据库以及数据库中的表格,并给某些表格设值 |
| | | sql_ck.checkAndCreateDB(); |
| | | } catch (SQLException e1) { |
| | | e1.printStackTrace(); |
| | | } f999+inally { |
| | | sql_ck.close_con(); |
| | | } |
| | | */ |
| | | |
| | | //创建tb_app_param表,并且设置表中的数据 |
| | | GB_App_Param = new AppParam(GB_MysqlConnPool); |
| | | |
| | | checkingMySQLServerStart(); |
| | | |
| | | //初始化数据库 |
| | | PowerArk_Task_SQL.init(GB_MysqlConnPool); |
| | | //检测数据库服务是否启动 |
| | | /*********************************************************************************/ |
| | | /*********************************************************************************/ |
| | | GB_DevData = PowerArk_Task_SQL.queryAllPowerArk(GB_MysqlConnPool); |
| | | |
| | | /*PowerArk_ServerSocket_Thread power_thread = new PowerArk_ServerSocket_Thread(GB_MysqlConnPool,GB_DevData); |
| | | new Thread(power_thread).start();*/ |
| | | //读取每套负载系统的信息 |
| | | Dynamicload_ServerSocket_Thread server = new Dynamicload_ServerSocket_Thread(GB_MysqlConnPool,GB_DevData); |
| | | new Thread(server).start(); |
| | | /*********************************************************************************/ |
| | | } |
| | | |
| | | public static void checkingMySQLServerStart(){ |
| | | int MysqlServer_Port = 3360; |
| | | System.out.println("IP:"+m_AppConfig.getMysqlServerIp()+"port"+MysqlServer_Port); |
| | | //初始化连接池中的各种参数信息 m_AppConfig.getMysqlServerIp() |
| | | GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, 5); |
| | | while(true){ |
| | | Connection conn = null; |
| | | try { |
| | | System.out.println(" 开始检测数据库连接 "+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); |
| | | conn = GB_MysqlConnPool.getConn(); |
| | | if(conn != null){ |
| | | System.out.println("检测数据库连接成功"); |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e1) { |
| | | e1.printStackTrace(); |
| | | } |
| | | System.out.println(" MySQL_FBSDEV not Start ... "); |
| | | } finally { |
| | | if(conn != null) { |
| | | try { |
| | | conn.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |