New file |
| | |
| | | package com.fgkj.mcp;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.IOException;
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import com.fgkj.bres.FileDataParseInfo_Interface;
|
| | | import com.fgkj.bres.RES_Crc16;
|
| | | import com.fgkj.data.ComBase;
|
| | | import com.fgkj.data.ComFn;
|
| | |
|
| | | /**
|
| | | * FBS充放电数据解析
|
| | | * @author LiJun
|
| | | *
|
| | | */
|
| | | public class TestDataInfo implements FileDataParseInfo_Interface{
|
| | |
|
| | | public int parse_result = PARSE_RESULT_NULL; //文件解析结果
|
| | | public int file_type = FILE_TYPE_NULL; //文件类型
|
| | | |
| | | public MonitorDataInfo testDataInfo;
|
| | | public List<FBSData> FBSDatas;
|
| | | |
| | | public TestDataInfo() {
|
| | | testDataInfo = new MonitorDataInfo();
|
| | | FBSDatas = new ArrayList<TestDataInfo.FBSData>();
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void readFileData(String filePath) {
|
| | | FileInputStream fis = null;
|
| | | try {
|
| | | File f = new File(filePath);
|
| | | if((!filePath.endsWith(".MCP") && !filePath.endsWith(".mcp")) && (!filePath.endsWith(".MCH") && !filePath.endsWith(".mch"))) {
|
| | | System.out.println("文件格式错误");
|
| | | parse_result = PARSE_RESULT_FILETYPEERR;
|
| | | return;
|
| | | }
|
| | | if(!f.exists()) {
|
| | | parse_result = PARSE_RESULT_NOTFOUNDFILE;
|
| | | System.out.println("文件不存在..........");
|
| | | return;
|
| | | }
|
| | | fis = new FileInputStream(f);
|
| | | byte[] buf = new byte[MonitorDataInfo.BYTE_LEN];
|
| | | if(fis.read(buf, 0, buf.length) == MonitorDataInfo.BYTE_LEN)
|
| | | {
|
| | | if(this.testDataInfo.setHeadData(buf)) {
|
| | | parse_result = PARSE_RESULT_SUCCESS;
|
| | | }else {
|
| | | parse_result = PARSE_RESULT_FILEERROR;
|
| | | }
|
| | | while(true)
|
| | | { |
| | | if(testDataInfo.checkDataHead(fis))
|
| | | {
|
| | | byte[] databuf = new byte[FBSData.BYTE_LEN - MVolData.BYTE_LEN +(testDataInfo.battparam.eachGroupBattCount*testDataInfo.battparam.battGroupCount)*2];
|
| | | //System.out.println("databuf.length:"+databuf.length);
|
| | | if(fis.read(databuf) == databuf.length)
|
| | | {
|
| | | FBSData fbsData = new FBSData(testDataInfo.monitorstate.testType);
|
| | | if(fbsData.setData(databuf)) {
|
| | | //System.out.println(resData);
|
| | | FBSDatas.add(fbsData);
|
| | | }
|
| | | }
|
| | | }
|
| | | if(fis.available() <1) {
|
| | | //System.out.println("解析完成");
|
| | | break;
|
| | | |
| | | }
|
| | | }
|
| | | }else {
|
| | | parse_result = PARSE_RESULT_FILEERROR;
|
| | | }
|
| | | |
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != fis)
|
| | | {
|
| | | try {
|
| | | fis.close();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 测试时长
|
| | | * @author LiJun
|
| | | *
|
| | | */
|
| | | public class TestTime{
|
| | | public static final int BYTE_LEN = 3;
|
| | | |
| | | public int hour; //时
|
| | | public int minute; //分
|
| | | public int second; //秒
|
| | | public void setTestTime(ByteBuffer bf) {
|
| | | if(bf.limit() < BYTE_LEN) {
|
| | | return;
|
| | | }
|
| | | this.hour = ComBase.changeByteToInt(bf.get());
|
| | | this.minute = ComBase.changeByteToInt(bf.get());
|
| | | this.second = ComBase.changeByteToInt(bf.get());
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | public class VolCurrData{
|
| | | public static final int BYTE_LEN = 80;
|
| | | |
| | | public static final int GROUP_COUNT_MAX = 4;
|
| | | public float onlinevol[] = new float[GROUP_COUNT_MAX];//在线电压 分辨率0.1V
|
| | | public float groupvol[] = new float[GROUP_COUNT_MAX];//组端电压 分辨率0.1V
|
| | | public int battstate[] = new int[GROUP_COUNT_MAX];//电池状态,见表2
|
| | | public float battcurr[] = new float[GROUP_COUNT_MAX];//电流 分辨率0.1A
|
| | | public int battcap[] = new int[GROUP_COUNT_MAX];//已测容量 AH
|
| | | public float batttemp[] = new float[GROUP_COUNT_MAX];//温度,预留,没使用
|
| | | public int monMAX_num[] = new int[GROUP_COUNT_MAX];//最高单体索引号
|
| | | public int monMIN_num[] = new int[GROUP_COUNT_MAX];//最低单体索引号
|
| | | public float monvolMAX[] = new float[GROUP_COUNT_MAX];//最高单体电压 0.001V
|
| | | public float monvolMIN[] = new float[GROUP_COUNT_MAX];//最低单体电压 0.001V
|
| | | |
| | | public boolean puByteBuffer(ByteBuffer bf) {
|
| | | //System.err.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
|
| | | bf.position(0);
|
| | | if(bf.remaining() < BYTE_LEN) {
|
| | | return false;
|
| | | }
|
| | | for(int i=0;i<onlinevol.length;i++) {
|
| | | onlinevol[i] = ComBase.changeShortToFloat(bf.getShort())*0.1f; //在线电压 分辨率0.1V
|
| | | }
|
| | | for(int i=0;i<groupvol.length;i++) {
|
| | | groupvol[i] = ComBase.changeShortToFloat(bf.getShort())*0.1f; //组端电压 分辨率0.1V
|
| | | }
|
| | | for(int i =0;i<battstate.length;i++) {
|
| | | battstate[i] = ComBase.changeShortToInt(bf.getShort()); //电池状态,见表2
|
| | | }
|
| | | for(int i = 0;i<battcurr.length;i++) { |
| | | battcurr[i] = ComBase.changeShortToFloat(bf.getShort())*0.1f; //电流 分辨率0.1A
|
| | | }
|
| | | for(int i=0;i<battcap.length;i++) {
|
| | | battcap[i] = ComBase.changeShortToInt(bf.getShort()); //已测容量 AH
|
| | | }
|
| | | for(int i=0;i<batttemp.length;i++) { |
| | | batttemp[i] = ComBase.changeShortToFloat(bf.getShort()); //温度,预留,没使用
|
| | | }
|
| | | for(int i=0;i<monMAX_num.length;i++) { |
| | | monMAX_num[i] = ComBase.changeShortToInt(bf.getShort()); //最高单体索引号
|
| | | }
|
| | | for(int i=0;i<monMIN_num.length;i++) { |
| | | monMIN_num[i] = ComBase.changeShortToInt(bf.getShort());//最低单体索引号
|
| | | }
|
| | | for(int i=0;i<monvolMAX.length;i++) { |
| | | monvolMAX[i] = ComBase.changeShortToFloat(bf.getShort())*0.001f;//最高单体电压 0.001V
|
| | | }
|
| | | for(int i=0;i<monvolMIN.length;i++) {
|
| | | monvolMIN[i] = ComBase.changeShortToFloat(bf.getShort())*0.001f;//最低单体电压 0.001V
|
| | | }
|
| | | bf.compact();
|
| | | //System.out.println(this);
|
| | | return true;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "VolCurrData [onlinevol=" + Arrays.toString(onlinevol) + ", groupvol=" + Arrays.toString(groupvol)
|
| | | + ", battstate=" + Arrays.toString(battstate) + ", battcurr=" + Arrays.toString(battcurr)
|
| | | + ", battcap=" + Arrays.toString(battcap) + ", batttemp=" + Arrays.toString(batttemp)
|
| | | + ", monMAX_num=" + Arrays.toString(monMAX_num) + ", monMIN_num=" + Arrays.toString(monMIN_num)
|
| | | + ", monvolMAX=" + Arrays.toString(monvolMAX) + ", monvolMIN=" + Arrays.toString(monvolMIN) + "]";
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | public class MVolData{
|
| | | public static final int BYTE_LEN = 1000;
|
| | | |
| | | public static final int MONOMER_COUNT_MAX = 500;
|
| | | public float vol[];//单体电压 偏移20000 分辨率0.001V |
| | | public MVolData(int count) {
|
| | | vol = new float[count];
|
| | | }
|
| | | public boolean puByteBuffer(ByteBuffer bf) {
|
| | | bf.position(0);
|
| | | if(bf.remaining() < vol.length*2) {
|
| | | return false;
|
| | | }
|
| | | for(int i=0;i<vol.length;i++) {
|
| | | //System.out.println(ComBase.changeShortToFloat(bf.getShort()));
|
| | | vol[i] = ComBase.changeShortToFloat(bf.getShort())*0.001f;//单体电压 偏移20000 分辨率0.001V |
| | | } |
| | | bf.compact();
|
| | | //System.out.println(this);
|
| | | return true;
|
| | | }
|
| | | @Override
|
| | | public String toString() {
|
| | | return "MVolData [vol=" + Arrays.toString(vol) + "]";
|
| | | }
|
| | | }
|
| | | |
| | | public class FBSData{
|
| | | public static final int BYTE_LEN = 5 + TestTime.BYTE_LEN+VolCurrData.BYTE_LEN + MVolData.BYTE_LEN;
|
| | | |
| | | public int dataType[] = new int[4]; //数据类型 见表1
|
| | | public int CRC16;
|
| | | public TestTime testTime; //已测试时间(HMS)
|
| | | public int battGroup; //组数
|
| | | public int battSum; //单体个数
|
| | | public VolCurrData vcData;
|
| | | public MVolData mVol;
|
| | | |
| | | public FBSData(int dataType) {
|
| | | testTime = new TestTime();
|
| | | vcData = new VolCurrData();
|
| | | for(int i=0;i<this.dataType.length;i++) {
|
| | | this.dataType[i] = dataType;
|
| | | }
|
| | | }
|
| | | |
| | | public boolean setData(byte[] databuf) {
|
| | | boolean flag = false;
|
| | | //System.out.println(databuf.length + "===" + BYTE_LEN);
|
| | | //System.out.println(ComFn.bytesToHexString(databuf, databuf.length));
|
| | | ByteBuffer bf = ByteBuffer.allocate(databuf.length + dataType.length);
|
| | | bf.order(ByteOrder.LITTLE_ENDIAN);
|
| | | bf.position(0);
|
| | | if(databuf.length < (BYTE_LEN-MVolData.BYTE_LEN)) { |
| | | return flag;
|
| | | }
|
| | | for(int i = 0;i<dataType.length;i++) {
|
| | | bf.put(ComBase.changeIntToByte(this.dataType[i]));
|
| | | }
|
| | | bf.put(databuf);
|
| | | //System.out.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
|
| | | bf.flip();
|
| | | |
| | | CRC16 = ComBase.changeShortToInt(bf.getShort(4));
|
| | | bf.putShort(4, ComBase.changeIntToShort(0));
|
| | | int crc1 = RES_Crc16.CalCRC16(bf, bf.limit());
|
| | | if(CRC16 != crc1) {
|
| | | System.err.println(CRC16 +"!="+ crc1);
|
| | | return false;
|
| | | }
|
| | | bf.position(6);
|
| | | |
| | | testTime.setTestTime(bf); //已测试时间(HMS)
|
| | | battGroup = ComBase.changeByteToInt(bf.get()); //组数
|
| | | battSum = ComBase.changeShortToInt(bf.getShort()); //单体个数
|
| | | |
| | | mVol = new MVolData(battGroup*battSum);
|
| | | bf.compact();
|
| | | |
| | | flag &= vcData.puByteBuffer(bf);
|
| | | flag &= mVol.puByteBuffer(bf);
|
| | | |
| | | return flag;
|
| | | |
| | | }
|
| | | }
|
| | |
|
| | | public class BattParam{
|
| | | public static final int BYTE_LEN = 44;
|
| | | |
| | | public int STD_CAP; //标称容量 分辨率 1AH
|
| | | public float STD_RES; //标称内阻 分辨率0.001mΩ
|
| | | public int battGroupCount; //组数
|
| | | public int eachGroupBattCount; //每组单体个数
|
| | | public float monomerVol; //单体标称电压 分辨率0.1V
|
| | | public float groupVol; //未使用
|
| | | public float battTemp; ////未使用
|
| | | public float floatChargeVol; //未使用
|
| | | public float floatChargeCurr; //未使用
|
| | | public float onlineVolLow; //未使用
|
| | | public int groupConnType; //未使用
|
| | | |
| | | public int bakeup1;
|
| | | public int bakeup2;
|
| | | public int bakeup3;
|
| | | public int bakeup4;
|
| | | public int bakeup5;
|
| | | public int bakeup6;
|
| | | public int bakeup7;
|
| | | public int bakeup8;
|
| | | public int bakeup9;
|
| | | public int bakeup10;
|
| | | |
| | | public int CRC; //未使用
|
| | |
|
| | | public boolean putByteBuffer(ByteBuffer bf) {
|
| | | if(bf.remaining() < BYTE_LEN) {
|
| | | return false;
|
| | | }
|
| | | bf.position(0);
|
| | | |
| | | STD_CAP = ComBase.changeShortToInt(bf.getShort()); //标称容量 分辨率 1AH
|
| | | STD_RES = ComBase.changeShortToFloat(bf.getShort()) * 0.001f; //标称内阻 分辨率0.001mΩ
|
| | | battGroupCount = ComBase.changeShortToInt(bf.getShort()); //组数
|
| | | eachGroupBattCount = ComBase.changeShortToInt(bf.getShort()); //每组单体个数
|
| | | monomerVol = ComBase.changeShortToFloat(bf.getShort())*0.1f; //单体标称电压 分辨率0.1V
|
| | | groupVol = ComBase.changeShortToFloat(bf.getShort()); //未使用
|
| | | battTemp = ComBase.changeShortToFloat(bf.getShort()); ////未使用
|
| | | floatChargeVol = ComBase.changeShortToFloat(bf.getShort()); //未使用
|
| | | floatChargeCurr = ComBase.changeShortToFloat(bf.getShort()); //未使用
|
| | | onlineVolLow = ComBase.changeShortToFloat(bf.getShort()); //未使用
|
| | | groupConnType = ComBase.changeShortToInt(bf.getShort()); //未使用
|
| | | |
| | | bakeup1 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup2 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup3 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup4 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup5 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup6 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup7 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup8 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup9 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup10 = ComBase.changeShortToInt(bf.getShort());
|
| | | |
| | | CRC = ComBase.changeShortToInt(bf.getShort());
|
| | | |
| | | //System.out.println(this);
|
| | | //System.out.println("bf.limit()"+bf.limit());
|
| | | bf.compact();
|
| | | //System.out.println("bf.limit()"+bf.limit());
|
| | | return true;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "BattParam [STD_CAP=" + STD_CAP + ", STD_RES=" + STD_RES + ", battGroupCount=" + battGroupCount
|
| | | + ", eachGroupBattCount=" + eachGroupBattCount + ", monomerVol=" + monomerVol + ", groupVol="
|
| | | + groupVol + ", battTemp=" + battTemp + ", floatChargeVol=" + floatChargeVol + ", floatChargeCurr="
|
| | | + floatChargeCurr + ", onlineVolLow=" + onlineVolLow + ", groupConnType=" + groupConnType
|
| | | + ", bakeup1=" + bakeup1 + ", bakeup2=" + bakeup2 + ", bakeup3=" + bakeup3 + ", bakeup4=" + bakeup4
|
| | | + ", bakeup5=" + bakeup5 + ", bakeup6=" + bakeup6 + ", bakeup7=" + bakeup7 + ", bakeup8=" + bakeup8
|
| | | + ", bakeup9=" + bakeup9 + ", bakeup10=" + bakeup10 + ", CRC=" + CRC + "]";
|
| | | }
|
| | | |
| | | |
| | | }
|
| | | |
| | | public class SYSMonitorParam{
|
| | | public static final int BYTE_LEN = 46;
|
| | | |
| | | public int monitorEN;
|
| | | public float disCurr;
|
| | | public float disCap;
|
| | | public int disTime;
|
| | | public float groupVol_LOW;
|
| | | public float monomerVol_LOW;
|
| | | public int monomerLowCount;
|
| | | public int battGroupCount;
|
| | | public int onlineVolLowAction;
|
| | | public float chrCurr;
|
| | | public float chrCap;
|
| | | public int chrTime;
|
| | |
|
| | | public int bakeup1;
|
| | | public int bakeup2;
|
| | | public int bakeup3;
|
| | | public int bakeup4;
|
| | | public int bakeup5;
|
| | | public int bakeup6;
|
| | | public int bakeup7;
|
| | | public int bakeup8;
|
| | | public int bakeup9;
|
| | | public int bakeup10;
|
| | |
|
| | | public int CRC;
|
| | |
|
| | | public boolean putByteBuffer(ByteBuffer bf) {
|
| | | if(bf.remaining() < BYTE_LEN) {
|
| | | return false;
|
| | | }
|
| | | bf.position(0);
|
| | | |
| | | monitorEN = ComBase.changeShortToInt(bf.getShort());
|
| | | disCurr = ComBase.changeShortToFloat(bf.getShort());
|
| | | disCap = ComBase.changeShortToFloat(bf.getShort());
|
| | | disTime = ComBase.changeShortToInt(bf.getShort());
|
| | | groupVol_LOW = ComBase.changeShortToFloat(bf.getShort());
|
| | | monomerVol_LOW = ComBase.changeShortToFloat(bf.getShort());
|
| | | monomerLowCount = ComBase.changeShortToInt(bf.getShort());
|
| | | battGroupCount = ComBase.changeShortToInt(bf.getShort());
|
| | | onlineVolLowAction = ComBase.changeShortToInt(bf.getShort());
|
| | | chrCurr = ComBase.changeShortToFloat(bf.getShort());
|
| | | chrCap = ComBase.changeShortToInt(bf.getShort());
|
| | | chrTime = ComBase.changeShortToInt(bf.getShort());
|
| | |
|
| | | bakeup1 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup2 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup3 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup4 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup5 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup6 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup7 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup8 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup9 = ComBase.changeShortToInt(bf.getShort());
|
| | | bakeup10 = ComBase.changeShortToInt(bf.getShort());
|
| | |
|
| | | CRC = ComBase.changeShortToInt(bf.getShort());
|
| | | |
| | | //System.out.println(this);
|
| | | bf.compact();
|
| | | return true;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "SYSMonitorParam [monitorEN=" + monitorEN + ", disCurr=" + disCurr + ", disCap=" + disCap
|
| | | + ", disTime=" + disTime + ", groupVol_LOW=" + groupVol_LOW + ", monomerVol_LOW=" + monomerVol_LOW
|
| | | + ", monomerLowCount=" + monomerLowCount + ", battGroupCount=" + battGroupCount
|
| | | + ", onlineVolLowAction=" + onlineVolLowAction + ", chrCurr=" + chrCurr + ", chrCap=" + chrCap
|
| | | + ", chrTime=" + chrTime + ", bakeup1=" + bakeup1 + ", bakeup2=" + bakeup2 + ", bakeup3=" + bakeup3
|
| | | + ", bakeup4=" + bakeup4 + ", bakeup5=" + bakeup5 + ", bakeup6=" + bakeup6 + ", bakeup7=" + bakeup7
|
| | | + ", bakeup8=" + bakeup8 + ", bakeup9=" + bakeup9 + ", bakeup10=" + bakeup10 + ", CRC=" + CRC + "]";
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | public class SYSMonitorState{
|
| | | public static final int BYTE_LEN = 46;
|
| | | |
| | | public DateTime startDT; //启动放电的日期时间
|
| | | public DateTime stopDT; //终止放电的日期时间
|
| | | public TestTime test_Time; //已测试时间(HMS)
|
| | | public int testState; //监测状态(MONITOR_STATE_) //0:停止监测 1:放电监测 2:充电监测
|
| | | public int testType; //测试类型 0xFA:放电 0xFB:充电
|
| | | public int testGroupCount; //unused
|
| | | public int saveDataEN; //保存数据标识
|
| | | public int backUp; //reserved
|
| | | public int restTest_Time[] = new int[4]; //剩余容量可放电时间(HMS)
|
| | | public double testCap[] = new double[4]; //每组已测试容量 单位AH 显示一位小数
|
| | | public double groupCap[] = new double[4]; //每组实际容量 单位AH 显示一位小数
|
| | | public double groupRestCap[] = new double[4]; //每组剩余容量 单位AH 显示一位小数
|
| | |
|
| | | public int CRC; //未使用
|
| | |
|
| | | public SYSMonitorState() {
|
| | | startDT = new DateTime(); //启动放电的日期时间
|
| | | stopDT = new DateTime(); //终止放电的日期时间
|
| | | test_Time = new TestTime(); //已测试时间(HMS)
|
| | | }
|
| | | |
| | | public boolean putByteBuffer(ByteBuffer bf) {
|
| | | //System.err.println("bf.remaining():"+bf.remaining());
|
| | | if(bf.remaining() < BYTE_LEN) {
|
| | | return false;
|
| | | }
|
| | | bf.position(0);
|
| | | |
| | | startDT.setDateTime(bf); //启动放电的日期时间
|
| | | stopDT.setDateTime(bf); //终止放电的日期时间
|
| | | test_Time.setTestTime(bf); //已测试时间(HMS)
|
| | | testState = ComBase.changeByteToInt(bf.get()); //监测状态(MONITOR_STATE_) //0:停止监测 1:放电监测 2:充电监测
|
| | | testType = ComBase.changeByteToInt(bf.get()); //测试类型 0xFA:放电 0xFB:充电
|
| | | testGroupCount = ComBase.changeByteToInt(bf.get()); //unused
|
| | | saveDataEN = ComBase.changeByteToInt(bf.get()); //保存数据标识
|
| | | backUp = ComBase.changeByteToInt(bf.get()); //reserved
|
| | | for(int i=0;i<restTest_Time.length;i++) {
|
| | | restTest_Time[i] = bf.getInt(); //剩余容量可放电时间(HMS)
|
| | | }
|
| | | for(int i=0;i<testCap.length;i++) {
|
| | | testCap[i] = bf.getDouble(); //每组已测试容量 单位AH 显示一位小数
|
| | | |
| | | }
|
| | | |
| | | for(int i=0;i<groupCap.length;i++) {
|
| | | groupCap[i] = bf.getDouble(); //每组实际容量 单位AH 显示一位小数
|
| | | }
|
| | | |
| | | for(int i=0;i<groupRestCap.length;i++) {
|
| | | groupRestCap[i] = bf.getDouble(); //每组剩余容量 单位AH 显示一位小数
|
| | | }
|
| | | |
| | | CRC = ComBase.changeShortToInt(bf.getShort());
|
| | | //System.out.println(this);
|
| | | return true;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "SYSMonitorState [startDT=" + startDT + ", stopDT=" + stopDT + ", test_Time=" + test_Time
|
| | | + ", testState=" + testState + ", testType=" + testType + ", testGroupCount=" + testGroupCount
|
| | | + ", saveDataEN=" + saveDataEN + ", backUp=" + backUp + ", restTest_Time="
|
| | | + Arrays.toString(restTest_Time) + ", testCap=" + Arrays.toString(testCap) + ", groupCap="
|
| | | + Arrays.toString(groupCap) + ", groupRestCap=" + Arrays.toString(groupRestCap) + ", CRC=" + CRC
|
| | | + "]";
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 测试数据数据头
|
| | | * @author LiJun
|
| | | *
|
| | | */
|
| | | public class MonitorDataInfo{
|
| | | public static final int BYTE_LEN = BattParam.BYTE_LEN + SYSMonitorParam.BYTE_LEN + SYSMonitorState.BYTE_LEN;
|
| | | |
| | | public BattParam battparam; //电池参数
|
| | | public SYSMonitorParam monitorparam; //未使用
|
| | | public SYSMonitorState monitorstate;
|
| | | |
| | | public MonitorDataInfo() {
|
| | | battparam = new BattParam();
|
| | | monitorparam = new SYSMonitorParam();
|
| | | monitorstate = new SYSMonitorState();
|
| | | }
|
| | | |
| | | public boolean checkDataHead(FileInputStream fis)
|
| | | {
|
| | | boolean check_ok = false;
|
| | | boolean file_end = false;
|
| | | byte[] tag = new byte[1]; |
| | | try {
|
| | | while(true)
|
| | | {
|
| | | int n = 0;
|
| | | for(n=0; n<4; n++)
|
| | | {
|
| | | if(1 != fis.read(tag, 0, 1))
|
| | | {
|
| | | file_end = true;
|
| | | break;
|
| | | }
|
| | | if((0xFA != (tag[0]&0xFF)) && (0xFB != (tag[0]&0xFF)))
|
| | | {
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if(n >= 4)
|
| | | {
|
| | | if(tag[0] == 0xFA) {
|
| | | file_type = FILE_TYPE_MCP;
|
| | | }
|
| | | if(tag[0] == 0xFB) {
|
| | | file_type = FILE_TYPE_MCH;
|
| | | }
|
| | | check_ok = true;
|
| | | break;
|
| | | }
|
| | | if(true == file_end)
|
| | | {
|
| | | break;
|
| | | }
|
| | | }
|
| | | } catch (IOException e) {
|
| | | //e.printStackTrace();
|
| | | } |
| | | return check_ok;
|
| | | }
|
| | |
|
| | | public boolean setHeadData(byte[] buf) {
|
| | | boolean flag = false;
|
| | | if(buf.length < BYTE_LEN) {
|
| | | return flag;
|
| | | }
|
| | | ByteBuffer bf = ByteBuffer.allocate(buf.length);
|
| | | bf.order(ByteOrder.LITTLE_ENDIAN);
|
| | | bf.position(0);
|
| | | bf.put(buf);
|
| | | bf.flip();
|
| | | //System.out.println("bf len:"+bf.remaining());
|
| | | flag = battparam.putByteBuffer(bf);
|
| | | //System.out.println(battparam);
|
| | | bf.position(0);
|
| | | //System.out.println("bf len:"+bf.remaining());
|
| | | flag &= monitorparam.putByteBuffer(bf);
|
| | | bf.position(0);
|
| | | flag &= monitorstate.putByteBuffer(bf);
|
| | | |
| | | return flag;
|
| | | }
|
| | | }
|
| | | public class DateTime{
|
| | | private static final int BYTE_LEN = 6;
|
| | | public int year;
|
| | | public int month;
|
| | | public int day;
|
| | | public int hour;
|
| | | public int minute;
|
| | | public int second;
|
| | | |
| | | public Date time;
|
| | | |
| | | public DateTime() {
|
| | | }
|
| | | |
| | | public void setDateTime(ByteBuffer bf) {
|
| | | if(bf.remaining()< BYTE_LEN) {
|
| | | return;
|
| | | }
|
| | | this.year = ComBase.changeByteToInt(bf.get());
|
| | | this.month = ComBase.changeByteToInt(bf.get());
|
| | | this.day = ComBase.changeByteToInt(bf.get());
|
| | | this.hour = ComBase.changeByteToInt(bf.get());
|
| | | this.minute = ComBase.changeByteToInt(bf.get());
|
| | | this.second = ComBase.changeByteToInt(bf.get());
|
| | | |
| | | time = getFBODateTime();
|
| | | //System.out.println(year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second);
|
| | | }
|
| | | |
| | | public Date getFBODateTime() {
|
| | | Calendar c = Calendar.getInstance();
|
| | | c.set(2000+year, month, day, hour, minute, second);
|
| | | return c.getTime();
|
| | | //return Com.get_DT_FromStr(year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second, Com.DTF_YMDhms);
|
| | | }
|
| | | }
|
| | | |
| | | public static void main(String[] args) {
|
| | | TestDataInfo info = new TestDataInfo();
|
| | | //info.readFileData("D:\\桌面文件备份\\公司各种设备资料\\FBS存储文件解析/M2021-06-22 13.08.40.MCP");
|
| | | //info.readFileData("D:\\桌面文件备份\\公司各种设备资料\\FBS存储文件解析/M2021-06-22 13.12.45.MCH");
|
| | | info.readFileData("D:\\桌面文件备份\\公司各种设备资料\\FBS存储文件解析/M2021-08-13 09.40.06.MCP");
|
| | | |
| | | }
|
| | | }
|