/*
 * File: BSPR_BattTempRngDiag.c
 *
 * Code generated for Simulink model 'BSPR_BattTempRngDiag'.
 *
 * Model version                  : 1.1343
 * Simulink Coder version         : 8.13 (R2017b) 24-Jul-2017
 * C/C++ source code generated on : Wed Mar 10 09:56:07 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_BattTempRngDiag.h"
#include "BSPR_BattTempRngDiag_private.h"

/* Exported data definition */

/* Definition for custom storage class: FileScope */
static boolean_T BSPR_bBattTRngOTAlrmSwt;
static boolean_T BSPR_bBattTRngOTFaultSwt;
static boolean_T BSPR_bBattTRngOTWarnSwt;
static boolean_T BSPR_bBattTRngUTAlrmSwt;
static boolean_T BSPR_bBattTRngUTFaultSwt;
static boolean_T BSPR_bBattTRngUTWarnSwt;
static boolean_T BSPR_bCellTRngOTAlrmSwt;
static boolean_T BSPR_bCellTRngOTFaultSwt;
static boolean_T BSPR_bCellTRngOTWarnSwt;
static boolean_T BSPR_bCellTRngUTAlrmSwt;
static boolean_T BSPR_bCellTRngUTFaultSwt;
static boolean_T BSPR_bCellTRngUTWarnSwt;

#define ASW1_OEM_START_SEC_DEFAULT_RAM2_CLEARED_UNSPECIFIED
#include "Asw1_OEM_MemMap.h"

/* Definition for custom storage class: OutputSignal */
volatile boolean_T BSPR_bBattTMaxAlrmDet;/* Out of range high alarm state for battery temperature */
volatile boolean_T BSPR_bBattTMaxAlrmHeal;/* Out of range high alarm state healing condition for battery temperature */
volatile boolean_T BSPR_bBattTMaxFaultDet;/* Out of range high error for battery temperature */
volatile boolean_T BSPR_bBattTMaxFaultHeal;/* Out of range high error healing condition for battery temperature  */
volatile boolean_T BSPR_bBattTMaxWarnDet;/* Out of range high warn state for battery temperature */
volatile boolean_T BSPR_bBattTMaxWarnHeal;/* Out of range high warn state healing condition for battery temperature */
volatile boolean_T BSPR_bBattTMinAlrmDet;/* Out of range low alarm state for battery temperature */
volatile boolean_T BSPR_bBattTMinAlrmHeal;/* Out of range low alarm state healing condition for battery temperature */
volatile boolean_T BSPR_bBattTMinFaultDet;/* Out of range low error for battery temperature */
volatile boolean_T BSPR_bBattTMinFaultHeal;/* Out of range low error healing condition for battery temperature  */
volatile boolean_T BSPR_bBattTMinWarnDet;/* Out of range low warn state for battery temperature */
volatile boolean_T BSPR_bBattTMinWarnHeal;/* Out of range low warn state healing condition for battery temperature  */
volatile boolean_T BSPR_bBusbarMaxTempVld_flg;
volatile boolean_T BSPR_bCellMaxTempVld_flg;
volatile boolean_T BSPR_bCellTMaxAlrmDet;/* Out of range high alarm state for battery temperature */
volatile boolean_T BSPR_bCellTMaxAlrmHeal;/* Out of range high alarm state healing condition for battery temperature */
volatile boolean_T BSPR_bCellTMaxFaultDet;/* Out of range high error for battery temperature */
volatile boolean_T BSPR_bCellTMaxFaultHeal;/* Out of range high error healing condition for battery temperature  */
volatile boolean_T BSPR_bCellTMaxWarnDet;/* Out of range high warn state for battery temperature */
volatile boolean_T BSPR_bCellTMaxWarnHeal;/* Out of range high warn state healing condition for battery temperature */
volatile boolean_T BSPR_bCellTMinAlrmDet;/* Out of range low alarm state for battery temperature */
volatile boolean_T BSPR_bCellTMinAlrmHeal;/* Out of range low alarm state healing condition for battery temperature */
volatile boolean_T BSPR_bCellTMinFaultDet;/* Out of range low error for battery temperature */
volatile boolean_T BSPR_bCellTMinFaultHeal;/* Out of range low error healing condition for battery temperature  */
volatile boolean_T BSPR_bCellTMinWarnDet;/* Out of range low warn state for battery temperature */
volatile boolean_T BSPR_bCellTMinWarnHeal;/* Out of range low warn state healing condition for battery temperature  */

