| | |
| | | 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.modbus.historydata.Motor_HistoryData_Record_Thread;
|
| | | import com.modbus.historydata.Motor_HistoryData_Record_Thread_SQL;
|
| | | import com.motor.alarm.Motor_Alarm_Thread;
|
| | | import com.motor.conn.Motor_ServerSocket_Thread;
|
| | | import com.motor.conn.Motor_Task_SQL;
|
| | | import com.motor.data.Motor_inf;
|
| | | import com.sql.MysqlConnPool;
|
| | |
|
| | | public class main_MonitorServer_Motor {
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | public final static boolean app_debug = false;
|
| | | public final static double m_VersionNum = 1.102;
|
| | | public final static String m_Version = "Welcome To Use main_MonitorServer_Motor 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<Motor_inf> motors;
|
| | | /*********************************************************************************************/
|
| | | /*********************************************************************************************/
|
| | | public static void main(String[] args) {
|
| | | String ver = m_Version;
|
| | | |
| | | System.out.println("main_MonitorServer_Motor 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);
|
| | | |
| | | //创建tb_app_param表,并且设置表中的数据
|
| | | GB_App_Param = new AppParam(GB_MysqlConnPool);
|
| | | |
| | | checkingMySQLServerStart(); //检测数据库服务是否启动
|
| | | /*********************************************************************************/
|
| | | /*********************************************************************************/
|
| | | Motor_Task_SQL.init(GB_MysqlConnPool);
|
| | | |
| | | Motor_HistoryData_Record_Thread_SQL.createDB_Motor_Realhistory(GB_MysqlConnPool);
|
| | | |
| | | motors = Motor_Task_SQL.queryAllMotor_inf(GB_MysqlConnPool);
|
| | | |
| | | Motor_Alarm_Thread alarmthread = new Motor_Alarm_Thread(GB_MysqlConnPool,motors);
|
| | | new Thread(alarmthread).start();
|
| | | |
| | | |
| | | Motor_HistoryData_Record_Thread history = new Motor_HistoryData_Record_Thread(GB_MysqlConnPool, motors);
|
| | | new Thread(history).start();
|
| | | |
| | | Motor_ServerSocket_Thread server = new Motor_ServerSocket_Thread(GB_MysqlConnPool,motors);
|
| | | new Thread(server).start();
|
| | | |
| | | while(true) {
|
| | | try { |
| | | Thread.sleep(5000);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | /*********************************************************************************/
|
| | | }
|
| | | |
| | | 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.modbus.historydata.Motor_HistoryData_Record_Thread; |
| | | import com.modbus.historydata.Motor_HistoryData_Record_Thread_SQL; |
| | | import com.motor.alarm.Motor_Alarm_Thread; |
| | | import com.motor.conn.Motor_ServerSocket_Thread; |
| | | import com.motor.conn.Motor_Task_SQL; |
| | | import com.motor.data.Motor_inf; |
| | | import com.sql.MysqlConnPool; |
| | | |
| | | public class main_MonitorServer_Motor { |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | public final static boolean app_debug = false; |
| | | public final static double m_VersionNum = 1.102; |
| | | public final static String m_Version = "Welcome To Use main_MonitorServer_Motor 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<Motor_inf> motors; |
| | | /*********************************************************************************************/ |
| | | /*********************************************************************************************/ |
| | | public static void main(String[] args) { |
| | | String ver = m_Version; |
| | | |
| | | System.out.println("main_MonitorServer_Motor 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); |
| | | |
| | | //创建tb_app_param表,并且设置表中的数据 |
| | | GB_App_Param = new AppParam(GB_MysqlConnPool); |
| | | |
| | | checkingMySQLServerStart(); //检测数据库服务是否启动 |
| | | /*********************************************************************************/ |
| | | /*********************************************************************************/ |
| | | Motor_Task_SQL.init(GB_MysqlConnPool); |
| | | |
| | | //Motor_HistoryData_Record_Thread_SQL.createDB_Motor_Realhistory(GB_MysqlConnPool); |
| | | |
| | | motors = Motor_Task_SQL.queryAllMotor_inf(GB_MysqlConnPool); |
| | | |
| | | Motor_Alarm_Thread alarmthread = new Motor_Alarm_Thread(GB_MysqlConnPool,motors); |
| | | new Thread(alarmthread).start(); |
| | | |
| | | |
| | | //Motor_HistoryData_Record_Thread history = new Motor_HistoryData_Record_Thread(GB_MysqlConnPool, motors); |
| | | //new Thread(history).start(); |
| | | |
| | | Motor_ServerSocket_Thread server = new Motor_ServerSocket_Thread(GB_MysqlConnPool,motors); |
| | | new Thread(server).start(); |
| | | |
| | | while(true) { |
| | | try { |
| | | Thread.sleep(5000); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | /*********************************************************************************/ |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |