package com.fgkj.fbo;
|
|
import java.io.File;
|
import java.io.FileInputStream;
|
import java.io.IOException;
|
import java.nio.ByteBuffer;
|
import java.nio.ByteOrder;
|
import java.util.ArrayList;
|
|
public class FboData {
|
public FboDataType m_DataType = new FboDataType();
|
public short CRC16;
|
public FboTestTime m_TestTime = new FboTestTime();
|
public int BattGroup;
|
public int BattSum;
|
public float OnlineVol;
|
public float SumVoltage;
|
public float SumCurrent;
|
public float[] SubCurrent = new float[4];
|
public float AllCap;
|
public float[] SubCap = new float[4];
|
public float[] SingleVol = new float[500];
|
|
public void setData(byte[] buf)
|
{
|
ByteBuffer bf = ByteBuffer.allocate(2048);
|
bf.order(ByteOrder.LITTLE_ENDIAN);
|
bf.put(buf);
|
bf.position(0);
|
|
CRC16 = (short) (bf.getShort()&0xFFFF);
|
m_TestTime.hour = (int) (bf.get()&0xFF);
|
m_TestTime.minute = (int) (bf.get()&0xFF);
|
m_TestTime.second = (int) (bf.get()&0xFF);
|
BattGroup = (int) (bf.get()&0xFF);
|
|
BattSum = (int) (bf.getShort()&0xFFFF);
|
if(BattSum > 500)
|
BattSum = 500;
|
else if (BattSum < 0) {
|
BattSum = 0;
|
}
|
|
OnlineVol = ((float) (bf.getShort()&0xFFFF)) / 10;
|
SumVoltage = ((float) (bf.getShort()&0xFFFF)) / 10;
|
|
SumCurrent = ((float) (bf.getShort()&0xFFFF)) / 10;
|
if(0xFD == m_DataType.TypeTag0) {
|
SumCurrent *= -1;
|
}
|
for(int n=0; n<4; n++)
|
{
|
SubCurrent[n] = ((float) (bf.getShort()&0xFFFF)) / 10;
|
if(0xFD == m_DataType.TypeTag0) {
|
SubCurrent[n] *= -1;
|
}
|
}
|
|
AllCap = ((float) (bf.getShort()&0xFFFF));
|
if(0xFD == m_DataType.TypeTag0) {
|
AllCap *= -1;
|
}
|
for(int n=0; n<4; n++)
|
{
|
SubCap[n] = ((float) (bf.getShort()&0xFFFF));
|
if(0xFD == m_DataType.TypeTag0) {
|
SubCap[n] *= -1;
|
}
|
}
|
|
for(int n=0; n<BattSum; n++)
|
{
|
SingleVol[n] = ((float) (bf.getShort()&0xFFFF)) / 1000;
|
}
|
}
|
|
public static void checkFboFile(File file, FboDataInf data_inf, ArrayList<FboData> al_fbo_data)
|
{
|
File f = file;
|
FileInputStream fis = null;
|
try {
|
fis = new FileInputStream(f);
|
byte[] buf = new byte[256];
|
if(fis.read(buf, 0, buf.length) == 256)
|
{
|
data_inf.setDataInf(buf);
|
while(true)
|
{
|
FboDataType mType = new FboDataType();
|
int tag = mType.checkDataHead(fis);
|
if((0xFD == tag) || (0xFC == tag))
|
{
|
byte[] databuf = new byte[data_inf.BattSum*2 + 32];
|
if(fis.read(databuf) == databuf.length)
|
{
|
FboData m_FboData = new FboData();
|
m_FboData.m_DataType = mType;
|
m_FboData.setData(databuf);
|
al_fbo_data.add(m_FboData);
|
}
|
}
|
if(tag == 1)
|
break;
|
}
|
}
|
|
} catch (IOException e) {
|
e.printStackTrace();
|
} finally {
|
if(null != fis)
|
{
|
try {
|
fis.close();
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
}
|
|
|
public void setData(IdcData i_data)
|
{
|
m_DataType.TypeTag0 = i_data.DataType;
|
m_DataType.TypeTag1 = i_data.DataType;
|
m_DataType.TypeTag2 = i_data.DataType;
|
m_DataType.TypeTag3 = i_data.DataType;
|
|
OnlineVol = 0;
|
SumVoltage = i_data.SumVol;
|
SumCurrent = i_data.SumCur;
|
SubCurrent[0] = SumCurrent;
|
|
AllCap = i_data.SumAH;
|
SubCap[0] = AllCap;
|
|
int param = (-1);
|
if(0xFC == m_DataType.TypeTag0) {
|
param = 1;
|
}
|
SumCurrent = Math.abs(SumCurrent) * param;
|
SubCurrent[0] = Math.abs(SubCurrent[0]) * param;
|
|
AllCap = Math.abs(AllCap) * param;
|
SubCap[0] = Math.abs(SubCap[0]) * param;
|
|
for(int n=0; n<400; n++)
|
{
|
SingleVol[n] = i_data.MonomerVol[n];
|
}
|
}
|
|
public int getMinIndex()
|
{
|
int num = 0;
|
float min = 800000;
|
for(int n=0; n<SingleVol.length; n++)
|
{
|
if((SingleVol[n] > 0.1) && (SingleVol[n] < min))
|
{
|
min = SingleVol[n];
|
num = n;
|
}
|
}
|
|
return num;
|
}
|
|
public int getMaxIndex()
|
{
|
int num = 0;
|
float max = 0;
|
for(int n=0; n<SingleVol.length; n++)
|
{
|
if((SingleVol[n] > 0.1) && (max < SingleVol[n]))
|
{
|
max = SingleVol[n];
|
num = n;
|
}
|
}
|
|
return num;
|
}
|
|
public float getMinVol()
|
{
|
float min = 800000;
|
for(int n=0; n<SingleVol.length; n++)
|
{
|
if((SingleVol[n] > 0.1) && (SingleVol[n] < min))
|
{
|
min = SingleVol[n];
|
}
|
}
|
|
return min;
|
}
|
|
public float getMaxVol()
|
{
|
float max = 0;
|
for(int n=0; n<SingleVol.length; n++)
|
{
|
if((SingleVol[n] > 0.1) && (max < SingleVol[n]))
|
{
|
max = SingleVol[n];
|
}
|
}
|
|
return max;
|
}
|
}
|