New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | |
|
| | |
|
| | | public class FBS5100_BattParam {
|
| | | public static final int BYTE_LEN = 44; //常规BTS长度
|
| | | |
| | | public int op_cmd = 0;
|
| | | |
| | | public float STD_CAP;
|
| | | public float STD_RES;
|
| | | public int BattGroupCount; //电池组数(1~4) |
| | | public int EachGroupBattCount; //每组节数(1~15)
|
| | | public float MonomerVol; |
| | | public float GroupVol;
|
| | | public float BattTemp;
|
| | | public float FloatChargeVol; //浮充电压 (0.1V, 1.8~28.8)
|
| | | public float FloatChargeCurr; //浮充电流阈值(0.1A 0.5~20.0)
|
| | | public float OnlineVolLow; //在线电压低阈值(0.1V 30.0~56.0)
|
| | | public int GroupConnType;
|
| | | |
| | | public float JunChargeVol; //均充电压(0.1V, 30.0~56.0)
|
| | | |
| | | public int bakeup2;
|
| | | public int bakeup3;
|
| | | public int bakeup4;
|
| | | public int bakeup5;
|
| | | public int bakeup6;
|
| | | public int bakeup7;
|
| | | public int bakeup8;
|
| | | public int bakeup9;
|
| | | public int bakeup10;
|
| | | |
| | | public int CRC = 0;
|
| | | |
| | | /**
|
| | | * 复制一个当前对象(引用不同);
|
| | | */
|
| | | public FBS5100_BattParam clone()
|
| | | {
|
| | | FBS5100_BattParam obj = null; |
| | | try
|
| | | {
|
| | | obj = (FBS5100_BattParam)super.clone();
|
| | | }
|
| | | catch(CloneNotSupportedException e)
|
| | | {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return obj;
|
| | | }
|
| | | |
| | | /**
|
| | | * 清空当前对象
|
| | | */
|
| | | public void clear()
|
| | | {
|
| | | STD_CAP = 0.0f;
|
| | | STD_RES = 0.0f;
|
| | | BattGroupCount = 0;
|
| | | EachGroupBattCount = 0;
|
| | | MonomerVol = 0.0f;
|
| | | GroupVol = 0.0f;
|
| | | BattTemp = 0.0f;
|
| | | FloatChargeVol = 0.0f;
|
| | | FloatChargeCurr = 0.0f;
|
| | | OnlineVolLow = 0.0f;
|
| | | GroupConnType = 0;
|
| | | |
| | | JunChargeVol = 0f;
|
| | | |
| | | bakeup2 = 0;
|
| | | bakeup3 = 0;
|
| | | bakeup4 = 0;
|
| | | bakeup5 = 0;
|
| | | bakeup6 = 0;
|
| | | bakeup7 = 0;
|
| | | bakeup8 = 0;
|
| | | bakeup9 = 0;
|
| | | bakeup10 = 0;
|
| | | |
| | | CRC = 0;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 将bytebuffer中的数据取出放入该对象的属性中,并返回是否取出成功
|
| | | * |
| | | * @param bf
|
| | | * @return
|
| | | */
|
| | | public boolean putByteBuffer(final ByteBuffer bf)
|
| | | {
|
| | | if(bf.limit() < BYTE_LEN) {
|
| | | //System.out.println("长度错误");
|
| | | return false;
|
| | | }
|
| | | ByteBuffer tmpbuf = bf;
|
| | | int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
|
| | | int crc1 = FBS5100_Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
|
| | | if(crc0 != crc1) {
|
| | | System.out.println("FBS5100_BattParam" + crc0 + "==" + crc1);
|
| | | return false;
|
| | | }
|
| | | tmpbuf.position(0);
|
| | | STD_CAP = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort());
|
| | | STD_RES = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())*10;//uΩ
|
| | | BattGroupCount = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | EachGroupBattCount = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | MonomerVol = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;
|
| | | GroupVol = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort());
|
| | | BattTemp = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;
|
| | | FloatChargeVol = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;
|
| | | FloatChargeCurr = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;
|
| | | OnlineVolLow = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;
|
| | | GroupConnType = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | JunChargeVol = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; |
| | | |
| | | bakeup2 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup3 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup4 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup5 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup6 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup7 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup8 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup9 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup10 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | |
| | | CRC = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | tmpbuf.compact();
|
| | | tmpbuf.flip();
|
| | | //System.out.println(this);
|
| | | return true;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 将数据放入bytebuffer中并返回
|
| | | * @return
|
| | | */
|
| | | public ByteBuffer getByteBuffer()
|
| | | {
|
| | | ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
|
| | | bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort(STD_CAP));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort(STD_RES/10));//uΩ
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(BattGroupCount));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(EachGroupBattCount));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort(MonomerVol*10));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort(GroupVol));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort(BattTemp*10));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort(FloatChargeVol*10));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort(FloatChargeCurr*10));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort(OnlineVolLow*10));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(GroupConnType));
|
| | | |
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort(JunChargeVol*10));
|
| | | |
| | | |
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(bakeup2));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(bakeup3));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(bakeup4));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(bakeup5));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(bakeup6));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(bakeup7));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(bakeup8));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(bakeup9));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(bakeup10));
|
| | | |
| | | CRC = FBS5100_Crc16.CalCRC16(bytebuffer, bytebuffer.position());
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(CRC));
|
| | | |
| | | bytebuffer.flip();
|
| | | |
| | | return bytebuffer;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS5100_BattParam [STD_CAP=" + STD_CAP + ", STD_RES=" + STD_RES + ", BattGroupCount=" + BattGroupCount
|
| | | + ", EachGroupBattCount=" + EachGroupBattCount + ", MonomerVol=" + MonomerVol + ", GroupVol=" + GroupVol
|
| | | + ", BattTemp=" + BattTemp + ", FloatChargeVol=" + FloatChargeVol + ", FloatChargeCurr="
|
| | | + FloatChargeCurr + ", OnlineVolLow=" + OnlineVolLow + ", GroupConnType=" + GroupConnType
|
| | | + ", JunChargeVol=" + JunChargeVol + "]";
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | | import java.util.Arrays;
|
| | |
|
| | | import com.fgkj.data.ComFn;
|
| | |
|
| | | public class FBS5100_CapState {
|
| | | public static final int BYTE_LEN = 214; //常规BTS长度
|
| | | |
| | | |
| | | public FBS5100_DateTime StartDT; //启动放电的日期时间
|
| | | public FBS5100_DateTime StopDT; //终止放电的日期时间
|
| | | public FBS5100_TestTime Test_Time; //已测试时间(HMS)
|
| | | public int TestState; //测试状态(停止/暂停/放电)
|
| | | public int TestType; //测试类型(放电/充电)
|
| | | public int TestGroupNum; //被测试电池组编号(1~4)
|
| | | public int SaveDataEN; //保存数据标识
|
| | | public int NT_DCDC_State; //备用,DCDC模块工作状态
|
| | | |
| | | public int MonomerLowCount[] = new int[FBS5100_ComBase.BattGroupCountMax]; //每组已到单体下限数量
|
| | | public float TestCur[] = new float[FBS5100_ComBase.BattGroupCountMax];
|
| | | public float GroupVol[] = new float[FBS5100_ComBase.BattGroupCountMax];
|
| | | public float OnlineVol[] = new float[FBS5100_ComBase.BattGroupCountMax];
|
| | | public int TestCapInt[] = new int[FBS5100_ComBase.BattGroupCountMax];
|
| | | public int GroupCapInt[] = new int[FBS5100_ComBase.BattGroupCountMax];
|
| | | public int GroupRestCapInt[] = new int[FBS5100_ComBase.BattGroupCountMax];
|
| | | public int MonMaxNum[] = new int[FBS5100_ComBase.BattGroupCountMax];
|
| | | public int MonMinNum[] = new int[FBS5100_ComBase.BattGroupCountMax];
|
| | | public float MonMaxValue[] = new float[FBS5100_ComBase.BattGroupCountMax];
|
| | | public float MonMinValue[] = new float[FBS5100_ComBase.BattGroupCountMax];
|
| | | public int RestTest_Time[] = new int[FBS5100_ComBase.BattGroupCountMax]; //剩余容量可放电时间(HMS)
|
| | | public double TestCap[] = new double[FBS5100_ComBase.BattGroupCountMax]; //每组已测试容量
|
| | | public double GroupCap[] = new double[FBS5100_ComBase.BattGroupCountMax]; //每组实际容量
|
| | | public double GroupRestCap[] = new double[FBS5100_ComBase.BattGroupCountMax]; //每组剩余容量
|
| | | |
| | | public int CRC;
|
| | | |
| | | public FBS5100_CapState() {
|
| | | StartDT = new FBS5100_DateTime();
|
| | | StopDT = new FBS5100_DateTime();
|
| | | Test_Time = new FBS5100_TestTime();
|
| | | }
|
| | | |
| | | |
| | | public boolean putByteBuffer(final ByteBuffer bf)
|
| | | {
|
| | | if(bf.limit() < BYTE_LEN) {
|
| | | System.out.println("长度错误");
|
| | | return false;
|
| | | }
|
| | | //System.err.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
|
| | | |
| | | ByteBuffer tmpbuf = bf;
|
| | | int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
|
| | | int crc1 = FBS5100_Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
|
| | | if(crc0 != crc1) {
|
| | | System.out.println("FBS5100_CapState" + crc0 + "Crc 错误" + crc1);
|
| | | //return false;
|
| | | }
|
| | | tmpbuf.position(0);
|
| | |
|
| | | StartDT.putByteBuffer(tmpbuf); //启动放电的日期时间
|
| | | StopDT.putByteBuffer(tmpbuf); //终止放电的日期时间
|
| | | Test_Time.putByteBuffer(tmpbuf); //已测试时间(HMS)
|
| | | |
| | | TestState = FBS5100_ComBase.changeByteToInt(tmpbuf.get()); //测试状态(停止/暂停/放电)
|
| | | TestType = FBS5100_ComBase.changeByteToInt(tmpbuf.get()); //测试类型(放电/充电)
|
| | | TestGroupNum = FBS5100_ComBase.changeByteToInt(tmpbuf.get()); //被测试电池组编号(1~4)
|
| | | SaveDataEN = FBS5100_ComBase.changeByteToInt(tmpbuf.get()); //保存数据标识
|
| | | NT_DCDC_State = FBS5100_ComBase.changeByteToInt(tmpbuf.get()); //备用,DCDC模块工作状态
|
| | | |
| | | for(int i =0;i<MonomerLowCount.length;i++) {
|
| | | MonomerLowCount[i] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort()); //每组已到单体下限数量
|
| | | }
|
| | | |
| | | for(int i =0;i<TestCur.length;i++) { |
| | | TestCur[i] = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort());
|
| | | }
|
| | | |
| | | for(int i =0;i<OnlineVol.length;i++) { |
| | | OnlineVol[i] = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort());
|
| | | }
|
| | | |
| | | for(int i =0;i<TestCapInt.length;i++) { |
| | | TestCapInt[i] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | }
|
| | | |
| | | for(int i =0;i<GroupCapInt.length;i++) { |
| | | GroupCapInt[i] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | } |
| | | |
| | | for(int i =0;i<GroupRestCapInt.length;i++) { |
| | | GroupRestCapInt[i] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | }
|
| | | |
| | | for(int i =0;i<MonMaxNum.length;i++) { |
| | | MonMaxNum[i] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | }
|
| | | |
| | | for(int i =0;i<MonMinNum.length;i++) { |
| | | MonMinNum[i] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | }
|
| | | |
| | | for(int i =0;i<MonMaxValue.length;i++) { |
| | | MonMaxValue[i] = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort());
|
| | | } |
| | |
|
| | | for(int i =0;i<MonMinValue.length;i++) { |
| | | MonMinValue[i] = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort());
|
| | | } |
| | | |
| | | for(int i =0;i<RestTest_Time.length;i++) { |
| | | //RestTest_Time[i] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort()); //剩余容量可放电时间(HMS)
|
| | | RestTest_Time[i] = tmpbuf.getInt(); //剩余容量可放电时间(HMS)
|
| | | } |
| | | |
| | | for(int i =0;i<TestCap.length;i++) { |
| | | //TestCap[i] = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort()); //每组已测试容量
|
| | | TestCap[i] = tmpbuf.getDouble(); //每组已测试容量
|
| | | } |
| | | |
| | | for(int i =0;i<GroupCap.length;i++) { |
| | | //GroupCap[i] = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort()); //每组实际容量
|
| | | GroupCap[i] = tmpbuf.getDouble(); //每组实际容量
|
| | | } |
| | | |
| | | for(int i =0;i<GroupRestCap.length;i++) { |
| | | //GroupRestCap[i] = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort()); //每组剩余容量
|
| | | GroupRestCap[i] = tmpbuf.getDouble(); //每组剩余容量
|
| | | } |
| | | |
| | | CRC = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | //System.out.println("position:"+tmpbuf.position()+"====" + CRC);
|
| | | |
| | | tmpbuf.compact();
|
| | | tmpbuf.flip();
|
| | | |
| | | return true;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS5100_CapState [StartDT=" + StartDT + ", StopDT=" + StopDT + ", Test_Time=" + Test_Time
|
| | | + ", TestState=" + TestState + ", TestType=" + TestType + ", TestGroupNum=" + TestGroupNum
|
| | | + ", SaveDataEN=" + SaveDataEN + ", NT_DCDC_State=" + NT_DCDC_State + ", MonomerLowCount="
|
| | | + Arrays.toString(MonomerLowCount) + ", TestCur=" + Arrays.toString(TestCur) + ", GroupVol="
|
| | | + Arrays.toString(GroupVol) + ", OnlineVol=" + Arrays.toString(OnlineVol) + ", TestCapInt="
|
| | | + Arrays.toString(TestCapInt) + ", GroupCapInt=" + Arrays.toString(GroupCapInt) + ", GroupRestCapInt="
|
| | | + Arrays.toString(GroupRestCapInt) + ", MonMaxNum=" + Arrays.toString(MonMaxNum) + ", MonMinNum="
|
| | | + Arrays.toString(MonMinNum) + ", MonMaxValue=" + Arrays.toString(MonMaxValue) + ", MonMinValue="
|
| | | + Arrays.toString(MonMinValue) + ", RestTest_Time=" + Arrays.toString(RestTest_Time) + ", TestCap="
|
| | | + Arrays.toString(TestCap) + ", GroupCap=" + Arrays.toString(GroupCap) + ", GroupRestCap="
|
| | | + Arrays.toString(GroupRestCap) + "]";
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.IOException;
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import com.fgkj.data.ComFn;
|
| | |
|
| | | /**
|
| | | * 配网电源
|
| | | * @author LiJun
|
| | | * 充电数据结构体
|
| | | */
|
| | | public class FBS5100_ChargeData {
|
| | | public FBS5100_BattParam battParam; //电池参数
|
| | | public FBS5100_ChargeParam chargeParam; //测试参数
|
| | | public FBS5100_ChargeState chargeState; //容量状态
|
| | | |
| | | public List<FBS5100_FBSData> fbsDatas;
|
| | | |
| | | public int parse_result = FBS5100_ComBase.PARSE_RESULT_NULL;
|
| | | |
| | | public FBS5100_ChargeData() {
|
| | | battParam = new FBS5100_BattParam();
|
| | | chargeParam = new FBS5100_ChargeParam();
|
| | | chargeState = new FBS5100_ChargeState();
|
| | | fbsDatas = new ArrayList<FBS5100_FBSData>();
|
| | | }
|
| | | |
| | | public void parseFileData(String filePath)
|
| | | {
|
| | | |
| | | FileInputStream fis = null;
|
| | | try {
|
| | | File f = new File(filePath);
|
| | | //非充电文件
|
| | | if(!filePath.endsWith(".CHR")) {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_FILETYPEERR;
|
| | | return;
|
| | | }
|
| | | if(!f.exists()) {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_NOTFOUNDFILE;
|
| | | return;
|
| | | //System.out.println("文件不存在..........");
|
| | | }
|
| | | fis = new FileInputStream(f);
|
| | | byte[] buf = new byte[1024];
|
| | | if(fis.read(buf, 0, buf.length) == 1024)
|
| | | {
|
| | | if(this.readDataHead(buf)) {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_SUCCESS;
|
| | | }else {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_FILEERROR;
|
| | | }
|
| | | |
| | | while(true)
|
| | | { |
| | | FBS5100_FBSData fbsData = new FBS5100_FBSData();
|
| | | int tag = fbsData.checkDataHead(fis);
|
| | | if((0xFD == tag) || (0xFC == tag) || (0xFB == tag))
|
| | | {
|
| | | byte[] databuf = new byte[FBS5100_FBSData.BYTE_LEN - 4];
|
| | | if(fis.read(databuf) == databuf.length)
|
| | | {
|
| | | //System.out.println(ComFn.bytesToHexString(databuf, databuf.length));
|
| | | |
| | | if(fbsData.putByteBuffer(databuf)) { |
| | | fbsDatas.add(fbsData);
|
| | | }
|
| | | }
|
| | | }
|
| | | if(tag == 1)
|
| | | break;
|
| | | }
|
| | | }else {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_FILEERROR;
|
| | | }
|
| | | |
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != fis)
|
| | | {
|
| | | try {
|
| | | fis.close();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | //解析数据头
|
| | | public boolean readDataHead(byte[] buf) {
|
| | | System.out.println(ComFn.bytesToHexString(buf, buf.length));
|
| | | boolean flag = false;
|
| | | if(buf.length < (FBS5100_BattParam.BYTE_LEN + FBS5100_TestParam.BYTE_LEN + FBS5100_CapState.BYTE_LEN)) {
|
| | | System.out.println("头部数据长度异常");
|
| | | return flag;
|
| | | } |
| | | ByteBuffer bf = ByteBuffer.allocate(buf.length);
|
| | | bf.order(ByteOrder.LITTLE_ENDIAN);
|
| | | bf.put(buf);
|
| | | bf.position(0);
|
| | | flag = this.battParam.putByteBuffer(bf);
|
| | | System.out.println("battParam:"+flag);
|
| | | flag &= this.chargeParam.putByteBuffer(bf);
|
| | | System.out.println("chargeParam:"+flag);
|
| | | flag &= this.chargeState.putByteBuffer(bf);
|
| | | System.out.println("chargeState:"+flag);
|
| | | return flag;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS5100_ChargeData [battParam=" + battParam + ", chargeParam=" + chargeParam + ", chargeState="
|
| | | + chargeState + ", fbsDatas=" + fbsDatas + ", parse_result=" + parse_result + "]";
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | |
|
| | |
|
| | | /**
|
| | | * 充电参数
|
| | | * @author LiJun
|
| | | *
|
| | | */
|
| | | public class FBS5100_ChargeParam {
|
| | | |
| | | private final int BYTE_LEN = 44;
|
| | | |
| | | public int HourRate = 0; //小时率
|
| | | public double ChargeCurr = 0; //充电电流 |
| | | public double ChargeCap = 0; //充电容量
|
| | | public int ChargeTime = 0; //充电时间
|
| | | public double GroupVol_High = 0; //组端电压上限
|
| | | public double MonomerVol_High = 0; //单体电压上限
|
| | | public int MonomerHighCount = 0; //单体电压上限数量
|
| | | public int BattGroupNum = 0; //组号
|
| | | public int OnlineVolLowAction = 0; //在线电压低处理 |
| | | public int StaticTime = 0; //静置时间
|
| | | public int ChargeTestCount = 0; //充电测试次数
|
| | | |
| | | public int bakeup1 = 0;
|
| | | public int bakeup2 = 0;
|
| | | public int bakeup3 = 0;
|
| | | public int bakeup4 = 0;
|
| | | public int bakeup5 = 0;
|
| | | public int bakeup6 = 0;
|
| | | public int bakeup7 = 0;
|
| | | public int bakeup8 = 0;
|
| | | public int bakeup9 = 0;
|
| | | public int bakeup10 = 0;
|
| | | |
| | | public int CRC = 0;
|
| | | |
| | | public FBS5100_ChargeParam clone()
|
| | | {
|
| | | FBS5100_ChargeParam obj = null; |
| | | try
|
| | | {
|
| | | obj = (FBS5100_ChargeParam)super.clone();
|
| | | }
|
| | | catch(CloneNotSupportedException e)
|
| | | {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return obj;
|
| | | }
|
| | | |
| | | public void clear()
|
| | | {
|
| | | HourRate = 0;
|
| | | ChargeCurr = 0;
|
| | | ChargeCap = 0;
|
| | | ChargeTime = 0;
|
| | | GroupVol_High = 0;
|
| | | MonomerVol_High = 0;
|
| | | MonomerHighCount = 0;
|
| | | BattGroupNum = 0;
|
| | | OnlineVolLowAction = 0;
|
| | | StaticTime = 0;
|
| | | ChargeTestCount = 0;
|
| | | |
| | | bakeup1 = 0;
|
| | | bakeup2 = 0;
|
| | | bakeup3 = 0;
|
| | | bakeup4 = 0;
|
| | | bakeup5 = 0;
|
| | | bakeup6 = 0;
|
| | | bakeup7 = 0;
|
| | | bakeup8 = 0;
|
| | | bakeup9 = 0;
|
| | | bakeup10 = 0;
|
| | | |
| | | CRC = 0;
|
| | | }
|
| | | |
| | | public boolean putByteBuffer(final ByteBuffer bf)
|
| | | {
|
| | | if(bf.limit() < BYTE_LEN)
|
| | | return false;
|
| | | |
| | | ByteBuffer tmpbuf = bf;
|
| | | int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
|
| | | int crc1 = FBS5100_Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
|
| | | if(crc0 != crc1)
|
| | | return false;
|
| | | |
| | | tmpbuf.position(0);
|
| | | HourRate = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | ChargeCurr = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort());
|
| | | ChargeCap = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort());
|
| | | ChargeTime = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | GroupVol_High = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort())/10;
|
| | | MonomerVol_High = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
|
| | | MonomerHighCount = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | BattGroupNum = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | OnlineVolLowAction = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | StaticTime = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | ChargeTestCount = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | bakeup1 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup2 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup3 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup4 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup5 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup6 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup7 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup8 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup9 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup10 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | tmpbuf.compact();
|
| | | tmpbuf.flip();
|
| | | |
| | | return true;
|
| | | }
|
| | | |
| | | public ByteBuffer getByteBuffer()
|
| | | {
|
| | | ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
|
| | | bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(HourRate));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(ChargeCurr));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(ChargeCap));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(ChargeTime));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(GroupVol_High*10));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(MonomerVol_High*1000));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(MonomerHighCount));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(BattGroupNum));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(OnlineVolLowAction));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(StaticTime));
|
| | | |
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(ChargeTestCount));
|
| | | |
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup1));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup2));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup3));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup4));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup5));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup6));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup7));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup8));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup9));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup10));
|
| | | |
| | | CRC = FBS5100_Crc16.CalCRC16(bytebuffer, bytebuffer.position());
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(CRC));
|
| | | |
| | | bytebuffer.flip();
|
| | | |
| | | return bytebuffer;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS9100_ParamCharge [BYTE_LEN=" + BYTE_LEN + ", HourRate=" + HourRate + ", ChargeCurr=" + ChargeCurr
|
| | | + ", ChargeCap=" + ChargeCap + ", ChargeTime=" + ChargeTime + ", GroupVol_High=" + GroupVol_High
|
| | | + ", MonomerVol_High=" + MonomerVol_High + ", MonomerHighCount=" + MonomerHighCount + ", BattGroupNum="
|
| | | + BattGroupNum + ", OnlineVolLowAction=" + OnlineVolLowAction + ", StaticTime=" + StaticTime
|
| | | + ", ChargeTestCount=" + ChargeTestCount + ", bakeup1=" + bakeup1 + ", bakeup2=" + bakeup2
|
| | | + ", bakeup3=" + bakeup3 + ", bakeup4=" + bakeup4 + ", bakeup5=" + bakeup5 + ", bakeup6=" + bakeup6
|
| | | + ", bakeup7=" + bakeup7 + ", bakeup8=" + bakeup8 + ", bakeup9=" + bakeup9 + ", bakeup10=" + bakeup10
|
| | | + ", CRC=" + CRC + "]";
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | | import java.util.Arrays;
|
| | |
|
| | |
|
| | | public class FBS5100_ChargeState {
|
| | | private final int BYTE_LEN = 120;
|
| | | private final int BATTGROUP_COUNT = FBS5100_ComBase.BattGroupCountMax;
|
| | | |
| | | public FBS5100_DateTime StartDT = new FBS5100_DateTime(); //启动放电的日期时间
|
| | | public FBS5100_DateTime StopDT = new FBS5100_DateTime(); //终止放电的日期时间
|
| | | public FBS5100_TestTime Test_Time = new FBS5100_TestTime(); //已测试时间(HMS)
|
| | | |
| | | public int TestState; //测试状态(停止/暂停/放电)
|
| | | public int TestType; //测试类型(放电/充电)
|
| | | public int TestGroupNum; //被测试电池组编号(1~4)
|
| | | public int SaveDataEN; //保存数据标识
|
| | | public int ChargeEN; //开始充电标识
|
| | | public int ChargeOverTime; //充电过流超时
|
| | | public int LastCapTestAlarmRes; //上次容量放电测试结果
|
| | | |
| | | public double TestCur[] = new double[FBS5100_ComBase.BattGroupCountMax];
|
| | | public double GroupVol[] = new double[FBS5100_ComBase.BattGroupCountMax];
|
| | | public double OnlineVol[] = new double[FBS5100_ComBase.BattGroupCountMax];
|
| | | public double TestCapInt[] = new double[FBS5100_ComBase.BattGroupCountMax];
|
| | | public int MonMaxNum[] = new int[FBS5100_ComBase.BattGroupCountMax];
|
| | | public int MonMinNum[] = new int[FBS5100_ComBase.BattGroupCountMax];
|
| | | public double MonMaxValue[] = new double[FBS5100_ComBase.BattGroupCountMax];
|
| | | public double MonMinValue[] = new double[FBS5100_ComBase.BattGroupCountMax];
|
| | | |
| | | public double TestCap[] = new double[FBS5100_ComBase.BattGroupCountMax]; //每组已测试容量 |
| | |
|
| | | public int CRC;
|
| | | |
| | | public FBS5100_ChargeState clone()
|
| | | {
|
| | | FBS5100_ChargeState obj = null; |
| | | try
|
| | | {
|
| | | obj = (FBS5100_ChargeState)super.clone();
|
| | | }
|
| | | catch(CloneNotSupportedException e)
|
| | | {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return obj;
|
| | | }
|
| | | |
| | | public boolean putByteBuffer(final ByteBuffer bf)
|
| | | {
|
| | | if(bf.limit() < BYTE_LEN)
|
| | | return false;
|
| | | |
| | | ByteBuffer tmpbuf = bf;
|
| | | int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
|
| | | int crc1 = FBS5100_Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
|
| | | if(crc0 != crc1)
|
| | | return false;
|
| | | |
| | | tmpbuf.position(0);
|
| | | StartDT.year = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StartDT.month = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StartDT.day = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StartDT.hour = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StartDT.minute = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StartDT.second = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | |
| | | StopDT.year = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StopDT.month = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StopDT.day = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StopDT.hour = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StopDT.minute = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | StopDT.second = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | |
| | | Test_Time.hour = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | Test_Time.minute = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | Test_Time.second = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | |
| | | TestState = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | TestType = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | TestGroupNum = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | SaveDataEN = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | ChargeEN = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | ChargeOverTime = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | LastCapTestAlarmRes = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | TestCur[n] = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort()) / 10;
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | GroupVol[n] = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort()) / 10;
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | OnlineVol[n] = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort()) / 10;
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | TestCapInt[n] = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort());
|
| | |
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | MonMaxNum[n] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | MonMinNum[n] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | MonMaxValue[n] = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort()) / 1000;
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | MonMinValue[n] = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort()) / 1000;
|
| | | |
| | | tmpbuf.compact();
|
| | | tmpbuf.flip();
|
| | | |
| | | return true;
|
| | | }
|
| | | |
| | | public ByteBuffer getByteBuffer()
|
| | | {
|
| | | ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
|
| | | bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | |
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StartDT.year));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StartDT.month));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StartDT.day));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StartDT.hour));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StartDT.minute));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StartDT.second));
|
| | | |
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StopDT.year));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StopDT.month));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StopDT.day));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StopDT.hour));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StopDT.minute));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(StopDT.second));
|
| | | |
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(Test_Time.hour));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(Test_Time.minute));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(Test_Time.second));
|
| | | |
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(TestState));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(TestType));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(TestGroupNum));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(SaveDataEN));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(ChargeEN));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(ChargeOverTime));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(LastCapTestAlarmRes));
|
| | | |
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(TestCur[n]*10));
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(GroupVol[n]*10));
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(OnlineVol[n]*10));
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(TestCapInt[n]));
|
| | |
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(MonMaxNum[n]));
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(MonMinNum[n]));
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(MonMaxValue[n]*1000));
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(MonMinValue[n]*1000));
|
| | | |
| | | CRC = FBS5100_Crc16.CalCRC16(bytebuffer, bytebuffer.capacity()-2);
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(CRC));
|
| | | |
| | | bytebuffer.flip();
|
| | | System.out.println("bytebuffer limit:"+bytebuffer.limit());
|
| | | return bytebuffer;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS5100_ChargeState [StartDT=" + StartDT + ", StopDT=" + StopDT + ", Test_Time=" + Test_Time
|
| | | + ", TestState=" + TestState + ", TestType=" + TestType + ", TestGroupNum=" + TestGroupNum
|
| | | + ", SaveDataEN=" + SaveDataEN + ", ChargeEN=" + ChargeEN + ", ChargeOverTime=" + ChargeOverTime
|
| | | + ", LastCapTestAlarmRes=" + LastCapTestAlarmRes + ", TestCur=" + Arrays.toString(TestCur)
|
| | | + ", GroupVol=" + Arrays.toString(GroupVol) + ", OnlineVol=" + Arrays.toString(OnlineVol)
|
| | | + ", TestCapInt=" + Arrays.toString(TestCapInt) + ", MonMaxNum=" + Arrays.toString(MonMaxNum)
|
| | | + ", MonMinNum=" + Arrays.toString(MonMinNum) + ", MonMaxValue=" + Arrays.toString(MonMaxValue)
|
| | | + ", MonMinValue=" + Arrays.toString(MonMinValue) + ", TestCap=" + Arrays.toString(TestCap) + "]";
|
| | | }
|
| | | |
| | | |
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | public class FBS5100_ComBase |
| | | {
|
| | | //------------------------ 测试类型 ----------------------------------------------------
|
| | | public static final int DataType_Dis = 0xFD; //放电
|
| | | public static final int DataType_Char = 0xFC; //充电
|
| | | public static final int DataType_Peac = 0xFB; //常规
|
| | | |
| | | //----------------------------------------------------------------------------
|
| | | //------------------------ 解析结果 ----------------------------------------------------
|
| | | public static final int PARSE_RESULT_NULL = 0; //未知
|
| | | public static final int PARSE_RESULT_SUCCESS = 1; //解析成功
|
| | | public static final int PARSE_RESULT_NOTFOUNDFILE = 2; //文件未找到
|
| | | public static final int PARSE_RESULT_FILETYPEERR = 3; //文件格式错误
|
| | | public static final int PARSE_RESULT_FILEERROR = 4; //文件异常
|
| | | //----------------------------------------------------------------------------
|
| | | //----------------------------------------------------------------------------
|
| | | public static final int BattGroupCountMax = 4;
|
| | | public static final int MonomerCountMax = 480;
|
| | | //----------------------------------------------------------------------------
|
| | | public static final int BTS_DCDC_CountMax = 8;
|
| | | public static final int LIBTS_DCDC_CountMax = 4; //锂电BTS的最大DCDC模块信息
|
| | | //----------------------------------------------------------------------------
|
| | | public static final int CMD_NULL = 0x00;
|
| | | //----------------------------------------------------------------------------
|
| | | //------------ 重启FBS9100设备 ------------------------------------------------
|
| | | public static final int CMD_ResetSystemAck = 0x0F;
|
| | | public static final int CMD_ResetSystem = 0x10;
|
| | | //------------ 升级FBS9100软件 ------------------------------------------------
|
| | | public static final int CMD_SystemUpdate = 0x11;
|
| | | public static final int CMD_SystemUpdateAck = 0x12;
|
| | | //----------------------------------------------------------------------------
|
| | | //------------ 读取设备版本号、实时任务列表等 ----------------------------------
|
| | | public static final int CMD_GetDeviceInf = 0x15;
|
| | | public static final int CMD_GetDeviceTaskInfAck = 0x16;
|
| | | 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_GETDEVID = 0x23; //获取设备id
|
| | | |
| | | //----------------------------------------------------------------------------
|
| | | //------------ 启动放电测试和读取设置参数,读取放电测试状态----------------------
|
| | | public static final int CMD_StartDischarge = 0x25;
|
| | | public static final int CMD_StartDischargeAck = 0x26;
|
| | | public static final int CMD_SetDischargeParmAck = 0x27;
|
| | | public static final int CMD_SetDischargeParm = 0x28;
|
| | | public static final int CMD_GetDischargeParm = 0x29;
|
| | | public static final int CMD_GetDischargeParmAck = 0x30;
|
| | | 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_GetBattParamACK = 0x38;
|
| | | public static final int CMD_SetBattParamACK = 0x39;
|
| | | //----------------------------------------------------------------------------
|
| | | //------------ 启动充电测试和读取设置参数,读取充电测试状态-----------------------
|
| | | 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_Set_BattOFFLine = 0x4A;
|
| | | public static final int CMD_Set_BattONLine = 0x4B;
|
| | | //-----------------------------------------------------------------------------
|
| | | //------------ 停止任何的测试 --------------------------------------------------
|
| | | public static final int CMD_Start = 0x51;
|
| | | public static final int CMD_StartAck = 0x52;
|
| | | public static final int CMD_Stop = 0x53;
|
| | | public static final int CMD_StopAck = 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_GetMonomerJHcurr = 0x66;
|
| | | public static final int CMD_Get_DCDC_Data = 0x67; //铁塔版本获取DCDC命令
|
| | | public static final int CMD_Get_K_D_TestData = 0x68;
|
| | | |
| | | |
| | | public static final int CMD_Result_Error = - 0x01; //操作失败 |
| | | |
| | | public static final int CMD_Result_Success = 0x00; //操作成功过
|
| | | public static final int CMD_Result_Fail = 0x05; //操作失败
|
| | | public static final int CMD_Result_Work = 0x10; //系统处于工作状态
|
| | | public static final int CMD_Result_NotNull = 0x11; //句柄非空错误
|
| | | public static final int CMD_Result_CreateErr = 0x12; //任务创建失败
|
| | | public static final int CMD_Result_MemoryErr = 0x13; //内存申请错误
|
| | | public static final int CMD_Result_OutErr = 0x14; //假负载失控
|
| | | public static final int CMD_Result_OtherWork = 0x15; //其他设备在工作
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 2021-08-31 @lijun 假负载版本新增均衡电流和漏液电压读取
|
| | | */
|
| | | public static final int CMD_GetMonomerLYVolt = 0x78; //漏液电压
|
| | | public static final int CMD_GetMonomerJHCUR = 0x69; //增加均衡电流
|
| | | |
| | | |
| | | public static final int CMD_GetLiDCDCParam = 0x8B; //读取锂电DCDC参数
|
| | | public static final int CMD_SetLiDCDCParam = 0x8C; //设置锂电DCDC参数
|
| | | |
| | | public static final int CMD_GetPbDCDCParam = 0x8D; //读取铅酸DCDC参数
|
| | | public static final int CMD_SetPbDCDCParam = 0x8E; //设置铅酸DCDC参数
|
| | | |
| | | public static final int CMD_GetSXDCDCData = 0x8F; //读取双向DCDC内部数据
|
| | | |
| | | public static final int CMD_GetLiBMSData = 0x95; //读取锂电池BMS模拟量
|
| | | public static final int CMD_GetLiBMSState = 0x96; //读取锂电池BMS告警量
|
| | | |
| | | public static final int CMD_ReStartDCDC = 0x9A; //远程重启内部DCDC模块
|
| | | |
| | | /**
|
| | | * 读取切换箱正负极开关状态
|
| | | */
|
| | | public static final int CMD_ReadQHZZFZCDState = 0xC3; //读取切换箱正负极开关状态
|
| | | |
| | | |
| | | /**
|
| | | * 2022-01-06 edit by lijun 逆变设备新增机柜头数据
|
| | | * |
| | | * 读取
|
| | | */
|
| | | public static final int CMD_GetSimData = 0x99; //读取逆变机柜头数据
|
| | | //------------ 平台锂电池命令 -----------------------------------------------------------------
|
| | | public static final int CMD_GetLiDCDCParam_Ack = 0x8D; //读取锂电BTS参数成功
|
| | | public static final int CMD_SetLiDCDCParam_Ack = 0x8E; //设置锂电BTS参数成功 |
| | | |
| | | public static final int CMD_GetSXDCDCData_Ack = 0x92; //读取双向DCDC内部数据成功
|
| | | public static final int CMD_GetLiBMSData_Ack = 0x93; //读取锂电池BMS模拟量
|
| | | public static final int CMD_GetLiBMSState_Ack = 0x94; //读取锂电池BMS告警量
|
| | | |
| | | public static final int CMD_ReStartDCDC_Ack = 0x9B; //远程重启内部DCDC模块成功
|
| | | |
| | | |
| | | //----------------------------------------------------------------------------------------
|
| | | |
| | | //-----------------------------------------------------------------------------
|
| | | //------------ 在线电压校准 ----------------------------------------------------
|
| | | 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_GetSYSSetParamAck = 0x7E;
|
| | | public static final int CMD_SetSYSSetParamAck = 0x7F;
|
| | | 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 CMD_GetAlarmParamAck = 0x84;
|
| | | public static final int CMD_SetAlarmParamAck = 0x85;
|
| | | |
| | | public static final int CMD_GetJuHengParam = 0xC1; //读取均衡参数
|
| | | public static final int CMD_GetJuHengParamAck = 0xC2; //读取均衡参数成功
|
| | | public static final int CMD_SetJuHengParam = 0xC3; //设置均衡参数
|
| | | public static final int CMD_SetJuHengParamAck = 0xC4; //设置均衡参数成功
|
| | | |
| | | //-------------- 清除告警 --------------------------------------------------
|
| | | public static final int CMD_ClearSysAlarm = 0xB8; //清除告警 |
| | | public static final int CMD_ClearSysAlarm_ACK = 0xB9; //清除告警成功
|
| | | //------------------------------------------------------------------------------
|
| | | //------------ DFU 命令 ---------------------------------------------------------
|
| | | public static final int CMD_FBS9100_WriteDFU = 0x86;
|
| | | public static final int CMD_FBS9100_ReadDFU = 0x87;
|
| | | //------------------------------------------------------------------------------
|
| | | //读取cmcc的电压电流
|
| | | public static final int CMD_ReadCMCCVolCurr = 0x8A;
|
| | | |
| | | //读取GPRS模块的信号质量
|
| | | public static final int CMD_ReadGPRSCSQ = 0x91;
|
| | | public static final int CMD_ReadGPRSCSQAck = 0x92;
|
| | | |
| | | //读取干节点数据
|
| | | public static final int CMD_ReadStemNode = 0xC2;
|
| | | //清除告警 |
| | | public static final int CMD_ClearAlarm = 0x90;
|
| | | |
| | | |
| | | /**
|
| | | * 2023-04-25 @lijun 新增逆变器信息读取以及告警数据读取
|
| | | */
|
| | | public static final int CMD_Get_DCAC_Data = 0x90; //获取逆变器模块的数据
|
| | | public static final int CMD_Get_AlarmData = 0x96; //获取告警数据
|
| | | public static final int CMD_Get_MOSSTATE = 0x97; //获取MOS管状态
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * @lijun 2021-11-13
|
| | | * 假负载BTS新增连接条阻抗信息以及温湿度信息读取
|
| | | */
|
| | | public static final int CMD_ReadConnRes = 0x97; //读取连接条阻抗信息
|
| | | public static final int CMD_ReadTmpHum = 0x98; //读取温湿度传感器信息
|
| | | |
| | | public static final int CMD_ReadBusCoupleState = 0x9D; //读取智能母联状态
|
| | | |
| | | public static final int CMD_GetJunHengState = 0xA8; //读取均衡供电模块信息
|
| | | |
| | | public static final int CMD_ReadJunHengParam = 0xB0; //读取均衡参数信息
|
| | | public static final int CMD_WriteJunHengParam = 0xB1; //设置均衡参数信息
|
| | | |
| | | |
| | | |
| | | //------------ 测试类型 ---------------------------------------------------------
|
| | | 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 TestType_Charge_HELUQI = 0xBC;
|
| | | public static final int TestType_CAP_HELUQI = 0xBD; //升压续航放电测试类型
|
| | | public static final int TestType_SwitchDiode = 0xD1; //KD测试
|
| | | //------------------------------------------------------------------------------
|
| | | //------------ 电池状态 ---------------------------------------------------------
|
| | | 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;
|
| | | public static final int DataType_MonJHcurr = 0x08; //均衡电流
|
| | | |
| | | public static final int DataType_MonLYvol = 0x09; //漏液电压
|
| | | public static final int DataType_MonConnRes = 0x10; //连接条阻抗
|
| | | //------------------------------------------------------------------------------
|
| | | //------------------------------------------------------------------------------
|
| | | public static final int BTSE_DevType_TieTa = 0x08; //铁塔版本的bt
|
| | | public static final int BTSE_DevType_NiBian = 0x06; //逆变版本的bts
|
| | | public static final int BTSE_DevType_LIBTS = 0x05; //锂电池版本的bts
|
| | | //------------------------------------------------------------------------------
|
| | | public static final int SYS_STATE_STOPPED = 0x00;
|
| | | public static final int SYS_STATE_DISCHARGING = 0x01;
|
| | | public static final int SYS_STATE_CHARGING = 0x02;
|
| | | public static final int SYS_STATE_HELUQI_DISCHARGING = 0x03;
|
| | | //------------------------------------------------------------------------------
|
| | | //-------------------------------------------------------------------------------------------
|
| | | public static final int ALARM_NULL = 0; //无
|
| | | public static final int ALARM_PAUSED = 1; //暂停
|
| | | public static final int ALARM_DISCHARGING = 2; //正在放电测试
|
| | | public static final int ALARM_DISCHARGEWAIT = 3; //正在等待放电
|
| | | public static final int ALARM_LimitCHARGING = 4; //正在限流充电
|
| | | public static final int ALARM_LargeCHARGING = 5; //正在直连充电
|
| | | public static final int ALARM_CHARGEWAIT = 6; //正在等待充电
|
| | | public static final int ALARM_TIMESTOP = 7; //放电时间到停止
|
| | | public static final int ALARM_CAPSTOP = 8; //放电容量到停止
|
| | | public static final int ALARM_MVLLSTOP = 9; //单体电压下限到停止
|
| | | public static final int ALARM_SVLLSTOP = 10; //组端电压下限到停止
|
| | | public static final int ALARM_POWERBREAKSTOP = 11; //市电中断停止
|
| | | public static final int ALARM_FLASHUPSTOP = 12; //存储数据满停止
|
| | | public static final int ALARM_TEMPHIGHSTOP = 13; //机内温度异常停止
|
| | | public static final int ALARM_CURRSTOP = 14; //放电电流过流停止
|
| | | public static final int ALARM_PCCOMMBREAKSTOP = 15; //后台通信中断停止
|
| | | public static final int ALARM_LoaderCOMMBREAKSTOP = 16; //负载模块通信中断停止
|
| | | public static final int ALARM_Sel2TO1COMMBREAKSTOP = 17; //选择模块通信中断停止
|
| | | public static final int ALARM_LoaderPowerError = 18; //负载模块放电过功率停止
|
| | | public static final int ALARM_Malloc_ERROR = 19; //内部程序异常停止
|
| | | public static final int ALARM_POWERRESUMESTOP_HELUQI = 20; //合路器放电功能,市电恢复停止升压放电
|
| | | public static final int ALARM_POWERBREAKSTOP_HELUQI = 21; //合路器放电功能,充电过程中市电中断
|
| | | public static final int ALARM_SVLLSTOP_HELUQI = 22; //合路器放电功能组端电压下限
|
| | | public static final int ALARM_MOMTEMP_HL_STOP = 23; //单体温度上限到停止
|
| | | public static final int ALARM_ONLINEVOL_HL_STOP = 24; //在线电压异常高停止
|
| | | public static final int ALARM_XIEZHUANG_COMM_ERR_STOP = 25; //协转通信异常停止
|
| | | public static final int ALARM_MONOMER_COMM_ERR_STOP = 26; //单体通信异常停止
|
| | | public static final int ALARM_UNKOWN = 27; //未知
|
| | | //-------------------------------------------------------------------------------------------
|
| | | 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 float changeShortToFloat(short data)
|
| | | {
|
| | | int tmp = data & 0xFFFF;
|
| | | return (float)(tmp);
|
| | | }
|
| | | //------------------------------------------------------------------------------
|
| | | public static short changeDoubleToShort(double data)
|
| | | {
|
| | | int tmp = (int)data;
|
| | | //System.out.println("tmp:"+tmp);
|
| | | return (short)(tmp & 0xFFFF);
|
| | | }
|
| | | |
| | | |
| | | public static short changeFloatToShort(float 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)*******************************
|
| | | ***************************************************************************************/ |
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | |
|
| | | public class FBS5100_Crc16 |
| | | {
|
| | | private final static int CRC16Table[] = |
| | | {
|
| | | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
|
| | | 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
|
| | | 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
|
| | | 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
|
| | | 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
|
| | | 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
|
| | | 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
|
| | | 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
|
| | | 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
|
| | | 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
|
| | | 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
|
| | | 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
|
| | | 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
|
| | | 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
|
| | | 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
|
| | | 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
|
| | | 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
|
| | | 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
|
| | | 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
|
| | | 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
|
| | | 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
|
| | | 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
| | | 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
|
| | | 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
|
| | | 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
|
| | | 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
|
| | | 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
|
| | | 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
|
| | | 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
|
| | | 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
|
| | | 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
|
| | | 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
|
| | | };
|
| | | |
| | | public static int CalCRC16(final ByteBuffer buf, int count)
|
| | | {
|
| | | ByteBuffer tmpbuf = buf; |
| | | tmpbuf.position(0);
|
| | | |
| | | int crc = 0xFFFF; //�ؼ��Եij�ֵ...
|
| | | int tmp;
|
| | | for (int i=0; i<count; i++)
|
| | | {
|
| | | if(!buf.hasRemaining())
|
| | | break;
|
| | | |
| | | tmp = crc;
|
| | | crc = CRC16Table[(int)((((tmp&0xFFFF) >> 8) ^ (tmpbuf.get())) & 0xFF)];
|
| | | crc = crc ^ ((tmp&0xFFFF) << 8);
|
| | | }
|
| | | |
| | | return (crc & 0xFFFF);
|
| | | }
|
| | | }
|
| | | /***************************************************************************************
|
| | | ****************************** end of file (FBS_Crc16) *********************************
|
| | | ***************************************************************************************/
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | | import java.util.Calendar;
|
| | |
|
| | |
|
| | | public class FBS5100_DateTime |
| | | {
|
| | | public int year = 0;
|
| | | public int month = 1;
|
| | | public int day = 1;
|
| | | public int hour = 0;
|
| | | public int minute = 0;
|
| | | public int second = 0;
|
| | | |
| | | public FBS5100_DateTime clone()
|
| | | {
|
| | | FBS5100_DateTime obj = new FBS5100_DateTime();
|
| | | |
| | | obj.year = year;
|
| | | obj.month = month;
|
| | | obj.day = day;
|
| | | obj.hour = hour;
|
| | | obj.minute = minute;
|
| | | obj.second = second;
|
| | | |
| | | return obj;
|
| | | }
|
| | | |
| | | public void putByteBuffer(final ByteBuffer bf)
|
| | | {
|
| | | year = FBS5100_ComBase.changeByteToInt(bf.get());
|
| | | month = FBS5100_ComBase.changeByteToInt(bf.get());
|
| | | day = FBS5100_ComBase.changeByteToInt(bf.get());
|
| | | hour = FBS5100_ComBase.changeByteToInt(bf.get());
|
| | | minute = FBS5100_ComBase.changeByteToInt(bf.get());
|
| | | second = FBS5100_ComBase.changeByteToInt(bf.get());
|
| | | }
|
| | | |
| | | public ByteBuffer getPCDateTimeBytes()
|
| | | {
|
| | | ByteBuffer bytebuffer = ByteBuffer.allocate(12);
|
| | | bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | Calendar cad = Calendar.getInstance();
|
| | | //cad.set(23, 5, 10);
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(cad.get(Calendar.YEAR)%100));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(cad.get(Calendar.MONTH)+1));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(cad.get(Calendar.DAY_OF_MONTH)));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(cad.get(Calendar.HOUR_OF_DAY)));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(cad.get(Calendar.MINUTE)));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(cad.get(Calendar.SECOND)));
|
| | | bytebuffer.flip();
|
| | | //System.out.println("设置时间:"+cad.get(Calendar.YEAR)+"-"+(cad.get(Calendar.MONTH)+1)+"-"+cad.get(Calendar.DAY_OF_MONTH)+" "+cad.get(Calendar.HOUR_OF_DAY)+":"+cad.get(Calendar.MINUTE)+":"+cad.get(Calendar.SECOND));
|
| | | return bytebuffer;
|
| | | }
|
| | | |
| | | public long getTimeInMillis() {
|
| | | Calendar ca = Calendar.getInstance();
|
| | | int month_t = month;
|
| | | if(month_t > 0) {
|
| | | month_t -= 1;
|
| | | }
|
| | | ca.set(year+2000, month_t, day, hour, minute, second);
|
| | | |
| | | return ca.getTimeInMillis();
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS5100_DateTime [year=" + year + ", month=" + month + ", day=" + day + ", hour=" + hour
|
| | | + ", minute=" + minute + ", second=" + second + "]";
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.IOException;
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import com.fgkj.data.ComFn;
|
| | |
|
| | | /**
|
| | | * 配网电源
|
| | | * @author LiJun
|
| | | *
|
| | | */
|
| | | public class FBS5100_DisChargeData {
|
| | | public FBS5100_BattParam battParam; //电池参数
|
| | | public FBS5100_TestParam testParam; //测试参数
|
| | | public FBS5100_CapState capState; //容量状态
|
| | | |
| | | public List<FBS5100_FBSData> fbsDatas;
|
| | | |
| | | public int parse_result = FBS5100_ComBase.PARSE_RESULT_NULL;
|
| | | |
| | | public FBS5100_DisChargeData() {
|
| | | battParam = new FBS5100_BattParam();
|
| | | testParam = new FBS5100_TestParam();
|
| | | capState = new FBS5100_CapState();
|
| | | fbsDatas = new ArrayList<FBS5100_FBSData>();
|
| | | }
|
| | | |
| | | public void parseFileData(String filePath)
|
| | | {
|
| | | |
| | | FileInputStream fis = null;
|
| | | try {
|
| | | File f = new File(filePath);
|
| | | //既不是核容放电也不是监测放电
|
| | | if(!filePath.endsWith(".BCP") && !filePath.endsWith(".MCP")) {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_FILETYPEERR;
|
| | | return;
|
| | | }
|
| | | if(!f.exists()) {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_NOTFOUNDFILE;
|
| | | return;
|
| | | //System.out.println("文件不存在..........");
|
| | | }
|
| | | fis = new FileInputStream(f);
|
| | | byte[] buf = new byte[1024];
|
| | | if(fis.read(buf, 0, buf.length) == 1024)
|
| | | {
|
| | | if(this.readDataHead(buf)) {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_SUCCESS;
|
| | | }else {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_FILEERROR;
|
| | | }
|
| | | |
| | | while(true)
|
| | | { |
| | | FBS5100_FBSData fbsData = new FBS5100_FBSData();
|
| | | int tag = fbsData.checkDataHead(fis);
|
| | | if((0xFD == tag) || (0xFC == tag) || (0xFB == tag))
|
| | | {
|
| | | byte[] databuf = new byte[FBS5100_FBSData.BYTE_LEN - 4];
|
| | | if(fis.read(databuf) == databuf.length)
|
| | | {
|
| | | //System.out.println(ComFn.bytesToHexString(databuf, databuf.length));
|
| | | |
| | | if(fbsData.putByteBuffer(databuf)) { |
| | | fbsDatas.add(fbsData);
|
| | | }
|
| | | }
|
| | | }
|
| | | if(tag == 1)
|
| | | break;
|
| | | }
|
| | | }else {
|
| | | parse_result = FBS5100_ComBase.PARSE_RESULT_FILEERROR;
|
| | | }
|
| | | |
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != fis)
|
| | | {
|
| | | try {
|
| | | fis.close();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | //解析数据头
|
| | | public boolean readDataHead(byte[] buf) {
|
| | | System.out.println(ComFn.bytesToHexString(buf, buf.length));
|
| | | boolean flag = false;
|
| | | if(buf.length < (FBS5100_BattParam.BYTE_LEN + FBS5100_TestParam.BYTE_LEN + FBS5100_CapState.BYTE_LEN)) {
|
| | | System.out.println("头部数据长度异常");
|
| | | return flag;
|
| | | } |
| | | ByteBuffer bf = ByteBuffer.allocate(buf.length);
|
| | | bf.order(ByteOrder.LITTLE_ENDIAN);
|
| | | bf.put(buf);
|
| | | bf.position(0);
|
| | | flag = this.battParam.putByteBuffer(bf);
|
| | | //System.out.println("battParam:"+flag);
|
| | | flag &= this.testParam.putByteBuffer(bf);
|
| | | //System.out.println("testParam:"+flag);
|
| | | flag &= this.capState.putByteBuffer(bf);
|
| | | //System.out.println("capState:"+flag);
|
| | | return flag;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS5100_DisChargeData [battParam=" + battParam + ", testParam=" + testParam + ", capState=" + capState
|
| | | + ", fbsDatas=" + fbsDatas + ", parse_result=" + parse_result + "]";
|
| | | }
|
| | | |
| | | |
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.io.FileInputStream;
|
| | | import java.io.IOException;
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | | import java.util.Arrays;
|
| | |
|
| | | import com.fgkj.data.ComFn;
|
| | |
|
| | | public class FBS5100_FBSData {
|
| | | public static final int BYTE_LEN = 10 + 20*FBS5100_ComBase.BattGroupCountMax;
|
| | | |
| | | private final int BATTGROUP_COUNT = FBS5100_ComBase.BattGroupCountMax;
|
| | | private final int BASIC_LEN = 10 + 20*BATTGROUP_COUNT;
|
| | | |
| | | //public FBS9100_SysState m_SysState = new FBS9100_SysState();
|
| | | |
| | | public int dataType[] = {0xAA, 0xAA, 0xAA, 0xAA};
|
| | | public int CRC = 0;
|
| | | public FBS5100_TestTime testTime = new FBS5100_TestTime();
|
| | | public int battGroup = 1;
|
| | | public int battSum = 24;
|
| | | public int battGroupNum = 1;
|
| | | |
| | | public float muxianvol_discharge; //放电母线电压 24Vd+
|
| | | public float muxianvol_charge; //充电母线电压 24Vc+
|
| | | public float boostDCDC_OutVol; //升压DCDC输出电压 48Vd+
|
| | | public float muxianvol; //48V母线电压 48Vo+
|
| | |
|
| | | |
| | | public int battXuHangTime = 0;
|
| | | public int stationPowerOffTLong = 0;
|
| | | public int stationPowerOffCNT = 0;
|
| | | |
| | | public double conresist = 0; //组1接触器导通阻抗 (0.001mR)
|
| | | public double conresist1 = 0; //组2接触器导通阻抗 (0.001mR)
|
| | | public double condvoldp = 0; //组1二极管压降(0.01V) |
| | | public double condvoldp1 = 0; //组2二极管压降(0.01V) |
| | | |
| | | |
| | | public float onlinevol[] = new float[FBS5100_ComBase.BattGroupCountMax]; //在线电压
|
| | | public float groupvol[] = new float[FBS5100_ComBase.BattGroupCountMax]; //组端电压
|
| | | public int battstate[] = new int[FBS5100_ComBase.BattGroupCountMax]; //充放电状态 3 5 9 |
| | | public float battcurr[] = new float[FBS5100_ComBase.BattGroupCountMax]; //电池组电流
|
| | | public float battcap[] = new float[FBS5100_ComBase.BattGroupCountMax]; //电池组容量
|
| | | public float batttemp[] = new float[FBS5100_ComBase.BattGroupCountMax]; //电池组温度
|
| | | public int monMAX_num[] = new int[FBS5100_ComBase.BattGroupCountMax]; //最大单体编号 |
| | | public int monMIN_num[] = new int[FBS5100_ComBase.BattGroupCountMax]; //最低按单体编号
|
| | | public double monvolMAX[] = new double[FBS5100_ComBase.BattGroupCountMax]; //最大单体电压
|
| | | public double monvolMIN[] = new double[FBS5100_ComBase.BattGroupCountMax]; //最低单体电压
|
| | | |
| | | public float vol[] = new float[FBS5100_ComBase.MonomerCountMax]; //单体电压
|
| | | |
| | | public FBS5100_VCData clone()
|
| | | {
|
| | | FBS5100_VCData obj = new FBS5100_VCData(); |
| | | |
| | | //obj.m_SysState = (FBS9100_SysState) m_SysState.clone();
|
| | | obj.dataType = dataType.clone();
|
| | | obj.CRC = CRC;
|
| | | obj.testTime = testTime;
|
| | | obj.battGroup = battGroup;
|
| | | obj.battSum = battSum;
|
| | | |
| | | obj.onlinevol = onlinevol.clone();
|
| | | obj.groupvol = groupvol.clone();
|
| | | obj.battstate = battstate.clone();
|
| | | obj.battcurr = battcurr.clone();
|
| | | |
| | | obj.battcap = battcap.clone();
|
| | | obj.batttemp = batttemp.clone();
|
| | | obj.monMAX_num = monMAX_num.clone();
|
| | | obj.monMIN_num = monMIN_num.clone();
|
| | | obj.monvolMAX = monvolMAX.clone();
|
| | | obj.monvolMIN = monvolMIN.clone();
|
| | | obj.vol = vol.clone();
|
| | | |
| | | return obj;
|
| | | }
|
| | | |
| | | public void copy(FBS5100_VCData source) {
|
| | | for(int i = 0 ; i < groupvol.length;i++) {
|
| | | this.groupvol[i] = source.groupvol[i];
|
| | | }
|
| | | for(int i = 0 ; i < battcurr.length;i++) {
|
| | | this.battcurr[i] = source.battcurr[i];
|
| | | }
|
| | | for(int i = 0 ; i < battstate.length;i++) {
|
| | | this.battstate[i] = source.battstate[i];
|
| | | }
|
| | | this.muxianvol_discharge = source.muxianvol_discharge; //放电母线电压 24Vd+
|
| | | this.muxianvol_charge = source.muxianvol_charge; //充电母线电压 24Vc+
|
| | | this.boostDCDC_OutVol = source.boostDCDC_OutVol; //升压DCDC输出电压 48Vd+
|
| | | this.muxianvol = source.muxianvol; //48V母线电压 48Vo+
|
| | |
|
| | | }
|
| | | |
| | | /**
|
| | | * 2021-05-11 911设备用于区分大功率假负载设备读取在线电压和组端电压数据修改
|
| | | * @param bf
|
| | | * @param dev_type
|
| | | * @param soft_ver
|
| | | * @param hard_ver
|
| | | * @return
|
| | | */
|
| | | public boolean putByteBuffer(byte[] data)
|
| | | {
|
| | | ByteBuffer bf = ByteBuffer.allocate(BASIC_LEN);
|
| | | bf.order(ByteOrder.LITTLE_ENDIAN);
|
| | | for(int i = 0 ;i<this.dataType.length;i++) {
|
| | | bf.put(FBS5100_ComBase.changeIntToByte(this.dataType[i]));
|
| | | }
|
| | | bf.put(data);
|
| | | bf.flip();
|
| | | //System.out.println(ComFn.bytesToHexString(bf.array(), bf.array().length));
|
| | | if(bf.limit() < BASIC_LEN) {
|
| | | System.out.println(bf.limit() + "==" + BASIC_LEN);
|
| | | return false;
|
| | | }
|
| | | int battcount = bf.getShort(10);
|
| | | if(battcount > FBS5100_ComBase.MonomerCountMax) {
|
| | | //System.out.println("单体数目"+battcount);
|
| | | return false;
|
| | | }
|
| | | |
| | | ByteBuffer tmpbuf = bf;
|
| | | int crc0 = tmpbuf.getShort(4) & 0xFFFF;
|
| | | tmpbuf.putShort(4, (short) 0);
|
| | | int crc1 = FBS5100_Crc16.CalCRC16(tmpbuf, BASIC_LEN + 2*battcount);
|
| | | if(crc0 != crc1) {
|
| | | System.out.println(crc0 + "===" + crc1);
|
| | | return false;
|
| | | }
|
| | | tmpbuf.position(0);
|
| | | for(int n=0; n<4; n++)
|
| | | dataType[n] = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | |
| | | CRC = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | testTime.hour = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | testTime.minute = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | testTime.second = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | battGroup = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | battSum = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | muxianvol_discharge = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; //放电母线电压 24Vd+
|
| | | muxianvol_charge = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; //充电母线电压 24Vc+
|
| | | boostDCDC_OutVol = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; //升压DCDC输出电压 48Vd+
|
| | | |
| | | |
| | | muxianvol = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; //48V母线电压 48Vo+
|
| | | /*** 2020-12-04 lijun 逆变版本的设备在线电压和组端电压不用/10 ****/
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | //float o_v = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/100;
|
| | | onlinevol[n] = muxianvol;
|
| | | }
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | float g_v = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;
|
| | | groupvol[n] = g_v;
|
| | | }
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | battcurr[n] = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;
|
| | | }
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | battstate[n] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | if(FBS5100_ComBase.BattState_Discharge == battstate[n]) {
|
| | | battcurr[n] *= -1;
|
| | | }
|
| | | }
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | float b_cap = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort());
|
| | | if(FBS5100_ComBase.BattState_Discharge == battstate[n]) {
|
| | | b_cap *= -1;
|
| | | }
|
| | | battcap[n] = b_cap;
|
| | | }
|
| | | for(int n=0; n<(BATTGROUP_COUNT-1); n++)
|
| | | /**
|
| | | * 2021-10-27 @lijun 修复温度<10度时,温度显示bug
|
| | | */
|
| | | //batttemp[n] = FBS5100_ComBase.changeShortToDouble((short)(tmpbuf.getShort()-(short)100))/10;
|
| | | batttemp[n] = FBS5100_ComBase.changeShortToFloat((short)(tmpbuf.getShort()))/10 -10;
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | monMAX_num[n] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | }
|
| | | battXuHangTime = (monMAX_num[0]<<16) + monMAX_num[1];
|
| | | stationPowerOffTLong = (monMAX_num[2]<<16) + monMAX_num[3];
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | monMIN_num[n] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | }
|
| | | stationPowerOffCNT = monMIN_num[0];
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | monvolMAX[n] = ((double)FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort()))/100;
|
| | | conresist = monvolMAX[0]/10;
|
| | | conresist1 = monvolMAX[1]/10;
|
| | | condvoldp = monvolMAX[2];
|
| | | condvoldp1 = monvolMAX[3];
|
| | | //System.out.println(conresist+"=="+conresist1+"=="+condvoldp+"=="+condvoldp1);
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | monvolMIN[n] = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
|
| | | |
| | | for(int n=0; n<battSum; n++) {
|
| | | vol[n] = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/1000;
|
| | | }
|
| | | |
| | | tmpbuf.compact();
|
| | | tmpbuf.flip();
|
| | | System.out.println(this);
|
| | | 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<4; n++)
|
| | | {
|
| | | if(1 != fis.read(tag, 0, 1))
|
| | | {
|
| | | file_end = true;
|
| | | break;
|
| | | }
|
| | | if((0xFD != (tag[0]&0xFF)) && (0xFC != (tag[0]&0xFF)) && (0xFB != (tag[0]&0xFF)))
|
| | | {
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | | if(n >= 4)
|
| | | {
|
| | | 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 type) {
|
| | | for(int i = 0;i<dataType.length;i++) {
|
| | | dataType[i] = type;
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS5100_FBSData [dataType=" + Arrays.toString(dataType) + ", testTime=" + testTime + ", battGroup="
|
| | | + battGroup + ", battSum=" + battSum + ", battGroupNum=" + battGroupNum + ", muxianvol_discharge="
|
| | | + muxianvol_discharge + ", muxianvol_charge=" + muxianvol_charge + ", boostDCDC_OutVol="
|
| | | + boostDCDC_OutVol + ", muxianvol=" + muxianvol + ", conresist=" + conresist + ", conresist1="
|
| | | + conresist1 + ", condvoldp=" + condvoldp + ", condvoldp1=" + condvoldp1 + ", onlinevol="
|
| | | + Arrays.toString(onlinevol) + ", groupvol=" + Arrays.toString(groupvol) + ", battstate="
|
| | | + Arrays.toString(battstate) + ", battcurr=" + Arrays.toString(battcurr) + ", battcap="
|
| | | + Arrays.toString(battcap) + ", batttemp=" + Arrays.toString(batttemp) + "]";
|
| | | }
|
| | | |
| | | |
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | public class FBS5100_Main {
|
| | |
|
| | | |
| | | |
| | | public static void main(String[] args) {
|
| | | |
| | | |
| | | //解析监测放电/核容放电数据
|
| | | FBS5100_DisChargeData data = new FBS5100_DisChargeData();
|
| | | //data.parseFileData("D:\\桌面文件备份\\公司各种设备资料\\配网电源相关\\通信协议相关\\数据解析(1)\\BATT_CAP\\CAP0017.BCP");
|
| | | //System.out.println(data);
|
| | | |
| | | //解析充电数据
|
| | | FBS5100_ChargeData chardata = new FBS5100_ChargeData();
|
| | | chardata.parseFileData("D:\\桌面文件备份\\公司各种设备资料\\配网电源相关\\通信协议相关\\数据解析(1)\\BATT_CHR\\CHR0021.CHR");
|
| | | System.out.println(chardata);
|
| | | |
| | | }
|
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | |
|
| | |
|
| | | public class FBS5100_TestParam {
|
| | | public static final int BYTE_LEN = 44;
|
| | | //private final int BYTE_LEN = 45;
|
| | | |
| | | |
| | | public int HourRate = 0; //小时率
|
| | | public float DisCurr = 0; //放电电流A(1~50)
|
| | | public float DisCap = 0; //放电容量AH(10~9999)
|
| | | public int DisTime = 0; //放电时长Min(1~9999)
|
| | | public float GroupVol_LOW = 0; //组端下限(0.1V 18~28.8) |
| | | public float MonomerVol_LOW = 0; //单体电压下限
|
| | | public int MonomerLowCount = 0; //单体下限数量
|
| | | public int BattGroupNum = 0; //组号 [0-全组一起测试 1~4分别代表单组放电] |
| | | public int OnlineVolLowAction = 0; //在线电压低处理
|
| | | public int StaticTime = 0; //静置时间
|
| | | public int DisTestCount = 0; //放电测试次数
|
| | | |
| | | public float DCVolHighLimit = 0; //升压上限(0.1V 48.0~54.0)
|
| | | |
| | | public float ChargeCurrSet = 0; //充电电流(1~50A)
|
| | | public int DisTestType = 0; //放电测试类型
|
| | | public float MonomerTmp_High = 0; //单体温度上限
|
| | | |
| | | public int bakeup5 = 0;
|
| | | public int bakeup6 = 0;
|
| | | public int bakeup7 = 0;
|
| | | public int bakeup8 = 0;
|
| | | public int bakeup9 = 0;
|
| | | public int bakeup10 = 0;
|
| | |
|
| | | public int CRC = 0;
|
| | | |
| | | public FBS5100_TestParam clone()
|
| | | {
|
| | | FBS5100_TestParam obj = null; |
| | | try
|
| | | {
|
| | | obj = (FBS5100_TestParam)super.clone();
|
| | | }
|
| | | catch(CloneNotSupportedException e)
|
| | | {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return obj;
|
| | | }
|
| | | |
| | | public void clear()
|
| | | {
|
| | | HourRate = 0;
|
| | | DisCurr = 0;
|
| | | DisCap = 0;
|
| | | DisTime = 0;
|
| | | GroupVol_LOW = 0;
|
| | | MonomerVol_LOW = 0;
|
| | | MonomerLowCount = 0;
|
| | | BattGroupNum = 0;
|
| | | OnlineVolLowAction = 0;
|
| | | StaticTime = 0;
|
| | | DisTestCount = 0;
|
| | | |
| | | DCVolHighLimit = 0;
|
| | | |
| | | ChargeCurrSet = 0;
|
| | | DisTestType = 0;
|
| | | MonomerTmp_High = 0;
|
| | | |
| | | bakeup5 = 0;
|
| | | bakeup6 = 0;
|
| | | bakeup7 = 0;
|
| | | bakeup8 = 0;
|
| | | bakeup9 = 0;
|
| | | bakeup10 = 0;
|
| | |
|
| | | CRC = 0;
|
| | | }
|
| | | |
| | | public boolean putByteBuffer(final ByteBuffer bf)
|
| | | {
|
| | | if(bf.limit() < BYTE_LEN){
|
| | | return false;
|
| | | }
|
| | | ByteBuffer tmpbuf = bf;
|
| | | int crc0 = tmpbuf.getShort(BYTE_LEN-2) & 0xFFFF;
|
| | | int crc1 = FBS5100_Crc16.CalCRC16(tmpbuf, BYTE_LEN-2);
|
| | | if(crc0 != crc1){
|
| | | System.out.println("FBS5100_TestParam:" + crc0 + "===" + crc1);
|
| | | return false;
|
| | | }
|
| | | |
| | | tmpbuf.position(0);
|
| | | HourRate = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | DisCurr = (float)FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort());
|
| | | DisCap = (float)FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort());
|
| | | DisTime = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | GroupVol_LOW = (float)FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort())/10;
|
| | | MonomerVol_LOW = (float)FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
|
| | | MonomerLowCount = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | BattGroupNum = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | OnlineVolLowAction = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | StaticTime = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | DisTestCount = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | DCVolHighLimit = (float)FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort())/10;
|
| | | |
| | | ChargeCurrSet = (float)FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort());
|
| | | DisTestType = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | MonomerTmp_High = (float)FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort())/10;
|
| | | bakeup5 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup6 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup7 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup8 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup9 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | bakeup10 = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | CRC = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | tmpbuf.compact();
|
| | | tmpbuf.flip();
|
| | | |
| | | //System.out.println(this);
|
| | | return true;
|
| | | }
|
| | | |
| | | public ByteBuffer getByteBuffer()
|
| | | {
|
| | | System.out.println(this);
|
| | | |
| | | ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
|
| | | bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(HourRate));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(DisCurr));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(DisCap));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(DisTime));
|
| | | //bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort((GroupVol_LOW+0.000001)*10));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort((GroupVol_LOW)*10));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort((MonomerVol_LOW)*1000));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(MonomerLowCount));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(BattGroupNum));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(OnlineVolLowAction));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(StaticTime));
|
| | | |
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(DisTestCount));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort((DCVolHighLimit)*10));
|
| | | |
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(ChargeCurrSet));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(DisTestType));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeFloatToShort((MonomerTmp_High)*10));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup5));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup6));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup7));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup8));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup9));
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(bakeup10));
|
| | | |
| | | CRC = FBS5100_Crc16.CalCRC16(bytebuffer, bytebuffer.position());
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(CRC));
|
| | | //System.out.println(this+"$$$$$$$$$$$$$$$$$$$$$$$$$");
|
| | | bytebuffer.flip();
|
| | | |
| | | return bytebuffer;
|
| | | }
|
| | |
|
| | | |
| | | |
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS5100_TestParam [HourRate=" + HourRate + ", DisCurr=" + DisCurr
|
| | | + ", DisCap=" + DisCap + ", DisTime=" + DisTime + ", GroupVol_LOW=" + GroupVol_LOW + ", MonomerVol_LOW="
|
| | | + MonomerVol_LOW + ", MonomerLowCount=" + MonomerLowCount + ", BattGroupNum=" + BattGroupNum
|
| | | + ", OnlineVolLowAction=" + OnlineVolLowAction + ", StaticTime=" + StaticTime + ", DisTestCount="
|
| | | + DisTestCount + ", DCVolHighLimit=" + DCVolHighLimit + ", ChargeCurrSet=" + ChargeCurrSet
|
| | | + ", DisTestType=" + DisTestType + ", MonomerTmp_High=" + MonomerTmp_High + "]";
|
| | | }
|
| | |
|
| | | public static void main(String[] args) {
|
| | | double d = 56.6;
|
| | | float f = (float)d;
|
| | | |
| | | float ff = (56.6f)*10;
|
| | | |
| | | System.err.println(f);
|
| | | |
| | | double dd = 56.6;
|
| | | System.out.println("dd:"+dd);
|
| | | FBS5100_ComBase.changeDoubleToShort((dd)*10);
|
| | | System.out.println((int)ff);
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | |
|
| | |
|
| | | public class FBS5100_TestTime {
|
| | | public int hour = 0;
|
| | | public int minute = 0;
|
| | | public int second = 0;
|
| | | |
| | | public void putByteBuffer(final ByteBuffer bf)
|
| | | {
|
| | | hour = FBS5100_ComBase.changeByteToInt(bf.get());
|
| | | minute = FBS5100_ComBase.changeByteToInt(bf.get());
|
| | | second = FBS5100_ComBase.changeByteToInt(bf.get());
|
| | | }
|
| | | |
| | | public ByteBuffer getBytes()
|
| | | {
|
| | | ByteBuffer bytebuffer = ByteBuffer.allocate(6);
|
| | | bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(hour));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(minute));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(second));
|
| | | bytebuffer.flip();
|
| | | |
| | | return bytebuffer;
|
| | | }
|
| | | |
| | | public int getSecondCount()
|
| | | {
|
| | | return (hour*3600 + minute*60 + second);
|
| | | }
|
| | | |
| | | public static int getMinutesCount(String str)
|
| | | {
|
| | | int mcount = 0;
|
| | | try
|
| | | {
|
| | | // 先找到字符串中:的位置
|
| | | int position = str.indexOf(":");
|
| | | // 将每个:之间的字符串转换成整型
|
| | | mcount = Integer.parseInt(str.substring(0, position))*60;
|
| | | mcount += Integer.parseInt(str.substring(position + 1));
|
| | | }
|
| | | catch(Exception e)
|
| | | {
|
| | | mcount = 0;
|
| | | }
|
| | | |
| | | return mcount;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "FBS5100_TestTime [hour=" + hour + ", minute=" + minute + ", second=" + second + "]";
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.fgkj.fbs5100;
|
| | |
|
| | | import java.nio.ByteBuffer;
|
| | | import java.nio.ByteOrder;
|
| | |
|
| | | public class FBS5100_VCData {
|
| | | private final int BYTE_LEN = 1500;
|
| | | private final int BATTGROUP_COUNT = FBS5100_ComBase.BattGroupCountMax;
|
| | | private final int BASIC_LEN = 10 + 20*BATTGROUP_COUNT;
|
| | | |
| | | //public FBS9100_SysState m_SysState = new FBS9100_SysState();
|
| | | |
| | | public int dataType[] = {0xAA, 0xAA, 0xAA, 0xAA};
|
| | | public int CRC = 0;
|
| | | public FBS5100_TestTime testTime = new FBS5100_TestTime();
|
| | | public int battGroup = 1;
|
| | | public int battSum = 24;
|
| | | public int battGroupNum = 1;
|
| | | |
| | | public float muxianvol_discharge; //放电母线电压 24Vd+
|
| | | public float muxianvol_charge; //充电母线电压 24Vc+
|
| | | public float boostDCDC_OutVol; //升压DCDC输出电压 48Vd+
|
| | | public float muxianvol; //48V母线电压 48Vo+
|
| | |
|
| | | |
| | | public int battXuHangTime = 0;
|
| | | public int stationPowerOffTLong = 0;
|
| | | public int stationPowerOffCNT = 0;
|
| | | |
| | | public double conresist = 0; //组1接触器导通阻抗 (0.001mR)
|
| | | public double conresist1 = 0; //组2接触器导通阻抗 (0.001mR)
|
| | | public double condvoldp = 0; //组1二极管压降(0.01V) |
| | | public double condvoldp1 = 0; //组2二极管压降(0.01V) |
| | | |
| | | |
| | | public float onlinevol[] = new float[FBS5100_ComBase.BattGroupCountMax]; //在线电压
|
| | | public float groupvol[] = new float[FBS5100_ComBase.BattGroupCountMax]; //组端电压
|
| | | public int battstate[] = new int[FBS5100_ComBase.BattGroupCountMax]; //充放电状态 3 5 9 |
| | | public float battcurr[] = new float[FBS5100_ComBase.BattGroupCountMax]; //电池组电流
|
| | | public float battcap[] = new float[FBS5100_ComBase.BattGroupCountMax]; //电池组容量
|
| | | public float batttemp[] = new float[FBS5100_ComBase.BattGroupCountMax]; //电池组温度
|
| | | public int monMAX_num[] = new int[FBS5100_ComBase.BattGroupCountMax]; //最大单体编号 |
| | | public int monMIN_num[] = new int[FBS5100_ComBase.BattGroupCountMax]; //最低按单体编号
|
| | | public double monvolMAX[] = new double[FBS5100_ComBase.BattGroupCountMax]; //最大单体电压
|
| | | public double monvolMIN[] = new double[FBS5100_ComBase.BattGroupCountMax]; //最低单体电压
|
| | | |
| | | public float vol[] = new float[FBS5100_ComBase.MonomerCountMax]; //单体电压
|
| | | |
| | | public FBS5100_VCData clone()
|
| | | {
|
| | | FBS5100_VCData obj = new FBS5100_VCData(); |
| | | |
| | | //obj.m_SysState = (FBS9100_SysState) m_SysState.clone();
|
| | | obj.dataType = dataType.clone();
|
| | | obj.CRC = CRC;
|
| | | obj.testTime = testTime;
|
| | | obj.battGroup = battGroup;
|
| | | obj.battSum = battSum;
|
| | | |
| | | obj.onlinevol = onlinevol.clone();
|
| | | obj.groupvol = groupvol.clone();
|
| | | obj.battstate = battstate.clone();
|
| | | obj.battcurr = battcurr.clone();
|
| | | |
| | | obj.battcap = battcap.clone();
|
| | | obj.batttemp = batttemp.clone();
|
| | | obj.monMAX_num = monMAX_num.clone();
|
| | | obj.monMIN_num = monMIN_num.clone();
|
| | | obj.monvolMAX = monvolMAX.clone();
|
| | | obj.monvolMIN = monvolMIN.clone();
|
| | | obj.vol = vol.clone();
|
| | | |
| | | return obj;
|
| | | }
|
| | | |
| | | public void copy(FBS5100_VCData source) {
|
| | | for(int i = 0 ; i < groupvol.length;i++) {
|
| | | this.groupvol[i] = source.groupvol[i];
|
| | | }
|
| | | for(int i = 0 ; i < battcurr.length;i++) {
|
| | | this.battcurr[i] = source.battcurr[i];
|
| | | }
|
| | | for(int i = 0 ; i < battstate.length;i++) {
|
| | | this.battstate[i] = source.battstate[i];
|
| | | }
|
| | | this.muxianvol_discharge = source.muxianvol_discharge; //放电母线电压 24Vd+
|
| | | this.muxianvol_charge = source.muxianvol_charge; //充电母线电压 24Vc+
|
| | | this.boostDCDC_OutVol = source.boostDCDC_OutVol; //升压DCDC输出电压 48Vd+
|
| | | this.muxianvol = source.muxianvol; //48V母线电压 48Vo+
|
| | |
|
| | | }
|
| | | |
| | | /**
|
| | | * 2021-05-11 911设备用于区分大功率假负载设备读取在线电压和组端电压数据修改
|
| | | * @param bf
|
| | | * @param dev_type
|
| | | * @param soft_ver
|
| | | * @param hard_ver
|
| | | * @return
|
| | | */
|
| | | public boolean putByteBuffer(final ByteBuffer bf)
|
| | | {
|
| | | if(bf.limit() < BASIC_LEN) {
|
| | | System.out.println(bf.limit() + "==" + BASIC_LEN);
|
| | | return false;
|
| | | }
|
| | | int battcount = bf.getShort(10);
|
| | | if(battcount > FBS5100_ComBase.MonomerCountMax) {
|
| | | System.out.println("单体数目"+battcount);
|
| | | return false;
|
| | | }
|
| | | |
| | | ByteBuffer tmpbuf = bf;
|
| | | int crc0 = tmpbuf.getShort(4) & 0xFFFF;
|
| | | tmpbuf.putShort(4, (short) 0);
|
| | | int crc1 = FBS5100_Crc16.CalCRC16(tmpbuf, BASIC_LEN + 2*battcount);
|
| | | if(crc0 != crc1) {
|
| | | return false;
|
| | | }
|
| | | |
| | | tmpbuf.position(0);
|
| | | for(int n=0; n<4; n++)
|
| | | dataType[n] = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | |
| | | CRC = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | testTime.hour = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | testTime.minute = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | testTime.second = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | battGroup = FBS5100_ComBase.changeByteToInt(tmpbuf.get());
|
| | | battSum = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | |
| | | muxianvol_discharge = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; //放电母线电压 24Vd+
|
| | | muxianvol_charge = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; //充电母线电压 24Vc+
|
| | | boostDCDC_OutVol = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; //升压DCDC输出电压 48Vd+
|
| | | |
| | | |
| | | muxianvol = (float)FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10; //48V母线电压 48Vo+
|
| | | /*** 2020-12-04 lijun 逆变版本的设备在线电压和组端电压不用/10 ****/
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | //float o_v = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/100;
|
| | | onlinevol[n] = muxianvol;
|
| | | }
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | float g_v = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;
|
| | | groupvol[n] = g_v;
|
| | | }
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | battcurr[n] = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/10;
|
| | | }
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | battstate[n] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | if(FBS5100_ComBase.BattState_Discharge == battstate[n]) {
|
| | | battcurr[n] *= -1;
|
| | | }
|
| | | }
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | float b_cap = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort());
|
| | | if(FBS5100_ComBase.BattState_Discharge == battstate[n]) {
|
| | | b_cap *= -1;
|
| | | }
|
| | | battcap[n] = b_cap;
|
| | | }
|
| | | for(int n=0; n<(BATTGROUP_COUNT-1); n++)
|
| | | /**
|
| | | * 2021-10-27 @lijun 修复温度<10度时,温度显示bug
|
| | | */
|
| | | //batttemp[n] = FBS5100_ComBase.changeShortToDouble((short)(tmpbuf.getShort()-(short)100))/10;
|
| | | batttemp[n] = FBS5100_ComBase.changeShortToFloat((short)(tmpbuf.getShort()))/10 -10;
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | monMAX_num[n] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | }
|
| | | battXuHangTime = (monMAX_num[0]<<16) + monMAX_num[1];
|
| | | stationPowerOffTLong = (monMAX_num[2]<<16) + monMAX_num[3];
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++) {
|
| | | monMIN_num[n] = FBS5100_ComBase.changeShortToInt(tmpbuf.getShort());
|
| | | }
|
| | | stationPowerOffCNT = monMIN_num[0];
|
| | | |
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | monvolMAX[n] = ((double)FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort()))/100;
|
| | | conresist = monvolMAX[0]/10;
|
| | | conresist1 = monvolMAX[1]/10;
|
| | | condvoldp = monvolMAX[2];
|
| | | condvoldp1 = monvolMAX[3];
|
| | | //System.out.println(conresist+"=="+conresist1+"=="+condvoldp+"=="+condvoldp1);
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | monvolMIN[n] = FBS5100_ComBase.changeShortToDouble(tmpbuf.getShort())/1000;
|
| | | |
| | | for(int n=0; n<battSum; n++) {
|
| | | vol[n] = FBS5100_ComBase.changeShortToFloat(tmpbuf.getShort())/1000;
|
| | | }
|
| | | |
| | | tmpbuf.compact();
|
| | | tmpbuf.flip();
|
| | | //System.out.println(this);
|
| | | return true;
|
| | | }
|
| | | |
| | | public ByteBuffer getByteBuffer()
|
| | | {
|
| | | ByteBuffer bytebuffer = ByteBuffer.allocate(BYTE_LEN);
|
| | | bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
|
| | | |
| | | for(int n=0; n<4; n++)
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(dataType[n]));
|
| | | |
| | | CRC = 0;
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(CRC));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(testTime.hour));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(testTime.minute));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(testTime.second));
|
| | | bytebuffer.put(FBS5100_ComBase.changeIntToByte(battGroup));
|
| | | //System.err.println(bytebuffer.position()+"#########################");
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(battSum));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(onlinevol[n]*10));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(groupvol[n]*10));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(battstate[n]));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(battcurr[n]*10));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(battcap[n]));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(batttemp[n]*10));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(monMAX_num[n]));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeIntToShort(monMIN_num[n]));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(monvolMAX[n]*1000));
|
| | | for(int n=0; n<BATTGROUP_COUNT; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(monvolMIN[n]*1000));
|
| | | |
| | | for(int n=0; n<battSum; n++)
|
| | | bytebuffer.putShort(FBS5100_ComBase.changeDoubleToShort(vol[n]*1000));
|
| | | |
| | | CRC = FBS5100_Crc16.CalCRC16(bytebuffer, bytebuffer.position());
|
| | | bytebuffer.putShort(4, FBS5100_ComBase.changeIntToShort(CRC));
|
| | | bytebuffer.flip();
|
| | | //System.err.println("buffer limit:"+bytebuffer.limit());
|
| | | return bytebuffer;
|
| | | }
|
| | | }
|