package com.dev.bts.data; import java.util.Date; 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_state = 0; public int recordNum; public int recordNum_BPM7100; public Date startTestTime = new Date(); public Date recordTime = new Date(); public Date newDataRecordTime = new Date(); 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 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; 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; } private 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 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 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; } } }