61850适应多组电池组并读取充电机,汇集器,以及绝缘装置信息
whyclj
2020-12-24 0f2f7c952edac4b6a62c61062d664d83a32b985c
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
package com.data.Comm;
 
import java.sql.SQLException;
 
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
 
public class AFE_Inverter_Task_SQL {
    
    public static void init(MysqlConnPool pool) {
        CreateDB_MW_Motor(pool);
        
        CreateDB_MW_Motor_History(pool);        
        
        //CreateTb_Central_Monitor_Sys_StTable(pool);
        
        //CreateTb_Central_Monitor_Sys_RtTable(pool);
        
        //CreateTb_Central_Monitor_Sys_ControlTable(pool);
        
        CreateAfe_Inverter_State_Table(pool);
        
        CreateAfe_Rectifier_State_Table(pool);
        
    }
    
    /**
     *     ¹¹Ôì3.5mwÊý¾Ý¿â
     * @param pool
     */
    public static void CreateDB_MW_Motor(MysqlConnPool pool) {
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(" CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_MW_Motor);
        } catch (SQLException e) {
            sql.logger.error(e.toString(),e);
        }
    }
    
    /**
     *     ¹¹Ôì3.5mwÀúʷʵʱÊý¾Ý¿â
     * @param pool
     */
    public static void CreateDB_MW_Motor_History(MysqlConnPool pool) {
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(" CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_MW_Motor_History);
        } catch (SQLException e) {
            sql.logger.error(e.toString(),e);
        }
    }
    
