/*
 * File: COMR_LowVoltDiag.c
 *
 * Code generated for Simulink model 'COMR_LowVoltDiag'.
 *
 * Model version                  : A1.0_0
 * Simulink Coder version         : 8.11 (R2016b) 25-Aug-2016
 * C/C++ source code generated on : Fri Sep 11 17:26:07 2020
 *
 * 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 "COMR_LowVoltDiag.h"
#include "COMR_LowVoltDiag_private.h"

/* Named constants for Chart: '<S25>/ComDiagEn' */
#define COMR_LowVoltDia_IN_LowerDeb_Stt ((uint8_T)3U)
#define COMR_LowVoltDiag_IN_En_Stt     ((uint8_T)1U)
#define COMR_LowVoltDiag_IN_Ini_Stt    ((uint8_T)2U)
#define COMR_LowVoltDiag_IN_Lower_Stt  ((uint8_T)4U)
#define COMR_LowVoltDiag_IN_Normal_Stt ((uint8_T)5U)

/* Exported data definition */

/* Volatile memory section */
/* Definition for custom storage class: Volatile */
volatile uint8_T DFC_CSCPwrSpyHiErr_ASW;
volatile uint8_T DFC_CSCPwrSpyLoErr_ASW;
volatile uint8_T DFC_Kl30OutRngErr_ASW;
volatile uint8_T DFC_Kl30VoltHiErr_ASW;
volatile uint8_T DFC_Kl30VoltLoErr_ASW;
volatile uint8_T DFC_Kl30cVoltLoErr_ASW;

/* Definition for custom storage class: OutputSignal */
volatile boolean_T COMR_bCscPwrSpyHiDet;
volatile boolean_T COMR_bCscPwrSpyHiHeal;
volatile boolean_T COMR_bCscPwrSpyLoDet;
volatile boolean_T COMR_bCscPwrSpyLoHeal;
volatile boolean_T COMR_bKl30HiDet;
volatile boolean_T COMR_bKl30HiHeal;
volatile boolean_T COMR_bKl30LoDet;
volatile boolean_T COMR_bKl30LoHeal;
volatile boolean_T COMR_bKl30OutRngDet;
volatile boolean_T COMR_bKl30OutRngHeal;
volatile boolean_T COMR_bKl30cLowDet;
volatile boolean_T COMR_bKl30cLowHeal;
volatile boolean_T COMR_bLvComDiagEn;

/* Block states (auto storage) */
DW_COMR_LowVoltDiag_T COMR_LowVoltDiag_DW;

/* Forward declaration for local functions */
static void COMR_Low_enter_atomic_Lower_Stt(void);
static void COMR_LowVol_enter_atomic_En_Stt(void);
static void COMR_LowVoltDiag_Normal_Stt(void);
static void COMR_LowVoltDiag_En_Stt(void);
static void COMR_Lo_enter_atomic_Normal_Stt(void);
static void COMR_LowVoltDiag_Ini_Stt(void);
static void COMR_LowVoltDiag_LowerDeb_Stt(void);
static void COMR__enter_atomic_LowerDeb_Stt(void);
static void COMR_LowVoltDiag_Lower_Stt(void);
static void COMR_LowVo_enter_atomic_Ini_Stt(void);

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR_Low_enter_atomic_Lower_Stt(void)
{
  COMR_LowVoltDiag_DW.counter = 0.0F;
  COMR_bLvComDiagEn = false;
}

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR_LowVol_enter_atomic_En_Stt(void)
{
  COMR_LowVoltDiag_DW.counter = 0.0F;
  COMR_bLvComDiagEn = true;
}

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR_LowVoltDiag_Normal_Stt(void)
{
  if (COMR_LowVoltDiag_DW.counter >= 2.0F) {
    COMR_LowVoltDiag_DW.is_c4_COMR_LowVoltDiag = COMR_LowVoltDiag_IN_En_Stt;
    COMR_LowVol_enter_atomic_En_Stt();
  } else if ((BSPR_uKl30 < 9.0F) || (BSPR_uKl30 > 16.0F)) {
    COMR_LowVoltDiag_DW.is_c4_COMR_LowVoltDiag = COMR_LowVoltDiag_IN_Lower_Stt;
    COMR_Low_enter_atomic_Lower_Stt();
  } else {
    COMR_LowVoltDiag_DW.counter = (real32_T)(COMR_LowVoltDiag_DW.counter + 0.01F);
  }
}

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR_LowVoltDiag_En_Stt(void)
{
  if ((BSPR_uKl30 < 9.0F) || (BSPR_uKl30 > 16.0F)) {
    COMR_LowVoltDiag_DW.is_c4_COMR_LowVoltDiag = COMR_LowVoltDiag_IN_Lower_Stt;
    COMR_Low_enter_atomic_Lower_Stt();
  }
}

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR_Lo_enter_atomic_Normal_Stt(void)
{
  COMR_LowVoltDiag_DW.counter = 0.0F;
  COMR_bLvComDiagEn = false;
}

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR_LowVoltDiag_Ini_Stt(void)
{
  if ((BSPR_uKl30 >= 9.0F) && (BSPR_uKl30 <= 16.0F) &&
      (COMR_LowVoltDiag_DW.counter >= 0.05F)) {
    COMR_LowVoltDiag_DW.is_c4_COMR_LowVoltDiag = COMR_LowVoltDiag_IN_Normal_Stt;
    COMR_Lo_enter_atomic_Normal_Stt();
  } else if (((BSPR_uKl30 < 9.0F) || (BSPR_uKl30 > 16.0F)) &&
             (COMR_LowVoltDiag_DW.counter >= 0.05F)) {
    COMR_LowVoltDiag_DW.is_c4_COMR_LowVoltDiag = COMR_LowVoltDiag_IN_Lower_Stt;
    COMR_Low_enter_atomic_Lower_Stt();
  } else {
    COMR_LowVoltDiag_DW.counter = (real32_T)(COMR_LowVoltDiag_DW.counter + 0.01F);
  }
}

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR_LowVoltDiag_LowerDeb_Stt(void)
{
  if (COMR_LowVoltDiag_DW.counter >= 2.0F) {
    COMR_LowVoltDiag_DW.is_c4_COMR_LowVoltDiag = COMR_LowVoltDiag_IN_En_Stt;
    COMR_LowVol_enter_atomic_En_Stt();
  } else {
    COMR_LowVoltDiag_DW.counter = (real32_T)(COMR_LowVoltDiag_DW.counter + 0.01F);
  }
}

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR__enter_atomic_LowerDeb_Stt(void)
{
  COMR_LowVoltDiag_DW.counter = 0.0F;
  COMR_bLvComDiagEn = false;
}

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR_LowVoltDiag_Lower_Stt(void)
{
  if ((BSPR_uKl30 >= 10.0F) && (BSPR_uKl30 <= 15.0F)) {
    COMR_LowVoltDiag_DW.is_c4_COMR_LowVoltDiag = COMR_LowVoltDia_IN_LowerDeb_Stt;
    COMR__enter_atomic_LowerDeb_Stt();
  }
}

/* Function for Chart: '<S25>/ComDiagEn' */
static void COMR_LowVo_enter_atomic_Ini_Stt(void)
{
  COMR_LowVoltDiag_DW.counter = 0.0F;
  COMR_bLvComDiagEn = false;
}

