package com.battdata_rt;
|
import java.util.Date;
|
|
import com.base.Com;
|
import com.dev.fbs9100.FBS9100_ComBase;
|
|
|
public class BattStatData
|
{
|
//----------------------------------------------------------
|
final public static byte BATTDATA_NULL = 0;
|
final public static byte BATTDATA_FLOAT = 1;
|
final public static byte BATTDATA_CHARGE = 2;
|
final public static byte BATTDATA_DISCHARGE = 3;
|
final public static byte BATTDATA_JUNCHARGE = 4;
|
final public static byte BATTDATA_RES = 5;
|
final public static byte BATTDATA_SER = 6;
|
final public static byte BATTDATA_TMP = 7;
|
final public static byte BATTDATA_CONNRES = 8;
|
final public static byte BATTDATA_MONITOR = 9;
|
//----------------------------------------------------------
|
final public static byte BATTSTATE_NULL = 0;
|
final public static byte BATTSTATE_FLOAT = 1;
|
final public static byte BATTSTATE_CHARGE = 2;
|
final public static byte BATTSTATE_DISCHARGE = 3;
|
final public static byte BATTSTATE_JUNCHARGE = 4;
|
final public static byte BATTSTATE_RES = 5;
|
final public static byte BATTSTATE_SER = 6;
|
final public static byte BATTSTATE_TMP = 7;
|
final public static byte BATTSTATE_CONNRES = 8;
|
final public static byte BATTSTATE_MONITOR = 9;
|
//----------------------------------------------------------
|
final public static byte TEST_LOADER_REALLOADER = 1;
|
final public static byte TEST_LOADER_FBI_IDCE = 2;
|
final public static byte TEST_LOADER_FBS9100S = 3;
|
//----------------------------------------------------------
|
//---- FBI/IDCE serials device connection state monitor ----
|
private boolean CurrDataIsUseForIdceFbi = false;
|
private boolean CurrDataIsUseForIdceFbi_LaZha = false;
|
//----------------------------------------------------------
|
private float mBattFloatCurrLevel = 30;
|
//----------------------------------------------------------
|
//----------------------------------------------------------
|
public int dev_FBS9100S_WorkState = FBS9100_ComBase.SYS_STATE_STOPPED;
|
public int dev_FBS9100S_TestType = FBS9100_ComBase.TestType_NULL;
|
public byte battTestState = BATTSTATE_FLOAT;
|
public byte battTestType_For_DataSave = BATTSTATE_FLOAT;
|
public int dataCalCount;
|
public int testRecordCount;
|
public byte testLoaderType = 0;
|
public int test_stoptype = 0;
|
public int batt_res_test_cnt_last = 0;
|
public int batt_res_test_cnt = 0;
|
public int batt_res_test_cnt_out = 0;
|
|
public int batt_res_test_state = 0;
|
public int recordNum;
|
public int recordNum_BPM7100;
|
public Date startTestTime = new Date();
|
public Date recordTime = new Date();
|
public Date newDataRecordTime = new Date(0); //new data time that get from fbs_dev;
|
//public Date dataInsertToDBTime = new Date(); //data insert to database time;
|
public int testTimeLong;
|
public float onlineVol;
|
public float groupVol;
|
public float groupTmp;
|
public byte battState;
|
|
private boolean bpm7100_runState = false;
|
|
public float testCurr = 0;
|
public float testCurrAbsMax = 0;
|
public float TestCurr_RT = 0;
|
public float TestCurr_RT_TMP = 0;
|
public int TestState_RT;
|
|
public float sybase_server_battcurr;
|
public float testCap;
|
public float battRealCap;
|
public float battRestCap;
|
public int battRestTime;
|
|
public BattStatData()
|
{
|
init((byte) BATTSTATE_FLOAT, 0);
|
}
|
|
public String getStartTestTimeString() {
|
return Com.getDateTimeFormat(startTestTime, Com.DTF_YMDhms);
|
}
|
public String getRecordTimeString() {
|
return Com.getDateTimeFormat(recordTime, Com.DTF_YMDhms);
|
}
|
|
public void setStartTestTime(long tm) {
|
startTestTime.setTime(tm);
|
}
|
public void setRecordTime(long tm) {
|
recordTime.setTime(tm);
|
}
|
|
public long getStartTestTimeInLong() {
|
return startTestTime.getTime();
|
}
|
public long getRecordTimeInLong() {
|
return recordTime.getTime();
|
}
|
|
public void setBattFloatCurrLevel(float curr_level)
|
{
|
mBattFloatCurrLevel = curr_level;
|
}
|
|
public void setBpm7100RunState(boolean stat) {
|
bpm7100_runState = stat;
|
}
|
public boolean getBpm7100RunState() {
|
return bpm7100_runState;
|
}
|
|
public BattStatData clone()
|
{
|
BattStatData bdata = new BattStatData();
|
bdata.battTestState = battTestState;
|
bdata.battTestType_For_DataSave = battTestType_For_DataSave;
|
bdata.battState = battState;
|
bdata.dataCalCount = dataCalCount;
|
bdata.testRecordCount = testRecordCount;
|
bdata.recordNum = recordNum;
|
bdata.recordNum_BPM7100 = recordNum_BPM7100;
|
bdata.startTestTime.setTime(startTestTime.getTime());
|
bdata.testLoaderType = testLoaderType;
|
bdata.test_stoptype = test_stoptype;
|
bdata.recordTime.setTime(recordTime.getTime());
|
bdata.newDataRecordTime.setTime(newDataRecordTime.getTime());
|
bdata.testTimeLong = testTimeLong;
|
bdata.onlineVol = onlineVol;
|
bdata.groupVol = groupVol;
|
bdata.groupTmp = groupTmp;
|
bdata.testCurr = testCurr;
|
bdata.testCurrAbsMax = testCurrAbsMax;
|
bdata.sybase_server_battcurr = sybase_server_battcurr;
|
bdata.testCap = testCap;
|
bdata.battRealCap = battRealCap;
|
bdata.battRestCap = battRestCap;
|
bdata.battRestTime = battRestTime;
|
|
return bdata;
|
}
|
|
public void init(byte test_type, int count)
|
{
|
battTestState = test_type;
|
battTestType_For_DataSave = test_type;
|
if(BattStatData.BATTSTATE_MONITOR == test_type) {
|
TestState_RT = battTestState;
|
} else {
|
battState = test_type;
|
}
|
|
testLoaderType = TEST_LOADER_REALLOADER;
|
//edit by mxpopstar @20201002
|
this.checkAndSetLoaderType();
|
|
test_stoptype = -1;
|
|
testRecordCount = count;
|
dataCalCount = 0;
|
recordNum = 0;
|
recordNum_BPM7100 = 0;
|
startTestTime.setTime(new Date().getTime());
|
recordTime.setTime(new Date().getTime());
|
testTimeLong = 0;
|
testCap = 0;
|
testCurrAbsMax = 0;
|
}
|
|
public void bpm7100_init(byte batt_state)
|
{
|
battState = batt_state;
|
dataCalCount = 0;
|
recordNum_BPM7100 = 0;
|
testCap = 0;
|
testCurrAbsMax = 0;
|
}
|
|
public void upDateCurrRT(float curr)
|
{
|
TestCurr_RT = curr;
|
//System.out.println("TestCurr_RT: " + TestCurr_RT);
|
if(Math.abs(testCurrAbsMax) < Math.abs(TestCurr_RT))
|
{
|
testCurrAbsMax = TestCurr_RT;
|
}
|
|
if(Math.abs(TestCurr_RT) < mBattFloatCurrLevel) {
|
TestState_RT = BATTSTATE_FLOAT;
|
}
|
if(TestCurr_RT >= mBattFloatCurrLevel) {
|
TestState_RT = BATTSTATE_CHARGE;
|
} else if(TestCurr_RT <= (mBattFloatCurrLevel*(-1))) {
|
TestState_RT = BATTSTATE_DISCHARGE;
|
}
|
}
|
|
public float getAvgTestCurr() {
|
float avg_curr = 0;
|
if(testTimeLong > 0) {
|
avg_curr = (testCap*3600)/testTimeLong;
|
}
|
|
return avg_curr;
|
}
|
|
public boolean isCurrDataUseForIdceFbi()
|
{
|
return CurrDataIsUseForIdceFbi;
|
}
|
public void setCurrDataIsUseForIdceFbi(boolean stat)
|
{
|
CurrDataIsUseForIdceFbi = stat;
|
}
|
|
public void setLoaderType(byte ld_t) {
|
testLoaderType = ld_t;
|
}
|
public byte getLoaderType() {
|
return testLoaderType;
|
}
|
|
public void checkAndSetLoaderType() {
|
int fbsdev_testtype = this.getDevFBS9100S_TestType();
|
if((FBS9100_ComBase.SYS_STATE_STOPPED != this.getDevFBS9100S_WorkState())
|
&& ((FBS9100_ComBase.TestType_CAP==fbsdev_testtype)
|
|| (FBS9100_ComBase.TestType_Charge==fbsdev_testtype))) {
|
|
//--------------------- edit by mxpopstar @20201107 ----------------------//
|
if(FBS9100_ComBase.SYS_STATE_CHARGING != this.getDevFBS9100S_WorkState()) {
|
this.battTestType_For_DataSave = BattStatData.BATTSTATE_DISCHARGE;
|
}
|
|
if(BattStatData.TEST_LOADER_FBS9100S != this.getLoaderType()) {
|
this.setLoaderType(BattStatData.TEST_LOADER_FBS9100S);
|
}
|
}
|
/*******************************************************
|
else {
|
if(true == this.isCurrDataUseForIdceFbi()) {
|
if(false == this.isCurrDataUseForIdceFbi_LaZha()) {
|
this.setLoaderType(BattStatData.TEST_LOADER_FBI_IDCE);
|
}
|
}
|
}
|
********************************************************/
|
}
|
|
public void addBatt_res_test_cnt() {
|
if(this.batt_res_test_cnt>9999999) {
|
this.batt_res_test_cnt = 1;
|
}
|
this.batt_res_test_cnt++;
|
}
|
|
public int getTestRecordNum() {
|
return recordNum;
|
}
|
|
public void setDevFBS9100S_WorkState(int alarm_stat, int test_type, int wks_t) {
|
test_stoptype = alarm_stat;
|
|
dev_FBS9100S_TestType = test_type;
|
dev_FBS9100S_WorkState = wks_t;
|
}
|
public int getDevFBS9100S_WorkState() {
|
return dev_FBS9100S_WorkState;
|
}
|
public int getDevFBS9100S_TestType() {
|
return dev_FBS9100S_TestType;
|
}
|
|
public boolean isCurrDataUseForIdceFbi_LaZha()
|
{
|
return CurrDataIsUseForIdceFbi_LaZha;
|
}
|
public void setCurrDataIsUseForIdceFbi_LaZha(boolean stat)
|
{
|
CurrDataIsUseForIdceFbi_LaZha = stat;
|
}
|
|
/**
|
* 从FBS设备更新group temp
|
* @param vol
|
*/
|
public void updateGroupTempFrom_FBSDev(float temp)
|
{
|
groupTmp = temp;
|
}
|
|
/**
|
* 从FBS设备更新online vol
|
* @param vol
|
*/
|
public void updateOnlineVolFrom_FBSDev(float vol)
|
{
|
onlineVol = vol;
|
}
|
|
/**
|
* 从FBS设备更新组端电压
|
* @param vol
|
*/
|
public void updateGroupVolFrom_FBSDev(float vol)
|
{
|
groupVol = vol;
|
}
|
|
/*************************************************************************/
|
|
/**
|
* 从FBS设备更新电流
|
* @param curr
|
*/
|
public void updateCurrFrom_FBSDev(float curr)
|
{
|
upDateCurrRT(curr);
|
}
|
|
public void updateNewDataRCTime(Date d_t) {
|
newDataRecordTime.setTime(d_t.getTime());
|
}
|
|
public void calTestCap(int second_interval)
|
{
|
Date old_rec_t = new Date();
|
old_rec_t.setTime(recordTime.getTime());
|
|
recordTime.setTime(new Date().getTime());
|
|
testTimeLong = (int) ((recordTime.getTime() - startTestTime.getTime())/1000);
|
|
double t_interval = recordTime.getTime();
|
t_interval = (t_interval-old_rec_t.getTime()) / 1000;
|
|
testCap += (testCurr*t_interval)/3600;
|
|
if((++dataCalCount) >= 36000) {
|
dataCalCount = 0;
|
}
|
}
|
}
|