#define ASW1_OEM_STOP_SEC_DEFAULT_RAM2_CLEARED_UNSPECIFIED
#include "Asw1_OEM_MemMap.h"

/* Block signals (auto storage) */
B_BSPR_BattTempRngDiag_T BSPR_BattTempRngDiag_B;

/* Block states (auto storage) */
DW_BSPR_BattTempRngDiag_T BSPR_BattTempRngDiag_DW;

/*
 * Output and update for atomic system:
 *    '<S4>/TempRngBMSDebounceStartZero1'
 *    '<S6>/TempRngBMSDebounceStartZero5'
 *    '<S84>/TempRngBMSDebounceStartZero8'
 *    '<S86>/TempRngBMSDebounceStartZero11'
 */
void BS_TempRngBMSDebounceStartZero1(boolean_T rtu_Signal, real32_T
  rtu_Hearl2Fault, real32_T rtu_FaultStep, real32_T rtu_HealStep,
  B_TempRngBMSDebounceStartZero_T *localB, DW_TempRngBMSDebounceStartZer_T
  *localDW)
{
  boolean_T rtb_RelationalOperator_a;
  boolean_T rtb_RelationalOperator_d;
  uint16_T rtb_Switch2;
  uint16_T rtb_Switch2_e;
  real32_T tmp;
  if (localDW->StateName_p) {
    rtb_Switch2 = 0U;
  } else {
    rtb_Switch2 = localDW->StateName;
  }

  if (rtu_Signal) {
    tmp = (real32_T)fmod((real32_T)floor(rtu_FaultStep), 65536.0F);
    rtb_Switch2 = (uint16_T)((uint32_T)(tmp < 0.0F ? (int32_T)(uint16_T)
      -(int16_T)(uint16_T)-tmp : (int32_T)(uint16_T)tmp) + rtb_Switch2);
    if (!(rtb_Switch2 < 60000)) {
      rtb_Switch2 = 60000U;
    }
  } else if (rtb_Switch2 >= rtu_FaultStep) {
    tmp = (real32_T)fmod((real32_T)floor(rtu_FaultStep), 65536.0F);
    rtb_Switch2 = (uint16_T)((uint32_T)rtb_Switch2 - (tmp < 0.0F ? (int32_T)
      (uint16_T)-(int16_T)(uint16_T)-tmp : (int32_T)(uint16_T)tmp));
  } else {
    rtb_Switch2 = 0U;
  }

  rtb_RelationalOperator_a = (rtb_Switch2 > rtu_Hearl2Fault);
  if (localDW->StateName_j) {
    rtb_Switch2_e = 0U;
  } else {
    rtb_Switch2_e = localDW->StateName_g;
  }

  if (!rtu_Signal) {
    tmp = (real32_T)fmod((real32_T)floor(rtu_HealStep), 65536.0F);
    rtb_Switch2_e = (uint16_T)((uint32_T)(tmp < 0.0F ? (int32_T)(uint16_T)
      -(int16_T)(uint16_T)-tmp : (int32_T)(uint16_T)tmp) + rtb_Switch2_e);
    if (!(rtb_Switch2_e < 60000)) {
      rtb_Switch2_e = 60000U;
    }
  } else if (rtb_Switch2_e >= rtu_HealStep) {
    tmp = (real32_T)fmod((real32_T)floor(rtu_HealStep), 65536.0F);
    rtb_Switch2_e = (uint16_T)((uint32_T)rtb_Switch2_e - (tmp < 0.0F ? (int32_T)
      (uint16_T)-(int16_T)(uint16_T)-tmp : (int32_T)(uint16_T)tmp));
  } else {
    rtb_Switch2_e = 0U;
  }

  rtb_RelationalOperator_d = (rtb_Switch2_e > rtu_Hearl2Fault);
  if (!localB->Switch) {
    localB->Switch = rtb_RelationalOperator_a;
  } else {
    localB->Switch = !rtb_RelationalOperator_d;
  }

  localDW->StateName_p = rtb_RelationalOperator_a;
  localDW->StateName = rtb_Switch2;
  localDW->StateName_j = rtb_RelationalOperator_d;
  localDW->StateName_g = rtb_Switch2_e;
}

