| | |
| | | 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 int file_count; //当前文件数
|
| | | public int file_total; //数据文件总数
|
| | |
|
| | | public int total_data_block; //总的数据块数
|
| | | public int now_data_block; //当前数据块数目
|
| | | private int download_state; //当前下载状态
|
| | | private int stop_reason; //结束原因
|
| | | |
| | | public FBOFile[] files = new FBOFile[8]; //读取的历史文件
|
| | |
|
| | | public FGCD_TestFBOFile(int dev_id) {
|
| | |
| | | for(int i=0;i<files.length;i++) {
|
| | | files[i] = new FBOFile();
|
| | | }
|
| | | }
|
| | | |
| | | public void initDownLoadState() {
|
| | | total_data_block = 0; //总的数据块数
|
| | | now_data_block = 0; //当前数据块数目
|
| | | download_state = FGCD_TestDataDownLoad.DownLoadState_ReadData; //当前下载状态
|
| | | }
|
| | |
|
| | | public FGCD_Cmd createCmd(int cmd) {
|
| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | |
| | | public int getDownload_state() {
|
| | | return download_state;
|
| | | }
|
| | |
|
| | | public int getStop_reason() {
|
| | | return stop_reason;
|
| | | }
|
| | |
|
| | | public void setDownload_state(int download_state) {
|
| | | this.download_state = download_state;
|
| | | }
|
| | |
|
| | | 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<this.file_count;i++) {
|
| | | 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 = 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())); //单体电压类型
|
| | | |
| | | 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())); //单体电压类型
|
| | | |
| | | }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;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | public int mon_count; //单体个数
|
| | | public int testgroup_count; //测试第几组得到的数据
|
| | | public int teststop_reason; //停止原因
|
| | | public float monvol_type; //单体电压类型
|
| | | public float monvol_type; //单体电压类型
|
| | | public int download_flag; //下载标识
|
| | | public int download_state; //下载状态
|
| | | |
| | | 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; //下载状态
|
| | | }
|
| | |
|
| | | public int getFile_count() {
|
| | | return file_count;
|
| | |
| | | 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;
|
| | | if(this.download_flag == FGCD_TestDataDownLoad.DownloadFlag_Start) {
|
| | | this.download_state = FGCD_TestDataDownLoad.DownLoadState_ReadData;
|
| | | }
|
| | | }
|
| | | 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 setFileName() {
|
| | | filename = "F"+(2000+year);
|
| | | if(month>10) {
|
| | | if(month>=10) {
|
| | | filename += "-"+month;
|
| | | }else {
|
| | | filename += "-0"+month;
|
| | | }
|
| | | if(day>10) {
|
| | | if(day>=10) {
|
| | | filename += "-"+day;
|
| | | }else {
|
| | | filename += "-0"+day;
|
| | | }
|
| | | if(hour>10) {
|
| | | if(hour>=10) {
|
| | | filename += " "+hour;
|
| | | }else {
|
| | | filename += " 0"+hour;
|
| | | }
|
| | | if(second > 10) {
|
| | | if(minte >= 10) {
|
| | | filename += ":"+minte;
|
| | | }else {
|
| | | filename += ":0"+minte;
|
| | | }
|
| | | if(second >= 10) {
|
| | | filename += ":"+second;
|
| | | }else {
|
| | | filename += ":0"+second;
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FGCD_TestFBOFile [dev_id=" + dev_id + ", op_cmd=" + op_cmd + ", battgroupid=" + battgroupid
|
| | | + ", file_index=" + file_index + ", file_count=" + file_count + ", file_total=" + file_total
|
| | | + ", total_data_block=" + total_data_block + ", now_data_block=" + now_data_block + ", download_state="
|
| | | + download_state + ", stop_reason=" + stop_reason + "]";
|
| | | }
|
| | | |
| | | }
|