From 58486b2b413ba7e49108d57b09ac28ce9d682a64 Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq,com> Date: 星期二, 25 八月 2020 14:00:52 +0800 Subject: [PATCH] 修改 --- Motor_MonitorServer/src/main/main_MonitorServer_Motor.java | 236 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 118 insertions(+), 118 deletions(-) diff --git a/Motor_MonitorServer/src/main/main_MonitorServer_Motor.java b/Motor_MonitorServer/src/main/main_MonitorServer_Motor.java index ebd3336..951e2ba 100644 --- a/Motor_MonitorServer/src/main/main_MonitorServer_Motor.java +++ b/Motor_MonitorServer/src/main/main_MonitorServer_Motor.java @@ -1,118 +1,118 @@ -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(); + } + } + } + } + } +} -- Gitblit v1.9.1