|
@@ -0,0 +1,1446 @@
|
|
|
+/*
|
|
|
+ * File: SOC.c
|
|
|
+ *
|
|
|
+ * Code generated for Simulink model 'SOC'.
|
|
|
+ *
|
|
|
+ * Model version : 1.24
|
|
|
+ * Simulink Coder version : 9.4 (R2020b) 29-Jul-2020
|
|
|
+ * C/C++ source code generated on : Thu Aug 12 17:54:23 2021
|
|
|
+ *
|
|
|
+ * Target selection: ert.tlc
|
|
|
+ * Embedded hardware selection: Intel->x86-64 (Windows64)
|
|
|
+ * Code generation objectives: Unspecified
|
|
|
+ * Validation result: Not run
|
|
|
+ */
|
|
|
+
|
|
|
+#include "SOC.h"
|
|
|
+#include "SOC_private.h"
|
|
|
+#include "LookUp_U16_U16.h"
|
|
|
+#include "div_nde_s32_floor.h"
|
|
|
+#include "div_repeat_s16s32_floor.h"
|
|
|
+#include "look1_binlxpw.h"
|
|
|
+#include "look1_is16lu16n16tu16_binlcase.h"
|
|
|
+#include "look1_iu16lu16n16tu16_binlcase.h"
|
|
|
+#include "mul_u32_hiSR_near.h"
|
|
|
+
|
|
|
+/*
|
|
|
+ * Output and update for atomic system:
|
|
|
+ * '<S21>/MATLAB Function'
|
|
|
+ * '<S30>/MATLAB Function'
|
|
|
+ */
|
|
|
+void SOC_MATLABFunction(real_T rtu_x, real_T *rty_y)
|
|
|
+{
|
|
|
+ *rty_y = ((((((-2.8104E-13 * pow(rtu_x, 7.0) + 1.0283E-10 * pow(rtu_x, 6.0)) +
|
|
|
+ -1.5072E-8 * pow(rtu_x, 5.0)) + 1.1295E-6 * pow(rtu_x, 4.0)) +
|
|
|
+ -4.588E-5 * pow(rtu_x, 3.0)) + rtu_x * rtu_x * 0.000993) +
|
|
|
+ -0.010548 * rtu_x) + 0.04876;
|
|
|
+}
|
|
|
+
|
|
|
+/* System initialize for referenced model: 'SOC' */
|
|
|
+void SOC_Init(DW_SOC_f_T *localDW)
|
|
|
+{
|
|
|
+ /* InitializeConditions for UnitDelay: '<S1>/Unit Delay' */
|
|
|
+ localDW->UnitDelay_DSTATE_et = true;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S1>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE_c = true;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S11>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE[0] = 1.0E-6;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S12>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE_j[0] = 1.0E-6;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S11>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE[1] = 0.0;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S12>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE_j[1] = 0.0;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S11>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE[2] = 0.0;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S12>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE_j[2] = 0.0;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S11>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE[3] = 1.0E-6;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S12>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE_j[3] = 1.0E-6;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S6>/Unit Delay' */
|
|
|
+ localDW->UnitDelay_DSTATE_j = true;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S6>/Unit Delay1' */
|
|
|
+ localDW->UnitDelay1_DSTATE_a = 1U;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S6>/Unit Delay2' */
|
|
|
+ localDW->UnitDelay2_DSTATE_d = 1U;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S6>/Unit Delay5' */
|
|
|
+ localDW->UnitDelay5_DSTATE = true;
|
|
|
+
|
|
|
+ /* InitializeConditions for UnitDelay: '<S32>/Unit Delay3' */
|
|
|
+ localDW->UnitDelay3_DSTATE_p = 2000U;
|
|
|
+}
|
|
|
+
|
|
|
+/* Output and update for referenced model: 'SOC' */
|
|
|
+void SOC(B_SOC_c_T *localB, DW_SOC_f_T *localDW)
|
|
|
+{
|
|
|
+ /* local block i/o variables */
|
|
|
+ uint16_T rtb_Saturation_l;
|
|
|
+ uint16_T rtb_LookupTableDynamic1;
|
|
|
+ uint16_T rtb_LookupTableDynamic;
|
|
|
+ uint16_T rtb_TmpSignalConversionAtLookup[2];
|
|
|
+ uint16_T rtb_TmpSignalConversionAtLook_h[2];
|
|
|
+ uint16_T rtb_TmpSignalConversionAtLook_g[2];
|
|
|
+ uint16_T rtb_TmpSignalConversionAtLook_j[2];
|
|
|
+ real_T rtb_Add_mp[4];
|
|
|
+ real_T rtb_MatrixConcatenate[4];
|
|
|
+ real_T tmp[4];
|
|
|
+ real_T rtb_Divide[2];
|
|
|
+ real_T rtb_Divide_n[2];
|
|
|
+ real_T rtb_UnitDelay3[2];
|
|
|
+ real_T tmp_0[2];
|
|
|
+ real_T rtb_Add1;
|
|
|
+ real_T rtb_Add1_b;
|
|
|
+ real_T rtb_Add1_tmp;
|
|
|
+ real_T rtb_Add_d;
|
|
|
+ real_T rtb_Divide_a;
|
|
|
+ real_T rtb_Gain1;
|
|
|
+ real_T rtb_Gain1_p;
|
|
|
+ real_T rtb_MathFunction;
|
|
|
+ real_T rtb_Product_ie;
|
|
|
+ real_T rtb_UnitDelay3_0;
|
|
|
+ real_T tmp_1;
|
|
|
+ real_T tmp_2;
|
|
|
+ int32_T UnitDelay1_DSTATE_tmp;
|
|
|
+ int32_T i;
|
|
|
+ uint32_T tmp_3;
|
|
|
+ int16_T rtb_Saturation_n;
|
|
|
+ uint16_T rtb_DataTypeConversion;
|
|
|
+ uint16_T rtb_DataTypeConversion1;
|
|
|
+ uint16_T rtb_Saturation_j;
|
|
|
+ boolean_T rtb_RelationalOperator1_ii;
|
|
|
+ boolean_T rtb_RelationalOperator1_m;
|
|
|
+
|
|
|
+ /* Outputs for Enabled SubSystem: '<S1>/EEcheck' incorporates:
|
|
|
+ * EnablePort: '<S2>/Enable'
|
|
|
+ */
|
|
|
+ /* UnitDelay: '<S1>/Unit Delay' */
|
|
|
+ if (localDW->UnitDelay_DSTATE_et) {
|
|
|
+ /* If: '<S2>/If' incorporates:
|
|
|
+ * Inport: '<Root>/socd_pct_battSocEi'
|
|
|
+ * Inport: '<Root>/socd_pct_bcuSocEi'
|
|
|
+ * Logic: '<S10>/Logical Operator'
|
|
|
+ * RelationalOperator: '<S10>/Relational Operator'
|
|
|
+ * RelationalOperator: '<S10>/Relational Operator1'
|
|
|
+ */
|
|
|
+ if ((socd_pct_battSocEi > 1000) || (socd_pct_bcuSocEi > 1000)) {
|
|
|
+ /* Outputs for IfAction SubSystem: '<S2>/If Action Subsystem' incorporates:
|
|
|
+ * ActionPort: '<S8>/Action Port'
|
|
|
+ */
|
|
|
+ /* Lookup_n-D: '<S8>/OCV-SOC' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_V_cellUAvrg'
|
|
|
+ */
|
|
|
+ localB->Merge = look1_iu16lu16n16tu16_binlcase(ihd_V_cellUAvrg,
|
|
|
+ rtCP_OCVSOC_bp01Data, rtCP_OCVSOC_tableData, 12U);
|
|
|
+
|
|
|
+ /* Merge: '<S2>/Merge1' incorporates:
|
|
|
+ * Lookup_n-D: '<S8>/OCV-SOC'
|
|
|
+ * SignalConversion: '<S8>/Signal Conversion1'
|
|
|
+ */
|
|
|
+ localB->Merge1 = localB->Merge;
|
|
|
+
|
|
|
+ /* End of Outputs for SubSystem: '<S2>/If Action Subsystem' */
|
|
|
+ } else {
|
|
|
+ /* Outputs for IfAction SubSystem: '<S2>/If Action Subsystem1' incorporates:
|
|
|
+ * ActionPort: '<S9>/Action Port'
|
|
|
+ */
|
|
|
+ /* Lookup_n-D: '<S8>/OCV-SOC' incorporates:
|
|
|
+ * Inport: '<S9>/socd_pct_battSocEi'
|
|
|
+ * Merge: '<S2>/Merge'
|
|
|
+ */
|
|
|
+ localB->Merge = socd_pct_battSocEi;
|
|
|
+
|
|
|
+ /* Merge: '<S2>/Merge1' incorporates:
|
|
|
+ * Inport: '<S9>/socd_pct_bcuSocEi'
|
|
|
+ */
|
|
|
+ localB->Merge1 = socd_pct_bcuSocEi;
|
|
|
+
|
|
|
+ /* End of Outputs for SubSystem: '<S2>/If Action Subsystem1' */
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of If: '<S2>/If' */
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of UnitDelay: '<S1>/Unit Delay' */
|
|
|
+ /* End of Outputs for SubSystem: '<S1>/EEcheck' */
|
|
|
+
|
|
|
+ /* Outputs for Enabled SubSystem: '<S1>/Inti_correct' incorporates:
|
|
|
+ * EnablePort: '<S5>/Enable'
|
|
|
+ */
|
|
|
+ /* UnitDelay: '<S1>/Unit Delay1' */
|
|
|
+ if (localDW->UnitDelay1_DSTATE_c) {
|
|
|
+ /* Switch: '<S5>/Switch' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_tm_packTime'
|
|
|
+ * RelationalOperator: '<S5>/Relational Operator'
|
|
|
+ */
|
|
|
+ if (ihd_tm_parkTime > 1800U) {
|
|
|
+ /* Switch: '<S5>/Switch' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_V_cellUAvrg'
|
|
|
+ * Lookup_n-D: '<S5>/OCV-SOC'
|
|
|
+ */
|
|
|
+ localB->Switch = look1_iu16lu16n16tu16_binlcase(ihd_V_cellUAvrg,
|
|
|
+ rtCP_OCVSOC_bp01Data_b, rtCP_OCVSOC_tableData_b, 12U);
|
|
|
+ } else {
|
|
|
+ /* Switch: '<S5>/Switch' incorporates:
|
|
|
+ * Merge: '<S2>/Merge'
|
|
|
+ */
|
|
|
+ localB->Switch = localB->Merge;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S5>/Switch' */
|
|
|
+
|
|
|
+ /* Product: '<S5>/Divide' incorporates:
|
|
|
+ * Constant: '<S5>/Constant2'
|
|
|
+ * Inport: '<Root>/sohd_pct_bcuSoh'
|
|
|
+ * Product: '<S5>/Product'
|
|
|
+ */
|
|
|
+ localB->Divide = (uint16_T)((int32_T)(sohd_pct_bcuSoh * 300U / 2000U) << 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of UnitDelay: '<S1>/Unit Delay1' */
|
|
|
+ /* End of Outputs for SubSystem: '<S1>/Inti_correct' */
|
|
|
+
|
|
|
+ /* Switch: '<S14>/Switch' incorporates:
|
|
|
+ * UnitDelay: '<S14>/Unit Delay'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay_DSTATE_c <= 0.0) {
|
|
|
+ /* Switch: '<S14>/Switch' incorporates:
|
|
|
+ * Switch: '<S5>/Switch'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE = (real_T)localB->Switch * 0.1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S14>/Switch' */
|
|
|
+
|
|
|
+ /* Sum: '<S20>/Add1' incorporates:
|
|
|
+ * Constant: '<S20>/Constant'
|
|
|
+ * Gain: '<S20>/Gain4'
|
|
|
+ * Inport: '<Root>/ihd_I_curr'
|
|
|
+ * Product: '<S20>/Divide'
|
|
|
+ * Product: '<S20>/Divide2'
|
|
|
+ * Product: '<S5>/Divide'
|
|
|
+ * Sum: '<S29>/Add1'
|
|
|
+ */
|
|
|
+ rtb_Add1_tmp = (real32_T)ihd_I_curr * 0.1F / 36000.0F / ((real32_T)
|
|
|
+ localB->Divide * 0.1F) * 100.0F;
|
|
|
+ rtb_Add1 = rtb_Add1_tmp + localDW->UnitDelay_DSTATE;
|
|
|
+
|
|
|
+ /* MATLAB Function: '<S21>/MATLAB Function' */
|
|
|
+ SOC_MATLABFunction(rtb_Add1, &rtb_Add_d);
|
|
|
+
|
|
|
+ /* SignalConversion generated from: '<S21>/Math Function1' incorporates:
|
|
|
+ * Constant: '<S21>/Constant'
|
|
|
+ */
|
|
|
+ rtb_UnitDelay3[0] = rtb_Add_d;
|
|
|
+ rtb_UnitDelay3[1] = 1.0;
|
|
|
+
|
|
|
+ /* SignalConversion generated from: '<S21>/Matrix Concatenate' */
|
|
|
+ rtb_MatrixConcatenate[0] = 1.0;
|
|
|
+ rtb_MatrixConcatenate[1] = 0.0;
|
|
|
+
|
|
|
+ /* Gain: '<S20>/Gain1' incorporates:
|
|
|
+ * Lookup_n-D: '<S20>/SOC-Rp'
|
|
|
+ * Sum: '<S20>/Add1'
|
|
|
+ */
|
|
|
+ rtb_Gain1 = 0.001 * look1_binlxpw(rtb_Add1, rtCP_SOCRp_bp01Data,
|
|
|
+ rtCP_SOCRp_tableData, 12U);
|
|
|
+
|
|
|
+ /* Math: '<S21>/Math Function' incorporates:
|
|
|
+ * Constant: '<S21>/Constant1'
|
|
|
+ * Gain: '<S20>/Gain5'
|
|
|
+ * Lookup_n-D: '<S20>/SOC-C'
|
|
|
+ * Product: '<S20>/Divide1'
|
|
|
+ * Product: '<S21>/Divide1'
|
|
|
+ * Sum: '<S20>/Add1'
|
|
|
+ *
|
|
|
+ * About '<S21>/Math Function':
|
|
|
+ * Operator: exp
|
|
|
+ */
|
|
|
+ rtb_MathFunction = exp(-0.1 / (rtb_Gain1 / (1000.0 * look1_binlxpw(rtb_Add1,
|
|
|
+ rtCP_SOCC_bp01Data, rtCP_SOCC_tableData, 12U))));
|
|
|
+
|
|
|
+ /* SignalConversion generated from: '<S21>/Matrix Concatenate' incorporates:
|
|
|
+ * Constant: '<S21>/Constant3'
|
|
|
+ */
|
|
|
+ rtb_MatrixConcatenate[2] = 0.0;
|
|
|
+ rtb_MatrixConcatenate[3] = rtb_MathFunction;
|
|
|
+
|
|
|
+ /* Product: '<S16>/Product' incorporates:
|
|
|
+ * Math: '<S16>/Math Function1'
|
|
|
+ * SignalConversion generated from: '<S21>/Matrix Concatenate'
|
|
|
+ * UnitDelay: '<S11>/Unit Delay1'
|
|
|
+ */
|
|
|
+ for (i = 0; i < 2; i++) {
|
|
|
+ tmp[i] = 0.0;
|
|
|
+ tmp[i] += localDW->UnitDelay1_DSTATE[i];
|
|
|
+ tmp[i + 2] = 0.0;
|
|
|
+ tmp[i + 2] += localDW->UnitDelay1_DSTATE[i + 2] * rtb_MathFunction;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Product: '<S17>/Product1' */
|
|
|
+ rtb_UnitDelay3_0 = 0.0;
|
|
|
+ for (i = 0; i < 2; i++) {
|
|
|
+ /* Sum: '<S16>/Add' incorporates:
|
|
|
+ * Concatenate: '<S21>/Matrix Concatenate'
|
|
|
+ * Constant: '<S11>/Constant'
|
|
|
+ * Product: '<S16>/Product'
|
|
|
+ * Sum: '<S24>/Add'
|
|
|
+ */
|
|
|
+ tmp_2 = rtb_MatrixConcatenate[i + 2];
|
|
|
+ tmp_1 = tmp_2 * tmp[1] + rtb_MatrixConcatenate[i] * tmp[0];
|
|
|
+ rtb_Add_mp[i] = tmp_1 + 0.001;
|
|
|
+
|
|
|
+ /* Product: '<S17>/Product1' incorporates:
|
|
|
+ * Constant: '<S11>/Constant'
|
|
|
+ * SignalConversion generated from: '<S21>/Math Function1'
|
|
|
+ * Sum: '<S16>/Add'
|
|
|
+ */
|
|
|
+ rtb_Divide_a = (tmp_1 + 0.001) * rtb_Add_d;
|
|
|
+
|
|
|
+ /* Sum: '<S16>/Add' incorporates:
|
|
|
+ * Concatenate: '<S21>/Matrix Concatenate'
|
|
|
+ * Constant: '<S11>/Constant'
|
|
|
+ * Product: '<S16>/Product'
|
|
|
+ * Sum: '<S24>/Add'
|
|
|
+ */
|
|
|
+ tmp_1 = tmp_2 * tmp[3] + rtb_MatrixConcatenate[i] * tmp[2];
|
|
|
+ rtb_Add_mp[i + 2] = tmp_1 + 0.001;
|
|
|
+ rtb_Divide_a += tmp_1 + 0.001;
|
|
|
+
|
|
|
+ /* Product: '<S17>/Product1' incorporates:
|
|
|
+ * Product: '<S17>/Product'
|
|
|
+ * UnitDelay: '<S11>/Unit Delay3'
|
|
|
+ */
|
|
|
+ rtb_UnitDelay3_0 += rtb_UnitDelay3[i] * rtb_Divide_a;
|
|
|
+ rtb_Divide[i] = rtb_Divide_a;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Product: '<S17>/Divide' incorporates:
|
|
|
+ * Constant: '<S11>/Constant1'
|
|
|
+ * Product: '<S17>/Product'
|
|
|
+ * Product: '<S17>/Product1'
|
|
|
+ * Sum: '<S17>/Add'
|
|
|
+ */
|
|
|
+ rtb_Divide[0] /= rtb_UnitDelay3_0 + 0.5;
|
|
|
+ rtb_Divide_a = rtb_Divide[1] / (rtb_UnitDelay3_0 + 0.5);
|
|
|
+
|
|
|
+ /* Sum: '<S15>/Add' incorporates:
|
|
|
+ * Product: '<S15>/Product1'
|
|
|
+ * Product: '<S17>/Divide'
|
|
|
+ * SignalConversion generated from: '<S21>/Math Function1'
|
|
|
+ */
|
|
|
+ tmp_1 = 1.0 - rtb_Divide[0] * rtb_Add_d;
|
|
|
+ tmp_2 = 0.0 - rtb_Divide_a * rtb_Add_d;
|
|
|
+ rtb_Add_d = 0.0 - rtb_Divide[0];
|
|
|
+
|
|
|
+ /* Product: '<S15>/Product' incorporates:
|
|
|
+ * Sum: '<S15>/Add'
|
|
|
+ * Sum: '<S24>/Add'
|
|
|
+ * UnitDelay: '<S11>/Unit Delay1'
|
|
|
+ */
|
|
|
+ for (i = 0; i < 2; i++) {
|
|
|
+ UnitDelay1_DSTATE_tmp = i << 1;
|
|
|
+ localDW->UnitDelay1_DSTATE[UnitDelay1_DSTATE_tmp] = 0.0;
|
|
|
+ rtb_UnitDelay3_0 = rtb_Add_mp[UnitDelay1_DSTATE_tmp];
|
|
|
+ localDW->UnitDelay1_DSTATE[UnitDelay1_DSTATE_tmp] += rtb_UnitDelay3_0 *
|
|
|
+ tmp_1;
|
|
|
+ rtb_Add1_b = rtb_Add_mp[UnitDelay1_DSTATE_tmp + 1];
|
|
|
+ localDW->UnitDelay1_DSTATE[UnitDelay1_DSTATE_tmp] += rtb_Add1_b * rtb_Add_d;
|
|
|
+ localDW->UnitDelay1_DSTATE[UnitDelay1_DSTATE_tmp + 1] = 0.0;
|
|
|
+ localDW->UnitDelay1_DSTATE[UnitDelay1_DSTATE_tmp + 1] += rtb_UnitDelay3_0 *
|
|
|
+ tmp_2;
|
|
|
+ localDW->UnitDelay1_DSTATE[UnitDelay1_DSTATE_tmp + 1] += rtb_Add1_b * (1.0 -
|
|
|
+ rtb_Divide_a);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Product: '<S15>/Product' */
|
|
|
+
|
|
|
+ /* Switch: '<S23>/Switch' incorporates:
|
|
|
+ * UnitDelay: '<S23>/Unit Delay'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay_DSTATE_e <= 0.0) {
|
|
|
+ /* Switch: '<S23>/Switch' incorporates:
|
|
|
+ * Switch: '<S5>/Switch'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE_o = (real_T)localB->Switch * 0.1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S23>/Switch' */
|
|
|
+
|
|
|
+ /* Sum: '<S29>/Add1' */
|
|
|
+ rtb_Add1_b = rtb_Add1_tmp + localDW->UnitDelay_DSTATE_o;
|
|
|
+
|
|
|
+ /* MATLAB Function: '<S30>/MATLAB Function' */
|
|
|
+ SOC_MATLABFunction(rtb_Add1_b, &rtb_Add_d);
|
|
|
+
|
|
|
+ /* SignalConversion generated from: '<S30>/Math Function1' incorporates:
|
|
|
+ * Constant: '<S30>/Constant'
|
|
|
+ */
|
|
|
+ rtb_UnitDelay3[0] = rtb_Add_d;
|
|
|
+ rtb_UnitDelay3[1] = 1.0;
|
|
|
+
|
|
|
+ /* SignalConversion generated from: '<S30>/Matrix Concatenate' */
|
|
|
+ rtb_Add_mp[0] = 1.0;
|
|
|
+ rtb_Add_mp[1] = 0.0;
|
|
|
+
|
|
|
+ /* Gain: '<S29>/Gain1' incorporates:
|
|
|
+ * Lookup_n-D: '<S29>/SOC-Rp'
|
|
|
+ * Sum: '<S29>/Add1'
|
|
|
+ */
|
|
|
+ rtb_Gain1_p = 0.001 * look1_binlxpw(rtb_Add1_b, rtCP_SOCRp_bp01Data_a,
|
|
|
+ rtCP_SOCRp_tableData_b, 12U);
|
|
|
+
|
|
|
+ /* Math: '<S30>/Math Function' incorporates:
|
|
|
+ * Constant: '<S30>/Constant1'
|
|
|
+ * Gain: '<S29>/Gain5'
|
|
|
+ * Lookup_n-D: '<S29>/SOC-C'
|
|
|
+ * Product: '<S29>/Divide1'
|
|
|
+ * Product: '<S30>/Divide1'
|
|
|
+ * Sum: '<S29>/Add1'
|
|
|
+ *
|
|
|
+ * About '<S30>/Math Function':
|
|
|
+ * Operator: exp
|
|
|
+ */
|
|
|
+ rtb_Product_ie = exp(-0.1 / (rtb_Gain1_p / (1000.0 * look1_binlxpw(rtb_Add1_b,
|
|
|
+ rtCP_SOCC_bp01Data_o, rtCP_SOCC_tableData_l, 12U))));
|
|
|
+
|
|
|
+ /* SignalConversion generated from: '<S30>/Matrix Concatenate' incorporates:
|
|
|
+ * Constant: '<S30>/Constant3'
|
|
|
+ */
|
|
|
+ rtb_Add_mp[2] = 0.0;
|
|
|
+ rtb_Add_mp[3] = rtb_Product_ie;
|
|
|
+
|
|
|
+ /* Product: '<S25>/Product' incorporates:
|
|
|
+ * Math: '<S25>/Math Function1'
|
|
|
+ * SignalConversion generated from: '<S30>/Matrix Concatenate'
|
|
|
+ * UnitDelay: '<S12>/Unit Delay1'
|
|
|
+ */
|
|
|
+ for (i = 0; i < 2; i++) {
|
|
|
+ tmp[i] = 0.0;
|
|
|
+ tmp[i] += localDW->UnitDelay1_DSTATE_j[i];
|
|
|
+ tmp[i + 2] = 0.0;
|
|
|
+ tmp[i + 2] += localDW->UnitDelay1_DSTATE_j[i + 2] * rtb_Product_ie;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Product: '<S26>/Product1' */
|
|
|
+ rtb_UnitDelay3_0 = 0.0;
|
|
|
+ for (i = 0; i < 2; i++) {
|
|
|
+ /* Sum: '<S25>/Add' incorporates:
|
|
|
+ * Concatenate: '<S30>/Matrix Concatenate'
|
|
|
+ * Constant: '<S12>/Constant'
|
|
|
+ * Product: '<S25>/Product'
|
|
|
+ */
|
|
|
+ tmp_2 = rtb_Add_mp[i + 2];
|
|
|
+ tmp_1 = tmp_2 * tmp[1] + rtb_Add_mp[i] * tmp[0];
|
|
|
+ rtb_MatrixConcatenate[i] = tmp_1 + 0.001;
|
|
|
+
|
|
|
+ /* Product: '<S26>/Product1' incorporates:
|
|
|
+ * Constant: '<S12>/Constant'
|
|
|
+ * SignalConversion generated from: '<S30>/Math Function1'
|
|
|
+ * Sum: '<S25>/Add'
|
|
|
+ */
|
|
|
+ rtb_Add1_tmp = (tmp_1 + 0.001) * rtb_Add_d;
|
|
|
+
|
|
|
+ /* Sum: '<S25>/Add' incorporates:
|
|
|
+ * Concatenate: '<S30>/Matrix Concatenate'
|
|
|
+ * Constant: '<S12>/Constant'
|
|
|
+ * Product: '<S25>/Product'
|
|
|
+ */
|
|
|
+ tmp_1 = tmp_2 * tmp[3] + rtb_Add_mp[i] * tmp[2];
|
|
|
+ rtb_MatrixConcatenate[i + 2] = tmp_1 + 0.001;
|
|
|
+ rtb_Add1_tmp += tmp_1 + 0.001;
|
|
|
+
|
|
|
+ /* Product: '<S26>/Product1' incorporates:
|
|
|
+ * Product: '<S26>/Product'
|
|
|
+ * UnitDelay: '<S11>/Unit Delay3'
|
|
|
+ */
|
|
|
+ rtb_UnitDelay3_0 += rtb_UnitDelay3[i] * rtb_Add1_tmp;
|
|
|
+ rtb_Divide_n[i] = rtb_Add1_tmp;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Product: '<S26>/Divide' incorporates:
|
|
|
+ * Constant: '<S12>/Constant1'
|
|
|
+ * Product: '<S26>/Product'
|
|
|
+ * Product: '<S26>/Product1'
|
|
|
+ * Sum: '<S26>/Add'
|
|
|
+ */
|
|
|
+ rtb_Divide_n[0] /= rtb_UnitDelay3_0 + 0.5;
|
|
|
+ rtb_Add1_tmp = rtb_Divide_n[1] / (rtb_UnitDelay3_0 + 0.5);
|
|
|
+
|
|
|
+ /* Sum: '<S24>/Add' incorporates:
|
|
|
+ * Product: '<S24>/Product1'
|
|
|
+ * Product: '<S26>/Divide'
|
|
|
+ * SignalConversion generated from: '<S30>/Math Function1'
|
|
|
+ */
|
|
|
+ tmp[0] = 1.0 - rtb_Divide_n[0] * rtb_Add_d;
|
|
|
+ tmp[1] = 0.0 - rtb_Add1_tmp * rtb_Add_d;
|
|
|
+ tmp[2] = 0.0 - rtb_Divide_n[0];
|
|
|
+ tmp[3] = 1.0 - rtb_Add1_tmp;
|
|
|
+
|
|
|
+ /* Switch: '<S23>/Switch1' incorporates:
|
|
|
+ * UnitDelay: '<S23>/Unit Delay1'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay1_DSTATE_h <= 0.0) {
|
|
|
+ /* SignalConversion generated from: '<S28>/Product1' incorporates:
|
|
|
+ * Constant: '<S23>/Up'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay2_DSTATE = 0.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S23>/Switch1' */
|
|
|
+
|
|
|
+ /* Product: '<S28>/Product2' incorporates:
|
|
|
+ * Constant: '<S30>/Constant4'
|
|
|
+ * Constant: '<S30>/Constant5'
|
|
|
+ * Gain: '<S30>/Gain'
|
|
|
+ * Inport: '<Root>/ihd_I_curr'
|
|
|
+ * Product: '<S19>/Product'
|
|
|
+ * Product: '<S19>/Product2'
|
|
|
+ * Product: '<S28>/Product'
|
|
|
+ * Product: '<S30>/Divide2'
|
|
|
+ * Product: '<S30>/Product'
|
|
|
+ * Product: '<S5>/Divide'
|
|
|
+ * Sum: '<S30>/Add'
|
|
|
+ */
|
|
|
+ tmp_2 = (real_T)ihd_I_curr * 0.1;
|
|
|
+ tmp_1 = 0.1 / ((real_T)localB->Divide * 0.1) * 0.027777777777777776 * tmp_2;
|
|
|
+ tmp_0[0] = tmp_1;
|
|
|
+ tmp_0[1] = (1.0 - rtb_Product_ie) * rtb_Gain1_p * tmp_2;
|
|
|
+ for (i = 0; i < 2; i++) {
|
|
|
+ /* Product: '<S24>/Product' incorporates:
|
|
|
+ * Sum: '<S25>/Add'
|
|
|
+ * UnitDelay: '<S12>/Unit Delay1'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay1_DSTATE_j[i] = 0.0;
|
|
|
+ localDW->UnitDelay1_DSTATE_j[i] += tmp[i] * rtb_MatrixConcatenate[0];
|
|
|
+ rtb_Add_d = tmp[i + 2];
|
|
|
+ localDW->UnitDelay1_DSTATE_j[i] += rtb_Add_d * rtb_MatrixConcatenate[1];
|
|
|
+ localDW->UnitDelay1_DSTATE_j[i + 2] = 0.0;
|
|
|
+ localDW->UnitDelay1_DSTATE_j[i + 2] += tmp[i] * rtb_MatrixConcatenate[2];
|
|
|
+ localDW->UnitDelay1_DSTATE_j[i + 2] += rtb_Add_d * rtb_MatrixConcatenate[3];
|
|
|
+
|
|
|
+ /* Sum: '<S28>/Add1' incorporates:
|
|
|
+ * Concatenate: '<S30>/Matrix Concatenate'
|
|
|
+ * Product: '<S28>/Product1'
|
|
|
+ * SignalConversion generated from: '<S28>/Product1'
|
|
|
+ */
|
|
|
+ rtb_UnitDelay3[i] = (rtb_Add_mp[i + 2] * localDW->UnitDelay2_DSTATE +
|
|
|
+ rtb_Add_mp[i] * localDW->UnitDelay_DSTATE_o) + tmp_0[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Sum: '<S27>/Add1' incorporates:
|
|
|
+ * Gain: '<S29>/Gain2'
|
|
|
+ * Inport: '<Root>/ihd_V_cellUMin'
|
|
|
+ * Lookup_n-D: '<S29>/SOC-OCV'
|
|
|
+ * Lookup_n-D: '<S29>/SOC-Ro'
|
|
|
+ * Product: '<S28>/Product'
|
|
|
+ * Sum: '<S28>/Add'
|
|
|
+ * Sum: '<S29>/Add1'
|
|
|
+ */
|
|
|
+ rtb_Add_d = (real_T)ihd_V_cellUMin * 0.001 - ((0.001 * look1_binlxpw
|
|
|
+ (rtb_Add1_b, rtCP_SOCRo_bp01Data, rtCP_SOCRo_tableData, 12U) * tmp_2 +
|
|
|
+ look1_binlxpw(rtb_Add1_b, rtCP_SOCOCV_bp01Data, rtCP_SOCOCV_tableData, 12U))
|
|
|
+ + rtb_UnitDelay3[1]);
|
|
|
+
|
|
|
+ /* Sum: '<S27>/Add' incorporates:
|
|
|
+ * Product: '<S27>/Product'
|
|
|
+ * UnitDelay: '<S12>/Unit Delay3'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay3_DSTATE[0] = localDW->UnitDelay3_DSTATE[0] * rtb_Add_d +
|
|
|
+ rtb_UnitDelay3[0];
|
|
|
+ localDW->UnitDelay3_DSTATE[1] = localDW->UnitDelay3_DSTATE[1] * rtb_Add_d +
|
|
|
+ rtb_UnitDelay3[1];
|
|
|
+
|
|
|
+ /* Switch: '<S14>/Switch1' incorporates:
|
|
|
+ * Constant: '<S14>/Up'
|
|
|
+ * UnitDelay: '<S14>/Unit Delay1'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay1_DSTATE_l <= 0.0) {
|
|
|
+ localDW->UnitDelay2_DSTATE_k = 0.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S14>/Switch1' */
|
|
|
+
|
|
|
+ /* Sum: '<S19>/Add1' incorporates:
|
|
|
+ * Constant: '<S21>/Constant5'
|
|
|
+ * Product: '<S19>/Product1'
|
|
|
+ * Product: '<S19>/Product2'
|
|
|
+ * Product: '<S21>/Product'
|
|
|
+ * SignalConversion generated from: '<S21>/Matrix Concatenate'
|
|
|
+ * Sum: '<S21>/Add'
|
|
|
+ */
|
|
|
+ rtb_UnitDelay3_0 = (1.0 - rtb_MathFunction) * rtb_Gain1 * tmp_2 +
|
|
|
+ rtb_MathFunction * localDW->UnitDelay2_DSTATE_k;
|
|
|
+
|
|
|
+ /* Sum: '<S18>/Add1' incorporates:
|
|
|
+ * Gain: '<S20>/Gain2'
|
|
|
+ * Inport: '<Root>/ihd_V_cellUMax'
|
|
|
+ * Lookup_n-D: '<S20>/SOC-OCV'
|
|
|
+ * Lookup_n-D: '<S20>/SOC-Ro'
|
|
|
+ * Product: '<S19>/Product'
|
|
|
+ * Sum: '<S19>/Add'
|
|
|
+ * Sum: '<S20>/Add1'
|
|
|
+ */
|
|
|
+ rtb_Add1 = (real_T)ihd_V_cellUMax * 0.001 - ((0.001 * look1_binlxpw(rtb_Add1,
|
|
|
+ rtCP_SOCRo_bp01Data_c, rtCP_SOCRo_tableData_n, 12U) * tmp_2 + look1_binlxpw
|
|
|
+ (rtb_Add1, rtCP_SOCOCV_bp01Data_a, rtCP_SOCOCV_tableData_c, 12U)) +
|
|
|
+ rtb_UnitDelay3_0);
|
|
|
+
|
|
|
+ /* Sum: '<S18>/Add' incorporates:
|
|
|
+ * Product: '<S18>/Product'
|
|
|
+ * SignalConversion generated from: '<S19>/Product1'
|
|
|
+ * Sum: '<S19>/Add1'
|
|
|
+ * UnitDelay: '<S11>/Unit Delay3'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay3_DSTATE_g[0] = (tmp_1 + localDW->UnitDelay_DSTATE) +
|
|
|
+ localDW->UnitDelay3_DSTATE_g[0] * rtb_Add1;
|
|
|
+ localDW->UnitDelay3_DSTATE_g[1] = localDW->UnitDelay3_DSTATE_g[1] * rtb_Add1 +
|
|
|
+ rtb_UnitDelay3_0;
|
|
|
+
|
|
|
+ /* Saturate: '<S33>/Saturation' incorporates:
|
|
|
+ * Constant: '<S33>/Constant'
|
|
|
+ * Sum: '<S33>/Add'
|
|
|
+ * UnitDelay: '<S33>/Unit Delay'
|
|
|
+ */
|
|
|
+ if ((uint16_T)(localDW->UnitDelay_DSTATE_i + 1U) < 60000) {
|
|
|
+ rtb_Saturation_j = (uint16_T)(localDW->UnitDelay_DSTATE_i + 1U);
|
|
|
+ } else {
|
|
|
+ rtb_Saturation_j = 60000U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Saturate: '<S33>/Saturation' */
|
|
|
+
|
|
|
+ /* RelationalOperator: '<S33>/Relational Operator1' incorporates:
|
|
|
+ * Constant: '<S33>/para'
|
|
|
+ */
|
|
|
+ rtb_RelationalOperator1_ii = (rtb_Saturation_j >= 20);
|
|
|
+
|
|
|
+ /* Saturate: '<S11>/Saturation' */
|
|
|
+ if (localDW->UnitDelay3_DSTATE_g[0] > 100.0) {
|
|
|
+ /* Switch: '<S14>/Switch' */
|
|
|
+ localDW->UnitDelay_DSTATE = 100.0;
|
|
|
+ } else if (localDW->UnitDelay3_DSTATE_g[0] < 0.0) {
|
|
|
+ /* Switch: '<S14>/Switch' */
|
|
|
+ localDW->UnitDelay_DSTATE = 0.0;
|
|
|
+ } else {
|
|
|
+ /* Switch: '<S14>/Switch' */
|
|
|
+ localDW->UnitDelay_DSTATE = localDW->UnitDelay3_DSTATE_g[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Saturate: '<S11>/Saturation' */
|
|
|
+
|
|
|
+ /* DataTypeConversion: '<S3>/Data Type Conversion1' incorporates:
|
|
|
+ * UnitDelay: '<S11>/Unit Delay'
|
|
|
+ */
|
|
|
+ rtb_Add1 = localDW->UnitDelay_DSTATE / 0.1;
|
|
|
+ rtb_Gain1 = fabs(rtb_Add1);
|
|
|
+ if (rtb_Gain1 < 4.503599627370496E+15) {
|
|
|
+ if (rtb_Gain1 >= 0.5) {
|
|
|
+ rtb_Add1 = floor(rtb_Add1 + 0.5);
|
|
|
+ } else {
|
|
|
+ rtb_Add1 = 0.0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ tmp_2 = fmod(rtb_Add1, 65536.0);
|
|
|
+ rtb_DataTypeConversion1 = (uint16_T)(tmp_2 < 0.0 ? (int32_T)(uint16_T)
|
|
|
+ -(int16_T)(uint16_T)-tmp_2 : (int32_T)(uint16_T)tmp_2);
|
|
|
+
|
|
|
+ /* End of DataTypeConversion: '<S3>/Data Type Conversion1' */
|
|
|
+
|
|
|
+ /* Saturate: '<S12>/Saturation' */
|
|
|
+ if (localDW->UnitDelay3_DSTATE[0] > 100.0) {
|
|
|
+ /* Switch: '<S23>/Switch' */
|
|
|
+ localDW->UnitDelay_DSTATE_o = 100.0;
|
|
|
+ } else if (localDW->UnitDelay3_DSTATE[0] < 0.0) {
|
|
|
+ /* Switch: '<S23>/Switch' */
|
|
|
+ localDW->UnitDelay_DSTATE_o = 0.0;
|
|
|
+ } else {
|
|
|
+ /* Switch: '<S23>/Switch' */
|
|
|
+ localDW->UnitDelay_DSTATE_o = localDW->UnitDelay3_DSTATE[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Saturate: '<S12>/Saturation' */
|
|
|
+
|
|
|
+ /* DataTypeConversion: '<S3>/Data Type Conversion' incorporates:
|
|
|
+ * UnitDelay: '<S12>/Unit Delay'
|
|
|
+ */
|
|
|
+ rtb_Add1 = localDW->UnitDelay_DSTATE_o / 0.1;
|
|
|
+ rtb_Gain1 = fabs(rtb_Add1);
|
|
|
+ if (rtb_Gain1 < 4.503599627370496E+15) {
|
|
|
+ if (rtb_Gain1 >= 0.5) {
|
|
|
+ rtb_Add1 = floor(rtb_Add1 + 0.5);
|
|
|
+ } else {
|
|
|
+ rtb_Add1 = 0.0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ tmp_2 = fmod(rtb_Add1, 65536.0);
|
|
|
+ rtb_DataTypeConversion = (uint16_T)(tmp_2 < 0.0 ? (int32_T)(uint16_T)-(int16_T)
|
|
|
+ (uint16_T)-tmp_2 : (int32_T)(uint16_T)tmp_2);
|
|
|
+
|
|
|
+ /* End of DataTypeConversion: '<S3>/Data Type Conversion' */
|
|
|
+
|
|
|
+ /* Switch: '<S13>/Switch' incorporates:
|
|
|
+ * DataTypeConversion: '<S3>/Data Type Conversion'
|
|
|
+ * DataTypeConversion: '<S3>/Data Type Conversion1'
|
|
|
+ * RelationalOperator: '<S13>/Relational Operator'
|
|
|
+ * RelationalOperator: '<S13>/Relational Operator1'
|
|
|
+ * Switch: '<S13>/Switch1'
|
|
|
+ */
|
|
|
+ if (rtb_DataTypeConversion1 >= 800) {
|
|
|
+ /* Product: '<S13>/Divide' incorporates:
|
|
|
+ * Constant: '<S13>/Constant6'
|
|
|
+ * Sum: '<S4>/Add1'
|
|
|
+ */
|
|
|
+ socd_pct_ahSoc = 100U;
|
|
|
+ } else if (200 >= rtb_DataTypeConversion) {
|
|
|
+ /* Product: '<S13>/Divide' incorporates:
|
|
|
+ * Constant: '<S13>/Constant8'
|
|
|
+ * Sum: '<S4>/Add1'
|
|
|
+ * Switch: '<S13>/Switch1'
|
|
|
+ */
|
|
|
+ socd_pct_ahSoc = 0U;
|
|
|
+ } else {
|
|
|
+ /* Product: '<S13>/Divide' incorporates:
|
|
|
+ * Constant: '<S13>/Constant2'
|
|
|
+ * Constant: '<S13>/Constant3'
|
|
|
+ * DataTypeConversion: '<S3>/Data Type Conversion'
|
|
|
+ * Sum: '<S13>/Add3'
|
|
|
+ * Sum: '<S13>/Add4'
|
|
|
+ * Sum: '<S13>/Add5'
|
|
|
+ * Switch: '<S13>/Switch1'
|
|
|
+ */
|
|
|
+ i = (uint16_T)((uint16_T)(800 - (uint16_T)(rtb_DataTypeConversion1 -
|
|
|
+ rtb_DataTypeConversion)) - 200);
|
|
|
+
|
|
|
+ /* Product: '<S13>/Divide' incorporates:
|
|
|
+ * Constant: '<S13>/Constant1'
|
|
|
+ * DataTypeConversion: '<S3>/Data Type Conversion'
|
|
|
+ * Sum: '<S13>/Add2'
|
|
|
+ * Switch: '<S13>/Switch1'
|
|
|
+ */
|
|
|
+ socd_pct_ahSoc = (uint16_T)(((uint16_T)((uint32_T)i == 0U ? MAX_uint32_T :
|
|
|
+ ((uint32_T)(rtb_DataTypeConversion - 200) << 6) / i) * 25U) >> 4);
|
|
|
+
|
|
|
+ /* MinMax: '<S13>/Max' incorporates:
|
|
|
+ * Product: '<S13>/Divide'
|
|
|
+ * Switch: '<S13>/Switch1'
|
|
|
+ */
|
|
|
+ if (socd_pct_ahSoc <= 0) {
|
|
|
+ /* Sum: '<S4>/Add1' incorporates:
|
|
|
+ * Constant: '<S13>/Constant4'
|
|
|
+ */
|
|
|
+ socd_pct_ahSoc = 0U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of MinMax: '<S13>/Max' */
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S13>/Switch' */
|
|
|
+
|
|
|
+ /* Sum: '<S13>/Add' incorporates:
|
|
|
+ * Constant: '<S13>/Constant'
|
|
|
+ * DataTypeConversion: '<S3>/Data Type Conversion'
|
|
|
+ * DataTypeConversion: '<S3>/Data Type Conversion1'
|
|
|
+ * Product: '<S13>/Product'
|
|
|
+ * Product: '<S13>/Product1'
|
|
|
+ * Sum: '<S13>/Add1'
|
|
|
+ * Sum: '<S4>/Add1'
|
|
|
+ */
|
|
|
+ tmp_3 = mul_u32_hiSR_near((uint32_T)(uint16_T)(100 - socd_pct_ahSoc) *
|
|
|
+ rtb_DataTypeConversion, 2748779069U, 1U) + mul_u32_hiSR_near((uint32_T)
|
|
|
+ rtb_DataTypeConversion1 * socd_pct_ahSoc, 2748779069U, 1U);
|
|
|
+
|
|
|
+ /* Sum: '<S13>/Add' */
|
|
|
+ rtb_Saturation_l = (uint16_T)(((tmp_3 & 16U) != 0U) + (tmp_3 >> 5));
|
|
|
+
|
|
|
+ /* Saturate: '<S38>/Saturation1' incorporates:
|
|
|
+ * Constant: '<S38>/Constant'
|
|
|
+ * Sum: '<S38>/Add'
|
|
|
+ * UnitDelay: '<S38>/Unit Delay'
|
|
|
+ */
|
|
|
+ if ((uint8_T)(localDW->UnitDelay_DSTATE_m + 1U) < 30) {
|
|
|
+ localDW->UnitDelay_DSTATE_m++;
|
|
|
+ } else {
|
|
|
+ localDW->UnitDelay_DSTATE_m = 30U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Saturate: '<S38>/Saturation1' */
|
|
|
+
|
|
|
+ /* If: '<S7>/If' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_st_workStat'
|
|
|
+ * UnitDelay: '<S38>/Unit Delay'
|
|
|
+ */
|
|
|
+ if ((ihd_st_workStat == 2) && (localDW->UnitDelay_DSTATE_m >= 20)) {
|
|
|
+ /* Outputs for IfAction SubSystem: '<S7>/chrgCCV' incorporates:
|
|
|
+ * ActionPort: '<S39>/Action Port'
|
|
|
+ */
|
|
|
+ /* Saturate: '<S43>/Saturation' incorporates:
|
|
|
+ * Constant: '<S43>/Constant'
|
|
|
+ * Sum: '<S43>/Add'
|
|
|
+ * UnitDelay: '<S43>/Unit Delay'
|
|
|
+ */
|
|
|
+ if ((uint16_T)(localDW->UnitDelay_DSTATE_h + 1U) < 60000) {
|
|
|
+ rtb_DataTypeConversion1 = (uint16_T)(localDW->UnitDelay_DSTATE_h + 1U);
|
|
|
+ } else {
|
|
|
+ rtb_DataTypeConversion1 = 60000U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Saturate: '<S43>/Saturation' */
|
|
|
+
|
|
|
+ /* Product: '<S43>/Product' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_I_curr'
|
|
|
+ * Inport: '<Root>/ihd_V_cellUMax'
|
|
|
+ * Lookup_n-D: '<S39>/1-D Lookup Table'
|
|
|
+ * RelationalOperator: '<S39>/Relational Operator'
|
|
|
+ * UnitDelay: '<S43>/Unit Delay'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE_h = (uint16_T)(ihd_V_cellUMax >=
|
|
|
+ look1_is16lu16n16tu16_binlcase(ihd_I_curr, rtCP_uDLookupTable_bp01Data,
|
|
|
+ rtCP_uDLookupTable_tableData, 3U) ? (int32_T)rtb_DataTypeConversion1 : 0);
|
|
|
+
|
|
|
+ /* RelationalOperator: '<S43>/Relational Operator1' incorporates:
|
|
|
+ * Constant: '<S43>/para'
|
|
|
+ */
|
|
|
+ rtb_RelationalOperator1_m = (rtb_DataTypeConversion1 >= 20);
|
|
|
+
|
|
|
+ /* Switch: '<S42>/Switch' incorporates:
|
|
|
+ * Logic: '<S42>/Logical Operator'
|
|
|
+ * RelationalOperator: '<S42>/Relational Operator'
|
|
|
+ * RelationalOperator: '<S42>/Relational Operator1'
|
|
|
+ * Sum: '<S13>/Add'
|
|
|
+ * UnitDelay: '<S42>/Unit Delay'
|
|
|
+ * UnitDelay: '<S42>/Unit Delay1'
|
|
|
+ */
|
|
|
+ if ((!localDW->UnitDelay_DSTATE_iz) && rtb_RelationalOperator1_m) {
|
|
|
+ localDW->UnitDelay1_DSTATE_i = rtb_Saturation_l;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S42>/Switch' */
|
|
|
+
|
|
|
+ /* Switch: '<S39>/Switch' incorporates:
|
|
|
+ * Saturate: '<S39>/Saturation'
|
|
|
+ * Sum: '<S13>/Add'
|
|
|
+ */
|
|
|
+ if (rtb_RelationalOperator1_m) {
|
|
|
+ /* Sum: '<S13>/Add' incorporates:
|
|
|
+ * Constant: '<S39>/Constant'
|
|
|
+ * Sum: '<S39>/Add1'
|
|
|
+ * Sum: '<S39>/Add2'
|
|
|
+ * Switch: '<S42>/Switch'
|
|
|
+ * UnitDelay: '<S42>/Unit Delay1'
|
|
|
+ */
|
|
|
+ rtb_Saturation_l = (uint16_T)((int16_T)(rtb_Saturation_l -
|
|
|
+ localDW->UnitDelay1_DSTATE_i) + 950);
|
|
|
+ } else {
|
|
|
+ if (rtb_Saturation_l >= 950) {
|
|
|
+ /* Sum: '<S13>/Add' incorporates:
|
|
|
+ * Saturate: '<S39>/Saturation'
|
|
|
+ */
|
|
|
+ rtb_Saturation_l = 950U;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S39>/Switch' */
|
|
|
+
|
|
|
+ /* Sum: '<S41>/Add4' incorporates:
|
|
|
+ * Saturate: '<S41>/Saturation'
|
|
|
+ * UnitDelay: '<S41>/Unit Delay'
|
|
|
+ */
|
|
|
+ rtb_Saturation_n = (int16_T)(rtb_Saturation_l - localDW->UnitDelay_DSTATE_b);
|
|
|
+
|
|
|
+ /* Saturate: '<S41>/Saturation' */
|
|
|
+ if (rtb_Saturation_n > 1000) {
|
|
|
+ rtb_Saturation_n = 1000;
|
|
|
+ } else {
|
|
|
+ if (rtb_Saturation_n < 0) {
|
|
|
+ rtb_Saturation_n = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Saturate: '<S41>/Saturation' */
|
|
|
+
|
|
|
+ /* Sum: '<S41>/Add3' incorporates:
|
|
|
+ * Saturate: '<S41>/Saturation'
|
|
|
+ * UnitDelay: '<S41>/Unit Delay'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE_b += rtb_Saturation_n;
|
|
|
+
|
|
|
+ /* Sum: '<S13>/Add' incorporates:
|
|
|
+ * Merge: '<S7>/Merge'
|
|
|
+ * SignalConversion generated from: '<S39>/socn_pct_estSoc'
|
|
|
+ * Sum: '<S41>/Add3'
|
|
|
+ * UnitDelay: '<S41>/Unit Delay'
|
|
|
+ */
|
|
|
+ rtb_Saturation_l = localDW->UnitDelay_DSTATE_b;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S42>/Unit Delay' */
|
|
|
+ localDW->UnitDelay_DSTATE_iz = rtb_RelationalOperator1_m;
|
|
|
+
|
|
|
+ /* End of Outputs for SubSystem: '<S7>/chrgCCV' */
|
|
|
+ } else {
|
|
|
+ if ((ihd_st_workStat != 2) && (localDW->UnitDelay_DSTATE_m >= 20)) {
|
|
|
+ /* Outputs for IfAction SubSystem: '<S7>/disChrgCCV' incorporates:
|
|
|
+ * ActionPort: '<S40>/Action Port'
|
|
|
+ */
|
|
|
+ /* Saturate: '<S45>/Saturation' incorporates:
|
|
|
+ * Constant: '<S45>/Constant'
|
|
|
+ * Sum: '<S45>/Add'
|
|
|
+ * UnitDelay: '<S45>/Unit Delay'
|
|
|
+ */
|
|
|
+ if ((uint16_T)(localDW->UnitDelay_DSTATE_l + 1U) < 60000) {
|
|
|
+ rtb_DataTypeConversion1 = (uint16_T)(localDW->UnitDelay_DSTATE_l + 1U);
|
|
|
+ } else {
|
|
|
+ rtb_DataTypeConversion1 = 60000U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Saturate: '<S45>/Saturation' */
|
|
|
+
|
|
|
+ /* Product: '<S45>/Product' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_I_curr'
|
|
|
+ * Inport: '<Root>/ihd_V_cellUMin'
|
|
|
+ * Lookup_n-D: '<S40>/1-D Lookup Table'
|
|
|
+ * RelationalOperator: '<S40>/Relational Operator'
|
|
|
+ * UnitDelay: '<S45>/Unit Delay'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE_l = (uint16_T)(ihd_V_cellUMin <=
|
|
|
+ look1_is16lu16n16tu16_binlcase(ihd_I_curr, rtCP_uDLookupTable_bp01Data_g,
|
|
|
+ rtCP_uDLookupTable_tableData_b, 2U) ? (int32_T)rtb_DataTypeConversion1 :
|
|
|
+ 0);
|
|
|
+
|
|
|
+ /* RelationalOperator: '<S45>/Relational Operator1' incorporates:
|
|
|
+ * Constant: '<S45>/para'
|
|
|
+ */
|
|
|
+ rtb_RelationalOperator1_m = (rtb_DataTypeConversion1 >= 20);
|
|
|
+
|
|
|
+ /* Switch: '<S44>/Switch' incorporates:
|
|
|
+ * Logic: '<S44>/Logical Operator'
|
|
|
+ * RelationalOperator: '<S44>/Relational Operator'
|
|
|
+ * RelationalOperator: '<S44>/Relational Operator1'
|
|
|
+ * Sum: '<S13>/Add'
|
|
|
+ * UnitDelay: '<S44>/Unit Delay'
|
|
|
+ * UnitDelay: '<S44>/Unit Delay1'
|
|
|
+ */
|
|
|
+ if ((!localDW->UnitDelay_DSTATE_cu) && rtb_RelationalOperator1_m) {
|
|
|
+ localDW->UnitDelay1_DSTATE_o = rtb_Saturation_l;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S44>/Switch' */
|
|
|
+
|
|
|
+ /* Switch: '<S40>/Switch1' incorporates:
|
|
|
+ * Saturate: '<S40>/Saturation'
|
|
|
+ * Sum: '<S13>/Add'
|
|
|
+ */
|
|
|
+ if (rtb_RelationalOperator1_m) {
|
|
|
+ /* Sum: '<S13>/Add' incorporates:
|
|
|
+ * Constant: '<S40>/Constant1'
|
|
|
+ * Merge: '<S7>/Merge'
|
|
|
+ * Sum: '<S40>/Add1'
|
|
|
+ * Sum: '<S40>/Add2'
|
|
|
+ * Switch: '<S44>/Switch'
|
|
|
+ * UnitDelay: '<S44>/Unit Delay1'
|
|
|
+ */
|
|
|
+ rtb_Saturation_l = (uint16_T)((int16_T)(rtb_Saturation_l -
|
|
|
+ localDW->UnitDelay1_DSTATE_o) + 50);
|
|
|
+ } else if (rtb_Saturation_l > 1000) {
|
|
|
+ /* Sum: '<S13>/Add' incorporates:
|
|
|
+ * Merge: '<S7>/Merge'
|
|
|
+ * Saturate: '<S40>/Saturation'
|
|
|
+ */
|
|
|
+ rtb_Saturation_l = 1000U;
|
|
|
+ } else {
|
|
|
+ if (rtb_Saturation_l < 50) {
|
|
|
+ /* Sum: '<S13>/Add' incorporates:
|
|
|
+ * Merge: '<S7>/Merge'
|
|
|
+ * Saturate: '<S40>/Saturation'
|
|
|
+ */
|
|
|
+ rtb_Saturation_l = 50U;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S40>/Switch1' */
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S44>/Unit Delay' */
|
|
|
+ localDW->UnitDelay_DSTATE_cu = rtb_RelationalOperator1_m;
|
|
|
+
|
|
|
+ /* End of Outputs for SubSystem: '<S7>/disChrgCCV' */
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of If: '<S7>/If' */
|
|
|
+
|
|
|
+ /* Switch: '<S6>/Switch' */
|
|
|
+ if (rtb_RelationalOperator1_ii || (!(rtb_Saturation_l < 1000))) {
|
|
|
+ /* Sum: '<S13>/Add' incorporates:
|
|
|
+ * Saturate: '<S6>/Saturation'
|
|
|
+ */
|
|
|
+ rtb_Saturation_l = 1000U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S6>/Switch' */
|
|
|
+
|
|
|
+ /* Sum: '<S6>/Add' incorporates:
|
|
|
+ * Product: '<S4>/Divide1'
|
|
|
+ * Saturate: '<S6>/Saturation'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay7'
|
|
|
+ */
|
|
|
+ rtb_Saturation_n = (int16_T)(rtb_Saturation_l - localDW->UnitDelay7_DSTATE);
|
|
|
+
|
|
|
+ /* Abs: '<S6>/Abs' incorporates:
|
|
|
+ * Product: '<S4>/Divide1'
|
|
|
+ */
|
|
|
+ if (rtb_Saturation_n < 0) {
|
|
|
+ rtb_Saturation_n = (int16_T)-rtb_Saturation_n;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Abs: '<S6>/Abs' */
|
|
|
+
|
|
|
+ /* Switch: '<S6>/Switch1' incorporates:
|
|
|
+ * Constant: '<S6>/Constant3'
|
|
|
+ * Constant: '<S6>/Constant4'
|
|
|
+ * Constant: '<S6>/Constant5'
|
|
|
+ * Constant: '<S6>/Constant6'
|
|
|
+ * Inport: '<Root>/ihd_st_workStat'
|
|
|
+ * Logic: '<S6>/Logical Operator'
|
|
|
+ * Logic: '<S6>/Logical Operator1'
|
|
|
+ * Logic: '<S6>/Logical Operator2'
|
|
|
+ * Product: '<S4>/Divide1'
|
|
|
+ * RelationalOperator: '<S6>/Relational Operator1'
|
|
|
+ * RelationalOperator: '<S6>/Relational Operator2'
|
|
|
+ * RelationalOperator: '<S6>/Relational Operator3'
|
|
|
+ * RelationalOperator: '<S6>/Relational Operator4'
|
|
|
+ * RelationalOperator: '<S6>/Relational Operator6'
|
|
|
+ * Saturate: '<S6>/Saturation'
|
|
|
+ * Switch: '<S6>/Switch2'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay1'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay2'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay3'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay_DSTATE_j || ((localDW->UnitDelay1_DSTATE_a == 2) &&
|
|
|
+ (ihd_st_workStat != 2)) || ((localDW->UnitDelay2_DSTATE_d != 2) &&
|
|
|
+ (ihd_st_workStat == 2)) || (rtb_Saturation_n > 20)) {
|
|
|
+ localDW->UnitDelay3_DSTATE_l = rtb_Saturation_l;
|
|
|
+
|
|
|
+ /* Switch: '<S6>/Switch4' incorporates:
|
|
|
+ * Merge: '<S2>/Merge1'
|
|
|
+ * Saturate: '<S6>/Saturation'
|
|
|
+ * Switch: '<S6>/Switch1'
|
|
|
+ * Switch: '<S6>/Switch2'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay3'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay4'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay5'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay6'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay5_DSTATE) {
|
|
|
+ localDW->UnitDelay4_DSTATE = localB->Merge1;
|
|
|
+ } else {
|
|
|
+ localDW->UnitDelay4_DSTATE = localDW->UnitDelay6_DSTATE;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S6>/Switch4' */
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S6>/Switch1' */
|
|
|
+
|
|
|
+ /* Switch: '<S6>/Switch3' incorporates:
|
|
|
+ * Constant: '<S6>/Constant7'
|
|
|
+ * Inport: '<Root>/ihd_st_workStat'
|
|
|
+ * RelationalOperator: '<S6>/Relational Operator5'
|
|
|
+ * S-Function (sfix_look1_dyn): '<S6>/Lookup Table Dynamic'
|
|
|
+ * S-Function (sfix_look1_dyn): '<S6>/Lookup Table Dynamic1'
|
|
|
+ */
|
|
|
+ if (ihd_st_workStat == 2) {
|
|
|
+ /* MinMax: '<S6>/Max3' incorporates:
|
|
|
+ * Switch: '<S6>/Switch2'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay4'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay4_DSTATE < 999) {
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic' */
|
|
|
+ rtb_TmpSignalConversionAtLook_g[0] = localDW->UnitDelay4_DSTATE;
|
|
|
+ } else {
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic' incorporates:
|
|
|
+ * Constant: '<S6>/Constant18'
|
|
|
+ */
|
|
|
+ rtb_TmpSignalConversionAtLook_g[0] = 999U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of MinMax: '<S6>/Max3' */
|
|
|
+
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic' incorporates:
|
|
|
+ * Constant: '<S6>/Constant8'
|
|
|
+ */
|
|
|
+ rtb_TmpSignalConversionAtLook_g[1] = 1000U;
|
|
|
+
|
|
|
+ /* MinMax: '<S6>/Max2' incorporates:
|
|
|
+ * Switch: '<S6>/Switch1'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay3'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay3_DSTATE_l < 999) {
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic' */
|
|
|
+ rtb_TmpSignalConversionAtLook_j[0] = localDW->UnitDelay3_DSTATE_l;
|
|
|
+ } else {
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic' incorporates:
|
|
|
+ * Constant: '<S6>/Constant17'
|
|
|
+ */
|
|
|
+ rtb_TmpSignalConversionAtLook_j[0] = 999U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of MinMax: '<S6>/Max2' */
|
|
|
+
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic' incorporates:
|
|
|
+ * Constant: '<S6>/Constant9'
|
|
|
+ */
|
|
|
+ rtb_TmpSignalConversionAtLook_j[1] = 1000U;
|
|
|
+
|
|
|
+ /* S-Function (sfix_look1_dyn): '<S6>/Lookup Table Dynamic' */
|
|
|
+ /* Dynamic Look-Up Table Block: '<S6>/Lookup Table Dynamic'
|
|
|
+ * Input0 Data Type: Fixed Point U16 2^-4 FSlope 1.6
|
|
|
+ * Input1 Data Type: Fixed Point U16 2^-4 FSlope 1.6
|
|
|
+ * Input2 Data Type: Fixed Point U16 2^-4 FSlope 1.6
|
|
|
+ * Output0 Data Type: Fixed Point U16 2^-4 FSlope 1.6
|
|
|
+ * Lookup Method: Linear_Endpoint
|
|
|
+ *
|
|
|
+ */
|
|
|
+ LookUp_U16_U16( &(rtb_LookupTableDynamic), &rtb_TmpSignalConversionAtLook_g
|
|
|
+ [0], rtb_Saturation_l, &rtb_TmpSignalConversionAtLook_j[0],
|
|
|
+ 1U);
|
|
|
+ rtb_DataTypeConversion1 = rtb_LookupTableDynamic;
|
|
|
+ } else {
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic1' incorporates:
|
|
|
+ * Constant: '<S6>/Constant10'
|
|
|
+ */
|
|
|
+ rtb_TmpSignalConversionAtLookup[0] = 0U;
|
|
|
+
|
|
|
+ /* MinMax: '<S6>/Max1' incorporates:
|
|
|
+ * Switch: '<S6>/Switch2'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay4'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay4_DSTATE > 10) {
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic1' */
|
|
|
+ rtb_TmpSignalConversionAtLookup[1] = localDW->UnitDelay4_DSTATE;
|
|
|
+ } else {
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic1' incorporates:
|
|
|
+ * Constant: '<S6>/Constant15'
|
|
|
+ */
|
|
|
+ rtb_TmpSignalConversionAtLookup[1] = 10U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of MinMax: '<S6>/Max1' */
|
|
|
+
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic1' incorporates:
|
|
|
+ * Constant: '<S6>/Constant11'
|
|
|
+ */
|
|
|
+ rtb_TmpSignalConversionAtLook_h[0] = 0U;
|
|
|
+
|
|
|
+ /* MinMax: '<S6>/Max' incorporates:
|
|
|
+ * Switch: '<S6>/Switch1'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay3'
|
|
|
+ */
|
|
|
+ if (localDW->UnitDelay3_DSTATE_l > 10) {
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic1' */
|
|
|
+ rtb_TmpSignalConversionAtLook_h[1] = localDW->UnitDelay3_DSTATE_l;
|
|
|
+ } else {
|
|
|
+ /* SignalConversion generated from: '<S6>/Lookup Table Dynamic1' incorporates:
|
|
|
+ * Constant: '<S6>/Constant14'
|
|
|
+ */
|
|
|
+ rtb_TmpSignalConversionAtLook_h[1] = 10U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of MinMax: '<S6>/Max' */
|
|
|
+
|
|
|
+ /* S-Function (sfix_look1_dyn): '<S6>/Lookup Table Dynamic1' */
|
|
|
+ /* Dynamic Look-Up Table Block: '<S6>/Lookup Table Dynamic1'
|
|
|
+ * Input0 Data Type: Fixed Point U16 2^-4 FSlope 1.6
|
|
|
+ * Input1 Data Type: Fixed Point U16 2^-4 FSlope 1.6
|
|
|
+ * Input2 Data Type: Fixed Point U16 2^-4 FSlope 1.6
|
|
|
+ * Output0 Data Type: Fixed Point U16 2^-4 FSlope 1.6
|
|
|
+ * Lookup Method: Linear_Endpoint
|
|
|
+ *
|
|
|
+ */
|
|
|
+ LookUp_U16_U16( &(rtb_LookupTableDynamic1),
|
|
|
+ &rtb_TmpSignalConversionAtLookup[0], rtb_Saturation_l,
|
|
|
+ &rtb_TmpSignalConversionAtLook_h[0], 1U);
|
|
|
+ rtb_DataTypeConversion1 = rtb_LookupTableDynamic1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S6>/Switch3' */
|
|
|
+
|
|
|
+ /* Sum: '<S32>/Add6' incorporates:
|
|
|
+ * Switch: '<S6>/Switch3'
|
|
|
+ * UnitDelay: '<S32>/Unit Delay3'
|
|
|
+ */
|
|
|
+ rtb_Saturation_n = (int16_T)(rtb_DataTypeConversion1 -
|
|
|
+ localDW->UnitDelay3_DSTATE_p);
|
|
|
+
|
|
|
+ /* Switch: '<S32>/Switch' incorporates:
|
|
|
+ * If: '<S32>/If'
|
|
|
+ * Logic: '<S32>/Logical Operator'
|
|
|
+ * RelationalOperator: '<S32>/Relational Operator'
|
|
|
+ * RelationalOperator: '<S32>/Relational Operator1'
|
|
|
+ * RelationalOperator: '<S32>/Relational Operator2'
|
|
|
+ * Sum: '<S32>/Add6'
|
|
|
+ */
|
|
|
+ if (rtb_Saturation_n > 1) {
|
|
|
+ /* Outputs for IfAction SubSystem: '<S32>/If Action Subsystem' incorporates:
|
|
|
+ * ActionPort: '<S34>/Action Port'
|
|
|
+ */
|
|
|
+ /* If: '<S32>/If' incorporates:
|
|
|
+ * Merge: '<S32>/Merge'
|
|
|
+ * MinMax: '<S34>/Min1'
|
|
|
+ * Sum: '<S34>/Add3'
|
|
|
+ * Sum: '<S34>/Add4'
|
|
|
+ * Switch: '<S6>/Switch3'
|
|
|
+ * UnitDelay: '<S32>/Unit Delay3'
|
|
|
+ */
|
|
|
+ i = (int16_T)(rtb_DataTypeConversion1 - localDW->UnitDelay3_DSTATE_p);
|
|
|
+ if (i >= 1) {
|
|
|
+ i = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ localDW->UnitDelay3_DSTATE_p = (uint16_T)((uint32_T)(uint16_T)i +
|
|
|
+ localDW->UnitDelay3_DSTATE_p);
|
|
|
+
|
|
|
+ /* End of Outputs for SubSystem: '<S32>/If Action Subsystem' */
|
|
|
+ } else if ((rtb_Saturation_n < -1) && (rtb_Saturation_n > -1000)) {
|
|
|
+ /* Outputs for IfAction SubSystem: '<S32>/If Action Subsystem1' incorporates:
|
|
|
+ * ActionPort: '<S35>/Action Port'
|
|
|
+ */
|
|
|
+ /* If: '<S32>/If' incorporates:
|
|
|
+ * Constant: '<S35>/Constant4'
|
|
|
+ * Merge: '<S32>/Merge'
|
|
|
+ * MinMax: '<S35>/Min1'
|
|
|
+ * Sum: '<S35>/Add3'
|
|
|
+ * Sum: '<S35>/Add4'
|
|
|
+ * Switch: '<S6>/Switch3'
|
|
|
+ * UnitDelay: '<S32>/Unit Delay3'
|
|
|
+ */
|
|
|
+ rtb_Saturation_n = (int16_T)(rtb_DataTypeConversion1 -
|
|
|
+ localDW->UnitDelay3_DSTATE_p);
|
|
|
+ if (rtb_Saturation_n <= -1) {
|
|
|
+ rtb_Saturation_n = -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ localDW->UnitDelay3_DSTATE_p += rtb_Saturation_n;
|
|
|
+
|
|
|
+ /* End of Outputs for SubSystem: '<S32>/If Action Subsystem1' */
|
|
|
+ } else {
|
|
|
+ /* Outputs for IfAction SubSystem: '<S32>/If Action Subsystem2' incorporates:
|
|
|
+ * ActionPort: '<S36>/Action Port'
|
|
|
+ */
|
|
|
+ /* If: '<S32>/If' incorporates:
|
|
|
+ * Inport: '<S36>/In1'
|
|
|
+ * Merge: '<S32>/Merge'
|
|
|
+ * Switch: '<S6>/Switch3'
|
|
|
+ * UnitDelay: '<S32>/Unit Delay3'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay3_DSTATE_p = rtb_DataTypeConversion1;
|
|
|
+
|
|
|
+ /* End of Outputs for SubSystem: '<S32>/If Action Subsystem2' */
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S32>/Switch' */
|
|
|
+
|
|
|
+ /* SignalConversion: '<S6>/Signal Conversion' incorporates:
|
|
|
+ * Saturate: '<S6>/Saturation'
|
|
|
+ */
|
|
|
+ socd_pct_battSoc = rtb_Saturation_l;
|
|
|
+
|
|
|
+ /* SignalConversion: '<S6>/Signal Conversion1' incorporates:
|
|
|
+ * Saturate: '<S6>/Saturation'
|
|
|
+ */
|
|
|
+ socd_pct_battSocEo = rtb_Saturation_l;
|
|
|
+
|
|
|
+ /* Switch: '<S6>/Switch5' */
|
|
|
+ if (rtb_RelationalOperator1_ii) {
|
|
|
+ /* Product: '<S13>/Divide' incorporates:
|
|
|
+ * Constant: '<S6>/Constant13'
|
|
|
+ * Sum: '<S4>/Add1'
|
|
|
+ */
|
|
|
+ socd_pct_ahSoc = 1000U;
|
|
|
+ } else {
|
|
|
+ /* Product: '<S13>/Divide' incorporates:
|
|
|
+ * Merge: '<S32>/Merge'
|
|
|
+ * Sum: '<S4>/Add1'
|
|
|
+ * UnitDelay: '<S32>/Unit Delay3'
|
|
|
+ */
|
|
|
+ socd_pct_ahSoc = localDW->UnitDelay3_DSTATE_p;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Switch: '<S6>/Switch5' */
|
|
|
+
|
|
|
+ /* Saturate: '<S6>/Saturation1' incorporates:
|
|
|
+ * Sum: '<S4>/Add1'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay6'
|
|
|
+ */
|
|
|
+ if (socd_pct_ahSoc < 1000) {
|
|
|
+ localDW->UnitDelay6_DSTATE = socd_pct_ahSoc;
|
|
|
+ } else {
|
|
|
+ localDW->UnitDelay6_DSTATE = 1000U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Saturate: '<S6>/Saturation1' */
|
|
|
+
|
|
|
+ /* SignalConversion: '<S6>/Signal Conversion2' incorporates:
|
|
|
+ * Saturate: '<S6>/Saturation1'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay6'
|
|
|
+ */
|
|
|
+ socd_pct_bcuSoc = localDW->UnitDelay6_DSTATE;
|
|
|
+
|
|
|
+ /* SignalConversion: '<S6>/Signal Conversion3' incorporates:
|
|
|
+ * Saturate: '<S6>/Saturation1'
|
|
|
+ * UnitDelay: '<S6>/Unit Delay6'
|
|
|
+ */
|
|
|
+ socd_pct_bcuSocEo = localDW->UnitDelay6_DSTATE;
|
|
|
+
|
|
|
+ /* Product: '<S33>/Product' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_V_cellUMax'
|
|
|
+ * RelationalOperator: '<S6>/Relational Operator'
|
|
|
+ * UnitDelay: '<S33>/Unit Delay'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE_i = (uint16_T)(ihd_V_cellUMax >= 4200 ? (int32_T)
|
|
|
+ rtb_Saturation_j : 0);
|
|
|
+
|
|
|
+ /* Sum: '<S4>/Add' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_I_curr'
|
|
|
+ * UnitDelay: '<S4>/Unit Delay1'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay1_DSTATE_b += ihd_I_curr;
|
|
|
+
|
|
|
+ /* Product: '<S13>/Divide' incorporates:
|
|
|
+ * Constant: '<S4>/Constant1'
|
|
|
+ * Product: '<S4>/Divide'
|
|
|
+ * Product: '<S4>/Divide1'
|
|
|
+ * Product: '<S5>/Divide'
|
|
|
+ * Sum: '<S4>/Add'
|
|
|
+ * Sum: '<S4>/Add1'
|
|
|
+ * Switch: '<S5>/Switch'
|
|
|
+ * UnitDelay: '<S4>/Unit Delay1'
|
|
|
+ */
|
|
|
+ socd_pct_ahSoc = (uint16_T)((int16_T)((div_repeat_s16s32_floor
|
|
|
+ (div_nde_s32_floor(localDW->UnitDelay1_DSTATE_b, 360), localB->Divide, 3U) *
|
|
|
+ 5) >> 2) + localB->Switch);
|
|
|
+
|
|
|
+ /* Saturate: '<S4>/Saturation' incorporates:
|
|
|
+ * Sum: '<S4>/Add1'
|
|
|
+ */
|
|
|
+ if (socd_pct_ahSoc >= 1000) {
|
|
|
+ /* Product: '<S13>/Divide' incorporates:
|
|
|
+ * Saturate: '<S4>/Saturation'
|
|
|
+ */
|
|
|
+ socd_pct_ahSoc = 1000U;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* End of Saturate: '<S4>/Saturation' */
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S1>/Unit Delay' incorporates:
|
|
|
+ * Constant: '<S1>/Constant'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE_et = false;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S1>/Unit Delay1' incorporates:
|
|
|
+ * Constant: '<S1>/Constant1'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay1_DSTATE_c = false;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S14>/Unit Delay' incorporates:
|
|
|
+ * Constant: '<S14>/Constant'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE_c = 1.0;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S23>/Unit Delay' incorporates:
|
|
|
+ * Constant: '<S23>/Constant'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE_e = 1.0;
|
|
|
+
|
|
|
+ /* Update for SignalConversion generated from: '<S28>/Product1' incorporates:
|
|
|
+ * UnitDelay: '<S12>/Unit Delay2'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay2_DSTATE = localDW->UnitDelay3_DSTATE[1];
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S23>/Unit Delay1' incorporates:
|
|
|
+ * Constant: '<S23>/Constant1'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay1_DSTATE_h = 1.0;
|
|
|
+
|
|
|
+ /* Update for Switch: '<S14>/Switch1' incorporates:
|
|
|
+ * UnitDelay: '<S11>/Unit Delay2'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay2_DSTATE_k = localDW->UnitDelay3_DSTATE_g[1];
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S14>/Unit Delay1' incorporates:
|
|
|
+ * Constant: '<S14>/Constant1'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay1_DSTATE_l = 1.0;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S12>/Unit Delay3' incorporates:
|
|
|
+ * Product: '<S26>/Divide'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay3_DSTATE[0] = rtb_Divide_n[0];
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S11>/Unit Delay3' incorporates:
|
|
|
+ * Product: '<S17>/Divide'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay3_DSTATE_g[0] = rtb_Divide[0];
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S12>/Unit Delay3' */
|
|
|
+ localDW->UnitDelay3_DSTATE[1] = rtb_Add1_tmp;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S11>/Unit Delay3' */
|
|
|
+ localDW->UnitDelay3_DSTATE_g[1] = rtb_Divide_a;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S6>/Unit Delay' incorporates:
|
|
|
+ * Constant: '<S6>/Constant2'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay_DSTATE_j = false;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S6>/Unit Delay1' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_st_workStat'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay1_DSTATE_a = ihd_st_workStat;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S6>/Unit Delay2' incorporates:
|
|
|
+ * Inport: '<Root>/ihd_st_workStat'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay2_DSTATE_d = ihd_st_workStat;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S6>/Unit Delay7' incorporates:
|
|
|
+ * Saturate: '<S6>/Saturation'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay7_DSTATE = rtb_Saturation_l;
|
|
|
+
|
|
|
+ /* Update for UnitDelay: '<S6>/Unit Delay5' incorporates:
|
|
|
+ * Constant: '<S6>/Constant12'
|
|
|
+ */
|
|
|
+ localDW->UnitDelay5_DSTATE = false;
|
|
|
+}
|
|
|
+
|
|
|
+/* Model initialize function */
|
|
|
+void SOC_initialize(const char_T **rt_errorStatus, RT_MODEL_SOC_T *const SOC_M)
|
|
|
+{
|
|
|
+ /* Registration code */
|
|
|
+
|
|
|
+ /* initialize error status */
|
|
|
+ rtmSetErrorStatusPointer(SOC_M, rt_errorStatus);
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * File trailer for generated code.
|
|
|
+ *
|
|
|
+ * [EOF]
|
|
|
+ */
|