123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- #include "DAM.h"
- #include <math.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;
- 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)
- {
- DAM_DW.If_ActiveSubsystem = -1;
- }
- void DAM(void)
- {
- real32_T rtb_Product;
- real32_T rtb_Product_tmp;
- int8_T rtPrevAction;
- 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[0]) {
- DAM_B.Merge = 0.0F;
- DAM_B.Merge1 = 0.0F;
- DAM_B.Merge2 = 0.0F;
- DAM_B.Merge3 = 0.0F;
- DAM_B.Merge4 = 0.0F;
- 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;
- DAM_B.Merge1 = damd_Q_totalChrgCpEi;
- DAM_B.Merge2 = damd_E_totalDisChrgEngEi;
- DAM_B.Merge3 = damd_Q_totalDisChrgCpEi;
- DAM_B.Merge4 = damd_E_totalRegenEngEi;
- 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;
- }
- DAM_B.DataTypeConversion = rtb_Merge10;
- }
- 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_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 = 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_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_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;
- DAM_B.Gain4 = DAM_DW.UnitDelay2_DSTATE_e * damc_tm_step * 2.77777787E-7F;
- }
- damd_E_totalChrgEng = DAM_B.Merge + DAM_B.Gain1_b;
- 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_ac ==
- noChrg) && (dcmd_st_chrgSt_T2 == chrging)) + DAM_DW.UnitDelay1_DSTATE_k);
- 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;
- damd_Q_totalDisChrgCpEo = damd_Q_totalDisChrgCp;
- damd_E_totalRegenEng = DAM_B.Merge4 + DAM_B.Gain4;
- 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_RelationalOperator &&
- (DAM_B.DataTypeConversion == chgStation)) + DAM_B.Merge8);
- damd_Nr_totalChgEo = damd_Nr_totalChg;
- damd_st_chgCnctObjEo = hvmd_st_chgCnctObj_T2;
- rtPrevAction = DAM_DW.If_ActiveSubsystem;
- DAM_DW.If_ActiveSubsystem = (int8_T)(dcmd_st_chrgSt_T2 != chrging);
- if (DAM_DW.If_ActiveSubsystem == 0) {
- if (rtPrevAction != 0) {
- DAM_DW.UnitDelay_DSTATE_h = 0.0F;
- DAM_DW.UnitDelay1_DSTATE_c = 0.0F;
- }
- DAM_DW.UnitDelay_DSTATE_h += rtb_Product_tmp;
- DAM_B.Gain = DAM_DW.UnitDelay_DSTATE_h * damc_tm_step * 0.000277777785F;
- DAM_DW.UnitDelay1_DSTATE_c += rtb_Product;
- DAM_B.Gain1 = DAM_DW.UnitDelay1_DSTATE_c * damc_tm_step * 2.77777787E-7F;
- } else {
- if (rtPrevAction != 1) {
- DAM_DW.UnitDelay_DSTATE = 0.0F;
- DAM_DW.UnitDelay1_DSTATE = 0.0F;
- DAM_DW.UnitDelay4_DSTATE = 0.0F;
- DAM_DW.UnitDelay5_DSTATE = 0.0F;
- DAM_DW.UnitDelay2_DSTATE = 0.0F;
- DAM_DW.UnitDelay3_DSTATE = 0.0F;
- DAM_DW.UnitDelay6_DSTATE = 0.0F;
- DAM_DW.UnitDelay7_DSTATE = 0.0F;
- }
- 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 * 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) {
- DAM_DW.UnitDelay6_DSTATE = DAM_DW.UnitDelay4_DSTATE * damc_tm_step *
- 0.000277777785F;
- DAM_DW.UnitDelay7_DSTATE = DAM_DW.UnitDelay5_DSTATE * damc_tm_step *
- 2.77777787E-7F;
- }
- }
- damd_Q_chrgCp = DAM_B.Gain;
- damd_E_chrgEng = DAM_B.Gain1;
- damd_E_disChrgEng = DAM_DW.UnitDelay7_DSTATE;
- 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_ac = dcmd_st_chrgSt_T2;
- }
- void DAM_initialize(const char_T **rt_errorStatus)
- {
- RT_MODEL_DAM_T *const DAM_M = &(DAM_MdlrefDW.rtm);
- rtmSetErrorStatusPointer(DAM_M, rt_errorStatus);
- }
|