Administrator
2021-01-20 929c6af032f17eb85310cb027730fc6472b6fd5f
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
package com.config;
 
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
import java.io.PrintStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
 
public class AppParam {
    public static final String AppParamTableName = "tb_app_param";
    public static final int AppParam_Discharge = 0;
    public static final int AppParam_Charge = 1;
    public static final int AppParam_PowerOff = 2;
    private MysqlConnPool m_Conn_Pool;
    private boolean MysqlDataTable_Exist = false;
    private MonitorParam m_MonitorParam = new MonitorParam();
 
    public AppParam() {
    }
 
    public AppParam(MysqlConnPool pool) {
        this.m_Conn_Pool = pool;
        getAppParam();
    }
 
    public void copyAppParam(AppParam param) {
        this.m_MonitorParam.discharge_SaveDataTimeInterval = param.m_MonitorParam.discharge_SaveDataTimeInterval;
        this.m_MonitorParam.discharge_TestTimeLongMinimum = param.m_MonitorParam.discharge_TestTimeLongMinimum;
        this.m_MonitorParam.discharge_BattTestGroupCountMax = param.m_MonitorParam.discharge_BattTestGroupCountMax;
        this.m_MonitorParam.discharge_MonVolChangeLevel = param.m_MonitorParam.discharge_MonVolChangeLevel;
        this.m_MonitorParam.discharge_TestDataRecordCountMax = param.m_MonitorParam.discharge_TestDataRecordCountMax;
 
        this.m_MonitorParam.charge_SaveDataTimeInterval = param.m_MonitorParam.charge_SaveDataTimeInterval;
        this.m_MonitorParam.charge_TestTimeLongMinimum = param.m_MonitorParam.charge_TestTimeLongMinimum;
        this.m_MonitorParam.charge_BattTestGroupCountMax = param.m_MonitorParam.charge_BattTestGroupCountMax;
        this.m_MonitorParam.charge_MonVolChangeLevel = param.m_MonitorParam.charge_MonVolChangeLevel;
        this.m_MonitorParam.charge_TestDataRecordCountMax = param.m_MonitorParam.charge_TestDataRecordCountMax;
 
        this.m_MonitorParam.poweroff_SaveDataTimeInterval = param.m_MonitorParam.poweroff_SaveDataTimeInterval;
        this.m_MonitorParam.poweroff_TestTimeLongMinimum = param.m_MonitorParam.poweroff_TestTimeLongMinimum;
        this.m_MonitorParam.poweroff_BattTestGroupCountMax = param.m_MonitorParam.poweroff_BattTestGroupCountMax;
        this.m_MonitorParam.poweroff_MonVolChangeLevel = param.m_MonitorParam.poweroff_MonVolChangeLevel;
        this.m_MonitorParam.poweroff_TestDataRecordCountMax = param.m_MonitorParam.poweroff_TestDataRecordCountMax;
    }
 
    public int getSaveDataTimeInterval(int type) {
        int val = 0;
        switch (type) {
        case 0:
            val = this.m_MonitorParam.discharge_SaveDataTimeInterval;
            break;
        case 1:
            val = this.m_MonitorParam.charge_SaveDataTimeInterval;
            break;
        case 2:
            val = this.m_MonitorParam.poweroff_SaveDataTimeInterval;
        }
 
        return val;
    }
 
    public float getMonVolChangeLevel(int type) {
        float val = 0.0F;
        switch (type) {
        case 0:
            val = this.m_MonitorParam.discharge_MonVolChangeLevel;
            break;
        case 1:
            val = this.m_MonitorParam.charge_MonVolChangeLevel;
            break;
        case 2:
            val = this.m_MonitorParam.poweroff_MonVolChangeLevel;
        }
 
        return val;
    }
 
    public int getTestTimeLongMinimum(int type) {
        int val = 0;
        switch (type) {
        case 0:
            val = this.m_MonitorParam.discharge_TestTimeLongMinimum;
            break;
        case 1:
            val = this.m_MonitorParam.charge_TestTimeLongMinimum;
            break;
        case 2:
            val = this.m_MonitorParam.poweroff_TestTimeLongMinimum;
        }
 
        return val;
    }
 
    public int getTestDataRecordCountMax(int type) {
        int val = 0;
        switch (type) {
        case 0:
            val = this.m_MonitorParam.discharge_TestDataRecordCountMax;
            break;
        case 1:
            val = this.m_MonitorParam.charge_TestDataRecordCountMax;
            break;
        case 2:
            val = this.m_MonitorParam.poweroff_TestDataRecordCountMax;
        }
 
        return val;
    }
 
