/*
 * File: BSPR_BattTempCoord.c
 *
 * Code generated for Simulink model 'BSPR_BattTempCoord'.
 *
 * Model version                  : 1.1090
 * Simulink Coder version         : 8.13 (R2017b) 24-Jul-2017
 * C/C++ source code generated on : Tue Jul 27 15:10:22 2021
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Infineon->TriCore
 * Code generation objectives:
 *    1. MISRA C:2012 guidelines
 *    2. Execution efficiency
 * Validation result: Not run
 */

#include "BSPR_BattTempCoord.h"
#include "BSPR_BattTempCoord_private.h"
#include "look1_iflf_binlcpw.h"

/* Named constants for Chart: '<S35>/InputValueCalc' */
#define BSPR_BattTempCoord_IN_Default  ((uint8_T)1U)
#define BSPR_BattTempCoord_IN_Update   ((uint8_T)2U)

/* Exported data definition */

/* Volatile memory section */
#define ASW1_OEM_START_SEC_DEFAULT_RAM2_CLEARED_UNSPECIFIED
#include "Asw1_OEM_MemMap.h"

/* Definition for custom storage class: Volatile */
volatile uint8_T DFC_BattTempVldMax_ASW;   /* Max fault of invalid battery temperature signal */
volatile uint8_T DFC_BattTempVldMin_ASW;   /* Min fault of invalid battery temperature signal */
volatile uint8_T DFC_CellTempVldMax_ASW;
volatile uint8_T DFC_CellTempVldMin_ASW;

#define ASW1_OEM_STOP_SEC_DEFAULT_RAM2_CLEARED_UNSPECIFIED
#include "Asw1_OEM_MemMap.h"
#define ASW1_OEM_START_SEC_DEFAULT_RAM2_CLEARED_UNSPECIFIED
#include "Asw1_OEM_MemMap.h"

/* Definition for custom storage class: OutputSignal */
volatile boolean_T BSPR_bBattTempElecNorm;/* Wire status for for battery temperature signal */
volatile boolean_T BSPR_bBattTempInvld_A[48];/* Invalid status for for battery temperature signal */
volatile boolean_T BSPR_bCellTempElecNorm;
volatile boolean_T BSPR_bCellTempInvld_A[48];/* Invalid status for for battery temperature signal */
volatile uint8_T BSPR_cntBattTSnsrNum; /* Number of battery sensor in current battery package */
volatile uint8_T BSPR_cntCellTSnsrNum;
volatile uint8_T BSPR_cntSumBattTempInvld;/* Calculated total invalid signal of battery temperature */
volatile uint8_T BSPR_cntSumCellTempInvld;
volatile uint8_T BSPR_idxBattTempMax;  /* Calculated index of max battery temperature */
volatile uint8_T BSPR_idxBattTempMin;  /* Calculated index of min battery temperature */
volatile uint8_T BSPR_idxCellTempMax;
volatile uint8_T BSPR_idxCellTempMin;
volatile real32_T BSPR_tBattTempAvrg;  /* Calculated average battery temperature */
volatile real32_T BSPR_tBattTempMax;   /* Calculated max battery temperature */
volatile real32_T BSPR_tBattTempMin;   /* Calculated min battery temperature */
volatile real32_T BSPR_tBattTemp_A[48];/* Calculated battery temperature after coordinating */
volatile real32_T BSPR_tCellTempAvrg;
volatile real32_T BSPR_tCellTempMax;
volatile real32_T BSPR_tCellTempMin;
volatile real32_T BSPR_tCellTemp_A[48];
volatile real32_T COMR_tBattTemp_A[48];/* Battery temperature transform from voltage */
volatile real32_T COMR_tCellTemp_A[48];
volatile boolean_T GaCDP_AFETempSampAbn_flg[8];

#define ASW1_OEM_STOP_SEC_DEFAULT_RAM2_CLEARED_UNSPECIFIED
#include "Asw1_OEM_MemMap.h"

/* Block signals (auto storage) */
B_BSPR_BattTempCoord_T BSPR_BattTempCoord_B;

/* Block states (auto storage) */
DW_BSPR_BattTempCoord_T BSPR_BattTempCoord_DW;

/*
 * Output and update for atomic system:
 *    '<S35>/InputValueCalc'
 *    '<S165>/InputValueCalc'
 */
void BSPR_BattTempCoo_InputValueCalc(const real32_T rtu_Input_Value[48], const
  boolean_T rtu_Update[48], uint8_T rtu_Input_num, const real32_T rtu_Old_Value
  [240], B_InputValueCalc_BSPR_BattTem_T *localB,
  DW_InputValueCalc_BSPR_BattTe_T *localDW)
{
  int32_T Output_Value_tmp;
  if (localDW->is_active_c22_BSPR_BattTempCoor == 0U) {
    localDW->is_active_c22_BSPR_BattTempCoor = 1U;
    localDW->is_c22_BSPR_BattTempCoord = BSPR_BattTempCoord_IN_Default;

    /* {Output_Value[0] = Input_Value;
       Output_Value[1] = Input_Value;
       Output_Value[2] = Input_Value;
       Output_Value[3] = Input_Value;
       Output_Value[4] = Input_Value;} */
    localDW->i = 0U;
    while (localDW->i < rtu_Input_num) {
      localB->Output_Value[5 * localDW->i] = rtu_Input_Value[localDW->i];
      localB->Output_Value[1 + 5 * localDW->i] = rtu_Input_Value[localDW->i];
      localB->Output_Value[2 + 5 * localDW->i] = rtu_Input_Value[localDW->i];
      localB->Output_Value[3 + 5 * localDW->i] = rtu_Input_Value[localDW->i];
      localB->Output_Value[4 + 5 * localDW->i] = rtu_Input_Value[localDW->i];
      Output_Value_tmp = localDW->i + 1;
      if (Output_Value_tmp > 255) {
        Output_Value_tmp = 255;
      }

      localDW->i = (uint8_T)Output_Value_tmp;
    }
  } else if (localDW->is_c22_BSPR_BattTempCoord == BSPR_BattTempCoord_IN_Default)
  {
    if (localDW->i > rtu_Input_num - 1) {
      localDW->is_c22_BSPR_BattTempCoord = BSPR_BattTempCoord_IN_Update;
      localDW->i = 0U;
      while (localDW->i < rtu_Input_num) {
        if (rtu_Update[localDW->i]) {
          localB->Output_Value[5 * localDW->i] = rtu_Input_Value[localDW->i];
          localB->Output_Value[1 + 5 * localDW->i] = rtu_Old_Value[5 *
            localDW->i];
          localB->Output_Value[2 + 5 * localDW->i] = rtu_Old_Value[5 *
            localDW->i + 1];
          localB->Output_Value[3 + 5 * localDW->i] = rtu_Old_Value[5 *
            localDW->i + 2];
          localB->Output_Value[4 + 5 * localDW->i] = rtu_Old_Value[5 *
            localDW->i + 3];
        } else {
          localB->Output_Value[5 * localDW->i] = rtu_Old_Value[5 * localDW->i];
          localB->Output_Value[1 + 5 * localDW->i] = rtu_Old_Value[5 *
            localDW->i + 1];
          localB->Output_Value[2 + 5 * localDW->i] = rtu_Old_Value[5 *
            localDW->i + 2];
          localB->Output_Value[3 + 5 * localDW->i] = rtu_Old_Value[5 *
            localDW->i + 3];
          localB->Output_Value[4 + 5 * localDW->i] = rtu_Old_Value[5 *
            localDW->i + 4];
        }

        Output_Value_tmp = localDW->i + 1;
        if (Output_Value_tmp > 255) {
          Output_Value_tmp = 255;
        }

        localDW->i = (uint8_T)Output_Value_tmp;
      }

      localDW->i = 0U;
    }
  } else {
    while (localDW->i < rtu_Input_num) {
      if (rtu_Update[localDW->i]) {
        localB->Output_Value[5 * localDW->i] = rtu_Input_Value[localDW->i];
        localB->Output_Value[1 + 5 * localDW->i] = rtu_Old_Value[5 * localDW->i];
        localB->Output_Value[2 + 5 * localDW->i] = rtu_Old_Value[5 * localDW->i
          + 1];
        localB->Output_Value[3 + 5 * localDW->i] = rtu_Old_Value[5 * localDW->i
          + 2];
        localB->Output_Value[4 + 5 * localDW->i] = rtu_Old_Value[5 * localDW->i
          + 3];
      } else {
        Output_Value_tmp = 5 * localDW->i;
        localB->Output_Value[Output_Value_tmp] = rtu_Old_Value[Output_Value_tmp];
        localB->Output_Value[1 + Output_Value_tmp] =
          rtu_Old_Value[Output_Value_tmp + 1];
        localB->Output_Value[2 + Output_Value_tmp] =
          rtu_Old_Value[Output_Value_tmp + 2];
        localB->Output_Value[3 + Output_Value_tmp] =
          rtu_Old_Value[Output_Value_tmp + 3];
        localB->Output_Value[4 + Output_Value_tmp] =
          rtu_Old_Value[Output_Value_tmp + 4];
      }

      Output_Value_tmp = localDW->i + 1;
      if (Output_Value_tmp > 255) {
        Output_Value_tmp = 255;
      }

      localDW->i = (uint8_T)Output_Value_tmp;
    }

    localDW->i = 0U;
  }
}

/*
 * Output and update for atomic system:
 *    '<S35>/MaxValue_sort'
 *    '<S165>/MaxValue_sort'
 */