/*
 * Output and update for atomic system:
 *    '<S4>/TempRngBMSDebounceStartZero2'
 *    '<S4>/TempRngBMSDebounceStartZero3'
 *    '<S6>/TempRngBMSDebounceStartZero4'
 *    '<S6>/TempRngBMSDebounceStartZero6'
 *    '<S84>/TempRngBMSDebounceStartZero7'
 *    '<S84>/TempRngBMSDebounceStartZero9'
 *    '<S86>/TempRngBMSDebounceStartZero10'
 *    '<S86>/TempRngBMSDebounceStartZero12'
 */
void BS_TempRngBMSDebounceStartZero2(boolean_T rtu_Signal, real32_T
  rtu_Hearl2Fault, real32_T rtu_FaultStep, real32_T rtu_Fault2Heal, real32_T
  rtu_HealStep, B_TempRngBMSDebounceStartZe_p_T *localB,
  DW_TempRngBMSDebounceStartZ_j_T *localDW)
{
  boolean_T rtb_RelationalOperator_er;
  boolean_T rtb_RelationalOperator_l;
  uint16_T rtb_Switch2;
  uint16_T rtb_Switch2_l;
  real32_T tmp;
  if (localDW->StateName_o) {
    rtb_Switch2 = 0U;
  } else {
    rtb_Switch2 = localDW->StateName;
  }

  if (rtu_Signal) {
    tmp = (real32_T)fmod((real32_T)floor(rtu_FaultStep), 65536.0F);
    rtb_Switch2 = (uint16_T)((uint32_T)(tmp < 0.0F ? (int32_T)(uint16_T)
      -(int16_T)(uint16_T)-tmp : (int32_T)(uint16_T)tmp) + rtb_Switch2);
    if (!(rtb_Switch2 < 60000)) {
      rtb_Switch2 = 60000U;
    }
  } else if (rtb_Switch2 >= rtu_FaultStep) {
    tmp = (real32_T)fmod((real32_T)floor(rtu_FaultStep), 65536.0F);
    rtb_Switch2 = (uint16_T)((uint32_T)rtb_Switch2 - (tmp < 0.0F ? (int32_T)
      (uint16_T)-(int16_T)(uint16_T)-tmp : (int32_T)(uint16_T)tmp));
  } else {
    rtb_Switch2 = 0U;
  }

  rtb_RelationalOperator_er = (rtb_Switch2 > rtu_Hearl2Fault);
  if (localDW->StateName_od) {
    rtb_Switch2_l = 0U;
  } else {
    rtb_Switch2_l = localDW->StateName_h;
  }

  if (!rtu_Signal) {
    tmp = (real32_T)fmod((real32_T)floor(rtu_HealStep), 65536.0F);
    rtb_Switch2_l = (uint16_T)((uint32_T)(tmp < 0.0F ? (int32_T)(uint16_T)
      -(int16_T)(uint16_T)-tmp : (int32_T)(uint16_T)tmp) + rtb_Switch2_l);
    if (!(rtb_Switch2_l < 60000)) {
      rtb_Switch2_l = 60000U;
    }
  } else if (rtb_Switch2_l >= rtu_HealStep) {
    tmp = (real32_T)fmod((real32_T)floor(rtu_HealStep), 65536.0F);
    rtb_Switch2_l = (uint16_T)((uint32_T)rtb_Switch2_l - (tmp < 0.0F ? (int32_T)
      (uint16_T)-(int16_T)(uint16_T)-tmp : (int32_T)(uint16_T)tmp));
  } else {
    rtb_Switch2_l = 0U;
  }

  rtb_RelationalOperator_l = (rtb_Switch2_l > rtu_Fault2Heal);
  if (!localB->Switch) {
    localB->Switch = rtb_RelationalOperator_er;
  } else {
    localB->Switch = !rtb_RelationalOperator_l;
  }

  localDW->StateName_o = rtb_RelationalOperator_er;
  localDW->StateName = rtb_Switch2;
  localDW->StateName_od = rtb_RelationalOperator_l;
  localDW->StateName_h = rtb_Switch2_l;
}