    public int getBattTestGroupCountMax(int type) {
        int val = 0;
        switch (type) {
        case 0:
            val = this.m_MonitorParam.discharge_BattTestGroupCountMax;
            break;
        case 1:
            val = this.m_MonitorParam.charge_BattTestGroupCountMax;
            break;
        case 2:
            val = this.m_MonitorParam.poweroff_BattTestGroupCountMax;
        }
 
        return val;
    }
 
    public boolean getBattJunHengFN() {
        return this.m_MonitorParam.BattJunHengFN;
    }
 
    public void getAppParam() {
        Sql_Mysql sql = new Sql_Mysql(this.m_Conn_Pool.getConn());
        try {
            sql.sqlMysqlUseDB("`db_param`");
            if (!this.MysqlDataTable_Exist) {
                this.MysqlDataTable_Exist = sql.sqlMysqlCheckIfTableExist("tb_app_param");
            }
 
            if (!this.MysqlDataTable_Exist) {
                System.out.println("tb_app_param is not exist, create it now...");
                ArrayList al_sqlstr = new ArrayList();
 
                String sql_str = "CREATE TABLE `tb_app_param` ( `num` INT NOT NULL AUTO_INCREMENT, `param_name` VARCHAR(50) NULL, `param_value` VARCHAR(50) NULL, `param_caption` VARCHAR(200) NULL, PRIMARY KEY (`num`));";
 
                al_sqlstr.add(sql_str);
 
                sql_str = "INSERT INTO tb_app_param (param_name, param_value, param_caption) VALUES ('discharge_SaveDataTimeInterval', '10', 'discharge_TimeInterval for every data insert into db_batt_testdata by seconds'), ('discharge_MonVolChangeLevel', '0.05', 'discharge_MonVolChangeLevel for batt test data to save'), ('discharge_TestTimeLongMinimum', '1800', 'discharge_TestTimeLongMinimum for batttest data to store'), ('discharge_TestDataRecordCountMax', '10000', 'discharge_TestDataRecordCountMax for batttest data count to insert to mysql server'), ('discharge_BattTestGroupCountMax', '10', 'discharge_BattTestGroupCountMax for batttest thread count to work at the same time'), ('charge_SaveDataTimeInterval', '10', 'charge_TimeInterval for every data insert into db_batt_testdata by seconds'), ('charge_MonVolChangeLevel', '0.05', 'charge_MonVolChangeLevel for batt test data to save'), ('charge_TestTimeLongMinimum', '1800', 'charge_TestTimeLongMinimum for batttest data to store'), ('charge_TestDataRecordCountMax', '10000', 'charge_TestDataRecordCountMax for batttest data count to insert to mysql server'), ('charge_BattTestGroupCountMax', '10', 'charge_BattTestGroupCountMax for batttest thread count to work at the same time'), ('poweroff_SaveDataTimeInterval', '10', 'poweroff_TimeInterval for every data insert into db_batt_testdata by seconds'), ('poweroff_MonVolChangeLevel', '0.05', 'poweroff_MonVolChangeLevel for batt test data to save'), ('poweroff_TestTimeLongMinimum', '1800', 'poweroff_TestTimeLongMinimum for batttest data to store'), ('poweroff_TestDataRecordCountMax', '10000', 'poweroff_TestDataRecordCountMax for batttest data count to insert to mysql server'), ('poweroff_BattTestGroupCountMax', '10', 'poweroff_BattTestGroupCountMax for batttest thread count to work at the same time'), ('BattJunHengFN', 'false', 'BattJunHengFN for batt monomer to be balance')";
 
                al_sqlstr.add(sql_str);
 
                for (int n = 0; n < al_sqlstr.size(); n++) {
                    sql.sqlMysqlExecute((String) al_sqlstr.get(n));
                }
            }
            String sql_str = "SELECT * FROM  tb_app_param";
            ResultSet res = sql.sqlMysqlQuery(sql_str);
 
            while (res.next()) {
                String pm_name = res.getString("param_name");
 
                if (pm_name.equals("discharge_SaveDataTimeInterval"))
                    this.m_MonitorParam.discharge_SaveDataTimeInterval = res.getInt("param_value");
                else if (pm_name.equals("discharge_MonVolChangeLevel"))
                    this.m_MonitorParam.discharge_MonVolChangeLevel = res.getFloat("param_value");
                else if (pm_name.equals("discharge_TestTimeLongMinimum"))
                    this.m_MonitorParam.discharge_TestTimeLongMinimum = res.getInt("param_value");
                else if (pm_name.equals("discharge_TestDataRecordCountMax"))
                    this.m_MonitorParam.discharge_TestDataRecordCountMax = res.getInt("param_value");
                else if (pm_name.equals("discharge_BattTestGroupCountMax")) {
                    this.m_MonitorParam.discharge_BattTestGroupCountMax = res.getInt("param_value");
                } else if (pm_name.equals("charge_SaveDataTimeInterval"))
                    this.m_MonitorParam.charge_SaveDataTimeInterval = res.getInt("param_value");
                else if (pm_name.equals("charge_MonVolChangeLevel"))
                    this.m_MonitorParam.charge_MonVolChangeLevel = res.getFloat("param_value");
                else if (pm_name.equals("charge_TestTimeLongMinimum"))
                    this.m_MonitorParam.charge_TestTimeLongMinimum = res.getInt("param_value");
                else if (pm_name.equals("charge_TestDataRecordCountMax"))
                    this.m_MonitorParam.charge_TestDataRecordCountMax = res.getInt("param_value");
                else if (pm_name.equals("charge_BattTestGroupCountMax")) {
                    this.m_MonitorParam.charge_BattTestGroupCountMax = res.getInt("param_value");
                } else if (pm_name.equals("poweroff_SaveDataTimeInterval"))
                    this.m_MonitorParam.poweroff_SaveDataTimeInterval = res.getInt("param_value");
                else if (pm_name.equals("poweroff_MonVolChangeLevel"))
                    this.m_MonitorParam.poweroff_MonVolChangeLevel = res.getFloat("param_value");
                else if (pm_name.equals("poweroff_TestTimeLongMinimum"))
                    this.m_MonitorParam.poweroff_TestTimeLongMinimum = res.getInt("param_value");
                else if (pm_name.equals("poweroff_TestDataRecordCountMax"))
                    this.m_MonitorParam.poweroff_TestDataRecordCountMax = res.getInt("param_value");
                else if (pm_name.equals("poweroff_BattTestGroupCountMax")) {
                    this.m_MonitorParam.poweroff_BattTestGroupCountMax = res.getInt("param_value");
                } else if (pm_name.equals("BattJunHengFN"))
                    this.m_MonitorParam.BattJunHengFN = res.getBoolean("param_value");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
 
        if (this.m_MonitorParam.discharge_SaveDataTimeInterval < 5)
            this.m_MonitorParam.discharge_SaveDataTimeInterval = 5;
        if (this.m_MonitorParam.discharge_SaveDataTimeInterval > 600)
            this.m_MonitorParam.discharge_SaveDataTimeInterval = 600;
 
        if (this.m_MonitorParam.discharge_MonVolChangeLevel < 0.001D)
            this.m_MonitorParam.discharge_MonVolChangeLevel = 0.001F;
        if (this.m_MonitorParam.discharge_MonVolChangeLevel > 1.0F)
            this.m_MonitorParam.discharge_MonVolChangeLevel = 1.0F;
 
        if (this.m_MonitorParam.discharge_TestTimeLongMinimum < 60)
            this.m_MonitorParam.discharge_TestTimeLongMinimum = 60;
        if (this.m_MonitorParam.discharge_TestTimeLongMinimum > 3600)
            this.m_MonitorParam.discharge_TestTimeLongMinimum = 3600;
 
        if (this.m_MonitorParam.discharge_TestDataRecordCountMax < 5000)
            this.m_MonitorParam.discharge_TestDataRecordCountMax = 5000;
        if (this.m_MonitorParam.discharge_TestDataRecordCountMax > 20000)
            this.m_MonitorParam.discharge_TestDataRecordCountMax = 20000;
 
        if (this.m_MonitorParam.discharge_BattTestGroupCountMax < 10)
            this.m_MonitorParam.discharge_BattTestGroupCountMax = 10;
        if (this.m_MonitorParam.discharge_BattTestGroupCountMax > 350)
            this.m_MonitorParam.discharge_BattTestGroupCountMax = 350;
 
        if (this.m_MonitorParam.charge_SaveDataTimeInterval < 5)
            this.m_MonitorParam.charge_SaveDataTimeInterval = 5;
        if (this.m_MonitorParam.charge_SaveDataTimeInterval > 600)
            this.m_MonitorParam.charge_SaveDataTimeInterval = 600;
 
        if (this.m_MonitorParam.charge_MonVolChangeLevel < 0.001D)
            this.m_MonitorParam.charge_MonVolChangeLevel = 0.001F;
        if (this.m_MonitorParam.charge_MonVolChangeLevel > 1.0F)
            this.m_MonitorParam.charge_MonVolChangeLevel = 1.0F;
 
        if (this.m_MonitorParam.charge_TestTimeLongMinimum < 60)
            this.m_MonitorParam.charge_TestTimeLongMinimum = 60;
        if (this.m_MonitorParam.charge_TestTimeLongMinimum > 3600)
            this.m_MonitorParam.charge_TestTimeLongMinimum = 3600;
 
        if (this.m_MonitorParam.charge_TestDataRecordCountMax < 5000)
            this.m_MonitorParam.charge_TestDataRecordCountMax = 5000;
        if (this.m_MonitorParam.charge_TestDataRecordCountMax > 20000)
            this.m_MonitorParam.charge_TestDataRecordCountMax = 20000;
 
        if (this.m_MonitorParam.charge_BattTestGroupCountMax < 10)
            this.m_MonitorParam.charge_BattTestGroupCountMax = 10;
        if (this.m_MonitorParam.charge_BattTestGroupCountMax > 350)
            this.m_MonitorParam.charge_BattTestGroupCountMax = 350;
 
        if (this.m_MonitorParam.poweroff_SaveDataTimeInterval < 5)
            this.m_MonitorParam.poweroff_SaveDataTimeInterval = 5;
        if (this.m_MonitorParam.poweroff_SaveDataTimeInterval > 600)
            this.m_MonitorParam.poweroff_SaveDataTimeInterval = 600;
 
        if (this.m_MonitorParam.poweroff_MonVolChangeLevel < 0.001D)
            this.m_MonitorParam.poweroff_MonVolChangeLevel = 0.001F;
        if (this.m_MonitorParam.poweroff_MonVolChangeLevel > 1.0F)
            this.m_MonitorParam.poweroff_MonVolChangeLevel = 1.0F;
 
        if (this.m_MonitorParam.poweroff_TestTimeLongMinimum < 60)
            this.m_MonitorParam.poweroff_TestTimeLongMinimum = 60;
        if (this.m_MonitorParam.poweroff_TestTimeLongMinimum > 3600)
            this.m_MonitorParam.poweroff_TestTimeLongMinimum = 3600;
 
        if (this.m_MonitorParam.poweroff_TestDataRecordCountMax < 5000)
            this.m_MonitorParam.poweroff_TestDataRecordCountMax = 5000;
        if (this.m_MonitorParam.poweroff_TestDataRecordCountMax > 20000)
            this.m_MonitorParam.poweroff_TestDataRecordCountMax = 20000;
 
        if (this.m_MonitorParam.poweroff_BattTestGroupCountMax < 10)
            this.m_MonitorParam.poweroff_BattTestGroupCountMax = 10;
        if (this.m_MonitorParam.poweroff_BattTestGroupCountMax > 350)
            this.m_MonitorParam.poweroff_BattTestGroupCountMax = 350;
    }
 
    class MonitorParam {
        public int discharge_SaveDataTimeInterval = 10;
        public float discharge_MonVolChangeLevel = 0.05F;
        public int discharge_TestTimeLongMinimum = 1800;
        public int discharge_TestDataRecordCountMax = 10000;
        public int discharge_BattTestGroupCountMax = 10;
 
        public int charge_SaveDataTimeInterval = 10;
        public float charge_MonVolChangeLevel = 0.05F;
        public int charge_TestTimeLongMinimum = 1800;
        public int charge_TestDataRecordCountMax = 10000;
        public int charge_BattTestGroupCountMax = 10;
 
        public int poweroff_SaveDataTimeInterval = 10;
        public float poweroff_MonVolChangeLevel = 0.05F;
        public int poweroff_TestTimeLongMinimum = 1800;
        public int poweroff_TestDataRecordCountMax = 10000;
        public int poweroff_BattTestGroupCountMax = 10;
 
        public boolean BattJunHengFN = false;
 
        MonitorParam() {
        }
    }
}
 
/*
 * Location:
 * C:\Users\LiJun\Desktop\公司各种设备资料\9600显示模块相关文件\后台程序\2018-09-07\BattFBS9600XSP.
 * jar Qualified Name: com.config.AppParam JD-Core Version: 0.6.2
 */