package com.dev.fbs9100;
|
|
import java.nio.ByteBuffer;
|
import java.nio.ByteOrder;
|
|
public class FBS9100_StatAndParam {
|
private final int BYTE_LEN = 6;
|
|
public int dev_id = 0;
|
public String dev_ipaddr = "127.0.0.1";
|
|
public int op_cmd = FBS9100_ComBase.CMD_NULL;
|
public int test_type = FBS9100_ComBase.TestType_NULL;
|
public String dev_name;
|
|
public FBS9100_VCData m_FBS_VCData = new FBS9100_VCData();
|
public FBS9100_ParamDischarge m_FBS_DiscParam = new FBS9100_ParamDischarge();
|
public FBS9100_ParamDischarge m_FBS_DiscParamFromDev = new FBS9100_ParamDischarge();
|
public FBS9100_CMCC_Power m_CMCC_Power = new FBS9100_CMCC_Power();
|
|
public int CRC = 0;
|
|
public FBS9100_StatAndParam(String ipaddr, int devid)
|
{
|
dev_ipaddr = ipaddr;
|
dev_id = devid;
|
}
|
|
public boolean putByteBuffer(final ByteBuffer bf)
|
{
|
if(bf.limit() != BYTE_LEN){
|
//System.out.println("limit´íÎó"+bf.limit());
|
return false;
|
}
|
ByteBuffer tmpbuf = bf;
|
/*int id = */tmpbuf.getInt();
|
int crc0 = tmpbuf.getShort() & 0xFFFF;
|
int crc1 = FBS9100_Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
|
if(crc0 != crc1){
|
System.out.println("crc´íÎó");
|
return false;
|
}
|
tmpbuf.position(0);
|
|
dev_id = tmpbuf.getInt();
|
|
|
tmpbuf.compact();
|
tmpbuf.flip();
|
|
return true;
|
}
|
|
public ByteBuffer getByteBuffer()
|
{
|
ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
|
bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
|
//bytebuffer.putShort(FBS9100_ComBase.changeIntToShort(dev_id));
|
bytebuffer.putInt(dev_id);
|
CRC = FBS9100_Crc16.CalCRC16(bytebuffer, bytebuffer.position());
|
bytebuffer.putShort(FBS9100_ComBase.changeIntToShort(CRC));
|
|
bytebuffer.flip();
|
|
//System.out.println("bytebuffer limit"+bytebuffer.limit());
|
return bytebuffer;
|
}
|
|
@Override
|
public String toString() {
|
return "FBS9100_StatAndParam [BYTE_LEN=" + BYTE_LEN + ", dev_id=" + dev_id + ", dev_ipaddr=" + dev_ipaddr
|
+ ", op_cmd=" + op_cmd + ", test_type=" + test_type + "]";
|
}
|
}
|