void BSPR_BattTempCoor_MaxValue_sort(const real32_T rtu_Input_Value[240],
  uint8_T rtu_Input_dim, uint8_T rtu_Input_num, B_MaxValue_sort_BSPR_BattTemp_T *
  localB, DW_MaxValue_sort_BSPR_BattTem_T *localDW)
{
  uint8_T i;
  uint8_T j;
  real32_T temp;
  int8_T n;
  int32_T tmp;
  int32_T tmp_0;
  int32_T Output_Value_tmp;
  if (localDW->is_active_c23_BSPR_BattTempCoor == 0U) {
    localDW->is_active_c23_BSPR_BattTempCoor = 1U;

    /* Input value sort from big to small */
    i = 0U;
    j = 0U;
    while (i < rtu_Input_dim) {
      while (j < rtu_Input_num) {
        Output_Value_tmp = 5 * j;
        localB->Output_Value[i + Output_Value_tmp] =
          rtu_Input_Value[Output_Value_tmp + i];
        j++;
      }

      i++;
      j = 0U;
    }

    if (rtu_Input_dim != 1) {
      Output_Value_tmp = rtu_Input_dim - 1;
      if (Output_Value_tmp < 0) {
        Output_Value_tmp = 0;
      }

      j = (uint8_T)Output_Value_tmp;
      i = 0U;
      while (i < rtu_Input_num) {
        while (j >= 1) {
          Output_Value_tmp = j - 1;
          tmp = Output_Value_tmp;
          if (Output_Value_tmp > 127) {
            tmp = 127;
          }

          for (n = (int8_T)tmp; n >= 0; n--) {
            tmp = 5 * i;
            if (localB->Output_Value[tmp + n] > localB->Output_Value[tmp + j]) {
              temp = localB->Output_Value[5 * i + n];
              localB->Output_Value[n + tmp] = localB->Output_Value[5 * i + j];
              localB->Output_Value[j + tmp] = temp;
            }
          }

          j = (uint8_T)Output_Value_tmp;
        }

        i++;
        Output_Value_tmp = rtu_Input_dim - 1;
        if (Output_Value_tmp < 0) {
          Output_Value_tmp = 0;
        }

        j = (uint8_T)Output_Value_tmp;
      }
    }

    Output_Value_tmp = rtu_Input_dim - 1;
    Output_Value_tmp = ((Output_Value_tmp < 0) + Output_Value_tmp) >> 1;
    if (Output_Value_tmp < 0) {
      Output_Value_tmp = 0;
    }

    for (i = 0U; i < rtu_Input_num; i++) {
      localB->TargetOutput_Value[i] = localB->Output_Value[5 * i + (uint8_T)
        Output_Value_tmp];
    }
  } else {
    i = 0U;
    j = 0U;
    while (i < rtu_Input_dim) {
      while (j < rtu_Input_num) {
        Output_Value_tmp = 5 * j;
        localB->Output_Value[i + Output_Value_tmp] =
          rtu_Input_Value[Output_Value_tmp + i];
        j++;
      }

      i++;
      j = 0U;
    }

    if (rtu_Input_dim != 1) {
      Output_Value_tmp = rtu_Input_dim - 1;
      tmp = Output_Value_tmp;
      if (Output_Value_tmp < 0) {
        tmp = 0;
      }

      j = (uint8_T)tmp;
      i = 0U;
      while (i < rtu_Input_num) {
        while (j >= 1) {
          tmp = j - 1;
          tmp_0 = tmp;
          if (tmp > 127) {
            tmp_0 = 127;
          }

          for (n = (int8_T)tmp_0; n >= 0; n--) {
            tmp_0 = 5 * i;
            if (localB->Output_Value[tmp_0 + n] > localB->Output_Value[tmp_0 + j])
            {
              temp = localB->Output_Value[5 * i + n];
              localB->Output_Value[n + tmp_0] = localB->Output_Value[5 * i + j];
              localB->Output_Value[j + tmp_0] = temp;
            }
          }

          j = (uint8_T)tmp;
        }

        i++;
        tmp = Output_Value_tmp;
        if (Output_Value_tmp < 0) {
          tmp = 0;
        }

        j = (uint8_T)tmp;
      }
    }

    Output_Value_tmp = rtu_Input_dim - 1;
    Output_Value_tmp = ((Output_Value_tmp < 0) + Output_Value_tmp) >> 1;
    if (Output_Value_tmp < 0) {
      Output_Value_tmp = 0;
    }

    for (i = 0U; i < rtu_Input_num; i++) {
      localB->TargetOutput_Value[i] = localB->Output_Value[5 * i + (uint8_T)
        Output_Value_tmp];
    }
  }
}

/*
 * Output and update for atomic system:
 *    '<S33>/ValidValueFilter_BusbarTemp'
 *    '<S126>/ValidValueFilter_CellTemp'
 */
void BSP_ValidValueFilter_BusbarTemp(const real32_T rtu_InputValue[48], uint8_T
  rtu_NumbConfig, uint8_T rtu_InputNumb, B_ValidValueFilter_BusbarTemp_T *localB,
  DW_ValidValueFilter_BusbarTem_T *localDW)
{
  uint8_T i;
  if (localDW->is_active_c5_BSPR_BattTempCoord == 0U) {
    localDW->is_active_c5_BSPR_BattTempCoord = 1U;
    for (i = 0U; i < rtu_InputNumb; i++) {
      if (i < rtu_NumbConfig) {
        localB->OutputValue[i] = rtu_InputValue[i];
      } else {
        localB->OutputValue[i] = CcCDP_TempDefVal_C;
      }
    }
  } else {
    for (i = 0U; i < rtu_InputNumb; i++) {
      if (i < rtu_NumbConfig) {
        localB->OutputValue[i] = rtu_InputValue[i];
      } else {
        localB->OutputValue[i] = CcCDP_TempDefVal_C;
      }
    }
  }
}

/*
 * Output and update for atomic system:
 *    '<S41>/InputValueCalc'
 *    '<S42>/InputValueCalc'
 *    '<S128>/InputValueCalc'
 *    '<S129>/InputValueCalc'
 */
void BSPR_BattTempC_InputValueCalc_i(real32_T rtu_Input_Value, boolean_T
  rtu_Rige, const real32_T rtu_Old_Value[5], B_InputValueCalc_BSPR_BattT_l_T
  *localB, DW_InputValueCalc_BSPR_Batt_m_T *localDW)
{
  if (localDW->is_active_c24_BSPR_BattTempCoor == 0U) {
    localDW->is_active_c24_BSPR_BattTempCoor = 1U;
    localB->Output_Value[0] = rtu_Input_Value;
    localB->Output_Value[1] = rtu_Input_Value;
    localB->Output_Value[2] = rtu_Input_Value;
    localB->Output_Value[3] = rtu_Input_Value;
    localB->Output_Value[4] = rtu_Input_Value;
  } else if (rtu_Rige) {
    localB->Output_Value[0] = rtu_Input_Value;
    localB->Output_Value[1] = rtu_Old_Value[0];
    localB->Output_Value[2] = rtu_Old_Value[1];
    localB->Output_Value[3] = rtu_Old_Value[2];
    localB->Output_Value[4] = rtu_Old_Value[3];
  } else {
    localB->Output_Value[0] = rtu_Old_Value[0];
    localB->Output_Value[1] = rtu_Old_Value[1];
    localB->Output_Value[2] = rtu_Old_Value[2];
    localB->Output_Value[3] = rtu_Old_Value[3];
    localB->Output_Value[4] = rtu_Old_Value[4];
  }
}

/*
 * Output and update for atomic system:
 *    '<S41>/MaxValue_sort'
 *    '<S42>/MaxValue_sort'
 *    '<S128>/MaxValue_sort'
 *    '<S129>/MaxValue_sort'
 */
void BSPR_BattTempCo_MaxValue_sort_p(const real32_T rtu_Input_Value[5], uint8_T
  rtu_Input_dim, B_MaxValue_sort_BSPR_BattTe_h_T *localB,
  DW_MaxValue_sort_BSPR_BattT_h_T *localDW)
{
  uint8_T i;
  uint8_T j;
  real32_T temp;
  if (localDW->is_active_c25_BSPR_BattTempCoor == 0U) {
    localDW->is_active_c25_BSPR_BattTempCoor = 1U;

    /* Input value sort from big to small */
    for (i = 0U; i < rtu_Input_dim; i++) {
      localB->Output_Value[i] = rtu_Input_Value[i];
    }

    for (i = 0U; i < rtu_Input_dim; i++) {
      temp = 0.0F;
      localB->Output_index[i] = 0U;
      for (j = 0U; j < rtu_Input_dim; j++) {
        if (localB->Output_Value[j] > temp) {
          temp = localB->Output_Value[j];
          localB->Output_index[i] = j;
        }
      }

      localB->Output_Value[localB->Output_index[i]] = 0.0F;
    }

    for (i = 0U; i < rtu_Input_dim; i++) {
      localB->Output_Value[i] = rtu_Input_Value[localB->Output_index[i]];
    }
  } else {
    for (i = 0U; i < rtu_Input_dim; i++) {
      localB->Output_Value[i] = rtu_Input_Value[i];
    }

    for (i = 0U; i < rtu_Input_dim; i++) {
      temp = 0.0F;
      localB->Output_index[i] = 0U;
      for (j = 0U; j < rtu_Input_dim; j++) {
        if (localB->Output_Value[j] > temp) {
          temp = localB->Output_Value[j];
          localB->Output_index[i] = j;
        }
      }

      localB->Output_Value[localB->Output_index[i]] = 0.0F;
    }

    for (i = 0U; i < rtu_Input_dim; i++) {
      localB->Output_Value[i] = rtu_Input_Value[localB->Output_index[i]];
    }
  }
}

/*
 * Output and update for atomic system:
 *    '<S53>/InputValueCalc1'
 *    '<S59>/InputValueCalc1'
 *    '<S140>/InputValueCalc1'
 *    '<S150>/InputValueCalc1'
 */
