From 52d28224af7c3c471e821b476eff70a5bb7c8f4f Mon Sep 17 00:00:00 2001 From: Administrator <1525436766@qq.com> Date: 星期一, 15 五月 2023 16:05:40 +0800 Subject: [PATCH] 配网电源提交放电数据文件解析 --- FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_Main.java | 21 FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_BattParam.class | 0 FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_DisChargeData.java | 125 +++ FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeData.java | 123 +++ FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_FBSData.java | 281 +++++++ FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_VCData.class | 0 FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeData.class | 0 FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ComBase.class | 0 FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_DisChargeData.class | 0 FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_VCData.java | 248 ++++++ FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_TestParam.class | 0 FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_FBSData.class | 0 FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_Crc16.java | 65 + FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeParam.class | 0 FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_TestTime.class | 0 FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_CapState.class | 0 FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeParam.java | 171 ++++ FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ComBase.java | 464 +++++++++++ FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_CapState.java | 157 +++ FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_DateTime.class | 0 FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_BattParam.java | 192 ++++ FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_TestParam.java | 193 ++++ FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_Crc16.class | 0 FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_Main.class | 0 FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeState.java | 196 ++++ FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeState.class | 0 FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_DateTime.java | 75 + FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_TestTime.java | 60 + 28 files changed, 2,371 insertions(+), 0 deletions(-) diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_BattParam.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_BattParam.class new file mode 100644 index 0000000..3ecd7d6 --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_BattParam.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_CapState.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_CapState.class new file mode 100644 index 0000000..892d0bf --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_CapState.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeData.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeData.class new file mode 100644 index 0000000..4796cac --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeData.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeParam.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeParam.class new file mode 100644 index 0000000..becc6df --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeParam.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeState.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeState.class new file mode 100644 index 0000000..623bb92 --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ChargeState.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ComBase.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ComBase.class new file mode 100644 index 0000000..2e2cf40 --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_ComBase.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_Crc16.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_Crc16.class new file mode 100644 index 0000000..03abc71 --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_Crc16.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_DateTime.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_DateTime.class new file mode 100644 index 0000000..bfcb7b6 --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_DateTime.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_DisChargeData.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_DisChargeData.class new file mode 100644 index 0000000..be52381 --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_DisChargeData.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_FBSData.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_FBSData.class new file mode 100644 index 0000000..5a04291 --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_FBSData.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_Main.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_Main.class new file mode 100644 index 0000000..89b8359 --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_Main.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_TestParam.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_TestParam.class new file mode 100644 index 0000000..8e454fe --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_TestParam.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_TestTime.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_TestTime.class new file mode 100644 index 0000000..b4c249c --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_TestTime.class Binary files differ diff --git a/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_VCData.class b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_VCData.class new file mode 100644 index 0000000..392dcf0 --- /dev/null +++ b/FBS9600ForFBO_Parse/bin/com/fgkj/fbs5100/FBS5100_VCData.class Binary files differ diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_BattParam.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_BattParam.java new file mode 100644 index 0000000..c179a71 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_BattParam.java @@ -0,0 +1,192 @@ +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; + } + + + /** + * 灏哹ytebuffer涓殑鏁版嵁鍙栧嚭鏀惧叆璇ュ璞$殑灞炴�т腑锛屽苟杩斿洖鏄惁鍙栧嚭鎴愬姛 + * + * @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; + } + + + /** + * 灏嗘暟鎹斁鍏ytebuffer涓苟杩斿洖 + * @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 + "]"; + } + +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_CapState.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_CapState.java new file mode 100644 index 0000000..c0964e1 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_CapState.java @@ -0,0 +1,157 @@ +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) + "]"; + } +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeData.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeData.java new file mode 100644 index 0000000..f78a3c4 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeData.java @@ -0,0 +1,123 @@ +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(); + } + } + } + } + + //瑙f瀽鏁版嵁澶� + 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 + "]"; + } +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeParam.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeParam.java new file mode 100644 index 0000000..ef86083 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeParam.java @@ -0,0 +1,171 @@ +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 + "]"; + } +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeState.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeState.java new file mode 100644 index 0000000..fc294d3 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ChargeState.java @@ -0,0 +1,196 @@ +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) + "]"; + } + + +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ComBase.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ComBase.java new file mode 100644 index 0000000..7fe9d16 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_ComBase.java @@ -0,0 +1,464 @@ +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; //甯歌 + + //---------------------------------------------------------------------------- + //------------------------ 瑙f瀽缁撴灉 ---------------------------------------------------- + public static final int PARSE_RESULT_NULL = 0; //鏈煡 + public static final int PARSE_RESULT_SUCCESS = 1; //瑙f瀽鎴愬姛 + 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鐨勬渶澶CDC妯″潡淇℃伅 + //---------------------------------------------------------------------------- + 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; //璇诲彇閿傜數姹燘MS妯℃嫙閲� + public static final int CMD_GetLiBMSState = 0x96; //璇诲彇閿傜數姹燘MS鍛婅閲� + + 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; //璇诲彇閿傜數姹燘MS妯℃嫙閲� + public static final int CMD_GetLiBMSState_Ack = 0x94; //璇诲彇閿傜數姹燘MS鍛婅閲� + + 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 + * 鍋囪礋杞紹TS鏂板杩炴帴鏉¢樆鎶椾俊鎭互鍙婃俯婀垮害淇℃伅璇诲彇 + */ + 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; //姝e父鏍稿鏀剧數娴嬭瘯绫诲瀷 + 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; //閾佸鐗堟湰鐨刡t + public static final int BTSE_DevType_NiBian = 0x06; //閫嗗彉鐗堟湰鐨刡ts + 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; //姝e湪鏀剧數娴嬭瘯 + public static final int ALARM_DISCHARGEWAIT = 3; //姝e湪绛夊緟鏀剧數 + public static final int ALARM_LimitCHARGING = 4; //姝e湪闄愭祦鍏呯數 + public static final int ALARM_LargeCHARGING = 5; //姝e湪鐩磋繛鍏呯數 + public static final int ALARM_CHARGEWAIT = 6; //姝e湪绛夊緟鍏呯數 + 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)******************************* +***************************************************************************************/ \ No newline at end of file diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_Crc16.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_Crc16.java new file mode 100644 index 0000000..b4ff3c7 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_Crc16.java @@ -0,0 +1,65 @@ +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; //锟截硷拷锟皆的筹拷值... + 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) ********************************* +***************************************************************************************/ diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_DateTime.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_DateTime.java new file mode 100644 index 0000000..3c9b66b --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_DateTime.java @@ -0,0 +1,75 @@ +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 + "]"; + } + +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_DisChargeData.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_DisChargeData.java new file mode 100644 index 0000000..55bc898 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_DisChargeData.java @@ -0,0 +1,125 @@ +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(); + } + } + } + } + + //瑙f瀽鏁版嵁澶� + 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 + "]"; + } + + +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_FBSData.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_FBSData.java new file mode 100644 index 0000000..69237ef --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_FBSData.java @@ -0,0 +1,281 @@ +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搴︽椂锛屾俯搴︽樉绀篵ug + */ + //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) + "]"; + } + + +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_Main.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_Main.java new file mode 100644 index 0000000..06c1fec --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_Main.java @@ -0,0 +1,21 @@ +package com.fgkj.fbs5100; + +public class FBS5100_Main { + + + + public static void main(String[] args) { + + + //瑙f瀽鐩戞祴鏀剧數/鏍稿鏀剧數鏁版嵁 + FBS5100_DisChargeData data = new FBS5100_DisChargeData(); + //data.parseFileData("D:\\妗岄潰鏂囦欢澶囦唤\\鍏徃鍚勭璁惧璧勬枡\\閰嶇綉鐢垫簮鐩稿叧\\閫氫俊鍗忚鐩稿叧\\鏁版嵁瑙f瀽(1)\\BATT_CAP\\CAP0017.BCP"); + //System.out.println(data); + + //瑙f瀽鍏呯數鏁版嵁 + FBS5100_ChargeData chardata = new FBS5100_ChargeData(); + chardata.parseFileData("D:\\妗岄潰鏂囦欢澶囦唤\\鍏徃鍚勭璁惧璧勬枡\\閰嶇綉鐢垫簮鐩稿叧\\閫氫俊鍗忚鐩稿叧\\鏁版嵁瑙f瀽(1)\\BATT_CHR\\CHR0021.CHR"); + System.out.println(chardata); + + } +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_TestParam.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_TestParam.java new file mode 100644 index 0000000..57ddae9 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_TestParam.java @@ -0,0 +1,193 @@ +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鍒嗗埆浠h〃鍗曠粍鏀剧數] + 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); + } +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_TestTime.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_TestTime.java new file mode 100644 index 0000000..2220d04 --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_TestTime.java @@ -0,0 +1,60 @@ +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 + "]"; + } + +} diff --git a/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_VCData.java b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_VCData.java new file mode 100644 index 0000000..94fedfe --- /dev/null +++ b/FBS9600ForFBO_Parse/src/com/fgkj/fbs5100/FBS5100_VCData.java @@ -0,0 +1,248 @@ +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搴︽椂锛屾俯搴︽樉绀篵ug + */ + //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; + } +} -- Gitblit v1.9.1