ソースを参照

V0.2.0.12-MS 1、增加电池连接状态(车或站);2、增加UDS SOC修正功能;3、累计充电Ah包含动能回收Ah数

BJQX-ZHENGCHAO\Zhengchao 1 年間 前
コミット
250558ddbd

+ 27 - 0
code/BCU/BBox_Bcu.c

@@ -109,12 +109,25 @@ void BCUEEDataRead(void)
 	memcpy(iscv_Q_chrgEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_chrgE, sizeof(iscv_Q_chrgEi));
 	memcpy(iscv_Q_staticEi, BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_staticE, sizeof(iscv_Q_staticEi));
 	*///DAM
+
+	//uint16
+	damd_Nr_totalStaChrgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalStaChrgE;
+	damd_Nr_totalChgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalChgE;
+	damd_Nr_totalVehChrgEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalVehChrgE ;
+
+	//float
 	damd_Q_totalChrgCpEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalChrgCpE;
 	damd_E_totalChrgEngEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalChrgEngE;
 	damd_Q_totalRegenCpEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalRegenCpE;
 	damd_E_totalRegenEngEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalRegenEngE;
 	damd_Q_totalDisChrgCpEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalDisChrgCpE;
 	damd_E_totalDisChrgEngEi  = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalDisChrgEngE;
+
+	damd_Q_totalVehChrgCpEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalVehChrgCpE;
+	damd_E_totalVehChrgEngEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalVehChrgEngE;
+	damd_Q_totalSatChrgCpEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalSatChrgCpE ;
+	damd_E_totalSatChrgEngEi = BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalSatChrgEngE;
+
 }
 
 
@@ -128,6 +141,8 @@ void BCUEEDataSave(void)
 	BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_hourE = ihd_tm_hourEo;
 	BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_minE = ihd_tm_minEo;
 	BcuSaveDataInfo.BcuAppSaveDataInfo.ihd_tm_secE = ihd_tm_secEo;
+
+
     //SOC
 	BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_bcuSocE = socd_pct_bcuSocEo;
 	BcuSaveDataInfo.BcuAppSaveDataInfo.socd_pct_battSocE = socd_pct_battSocEo;
@@ -150,6 +165,12 @@ void BCUEEDataSave(void)
 	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_chrgE, iscv_Q_chrgEo,sizeof(iscv_Q_chrgEo));
 	memcpy(BcuSaveDataInfo.BcuAppSaveDataInfo.iscv_Q_staticE, iscv_Q_staticEo,sizeof(iscv_Q_staticEo));
 	*///DAM
+	//uint16
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalStaChrgE = damd_Nr_totalStaChrgEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalChgE = damd_Nr_totalChgEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Nr_totalVehChrgE = damd_Nr_totalVehChrgEo;
+
+	//float
 	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalChrgCpE = damd_Q_totalChrgCpEo;
 	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalChrgEngE = damd_E_totalChrgEngEo;
 	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalRegenCpE = damd_Q_totalRegenCpEo;
@@ -157,5 +178,11 @@ void BCUEEDataSave(void)
 	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalDisChrgCpE = damd_Q_totalDisChrgCpEo;
 	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalDisChrgEngE = damd_E_totalDisChrgEngEo;
 
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalVehChrgCpE = damd_Q_totalVehChrgCpEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalVehChrgEngE = damd_E_totalVehChrgEngEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_Q_totalSatChrgCpE = damd_Q_totalSatChrgCpEo;
+	BcuSaveDataInfo.BcuAppSaveDataInfo.damd_E_totalSatChrgEngE = damd_E_totalSatChrgEngEo;
+
+
 
 }

+ 4 - 6
code/BCU/BCUModel/BCU.c

@@ -1,11 +1,10 @@
 #include "BCU.h"
 #include "rtwtypes.h"
 #include "BCUDisp.h"
-#include "rt_nonfinite.h"
-#define IH100_MDLREF_HIDE_CHILD_
-#include "IH100.h"
 #define DAM_MDLREF_HIDE_CHILD_
 #include "DAM.h"
+#define IH100_MDLREF_HIDE_CHILD_
+#include "IH100.h"
 #define SOC_MDLREF_HIDE_CHILD_
 #include "SOC.h"
 
@@ -20,18 +19,17 @@ void BCU_step(void)
 
 void BCU_initialize(void)
 {
-  rt_InitInfAndNaN(sizeof(real_T));
   rted_tm_month = ((uint8_T)1U);
   rted_tm_day = ((uint8_T)1U);
   sohd_pct_bcuSoh = 100.0F;
-  IH100_initialize(rtmGetErrorStatusPointer(BCU_M));
   DAM_initialize(rtmGetErrorStatusPointer(BCU_M));
+  IH100_initialize(rtmGetErrorStatusPointer(BCU_M));
   SOC_initialize(rtmGetErrorStatusPointer(BCU_M));
-  SOC_Start();
   ihd_tm_dayEi = 1U;
   ihd_tm_dayEo = 1U;
   ihd_tm_monthEi = 1U;
   ihd_tm_monthEo = 1U;
+  IH100_Init();
   DAM_Init();
   SOC_Init();
 }

+ 0 - 2
code/BCU/BCUModel/BCU.h

@@ -6,8 +6,6 @@
 #endif
 
 #include "BCU_types.h"
-#include "rtGetInf.h"
-#include "rt_nonfinite.h"
 #include "zero_crossing_types.h"
 
 #include "BCUCal.h"

+ 13 - 4
code/BCU/BCUModel/BCUDisp.c

@@ -24,6 +24,9 @@ real32_T damd_E_totalVehChrgEngEo;
 uint16_T damd_Nr_totalChg;
 uint16_T damd_Nr_totalChgEi;
 uint16_T damd_Nr_totalChgEo;
+uint16_T damd_Nr_totalStaChrg;
+uint16_T damd_Nr_totalStaChrgEi;
+uint16_T damd_Nr_totalStaChrgEo;
 uint16_T damd_Nr_totalVehChrg;
 uint16_T damd_Nr_totalVehChrgEi;
 uint16_T damd_Nr_totalVehChrgEo;
@@ -39,6 +42,12 @@ real32_T damd_Q_totalDisChrgCpEo;
 real32_T damd_Q_totalRegenCp;
 real32_T damd_Q_totalRegenCpEi;
 real32_T damd_Q_totalRegenCpEo;
+real32_T damd_Q_totalSatChrgCp;
+real32_T damd_Q_totalSatChrgCpEi;
+real32_T damd_Q_totalSatChrgCpEo;
+real32_T damd_Q_totalVehChrgCp;
+real32_T damd_Q_totalVehChrgCpEi;
+real32_T damd_Q_totalVehChrgCpEo;
 uint8_T damd_st_chgCnctObjEi;
 uint8_T damd_st_chgCnctObjEo;
 chrgSt dcmd_st_chrgSt_T2;
@@ -74,12 +83,12 @@ boolean_T rtev_flg_EESt[4];
 real32_T socd_Q_dMax;
 real32_T socd_Q_dMin;
 boolean_T socd_flg_EEsave;
-real32_T socd_pct_ahSoc;  //
-real32_T socd_pct_battSoc;//
+real32_T socd_pct_ahSoc;
+real32_T socd_pct_battSoc;
 real32_T socd_pct_battSocEi;
 real32_T socd_pct_battSocEo;
-real32_T socd_pct_bcuSoc;//
+real32_T socd_pct_bcuSoc;
 real32_T socd_pct_bcuSocEi;
 real32_T socd_pct_bcuSocEo;