void BSPR_BattTempCo_InputValueCalc1(uint8_T rtu_Input_Value, boolean_T rtu_Rige,
  const uint8_T rtu_Old_Value[5], B_InputValueCalc1_BSPR_BattTe_T *localB,
  DW_InputValueCalc1_BSPR_BattT_T *localDW)
{
  if (localDW->is_active_c26_BSPR_BattTempCoor == 0U) {
    localDW->is_active_c26_BSPR_BattTempCoor = 1U;
    localB->Output_Value[0] = rtu_Input_Value;
    localB->Output_Value[1] = rtu_Input_Value;
    localB->Output_Value[2] = rtu_Input_Value;
    localB->Output_Value[3] = rtu_Input_Value;
    localB->Output_Value[4] = rtu_Input_Value;
  } else if (rtu_Rige) {
    localB->Output_Value[0] = rtu_Input_Value;
    localB->Output_Value[1] = rtu_Old_Value[0];
    localB->Output_Value[2] = rtu_Old_Value[1];
    localB->Output_Value[3] = rtu_Old_Value[2];
    localB->Output_Value[4] = rtu_Old_Value[3];
  } else {
    localB->Output_Value[0] = rtu_Old_Value[0];
    localB->Output_Value[1] = rtu_Old_Value[1];
    localB->Output_Value[2] = rtu_Old_Value[2];
    localB->Output_Value[3] = rtu_Old_Value[3];
    localB->Output_Value[4] = rtu_Old_Value[4];
  }
}

/*
 * System initialize for atomic system:
 *    '<S67>/Unit Delay External IC'
 *    '<S68>/Unit Delay External IC1'
 *    '<S158>/Unit Delay External IC'
 *    '<S159>/Unit Delay External IC1'
 */
void BSPR_B_UnitDelayExternalIC_Init(DW_UnitDelayExternalIC_BSPR_B_T *localDW)
{
  localDW->StateName_o = 1U;
}

/*
 * System reset for atomic system:
 *    '<S67>/Unit Delay External IC'
 *    '<S68>/Unit Delay External IC1'
 *    '<S158>/Unit Delay External IC'
 *    '<S159>/Unit Delay External IC1'
 */
void BSPR__UnitDelayExternalIC_Reset(DW_UnitDelayExternalIC_BSPR_B_T *localDW)
{
  localDW->StateName_o = 1U;
  localDW->StateName = 0.0F;
}

/*
 * Outputs for atomic system:
 *    '<S67>/Unit Delay External IC'
 *    '<S68>/Unit Delay External IC1'
 *    '<S158>/Unit Delay External IC'
 *    '<S159>/Unit Delay External IC1'
 */
void BSPR_BattTe_UnitDelayExternalIC(real32_T rtu_IC,
  B_UnitDelayExternalIC_BSPR_Ba_T *localB, DW_UnitDelayExternalIC_BSPR_B_T
  *localDW)
{
  if (localDW->StateName_o != 0) {
    localB->Init = rtu_IC;
  } else {
    localB->Init = localDW->StateName;
  }
}

/*
 * Update for atomic system:
 *    '<S67>/Unit Delay External IC'
 *    '<S68>/Unit Delay External IC1'
 *    '<S158>/Unit Delay External IC'
 *    '<S159>/Unit Delay External IC1'
 */
void BSPR_UnitDelayExternalIC_Update(real32_T rtu_u,
  DW_UnitDelayExternalIC_BSPR_B_T *localDW)
{
  localDW->StateName_o = 0U;
  localDW->StateName = rtu_u;
}

