Demo_Manage_Simul/src/com/mode/Manage_Util.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Demo_Manage_Simul/src/com/mode/Motor_State.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Demo_Manage_Simul/src/com/sql/Sql_Mysql.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Demo_Manage_Simul/src/com/thread/Manage_Simul_SQL.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Demo_Manage_Simul/src/com/thread/Manage_Simul_Server.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Demo_Manage_Simul/src/main/main_Demo_Manage_Simul.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Demo_Manage_Simul/src/com/mode/Manage_Util.java
New file @@ -0,0 +1,11 @@ package com.mode; public class Manage_Util{ public static final int DEV_TYPE_DYNAMICLOAD = 1001; //水冷负载 public static final int DEV_TYPE_MOTOR = 1002; //加载电机 public static final int DEV_TYPE_4MWPOWER = 1003; //1号,2号大功率整流电源 public static final int DEV_TYPE_2MWPOWER = 1004; //3号大功率整流电源 } Demo_Manage_Simul/src/com/mode/Motor_State.java
New file @@ -0,0 +1,85 @@ package com.mode; import java.util.Date; public class Motor_State { public int device_id;// '设备id', public Date record_time;//'记录时间', public float motor_curr;//'电机电流', public float motor_power;//'电机功率', public float motor_speed;//'电机转速', public float motor_vol;//'电机电压', public float motor_out_tmp;//'电机出口温度', public float motor_into_tmp;//'电机进口温度', public float motor_torque;//'电机转矩', public int motor_state;//'电机状态', public int getDevice_id() { return device_id; } public Date getRecord_time() { return record_time; } public float getMotor_curr() { return motor_curr; } public float getMotor_power() { return motor_power; } public float getMotor_speed() { return motor_speed; } public float getMotor_vol() { return motor_vol; } public float getMotor_out_tmp() { return motor_out_tmp; } public float getMotor_into_tmp() { return motor_into_tmp; } public float getMotor_torque() { return motor_torque; } public int getMotor_state() { return motor_state; } public void setDevice_id(int device_id) { this.device_id = device_id; } public void setRecord_time(Date record_time) { this.record_time = record_time; } public void setMotor_curr(float motor_curr) { this.motor_curr = motor_curr; } public void setMotor_power(float motor_power) { this.motor_power = motor_power; } public void setMotor_speed(float motor_speed) { this.motor_speed = motor_speed; } public void setMotor_vol(float motor_vol) { this.motor_vol = motor_vol; } public void setMotor_out_tmp(float motor_out_tmp) { this.motor_out_tmp = motor_out_tmp; } public void setMotor_into_tmp(float motor_into_tmp) { this.motor_into_tmp = motor_into_tmp; } public void setMotor_torque(float motor_torque) { this.motor_torque = motor_torque; } public void setMotor_state(int motor_state) { this.motor_state = motor_state; } @Override public String toString() { return "Motor_State [device_id=" + device_id + ", record_time=" + record_time + ", motor_curr=" + motor_curr + ", motor_power=" + motor_power + ", motor_speed=" + motor_speed + ", motor_vol=" + motor_vol + ", motor_out_tmp=" + motor_out_tmp + ", motor_into_tmp=" + motor_into_tmp + ", motor_torque=" + motor_torque + ", motor_state=" + motor_state + "]"; } } Demo_Manage_Simul/src/com/sql/Sql_Mysql.java
@@ -38,6 +38,9 @@ final public static String DB_Electric2MWSystem = "`db_electric2mwsystem`"; final public static String DB_ExperiMent = "`db_experiment`"; //--------------------------------------------------------------------------------------------// public final static String TB_HardDevSmsState = "tb_hard_dev_sms_state"; //--------------------------------------------------------------------------------------------// @@ -193,6 +196,13 @@ public final static String Tb_Device_ConnectState = DB_Electric2MWSystem+".tb_device_connectstate"; //设备通讯状态表 public final static String Tb_Electric_2MW_alarm = DB_Electric2MWSystem+".tb_Electric_2MW_alarm"; //2MW实时告警 public final static String Tb_Electric_2MW_alarm_history = DB_Electric2MWSystem+".tb_Electric_2MW_alarm_history";//2MW历史告警 //--------------------------------------------------------------------------------------------// public final static String Tb_Device_Inf_Table = DB_ExperiMent+".tb_device_inf"; // public final static String Tb_Water_Rt_Table = DB_ExperiMent+".tb_water_rt"; // public final static String Tb_Motor_State_Table = DB_ExperiMent+".tb_motor_state"; // public final static String Tb_Electric2mw_State_Table = DB_ExperiMent+".tb_electric2mw_state"; // public final static String Tb_Electric_State_Table = DB_ExperiMent+".tb_electric_state"; // public final static String Tb_Dynamicload_State_Rt_Table = DB_ExperiMent+".dynamicload_state_rt"; // //--------------------------------------------------------------------------------------------// Demo_Manage_Simul/src/com/thread/Manage_Simul_SQL.java
New file @@ -0,0 +1,52 @@ package com.thread; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import com.mode.Device_Inf; import com.sql.MysqlConnPool; import com.sql.Sql_Mysql; public class Manage_Simul_SQL { /** * 加载所有的设备 * @param gB_MysqlConnPool * @param devices */ public static void queryAllDevice(MysqlConnPool pool, List<Device_Inf> devices) { devices = new ArrayList<Device_Inf>(); String sql_str = " SELECT * FROM "+ Sql_Mysql.Tb_Device_Inf_Table; Sql_Mysql sql = new Sql_Mysql(pool.getConn()); ResultSet res = null; try { res = sql.sqlMysqlQuery(sql_str); while(res.next()) { Device_Inf dev = new Device_Inf(); dev.setDevice_id(res.getInt("device_id")); dev.setDevice_ip(res.getString("device_ip")); dev.setDevice_name(res.getString("device_name")); dev.setMaint_cycle(res.getInt("maint_cycle")); dev.setSystem_id(res.getInt("system_id")); dev.setSystem_name(res.getString("system_name")); dev.setUse_starttime(res.getDate("use_starttime")); dev.setUser_id(res.getInt("user_id")); devices.add(dev); } } catch (Exception e) { e.printStackTrace(); } finally { if(null != res) { try { res.close(); } catch (SQLException e) { e.printStackTrace(); } } sql.close_con(); } } } Demo_Manage_Simul/src/com/thread/Manage_Simul_Server.java
New file @@ -0,0 +1,40 @@ package com.thread; import java.util.List; import com.mode.Device_Inf; import com.mode.Manage_Util; import com.sql.MysqlConnPool; public class Manage_Simul_Server { public MysqlConnPool pool; public List<Device_Inf> devices; public Manage_Simul_Server(MysqlConnPool pool, List<Device_Inf> devices) { this.pool = pool; this.devices = devices; } public void run() { if(devices.size() > 0) { for(int i=0;i<devices.size();i++) { Device_Inf dev = devices.get(i); switch(dev.getSystem_id()) { case Manage_Util.DEV_TYPE_DYNAMICLOAD:{ }break; case Manage_Util.DEV_TYPE_4MWPOWER:{ }break; case Manage_Util.DEV_TYPE_2MWPOWER:{ }break; case Manage_Util.DEV_TYPE_MOTOR:{ }break; } } } } } Demo_Manage_Simul/src/main/main_Demo_Manage_Simul.java
@@ -2,11 +2,16 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.Date; import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.base.Com; import com.config.AppConfig; import com.mode.Device_Inf; import com.sql.MysqlConnPool; import com.thread.Manage_Simul_SQL; import com.thread.Manage_Simul_Server; public class main_Demo_Manage_Simul { /**************************************************************************/ @@ -31,6 +36,8 @@ public static Logger logger = null; public static List<Device_Inf> devices; static{ System.setProperty("log4j.configurationFile", "log4j2_demo_manage_simul.xml"); } @@ -54,8 +61,10 @@ checkingMySQLServerStart(); //检测数据库服务是否启动 /*********************************************************************************/ Manage_Simul_SQL.queryAllDevice(GB_MysqlConnPool,devices); Manage_Simul_Server server = new Manage_Simul_Server(GB_MysqlConnPool,devices); server.run(); while(true) {