-real32_T socd_pct_ekfSoc;//
+real32_T socd_pct_ekfSoc;
 real32_T sohd_pct_bcuSoh;

+ 9 - 0
code/BCU/BCUModel/BCUDisp.h

@@ -35,6 +35,9 @@ extern real32_T damd_E_totalVehChrgEngEo;
 extern uint16_T damd_Nr_totalChg;
 extern uint16_T damd_Nr_totalChgEi;
 extern uint16_T damd_Nr_totalChgEo;
+extern uint16_T damd_Nr_totalStaChrg;
+extern uint16_T damd_Nr_totalStaChrgEi;
+extern uint16_T damd_Nr_totalStaChrgEo;
 extern uint16_T damd_Nr_totalVehChrg;
 extern uint16_T damd_Nr_totalVehChrgEi;
 extern uint16_T damd_Nr_totalVehChrgEo;
@@ -50,6 +53,12 @@ extern real32_T damd_Q_totalDisChrgCpEo;
 extern real32_T damd_Q_totalRegenCp;
 extern real32_T damd_Q_totalRegenCpEi;
 extern real32_T damd_Q_totalRegenCpEo;
+extern real32_T damd_Q_totalSatChrgCp;
+extern real32_T damd_Q_totalSatChrgCpEi;
+extern real32_T damd_Q_totalSatChrgCpEo;
+extern real32_T damd_Q_totalVehChrgCp;
+extern real32_T damd_Q_totalVehChrgCpEi;
+extern real32_T damd_Q_totalVehChrgCpEo;
 extern uint8_T damd_st_chgCnctObjEi;
 extern uint8_T damd_st_chgCnctObjEo;
 extern chrgSt dcmd_st_chrgSt_T2;

+ 43 - 29
code/BCU/BCUModel/DAM.c

@@ -1,9 +1,9 @@
 #include "DAM.h"
 #include <math.h>
-#include "DAM_private.h"
 #include "rtwtypes.h"
 #include "BCUDisp.h"
 #include "BCUCal.h"
+#include "DAM_private.h"
 
 MdlrefDW_DAM_T DAM_MdlrefDW;
 B_DAM_c_T DAM_B;
@@ -11,6 +11,7 @@ DW_DAM_f_T DAM_DW;
 void DAM_Init(void)
 {
   DAM_DW.If_ActiveSubsystem = -1;
+  DAM_DW.UnitDelay_DSTATE_a = true;
 }
 
 void DAM_Disable(void)
@@ -23,16 +24,12 @@ void DAM(void)
   real32_T rtb_Product;
   real32_T rtb_Product_tmp;
   int8_T rtPrevAction;