/* Model step function */
void BSPR_BattTempRngDiag_step(void)
{
  boolean_T rtb_LogicalOperator6;
  real32_T rtb_BSPR_tBattTempMinProc;
  boolean_T rtb_LogicalOperator6_f;
  boolean_T rtb_LogicalOperator3;
  BSPR_bBattTRngOTWarnSwt = ((BSPR_cntBattTRngDiag_CW & 1) == 1);
  rtb_LogicalOperator6 = (((DFC_BattTHopMax_ASW & 16) == 16) || ((DFC_BattTCnstMax_ASW &
    16) == 16));
  if (rtb_LogicalOperator6) {
    rtb_BSPR_tBattTempMinProc = BSPR_tBattTempAvrg;
  } else {
    rtb_BSPR_tBattTempMinProc = BSPR_tBattTempMax;
  }

  rtb_LogicalOperator6_f = ((rtb_BSPR_tBattTempMinProc >=
    BSPR_tBusbarTRngWarnAlrmHi_C) && (rtb_BSPR_tBattTempMinProc <
    BSPR_tBusbarTRngHiFaultHi_C));
  BSPR_bBusbarMaxTempVld_flg = true;
  BS_TempRngBMSDebounceStartZero2((BSPR_tBusbarTRngHiFaultHi_C <=
    rtb_BSPR_tBattTempMinProc) && BSPR_bBusbarMaxTempVld_flg,
    BSPR_tiBattTempFault_C, BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempFault_C,
    BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero3,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero3);
  BSPR_bBattTRngOTFaultSwt = ((BSPR_cntBattTRngDiag_CW & 4) == 4);
  BSPR_bBattTMaxFaultDet = (BSPR_bBattTRngOTFaultSwt &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero3.Switch);
  BS_TempRngBMSDebounceStartZero1(rtb_LogicalOperator6_f &&
    (!BSPR_bBattTMaxFaultDet), BSPR_tiBattTempWarn_C + BSPR_tiBattTempAlrm_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero1,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero1);
  BSPR_bBattTRngOTAlrmSwt = ((BSPR_cntBattTRngDiag_CW & 2) == 2);
  BSPR_bBattTMaxAlrmDet = (BSPR_bBattTRngOTAlrmSwt &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero1.Switch);
  rtb_LogicalOperator3 = ((!BSPR_bBattTRngOTWarnSwt) || BSPR_bBattTMaxAlrmDet);
  BS_TempRngBMSDebounceStartZero2((!BSPR_bBattTMaxAlrmDet) &&
    (!BSPR_bBattTMaxFaultDet) && rtb_LogicalOperator6_f, BSPR_tiBattTempWarn_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempWarn_C,
    BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero2,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero2);
  BSPR_bBattTMaxWarnDet = ((!rtb_LogicalOperator3) &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero2.Switch);
  if (rtb_LogicalOperator3) {
    BSPR_bBattTMaxWarnHeal = true;
  } else {
    BSPR_bBattTMaxWarnHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero2.Switch;
  }

  if (BSPR_bBattTRngOTAlrmSwt) {
    BSPR_bBattTMaxAlrmHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero1.Switch;
  } else {
    BSPR_bBattTMaxAlrmHeal = true;
  }

  if (BSPR_bBattTRngOTFaultSwt) {
    BSPR_bBattTMaxFaultHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero3.Switch;
  } else {
    BSPR_bBattTMaxFaultHeal = true;
  }

  BSPR_bBattTRngUTWarnSwt = ((BSPR_cntBattTRngDiag_CW & 8) == 8);
  if (rtb_LogicalOperator6) {
    rtb_BSPR_tBattTempMinProc = BSPR_tBattTempAvrg;
  } else {
    rtb_BSPR_tBattTempMinProc = BSPR_tBattTempMin;
  }

  rtb_LogicalOperator3 = ((rtb_BSPR_tBattTempMinProc <=
    BSPR_tBattTRngWarnAlrmLo_C) && (rtb_BSPR_tBattTempMinProc >
    BSPR_tBattTRngHiFaultLo_C));
  BS_TempRngBMSDebounceStartZero2(BSPR_tBattTRngHiFaultLo_C >=
    rtb_BSPR_tBattTempMinProc, BSPR_tiBattTempFault_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempFault_C,
    BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero6,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero6);
  BSPR_bBattTRngUTFaultSwt = ((BSPR_cntBattTRngDiag_CW & 32) == 32);
  BSPR_bBattTMinFaultDet = (BSPR_bBattTRngUTFaultSwt &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero6.Switch);
  BS_TempRngBMSDebounceStartZero1(rtb_LogicalOperator3 &&
    (!BSPR_bBattTMinFaultDet), BSPR_tiBattTempWarn_C + BSPR_tiBattTempAlrm_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero5,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero5);
  BSPR_bBattTRngUTAlrmSwt = ((BSPR_cntBattTRngDiag_CW & 16) == 16);
  BSPR_bBattTMinAlrmDet = (BSPR_bBattTRngUTAlrmSwt &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero5.Switch);
  rtb_LogicalOperator6_f = ((!BSPR_bBattTRngUTWarnSwt) || BSPR_bBattTMinAlrmDet);
  BS_TempRngBMSDebounceStartZero2((!BSPR_bBattTMinAlrmDet) &&
    (!BSPR_bBattTMinFaultDet) && rtb_LogicalOperator3, BSPR_tiBattTempWarn_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempWarn_C,
    BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero4,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero4);
  BSPR_bBattTMinWarnDet = ((!rtb_LogicalOperator6_f) &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero4.Switch);
  if (rtb_LogicalOperator6_f) {
    BSPR_bBattTMinWarnHeal = true;
  } else {
    BSPR_bBattTMinWarnHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero4.Switch;
  }

  if (BSPR_bBattTRngUTAlrmSwt) {
    BSPR_bBattTMinAlrmHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero5.Switch;
  } else {
    BSPR_bBattTMinAlrmHeal = true;
  }

  if (BSPR_bBattTRngUTFaultSwt) {
    BSPR_bBattTMinFaultHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero6.Switch;
  } else {
    BSPR_bBattTMinFaultHeal = true;
  }

  BSPR_bCellTRngOTWarnSwt = ((BSPR_cntCellTRngDiag_CW & 1) == 1);
  rtb_LogicalOperator3 = (((DFC_CellTHopMax_ASW & 16) == 16) || ((DFC_CellTCnstMax_ASW &
    16) == 16));
  if (rtb_LogicalOperator3) {
    rtb_BSPR_tBattTempMinProc = BSPR_tCellTempAvrg;
  } else {
    rtb_BSPR_tBattTempMinProc = BSPR_tCellTempMax;
  }

  rtb_LogicalOperator6_f = ((rtb_BSPR_tBattTempMinProc >=
    BSPR_tBattTRngWarnAlrmHi_C) && (rtb_BSPR_tBattTempMinProc <
    BSPR_tBattTRngHiFaultHi_C));
  BSPR_bCellMaxTempVld_flg = true;
  BS_TempRngBMSDebounceStartZero2((BSPR_tBattTRngHiFaultHi_C <=
    rtb_BSPR_tBattTempMinProc) && BSPR_bCellMaxTempVld_flg,
    BSPR_tiBattTempFault_C, BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempFault_C,
    BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero9,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero9);
  BSPR_bCellTRngOTFaultSwt = ((BSPR_cntCellTRngDiag_CW & 4) == 4);
  BSPR_bCellTMaxFaultDet = (BSPR_bCellTRngOTFaultSwt &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero9.Switch);
  BS_TempRngBMSDebounceStartZero1(rtb_LogicalOperator6_f &&
    (!BSPR_bCellTMaxFaultDet), BSPR_tiBattTempWarn_C + BSPR_tiBattTempAlrm_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero8,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero8);
  BSPR_bCellTRngOTAlrmSwt = ((BSPR_cntCellTRngDiag_CW & 2) == 2);
  BSPR_bCellTMaxAlrmDet = (BSPR_bCellTRngOTAlrmSwt &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero8.Switch);
  rtb_LogicalOperator6 = ((!BSPR_bCellTRngOTWarnSwt) || BSPR_bCellTMaxAlrmDet);
  BS_TempRngBMSDebounceStartZero2((!BSPR_bCellTMaxAlrmDet) &&
    (!BSPR_bCellTMaxFaultDet) && rtb_LogicalOperator6_f, BSPR_tiBattTempWarn_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempWarn_C,
    BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero7,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero7);
  BSPR_bCellTMaxWarnDet = ((!rtb_LogicalOperator6) &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero7.Switch);
  if (rtb_LogicalOperator6) {
    BSPR_bCellTMaxWarnHeal = true;
  } else {
    BSPR_bCellTMaxWarnHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero7.Switch;
  }

  if (BSPR_bCellTRngOTAlrmSwt) {
    BSPR_bCellTMaxAlrmHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero8.Switch;
  } else {
    BSPR_bCellTMaxAlrmHeal = true;
  }

  if (BSPR_bCellTRngOTFaultSwt) {
    BSPR_bCellTMaxFaultHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero9.Switch;
  } else {
    BSPR_bCellTMaxFaultHeal = true;
  }

  BSPR_bCellTRngUTWarnSwt = ((BSPR_cntCellTRngDiag_CW & 8) == 8);
  if (rtb_LogicalOperator3) {
    rtb_BSPR_tBattTempMinProc = BSPR_tCellTempAvrg;
  } else {
    rtb_BSPR_tBattTempMinProc = BSPR_tCellTempMin;
  }

  rtb_LogicalOperator3 = ((rtb_BSPR_tBattTempMinProc <=
    BSPR_tBattTRngWarnAlrmLo_C) && (rtb_BSPR_tBattTempMinProc >
    BSPR_tBattTRngHiFaultLo_C));
  BS_TempRngBMSDebounceStartZero2(BSPR_tBattTRngHiFaultLo_C >=
    rtb_BSPR_tBattTempMinProc, BSPR_tiBattTempFault_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempFault_C,
    BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero12,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero12);
  BSPR_bCellTRngUTFaultSwt = ((BSPR_cntCellTRngDiag_CW & 32) == 32);
  BSPR_bCellTMinFaultDet = (BSPR_bCellTRngUTFaultSwt &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero12.Switch);
  BS_TempRngBMSDebounceStartZero1(rtb_LogicalOperator3 &&
    (!BSPR_bCellTMinFaultDet), BSPR_tiBattTempWarn_C + BSPR_tiBattTempAlrm_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero11,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero11);
  BSPR_bCellTRngUTAlrmSwt = ((BSPR_cntCellTRngDiag_CW & 16) == 16);
  BSPR_bCellTMinAlrmDet = (BSPR_bCellTRngUTAlrmSwt &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero11.Switch);
  rtb_LogicalOperator6_f = ((!BSPR_bCellTRngUTWarnSwt) || BSPR_bCellTMinAlrmDet);
  BS_TempRngBMSDebounceStartZero2((!BSPR_bCellTMinAlrmDet) &&
    (!BSPR_bCellTMinFaultDet) && rtb_LogicalOperator3, BSPR_tiBattTempWarn_C,
    BSPR_tiBattTempRngDiagTask_C, BSPR_tiBattTempWarn_C,
    BSPR_tiBattTempRngDiagTask_C,
    &BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero10,
    &BSPR_BattTempRngDiag_DW.TempRngBMSDebounceStartZero10);
  BSPR_bCellTMinWarnDet = ((!rtb_LogicalOperator6_f) &&
    BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero10.Switch);
  if (rtb_LogicalOperator6_f) {
    BSPR_bCellTMinWarnHeal = true;
  } else {
    BSPR_bCellTMinWarnHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero10.Switch;
  }

  if (BSPR_bCellTRngUTAlrmSwt) {
    BSPR_bCellTMinAlrmHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero11.Switch;
  } else {
    BSPR_bCellTMinAlrmHeal = true;
  }

  if (BSPR_bCellTRngUTFaultSwt) {
    BSPR_bCellTMinFaultHeal =
      !BSPR_BattTempRngDiag_B.TempRngBMSDebounceStartZero12.Switch;
  } else {
    BSPR_bCellTMinFaultHeal = true;
  }
}

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

  /* block I/O */

  /* custom signals */
  BSPR_bBattTMaxFaultDet = false;
  BSPR_bBattTMaxAlrmDet = false;
  BSPR_bBattTMaxWarnDet = false;
  BSPR_bBattTMaxWarnHeal = false;
  BSPR_bBattTMaxAlrmHeal = false;
  BSPR_bBattTMaxFaultHeal = false;
  BSPR_bBattTMinFaultDet = false;
  BSPR_bBattTMinAlrmDet = false;
  BSPR_bBattTMinWarnDet = false;
  BSPR_bBattTMinWarnHeal = false;
  BSPR_bBattTMinAlrmHeal = false;
  BSPR_bBattTMinFaultHeal = false;
  BSPR_bCellTMaxFaultDet = false;
  BSPR_bCellTMaxAlrmDet = false;
  BSPR_bCellTMaxWarnDet = false;
  BSPR_bCellTMaxWarnHeal = false;
  BSPR_bCellTMaxAlrmHeal = false;
  BSPR_bCellTMaxFaultHeal = false;
  BSPR_bCellTMinFaultDet = false;
  BSPR_bCellTMinAlrmDet = false;
  BSPR_bCellTMinWarnDet = false;
  BSPR_bCellTMinWarnHeal = false;
  BSPR_bCellTMinAlrmHeal = false;
  BSPR_bCellTMinFaultHeal = false;
}

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