package testElectronJ;
|
|
import java.nio.ByteBuffer;
|
import java.nio.ByteOrder;
|
import java.util.Arrays;
|
import java.util.Calendar;
|
import java.util.Date;
|
|
|
/**
|
* FBO数据头数据
|
* @author LiJun
|
*
|
*/
|
public class FboDataHeadStart {
|
public static final int BYTE_LEN = 179;
|
|
public int battname_len; //电池组名称长度 1
|
public byte[] battname = new byte[60]; //电池名称 最大20个中文 60
|
public String battNameStr; //电池组名称
|
public int batt_brand_len; //电池组品牌长度 1
|
public byte[] batt_brand = new byte[18]; //电池品牌 最大6个中文 18
|
public String battBrandStr;
|
public int batt_date_len; //日期长度 1
|
public byte[] batt_date = new byte[10]; //安装日期 2000-01-01 10
|
public String batt_date_str;
|
public float batt_std_cap; //标称容量 2
|
public float batt_std_res; //标称内阻 2
|
public float batt_std_cte; //标称电导 2
|
public int batt_mon_num; //单体数量 1
|
public float batt_mon_vol; //单体电压 0.1 2 =100
|
public DateTime TestStartTime; //放电开始的时间 6
|
public int Device; //仪表类型 未使用 1
|
public int DataVersion; //数据版本 1
|
public int DataType; //数据类型;0xFD表示放电,0xFC表示充电 1
|
public int HourRate; //小时率 未使用 1
|
public int SaveInterval; //采集间隔 未使用 1
|
public float TestCur; //测试电流 未使用 2
|
public int BattGroup; //电池组数[模块个数] 未使用 2
|
public int MVLLimitCount; //单体下限个数 未使用 2
|
public int module_mon_num[] = new int[10]; //每个组压模块单体节数 目前只用5个 20
|
public float GrpVol_H_Limit; //组压模块电压平均值上限(0.1) 2
|
public float GrpVol_L_Limit; //组压模块电压平均值下限(0.1) 2
|
public float Module_Vol_H_Limit; //组压模块电压平均值上限(0.1) 2
|
public float Module_Vol_L_Limit; //组压模块电压平均值下限(0.1) 2
|
public float ENV_Temp_H_Limit; //环境温度上限(0.1-20) 2
|
public float ENV_Temp_L_Limit; //环境温度下限(0.1) 2
|
public float ENV_Humi_H_Limit; //环境湿度上限(0.1) 2
|
public float ENV_Humi_L_Limit; //环境湿度下限(0.1) 2
|
public float ChargeCurr_H_Limit; //充电电流上限(0.1) 2
|
public float DischCurr_H_Limit; //放电电流上限(0.1) 2
|
public float Cap_L_Limit; //容量下限 2
|
|
public int[] StandBy = new int[10]; //保留备用 20 179
|
|
|
public FboDataHeadStart(){
|
TestStartTime = new DateTime();
|
}
|
|
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 void setDateTime(ByteBuffer bf) {
|
if(bf.limit() < 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());
|
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 void setDataInf(byte[] buf,FboDataHeadStop fboHeadStop) {
|
if(buf.length < BYTE_LEN) {
|
System.out.println("头部数据长度异常");
|
return;
|
}
|
ByteBuffer bf = ByteBuffer.allocate(buf.length);
|
bf.order(ByteOrder.LITTLE_ENDIAN);
|
bf.put(buf);
|
bf.position(0);
|
|
battname_len = ComBase.changeByteToInt(bf.get()); //电池组名称长度 1
|
bf.get(battname); //电池名称 最大20个中文 60
|
checkBattName(); //电池组名称
|
this.batt_brand_len = ComBase.changeByteToInt(bf.get()); //电池组品牌长度 1
|
bf.get(batt_brand); //电池品牌 最大6个中文 18
|
checkBattBrand();
|
batt_date_len = ComBase.changeByteToInt(bf.get()); //日期长度 1
|
bf.get(batt_date); //安装日期 2000-01-01 10
|
checkBattDate();
|
batt_std_cap = ComBase.changeShortToInt(bf.getShort()); //标称容量 2
|
batt_std_res = ComBase.changeShortToInt(bf.getShort())/10; //标称内阻 2
|
batt_std_cte = ComBase.changeShortToInt(bf.getShort())/10; //标称电导 2
|
batt_mon_num = ComBase.changeShortToInt(bf.getShort()); //单体数量 1
|
batt_mon_vol = ComBase.changeShortToInt(bf.getShort())/10; //单体电压 0.1 2 =100
|
TestStartTime.setDateTime(bf);; //放电开始的时间 6
|
Device = ComBase.changeShortToInt(bf.getShort()); //仪表类型 未使用 1
|
System.out.println("仪表类型:"+getDeviceType(Device));
|
DataVersion = ComBase.changeShortToInt(bf.getShort()); //数据版本 1
|
DataType = ComBase.changeByteToInt(bf.get()); //数据类型;0xFD表示放电,0xFC表示充电 1
|
HourRate = ComBase.changeByteToInt(bf.get()); //小时率 未使用 1
|
SaveInterval = ComBase.changeByteToInt(bf.get()); //采集间隔 未使用 1
|
TestCur = ComBase.changeShortToFloat(bf.getShort()); //测试电流 未使用 2
|
BattGroup = ComBase.changeShortToInt(bf.getShort()); //电池组数 未使用 2
|
MVLLimitCount = ComBase.changeShortToInt(bf.getShort()); //单体下限个数 未使用 2
|
for(int i=0;i<module_mon_num.length;i++) {
|
module_mon_num[i] = ComBase.changeShortToInt(bf.getShort()); //每个组压模块单体节数 目前只用5个 20
|
System.out.println((i+1)+":单体数目:"+module_mon_num[i]);
|
}
|
GrpVol_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10; //组端电压上限 2
|
GrpVol_L_Limit = ComBase.changeShortToFloat(bf.getShort())/10; //组端电压下限 2
|
Module_Vol_H_Limit = ComBase.changeShortToFloat(bf.getShort())/1000; //单体电压上限 2
|
Module_Vol_L_Limit = ComBase.changeShortToFloat(bf.getShort())/1000; //单体电压下限 2
|
ENV_Temp_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10; //单体温度上限 2
|
ENV_Temp_L_Limit = ComBase.changeShortToFloat(bf.getShort())/10; //单体温度下限 2
|
ENV_Humi_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10; //单体湿度上限 2
|
ENV_Humi_L_Limit = ComBase.changeShortToFloat(bf.getShort())/10; //单体湿度下限 2
|
ChargeCurr_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10; //充电电流上限 2
|
DischCurr_H_Limit = ComBase.changeShortToFloat(bf.getShort())/10; //放电电流上限 2
|
Cap_L_Limit = ComBase.changeShortToFloat(bf.getShort()); //容量下限 2
|
|
for(int i =0;i<StandBy.length;i++) {
|
StandBy[i] = ComBase.changeShortToInt(bf.getShort()); //保留备用 20 179
|
}
|
System.out.println(this);
|
|
fboHeadStop.setFboStopData(bf);
|
//System.out.println("avg_curr:"+avg_curr);
|
//realcap = BattCapFactory.GetMonomerCap(STDCap,HourRate, TestCap, SMaxVol[0], MonomerVol, SMinVol[0], BattCapFactory.CapType_Real);
|
}
|
|
|
private void checkBattBrand() {
|
byte[] batt_brand_tmp = new byte[batt_brand_len];
|
System.arraycopy(this.batt_brand, 0, batt_brand_tmp, 0, batt_brand_tmp.length);
|
this.battBrandStr = new String(batt_brand_tmp);
|
//System.out.println(this.battBrandStr);
|
|
}
|
|
|
public void checkBattName() {
|
byte[] batt = new byte[battname_len];
|
System.arraycopy(this.battname, 0, batt, 0, batt.length);
|
this.battNameStr = new String(batt);
|
//System.out.println(this.battNameStr);
|
}
|
|
public void checkBattDate() {
|
byte[] date = new byte[batt_date_len];
|
System.arraycopy(this.batt_date, 0, date, 0, date.length);
|
this.batt_date_str = new String(date);
|
//System.out.println(this.batt_date_str);
|
}
|
|
public String getDeviceType(int device) {
|
String deviceType = "未知";
|
switch(device) {
|
case 0xFB : deviceType = "FBO4815-CT";break;
|
case 0xDC : deviceType = "IDCE4815-CT";break;
|
case 0x2F : deviceType = "FBO2205-CT";break;
|
case 0x2E : deviceType = "IDCE2205-CT";break;
|
case 0x26 : deviceType = "FBO2206-CT";break;
|
case 0x25 : deviceType = "IDCE2206-CT";break;
|
case 0x3F : deviceType = "FBO4830-CT";break;
|
case 0x3E : deviceType = "IDCE4830-CT";break;
|
case 0x6F : deviceType = "FBO6003-CT";break;
|
case 0x6E : deviceType = "IDCE6003-CT";break;
|
case 0x66 : deviceType = "FBO6006-CT";break;
|
case 0x67 : deviceType = "IDCE6006-CT";break;
|
case 0x1F : deviceType = "FBO1110-CT";break;
|
case 0x1E : deviceType = "IDCE1110-CT";break;
|
case 0xF3 : deviceType = "FBI-3048CT";break;
|
case 0xF1 : deviceType = "FBI-3015CT";break;
|
case 0xF4 : deviceType = "FBI-10480CT";break;
|
case 0xF5 : deviceType = "FBI-05480CT";break;
|
case 0x22 : deviceType = "FBO2210-CT";break;
|
case 0x21 : deviceType = "IDCE2210-CT";break;
|
case 0x15 : deviceType = "FBO2415-CT";break;
|
case 0x16 : deviceType = "IDCE2415-CT";break;
|
}
|
return deviceType;
|
}
|
|
|
@Override
|
public String toString() {
|
return "FboDataHeadStart [battname_len=" + battname_len + ", battname=" + Arrays.toString(battname)
|
+ ", battNameStr=" + battNameStr + ", batt_brand_len=" + batt_brand_len + ", batt_brand="
|
+ Arrays.toString(batt_brand) + ", battBrandStr=" + battBrandStr + ", batt_date_len=" + batt_date_len
|
+ ", batt_date=" + Arrays.toString(batt_date) + ", batt_date_str=" + batt_date_str + ", batt_std_cap="
|
+ batt_std_cap + ", batt_std_res=" + batt_std_res + ", batt_std_cte=" + batt_std_cte + ", batt_mon_num="
|
+ batt_mon_num + ", batt_mon_vol=" + batt_mon_vol + ", TestStartTime=" + TestStartTime + ", Device="
|
+ Device + ", DataVersion=" + DataVersion + ", DataType=" + DataType + ", HourRate=" + HourRate
|
+ ", SaveInterval=" + SaveInterval + ", TestCur=" + TestCur + ", BattGroup=" + BattGroup
|
+ ", MVLLimitCount=" + MVLLimitCount + ", module_mon_num=" + Arrays.toString(module_mon_num)
|
+ ", GrpVol_H_Limit=" + GrpVol_H_Limit + ", GrpVol_L_Limit=" + GrpVol_L_Limit + ", Module_Vol_H_Limit="
|
+ Module_Vol_H_Limit + ", Module_Vol_L_Limit=" + Module_Vol_L_Limit + ", ENV_Temp_H_Limit="
|
+ ENV_Temp_H_Limit + ", ENV_Temp_L_Limit=" + ENV_Temp_L_Limit + ", ENV_Humi_H_Limit=" + ENV_Humi_H_Limit
|
+ ", ENV_Humi_L_Limit=" + ENV_Humi_L_Limit + ", ChargeCurr_H_Limit=" + ChargeCurr_H_Limit
|
+ ", DischCurr_H_Limit=" + DischCurr_H_Limit + ", Cap_L_Limit=" + Cap_L_Limit + ", StandBy="
|
+ Arrays.toString(StandBy) + "]";
|
}
|
}
|