DELL
4 天以前 c042ea8097bffe7582bae0d0024157dbc6ec897d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.main;
 
import java.sql.SQLException;
import java.util.TimeZone;
 
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
 
import com.base.AppConfig;
import com.power.mysql.Sql_Mysql;
import com.power.alarm.PwrDevHistoryAlm_SubtableThread;
import com.power.alarm.PwrDeviceAlarm_Thread;
import com.power.comm.Power_61850_Task_Thread;
import com.power.data.PowerData_RT_Array;
import com.power.data.PowerData_RT_SQL;
import com.power.datasave.PowerRealDataSave_Thread;
import com.power.mysql.MysqlConnPool;
 
public class main_PowerDev_IEC61850 {
    
    public final static boolean app_debug = false;
    public final static double m_VersionNum = 1.113;
    public final static String m_Version = "Welcome To Use Monitor_PowerDev_IEC61850 V" 
                                            + m_VersionNum + " RC_20210621";
    
    public static final int DEF_MysqlServerFBS9100S_Port = 3360;
    
    private static AppConfig m_AppConfig;
    
    private static MysqlConnPool GB_MysqlConnPool;
    private static PowerData_RT_Array GB_DataArray;
    private static Power_61850_Task_Thread GB_task_61850;
    
    /*********************************************************************************************/
    /*********************************************************************************************/
    static {
        System.setProperty("log4j.configurationFile", "log4j2_batt_comm_power_x64.xml");
    //    System.setProperty("contextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
    }
    /*********************************************************************************************/
    /*********************************************************************************************/
    
    
    public static void main(String[] args) {
        TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
        String ver = m_Version;
        
        Logger logger = LogManager.getLogger(main_PowerDev_IEC61850.class);
        
        m_AppConfig = new AppConfig();
        
        logger.info("Server Started...,Version: "+ver );
        
        logger.info("ÕýÔÚÁ¬½ÓÊý¾Ý¿â DBserver IP£º" + m_AppConfig.getMysqlServerIp() + ", port: " + DEF_MysqlServerFBS9100S_Port);
        
        do {
            
            String ip = m_AppConfig.getMysqlServerIp(); //
            
            GB_MysqlConnPool = new MysqlConnPool(ip, DEF_MysqlServerFBS9100S_Port, 
                                                    m_AppConfig.getMysqlConnCountMax());
            if(null == GB_MysqlConnPool) {
                logger.info("GB_MysqlConnPool connect to sql server timeout, continue...");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    logger.error(e.toString(), e);
                }
            } else {
                break;
            }
        } while (true);
        
        
        logger.info("³É¹¦Á¬½ÓÊý¾Ý¿â" + " DBserver IP£º" + m_AppConfig.getMysqlServerIp() + ", port: " + DEF_MysqlServerFBS9100S_Port );
        
        Sql_Mysql sql_ck = new Sql_Mysql(GB_MysqlConnPool.getConn());
        try {
            if(null != sql_ck.mysql_con) {
               sql_ck.checkAndCreateDB();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            logger.error(e.toString(), e);
        } finally {
            sql_ck.close_con();
        }
        
        GB_DataArray = new PowerData_RT_Array(m_AppConfig,GB_MysqlConnPool);
        
        GB_DataArray.initPowerData_RT_Info();
        
        GB_task_61850 = new Power_61850_Task_Thread(GB_MysqlConnPool,GB_DataArray);
        
        GB_task_61850.start();
        
        PwrDeviceAlarm_Thread alarmthread = new PwrDeviceAlarm_Thread(m_AppConfig,GB_MysqlConnPool,GB_DataArray);
        
        alarmthread.start();
        
        PowerData_RT_SQL.updateThread_StartTime(GB_MysqlConnPool, m_VersionNum);
        
        
        PowerRealDataSave_Thread datasavethd = new PowerRealDataSave_Thread(GB_MysqlConnPool,GB_DataArray);
        datasavethd.start();
        
        /********************************µçÔ´ÀúÊ·¸æ¾¯·Ö±í***********************************************/
        {
            PwrDevHistoryAlm_SubtableThread sub_thread = new PwrDevHistoryAlm_SubtableThread(GB_MysqlConnPool);
            new  Thread(sub_thread).start();
        }
        
        /*********************************************************************************/
        
        while(true)
        {
            try {
                
                Thread.sleep(2000);
                
                if(true == GB_DataArray.checkAndReinitPwrDevData()) {
                    GB_task_61850.reCreateClient();
                    logger.info("GB_task_61850.reCreateClient()");
                }
                
                Thread.sleep(1000);
                
                PowerData_RT_SQL.updateThread_Time(GB_MysqlConnPool);                
            } catch (Exception e) {
                logger.error(e.toString(), e);
            }
        }
        /*********************************************************************************/
    
    }
}