package com.fbs9100;
|
|
public class FBS_ComBase
|
{
|
public static final int BattGroupCountMax = 4;
|
public static final int MonomerCountMax = 480;
|
public static final int FBOMonomerCountMax = 300;
|
|
public static final int CMD_STARTCNNECT = 0x01; //开始通信
|
public static final int CMD_SETDEVICEIP = 0x02; //设置设备ip
|
|
//----------------------------------------------------------------------------
|
public static final int CMD_NULL = 0x00;
|
//----------------------------------------------------------------------------
|
//------------ 重启FBS9100设备 ------------------------------------------------
|
public static final int CMD_ResetSystem = 0x10;
|
//------------ 升级FBS9100软件 ------------------------------------------------
|
public static final int CMD_SystemUpdate = 0x11;
|
//----------------------------------------------------------------------------
|
//------------ 读取设备版本号、实时任务列表等 ----------------------------------
|
public static final int CMD_GetDeviceInf = 0x15;
|
public static final int CMD_GetDeviceTaskInf = 0x17;
|
public static final int CMD_GetSyslogFileLen = 0x18;
|
public static final int CMD_GetSyslogFileStr = 0x19;
|
public static final int CMD_ClearSyslogFile = 0x1A;
|
|
public static final int CMD_Connect = 0x20;
|
public static final int CMD_GetState = 0x22;
|
//----------------------------------------------------------------------------
|
//------------ 启动放电测试和读取设置参数,读取放电测试状态----------------------
|
public static final int CMD_StartDischarge = 0x25;
|
public static final int CMD_SetDischargeParm = 0x28;
|
public static final int CMD_GetDischargeParm = 0x29;
|
public static final int CMD_GetDischargeState = 0x31;
|
//----------------------------------------------------------------------------
|
//------------ 启动内阻测试和读取内阻测试状态-----------------------------------
|
public static final int CMD_StartResDischarge = 0x32;
|
public static final int CMD_GetResTestState = 0x34;
|
//-----------------------------------------------------------------------------
|
//------------ 读取和设置电池参数-----------------------------------------------
|
public static final int CMD_GetBattParam = 0x36;
|
public static final int CMD_SetBattParam = 0x37;
|
//----------------------------------------------------------------------------
|
//------------ 启动充电测试和读取设置参数,读取充电测试状态-----------------------
|
public static final int CMD_StartCharge = 0x40;
|
public static final int CMD_SetChargeParm = 0x43;
|
public static final int CMD_GetChargeParm = 0x44;
|
public static final int CMD_GetChargeState = 0x46;
|
//-----------------------------------------------------------------------------
|
//------------ 停止任何的测试 --------------------------------------------------
|
public static final int CMD_Stop = 0x53; //停止测试
|
public static final int CMD_Suspended = 0x54; //暂停测试
|
|
//----------------------------------------------------------------------------
|
//------------ 读取电压电流、充放电测试、内阻测试数据 ---------------------------
|
public static final int CMD_GetVIData = 0x60;
|
public static final int CMD_GetMonomerData = 0x61;
|
public static final int CMD_GetMonomerRES = 0x62;
|
public static final int CMD_GetMonomerCAP = 0x63;
|
public static final int CMD_GetMonomerChargeCAP = 0x64;
|
public static final int CMD_GetMonomerTMP = 0x65;
|
//-----------------------------------------------------------------------------
|
//------------ 在线电压校准 ----------------------------------------------------
|
public static final int CMD_GetOnlineVolAdjParam = 0x6A;
|
public static final int CMD_SetOnlineVolAdjParam = 0x6B;
|
//------------ 组端电压校准 ----------------------------------------------------
|
public static final int CMD_GetBattGroupVolAdjParam = 0x6C;
|
public static final int CMD_SetBattGroupVolAdjParam = 0x6D;
|
//------------ 放电电流校准 ----------------------------------------------------
|
public static final int CMD_GetDischargeCurrAdjParam = 0x6E;
|
public static final int CMD_SetDischargeCurrAdjParam = 0x6F;
|
//------------ 充电电流校准 ----------------------------------------------------
|
public static final int CMD_GetChargeCurrAdjParam = 0x70;
|
public static final int CMD_SetChargeCurrAdjParam = 0x71;
|
//------------ 单体内阻校准 ----------------------------------------------------
|
public static final int CMD_GetBattResAdjParam = 0x72;
|
public static final int CMD_SetBattResAdjParam = 0x73;
|
//------------ 单体电压偏移/斜率校准 --------------------------------------------
|
public static final int CMD_GetMonVolAdjParam = 0x74;
|
public static final int CMD_SetMonVolAdjOffset = 0x75;
|
public static final int CMD_SetMonVolAdjSlope = 0x76;
|
public static final int CMD_ResetMonVolAdjParam = 0x77;
|
//-----------------------------------------------------------------------------
|
//------------ 设置日期时间 ----------------------------------------------------
|
public static final int CMD_SetDateTime = 0x7A;
|
//------------ 读取设置系统参数和告警参数 ---------------------------------------
|
public static final int CMD_GetSYSSetParam = 0x80;
|
public static final int CMD_SetSYSSetParam = 0x81;
|
public static final int CMD_GetAlarmParam = 0x82;
|
public static final int CMD_SetAlarmParam = 0x83;
|
//------------------------------------------------------------------------------
|
//------------ 测试类型 ---------------------------------------------------------
|
public static final int TestType_NULL = 0x00;
|
public static final int TestType_VOL = 0xF9;
|
public static final int TestType_MDISCHARGE = 0xFA;
|
public static final int TestType_MCHARGE = 0xFB;
|
public static final int TestType_Charge = 0xFC;
|
public static final int TestType_CAP = 0xFD;
|
public static final int TestType_RES = 0xFE;
|
//------------------------------------------------------------------------------
|
//------------ 电池状态 ---------------------------------------------------------
|
public static final int BattState_Float = 0x00;
|
public static final int BattState_Discharge = 0x01;
|
public static final int BattState_Charge = 0x02;
|
//------------------------------------------------------------------------------
|
//------------ 数据类型 ---------------------------------------------------------
|
public static final int DataType_Null = 0x00;
|
public static final int DataType_MonVol = 0x01;
|
public static final int DataType_MonCap = 0x02;
|
public static final int DataType_MonRes = 0x03;
|
public static final int DataType_Temp = 0x04;
|
public static final int DataType_GrpVol = 0x05;
|
public static final int DataType_Curr = 0x06;
|
public static final int DataType_MonTmp = 0x07;
|
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
//------------ FBO返回状态 ---------------------------------------------------------
|
public static final int DataReturn_Successs = 0x00;
|
public static final int DataReturn_Fail = 0x01;
|
|
|
public static byte changeIntToByte(int data)
|
{
|
return (byte)(data & 0xFF);
|
}
|
//------------------------------------------------------------------------------
|
public static short changeIntToShort(int data)
|
{
|
return (short)(data & 0xFFFF);
|
}
|
//------------------------------------------------------------------------------
|
public static byte changeShortToByte(short data)
|
{
|
return (byte)(data & 0xFF);
|
}
|
//------------------------------------------------------------------------------
|
public static int changeByteToInt(byte data)
|
{
|
int tmp = data;
|
return (tmp & 0xFF);
|
}
|
//------------------------------------------------------------------------------
|
public static int changeShortToInt(short data)
|
{
|
int tmp = data;
|
return (tmp & 0xFFFF);
|
}
|
//------------------------------------------------------------------------------
|
public static double changeShortToDouble(short data)
|
{
|
int tmp = data & 0xFFFF;
|
return (double)(tmp);
|
}
|
//------------------------------------------------------------------------------
|
public static short changeDoubleToShort(double data)
|
{
|
int tmp = (int)data;
|
return (short)(tmp & 0xFFFF);
|
}
|
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
public static double GetFDCurrent(double stdcap, int hourrate)
|
{
|
double res = 0.055;
|
switch(hourrate)
|
{
|
case 1: res = 0.514; break;
|
case 2: res = 0.306; break;
|
case 3: res = 0.250; break;
|
case 4: res = 0.200; break;
|
case 5: res = 0.166; break;
|
case 6: res = 0.146; break;
|
case 7: res = 0.131; break;
|
case 8: res = 0.118; break;
|
case 9: res = 0.108; break;
|
case 10: res = 0.100; break;
|
case 20: res = 0.055; break;
|
default: res = 0.055; break;
|
}
|
|
return (stdcap * res);
|
}
|
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
public static int GetHourRate(int stdah, int current)
|
{
|
int index = 0;
|
int value[]={514, 306, 250, 200, 166, 146, 131, 118, 108, 100, 55};
|
int res;
|
res = (current*100)/(stdah/10);
|
if(res>=514) return 1;
|
else if(res<=55) return 20;
|
else
|
{
|
for(index=0; index<10; index++)
|
{
|
if((res<=value[index]) && (res>value[index+1])) break;
|
else continue;
|
}
|
if((value[index]-res) < (res-value[index+1]))
|
{
|
return (index+1);
|
}
|
else
|
{
|
if(index+2 > 10) return (20);
|
else return (index+2);
|
}
|
}
|
}
|
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
public static double N_TO_10H(int n_H)
|
{
|
switch(n_H)
|
{
|
case 1 : return(1/0.55);
|
case 2 : return(1/0.61);
|
case 3 : return(1/0.75);
|
case 4 : return(1/0.79);
|
case 5 : return(1/0.833);
|
case 6 : return(1/0.876);
|
case 7 : return(1/0.917);
|
case 8 : return(1/0.944);
|
case 9 : return(1/0.974);
|
case 10: return(1/1);
|
case 20: return(1/1.1);
|
}
|
return 1.0;
|
}
|
//-------------------------------------------------------------------------------
|
/*
|
//-------------------------------------------------------------------------------
|
double GetMonomerCap(double STDAH, int HourRate, double SumAH, double MaxMonomerVol,
|
double MonomerVol, double MonomerVolType, int CapType)
|
{
|
if(MaxMonomerVol - MonomerVolType*0.9 == 0)
|
return 0;
|
|
if(SumAH < 0)
|
SumAH *= (-1);
|
|
double tmp_cap;
|
tmp_cap = MonomerVol - MonomerVolType * 0.9;
|
tmp_cap *= (STDAH - SumAH * N_TO_10H(HourRate));
|
tmp_cap = tmp_cap/(MaxMonomerVol - MonomerVolType*0.9);
|
if(tmp_cap < 0)
|
tmp_cap = 0;
|
|
if(CapType == CapType_Rest)
|
return tmp_cap;
|
else if(CapType == CapType_Sum)
|
return (tmp_cap + SumAH * N_TO_10H(HourRate));
|
else
|
return ((tmp_cap + SumAH * N_TO_10H(HourRate))*100 / STDAH);
|
}
|
//----------------------------------------------------------------------------------
|
*/
|
}
|
/***************************************************************************************
|
******************************* end of file (FBS_ComBase)*******************************
|
***************************************************************************************/
|