-  boolean_T rtb_Switch2_j;
-  if (DAM_DW.UnitDelay_DSTATE + 1.0 <= DAM_ConstB.Add) {
-    DAM_DW.UnitDelay_DSTATE++;
-  } else {
-    DAM_DW.UnitDelay_DSTATE = DAM_ConstB.Add;
-  }
-
-  if (DAM_DW.UnitDelay_DSTATE == 1.0) {
+  boolean_T rtb_RelationalOperator;
+  rtb_RelationalOperator = DAM_DW.UnitDelay_DSTATE_a;
+  DAM_DW.UnitDelay_DSTATE_a = false;
+  if (rtb_RelationalOperator) {
     uint8_T rtb_Merge10;
-    if (ihv_flg_EESt[3]) {
+    if (ihv_flg_EESt[0]) {
       DAM_B.Merge = 0.0F;
       DAM_B.Merge1 = 0.0F;
       DAM_B.Merge2 = 0.0F;
@@ -41,8 +38,11 @@ void DAM(void)
       DAM_B.Merge5 = 0.0F;
       DAM_B.Merge6 = 0.0F;
       DAM_B.Merge7 = 0.0F;
+      DAM_B.Merge11 = 0.0F;
+      DAM_B.Merge12 = 0.0F;
       DAM_B.Merge8 = 0U;
       DAM_B.Merge9 = 0U;
+      DAM_B.Merge13 = 0U;
       rtb_Merge10 = 0U;
     } else {
       DAM_B.Merge = damd_E_totalChrgEngEi;
@@ -53,8 +53,11 @@ void DAM(void)
       DAM_B.Merge5 = damd_Q_totalRegenCpEi;
       DAM_B.Merge6 = damd_E_totalVehChrgEngEi;
       DAM_B.Merge7 = damd_E_totalSatChrgEngEi;
+      DAM_B.Merge11 = damd_Q_totalVehChrgCpEi;
+      DAM_B.Merge12 = damd_Q_totalSatChrgCpEi;
       DAM_B.Merge8 = damd_Nr_totalChgEi;
       DAM_B.Merge9 = damd_Nr_totalVehChrgEi;
+      DAM_B.Merge13 = damd_Nr_totalStaChrgEi;
       rtb_Merge10 = damd_st_chgCnctObjEi;
     }
 
@@ -64,22 +67,26 @@ void DAM(void)
   rtb_Product_tmp = fabsf(ihd_I_battCurr_T2);
   rtb_Product = rtb_Product_tmp * ihd_V_battU_T2;
   if (dcmd_st_chrgSt_T2 == chrging) {
+    boolean_T rtb_Switch1_m;
     DAM_DW.UnitDelay_DSTATE_d += rtb_Product_tmp;
-    DAM_B.Gain_m = DAM_DW.UnitDelay_DSTATE_d * damc_tm_step * 0.000277777785F;
     DAM_DW.UnitDelay1_DSTATE_p += rtb_Product;
+    rtb_RelationalOperator = (hvmd_st_chgCnctObj_T2 == vehicle);
+    rtb_Switch1_m = (hvmd_st_chgCnctObj_T2 == chgStation);
+    DAM_B.Gain_m = DAM_DW.UnitDelay_DSTATE_d * damc_tm_step * 0.000277777785F;
     DAM_B.Gain1_b = DAM_DW.UnitDelay1_DSTATE_p * damc_tm_step * 2.77777787E-7F;
-    DAM_B.Product2 = (real32_T)(hvmd_st_chgCnctObj_T2 == vehicle) *
-      DAM_B.Gain1_b;
-    DAM_B.Product3 = (real32_T)(hvmd_st_chgCnctObj_T2 == chgStation) *
-      DAM_B.Gain1_b;
+    DAM_B.Product2 = DAM_B.Gain1_b * (real32_T)rtb_RelationalOperator;
+    DAM_B.Product3 = DAM_B.Gain1_b * (real32_T)rtb_Switch1_m;
+    DAM_B.Product4 = DAM_B.Gain_m * (real32_T)rtb_RelationalOperator;
+    DAM_B.Product5 = DAM_B.Gain_m * (real32_T)rtb_Switch1_m;
   } else {
     boolean_T rtb_Switch1_m;
-    rtb_Switch2_j = (ihd_I_battCurr_T2 < 0.0F);
-    DAM_DW.UnitDelay1_DSTATE_o += rtb_Product_tmp * (real32_T)rtb_Switch2_j;
+    rtb_RelationalOperator = (ihd_I_battCurr_T2 < 0.0F);
+    DAM_DW.UnitDelay1_DSTATE_o += rtb_Product_tmp * (real32_T)
+      rtb_RelationalOperator;
     rtb_Switch1_m = (ihd_I_battCurr_T2 > 0.0F);
     DAM_DW.UnitDelay4_DSTATE_g += rtb_Product_tmp * (real32_T)rtb_Switch1_m;
     DAM_DW.UnitDelay7_DSTATE_l += rtb_Product * (real32_T)rtb_Switch1_m;
-    DAM_DW.UnitDelay2_DSTATE_e += rtb_Product * (real32_T)rtb_Switch2_j;
+    DAM_DW.UnitDelay2_DSTATE_e += rtb_Product * (real32_T)rtb_RelationalOperator;
     DAM_B.Gain1_n = DAM_DW.UnitDelay1_DSTATE_o * damc_tm_step * 0.000277777785F;
     DAM_B.Gain2 = DAM_DW.UnitDelay4_DSTATE_g * damc_tm_step * 0.000277777785F;
     DAM_B.Gain3 = DAM_DW.UnitDelay7_DSTATE_l * damc_tm_step * 2.77777787E-7F;
@@ -90,12 +97,16 @@ void DAM(void)
   damd_E_totalChrgEngEo = damd_E_totalChrgEng;
   damd_Q_totalChrgCp = DAM_B.Merge1 + DAM_B.Gain_m;
   damd_Q_totalChrgCpEo = damd_Q_totalChrgCp;
-  DAM_DW.UnitDelay1_DSTATE_k = (uint8_T)((uint32_T)((DAM_DW.UnitDelay_DSTATE_a ==
+  DAM_DW.UnitDelay1_DSTATE_k = (uint8_T)((uint32_T)((DAM_DW.UnitDelay_DSTATE_ac ==
     noChrg) && (dcmd_st_chrgSt_T2 == chrging)) + DAM_DW.UnitDelay1_DSTATE_k);
-  rtb_Switch2_j = (hvmd_st_chgCnctObj_T2 == vehicle);
-  damd_Nr_totalVehChrg = (uint16_T)(DAM_B.Merge9 + (uint32_T)(rtb_Switch2_j ?
-    (int32_T)DAM_DW.UnitDelay1_DSTATE_k : 0));
+  rtb_RelationalOperator = (hvmd_st_chgCnctObj_T2 == vehicle);
+  damd_Nr_totalVehChrg = (uint16_T)(DAM_B.Merge9 + (uint32_T)
+    (rtb_RelationalOperator ? (int32_T)DAM_DW.UnitDelay1_DSTATE_k : 0));
   damd_Nr_totalVehChrgEo = damd_Nr_totalVehChrg;
+  damd_Q_totalVehChrgCp = DAM_B.Merge11 + DAM_B.Product4;
+  damd_Q_totalVehChrgCpEo = damd_Q_totalVehChrgCp;
+  damd_Q_totalSatChrgCp = DAM_B.Merge12 + DAM_B.Product5;
+  damd_Q_totalSatChrgCpEo = damd_Q_totalSatChrgCp;
   damd_E_totalDisChrgEng = DAM_B.Merge2 + DAM_B.Gain3;
   damd_E_totalDisChrgEngEo = damd_E_totalDisChrgEng;
   damd_Q_totalDisChrgCp = DAM_B.Merge3 + DAM_B.Gain2;
@@ -104,11 +115,14 @@ void DAM(void)
   damd_E_totalRegenEngEo = damd_E_totalRegenEng;
   damd_Q_totalRegenCp = DAM_B.Merge5 + DAM_B.Gain1_n;
   damd_Q_totalRegenCpEo = damd_Q_totalRegenCp;
+  damd_Nr_totalStaChrg = (uint16_T)((uint32_T)(hvmd_st_chgCnctObj_T2 ==
+    chgStation ? (int32_T)DAM_DW.UnitDelay1_DSTATE_k : 0) + DAM_B.Merge13);
+  damd_Nr_totalStaChrgEo = damd_Nr_totalStaChrg;
   damd_E_totalVehChrgEng = DAM_B.Merge6 + DAM_B.Product2;
   damd_E_totalVehChrgEngEo = damd_E_totalVehChrgEng;
   damd_E_totalSatChrgEng = DAM_B.Merge7 + DAM_B.Product3;
   damd_E_totalSatChrgEngEo = damd_E_totalSatChrgEng;
-  damd_Nr_totalChg = (uint16_T)((uint32_T)(rtb_Switch2_j &&
+  damd_Nr_totalChg = (uint16_T)((uint32_T)(rtb_RelationalOperator &&
     (DAM_B.DataTypeConversion == chgStation)) + DAM_B.Merge8);
   damd_Nr_totalChgEo = damd_Nr_totalChg;
   damd_st_chgCnctObjEo = hvmd_st_chgCnctObj_T2;
@@ -126,7 +140,7 @@ void DAM(void)
     DAM_B.Gain1 = DAM_DW.UnitDelay1_DSTATE_c * damc_tm_step * 2.77777787E-7F;
   } else {
     if (rtPrevAction != 1) {
-      DAM_DW.UnitDelay_DSTATE_b = 0.0F;
+      DAM_DW.UnitDelay_DSTATE = 0.0F;
       DAM_DW.UnitDelay1_DSTATE = 0.0F;
       DAM_DW.UnitDelay4_DSTATE = 0.0F;
       DAM_DW.UnitDelay5_DSTATE = 0.0F;
@@ -136,18 +150,18 @@ void DAM(void)
       DAM_DW.UnitDelay7_DSTATE = 0.0F;
     }
 
-    DAM_DW.UnitDelay_DSTATE_b += rtb_Product_tmp;
+    DAM_DW.UnitDelay_DSTATE += rtb_Product_tmp;
     DAM_DW.UnitDelay1_DSTATE += rtb_Product;
     DAM_DW.UnitDelay4_DSTATE += rtb_Product_tmp;
     DAM_DW.UnitDelay5_DSTATE += rtb_Product;
-    if (ihd_I_battCurr_T2 > 0.0F) {
-      DAM_DW.UnitDelay2_DSTATE = DAM_DW.UnitDelay_DSTATE_b * damc_tm_step *
+    if (ihd_I_battCurr_T2 < 0.0F) {
+      DAM_DW.UnitDelay2_DSTATE = DAM_DW.UnitDelay_DSTATE * damc_tm_step *
         0.000277777785F;
       DAM_DW.UnitDelay3_DSTATE = DAM_DW.UnitDelay1_DSTATE * damc_tm_step *
         2.77777787E-7F;
     }
 
-    if (ihd_I_battCurr_T2 < 0.0F) {
+    if (ihd_I_battCurr_T2 > 0.0F) {
       DAM_DW.UnitDelay6_DSTATE = DAM_DW.UnitDelay4_DSTATE * damc_tm_step *
         0.000277777785F;
       DAM_DW.UnitDelay7_DSTATE = DAM_DW.UnitDelay5_DSTATE * damc_tm_step *
@@ -161,7 +175,7 @@ void DAM(void)
   damd_Q_disChrgCp = DAM_DW.UnitDelay6_DSTATE;
   damd_E_regenEng = DAM_DW.UnitDelay3_DSTATE;
   damd_Q_regenCp = DAM_DW.UnitDelay2_DSTATE;
-  DAM_DW.UnitDelay_DSTATE_a = dcmd_st_chrgSt_T2;
+  DAM_DW.UnitDelay_DSTATE_ac = dcmd_st_chrgSt_T2;
 }
 
 void DAM_initialize(const char_T **rt_errorStatus)

+ 8 - 11
code/BCU/BCUModel/DAM.h

@@ -23,14 +23,19 @@ typedef struct {
   real32_T Gain1_b;
   real32_T Product2;
   real32_T Product3;
+  real32_T Product4;
+  real32_T Product5;
   real32_T Merge;
   real32_T Merge1;
+  real32_T Merge11;
+  real32_T Merge12;
   real32_T Merge2;
   real32_T Merge3;
   real32_T Merge4;
   real32_T Merge5;
   real32_T Merge6;
   real32_T Merge7;
+  uint16_T Merge13;
   uint16_T Merge8;
   uint16_T Merge9;
   chgCnctObj DataTypeConversion;
@@ -41,8 +46,7 @@ typedef struct {
 #ifndef DAM_MDLREF_HIDE_CHILD_
 
 typedef struct {
-  real_T UnitDelay_DSTATE;
-  real32_T UnitDelay_DSTATE_b;
+  real32_T UnitDelay_DSTATE;
   real32_T UnitDelay1_DSTATE;
   real32_T UnitDelay4_DSTATE;
   real32_T UnitDelay5_DSTATE;
@@ -59,7 +63,8 @@ typedef struct {
   real32_T UnitDelay_DSTATE_d;
   real32_T UnitDelay1_DSTATE_p;
   uint8_T UnitDelay1_DSTATE_k;
-  chrgSt UnitDelay_DSTATE_a;
+  boolean_T UnitDelay_DSTATE_a;
+  chrgSt UnitDelay_DSTATE_ac;
   int8_T If_ActiveSubsystem;
 } DW_DAM_f_T;
 
@@ -67,14 +72,6 @@ typedef struct {
 
 #ifndef DAM_MDLREF_HIDE_CHILD_
 
-typedef struct {
-  const real_T Add;
-} ConstB_DAM_h_T;
-
-#endif
-
-#ifndef DAM_MDLREF_HIDE_CHILD_
-
 struct tag_RTM_DAM_T {
   const char_T **errorStatus;
 };

+ 0 - 5
code/BCU/BCUModel/DAM_data.c

@@ -1,5 +0,0 @@
-#include "DAM_private.h"
-
-const ConstB_DAM_h_T DAM_ConstB = {
-  3.0
-};

+ 0 - 4
code/BCU/BCUModel/DAM_private.h

@@ -2,7 +2,6 @@
 #define RTW_HEADER_DAM_private_h_
 #include "rtwtypes.h"
 #include "BCUDisp.h"
-#include "DAM.h"
 #include "DAM_types.h"
 
 #ifndef rtmGetErrorStatus
@@ -20,8 +19,5 @@
 #ifndef rtmSetErrorStatusPointer
 #define rtmSetErrorStatusPointer(rtm, val) ((rtm)->errorStatus = (val))
 #endif
-
-extern const ConstB_DAM_h_T DAM_ConstB;
-
 #endif
 

+ 28 - 33
code/BCU/BCUModel/IH100.c

@@ -7,55 +7,53 @@
 MdlrefDW_IH100_T IH100_MdlrefDW;
 B_IH100_c_T IH100_B;
 DW_IH100_f_T IH100_DW;
+void IH100_Init(void)
+{
+  IH100_DW.UnitDelay_DSTATE = true;
+}
+
 void IH100(uint16_T *rty_ihd_tm_parkTime)
 {
+  boolean_T rtb_RelationalOperator;
   ihd_tm_yearEo = rted_tm_year;
   ihd_tm_monthEo = rted_tm_month;
   ihd_tm_dayEo = rted_tm_day;
   ihd_tm_hourEo = rted_tm_hour;
   ihd_tm_minEo = rted_tm_min;
   ihd_tm_secEo = rted_tm_sec;
-  if (IH100_DW.UnitDelay_DSTATE + 1.0 <= IH100_ConstB.Add) {
-    IH100_DW.UnitDelay_DSTATE++;
-  } else {
-    IH100_DW.UnitDelay_DSTATE = IH100_ConstB.Add;
-  }
-
-  if (IH100_DW.UnitDelay_DSTATE == 1.0) {
-    uint32_T rtb_Product3_f;
-    uint16_T rtb_Add_j;
-    uint8_T rtb_Divide1;
-    uint8_T rtb_Divide_e;
+  rtb_RelationalOperator = IH100_DW.UnitDelay_DSTATE;
+  IH100_DW.UnitDelay_DSTATE = false;
+  if (rtb_RelationalOperator) {
+    uint16_T tmp;
     uint8_T rtb_Merge1;
     uint8_T rtb_Merge2;
     uint8_T rtb_Merge3;
     uint8_T rtb_Merge4;
     uint8_T rtb_Merge5;
-    boolean_T rtb_LogicalOperator1;
-    rtb_LogicalOperator1 = ((((uint16_T)(rted_tm_year % 4) == 0) && ((uint16_T)
+    uint8_T rtb_Merge6;
+    rtb_RelationalOperator = ((((uint16_T)(rted_tm_year % 4) == 0) && ((uint16_T)
       (rted_tm_year % 100) != 0)) || ((uint16_T)(rted_tm_year % 400) == 0));
-    if (rtb_LogicalOperator1) {
-      rtb_Add_j = look1_iu8lu16n16tu16_binlcase((uint8_T)(rted_tm_month - 1),
+    if (rtb_RelationalOperator) {
+      tmp = look1_iu8lu16n16tu16_binlcase((uint8_T)(rted_tm_month - 1),
         rtCP_uDLookupTable1_bp01Data, rtCP_uDLookupTable1_tableData, 11U);
     } else {
-      rtb_Add_j = look1_iu8lu16n16tu16_binlcase((uint8_T)(rted_tm_month - 1),
+      tmp = look1_iu8lu16n16tu16_binlcase((uint8_T)(rted_tm_month - 1),
         rtCP_uDLookupTable_bp01Data, rtCP_uDLookupTable_tableData, 11U);
     }
 
     IH100_B.Add1 = ((((((uint16_T)(((int32_T)((uint32_T)rted_tm_year >> 2) -
-      (int32_T)(rted_tm_year / 100U)) - rtb_LogicalOperator1) + rted_tm_year *
-                        365U) + rtb_Add_j) + (uint8_T)(rted_tm_day - 1)) *
-                     86400U + rted_tm_hour * 3600U) + rted_tm_min * 60U) +
-      rted_tm_sec;
+      (int32_T)(rted_tm_year / 100U)) - rtb_RelationalOperator) + rted_tm_year *
+                        365U) + tmp) + (uint8_T)(rted_tm_day - 1)) * 86400U +
+                     rted_tm_hour * 3600U) + rted_tm_min * 60U) + rted_tm_sec;
     if (rtev_flg_EESt[0]) {
-      rtb_Divide_e = ihd_tm_yearEi;
+      rtb_Merge6 = ihd_tm_yearEi;
       rtb_Merge1 = ihd_tm_monthEi;
       rtb_Merge3 = ihd_tm_dayEi;
       rtb_Merge2 = ihd_tm_hourEi;
       rtb_Merge4 = ihd_tm_minEi;
       rtb_Merge5 = ihd_tm_secEi;
     } else {
-      rtb_Divide_e = rted_tm_year;
+      rtb_Merge6 = rted_tm_year;
       rtb_Merge1 = rted_tm_month;
       rtb_Merge3 = rted_tm_day;
       rtb_Merge2 = rted_tm_hour;
@@ -63,23 +61,20 @@ void IH100(uint16_T *rty_ihd_tm_parkTime)
       rtb_Merge5 = rted_tm_sec;
     }
 
-    rtb_Add_j = rtb_Divide_e;
-    rtb_Product3_f = rtb_Divide_e * 365U;
-    rtb_Divide_e = (uint8_T)((uint32_T)rtb_Divide_e >> 2);
-    rtb_Divide1 = (uint8_T)(rtb_Add_j / 100U);
-    rtb_LogicalOperator1 = ((((uint16_T)(rtb_Add_j % 4) == 0) && ((uint16_T)
-      (rtb_Add_j % 100) != 0)) || ((uint16_T)(rtb_Add_j % 400) == 0));
-    if (rtb_LogicalOperator1) {
-      rtb_Add_j = look1_iu8lu16n16tu16_binlcase((uint8_T)(rtb_Merge1 - 1),
+    rtb_RelationalOperator = ((((uint16_T)(rtb_Merge6 % 4) == 0) && ((uint16_T)
+      (rtb_Merge6 % 100) != 0)) || ((uint16_T)(rtb_Merge6 % 400) == 0));
+    if (rtb_RelationalOperator) {
+      tmp = look1_iu8lu16n16tu16_binlcase((uint8_T)(rtb_Merge1 - 1),
         rtCP_uDLookupTable1_bp01Data_o, rtCP_uDLookupTable1_tableData_g, 11U);
     } else {
-      rtb_Add_j = look1_iu8lu16n16tu16_binlcase((uint8_T)(rtb_Merge1 - 1),
+      tmp = look1_iu8lu16n16tu16_binlcase((uint8_T)(rtb_Merge1 - 1),
         rtCP_uDLookupTable_bp01Data_b, rtCP_uDLookupTable_tableData_k, 11U);
     }
 
     *rty_ihd_tm_parkTime = (uint16_T)(((((int32_T)IH100_B.Add1 - (int32_T)
-      (((((uint16_T)((rtb_Divide_e - rtb_Divide1) - rtb_LogicalOperator1) +
-          rtb_Product3_f) + rtb_Add_j) + (uint8_T)(rtb_Merge3 - 1)) * 86400U)) -
+      (((((uint16_T)(((int32_T)((uint32_T)rtb_Merge6 >> 2) - (int32_T)
+                      (rtb_Merge6 / 100U)) - rtb_RelationalOperator) +
+          rtb_Merge6 * 365U) + tmp) + (uint8_T)(rtb_Merge3 - 1)) * 86400U)) -
       (int32_T)(rtb_Merge2 * 3600U)) - (int32_T)(rtb_Merge4 * 60U)) - rtb_Merge5);
   }
 

+ 2 - 9
code/BCU/BCUModel/IH100.h

@@ -20,22 +20,14 @@ typedef struct {
 #ifndef IH100_MDLREF_HIDE_CHILD_
 
 typedef struct {
-  real_T UnitDelay_DSTATE;
   uint32_T UnitDelay1_DSTATE;
+  boolean_T UnitDelay_DSTATE;
 } DW_IH100_f_T;
 
 #endif
 
 #ifndef IH100_MDLREF_HIDE_CHILD_
 
-typedef struct {
-  const real_T Add;
-} ConstB_IH100_h_T;
-
-#endif
-
-#ifndef IH100_MDLREF_HIDE_CHILD_
-
 struct tag_RTM_IH100_T {
   const char_T **errorStatus;
 };
@@ -50,6 +42,7 @@ typedef struct {
 
 #endif
 
+extern void IH100_Init(void);
 extern void IH100(uint16_T *rty_ihd_tm_parkTime);
 extern void IH100_initialize(const char_T **rt_errorStatus);
 

+ 0 - 5
code/BCU/BCUModel/IH100_data.c

@@ -1,5 +0,0 @@
-#include "IH100_private.h"
-
-const ConstB_IH100_h_T IH100_ConstB = {
-  3.0
-};

+ 0 - 4
code/BCU/BCUModel/IH100_private.h

@@ -1,7 +1,6 @@
 #ifndef RTW_HEADER_IH100_private_h_
 #define RTW_HEADER_IH100_private_h_
 #include "rtwtypes.h"
-#include "IH100.h"
 #include "IH100_types.h"
 #ifndef UCHAR_MAX
 #include <limits.h>
@@ -79,8 +78,5 @@ extern const uint8_T rtCP_pooled_Gh9RpM5of8Do[12];
 #define rtCP_uDLookupTable_bp01Data    rtCP_pooled_Gh9RpM5of8Do
 #define rtCP_uDLookupTable1_bp01Data_o rtCP_pooled_Gh9RpM5of8Do
 #define rtCP_uDLookupTable_bp01Data_b  rtCP_pooled_Gh9RpM5of8Do
-
-extern const ConstB_IH100_h_T IH100_ConstB;
-
 #endif
 

ファイルの差分が大きいため隠しています
+ 388 - 346
code/BCU/BCUModel/SOC.c


+ 84 - 25
code/BCU/BCUModel/SOC.h

@@ -15,6 +15,31 @@
 
 #ifndef SOC_MDLREF_HIDE_CHILD_
 
+typedef struct {
+  boolean_T UnitDelay_DSTATE;
+} DW_FristEn_SOC_T;
+
+#endif
+
+#ifndef SOC_MDLREF_HIDE_CHILD_
+
+typedef struct {
+  real32_T Delay_DSTATE;
+  boolean_T icLoad;
+} DW_fit_SOC_T;
+
+#endif
+
+#ifndef SOC_MDLREF_HIDE_CHILD_
+
+typedef struct {
+  uint16_T UnitDelay_DSTATE;
+} DW_Conditionalcounter1_SOC_T;
+
+#endif
+
+#ifndef SOC_MDLREF_HIDE_CHILD_
+
 typedef struct {
   real_T Subsystem1_Trig_ZC;
 } ZCV_Subsystem1_SOC_T;
@@ -31,6 +56,22 @@ typedef struct {
 
 #ifndef SOC_MDLREF_HIDE_CHILD_
 
+typedef struct {
+  real_T UnitDelay_DSTATE;
+} DW_TimeCounter_SOC_T;
+
+#endif
+
+#ifndef SOC_MDLREF_HIDE_CHILD_
+
+typedef struct {
+  uint16_T UnitDelay_DSTATE;
+} DW_Conditionalcounter_SOC_T;
+
+#endif
+
+#ifndef SOC_MDLREF_HIDE_CHILD_
+
 typedef struct {
   real32_T in1;
   real32_T in2;
@@ -38,8 +79,10 @@ typedef struct {
   real32_T in2_f;
   real32_T in1_ix;
   real32_T in2_fe;
+  real32_T SignalConversion;
+  real32_T SignalConversion_b;
   real32_T Switch1;
-  real32_T Switch;
+  real32_T Switch_d;
   real32_T Divide;
   boolean_T LogicalOperator_j;
 } B_SOC_c_T;
@@ -49,9 +92,6 @@ typedef struct {
 #ifndef SOC_MDLREF_HIDE_CHILD_
 
 typedef struct {
-  real_T UnitDelay_DSTATE;
-  real_T UnitDelay_DSTATE_d;
-  real_T UnitDelay_DSTATE_c;
   real32_T Delay_DSTATE;
   real32_T Delay_DSTATE_l;
   real32_T Delay1_DSTATE;
@@ -74,21 +114,13 @@ typedef struct {
   real32_T UnitDelay3_DSTATE;
   real32_T UnitDelay1_DSTATE_a;
   real32_T Delay_DSTATE_lp[10];
-  real32_T Delay_DSTATE_h;
-  real32_T Delay_DSTATE_h0;
   real32_T UnitDelay_DSTATE_b;
   real32_T Divide_DWORK4;
   real32_T Divide_DWORK4_l;
-  uint16_T UnitDelay_DSTATE_n;
-  uint16_T UnitDelay_DSTATE_m;
-  uint16_T UnitDelay_DSTATE_p;
-  uint16_T UnitDelay_DSTATE_ol;
-  uint16_T UnitDelay_DSTATE_o2;
-  uint16_T UnitDelay_DSTATE_dx;
-  uint16_T UnitDelay_DSTATE_h;
   uint16_T UnitDelay5_DSTATE;
   uint16_T UnitDelay5_DSTATE_k;
-  boolean_T UnitDelay_DSTATE_ca;
+  uint16_T UnitDelay_DSTATE_m;
+  boolean_T UnitDelay_DSTATE_c;
   boolean_T UnitDelay_DSTATE_f;
   boolean_T UnitDelay_DSTATE_fs;
   boolean_T UnitDelay_DSTATE_e;
@@ -103,8 +135,17 @@ typedef struct {
   boolean_T icLoad_a;
   boolean_T icLoad_l;
   boolean_T icLoad_m;
-  boolean_T icLoad_n;
-  boolean_T icLoad_g;
+  DW_TimeCounter_SOC_T TimeCounter_c;
+  DW_Conditionalcounter_SOC_T Conditionalcounter1_f;
+  DW_Conditionalcounter_SOC_T Conditionalcounter_n;
+  DW_TimeCounter_SOC_T TimeCounter;
+  DW_Conditionalcounter1_SOC_T Conditionalcounter1_j;
+  DW_Conditionalcounter1_SOC_T Conditionalcounter_i;
+  DW_Conditionalcounter1_SOC_T Conditionalcounter1;
+  DW_fit_SOC_T fit_j;
+  DW_fit_SOC_T fit;
+  DW_FristEn_SOC_T FristEn_n;
+  DW_FristEn_SOC_T FristEn;
 } DW_SOC_f_T;
 
 #endif
@@ -132,10 +173,6 @@ typedef struct {
 #ifndef SOC_MDLREF_HIDE_CHILD_
 
 typedef struct {
-  const real_T Add;
-  const real_T Add_j;
-  const real_T Add_m;
-  const real_T Add_i;
   const real32_T Add4;
   const real32_T Add4_j;
 } ConstB_SOC_h_T;
@@ -159,20 +196,42 @@ typedef struct {
 #endif
 
 extern void SOC_Init(void);
-extern void SOC_Start(void);
 extern void SOC_Disable(void);
 extern void SOC(void);
 extern void SOC_initialize(const char_T **rt_errorStatus);
 
 #ifndef SOC_MDLREF_HIDE_CHILD_
 
-extern void SOC_IfActionSubsystem(real32_T rtu_Fitdata, real32_T *rty_Out1,
-  real32_T rtp_m);
-extern void SOC_IfActionSubsystem1(real32_T rtu_Fitdata1, real32_T *rty_Out2,
-  real32_T rtp_m);
+extern void SOC_FristEn_Init(DW_FristEn_SOC_T *localDW);
+extern void SOC_FristEn(boolean_T *rty_Out1, DW_FristEn_SOC_T *localDW);
+extern void SOC_Subsystem(real32_T rtu_x, real32_T rtu_xdat, real32_T rtu_xdat_o,
+  real32_T rtu_xdat_d, real32_T rtu_ydat, real32_T rtu_ydat_e, real32_T *rty_y);
+extern void SOC_UpLim(real32_T rtu_In1, real32_T *rty_Out1, real32_T rtp_m,
+                      real_T rtp_n);
+extern void SOC_fit_Init(DW_fit_SOC_T *localDW);
+extern void SOC_fit_Reset(DW_fit_SOC_T *localDW);
+extern void SOC_fit(real32_T rtu_data, real32_T *rty_Fitdata, real32_T rtp_m,
+                    DW_fit_SOC_T *localDW);
+extern void SOC_LowLim(real32_T rtu_In1, real32_T *rty_Out1, real32_T rtp_m,
+  real_T rtp_n);
+extern void SOC_UpLim_n(uint16_T rtu_In1, uint16_T *rty_Out1, uint16_T rtp_m,
+  real_T rtp_n);
+extern void SOC_Conditionalcounter1_Reset(DW_Conditionalcounter1_SOC_T *localDW);
+extern void SOC_Conditionalcounter1_Update(boolean_T rtu_Flg, uint16_T *rty_Nr,
+  DW_Conditionalcounter1_SOC_T *localDW);
+extern void SOC_Conditionalcounter1(uint16_T *rty_Nr, uint16_T rtp_n,
+  DW_Conditionalcounter1_SOC_T *localDW);
 extern void SOC_Subsystem1(boolean_T rtu_Trigger, real32_T rtu_in1, real32_T
   rtu_in2, real32_T *rty_out1, real32_T *rty_out2, ZCE_Subsystem1_SOC_T
   *localZCE);
+extern void SOC_TimeCounter_Reset(DW_TimeCounter_SOC_T *localDW);
+extern void SOC_TimeCounter(real_T *rty_Nr, real_T rtp_n, DW_TimeCounter_SOC_T
+  *localDW);
+extern void SOC_Conditionalcounter_Reset(DW_Conditionalcounter_SOC_T *localDW);
+extern void SOC_Conditionalcounter_Update(boolean_T rtu_Flg, uint16_T *rty_Nr,
+  DW_Conditionalcounter_SOC_T *localDW);
+extern void SOC_Conditionalcounter(uint16_T *rty_Nr, uint16_T rtp_n,
+  DW_Conditionalcounter_SOC_T *localDW);
 
 #endif
 

+ 0 - 4
code/BCU/BCUModel/SOC_data.c

@@ -1,10 +1,6 @@
 #include "SOC_private.h"
 
 const ConstB_SOC_h_T SOC_ConstB = {
-  3.0,
-  100.0,
-  4.0,
-  256.0,
   0.02F,
   0.02F
 };

+ 4 - 2
code/app/AppGlobalVar.c

@@ -35,13 +35,13 @@ uint16 WebSitePort = 8812;
 #define EEP_START_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
 AppConfigBody AppConfigInfo = {false, true, {defaultSn}, {0}};
-BcuAppSaveBody BcuSaveDataInfo = {0};
+BcuSaveType BcuSaveDataInfo = {0};
 #define EEP_STOP_SEC_VAR_INIT_8_NO_CACHEABLE
 #include "Eep_MemMap.h"
 #endif
 
 //*全局变量*//
-const uint32 AppSwVersion = 0x0002000B;
+const uint32 AppSwVersion = 0x0002000C;
 const uint8 DataModuleType = 0x02; // 01=NB,02-4G
 const uint16 HwVersion = 0x0102;
 const uint32 BlSwVersion = 0x00000002;
@@ -337,6 +337,7 @@ UINT32 BMS_TotalStaCharCapy = 0x00;				// 累计换电站充入Ah 数,,Re-0.1,Of
  *BBox计算变量定义区
  ************************************************************/
 UINT8 BBox_DataReadyFlag = 0;
+UINT8 BBox_VCUConSt = 0x01;						//VCU 连接状态,用于判断电池连接与车或站的连接状态,1为站,0为车
 UINT8 BBox_PackSOC = 0x00;						//BBox计算SOC,Re-0.4,Off-0;
 UINT8 BBox_PackSOH = 0x00;						//BBox计算SOH,Re-1,Off-0;
 UINT32 BBox_TotalCharEngy = 0x00;				// 累计充入kWh 数,,Re-0.1,Off-0,KWh
@@ -352,5 +353,6 @@ UINT32 BBox_TotalStaCharCapy = 0x00;				// 累计换电站充入Ah 数,,Re-0.1,O
 UINT32 BBox_Dq_Dv_MAX = 0x00;					//BBox计算dq/dv_MAX,Re-0.001,Off-0,Ah/10mV
 UINT32 BBox_Dq_Dv_MIN = 0x00;					//BBox计算dq/dv_MIN,Re-0.001,Off-0,Ah/10mV
 
+float BBox_SocCorrectionValue = 0x00;			//BBox的SOC修正量,平台下发,Re-0.1,0ff-0,1bit std for 0.1%
 
 #endif

+ 18 - 0
code/app/AppGlobalVar.h

@@ -108,6 +108,7 @@ typedef struct _BcuSaveHader
 
 typedef struct _BcuAppSaveType
 {
+	//uint8 16 byte
 	//real time
 	uint8 bcuSaveFlg;
 	uint8 ihd_tm_yearE;
@@ -116,15 +117,29 @@ typedef struct _BcuAppSaveType
 	uint8 ihd_tm_hourE;
 	uint8 ihd_tm_minE;
 	uint8 ihd_tm_secE;
+	uint8 reU8[9];
 
+	//uint16 2*8=16byte
+	uint16 damd_Nr_totalStaChrgE;
+	uint16 damd_Nr_totalChgE;
+	uint16 damd_Nr_totalVehChrgE;
+	uint16 reU16[5];
+
+	//float 4*24=96byte
 	float socd_pct_bcuSocE;
 	float socd_pct_battSocE;
+
 	float damd_Q_totalChrgCpE;
 	float damd_E_totalChrgEngE;
 	float damd_Q_totalRegenCpE;
 	float damd_E_totalRegenEngE;
 	float damd_Q_totalDisChrgCpE;
 	float damd_E_totalDisChrgEngE;
+	float damd_Q_totalVehChrgCpE;
+	float damd_E_totalVehChrgEngE;
+	float damd_Q_totalSatChrgCpE;
+	float damd_E_totalSatChrgEngE;
+	float reU32[12];
 } BcuAppSaveBody;
 
 typedef struct _BcuSaveType
@@ -350,6 +365,7 @@ extern UINT32 BMS_TotalStaCharCapy;
  *BBox计算变量定义区
  ************************************************************/
 extern UINT8 BBox_DataReadyFlag;
+extern UINT8 BBox_VCUConSt;
 extern UINT8 BBox_PackSOC;
 extern UINT8 BBox_PackSOH;
 extern UINT32 BBox_TotalCharEngy;
@@ -365,4 +381,6 @@ extern UINT32 BBox_TotalStaCharCapy;
 extern UINT32 BBox_Dq_Dv_MAX;
 extern UINT32 BBox_Dq_Dv_MIN;
 
+extern float BBox_SocCorrectionValue;
+
 #endif /* APPGLOBALVAR_H_ */

+ 3 - 0
code/app/AppTaskCan.c

@@ -1056,6 +1056,9 @@ void BcuRxMsgSetInvalidValue(uint32 ID)
 
 	switch (ID)
 	{
+	case 0x1802F3D0:
+		BBox_VCUConSt = 0; //收到此报文,即视为电池与整车连接
+		break;
 	case 0x1801D0F3:
 //		BMS_ReqVIN = 0xFF;
 //		BMS_ReqHVOff = 0xFF;

+ 106 - 7
code/app/AppTaskUart1.c

@@ -46,7 +46,7 @@ static void AtcmdTransmit(sint8 CmdIdx, uint8 *SetValuePtr, uint16 SetValueLen,
 static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen);
 static void GetCSQValue(uint8 *out);
 void Fota_Ftp(uint8 *dataPtrIn);
-void tcpUdsFunc(uint8 *Ptr, uint8 *AnsPtr);
+uint16 tcpUdsFunc(uint8 *Ptr, uint8 *AnsPtr);
 static void vTimer1000msCallback(TimerHandle_t pxTimer);
 
 volatile TcpFeq_type TcpDataFeq={
@@ -296,7 +296,7 @@ static void TcpDataSendFeqHandFunc(uint8* DataIdx)
 
 
 	TcpDataFeq.DebugMsgFeqCnt[1] = TcpDataFeq.TrkBattFeqCnt[1];
-	if(BMS_PackSOC * 0.4 <= 25 && (BMS_PackCurr>=10000-50 && BMS_PackCurr <=10000+50)) //pack soc(0.4,0) ≤ 25%  and the abs value of pack current(0.1,-10000) ≤ 5A
+	if(BMS_PackSOC * 0.4 <= 25 && BMS_PackSOC > 0  && (BMS_PackCurr>=10000-50 && BMS_PackCurr <=10000+50)) //pack soc(0.4,0) ≤ 25%  and the abs value of pack current(0.1,-10000) ≤ 5A
 	{
 		if(timerDelayFlag == 0)
 		{
@@ -1168,6 +1168,14 @@ void TcpDataEncode(uint8 DataIdx,uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 0x23) = (UTC8TimeTcp.minute & 0xFF);	   // uint8	minute
 		*(SendBuffer + 0x24) = (UTC8TimeTcp.second & 0xFF);	   // uint8	second
 		*(SendBuffer + 0x25) = (CSQValue & 0xFF);			   // uint8	csq
+		if (BMS_Mode == 2)
+		{
+			bmsHVOn = 1;
+		}
+		else
+		{
+			bmsHVOn = 2;
+		}
 		*(SendBuffer + 0x26) = (bmsHVOn & 0xFF);			   // uint8	BMS当前状态,0:预留;1:高压上电;2:高压下电;3:无效;,Re-1,Off-0,
 		*(SendBuffer + 0x27) = (BMS_CharGunSt & 0xFF);		   // uint8	直流充电枪连接状态,0:未连接1 : 连接, Re - 1, Off - 0,
 		*(SendBuffer + 0x28) = (BMS_FtLvl & 0xFF);			   // uint8	当前最高故障等级,0-正常 1-1级 轻微故障 2-2级 较严重故障 3-3级 最严重故障,精度_1,偏移量_0,单位_
@@ -1641,8 +1649,8 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
 				TcpCmdAnswer[0] = TCP_START_SYM1;
 				TcpCmdAnswer[1] = TCP_START_SYM1;
 				TcpCmdAnswer[2] = TCP_UDSCMD_SYM;
-				tcpUdsFunc(Ptr, TcpCmdAnswer);
-				//				tcpipConnectionSend(SocketId, TcpCmdAnswer, 30);
+				uint16 sendLen = tcpUdsFunc(Ptr, TcpCmdAnswer);
+				tcpipConnectionSend(SocketId, TcpCmdAnswer, sendLen);
 				break;
 			}
 			default:
@@ -1653,15 +1661,41 @@ static void TcpDataInfoRecvHandle(uint8 *DataRecv, uint16 DataRecvLen)
 		}
 	}
 }
-void tcpUdsFunc(uint8 *Ptr, uint8 *AnsPtr)
+
+static uint8 tcpUdsAnsMsgEncode(bool posOrNeg,uint8 udsType_SID, uint16 udsType_DID, uint8 negCode,uint8 *AnsPtr)
+{
+	uint8 length = 0;
+	if(posOrNeg == false) //neg ans
+	{
+		length = 5;
+		*(AnsPtr + 0) = 0x7F;
+		*(AnsPtr + 1) = udsType_SID;
+		*(AnsPtr + 2) = (udsType_DID>>8)&0xFF;
+		*(AnsPtr + 3) = udsType_DID&0xFF;
+		*(AnsPtr + 4) = negCode;
+	}
+	else
+	{
+		length = 3;
+		*(AnsPtr + 0) = (udsType_SID + 0x40)&0xFF;
+		*(AnsPtr + 1) = (udsType_DID>>8)&0xFF;
+		*(AnsPtr + 2) = udsType_DID&0xFF;
+	}
+	return length;
+}
+
+uint16 tcpUdsFunc(uint8 *Ptr, uint8 *AnsPtr)
 {
+	uint16 AnsLength = 0;
 	uint8 contrlType = 0;
 	uint16 udsDataLen = 0;
 	uint16 DIDBuffer = 0;
 	uint8 udsType_SID = 0;
+	uint8 udsAnsBuffer[10];
+	uint8 retLength = 0;
 	uint8 DataBuffer[10];
 	contrlType = *(Ptr + 30);
-	udsDataLen = *(Ptr + 31);
+	udsDataLen = *(Ptr + 31) - 3;
 	udsType_SID = *(Ptr + 32);
 	DIDBuffer = *(Ptr + 33) << 8 | *(Ptr + 34);
 	memcpy(DataBuffer, Ptr + 35, udsDataLen);
@@ -1669,6 +1703,68 @@ void tcpUdsFunc(uint8 *Ptr, uint8 *AnsPtr)
 	{
 	case 0x00:
 	{
+		switch (udsType_SID)
+		{
+			case 0x2E:
+			{
+				switch (DIDBuffer)
+				{
+					case 0x0201:  //soc correction did
+					{
+
+						if(udsDataLen == 2)
+						{
+							float socCorrectionValue = (float)((float)((DataBuffer[0]<<8 | DataBuffer[1])&0xFFFF)*0.1-100);
+							if(socCorrectionValue != 0 && socCorrectionValue<100 && socCorrectionValue>-100)  //有效修正
+							{
+								BBox_SocCorrectionValue = socCorrectionValue;
+								socCorrectionValue = 0;
+								retLength = tcpUdsAnsMsgEncode(true,udsType_SID,DIDBuffer,0x00,udsAnsBuffer);
+							}
+							else
+							{
+								socCorrectionValue = 0;
+								retLength = tcpUdsAnsMsgEncode(false,udsType_SID,DIDBuffer,0x13,udsAnsBuffer);
+							}
+						}
+						else
+						{
+							retLength = tcpUdsAnsMsgEncode(false,udsType_SID,DIDBuffer,0x13,udsAnsBuffer);
+						}
+
+						*(AnsPtr + 3) = 0x01;
+						memcpy((AnsPtr + 4), (Ptr + 4), BATT_SN_LEN);
+						*(AnsPtr + 21) = TCP_ENCPT_DISABLE;
+						*(AnsPtr + 22) = 0x00;
+						*(AnsPtr + 23) = 0x06 + retLength + 1;
+						memcpy((AnsPtr + 24), (Ptr + 24), 6);
+						*(AnsPtr + 30) = retLength;
+						memcpy((AnsPtr + 31),udsAnsBuffer,retLength);
+						*(AnsPtr + 31 + retLength) = bcc_chk(AnsPtr, 31 + retLength);
+						AnsLength = 32 + retLength;
+						return AnsLength;
+						break;
+					}
+					default:
+						retLength = tcpUdsAnsMsgEncode(false,udsType_SID,DIDBuffer,0x31,udsAnsBuffer);
+
+						*(AnsPtr + 3) = 0x01;
+						memcpy((AnsPtr + 4), (Ptr + 4), BATT_SN_LEN);
+						*(AnsPtr + 21) = TCP_ENCPT_DISABLE;
+						*(AnsPtr + 22) = 0x00;
+						*(AnsPtr + 23) = 0x06 + retLength + 1;
+						memcpy((AnsPtr + 24), (Ptr + 24), 6);
+						*(AnsPtr + 30) = retLength;
+						memcpy((AnsPtr + 31),udsAnsBuffer,retLength);
+						*(AnsPtr + 31 + retLength) = bcc_chk(AnsPtr, 31 + retLength);
+						AnsLength = 32 + retLength;
+						return AnsLength;
+						break;
+				}
+			}
+			default:
+				break;
+		}
 		break;
 	}
 	case 0x01:
@@ -1703,10 +1799,12 @@ void tcpUdsFunc(uint8 *Ptr, uint8 *AnsPtr)
 				*(AnsPtr + 34) = DIDBuffer;
 				*(AnsPtr + 36) = DataBuffer[0];
 				*(AnsPtr + 37) = bcc_chk(AnsPtr, 37);
-				return;
+				return AnsLength;
 				break;
 			}
+
 			default:
+				return AnsLength;
 				break;
 			}
 			break;
@@ -1736,6 +1834,7 @@ void tcpUdsFunc(uint8 *Ptr, uint8 *AnsPtr)
 	*(AnsPtr + 34) = DIDBuffer;
 	*(AnsPtr + 36) = 0x31;
 	*(AnsPtr + 37) = bcc_chk(AnsPtr, 37);
+	return AnsLength;
 }
 void Fota_Ftp(uint8 *dataPtrIn)
 {

+ 19 - 4
code/hal/hal_adapter.c

@@ -1278,7 +1278,11 @@ void readConfigAndDataFromEEPROM(void)
 
 void IH_Data_Update(void)
 {
-	ihd_pct_socCor = 0;
+
+	hvmd_st_chgCnctObj_T2 =  BBox_VCUConSt;
+
+	ihd_pct_socCor = BBox_SocCorrectionValue;
+	BBox_SocCorrectionValue = 0;  //clear the SOC correction value from cloud which only available once
 
 	sohd_pct_bcuSoh = (real32_T)(BMS_PackSOH*0.4);
 
@@ -1317,12 +1321,23 @@ void OH_Data_Update(void)
 	BBox_PackSOH 			= (uint8)(BMS_PackSOH /25 *10);
 	BBox_Dq_Dv_MIN 			= (uint32)(socd_Q_dMin * 1000);					//dQ/dV
 	BBox_Dq_Dv_MAX 			= (uint32)(socd_Q_dMax * 1000);					//dQ/dV
-	BBox_TotalCharEngy 		= (uint32)(damd_E_totalChrgEng*10);			//累计充电电量
+
 	BBox_TotalDischarEngy	= (uint32)(damd_E_totalDisChrgEng*10);		//累计放电电电量
-	BBox_TotalBackCharEngy 	= (uint32)(damd_E_totalRegenEng*10);		//累计回收电量
-	BBox_TotalCharCapy 		= (uint32)(damd_Q_totalChrgCp*10);			//累计充电容量
 	BBox_TotalDischarCapy 	= (uint32)(damd_Q_totalDisChrgCp*10);		//累计放电电容量
+
+	BBox_TotalBackCharEngy 	= (uint32)(damd_E_totalRegenEng*10);		//累计回收电量
 	BBox_TotalBackCharCapy 	= (uint32)(damd_Q_totalRegenCp*10);			//累计回收容量
+
+	BBox_TotalCharEngy 		= BBox_TotalBackCharEngy + (uint32)(damd_E_totalChrgEng*10);		//累计充电电量
+	BBox_TotalCharCapy 		= BBox_TotalBackCharCapy + (uint32)(damd_Q_totalChrgCp*10);			//累计充电容量
+
+	BBox_TotalStaCharCapy   = (uint32)(damd_Q_totalSatChrgCp*10);			//累计回收容量
+	BBox_TotalStaCharEngy	= (uint32)(damd_E_totalSatChrgEng*10);			//累计回收容量
+	BBox_TotalGunCharCapy	= (uint32)(damd_Q_totalVehChrgCp*10);			//累计回收容量
+	BBox_TotalGunCharEngy	= (uint32)(damd_E_totalVehChrgEng*10);			//累计回收容量
+
+
+
 }
 
 

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません