package com.fgkj.fbs5100;
|
|
import java.io.FileInputStream;
|
import java.io.IOException;
|
import java.nio.ByteBuffer;
|
import java.nio.ByteOrder;
|
import java.util.Arrays;
|
|
public class FBS5100_Alarm {
|
public static final int ALMITEM_CAP1 = 0; //组1容量告警
|
public static final int ALMITEM_CAP2 = 1; //组2容量告警
|
public static final int ALMITEM_CAP3 = 2; //组3容量告警
|
public static final int ALMITEM_CAP4 = 3; //组4容量告警
|
public static final int ALMITEM_INPUTVOL = 4; //输入电压告警
|
public static final int ALMITEM_AC_DOWM = 5; //交流失电
|
public static final int ALMITEM_GROUPVOL1 = 6; //组1电压告警
|
public static final int ALMITEM_GROUPVOL2 = 7; //组2电压告警
|
public static final int ALMITEM_GROUPVOL3 = 8; //组3电压告警
|
public static final int ALMITEM_GROUPVOL4 = 9; //组4电压告警
|
public static final int ALMITEM_BOOST_FAULT = 10; //升压模块故障
|
public static final int ALMITEM_BUCK_FAULT = 11; //降压模块故障
|
public static final int ALMITEM_NBCOMM_FAULT = 12; //逆变通信故障
|
public static final int ALMITEM_ACDC_FAULT = 13; //电源故障
|
public static final int ALMITEM_COOLER_TEMP = 14; //散热器温度
|
public static final int ALMITEM_INNER_TEMP = 15; //内部温度
|
|
public static final int BYTE_LEN = 16;
|
|
public int SYNCode[] = new int[2]; //AA AA
|
|
public int AlarmItem; //告警类型
|
public int AlarmType; //1-超出上限 或 产生告警 2-超出下限
|
public float AlarmValue; //告警值
|
public FBS5100_DateTime StartTime; //告警开始时间
|
public FBS5100_DateTime EndTime; //暂未启用,不要显示
|
|
|
public FBS5100_Alarm() {
|
StartTime = new FBS5100_DateTime();
|
EndTime = new FBS5100_DateTime();
|
}
|
|
public boolean putByteBuffer(final byte[] buf)
|
{
|
|
ByteBuffer bf = ByteBuffer.allocate(buf.length);
|
bf.order(ByteOrder.LITTLE_ENDIAN);
|
bf.put(buf);
|
|
if(bf.limit() != BYTE_LEN){
|
return false;
|
}
|
ByteBuffer tmpbuf = bf;
|
|
tmpbuf.position(0);
|
|
AlarmItem = FBS5100_ComBase.changeByteToInt(tmpbuf.get()); //告警类型
|
AlarmType = FBS5100_ComBase.changeByteToInt(tmpbuf.get()); //1-超出上限 或 产生告警 2-超出下限
|
AlarmValue = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; //告警值
|
StartTime.putByteBuffer(tmpbuf); //告警开始时间
|
EndTime.putByteBuffer(tmpbuf); //暂未启用,不要显示
|
|
tmpbuf.compact();
|
tmpbuf.flip();
|
|
return true;
|
}
|
|
|
public int checkDataHead(FileInputStream fis)
|
{
|
boolean file_end = false;
|
byte type_tag = 0;
|
byte[] tag = new byte[1];
|
try {
|
while(true)
|
{
|
type_tag = 0;
|
int n = 0;
|
for(n=0; n<2; n++)
|
{
|
if(1 != fis.read(tag, 0, 1))
|
{
|
file_end = true;
|
break;
|
}
|
if((0xAA != (tag[0]&0xFF)))
|
{
|
break;
|
}
|
}
|
|
if(n >= 2)
|
{
|
type_tag = tag[0];
|
break;
|
}
|
if(true == file_end)
|
{
|
type_tag = 1;
|
break;
|
}
|
}
|
} catch (IOException e) {
|
//e.printStackTrace();
|
}
|
setType(type_tag&0xFF);
|
|
return (type_tag&0xFF);
|
}
|
|
|
private void setType(int synCode) {
|
for(int i = 0 ; i < SYNCode.length ; i++) {
|
SYNCode[i] = synCode;
|
}
|
|
}
|
|
@Override
|
public String toString() {
|
return "FBS5100_Alarm [SYNCode=" + Arrays.toString(SYNCode) + ", AlarmItem=" + AlarmItem + ", AlarmType="
|
+ AlarmType + ", AlarmValue=" + AlarmValue + ", StartTime=" + StartTime + ", EndTime=" + EndTime + "]";
|
}
|
|
|
|
}
|