package com.dev.fbs9100;
|
|
import java.nio.ByteBuffer;
|
import java.nio.ByteOrder;
|
import java.util.Date;
|
|
public class FBS9100_SysState
|
{
|
public static final byte SYS_STATE_STOPPED = 0;
|
public static final byte SYS_STATE_DISCHARGING = 1;
|
public static final byte SYS_STATE_CHARGING = 2;
|
private final int BYTE_LEN = 14;
|
|
public Date Record_DateTime = new Date();
|
|
public FBS9100_DateTime DTime = new FBS9100_DateTime();
|
public int TestType = 0;
|
public int TestGroupNum = 1;
|
public int WorkState = 0;
|
public int AlarmState = 0;
|
public int OnlineVolLow = 0;
|
public int CapTestStopType = 0;
|
|
public int CommCount = 0;
|
public int ErrCommCount = 0;
|
public int RxNullErrCount = 0;
|
public long Alm_RecId = 0L;
|
public int ResBattIndexMax;
|
public int ResBattIndex;
|
public int CRC = 0;
|
|
public FBS9100_SysState clone()
|
{
|
FBS9100_SysState obj = new FBS9100_SysState();
|
|
obj.DTime = this.DTime.clone();
|
obj.TestType = this.TestType;
|
obj.TestGroupNum = this.TestGroupNum;
|
obj.WorkState = this.WorkState;
|
obj.AlarmState = this.AlarmState;
|
obj.OnlineVolLow = this.OnlineVolLow;
|
obj.CapTestStopType = this.CapTestStopType;
|
obj.CommCount = this.CommCount;
|
obj.ErrCommCount = this.ErrCommCount;
|
obj.RxNullErrCount = this.RxNullErrCount;
|
obj.CRC = this.CRC;
|
|
return obj;
|
}
|
|
public void setCommCountInc()
|
{
|
this.Record_DateTime = new Date();
|
|
this.CommCount += 1;
|
if (this.CommCount >= 90000000)
|
this.CommCount = 1;
|
}
|
|
public void setErrCommCountInc(int rx_len)
|
{
|
if (rx_len < 1) {
|
this.RxNullErrCount += 1;
|
}
|
this.ErrCommCount += 1;
|
if (this.ErrCommCount >= 90000000) {
|
this.ErrCommCount = 20;
|
}
|
if (this.RxNullErrCount >= 90000000)
|
this.RxNullErrCount = 20;
|
}
|
|
public void setDateTime(FBS9100_DateTime dt)
|
{
|
this.DTime = dt;
|
}
|
|
public boolean putByteBuffer(ByteBuffer bf)
|
{
|
if (bf.limit() < 14) {
|
return false;
|
}
|
ByteBuffer tmpbuf = bf;
|
int crc0 = tmpbuf.getShort(12) & 0xFFFF;
|
int crc1 = FBS9100_Crc16.CalCRC16(tmpbuf, 12);
|
if (crc0 != crc1) {
|
return false;
|
}
|
tmpbuf.position(0);
|
this.DTime.putByteBuffer(tmpbuf);
|
this.TestType = FBS9100_ComBase.changeByteToInt(bf.get());
|
this.TestGroupNum = FBS9100_ComBase.changeByteToInt(bf.get());
|
this.WorkState = FBS9100_ComBase.changeByteToInt(bf.get());
|
this.AlarmState = FBS9100_ComBase.changeByteToInt(bf.get());
|
this.OnlineVolLow = FBS9100_ComBase.changeByteToInt(bf.get());
|
this.CapTestStopType = FBS9100_ComBase.changeByteToInt(bf.get());
|
this.CRC = FBS9100_ComBase.changeShortToInt(bf.getShort());
|
tmpbuf.compact();
|
tmpbuf.flip();
|
return true;
|
}
|
|
public ByteBuffer getByteBuffer()
|
{
|
ByteBuffer bytebuffer = ByteBuffer.allocate(14);
|
bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
|
bytebuffer.put(this.DTime.getBytes());
|
bytebuffer.put(FBS9100_ComBase.changeIntToByte(this.TestType));
|
bytebuffer.put(FBS9100_ComBase.changeIntToByte(this.TestGroupNum));
|
bytebuffer.put(FBS9100_ComBase.changeIntToByte(this.WorkState));
|
bytebuffer.put(FBS9100_ComBase.changeIntToByte(this.AlarmState));
|
bytebuffer.put(FBS9100_ComBase.changeIntToByte(this.OnlineVolLow));
|
bytebuffer.put(FBS9100_ComBase.changeIntToByte(this.CapTestStopType));
|
|
this.CRC = FBS9100_Crc16.CalCRC16(bytebuffer, bytebuffer.position());
|
bytebuffer.putShort(FBS9100_ComBase.changeIntToShort(this.CRC));
|
bytebuffer.flip();
|
|
return bytebuffer;
|
}
|
|
public String toString()
|
{
|
return "FBS9100_SysState [BYTE_LEN=14, DTime=" + this.DTime + ", TestType=" + this.TestType +
|
", TestGroupNum=" + this.TestGroupNum + ", WorkState=" + this.WorkState + ", AlarmState=" + this.AlarmState +
|
", OnlineVolLow=" + this.OnlineVolLow + ", CommCount=" + this.CommCount + ", ErrCommCount=" + this.ErrCommCount +
|
", Alm_RecId=" + this.Alm_RecId + ", ResBattIndexMax=" + this.ResBattIndexMax + ", ResBattIndex=" + this.ResBattIndex +
|
", CRC=" + this.CRC + "]";
|
}
|
}
|
|
/* Location: C:\Users\LiJun\Desktop\公司各种设备资料\9600显示模块相关文件\后台程序\2018-09-07\BattFBS9600XSP.jar
|
* Qualified Name: com.dev.fbs9100.FBS9100_SysState
|
* JD-Core Version: 0.6.2
|
*/
|