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
|
*/
|