    /**
     *     ´´½¨tb_central_monitor_sys_st±í
     * @param pool
     */
    public static void CreateTb_Central_Monitor_Sys_StTable(MysqlConnPool pool) {
        String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_Central_Monitor_Sys_St+" (" + 
                "  num bigint(20) NOT NULL AUTO_INCREMENT," + 
                "  dev_id int(11) NOT NULL DEFAULT '0' COMMENT 'É豸id'," + 
                "  record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '¸üÐÂʱ¼ä'," + 
                "  switch_close_1st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A½øÏ߯Á¿ª¹ØºÏբ״̬'," + 
                "  switch_open_1st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A½øÏ߯Á¿ª¹Ø·Öբ״̬'," + 
                "  switch_fault_1st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A½øÏ߯Á¿ª¹Ø¹ÊÕÏ״̬'," + 
                "  switch_close_2st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A½øÏ߯Á¿ª¹ØºÏբ״̬'," + 
                "  switch_open_2st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A½øÏ߯Á¿ª¹Ø·Öբ״̬'," + 
                "  switch_fault_2st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A½øÏ߯Á¿ª¹Ø¹ÊÕÏ״̬'," + 
                "  switch_close_bus_screen int(11) NOT NULL DEFAULT '0' COMMENT 'ĸÁªÆÁºÏբ״̬'," + 
                "  switch_open_bus_screen int(11) NOT NULL DEFAULT '0' COMMENT 'ĸÁªÆÁ·Öբ״̬'," + 
                "  switch_fault_bus_screen int(11) NOT NULL DEFAULT '0' COMMENT 'ĸÁªÆÁ¿ª¹Ø¹ÊÕÏ'," + 
                "  switch_close_1st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A¸ºÔØÆÁ¿ª¹ØºÏբ״̬'," + 
                "  switch_open_1st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A¸ºÔØÆÁ¿ª¹Ø·Öբ״̬'," + 
                "  switch_fault_1st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A¸ºÔØÆÁ¿ª¹Ø¹ÊÕÏ״̬'," + 
                "  switch_close_2st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A¸ºÔØÆÁ¿ª¹ØºÏբ״̬'," + 
                "  switch_open_2st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A¸ºÔØÆÁ¿ª¹Ø·Öբ״̬'," + 
                "  switch_fault_2st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A¸ºÔØÆÁ¿ª¹Ø¹ÊÕÏ״̬'," + 
                "  curr_a float NOT NULL DEFAULT '0' COMMENT 'AÅŵçÁ÷'," + 
                "  vol_a float NOT NULL DEFAULT '0' COMMENT 'AÅŵçѹ'," + 
                "  curr_b float NOT NULL DEFAULT '0' COMMENT 'BÅŵçÁ÷'," + 
                "  vol_b float NOT NULL DEFAULT '0' COMMENT 'BÅŵçѹ'," + 
                "  note varchar(255) NOT NULL DEFAULT '' COMMENT '±¸ÓÃ'," + 
                "  PRIMARY KEY (num)," + 
                "  KEY index_dev_id (dev_id) USING BTREE" + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            sql.logger.error(e.toString(), e);
        }
    }
    
    /**
     *     ´´½¨tb_central_monitor_sys_rt±í
     * @param pool
     */
    public static void CreateTb_Central_Monitor_Sys_RtTable(MysqlConnPool pool) {
        String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_Central_Monitor_Sys_Rt+" (" + 
                "  num bigint(20) NOT NULL AUTO_INCREMENT," + 
                "  dev_id int(11) NOT NULL DEFAULT '0' COMMENT 'É豸id'," + 
                "  record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '¸üÐÂʱ¼ä'," + 
                "  switch_close int(11) NOT NULL DEFAULT '0' COMMENT '¿ª¹ØºÏբ״̬'," + 
                "  switch_open int(11) NOT NULL DEFAULT '0' COMMENT '¿ª¹Ø·Öբ״̬'," + 
                "  switch_fault int(11) NOT NULL DEFAULT '0' COMMENT '¿ª¹Ø¹ÊÕÏ״̬'," + 
                "  panel_vol float(11,0) NOT NULL DEFAULT '0' COMMENT '½øÏ߯Áµçѹ'," + 
                "  panel_curr float(11,0) NOT NULL DEFAULT '0' COMMENT '½øÏ߯ÁµçÁ÷'," + 
                "  note varchar(255) NOT NULL DEFAULT '0' COMMENT '±¸ÓÃ'," + 
                "  PRIMARY KEY (num)," + 
                "  KEY index_dev_id (dev_id) USING BTREE" + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            sql.logger.error(e.toString(), e);
        }
    }
    
    /**
     *     ´´½¨tb_central_monitor_sys_control±í
     * @param pool
     */
    public static void CreateTb_Central_Monitor_Sys_ControlTable(MysqlConnPool pool) {
        String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_Central_Monitor_Sys_Control+" (" + 
                "  num bigint(20) NOT NULL," + 
                "  dev_id int(11) NOT NULL DEFAULT '0' COMMENT 'É豸id'," + 
                "  op_cmd int(11) NOT NULL DEFAULT '0' COMMENT 'ÃüÁî¿ØÖÆ'," + 
                "  switch_close_1st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A½øÏ߯Á¿ª¹ØºÏÕ¢'," + 
                "  switch_open_1st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A½øÏ߯Á¿ª¹Ø·ÖÕ¢'," + 
                "  switch_close_2st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A½øÏ߯Á¿ª¹ØºÏÕ¢'," + 
                "  switch_open_2st_2500A int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A½øÏ߯Á¿ª¹Ø·ÖÕ¢'," + 
                "  switch_close_bus_screen int(11) NOT NULL DEFAULT '0' COMMENT 'ĸÁªÆÁ¿ª¹ØºÏÕ¢'," + 
                "  switch_open_bus_screen int(11) NOT NULL DEFAULT '0' COMMENT 'ĸÁªÆÁ¿ª¹Ø·ÖÕ¢'," + 
                "  switch_close_1st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A¸ºÔØÆÁ¿ª¹ØºÏÕ¢'," + 
                "  switch_open_1st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '1ºÅ2500A¸ºÔØÆÁ¿ª¹Ø·ÖÕ¢'," + 
                "  switch_close_2st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A¸ºÔØÆÁ¿ª¹ØºÏÕ¢'," + 
                "  switch_open_2st_2500A_load int(11) NOT NULL DEFAULT '0' COMMENT '2ºÅ2500A¸ºÔØÆÁ¿ª¹Ø·ÖÕ¢'," + 
                "  PRIMARY KEY (num)," + 
                "  KEY index_dev_id (dev_id) USING BTREE" + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            sql.logger.error(e.toString(), e);
        }
    }
    
    
    /**
     *     ´´½¨tb_afe_inverter_rt±í
     * @param pool
     */
    public static void CreateTb_AFE_Inverter_RTTable(MysqlConnPool pool) {
        String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_AFE_Inverter_RT+" (" + 
                "  num bigint(20) NOT NULL AUTO_INCREMENT," + 
                "  dev_id int(11) NOT NULL DEFAULT '0' COMMENT 'É豸id'," + 
                "  record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '¼Ç¼ʱ¼ä'," + 
                "  rectifier_run int(11) NOT NULL DEFAULT '0' COMMENT 'ÕûÁ÷ÔËÐÐ'," + 
                "  inverter_run int(11) NOT NULL DEFAULT '0' COMMENT 'Äæ±äÔËÐÐ'," + 
                "  report_alm int(11) NOT NULL DEFAULT '0' COMMENT '×ۺϱ¨¾¯'," + 
                "  report_fault int(11) NOT NULL DEFAULT '0' COMMENT '×ۺϹÊÕÏ'," + 
                "  motor_speed float NOT NULL DEFAULT '0' COMMENT 'µç»úתËÙ'," + 
                "  output_power float NOT NULL DEFAULT '0' COMMENT 'Êä³öÓй¦¹¦ÂÊ'," + 
                "  output_curr float NOT NULL DEFAULT '0' COMMENT 'Êä³öµçÁ÷'," + 
                "  output_vol float NOT NULL DEFAULT '0' COMMENT 'Êä³öµçѹ'," + 
                "  model_tmp float NOT NULL DEFAULT '0' COMMENT 'Ä£¿éζÈ'," + 
                "  note varchar(255) NOT NULL DEFAULT '' COMMENT '±¸ÓÃ'," + 
                "  PRIMARY KEY (num)" + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            sql.logger.error(e.toString(), e);
        }
    }
    
    /**
     *     ´´½¨tb_afe_inverter_control±í
     * @param pool
     */
    public static void CreateTb_AFE_Inverter_ControlTable(MysqlConnPool pool) {
        String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Tb_AFE_Inverter_Control+" (" + 
                "  num bigint(20) NOT NULL," + 
                "  dev_id int(11) NOT NULL DEFAULT '0' COMMENT 'É豸id'," + 
                "  op_cmd int(11) NOT NULL DEFAULT '0' COMMENT '¿ØÖÆÃüÁî'," + 
                "  rectifier_start int(11) NOT NULL DEFAULT '0' COMMENT 'ÕûÁ÷Æô¶¯'," + 
                "  rectifier_stop int(11) NOT NULL DEFAULT '0' COMMENT 'ÕûÁ÷Í£Ö¹'," + 
                "  inverter_start int(11) NOT NULL DEFAULT '0' COMMENT 'Äæ±äÆô¶¯'," + 
                "  inverter_stop int(11) NOT NULL DEFAULT '0' COMMENT 'Äæ±äÍ£Ö¹'," + 
                "  speed_torque_change int(11) NOT NULL DEFAULT '0' COMMENT 'ËÙ¶È/ת¾ØÄ£Ê½'," + 
                "  reset int(11) NOT NULL DEFAULT '0' COMMENT '¸´Î»'," + 
                "  torque_set float NOT NULL DEFAULT '0' COMMENT 'ת¾Ø¸ø¶¨'," + 
                "  speed_set float NOT NULL DEFAULT '0' COMMENT 'Ëٶȸø¶¨'," + 
                "  positive_speed_limit float NOT NULL DEFAULT '0' COMMENT 'ÕýÏòתËÙÏÞ·ù'," + 
                "  reverse_speed_limit float NOT NULL DEFAULT '0' COMMENT '·´ÏòתËÙÏÞ·ù'," + 
                "  PRIMARY KEY (num)" + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            sql.logger.error(e.toString(), e);
        }
    }
    
    /**
     *     ´´½¨ tb_afe_inverter_state ±í
     * @param pool
     */
    public static void CreateAfe_Inverter_State_Table(MysqlConnPool pool) {
        String sql_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Afe_Inverter_State_Table+" (" + 
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT," + 
                "  `dev_id` int(11) NOT NULL DEFAULT '0' COMMENT 'É豸id'," + 
                "  `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '¼Ç¼ʱ¼ä'," + 
                "  `torque_set` float NOT NULL DEFAULT '0' COMMENT 'ת¾Ø¸ø¶¨'," + 
                "  `speed_set` float NOT NULL DEFAULT '0' COMMENT 'Ëٶȸø¶¨'," + 
                "  `positive_speed_limit` float NOT NULL DEFAULT '0' COMMENT 'ÕýÏòתËÙÏÞ·ù'," + 
                "  `reverse_speed_limit` float NOT NULL DEFAULT '0' COMMENT '¸ºÏòתËÙÏÞ·ù'," + 
                "  `motor_speed` float NOT NULL DEFAULT '0' COMMENT 'µç»úתËÙ'," + 
                "  `output_power` float NOT NULL DEFAULT '0' COMMENT 'Êä³öÓй¦¹¦ÂÊ'," + 
                "  `output_curr` float NOT NULL DEFAULT '0' COMMENT 'Êä³öµçÁ÷'," + 
                "  `output_vol` float NOT NULL DEFAULT '0' COMMENT 'Êä³öµçѹ'," + 
                "  `model_tmp` float NOT NULL DEFAULT '0' COMMENT 'Ä£¿éζÈ'," + 
                "  `note` varchar(255) NOT NULL DEFAULT '' COMMENT '±¸ÓÃ'," + 
                "  PRIMARY KEY (`num`)," + 
                "  UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE," + 
                "  KEY `index_record_time` (`record_time`) USING BTREE" + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            sql.logger.error(e.toString(), e);
        }
    }
    
    /**
     *     ´´½¨ tb_afe_rectifier_state ±í
     * @param pool
     */
    public static void CreateAfe_Rectifier_State_Table(MysqlConnPool pool) {
        String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Afe_Rectifier_State_Table + " (" + 
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Ö÷¼ü'," + 
                "  `dev_id` int(11) NOT NULL DEFAULT '0' COMMENT 'É豸id'," + 
                "  `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '¼Ç¼ʱ¼ä'," + 
                "  `rectifier_start` int(11) NOT NULL DEFAULT '0' COMMENT 'ÕûÁ÷Æô¶¯'," + 
                "  `rectifier_stop` int(11) NOT NULL DEFAULT '0' COMMENT 'ÕûÁ÷Í£Ö¹'," + 
                "  `inverter_start` int(11) NOT NULL DEFAULT '0' COMMENT 'Äæ±äÆô¶¯'," + 
                "  `inverter_stop` int(11) NOT NULL DEFAULT '0' COMMENT 'Äæ±äÍ£Ö¹'," + 
                "  `speed_torque_change` int(11) NOT NULL DEFAULT '0' COMMENT 'ËÙ¶È/ת¾ØÄ£Ê½'," + 
                "  `reset` int(11) NOT NULL DEFAULT '0' COMMENT '¸´Î»'," + 
                "  `rectifier_run` int(11) NOT NULL DEFAULT '0' COMMENT 'ÕûÁ÷ÔËÐÐ'," + 
                "  `inverter_run` int(11) NOT NULL DEFAULT '0' COMMENT 'Äæ±äÔËÐÐ'," + 
                "  `report_alm` int(11) NOT NULL DEFAULT '0' COMMENT '×ۺϱ¨¾¯'," + 
                "  `report_fault` int(11) NOT NULL DEFAULT '0' COMMENT '×ۺϹÊÕÏ'," + 
                "  `note` varchar(255) NOT NULL DEFAULT '' COMMENT '±¸ÓÃ'," + 
                "  PRIMARY KEY (`num`)," + 
                "  UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE," + 
                "  KEY `index_record_time` (`record_time`) USING BTREE" + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute(sql_str);
        } catch (SQLException e) {
            sql.logger.error(e.toString(), e);
        }
    }
}