/* Model step function */
void COMR_LowVoltDiag_step(void)
{
  boolean_T rtb_RelationalOperator2;
  boolean_T rtb_LogicalOperator5;
  boolean_T rtb_LogicalOperator3_n;
  real32_T rtb_Product_le;
  uint8_T rtb_Switch4_o;
  real32_T rtb_RelationalOperator2_0;
  rtb_RelationalOperator2 = (BSPR_uHwSplyVolt >= COMR_uCSCVoltHiErr_C);
  if (rtb_RelationalOperator2) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiCSCPwrSpy_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_jv) {
    rtb_Product_le = COMR_tiCSCPwrSpy_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_jv;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_RelationalOperator2;
  COMR_bCscPwrSpyHiDet = (rtb_Product_le > COMR_tiCSCPwrSpy_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_jv = rtb_Product_le;
  rtb_RelationalOperator2 = !rtb_RelationalOperator2;
  if (rtb_RelationalOperator2) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiCSCPwrSpy_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_l) {
    rtb_Product_le = COMR_tiCSCPwrSpy_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_l;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_RelationalOperator2;
  COMR_bCscPwrSpyHiHeal = (rtb_Product_le > COMR_tiCSCPwrSpy_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_l = rtb_Product_le;
  if (COMR_LowVoltDiag_DW.Delay2_DSTATE_k) {
    rtb_Switch4_o = (uint8_T)~(uint8_T)((uint8_T)~DFC_CSCPwrSpyHiErr_ASW | 8U);
  } else if (COMR_bCscPwrSpyHiDet) {
    rtb_Switch4_o = (uint8_T)(DFC_CSCPwrSpyHiErr_ASW | 152U);
  } else if (COMR_bCscPwrSpyHiHeal) {
    rtb_Switch4_o = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_CSCPwrSpyHiErr_ASW |
      16U) | 8U);
  } else {
    rtb_Switch4_o = COMR_LowVoltDiag_DW.Delay3_DSTATE_g;
  }

  COMR_LowVoltDiag_DW.Delay2_DSTATE_k = false;
  COMR_LowVoltDiag_DW.Delay3_DSTATE_g = rtb_Switch4_o;
  DFC_CSCPwrSpyHiErr_ASW = rtb_Switch4_o;
  rtb_RelationalOperator2 = (BSPR_uHwSplyVolt <= COMR_uCSCVoltLoErr_C);
  if (rtb_RelationalOperator2) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiCSCPwrSpy_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_id) {
    rtb_Product_le = COMR_tiCSCPwrSpy_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_id;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_RelationalOperator2;
  COMR_bCscPwrSpyLoDet = (rtb_Product_le > COMR_tiCSCPwrSpy_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_id = rtb_Product_le;
  rtb_RelationalOperator2 = !rtb_RelationalOperator2;
  if (rtb_RelationalOperator2) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiCSCPwrSpy_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_i) {
    rtb_Product_le = COMR_tiCSCPwrSpy_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_i;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_RelationalOperator2;
  COMR_bCscPwrSpyLoHeal = (rtb_Product_le > COMR_tiCSCPwrSpy_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_i = rtb_Product_le;
  if (COMR_LowVoltDiag_DW.Delay2_DSTATE_f) {
    rtb_Switch4_o = (uint8_T)~(uint8_T)((uint8_T)~DFC_CSCPwrSpyLoErr_ASW | 8U);
  } else if (COMR_bCscPwrSpyLoDet) {
    rtb_Switch4_o = (uint8_T)(DFC_CSCPwrSpyLoErr_ASW | 152U);
  } else if (COMR_bCscPwrSpyLoHeal) {
    rtb_Switch4_o = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_CSCPwrSpyLoErr_ASW |
      16U) | 8U);
  } else {
    rtb_Switch4_o = COMR_LowVoltDiag_DW.Delay3_DSTATE_n;
  }

  COMR_LowVoltDiag_DW.Delay2_DSTATE_f = false;
  COMR_LowVoltDiag_DW.Delay3_DSTATE_n = rtb_Switch4_o;
  DFC_CSCPwrSpyLoErr_ASW = rtb_Switch4_o;
  rtb_RelationalOperator2 = ((BSPR_uKl30 <= COMR_uKl30VoltOutRngLo_C) ||
    (BSPR_uKl30 >= COMR_uKl30VoltOutRngHi_C));
  if (rtb_RelationalOperator2) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiKl30OurRang_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_p) {
    rtb_Product_le = COMR_tiKl30OurRang_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_p;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_RelationalOperator2;
  COMR_bKl30OutRngDet = (rtb_Product_le > COMR_tiKl30OurRang_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_p = rtb_Product_le;
  rtb_LogicalOperator5 = !rtb_RelationalOperator2;
  if (rtb_LogicalOperator5) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiKl30OurRang_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_m) {
    rtb_Product_le = COMR_tiKl30OurRang_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_m;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_LogicalOperator5;
  COMR_bKl30OutRngHeal = (rtb_Product_le > COMR_tiKl30OurRang_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_m = rtb_Product_le;
  if (COMR_LowVoltDiag_DW.Delay2_DSTATE_g) {
    rtb_Switch4_o = (uint8_T)~(uint8_T)((uint8_T)~DFC_Kl30OutRngErr_ASW | 8U);
  } else if (COMR_bKl30OutRngDet) {
    rtb_Switch4_o = (uint8_T)(DFC_Kl30OutRngErr_ASW | 152U);
  } else if (COMR_bKl30OutRngHeal) {
    rtb_Switch4_o = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_Kl30OutRngErr_ASW |
      16U) | 8U);
  } else {
    rtb_Switch4_o = COMR_LowVoltDiag_DW.Delay3_DSTATE_o;
  }

  COMR_LowVoltDiag_DW.Delay2_DSTATE_g = false;
  COMR_LowVoltDiag_DW.Delay3_DSTATE_o = rtb_Switch4_o;
  DFC_Kl30OutRngErr_ASW = rtb_Switch4_o;
  rtb_LogicalOperator5 = !rtb_RelationalOperator2;
  rtb_LogicalOperator3_n = (rtb_LogicalOperator5 && (BSPR_uKl30 <
    COMR_uKl30VoltLoErr_C));
  if (rtb_LogicalOperator3_n) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiKl30HighLowErr_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_j) {
    rtb_Product_le = COMR_tiKl30HighLowErr_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_j;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_LogicalOperator3_n;
  COMR_bKl30LoDet = (rtb_Product_le > COMR_tiKl30HighLowErr_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_j = rtb_Product_le;
  rtb_LogicalOperator5 = (rtb_LogicalOperator5 && (BSPR_uKl30 >=
    COMR_uKl30VoltLoHeal_C));
  if (rtb_LogicalOperator5) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiKl30HighLowErr_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_n) {
    rtb_Product_le = COMR_tiKl30HighLowErr_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_n;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_LogicalOperator5;
  COMR_bKl30LoHeal = (rtb_Product_le > COMR_tiKl30HighLowErr_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_n = rtb_Product_le;
  if (COMR_LowVoltDiag_DW.Delay2_DSTATE_n) {
    rtb_Switch4_o = (uint8_T)~(uint8_T)((uint8_T)~DFC_Kl30VoltLoErr_ASW | 8U);
  } else if (COMR_bKl30LoDet) {
    rtb_Switch4_o = (uint8_T)(DFC_Kl30VoltLoErr_ASW | 152U);
  } else if (COMR_bKl30LoHeal) {
    rtb_Switch4_o = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_Kl30VoltLoErr_ASW |
      16U) | 8U);
  } else {
    rtb_Switch4_o = COMR_LowVoltDiag_DW.Delay3_DSTATE_h;
  }

  COMR_LowVoltDiag_DW.Delay2_DSTATE_n = false;
  COMR_LowVoltDiag_DW.Delay3_DSTATE_h = rtb_Switch4_o;
  DFC_Kl30VoltLoErr_ASW = rtb_Switch4_o;
  rtb_LogicalOperator5 = !rtb_RelationalOperator2;
  rtb_RelationalOperator2 = (rtb_LogicalOperator5 && (BSPR_uKl30 >
    COMR_uKl30VlotHiErr_C));
  if (rtb_RelationalOperator2) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiKl30HighLowErr_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_ox) {
    rtb_Product_le = COMR_tiKl30HighLowErr_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_ox;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_RelationalOperator2;
  COMR_bKl30HiDet = (rtb_Product_le > COMR_tiKl30HighLowErr_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_ox = rtb_Product_le;
  rtb_RelationalOperator2 = (rtb_LogicalOperator5 && (BSPR_uKl30 <=
    COMR_uKl30VlotHiHeal_C));
  if (rtb_RelationalOperator2) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiKl30HighLowErr_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_f) {
    rtb_Product_le = COMR_tiKl30HighLowErr_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_f;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_RelationalOperator2;
  COMR_bKl30HiHeal = (rtb_Product_le > COMR_tiKl30HighLowErr_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_f = rtb_Product_le;
  if (COMR_LowVoltDiag_DW.Delay2_DSTATE_d) {
    rtb_Switch4_o = (uint8_T)~(uint8_T)((uint8_T)~DFC_Kl30VoltHiErr_ASW | 8U);
  } else if (COMR_bKl30HiDet) {
    rtb_Switch4_o = (uint8_T)(DFC_Kl30VoltHiErr_ASW | 152U);
  } else if (COMR_bKl30HiHeal) {
    rtb_Switch4_o = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_Kl30VoltHiErr_ASW |
      16U) | 8U);
  } else {
    rtb_Switch4_o = COMR_LowVoltDiag_DW.Delay3_DSTATE_f;
  }

  COMR_LowVoltDiag_DW.Delay2_DSTATE_d = false;
  COMR_LowVoltDiag_DW.Delay3_DSTATE_f = rtb_Switch4_o;
  DFC_Kl30VoltHiErr_ASW = rtb_Switch4_o;
  if (COMR_LowVoltDiag_DW.is_active_c4_COMR_LowVoltDiag == 0U) {
    COMR_LowVoltDiag_DW.is_active_c4_COMR_LowVoltDiag = 1U;
    COMR_LowVoltDiag_DW.is_c4_COMR_LowVoltDiag = COMR_LowVoltDiag_IN_Ini_Stt;
    COMR_LowVo_enter_atomic_Ini_Stt();
  } else {
    switch (COMR_LowVoltDiag_DW.is_c4_COMR_LowVoltDiag) {
     case COMR_LowVoltDiag_IN_En_Stt:
      COMR_LowVoltDiag_En_Stt();
      break;

     case COMR_LowVoltDiag_IN_Ini_Stt:
      COMR_LowVoltDiag_Ini_Stt();
      break;

     case COMR_LowVoltDia_IN_LowerDeb_Stt:
      COMR_LowVoltDiag_LowerDeb_Stt();
      break;

     case COMR_LowVoltDiag_IN_Lower_Stt:
      COMR_LowVoltDiag_Lower_Stt();
      break;

     default:
      COMR_LowVoltDiag_Normal_Stt();
      break;
    }
  }

  if (BCCR_stBmsCtrMode == 4) {
    rtb_RelationalOperator2 = (BSPR_uKl30c <= COMR_uKl30cLowErrHVOn_C);
  } else {
    rtb_RelationalOperator2 = (BSPR_uKl30c <= COMR_uKl30cLowErrNoHVOn_C);
  }

  if (rtb_RelationalOperator2) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiKl30cLowErr_C <= COMR_LowVoltDiag_DW.Delay_DSTATE_o) {
    rtb_Product_le = COMR_tiKl30cLowErr_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE_o;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_RelationalOperator2;
  COMR_bKl30cLowDet = (rtb_Product_le > COMR_tiKl30cLowErr_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE_o = rtb_Product_le;
  rtb_RelationalOperator2 = (BSPR_uKl30c >= COMR_uKl30cLowErrHeal_C);
  if (rtb_RelationalOperator2) {
    rtb_RelationalOperator2_0 = 0.01F;
  } else {
    rtb_RelationalOperator2_0 = 0.0F;
  }

  if (COMR_tiKl30cLowErr_C <= COMR_LowVoltDiag_DW.Delay_DSTATE) {
    rtb_Product_le = COMR_tiKl30cLowErr_C;
  } else {
    rtb_Product_le = COMR_LowVoltDiag_DW.Delay_DSTATE;
  }

  rtb_Product_le = (rtb_RelationalOperator2_0 + rtb_Product_le) * (real32_T)
    rtb_RelationalOperator2;
  COMR_bKl30cLowHeal = (rtb_Product_le > COMR_tiKl30cLowErr_C);
  COMR_LowVoltDiag_DW.Delay_DSTATE = rtb_Product_le;
  if (COMR_LowVoltDiag_DW.Delay2_DSTATE) {
    rtb_Switch4_o = (uint8_T)~(uint8_T)((uint8_T)~DFC_Kl30cVoltLoErr_ASW | 8U);
  } else if (COMR_bKl30cLowDet) {
    rtb_Switch4_o = (uint8_T)(DFC_Kl30cVoltLoErr_ASW | 152U);
  } else if (COMR_bKl30cLowHeal) {
    rtb_Switch4_o = (uint8_T)((uint8_T)~(uint8_T)((uint8_T)~DFC_Kl30cVoltLoErr_ASW |
      16U) | 8U);
  } else {
    rtb_Switch4_o = COMR_LowVoltDiag_DW.Delay3_DSTATE;
  }

  COMR_LowVoltDiag_DW.Delay2_DSTATE = false;
  COMR_LowVoltDiag_DW.Delay3_DSTATE = rtb_Switch4_o;
  DFC_Kl30cVoltLoErr_ASW = rtb_Switch4_o;
}

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

  /* block I/O */

  /* custom signals */
  COMR_bKl30cLowHeal = false;
  COMR_bKl30cLowDet = false;
  COMR_bKl30HiHeal = false;
  COMR_bKl30LoHeal = false;
  COMR_bKl30OutRngHeal = false;
  COMR_bKl30OutRngDet = false;
  COMR_bKl30HiDet = false;
  COMR_bKl30LoDet = false;
  COMR_bLvComDiagEn = false;
  COMR_bCscPwrSpyLoHeal = false;
  COMR_bCscPwrSpyHiHeal = false;
  COMR_bCscPwrSpyHiDet = false;
  COMR_bCscPwrSpyLoDet = false;
  COMR_LowVoltDiag_DW.Delay2_DSTATE_k = true;
  COMR_LowVoltDiag_DW.Delay2_DSTATE_f = true;
  COMR_LowVoltDiag_DW.Delay2_DSTATE_g = true;
  COMR_LowVoltDiag_DW.Delay2_DSTATE_n = true;
  COMR_LowVoltDiag_DW.Delay2_DSTATE_d = true;
  COMR_LowVoltDiag_DW.Delay2_DSTATE = true;
}

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