package com.dev.fgcd.data;
|
|
import java.nio.ByteBuffer;
|
|
import com.battmonitor.base.ComBase;
|
import com.dev.fgcd.comm.FGCD_TestDataDownLoad;
|
import com.mchange.v3.hocon.HoconUtils;
|
|
public class FGCD_TestFBOFile {
|
public static int BYTE_LEN = 28; //µ¥¸öÊý¾ÝÎļþ´óС
|
public int dev_id;
|
public int op_cmd;
|
|
public int battgroupid; //µç³Ø×éid
|
public int file_index; //ÏÂÔØÎļþË÷Òý
|
public int file_count; //µ±Ç°ÎļþÊý
|
public int file_total; //Êý¾ÝÎļþ×ÜÊý
|
|
public int file_downloadNum; //µ±Ç°ÏÂÔØÎļþ±àºÅË÷Òý
|
|
private int stop_reason; //½áÊøÔÒò
|
|
public FBOFile[] files = new FBOFile[8]; //¶ÁÈ¡µÄÀúÊ·Îļþ
|
|
public FGCD_TestFBOFile(int dev_id) {
|
this.dev_id = dev_id;
|
for(int i=0;i<files.length;i++) {
|
files[i] = new FBOFile();
|
}
|
}
|
|
|
public FGCD_Cmd createCmd(int cmd) {
|
FGCD_Cmd m_Cmd = new FGCD_Cmd();
|
m_Cmd.CMD = cmd;
|
m_Cmd.Db1 = file_index; //±¾Ò³ÐòºÅ
|
return m_Cmd;
|
}
|
|
|
|
|
|
public int getStop_reason() {
|
return stop_reason;
|
}
|
|
|
public void setStop_reason(int stop_reason) {
|
this.stop_reason = stop_reason;
|
}
|
|
public boolean putByteBuffer(ByteBuffer bf,int file_count) {
|
this.file_count = (int)Math.floor((double)bf.limit()/BYTE_LEN);
|
if(bf.limit() < BYTE_LEN) {
|
return false;
|
}
|
ByteBuffer tmpbuf = bf;
|
tmpbuf.position(0);
|
for(int i=0;i<files.length;i++) {
|
if(i< this.file_count) {
|
FBOFile fbo = files[i];
|
fbo.file_count = ComBase.changeByteToInt(bf.get());
|
this.file_total = fbo.file_count;
|
fbo.file_index = ComBase.changeByteToInt(bf.get());
|
fbo.year = ComBase.changeByteToInt(bf.get()); //Äê
|
fbo.month = ComBase.changeByteToInt(bf.get()); //ÔÂ
|
fbo.day = ComBase.changeByteToInt(bf.get()); //Ìì
|
fbo.hour = ComBase.changeByteToInt(bf.get()); //ʱ
|
fbo.minte = ComBase.changeByteToInt(bf.get()); //·Ö
|
fbo.second = ComBase.changeByteToInt(bf.get()); //Ãë
|
//System.out.println(fbo.year+"-"+fbo.month+"-"+fbo.day+" "+fbo.hour+":"+fbo.minte+":"+fbo.second);
|
fbo.setFileName();
|
//System.out.println(fbo.filename);
|
//fbo.filename; //ÎļþÃû
|
int hour = ComBase.changeByteToInt(bf.get());
|
int minte = ComBase.changeByteToInt(bf.get());
|
int second = ComBase.changeByteToInt(bf.get());
|
fbo.test_timelong = hour*60*60+minte*60+second; //²âÊÔʱ³¤
|
fbo.data_type = getFBSDevType(ComBase.changeByteToInt(bf.get())); //Êý¾ÝÀàÐÍ
|
fbo.test_curr = (float)ComBase.changeShortToInt(bf.getShort())/10; //²âÊÔµçÁ÷(0.1A)
|
fbo.test_cap = ComBase.changeShortToInt(bf.getShort()); //²âÊÔÈÝÁ¿(1AH)
|
fbo.cap_std = ComBase.changeShortToInt(bf.getShort()); //±ê³ÆÈÝÁ¿(1AH)
|
fbo.monvol_low = ComBase.changeShortToInt(bf.getShort())/100; //µ¥ÌåÏÂÏÞ(0.01V)
|
fbo.groupvol_low = ComBase.changeShortToInt(bf.getShort()); //×é¶ËÏÂÏÞ
|
fbo.mon_count = ComBase.changeShortToInt(bf.getShort()); //µ¥Ìå¸öÊý
|
fbo.testgroup_count = ComBase.changeShortToInt(bf.getShort()); //²âÊÔµÚ¼¸×éµÃµ½µÄÊý¾Ý
|
fbo.teststop_reason = ComBase.changeByteToInt(bf.get()); //Í£Ö¹ÔÒò
|
fbo.monvol_type = getMonVolType(ComBase.changeByteToInt(bf.get())); //µ¥ÌåµçѹÀàÐÍ
|
|
fbo.download_state = 0;
|
fbo.download_flag = 0;
|
fbo.now_data_block = 0; //µ±Ç°Êý¾Ý¿éÊýÄ¿
|
fbo.total_data_block=0; //µ±Ç°ÏÂÔØ×´Ì¬
|
}else {
|
files[i].clear();
|
}
|
}
|
return true;
|
}
|
|
/**
|
* ת»¯µ±Ç°²âÊÔÀàÐÍ
|
* @param dev_type
|
* @return
|
*/
|
public static int getFBSDevType(int dev_type) {
|
switch(dev_type) {
|
case 0xFD:dev_type = 3;break; //·Åµç
|
case 0xFC:dev_type = 2;break; //³äµç
|
case 0xFE:dev_type = 4;break; //»î»¯
|
}
|
return dev_type;
|
}
|
|
/**
|
* »ñÈ¡µ±Ç°µ¥Ìåµçѹ
|
* @param testtype
|
* @return
|
*/
|
public float getMonVolType(int testtype) {
|
float mon_vol = 0;
|
switch(testtype) {
|
case 0x14:mon_vol = 2.0f;break;
|
case 0x28:mon_vol = 4.0f;break;
|
case 0x3C:mon_vol = 6.0f;break;
|
case 0x50:mon_vol = 8.0f;break;
|
case 0x64:mon_vol = 10.0f;break;
|
case 0x78:mon_vol = 12.0f;break;
|
case 0x20:mon_vol = 3.2f;break;
|
case 0x25:mon_vol = 3.7f;break;
|
}
|
return mon_vol;
|
}
|
|
public class FBOFile{
|
public int file_count; //Êý¾ÝÎļþ×ÜÊý
|
public int file_index; //µ±Ç°ÎļþË÷Òý
|
public int year; //Äê
|
public int month; //ÔÂ
|
public int day; //Ìì
|
public int hour; //ʱ
|
public int minte; //·Ö
|
public int second; //Ãë
|
public String filename; //ÎļþÃû
|
public int test_timelong; //²âÊÔʱ³¤
|
public int data_type; //Êý¾ÝÀàÐÍ
|
public float test_curr; //²âÊÔµçÁ÷(0.1A)
|
public int test_cap; //²âÊÔÈÝÁ¿(1AH)
|
public int cap_std; //±ê³ÆÈÝÁ¿(1AH)
|
public float monvol_low; //µ¥ÌåÏÂÏÞ(0.01V)
|
public float groupvol_low; //×é¶ËÏÂÏÞ
|
public int mon_count; //µ¥Ìå¸öÊý
|
public int testgroup_count; //²âÊÔµÚ¼¸×éµÃµ½µÄÊý¾Ý
|
public int teststop_reason; //Í£Ö¹ÔÒò
|
public float monvol_type; //µ¥ÌåµçѹÀàÐÍ
|
public int download_flag; //ÏÂÔØ±êʶ
|
public int download_state; //ÏÂÔØ×´Ì¬
|
public int now_data_block; //µ±Ç°Êý¾Ý¿éÊýÄ¿
|
public int total_data_block; //µ±Ç°ÏÂÔØ×´Ì¬
|
|
|
|
public void clear() {
|
file_count = 0; //Êý¾ÝÎļþ×ÜÊý
|
file_index = 0; //µ±Ç°ÎļþË÷Òý
|
filename = ""; //ÎļþÃû
|
test_timelong = 0; //²âÊÔʱ³¤
|
data_type = 0; //Êý¾ÝÀàÐÍ
|
test_curr = 0; //²âÊÔµçÁ÷(0.1A)
|
test_cap = 0; //²âÊÔÈÝÁ¿(1AH)
|
cap_std = 0; //±ê³ÆÈÝÁ¿(1AH)
|
monvol_low = 0; //µ¥ÌåÏÂÏÞ(0.01V)
|
groupvol_low = 0; //×é¶ËÏÂÏÞ
|
mon_count = 0; //µ¥Ìå¸öÊý
|
testgroup_count = 0; //²âÊÔµÚ¼¸×éµÃµ½µÄÊý¾Ý
|
teststop_reason = 0; //Í£Ö¹ÔÒò
|
monvol_type = 0; //µ¥ÌåµçѹÀàÐÍ
|
download_flag = 0; //ÏÂÔØ±êʶ
|
download_state = 0; //ÏÂÔØ×´Ì¬
|
|
now_data_block = 0; //µ±Ç°Êý¾Ý¿éÊýÄ¿
|
total_data_block = 0; //µ±Ç°ÏÂÔØ×´Ì¬
|
}
|
|
public FBOFile clone() {
|
FBOFile tmpFile = new FBOFile();
|
tmpFile.file_count = file_count; //Êý¾ÝÎļþ×ÜÊý
|
tmpFile.file_index = file_index; //µ±Ç°ÎļþË÷Òý
|
tmpFile.filename = filename; //ÎļþÃû
|
tmpFile.test_timelong = test_timelong; //²âÊÔʱ³¤
|
tmpFile.data_type =data_type; //Êý¾ÝÀàÐÍ
|
tmpFile.test_curr =test_curr; //²âÊÔµçÁ÷(0.1A)
|
tmpFile.test_cap =test_cap; //²âÊÔÈÝÁ¿(1AH)
|
tmpFile.cap_std =cap_std; //±ê³ÆÈÝÁ¿(1AH)
|
tmpFile.monvol_low = monvol_low; //µ¥ÌåÏÂÏÞ(0.01V)
|
tmpFile.groupvol_low = groupvol_low; //×é¶ËÏÂÏÞ
|
tmpFile.mon_count = mon_count; //µ¥Ìå¸öÊý
|
tmpFile.testgroup_count = testgroup_count; //²âÊÔµÚ¼¸×éµÃµ½µÄÊý¾Ý
|
tmpFile.teststop_reason = teststop_reason; //Í£Ö¹ÔÒò
|
tmpFile.monvol_type = monvol_type; //µ¥ÌåµçѹÀàÐÍ
|
tmpFile.download_flag = download_flag; //ÏÂÔØ±êʶ
|
tmpFile.download_state = download_state; //ÏÂÔØ×´Ì¬
|
|
tmpFile.now_data_block = now_data_block; //µ±Ç°Êý¾Ý¿éÊýÄ¿
|
tmpFile.total_data_block = total_data_block; //µ±Ç°ÏÂÔØ×´Ì¬
|
return tmpFile;
|
}
|
|
public int getFile_count() {
|
return file_count;
|
}
|
public int getFile_index() {
|
return file_index;
|
}
|
public int getYear() {
|
return year;
|
}
|
public int getMonth() {
|
return month;
|
}
|
public int getDay() {
|
return day;
|
}
|
public int getHour() {
|
return hour;
|
}
|
public int getMinte() {
|
return minte;
|
}
|
public int getSecond() {
|
return second;
|
}
|
public String getFilename() {
|
return filename;
|
}
|
public int getTest_timelong() {
|
return test_timelong;
|
}
|
public int getData_type() {
|
return data_type;
|
}
|
public float getTest_curr() {
|
return test_curr;
|
}
|
public int getTest_cap() {
|
return test_cap;
|
}
|
public int getCap_std() {
|
return cap_std;
|
}
|
public float getMonvol_low() {
|
return monvol_low;
|
}
|
public float getGroupvol_low() {
|
return groupvol_low;
|
}
|
public int getMon_count() {
|
return mon_count;
|
}
|
public int getTestgroup_count() {
|
return testgroup_count;
|
}
|
public int getTeststop_reason() {
|
return teststop_reason;
|
}
|
public void setFile_count(int file_count) {
|
this.file_count = file_count;
|
}
|
public void setFile_index(int file_index) {
|
this.file_index = file_index;
|
}
|
public void setYear(int year) {
|
this.year = year;
|
}
|
public void setMonth(int month) {
|
this.month = month;
|
}
|
public void setDay(int day) {
|
this.day = day;
|
}
|
public void setHour(int hour) {
|
this.hour = hour;
|
}
|
public void setMinte(int minte) {
|
this.minte = minte;
|
}
|
public void setSecond(int second) {
|
this.second = second;
|
}
|
public void setFilename(String filename) {
|
this.filename = filename;
|
}
|
public void setTest_timelong(int test_timelong) {
|
this.test_timelong = test_timelong;
|
}
|
public void setData_type(int data_type) {
|
this.data_type = data_type;
|
}
|
public void setTest_curr(float test_curr) {
|
this.test_curr = test_curr;
|
}
|
public void setTest_cap(int test_cap) {
|
this.test_cap = test_cap;
|
}
|
public void setCap_std(int cap_std) {
|
this.cap_std = cap_std;
|
}
|
public int getDownload_flag() {
|
return download_flag;
|
}
|
public int getDownload_state() {
|
return download_state;
|
}
|
public void setDownload_flag(int download_flag) {
|
this.download_flag = download_flag;
|
}
|
|
public int getNow_data_block() {
|
return now_data_block;
|
}
|
|
public int getTotal_data_block() {
|
return total_data_block;
|
}
|
|
public void setNow_data_block(int now_data_block) {
|
this.now_data_block = now_data_block;
|
}
|
|
public void setTotal_data_block(int total_data_block) {
|
this.total_data_block = total_data_block;
|
}
|
|
public void setDownload_state(int download_state) {
|
this.download_state = download_state;
|
}
|
public void setMonvol_low(float monvol_low) {
|
this.monvol_low = monvol_low;
|
}
|
public void setGroupvol_low(float groupvol_low) {
|
this.groupvol_low = groupvol_low;
|
}
|
public void setMon_count(int mon_count) {
|
this.mon_count = mon_count;
|
}
|
public void setTestgroup_count(int testgroup_count) {
|
this.testgroup_count = testgroup_count;
|
}
|
public void setTeststop_reason(int teststop_reason) {
|
this.teststop_reason = teststop_reason;
|
}
|
public float getMonvol_type() {
|
return monvol_type;
|
}
|
public void setMonvol_type(float monvol_type) {
|
this.monvol_type = monvol_type;
|
}
|
|
|
public void setFileName() {
|
filename = "F"+(2000+year);
|
if(month>=10) {
|
filename += "-"+month;
|
}else {
|
filename += "-0"+month;
|
}
|
if(day>=10) {
|
filename += "-"+day;
|
}else {
|
filename += "-0"+day;
|
}
|
if(hour>=10) {
|
filename += " "+hour;
|
}else {
|
filename += " 0"+hour;
|
}
|
if(minte >= 10) {
|
filename += ":"+minte;
|
}else {
|
filename += ":0"+minte;
|
}
|
if(second >= 10) {
|
filename += ":"+second;
|
}else {
|
filename += ":0"+second;
|
}
|
filename += ".FBO";
|
}
|
|
}
|
|
public void initDownLoadState() {
|
for(int i=0;i<files.length;i++) {
|
FBOFile fbo = files[i];
|
if(fbo.download_flag == 1) {
|
fbo.setDownload_state(FGCD_TestDataDownLoad.DownLoadState_ReadData);
|
fbo.total_data_block = 0;
|
fbo.now_data_block = 0;
|
}
|
|
}
|
|
}
|
|
|
public void cleatState() {
|
for(int i=0;i<files.length;i++) {
|
FBOFile f = files[i];
|
f.download_flag = 0;
|
f.download_state = 0;
|
f.now_data_block = 0;
|
f.total_data_block = 0;
|
}
|
}
|
|
|
|
}
|