/* Model step function */
void BSPR_BattTempCoord_step(void)
{
  uint8_T rtb_Product2;
  boolean_T rtb_LogicalOperator3;
  int16_T s47_iter;
  uint32_T tmp;
  int32_T i;
  real32_T rtb_Product_f;
  real32_T rtb_Product_g;
  int8_T s66_iter;
  real32_T rtb_UnitDelay21_d[5];
  uint8_T rtb_UnitDelay1_fy[5];
  boolean_T rtb_LaCDP_BusbarTempAbn_flg[48];
  uint8_T rtb_LcCDP_IniOutputCellTempNumb;
  boolean_T rtb_Compare_gm;
  boolean_T rtb_GaCDP_BusbarTempVld_flg[48];
  real32_T rtb_uDLookupTable1[48];
  boolean_T rtb_Switch1_ce[48];
  boolean_T rtb_LaCDP_BusbarTempUpdateVld_f[48];
  real32_T rtb_LaCDP_BusbarTemp_C[48];
  real32_T rtb_UnitDelay21[240];
  real32_T rtb_uDLookupTable1_k[48];
  real32_T rtb_LaCDP_CellTemp_C[48];
  uint8_T StateName_do;
  uint8_T StateName_bj;
  uint8_T StateName_lk;
  int32_T i_0;
  real32_T rtb_LogicalOperator3_0;
  int32_T tmp_0;
  tmp = 0U;
  for (i_0 = 0; i_0 < 48; i_0++) {
    rtb_LogicalOperator3 = ((GaISP_BusbarTempVld_numb[i_0] & 97) == 0);
    BSPR_bBattTempInvld_A[i_0] = !rtb_LogicalOperator3;
    rtb_GaCDP_BusbarTempVld_flg[i_0] = rtb_LogicalOperator3;
    tmp += BSPR_bBattTempInvld_A[i_0];
  }

  BSPR_cntSumBattTempInvld = (uint8_T)tmp;
  tmp = GaISP_AFECellTempUpdErr_numb[0];
  for (i = 0; i < 47; i++) {
    tmp += GaISP_AFECellTempUpdErr_numb[i + 1];
  }

  BSPR_bBattTempElecNorm = ((uint8_T)tmp == 0);
  rtb_LogicalOperator3 = ((BSPR_cntSumBattTempInvld >= 1) &&
    (BSPR_cntSumBattTempInvld <= BSPR_cntBattTempVldHi_C) &&
    BSPR_bBattTempElecNorm);
  if (rtb_LogicalOperator3) {
    rtb_LogicalOperator3_0 = 0.02F;
  } else {
    rtb_LogicalOperator3_0 = 0.0F;
  }

  if (BSPR_tiCellTempInvldChk_C < BSPR_BattTempCoord_DW.Delay_DSTATE_hv) {
    rtb_Product_g = BSPR_tiCellTempInvldChk_C;
  } else {
    rtb_Product_g = BSPR_BattTempCoord_DW.Delay_DSTATE_hv;
  }

  rtb_Product_f = (rtb_LogicalOperator3_0 + rtb_Product_g) * (real32_T)
    rtb_LogicalOperator3;
  BSPR_BattTempCoord_DW.Delay_DSTATE_hv = rtb_Product_f;
  rtb_LogicalOperator3 = (BSPR_cntSumBattTempInvld == 0);
  if (rtb_LogicalOperator3) {
    rtb_LogicalOperator3_0 = 0.02F;
  } else {
    rtb_LogicalOperator3_0 = 0.0F;
  }

  if (BSPR_tiCellTempInvldChk_C < BSPR_BattTempCoord_DW.Delay_DSTATE_hb) {
    rtb_Product_g = BSPR_tiCellTempInvldChk_C;
  } else {
    rtb_Product_g = BSPR_BattTempCoord_DW.Delay_DSTATE_hb;
  }

  rtb_Product_g = (rtb_LogicalOperator3_0 + rtb_Product_g) * (real32_T)
    rtb_LogicalOperator3;
  rtb_LogicalOperator3 = (rtb_Product_g > BSPR_tiCellTempInvldChk_C);
  BSPR_BattTempCoord_DW.Delay_DSTATE_hb = rtb_Product_g;
  if (BSPR_BattTempCoord_DW.Delay2_DSTATE_d) {
    rtb_Product2 = (uint8_T)~(uint8_T)((uint8_T)~DFC_BattTempVldMin_ASW | 8U);
  } else {
    rtb_Compare_gm = ((BSPR_cntBattTempVldDiag_CW & 1) == 1);
    if (rtb_Compare_gm && (rtb_Product_f > BSPR_tiCellTempInvldChk_C)) {
      rtb_Product2 = (uint8_T)(DFC_BattTempVldMin_ASW | 152U);
    } else if ((!rtb_Compare_gm) || rtb_LogicalOperator3) {
      rtb_Product2 = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_BattTempVldMin_ASW |
        16U) | 8U);
    } else {
      rtb_Product2 = BSPR_BattTempCoord_DW.Delay3_DSTATE_f;
    }
  }

  BSPR_BattTempCoord_DW.Delay2_DSTATE_d = false;
  BSPR_BattTempCoord_DW.Delay3_DSTATE_f = rtb_Product2;
  DFC_BattTempVldMin_ASW = rtb_Product2;
  rtb_Compare_gm = ((BSPR_cntSumBattTempInvld > BSPR_cntBattTempVldHi_C) &&
                    BSPR_bBattTempElecNorm);
  if (rtb_Compare_gm) {
    rtb_Product_f = 0.02F;
  } else {
    rtb_Product_f = 0.0F;
  }

  if (BSPR_tiCellTempInvldChk_C < BSPR_BattTempCoord_DW.Delay_DSTATE_o2) {
    rtb_Product_g = BSPR_tiCellTempInvldChk_C;
  } else {
    rtb_Product_g = BSPR_BattTempCoord_DW.Delay_DSTATE_o2;
  }

  rtb_Product_f = (rtb_Product_f + rtb_Product_g) * (real32_T)rtb_Compare_gm;
  BSPR_BattTempCoord_DW.Delay_DSTATE_o2 = rtb_Product_f;
  if (BSPR_BattTempCoord_DW.Delay2_DSTATE_g) {
    rtb_Product2 = (uint8_T)~(uint8_T)((uint8_T)~DFC_BattTempVldMax_ASW | 8U);
  } else {
    rtb_Compare_gm = ((BSPR_cntBattTempVldDiag_CW & 2) == 2);
    if (rtb_Compare_gm && (rtb_Product_f > BSPR_tiCellTempInvldChk_C)) {
      rtb_Product2 = (uint8_T)(DFC_BattTempVldMax_ASW | 152U);
    } else if ((!rtb_Compare_gm) || rtb_LogicalOperator3) {
      rtb_Product2 = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_BattTempVldMax_ASW |
        16U) | 8U);
    } else {
      rtb_Product2 = BSPR_BattTempCoord_DW.Delay3_DSTATE_a;
    }
  }

  BSPR_BattTempCoord_DW.Delay2_DSTATE_g = false;
  BSPR_BattTempCoord_DW.Delay3_DSTATE_a = rtb_Product2;
  DFC_BattTempVldMax_ASW = rtb_Product2;
  BSPR_cntBattTSnsrNum = GcRTE_BusbarTempNumb_numb;
  for (i_0 = 0; i_0 < 48; i_0++) {
    rtb_uDLookupTable1[i_0] = look1_iflf_binlcpw(GaBSW_BusbarTempVolt_V[i_0], ((
      const real32_T *)&(BSPR_uSmplVoltMap_MAP[0])), ((const real32_T *)
      &(BSPR_tSmplTempMap_MAP[0])), 190U);
    if (BSPR_IgnorUpdateVld_flg) {
      rtb_LogicalOperator3 = ((GaISP_BusbarTempVld_numb[i_0] & 97) != 0);
    } else {
      rtb_LogicalOperator3 = (((GaISP_BusbarTempVld_numb[i_0] & 97) != 0) ||
        (!(GaISP_BusbarTempUpdCnt_numb[i_0] == 0)));
    }

    rtb_LaCDP_BusbarTempUpdateVld_f[i_0] = !rtb_LogicalOperator3;
    rtb_Switch1_ce[i_0] = rtb_LogicalOperator3;
  }

  BSP_ValidValueFilter_BusbarTemp(rtb_uDLookupTable1, GcRTE_BusbarTempNumb_numb,
    CcCDP_TempConfig_numb, &BSPR_BattTempCoord_B.sf_ValidValueFilter_BusbarTemp,
    &BSPR_BattTempCoord_DW.sf_ValidValueFilter_BusbarTemp);
  for (i_0 = 0; i_0 < 48; i_0++) {
    COMR_tBattTemp_A[i_0] =
      BSPR_BattTempCoord_B.sf_ValidValueFilter_BusbarTemp.OutputValue[i_0];
    rtb_LogicalOperator3 = ((GaBSW_BusbarTempVolt_V[i_0] >=
      BSPR_uTempVldChkHiThrd_C) || (GaBSW_BusbarTempVolt_V[i_0] <=
      BSPR_uTempVldChkLowThrd_C));
    if (!rtb_LogicalOperator3) {
      rtb_Product_g = COMR_tBattTemp_A[i_0];
    } else {
      rtb_Product_g = BSPR_BattTempCoord_DW.StateName_e[i_0];
    }

    if (rtb_Switch1_ce[i_0]) {
      rtb_LaCDP_BusbarTemp_C[i_0] = BSPR_BattTempCoord_DW.StateName[i_0];
    } else {
      rtb_LaCDP_BusbarTemp_C[i_0] = rtb_Product_g;
    }

    rtb_LaCDP_BusbarTempAbn_flg[i_0] = rtb_LogicalOperator3;
    rtb_uDLookupTable1[i_0] = rtb_Product_g;
  }

  for (i_0 = 0; i_0 < 240; i_0++) {
    rtb_UnitDelay21[i_0] = BSPR_BattTempCoord_DW.StateName_ep[i_0];
  }

  BSPR_BattTempCoo_InputValueCalc(rtb_LaCDP_BusbarTemp_C,
    rtb_LaCDP_BusbarTempUpdateVld_f, GcRTE_BusbarTempNumb_numb, rtb_UnitDelay21,
    &BSPR_BattTempCoord_B.sf_InputValueCalc,
    &BSPR_BattTempCoord_DW.sf_InputValueCalc);
  BSPR_BattTempCoor_MaxValue_sort
    (BSPR_BattTempCoord_B.sf_InputValueCalc.Output_Value,
     CcCDP_CellTempFilCfig_numb, GcRTE_BusbarTempNumb_numb,
     &BSPR_BattTempCoord_B.sf_MaxValue_sort,
     &BSPR_BattTempCoord_DW.sf_MaxValue_sort);
  for (i_0 = 0; i_0 < 48; i_0++) {
    BSPR_tBattTemp_A[i_0] =
      BSPR_BattTempCoord_B.sf_MaxValue_sort.TargetOutput_Value[i_0];
  }

  if (BSPR_BattTempCoord_DW.is_active_c31_BSPR_BattTempCoor == 0U) {
    BSPR_BattTempCoord_DW.is_active_c31_BSPR_BattTempCoor = 1U;
    for (rtb_Product2 = 0U; rtb_Product2 < BSPR_AFENumb_C; rtb_Product2++) {
      BSPR_BattTempCoord_B.OutputValue_flg_e[rtb_Product2] = false;
    }

    for (rtb_Product2 = 0U; rtb_Product2 < GcRTE_BusbarTempNumb_numb;
         rtb_Product2++) {
      if (rtb_LaCDP_BusbarTempAbn_flg[rtb_Product2]) {
        BSPR_BattTempCoord_B.OutputValue_flg_e[GaRTE_BusbarTempAFEMap_numb[rtb_Product2]
          - 1] = true;
      }
    }
  } else {
    for (rtb_Product2 = 0U; rtb_Product2 < BSPR_AFENumb_C; rtb_Product2++) {
      BSPR_BattTempCoord_B.OutputValue_flg_e[rtb_Product2] = false;
    }

    for (rtb_Product2 = 0U; rtb_Product2 < GcRTE_BusbarTempNumb_numb;
         rtb_Product2++) {
      if (rtb_LaCDP_BusbarTempAbn_flg[rtb_Product2]) {
        BSPR_BattTempCoord_B.OutputValue_flg_e[GaRTE_BusbarTempAFEMap_numb[rtb_Product2]
          - 1] = true;
      }
    }
  }

  for (i_0 = 0; i_0 < 48; i_0++) {
    if (BSPR_IgnorUpdateVld_flg) {
      rtb_Switch1_ce[i_0] = rtb_GaCDP_BusbarTempVld_flg[i_0];
    } else {
      rtb_Switch1_ce[i_0] = (rtb_GaCDP_BusbarTempVld_flg[i_0] &&
        (GaISP_BusbarTempUpdCnt_numb[i_0] == 0));
    }
  }

  rtb_LogicalOperator3 = false;
  for (s47_iter = 1; s47_iter <= GcRTE_BusbarTempNumb_numb; s47_iter++) {
    BSPR_BattTempCoord_B.LbCDP_AllowUpdateBusbarTemp_flg = (rtb_LogicalOperator3
      || rtb_Switch1_ce[s47_iter - 1]);
    rtb_LogicalOperator3 = BSPR_BattTempCoord_B.LbCDP_AllowUpdateBusbarTemp_flg;
  }

  rtb_LogicalOperator3 = true;
  for (s47_iter = 1; s47_iter <= GcRTE_BusbarTempNumb_numb; s47_iter++) {
    BSPR_BattTempCoord_B.LogicalOperator_i =
      (rtb_GaCDP_BusbarTempVld_flg[s47_iter - 1] && rtb_LogicalOperator3);
    rtb_LogicalOperator3 = BSPR_BattTempCoord_B.LogicalOperator_i;
  }

  if (BSPR_BattTempCoord_B.LbCDP_AllowUpdateBusbarTemp_flg) {
    if (!BSPR_BattTempCoord_DW.MaxMin_BusbarTemp_Get_Sys_MODE) {
      BSPR_BattTempCoord_DW.MaxMin_BusbarTemp_Get_Sys_MODE = true;
    }

    if (!BSPR_IgnorUpdateVld_flg) {
      for (i = 0; i < 48; i++) {
        rtb_GaCDP_BusbarTempVld_flg[i] = (rtb_GaCDP_BusbarTempVld_flg[i] &&
          (GaISP_BusbarTempUpdCnt_numb[i] == 0));
      }
    }

    rtb_Product2 = 0U;
    StateName_do = 0U;
    BSPR__UnitDelayExternalIC_Reset(&BSPR_BattTempCoord_DW.UnitDelayExternalIC);
    StateName_bj = 1U;
    rtb_Product_f = 0.0F;
    BSPR__UnitDelayExternalIC_Reset(&BSPR_BattTempCoord_DW.UnitDelayExternalIC1);
    StateName_lk = 1U;
    rtb_Product_g = 0.0F;
    for (s66_iter = 1; s66_iter <= (int8_T)GcRTE_BusbarTempNumb_numb; s66_iter++)
    {
      rtb_LcCDP_IniOutputCellTempNumb = (uint8_T)s66_iter;
      BSPR_BattTe_UnitDelayExternalIC(rtb_LaCDP_BusbarTemp_C[s66_iter - 1],
        &BSPR_BattTempCoord_B.UnitDelayExternalIC,
        &BSPR_BattTempCoord_DW.UnitDelayExternalIC);
      i = s66_iter - 1;
      if (rtb_GaCDP_BusbarTempVld_flg[i] &&
          (BSPR_BattTempCoord_B.UnitDelayExternalIC.Init <=
           rtb_LaCDP_BusbarTemp_C[i])) {
        BSPR_BattTempCoord_B.LcCDP_MaxBusbarTemp_C =
          rtb_LaCDP_BusbarTemp_C[s66_iter - 1];
        BSPR_BattTempCoord_B.LcCDP_MaxBusbarTempNumb_numb =
          rtb_LcCDP_IniOutputCellTempNumb;
      } else {
        if (StateName_bj != 0) {
          BSPR_BattTempCoord_B.LcCDP_MaxBusbarTemp_C =
            CcCDP_MaxBusbarTempIniVal_C;
        } else {
          BSPR_BattTempCoord_B.LcCDP_MaxBusbarTemp_C = rtb_Product_f;
        }

        BSPR_BattTempCoord_B.LcCDP_MaxBusbarTempNumb_numb = rtb_Product2;
      }

      BSPR_BattTe_UnitDelayExternalIC(rtb_LaCDP_BusbarTemp_C[s66_iter - 1],
        &BSPR_BattTempCoord_B.UnitDelayExternalIC1,
        &BSPR_BattTempCoord_DW.UnitDelayExternalIC1);
      if (rtb_GaCDP_BusbarTempVld_flg[s66_iter - 1] &&
          (BSPR_BattTempCoord_B.UnitDelayExternalIC1.Init >=
           rtb_LaCDP_BusbarTemp_C[s66_iter - 1])) {
        BSPR_BattTempCoord_B.LcCDP_MinBusbarTemp_C =
          rtb_LaCDP_BusbarTemp_C[s66_iter - 1];
        BSPR_BattTempCoord_B.LcCDP_MinBusbarTempNumb_numb =
          rtb_LcCDP_IniOutputCellTempNumb;
      } else {
        if (StateName_lk != 0) {
          BSPR_BattTempCoord_B.LcCDP_MinBusbarTemp_C =
            CcCDP_MinBusbarTempIniVal_C;
        } else {
          BSPR_BattTempCoord_B.LcCDP_MinBusbarTemp_C = rtb_Product_g;
        }

        BSPR_BattTempCoord_B.LcCDP_MinBusbarTempNumb_numb = StateName_do;
      }

      BSPR_UnitDelayExternalIC_Update(BSPR_BattTempCoord_B.LcCDP_MaxBusbarTemp_C,
        &BSPR_BattTempCoord_DW.UnitDelayExternalIC);
      StateName_bj = 0U;
      rtb_Product_f = BSPR_BattTempCoord_B.LcCDP_MaxBusbarTemp_C;
      rtb_Product2 = BSPR_BattTempCoord_B.LcCDP_MaxBusbarTempNumb_numb;
      BSPR_UnitDelayExternalIC_Update(BSPR_BattTempCoord_B.LcCDP_MinBusbarTemp_C,
        &BSPR_BattTempCoord_DW.UnitDelayExternalIC1);
      StateName_lk = 0U;
      rtb_Product_g = BSPR_BattTempCoord_B.LcCDP_MinBusbarTemp_C;
      StateName_do = BSPR_BattTempCoord_B.LcCDP_MinBusbarTempNumb_numb;
    }
  } else {
    if (BSPR_BattTempCoord_DW.MaxMin_BusbarTemp_Get_Sys_MODE) {
      BSPR_BattTempCoord_DW.MaxMin_BusbarTemp_Get_Sys_MODE = false;
    }
  }

  for (i_0 = 0; i_0 < 5; i_0++) {
    rtb_UnitDelay21_d[i_0] = BSPR_BattTempCoord_DW.StateName_k[i_0];
  }

  BSPR_BattTempC_InputValueCalc_i(BSPR_BattTempCoord_B.LcCDP_MaxBusbarTemp_C,
    BSPR_BattTempCoord_B.LbCDP_AllowUpdateBusbarTemp_flg, rtb_UnitDelay21_d,
    &BSPR_BattTempCoord_B.sf_InputValueCalc_i,
    &BSPR_BattTempCoord_DW.sf_InputValueCalc_i);
  BSPR_BattTempCo_MaxValue_sort_p
    (BSPR_BattTempCoord_B.sf_InputValueCalc_i.Output_Value,
     CcCDP_MaxCellTempFilCfig_numb, &BSPR_BattTempCoord_B.sf_MaxValue_sort_p,
     &BSPR_BattTempCoord_DW.sf_MaxValue_sort_p);
  for (i_0 = 0; i_0 < 5; i_0++) {
    rtb_UnitDelay1_fy[i_0] = BSPR_BattTempCoord_DW.StateName_k2[i_0];
  }

  BSPR_BattTempCo_InputValueCalc1
    (BSPR_BattTempCoord_B.LcCDP_MaxBusbarTempNumb_numb,
     BSPR_BattTempCoord_B.LbCDP_AllowUpdateBusbarTemp_flg, rtb_UnitDelay1_fy,
     &BSPR_BattTempCoord_B.sf_InputValueCalc1,
     &BSPR_BattTempCoord_DW.sf_InputValueCalc1);
  tmp_0 = (int32_T)(CcCDP_MaxCellTempFilCfig_numb + 1U);
  i = tmp_0;
  if ((uint32_T)tmp_0 > 255U) {
    i = 255;
  }

  BSPR_idxBattTempMax =
    BSPR_BattTempCoord_B.sf_InputValueCalc1.Output_Value[BSPR_BattTempCoord_B.sf_MaxValue_sort_p.Output_index
    [(int32_T)((uint32_T)i >> 1) - 1]];
  for (i_0 = 0; i_0 < 5; i_0++) {
    rtb_UnitDelay21_d[i_0] = BSPR_BattTempCoord_DW.StateName_p[i_0];
  }

  BSPR_BattTempC_InputValueCalc_i(BSPR_BattTempCoord_B.LcCDP_MinBusbarTemp_C,
    BSPR_BattTempCoord_B.LbCDP_AllowUpdateBusbarTemp_flg, rtb_UnitDelay21_d,
    &BSPR_BattTempCoord_B.sf_InputValueCalc_e,
    &BSPR_BattTempCoord_DW.sf_InputValueCalc_e);
  BSPR_BattTempCo_MaxValue_sort_p
    (BSPR_BattTempCoord_B.sf_InputValueCalc_e.Output_Value,
     CcCDP_MaxCellTempFilCfig_numb, &BSPR_BattTempCoord_B.sf_MaxValue_sort_f,
     &BSPR_BattTempCoord_DW.sf_MaxValue_sort_f);
  i = tmp_0;
  if ((uint32_T)tmp_0 > 255U) {
    i = 255;
  }

  rtb_Product2 = (uint8_T)((uint32_T)i >> 1);
  i = tmp_0;
  if ((uint32_T)tmp_0 > 255U) {
    i = 255;
  }

  for (i_0 = 0; i_0 < 5; i_0++) {
    rtb_UnitDelay1_fy[i_0] = BSPR_BattTempCoord_DW.StateName_ob[i_0];
  }

  BSPR_BattTempCo_InputValueCalc1
    (BSPR_BattTempCoord_B.LcCDP_MinBusbarTempNumb_numb,
     BSPR_BattTempCoord_B.LbCDP_AllowUpdateBusbarTemp_flg, rtb_UnitDelay1_fy,
     &BSPR_BattTempCoord_B.sf_InputValueCalc1_g,
     &BSPR_BattTempCoord_DW.sf_InputValueCalc1_g);
  BSPR_idxBattTempMin =
    BSPR_BattTempCoord_B.sf_InputValueCalc1_g.Output_Value[BSPR_BattTempCoord_B.sf_MaxValue_sort_f.Output_index
    [(int32_T)((uint32_T)(uint8_T)i >> 1) - 1]];
  i = tmp_0;
  if ((uint32_T)tmp_0 > 255U) {
    i = 255;
  }

  if (CcCDP_BusbarTempHiThrd_C <
      BSPR_BattTempCoord_B.sf_MaxValue_sort_p.Output_Value[(int32_T)((uint32_T)i
       >> 1) - 1]) {
    rtb_Product_f = CcCDP_BusbarTempHiThrd_C;
  } else {
    i = tmp_0;
    if ((uint32_T)tmp_0 > 255U) {
      i = 255;
    }

    rtb_Product_f = BSPR_BattTempCoord_B.sf_MaxValue_sort_p.Output_Value
      [(int32_T)((uint32_T)i >> 1) - 1];
  }

  if (rtb_Product_f > CcCDP_BusbarTempLoThrd_C) {
    BSPR_tBattTempMax = rtb_Product_f;
  } else {
    BSPR_tBattTempMax = CcCDP_BusbarTempLoThrd_C;
  }

  if (CcCDP_BusbarTempHiThrd_C <
      BSPR_BattTempCoord_B.sf_MaxValue_sort_f.Output_Value[rtb_Product2 - 1]) {
    rtb_Product_f = CcCDP_BusbarTempHiThrd_C;
  } else {
    rtb_Product_f =
      BSPR_BattTempCoord_B.sf_MaxValue_sort_f.Output_Value[rtb_Product2 - 1];
  }

  if (rtb_Product_f > CcCDP_BusbarTempLoThrd_C) {
    BSPR_tBattTempMin = rtb_Product_f;
  } else {
    BSPR_tBattTempMin = CcCDP_BusbarTempLoThrd_C;
  }

  if (BSPR_BattTempCoord_B.LogicalOperator_i) {
    if (!BSPR_BattTempCoord_DW.MaxMin_BusbarAvgTemp_Get_Sys_MO) {
      BSPR_BattTempCoord_DW.MaxMin_BusbarAvgTemp_Get_Sys_MO = true;
    }

    rtb_Product_f = 0.0F;
    for (s66_iter = 1; s66_iter <= (int8_T)GcRTE_BusbarTempNumb_numb; s66_iter++)
    {
      BSPR_BattTempCoord_B.LcCDP_SumBusbarTemp_C =
        rtb_LaCDP_BusbarTemp_C[s66_iter - 1] + rtb_Product_f;
      rtb_Product_f = BSPR_BattTempCoord_B.LcCDP_SumBusbarTemp_C;
    }

    BSPR_BattTempCoord_B.GcCDP_AvgBusbarTemp_C =
      BSPR_BattTempCoord_B.LcCDP_SumBusbarTemp_C / (real32_T)
      GcRTE_BusbarTempNumb_numb;
  } else {
    if (BSPR_BattTempCoord_DW.MaxMin_BusbarAvgTemp_Get_Sys_MO) {
      BSPR_BattTempCoord_DW.MaxMin_BusbarAvgTemp_Get_Sys_MO = false;
    }
  }

  BSPR_tBattTempAvrg = BSPR_BattTempCoord_B.GcCDP_AvgBusbarTemp_C;
  tmp = 0U;
  for (i_0 = 0; i_0 < 48; i_0++) {
    rtb_LogicalOperator3 = ((GaISP_CellTempVld_numb[i_0] & 97) == 0);
    BSPR_bCellTempInvld_A[i_0] = !rtb_LogicalOperator3;
    rtb_GaCDP_BusbarTempVld_flg[i_0] = rtb_LogicalOperator3;
    tmp += BSPR_bCellTempInvld_A[i_0];
  }

  BSPR_cntSumCellTempInvld = (uint8_T)tmp;
  tmp = GaISP_AFECellTempUpdErr_numb[0];
  for (i = 0; i < 47; i++) {
    tmp += GaISP_AFECellTempUpdErr_numb[i + 1];
  }

  BSPR_bCellTempElecNorm = ((uint8_T)tmp == 0);
  rtb_LogicalOperator3 = ((BSPR_cntSumCellTempInvld >= 1) &&
    (BSPR_cntSumCellTempInvld <= BSPR_cntBattTempVldHi_C) &&
    BSPR_bCellTempElecNorm);
  if (rtb_LogicalOperator3) {
    rtb_LogicalOperator3_0 = 0.02F;
  } else {
    rtb_LogicalOperator3_0 = 0.0F;
  }

  if (BSPR_tiCellTempInvldChk_C < BSPR_BattTempCoord_DW.Delay_DSTATE_h) {
    rtb_Product_g = BSPR_tiCellTempInvldChk_C;
  } else {
    rtb_Product_g = BSPR_BattTempCoord_DW.Delay_DSTATE_h;
  }

  rtb_Product_f = (rtb_LogicalOperator3_0 + rtb_Product_g) * (real32_T)
    rtb_LogicalOperator3;
  BSPR_BattTempCoord_DW.Delay_DSTATE_h = rtb_Product_f;
  rtb_LogicalOperator3 = (BSPR_cntSumCellTempInvld == 0);
  if (rtb_LogicalOperator3) {
    rtb_LogicalOperator3_0 = 0.02F;
  } else {
    rtb_LogicalOperator3_0 = 0.0F;
  }

  if (BSPR_tiCellTempInvldChk_C < BSPR_BattTempCoord_DW.Delay_DSTATE) {
    rtb_Product_g = BSPR_tiCellTempInvldChk_C;
  } else {
    rtb_Product_g = BSPR_BattTempCoord_DW.Delay_DSTATE;
  }

  rtb_Product_g = (rtb_LogicalOperator3_0 + rtb_Product_g) * (real32_T)
    rtb_LogicalOperator3;
  rtb_LogicalOperator3 = (rtb_Product_g > BSPR_tiCellTempInvldChk_C);
  BSPR_BattTempCoord_DW.Delay_DSTATE = rtb_Product_g;
  if (BSPR_BattTempCoord_DW.Delay2_DSTATE_m) {
    rtb_Product2 = (uint8_T)~(uint8_T)((uint8_T)~DFC_CellTempVldMin_ASW | 8U);
  } else {
    rtb_Compare_gm = ((BSPR_cntCellTempVldDiag_CW & 1) == 1);
    if (rtb_Compare_gm && (rtb_Product_f > BSPR_tiCellTempInvldChk_C)) {
      rtb_Product2 = (uint8_T)(DFC_CellTempVldMin_ASW | 152U);
    } else if ((!rtb_Compare_gm) || rtb_LogicalOperator3) {
      rtb_Product2 = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_CellTempVldMin_ASW |
        16U) | 8U);
    } else {
      rtb_Product2 = BSPR_BattTempCoord_DW.Delay3_DSTATE_b;
    }
  }

  BSPR_BattTempCoord_DW.Delay2_DSTATE_m = false;
  BSPR_BattTempCoord_DW.Delay3_DSTATE_b = rtb_Product2;
  DFC_CellTempVldMin_ASW = rtb_Product2;
  rtb_Compare_gm = ((BSPR_cntSumCellTempInvld > BSPR_cntBattTempVldHi_C) &&
                    BSPR_bCellTempElecNorm);
  if (rtb_Compare_gm) {
    rtb_Product_f = 0.02F;
  } else {
    rtb_Product_f = 0.0F;
  }

  if (BSPR_tiCellTempInvldChk_C < BSPR_BattTempCoord_DW.Delay_DSTATE_o) {
    rtb_Product_g = BSPR_tiCellTempInvldChk_C;
  } else {
    rtb_Product_g = BSPR_BattTempCoord_DW.Delay_DSTATE_o;
  }

  rtb_Product_f = (rtb_Product_f + rtb_Product_g) * (real32_T)rtb_Compare_gm;
  BSPR_BattTempCoord_DW.Delay_DSTATE_o = rtb_Product_f;
  if (BSPR_BattTempCoord_DW.Delay2_DSTATE) {
    rtb_Product2 = (uint8_T)~(uint8_T)((uint8_T)~DFC_CellTempVldMax_ASW | 8U);
  } else {
    rtb_Compare_gm = ((BSPR_cntCellTempVldDiag_CW & 2) == 2);
    if (rtb_Compare_gm && (rtb_Product_f > BSPR_tiCellTempInvldChk_C)) {
      rtb_Product2 = (uint8_T)(DFC_CellTempVldMax_ASW | 152U);
    } else if ((!rtb_Compare_gm) || rtb_LogicalOperator3) {
      rtb_Product2 = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_CellTempVldMax_ASW |
        16U) | 8U);
    } else {
      rtb_Product2 = BSPR_BattTempCoord_DW.Delay3_DSTATE;
    }
  }

  BSPR_BattTempCoord_DW.Delay2_DSTATE = false;
  BSPR_BattTempCoord_DW.Delay3_DSTATE = rtb_Product2;
  DFC_CellTempVldMax_ASW = rtb_Product2;
  BSPR_cntCellTSnsrNum = GcRTE_CellTempNumb_numb;
  for (i_0 = 0; i_0 < 48; i_0++) {
    if (BSPR_IgnorUpdateVld_flg) {
      rtb_Switch1_ce[i_0] = rtb_GaCDP_BusbarTempVld_flg[i_0];
    } else {
      rtb_Switch1_ce[i_0] = (rtb_GaCDP_BusbarTempVld_flg[i_0] &&
        (GaISP_CellTempUpdCnt_numb[i_0] == 0));
    }
  }

  rtb_LogicalOperator3 = false;
  for (s47_iter = 1; s47_iter <= GcRTE_CellTempNumb_numb; s47_iter++) {
    BSPR_BattTempCoord_B.LbCDP_AllowUpdateCellTemp_flg = (rtb_LogicalOperator3 ||
      rtb_Switch1_ce[s47_iter - 1]);
    rtb_LogicalOperator3 = BSPR_BattTempCoord_B.LbCDP_AllowUpdateCellTemp_flg;
  }

  rtb_LogicalOperator3 = true;
  for (s47_iter = 1; s47_iter <= GcRTE_CellTempNumb_numb; s47_iter++) {
    BSPR_BattTempCoord_B.LogicalOperator = (rtb_GaCDP_BusbarTempVld_flg[s47_iter
      - 1] && rtb_LogicalOperator3);
    rtb_LogicalOperator3 = BSPR_BattTempCoord_B.LogicalOperator;
  }

  for (i_0 = 0; i_0 < 48; i_0++) {
    if (BSPR_IgnorUpdateVld_flg) {
      rtb_Switch1_ce[i_0] = ((GaISP_CellTempVld_numb[i_0] & 97) != 0);
    } else {
      rtb_Switch1_ce[i_0] = (((GaISP_CellTempVld_numb[i_0] & 97) != 0) ||
        (!(GaISP_CellTempUpdCnt_numb[i_0] == 0)));
    }

    rtb_uDLookupTable1_k[i_0] = look1_iflf_binlcpw(GaBSW_CellTempVolt_V[i_0], ((
      const real32_T *)&(BSPR_uSmplVoltMap_MAP[0])), ((const real32_T *)
      &(BSPR_tSmplTempMap_MAP[0])), 190U);
  }

  BSP_ValidValueFilter_BusbarTemp(rtb_uDLookupTable1_k, GcRTE_CellTempNumb_numb,
    CcCDP_TempConfig_numb, &BSPR_BattTempCoord_B.sf_ValidValueFilter_CellTemp,
    &BSPR_BattTempCoord_DW.sf_ValidValueFilter_CellTemp);
  for (i_0 = 0; i_0 < 48; i_0++) {
    COMR_tCellTemp_A[i_0] =
      BSPR_BattTempCoord_B.sf_ValidValueFilter_CellTemp.OutputValue[i_0];
    rtb_LogicalOperator3 = ((GaBSW_CellTempVolt_V[i_0] >=
      BSPR_uTempVldChkHiThrd_C) || (GaBSW_CellTempVolt_V[i_0] <=
      BSPR_uTempVldChkLowThrd_C));
    if (!rtb_LogicalOperator3) {
      rtb_Product_g = COMR_tCellTemp_A[i_0];
    } else {
      rtb_Product_g = BSPR_BattTempCoord_DW.StateName_o[i_0];
    }

    if (rtb_Switch1_ce[i_0]) {
      rtb_LaCDP_CellTemp_C[i_0] = BSPR_BattTempCoord_DW.StateName_b[i_0];
    } else {
      rtb_LaCDP_CellTemp_C[i_0] = rtb_Product_g;
    }

    rtb_LaCDP_BusbarTempUpdateVld_f[i_0] = rtb_LogicalOperator3;
    rtb_uDLookupTable1_k[i_0] = rtb_Product_g;
  }

  if (BSPR_BattTempCoord_B.LbCDP_AllowUpdateCellTemp_flg) {
    if (!BSPR_BattTempCoord_DW.MaxMin_CellTemp_Get_Sys_MODE) {
      BSPR_BattTempCoord_DW.MaxMin_CellTemp_Get_Sys_MODE = true;
    }

    if (!BSPR_IgnorUpdateVld_flg) {
      for (i = 0; i < 48; i++) {
        rtb_GaCDP_BusbarTempVld_flg[i] = (rtb_GaCDP_BusbarTempVld_flg[i] &&
          (GaISP_CellTempUpdCnt_numb[i] == 0));
      }
    }

    rtb_Product2 = 0U;
    StateName_do = 0U;
    BSPR__UnitDelayExternalIC_Reset(&BSPR_BattTempCoord_DW.UnitDelayExternalIC_o);
    StateName_bj = 1U;
    rtb_Product_f = 0.0F;
    BSPR__UnitDelayExternalIC_Reset
      (&BSPR_BattTempCoord_DW.UnitDelayExternalIC1_e);
    StateName_lk = 1U;
    rtb_Product_g = 0.0F;
    for (s66_iter = 1; s66_iter <= (int8_T)GcRTE_CellTempNumb_numb; s66_iter++)
    {
      rtb_LcCDP_IniOutputCellTempNumb = (uint8_T)s66_iter;
      BSPR_BattTe_UnitDelayExternalIC(rtb_LaCDP_CellTemp_C[s66_iter - 1],
        &BSPR_BattTempCoord_B.UnitDelayExternalIC_o,
        &BSPR_BattTempCoord_DW.UnitDelayExternalIC_o);
      i = s66_iter - 1;
      if (rtb_GaCDP_BusbarTempVld_flg[i] &&
          (BSPR_BattTempCoord_B.UnitDelayExternalIC_o.Init <=
           rtb_LaCDP_CellTemp_C[i])) {
        BSPR_BattTempCoord_B.LcCDP_MaxCellTemp_C = rtb_LaCDP_CellTemp_C[s66_iter
          - 1];
        BSPR_BattTempCoord_B.LcCDP_MaxCellTempNumb_numb =
          rtb_LcCDP_IniOutputCellTempNumb;
      } else {
        if (StateName_bj != 0) {
          BSPR_BattTempCoord_B.LcCDP_MaxCellTemp_C = CcCDP_MaxCellTempIniVal_C;
        } else {
          BSPR_BattTempCoord_B.LcCDP_MaxCellTemp_C = rtb_Product_f;
        }

        BSPR_BattTempCoord_B.LcCDP_MaxCellTempNumb_numb = rtb_Product2;
      }

      BSPR_BattTe_UnitDelayExternalIC(rtb_LaCDP_CellTemp_C[s66_iter - 1],
        &BSPR_BattTempCoord_B.UnitDelayExternalIC1_e,
        &BSPR_BattTempCoord_DW.UnitDelayExternalIC1_e);
      if (rtb_GaCDP_BusbarTempVld_flg[s66_iter - 1] &&
          (BSPR_BattTempCoord_B.UnitDelayExternalIC1_e.Init >=
           rtb_LaCDP_CellTemp_C[s66_iter - 1])) {
        BSPR_BattTempCoord_B.LcCDP_MinCellTemp_C = rtb_LaCDP_CellTemp_C[s66_iter
          - 1];
        BSPR_BattTempCoord_B.LcCDP_MinCellTempNumb_numb =
          rtb_LcCDP_IniOutputCellTempNumb;
      } else {
        if (StateName_lk != 0) {
          BSPR_BattTempCoord_B.LcCDP_MinCellTemp_C = CcCDP_MinCellTempIniVal_C;
        } else {
          BSPR_BattTempCoord_B.LcCDP_MinCellTemp_C = rtb_Product_g;
        }

        BSPR_BattTempCoord_B.LcCDP_MinCellTempNumb_numb = StateName_do;
      }

      BSPR_UnitDelayExternalIC_Update(BSPR_BattTempCoord_B.LcCDP_MaxCellTemp_C,
        &BSPR_BattTempCoord_DW.UnitDelayExternalIC_o);
      StateName_bj = 0U;
      rtb_Product_f = BSPR_BattTempCoord_B.LcCDP_MaxCellTemp_C;
      rtb_Product2 = BSPR_BattTempCoord_B.LcCDP_MaxCellTempNumb_numb;
      BSPR_UnitDelayExternalIC_Update(BSPR_BattTempCoord_B.LcCDP_MinCellTemp_C,
        &BSPR_BattTempCoord_DW.UnitDelayExternalIC1_e);
      StateName_lk = 0U;
      rtb_Product_g = BSPR_BattTempCoord_B.LcCDP_MinCellTemp_C;
      StateName_do = BSPR_BattTempCoord_B.LcCDP_MinCellTempNumb_numb;
    }
  } else {
    if (BSPR_BattTempCoord_DW.MaxMin_CellTemp_Get_Sys_MODE) {
      BSPR_BattTempCoord_DW.MaxMin_CellTemp_Get_Sys_MODE = false;
    }
  }

  for (i_0 = 0; i_0 < 5; i_0++) {
    rtb_UnitDelay21_d[i_0] = BSPR_BattTempCoord_DW.StateName_bv[i_0];
  }

  BSPR_BattTempC_InputValueCalc_i(BSPR_BattTempCoord_B.LcCDP_MaxCellTemp_C,
    BSPR_BattTempCoord_B.LbCDP_AllowUpdateCellTemp_flg, rtb_UnitDelay21_d,
    &BSPR_BattTempCoord_B.sf_InputValueCalc_k,
    &BSPR_BattTempCoord_DW.sf_InputValueCalc_k);
  BSPR_BattTempCo_MaxValue_sort_p
    (BSPR_BattTempCoord_B.sf_InputValueCalc_k.Output_Value,
     CcCDP_MaxCellTempFilCfig_numb, &BSPR_BattTempCoord_B.sf_MaxValue_sort_g,
     &BSPR_BattTempCoord_DW.sf_MaxValue_sort_g);
  for (i_0 = 0; i_0 < 5; i_0++) {
    rtb_UnitDelay1_fy[i_0] = BSPR_BattTempCoord_DW.StateName_g3[i_0];
  }

  BSPR_BattTempCo_InputValueCalc1
    (BSPR_BattTempCoord_B.LcCDP_MaxCellTempNumb_numb,
     BSPR_BattTempCoord_B.LbCDP_AllowUpdateCellTemp_flg, rtb_UnitDelay1_fy,
     &BSPR_BattTempCoord_B.sf_InputValueCalc1_k,
     &BSPR_BattTempCoord_DW.sf_InputValueCalc1_k);
  i = tmp_0;
  if ((uint32_T)tmp_0 > 255U) {
    i = 255;
  }

  BSPR_idxCellTempMax =
    BSPR_BattTempCoord_B.sf_InputValueCalc1_k.Output_Value[BSPR_BattTempCoord_B.sf_MaxValue_sort_g.Output_index
    [(int32_T)((uint32_T)i >> 1) - 1]];
  for (i_0 = 0; i_0 < 5; i_0++) {
    rtb_UnitDelay21_d[i_0] = BSPR_BattTempCoord_DW.StateName_kz[i_0];
  }

  BSPR_BattTempC_InputValueCalc_i(BSPR_BattTempCoord_B.LcCDP_MinCellTemp_C,
    BSPR_BattTempCoord_B.LbCDP_AllowUpdateCellTemp_flg, rtb_UnitDelay21_d,
    &BSPR_BattTempCoord_B.sf_InputValueCalc_ik,
    &BSPR_BattTempCoord_DW.sf_InputValueCalc_ik);
  BSPR_BattTempCo_MaxValue_sort_p
    (BSPR_BattTempCoord_B.sf_InputValueCalc_ik.Output_Value,
     CcCDP_MaxCellTempFilCfig_numb, &BSPR_BattTempCoord_B.sf_MaxValue_sort_i,
     &BSPR_BattTempCoord_DW.sf_MaxValue_sort_i);
  i = tmp_0;
  if ((uint32_T)tmp_0 > 255U) {
    i = 255;
  }

  rtb_Product2 = (uint8_T)((uint32_T)i >> 1);
  for (i_0 = 0; i_0 < 5; i_0++) {
    rtb_UnitDelay1_fy[i_0] = BSPR_BattTempCoord_DW.StateName_kh[i_0];
  }

  BSPR_BattTempCo_InputValueCalc1
    (BSPR_BattTempCoord_B.LcCDP_MinCellTempNumb_numb,
     BSPR_BattTempCoord_B.LbCDP_AllowUpdateCellTemp_flg, rtb_UnitDelay1_fy,
     &BSPR_BattTempCoord_B.sf_InputValueCalc1_p,
     &BSPR_BattTempCoord_DW.sf_InputValueCalc1_p);
  i = tmp_0;
  if ((uint32_T)tmp_0 > 255U) {
    i = 255;
  }

  BSPR_idxCellTempMin =
    BSPR_BattTempCoord_B.sf_InputValueCalc1_p.Output_Value[BSPR_BattTempCoord_B.sf_MaxValue_sort_i.Output_index
    [(int32_T)((uint32_T)i >> 1) - 1]];
  i = tmp_0;
  if ((uint32_T)tmp_0 > 255U) {
    i = 255;
  }

  if (CcCDP_CellTempHiThrd_C <
      BSPR_BattTempCoord_B.sf_MaxValue_sort_g.Output_Value[(int32_T)((uint32_T)i
       >> 1) - 1]) {
    rtb_Product_f = CcCDP_CellTempHiThrd_C;
  } else {
    if ((uint32_T)tmp_0 > 255U) {
      tmp_0 = 255;
    }

    rtb_Product_f = BSPR_BattTempCoord_B.sf_MaxValue_sort_g.Output_Value
      [(int32_T)((uint32_T)tmp_0 >> 1) - 1];
  }

  if (rtb_Product_f > CcCDP_CellTempLoThrd_C) {
    BSPR_tCellTempMax = rtb_Product_f;
  } else {
    BSPR_tCellTempMax = CcCDP_CellTempLoThrd_C;
  }

  if (CcCDP_CellTempHiThrd_C <
      BSPR_BattTempCoord_B.sf_MaxValue_sort_i.Output_Value[rtb_Product2 - 1]) {
    rtb_Product_f = CcCDP_CellTempHiThrd_C;
  } else {
    rtb_Product_f =
      BSPR_BattTempCoord_B.sf_MaxValue_sort_i.Output_Value[rtb_Product2 - 1];
  }

  if (rtb_Product_f > CcCDP_CellTempLoThrd_C) {
    BSPR_tCellTempMin = rtb_Product_f;
  } else {
    BSPR_tCellTempMin = CcCDP_CellTempLoThrd_C;
  }

  if (BSPR_BattTempCoord_B.LogicalOperator) {
    if (!BSPR_BattTempCoord_DW.MaxMin_CellAvgTemp_Get_Sys_MODE) {
      BSPR_BattTempCoord_DW.MaxMin_CellAvgTemp_Get_Sys_MODE = true;
    }

    rtb_Product_f = 0.0F;
    for (s66_iter = 1; s66_iter <= (int8_T)GcRTE_CellTempNumb_numb; s66_iter++)
    {
      BSPR_BattTempCoord_B.LcCDP_SumCellTemp_C = rtb_LaCDP_CellTemp_C[s66_iter -
        1] + rtb_Product_f;
      rtb_Product_f = BSPR_BattTempCoord_B.LcCDP_SumCellTemp_C;
    }

    BSPR_BattTempCoord_B.GcCDP_AvgCellTemp_C =
      BSPR_BattTempCoord_B.LcCDP_SumCellTemp_C / (real32_T)
      GcRTE_CellTempNumb_numb;
  } else {
    if (BSPR_BattTempCoord_DW.MaxMin_CellAvgTemp_Get_Sys_MODE) {
      BSPR_BattTempCoord_DW.MaxMin_CellAvgTemp_Get_Sys_MODE = false;
    }
  }

  BSPR_tCellTempAvrg = BSPR_BattTempCoord_B.GcCDP_AvgCellTemp_C;
  if (BSPR_BattTempCoord_DW.is_active_c6_BSPR_BattTempCoord == 0U) {
    BSPR_BattTempCoord_DW.is_active_c6_BSPR_BattTempCoord = 1U;
    for (rtb_Product2 = 0U; rtb_Product2 < BSPR_AFENumb_C; rtb_Product2++) {
      BSPR_BattTempCoord_B.OutputValue_flg[rtb_Product2] = false;
    }

    for (rtb_Product2 = 0U; rtb_Product2 < GcRTE_CellTempNumb_numb; rtb_Product2
         ++) {
      if (rtb_LaCDP_BusbarTempUpdateVld_f[rtb_Product2]) {
        BSPR_BattTempCoord_B.OutputValue_flg[GaRTE_CellTempAFEMap_numb[rtb_Product2]
          - 1] = true;
      }
    }
  } else {
    for (rtb_Product2 = 0U; rtb_Product2 < BSPR_AFENumb_C; rtb_Product2++) {
      BSPR_BattTempCoord_B.OutputValue_flg[rtb_Product2] = false;
    }

    for (rtb_Product2 = 0U; rtb_Product2 < GcRTE_CellTempNumb_numb; rtb_Product2
         ++) {
      if (rtb_LaCDP_BusbarTempUpdateVld_f[rtb_Product2]) {
        BSPR_BattTempCoord_B.OutputValue_flg[GaRTE_CellTempAFEMap_numb[rtb_Product2]
          - 1] = true;
      }
    }
  }

  for (i = 0; i < 48; i++) {
    rtb_Switch1_ce[i] = !rtb_Switch1_ce[i];
  }

  for (i_0 = 0; i_0 < 240; i_0++) {
    rtb_UnitDelay21[i_0] = BSPR_BattTempCoord_DW.StateName_ba[i_0];
  }

  BSPR_BattTempCoo_InputValueCalc(rtb_LaCDP_CellTemp_C, rtb_Switch1_ce,
    GcRTE_CellTempNumb_numb, rtb_UnitDelay21,
    &BSPR_BattTempCoord_B.sf_InputValueCalc_n,
    &BSPR_BattTempCoord_DW.sf_InputValueCalc_n);
  BSPR_BattTempCoor_MaxValue_sort
    (BSPR_BattTempCoord_B.sf_InputValueCalc_n.Output_Value,
     CcCDP_CellTempFilCfig_numb, GcRTE_CellTempNumb_numb,
     &BSPR_BattTempCoord_B.sf_MaxValue_sort_a,
     &BSPR_BattTempCoord_DW.sf_MaxValue_sort_a);
  for (i_0 = 0; i_0 < 48; i_0++) {
    BSPR_tCellTemp_A[i_0] =
      BSPR_BattTempCoord_B.sf_MaxValue_sort_a.TargetOutput_Value[i_0];
  }

  for (i_0 = 0; i_0 < 8; i_0++) {
    if (CbCDP_AFETempSampAbnOvrSwt_flg) {
      GaCDP_AFETempSampAbn_flg[i_0] = CaCDP_AFETempSampAbnOvr_flg[i_0];
    } else {
      GaCDP_AFETempSampAbn_flg[i_0] =
        (BSPR_BattTempCoord_B.OutputValue_flg_e[i_0] ||
         BSPR_BattTempCoord_B.OutputValue_flg[i_0]);
    }
  }

  for (i_0 = 0; i_0 < 48; i_0++) {
    BSPR_BattTempCoord_DW.StateName[i_0] = rtb_LaCDP_BusbarTemp_C[i_0];
    BSPR_BattTempCoord_DW.StateName_e[i_0] = rtb_uDLookupTable1[i_0];
  }

  for (i_0 = 0; i_0 < 240; i_0++) {
    BSPR_BattTempCoord_DW.StateName_ep[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc.Output_Value[i_0];
  }

  for (i_0 = 0; i_0 < 5; i_0++) {
    BSPR_BattTempCoord_DW.StateName_k[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc_i.Output_Value[i_0];
    BSPR_BattTempCoord_DW.StateName_k2[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc1.Output_Value[i_0];
    BSPR_BattTempCoord_DW.StateName_p[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc_e.Output_Value[i_0];
    BSPR_BattTempCoord_DW.StateName_ob[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc1_g.Output_Value[i_0];
  }

  for (i_0 = 0; i_0 < 48; i_0++) {
    BSPR_BattTempCoord_DW.StateName_b[i_0] = rtb_LaCDP_CellTemp_C[i_0];
    BSPR_BattTempCoord_DW.StateName_o[i_0] = rtb_uDLookupTable1_k[i_0];
  }

  for (i_0 = 0; i_0 < 5; i_0++) {
    BSPR_BattTempCoord_DW.StateName_bv[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc_k.Output_Value[i_0];
    BSPR_BattTempCoord_DW.StateName_g3[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc1_k.Output_Value[i_0];
    BSPR_BattTempCoord_DW.StateName_kz[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc_ik.Output_Value[i_0];
    BSPR_BattTempCoord_DW.StateName_kh[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc1_p.Output_Value[i_0];
  }

  for (i_0 = 0; i_0 < 240; i_0++) {
    BSPR_BattTempCoord_DW.StateName_ba[i_0] =
      BSPR_BattTempCoord_B.sf_InputValueCalc_n.Output_Value[i_0];
  }
}

/* Model initialize function */
void BSPR_BattTempCoord_initialize(void)
{
  /* Registration code */

  /* block I/O */

  /* custom signals */
  {
    int32_T i;
    for (i = 0; i < 48; i++) {
      COMR_tBattTemp_A[i] = 0.0F;
    }
  }

  {
    int32_T i;
    for (i = 0; i < 48; i++) {
      BSPR_tBattTemp_A[i] = 0.0F;
    }
  }

  BSPR_tBattTempAvrg = 0.0F;

  {
    int32_T i;
    for (i = 0; i < 48; i++) {
      COMR_tCellTemp_A[i] = 0.0F;
    }
  }

  BSPR_tCellTempAvrg = 0.0F;

  {
    int32_T i;
    for (i = 0; i < 48; i++) {
      BSPR_tCellTemp_A[i] = 0.0F;
    }
  }

  BSPR_tCellTempMin = 0.0F;
  BSPR_tCellTempMax = 0.0F;
  BSPR_tBattTempMin = 0.0F;
  BSPR_tBattTempMax = 0.0F;
  BSPR_cntBattTSnsrNum = ((uint8_T)0U);
  BSPR_idxBattTempMax = ((uint8_T)0U);
  BSPR_idxBattTempMin = ((uint8_T)0U);
  BSPR_cntCellTSnsrNum = ((uint8_T)0U);
  BSPR_idxCellTempMax = ((uint8_T)0U);
  BSPR_idxCellTempMin = ((uint8_T)0U);

  {
    int32_T i;
    for (i = 0; i < 8; i++) {
      GaCDP_AFETempSampAbn_flg[i] = false;
    }
  }

  BSPR_BattTempCoord_DW.Delay2_DSTATE_d = true;
  BSPR_BattTempCoord_DW.Delay2_DSTATE_g = true;
  BSPR_B_UnitDelayExternalIC_Init(&BSPR_BattTempCoord_DW.UnitDelayExternalIC);
  BSPR_B_UnitDelayExternalIC_Init(&BSPR_BattTempCoord_DW.UnitDelayExternalIC1);
  BSPR_BattTempCoord_DW.Delay2_DSTATE_m = true;
  BSPR_BattTempCoord_DW.Delay2_DSTATE = true;
  BSPR_B_UnitDelayExternalIC_Init(&BSPR_BattTempCoord_DW.UnitDelayExternalIC_o);
  BSPR_B_UnitDelayExternalIC_Init(&BSPR_BattTempCoord_DW.UnitDelayExternalIC1_e);
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
