/*
 * File: BCMR_DChrgGbFlow.c
 *
 * Code generated for Simulink model 'BCMR_DChrgGbFlow'.
 *
 * Model version                  : 1.299
 * Simulink Coder version         : 8.11 (R2016b) 25-Aug-2016
 * C/C++ source code generated on : Wed Nov 17 15:49:51 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 "BCMR_DChrgGbFlow.h"
#include "BCMR_DChrgGbFlow_private.h"

/* Named constants for Chart: '<S1>/DChrgEna' */
#define BCMR_DChrgGbFlow_IN_Disable    ((uint8_T)1U)
#define BCMR_DChrgGbFlow_IN_Enable     ((uint8_T)2U)
#define BCMR_DChrgGb_IN_NO_ACTIVE_CHILD ((uint8_T)0U)

/* Named constants for Chart: '<S3>/DcChrgStateFlow' */
#define BCMR_DChr_IN_TimeOutDChrgStop_g ((uint8_T)2U)
#define BCMR_DChrgG_IN_DChrgAbNormalEnd ((uint8_T)2U)
#define BCMR_DChrgG_IN_TimeOutDChrgStop ((uint8_T)4U)
#define BCMR_DChrgGbF_IN_DChrgNormalEnd ((uint8_T)3U)
#define BCMR_DChrgGbF_IN_DChrgRelayOpen ((uint8_T)4U)
#define BCMR_DChrgGbF_IN_NonTimeOutOpen ((uint8_T)2U)
#define BCMR_DChrgGbF_IN_TimeOutHandOvr ((uint8_T)5U)
#define BCMR_DChrgGbFl_IN_ReCnntTimeOut ((uint8_T)2U)
#define BCMR_DChrgGbFl_IN_TimeOutOpen_j ((uint8_T)4U)
#define BCMR_DChrgGbFlo_IN_DChrgHandOvr ((uint8_T)2U)
#define BCMR_DChrgGbFlo_IN_OtherTimeOut ((uint8_T)2U)
#define BCMR_DChrgGbFlow_IN_ComTimeOut ((uint8_T)1U)
#define BCMR_DChrgGbFlow_IN_DChrgEnd   ((uint8_T)1U)
#define BCMR_DChrgGbFlow_IN_DChrgFul   ((uint8_T)1U)
#define BCMR_DChrgGbFlow_IN_DChrgStop  ((uint8_T)4U)
#define BCMR_DChrgGbFlow_IN_DChrging   ((uint8_T)5U)
#define BCMR_DChrgGbFlow_IN_DcChrgCnnt ((uint8_T)5U)
#define BCMR_DChrgGbFlow_IN_DcChrgLvOn ((uint8_T)6U)
#define BCMR_DChrgGbFlow_IN_DcChrgRelay ((uint8_T)1U)
#define BCMR_DChrgGbFlow_IN_Init       ((uint8_T)1U)
#define BCMR_DChrgGbFlow_IN_Init_a     ((uint8_T)2U)
#define BCMR_DChrgGbFlow_IN_MainRelay  ((uint8_T)2U)
#define BCMR_DChrgGbFlow_IN_MsgMutual  ((uint8_T)7U)
#define BCMR_DChrgGbFlow_IN_RelayOpen  ((uint8_T)8U)
#define BCMR_DChrgGbFlow_IN_RxCCS      ((uint8_T)2U)
#define BCMR_DChrgGbFlow_IN_RxCHM      ((uint8_T)2U)
#define BCMR_DChrgGbFlow_IN_RxCRM00    ((uint8_T)3U)
#define BCMR_DChrgGbFlow_IN_RxCRMAA    ((uint8_T)4U)
#define BCMR_DChrgGbFlow_IN_RxCRO00    ((uint8_T)3U)
#define BCMR_DChrgGbFlow_IN_RxCROAA    ((uint8_T)4U)
#define BCMR_DChrgGbFlow_IN_RxCSD      ((uint8_T)3U)
#define BCMR_DChrgGbFlow_IN_RxCST      ((uint8_T)3U)
#define BCMR_DChrgGbFlow_IN_SPN3907    ((uint8_T)3U)
#define BCMR_DChrgGbFlow_IN_SysInit    ((uint8_T)9U)
#define BCMR_DChrgGbFlow_IN_SysSleep   ((uint8_T)10U)
#define BCMR_DChrgGbFlow_IN_TimeOutOpen ((uint8_T)3U)
#define BCMR_DChrgGbFlow_IN_TxBCL_BCS  ((uint8_T)4U)
#define BCMR_DChrgGbFlow_IN_TxBCP      ((uint8_T)6U)
#define BCMR_DChrgGbFlow_IN_TxBRO00    ((uint8_T)7U)
#define BCMR_DChrgGbFlow_IN_TxBROAA    ((uint8_T)8U)
#define BCMR_DChrgGbFlow_IN_TxBSD      ((uint8_T)3U)
#define BCMR_DChrgGbFlow_IN_TxBST      ((uint8_T)5U)
#define BCMR_DChrgGbFlow_IN_WaitCRM    ((uint8_T)2U)
#define BCMR_DChrgGbFlow_IN_WaitCurr   ((uint8_T)4U)
#define BCMR_DChrgGbFlow_IN_WaitCurr_a ((uint8_T)3U)
#define BCMR_DChrgGb_IN_DChrgParaConfig ((uint8_T)3U)
#define BCMR_DChrgGb_IN_TimeOutDChrgEnd ((uint8_T)3U)
#define BCMR_DChrgGb_IN_TimeOutDChrging ((uint8_T)3U)
#define BCMR_DChrg_IN_DChrgRelayControl ((uint8_T)1U)
#define BCMR_DChrg_IN_TimeOutParaConfig ((uint8_T)5U)

/* Exported block signals */
real32_T BCMR_cntDcAftTxBst;           /* '<S3>/DcChrgStateFlow' */
real32_T BCMR_cntDcAftRxCst;           /* '<S3>/DcChrgStateFlow' */
real32_T BCMR_cntDcAftTxBem;           /* '<S3>/DcChrgStateFlow' */
uint8_T BCMR_cntTimeOutCnt;            /* '<S3>/DcChrgStateFlow' */
boolean_T BCMR_bDChrgFulRaw;           /* '<S3>/Logical Operator' */

/* Exported data definition */
#define ASW1_OEM_START_SEC_DEFAULT_RAM1_CLEARED_UNSPECIFIED
#include "Asw1_OEM_MemMap.h"

/* Definition for custom storage class: OutputSignal */
volatile boolean_T BCMR_bDChrgAbrtWait;
volatile boolean_T BCMR_bDChrgFul;
volatile boolean_T BCMR_bDChrgIsoStopCmd;
volatile boolean_T BCMR_bDChrgPwrDwnReq;
volatile boolean_T BCMR_bDChrgPwrUpReq;
volatile boolean_T BCMR_bDChrgRdy;
volatile boolean_T BCMR_flgDChrgStopBActive;
volatile boolean_T BCMR_flgDChrgStopCActive;
volatile boolean_T BCMR_flgDChrgVer2015;
volatile boolean_T BCMR_flgReConnectFail;
volatile boolean_T BCMR_flgTxBCL;
volatile boolean_T BCMR_flgTxBCP;
volatile boolean_T BCMR_flgTxBCS;
volatile boolean_T BCMR_flgTxBEM;
volatile boolean_T BCMR_flgTxBHM;
volatile boolean_T BCMR_flgTxBRM;
volatile boolean_T BCMR_flgTxBRO;
volatile boolean_T BCMR_flgTxBSD;
volatile boolean_T BCMR_flgTxBSM;
volatile boolean_T BCMR_flgTxBST;
volatile uint8_T BCMR_stBmsRdyBro;
volatile uint8_T BCMR_stDChrgDebugOut;
volatile uint8_T BCMR_stDChrgElockReq;
volatile uint8_T BCMR_stDChrgGbFlowTimeout;
volatile uint8_T BCMR_stDChrgMode;
volatile uint8_T BCMR_stOtherErrBem;
volatile uint8_T BCMR_stSpn3901TimeoutBem;
volatile uint8_T BCMR_stSpn3902TimeoutBem;
volatile uint8_T BCMR_stSpn3903TimeoutBem;
volatile uint8_T BCMR_stSpn3904TimeoutBem;
volatile uint8_T BCMR_stSpn3905TimeoutBem;
volatile uint8_T BCMR_stSpn3906TimeoutBem;
volatile uint8_T BCMR_stSpn3907TimeoutBem;
volatile boolean_T COMR_flgRxCCS;
volatile boolean_T COMR_flgRxCEM;
volatile boolean_T COMR_flgRxCHM;
volatile boolean_T COMR_flgRxCML;
volatile boolean_T COMR_flgRxCRM;
volatile boolean_T COMR_flgRxCRO;
volatile boolean_T COMR_flgRxCSD;
volatile boolean_T COMR_flgRxCST;
volatile boolean_T COMR_flgRxCTS;
volatile boolean_T LcBCMR_ElockReq_flg;

#define ASW1_OEM_STOP_SEC_DEFAULT_RAM1_CLEARED_UNSPECIFIED
#include "Asw1_OEM_MemMap.h"

/* Block signals (auto storage) */
B_BCMR_DChrgGbFlow_T BCMR_DChrgGbFlow_B;

/* Block states (auto storage) */
DW_BCMR_DChrgGbFlow_T BCMR_DChrgGbFlow_DW;

/* Forward declaration for local functions */
static void BCMR_DChrg_enter_atomic_SysInit(void);
static void BCMR_DChr_enter_atomic_SysSleep(void);
static void BCM_enter_internal_DChrgHandOvr(void);
static void BCM_enter_atomic_DChrgNormalEnd(void);
static void B_enter_atomic_DChrgAbNormalEnd(void);
static void BCMR_DC_enter_atomic_DcChrgLvOn(void);
static void BCMR_DC_enter_atomic_ComTimeOut(void);
static void BCMR_DChrgGbFlow_DChrgHandOvr(void);
static void BCMR_DChrgGbFlo_DChrgParaConfig(void);
static void BCMR_DChrgGbFlow_DChrgStop(void);
static void BCMR_DChrgGbFlow_MsgMutual(void);
static void BCMR_DChrgGbFlow_RelayOpen(void);

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCMR_DChrg_enter_atomic_SysInit(void)
{
  BCMR_stDChrgDebugOut = 0U;
  BCMR_stDChrgMode = 0U;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e = false;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j = false;
  BCMR_stSpn3901TimeoutBem = 0U;
  BCMR_stSpn3902TimeoutBem = 0U;
  BCMR_stSpn3903TimeoutBem = 0U;
  BCMR_stSpn3904TimeoutBem = 0U;
  BCMR_stSpn3905TimeoutBem = 0U;
  BCMR_stSpn3906TimeoutBem = 0U;
  BCMR_stSpn3907TimeoutBem = 0U;
  BCMR_stOtherErrBem = 0U;
  BCMR_DChrgGbFlow_B.BCMR_stDChrgElockReq_p = 0U;
  COMR_flgRxCEM = false;
  COMR_flgRxCHM = false;
  COMR_flgRxCRM = false;
  COMR_flgRxCCS = false;
  COMR_flgRxCRO = false;
  COMR_flgRxCST = false;
  COMR_flgRxCML = false;
  COMR_flgRxCSD = false;
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCMR_DChr_enter_atomic_SysSleep(void)
{
  BCMR_flgTxBEM = false;
  BCMR_stDChrgDebugOut = 127U;
  BCMR_flgTxBSD = false;
  BCMR_flgTxBHM = false;
  BCMR_flgTxBCP = false;
  BCMR_flgTxBRO = false;
  BCMR_flgTxBRM = false;
  BCMR_flgTxBCL = false;
  BCMR_flgTxBCS = false;
  BCMR_flgTxBSM = false;
  BCMR_flgTxBST = false;
  BCMR_bDChrgRdy = false;
  COMR_flgRxCEM = false;
  COMR_flgRxCHM = false;
  COMR_flgRxCRM = false;
  COMR_flgRxCCS = false;
  COMR_flgRxCRO = false;
  COMR_flgRxCST = false;
  COMR_flgRxCML = false;
  COMR_flgRxCSD = false;
  BCMR_bDChrgPwrUpReq = false;
  BCMR_bDChrgPwrDwnReq = false;
  BCMR_bDChrgAbrtWait = false;
  BCMR_cntDcAftTxBst = 0.0F;
  BCMR_cntDcAftRxCst = 0.0F;
  BCMR_cntTimeOutCnt = 0U;
  BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 0U;
  BCMR_DChrgGbFlow_DW.Local_cntSysStartCnt = 0U;
  BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = 0U;
  BCMR_cntDcAftTxBem = 0.0F;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e = false;
  BCMR_flgDChrgVer2015 = false;
  BCMR_flgDChrgStopBActive = false;
  BCMR_flgDChrgStopCActive = false;
  BCMR_stDChrgGbFlowTimeout = 0U;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j = false;
  BCMR_stDChrgMode = 0U;
  BCMR_DChrgGbFlow_B.BCMR_stDChrgElockReq_p = 0U;
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCM_enter_internal_DChrgHandOvr(void)
{
  BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbFlow_IN_Init;
  BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
  BCMR_stDChrgDebugOut = 3U;
  BCMR_flgTxBRM = false;
  BCMR_flgDChrgVer2015 = false;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e = true;
  BCMR_flgDChrgStopBActive = false;
  BCMR_flgDChrgStopCActive = false;
  BCMR_stSpn3901TimeoutBem = 0U;
  BCMR_stSpn3902TimeoutBem = 0U;
  BCMR_stSpn3903TimeoutBem = 0U;
  BCMR_stSpn3904TimeoutBem = 0U;
  BCMR_stSpn3905TimeoutBem = 0U;
  BCMR_stSpn3906TimeoutBem = 0U;
  BCMR_stSpn3907TimeoutBem = 0U;
  BCMR_stOtherErrBem = 0U;
  BCMR_stDChrgGbFlowTimeout = 0U;
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCM_enter_atomic_DChrgNormalEnd(void)
{
  BCMR_stDChrgMode = 4U;
  BCMR_stDChrgDebugOut = 71U;
  BCMR_flgTxBSD = true;
  BCMR_flgTxBHM = false;
  BCMR_flgTxBCP = false;
  BCMR_flgTxBRO = false;
  BCMR_flgTxBRM = false;
  BCMR_flgTxBCL = false;
  BCMR_flgTxBCS = false;
  BCMR_flgTxBSM = false;
  BCMR_flgTxBST = false;
  BCMR_bDChrgRdy = false;
  COMR_flgRxCEM = false;
  COMR_flgRxCHM = false;
  COMR_flgRxCRM = false;
  COMR_flgRxCCS = false;
  COMR_flgRxCRO = false;
  COMR_flgRxCST = false;
  COMR_flgRxCML = false;
  COMR_flgRxCSD = false;
  BCMR_bDChrgPwrUpReq = false;
  BCMR_bDChrgPwrDwnReq = false;
  BCMR_bDChrgAbrtWait = false;
  BCMR_cntDcAftTxBst = 0.0F;
  BCMR_cntDcAftRxCst = 0.0F;
  BCMR_cntTimeOutCnt = 0U;
  BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 0U;
  BCMR_DChrgGbFlow_DW.Local_cntSysStartCnt = 0U;
  BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = 0U;
  BCMR_cntDcAftTxBem = 0.0F;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e = false;
  BCMR_flgDChrgVer2015 = false;
  BCMR_stDChrgGbFlowTimeout = 0U;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j = false;
  BCMR_DChrgGbFlow_B.BCMR_stDChrgElockReq_p = 1U;
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void B_enter_atomic_DChrgAbNormalEnd(void)
{
  BCMR_stDChrgMode = 6U;
  BCMR_stDChrgDebugOut = 74U;
  BCMR_flgTxBSD = false;
  BCMR_flgTxBHM = false;
  BCMR_flgTxBCP = false;
  BCMR_flgTxBRO = false;
  BCMR_flgTxBRM = false;
  BCMR_flgTxBCL = false;
  BCMR_flgTxBCS = false;
  BCMR_flgTxBSM = false;
  BCMR_flgTxBST = false;
  BCMR_bDChrgRdy = false;
  COMR_flgRxCEM = false;
  COMR_flgRxCHM = false;
  COMR_flgRxCRM = false;
  COMR_flgRxCCS = false;
  COMR_flgRxCRO = false;
  COMR_flgRxCST = false;
  COMR_flgRxCML = false;
  COMR_flgRxCSD = false;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e = false;
  BCMR_bDChrgPwrUpReq = false;
  BCMR_bDChrgPwrDwnReq = false;
  BCMR_bDChrgAbrtWait = false;
  BCMR_cntDcAftTxBst = 0.0F;
  BCMR_cntDcAftRxCst = 0.0F;
  BCMR_cntTimeOutCnt = 0U;
  BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 0U;
  BCMR_DChrgGbFlow_DW.Local_cntSysStartCnt = 0U;
  BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = 0U;
  BCMR_cntDcAftTxBem = 0.0F;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j = false;
  BCMR_DChrgGbFlow_B.BCMR_stDChrgElockReq_p = 1U;
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCMR_DC_enter_atomic_DcChrgLvOn(void)
{
  BCMR_stDChrgDebugOut = 2U;
  BCMR_stDChrgMode = 0U;
  BCMR_DChrgGbFlow_DW.Local_cntSysStartCnt = 0U;
  BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 0U;
  BCMR_stDChrgGbFlowTimeout = 0U;
  BCMR_cntDcAftTxBem = 0.0F;
  BCMR_flgTxBEM = false;
  BCMR_flgTxBSD = false;
  BCMR_flgTxBHM = false;
  BCMR_flgTxBCP = false;
  BCMR_flgTxBRO = false;
  BCMR_flgTxBRM = false;
  BCMR_flgTxBCL = false;
  BCMR_flgTxBCS = false;
  BCMR_flgTxBSM = false;
  BCMR_flgTxBST = false;
  BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e = BCMR_bDChrgIsoStopCmdLvOn_C;
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCMR_DC_enter_atomic_ComTimeOut(void)
{
  COMR_flgRxCRM = false;
  COMR_flgRxCHM = false;
  BCMR_stDChrgMode = 6U;
  BCMR_stDChrgDebugOut = 78U;

  /* TxEnaBEM;
     BCMR_flgTxBEM = true; */
  BCMR_cntDcAftTxBem = 0.0F;
  BCMR_flgTxBSD = false;
  BCMR_flgTxBHM = false;
  BCMR_flgTxBCP = false;
  BCMR_flgTxBRO = false;
  BCMR_flgTxBRM = false;
  BCMR_flgTxBCL = false;
  BCMR_flgTxBCS = false;
  BCMR_flgTxBSM = false;
  BCMR_flgTxBST = false;
  BCMR_DChrgGbFlow_B.BCMR_stDChrgElockReq_p = 1U;
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCMR_DChrgGbFlow_DChrgHandOvr(void)
{
  int32_T tmp;
  boolean_T guard1 = false;
  if ((BCMR_stDChrgDebugOut == 7) && (!COMR_bChrgStopActive)) {
    BCMR_stDChrgMode = 2U;
    BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_DChrgParaConfig;
    BCMR_flgTxBRM = false;
    BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGbFlow_IN_Init_a;
    BCMR_stDChrgDebugOut = 10U;
    COMR_flgRxCRM = false;
    BCMR_bDChrgPwrUpReq = false;
    BCMR_stBmsRdyBro = 0U;
  } else {
    guard1 = false;
    if (BCMR_flgTxBEM && (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 1)) {
      BCMR_cntDcAftTxBem++;
      guard1 = true;
    } else if (BCMR_flgTxBEM && (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 1)) {
      BCMR_cntDcAftTxBem++;
      guard1 = true;
    } else if (BCMR_flgTxBEM && (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 1)) {
      BCMR_cntDcAftTxBem++;
      guard1 = true;
    } else if (COMR_bChrgStopActive) {
      BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlow_IN_DChrgStop;
      BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
      BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_Init_a;
      BCMR_stDChrgDebugOut = 40U;
    } else {
      switch (BCMR_DChrgGbFlow_DW.is_DChrgHandOvr) {
       case BCMR_DChrgGbFlow_IN_Init:
        if (COMR_flgRxCHM && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >=
                              (uint32_T)ceil(BCMR_tiTxBHMTimeDly_C / 0.01F -
              1.0E-10F))) {
          BCMR_flgDChrgVer2015 = true;
          BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbFlow_IN_RxCHM;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 4U;
          BCMR_flgTxBHM = true;
        } else if (COMR_flgRxCRM && BCMR_bRxCrmIdtfRstNg) {
          BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbFlow_IN_RxCRM00;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 5U;
          BCMR_flgTxBHM = false;
          BCMR_flgTxBEM = false;
          BCMR_flgTxBSD = false;
        } else if ((!COMR_flgRxCHM) && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >=
                    (uint32_T)ceil(BCMR_tiDcAftSysStatTimout_C / 0.01F - 1.0E-10F)))
        {
          BCMR_stSpn3901TimeoutBem = 1U;
          BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
          BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbF_IN_TimeOutHandOvr;
          BCMR_stDChrgDebugOut = 9U;

          /* TxEnaBEM; */
          BCMR_flgTxBEM = true;
          BCMR_cntDcAftTxBem = 0.0F;
        } else if ((BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
                    (BCMR_tiTimeOut5S_C / 0.01F - 1.0E-10F)) &&
                   BCMR_G1E0PlatformSwFlow_C) {
          BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbFlow_IN_RxCHM;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 4U;
          BCMR_flgTxBHM = true;
        } else if (COMR_flgRxCHM && (BSPR_uDChrgVoltRaw < BCMR_uIsoCheck_C)) {
          BCMR_flgDChrgVer2015 = true;
          BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbFlow_IN_RxCHM;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 4U;
          BCMR_flgTxBHM = true;
        } else {
          tmp = BCMR_DChrgGbFlow_DW.Local_cntSysStartCnt + 1;
          if (tmp > 65535) {
            tmp = 65535;
          }

          BCMR_DChrgGbFlow_DW.Local_cntSysStartCnt = (uint16_T)tmp;
        }
        break;

       case BCMR_DChrgGbFlow_IN_RxCHM:
        if (COMR_flgRxCRM && BCMR_bRxCrmIdtfRstNg) {
          COMR_flgRxCHM = false;
          BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbFlow_IN_RxCRM00;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 5U;
          BCMR_flgTxBHM = false;
          BCMR_flgTxBEM = false;
          BCMR_flgTxBSD = false;
        } else if ((((!COMR_flgRxCRM) || (!BCMR_bRxCrmIdtfRstNg)) &&
                    COMR_flgRxCHM && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >=
                     (uint32_T)ceil(BCMR_tiDcAftRxChmTimout_C / 0.01F - 1.0E-10F)))
                   || ((!COMR_flgRxCRM) && (!COMR_flgRxCHM) &&
                       (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
                        ((BCMR_tiDcAftSysStatTimout_C - BCMR_tiTimeOut5S_C) /
                         0.01F - 1.0E-10F)))) {
          BCMR_stSpn3901TimeoutBem = 1U;
          BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
          COMR_flgRxCHM = false;
          BCMR_stDChrgGbFlowTimeout = 1U;
          BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbF_IN_TimeOutHandOvr;
          BCMR_stDChrgDebugOut = 9U;

          /* TxEnaBEM; */
          BCMR_flgTxBEM = true;
          BCMR_cntDcAftTxBem = 0.0F;
        } else {
          tmp = BCMR_DChrgGbFlow_DW.Local_cntSysStartCnt + 1;
          if (tmp > 65535) {
            tmp = 65535;
          }

          BCMR_DChrgGbFlow_DW.Local_cntSysStartCnt = (uint16_T)tmp;
        }
        break;

       case BCMR_DChrgGbFlow_IN_RxCRM00:
        if (COMR_flgRxCRM && (!BCMR_bRxCrmIdtfRstOk) &&
            (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
             (BCMR_tiDcAftTxBrmTimout_C / 0.01F - 1.0E-10F))) {
          BCMR_stSpn3902TimeoutBem = 1U;
          BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
          BCMR_stDChrgGbFlowTimeout = 2U;
          COMR_flgRxCRM = false;
          BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbF_IN_TimeOutHandOvr;
          BCMR_stDChrgDebugOut = 9U;

          /* TxEnaBEM; */
          BCMR_flgTxBEM = true;
          BCMR_cntDcAftTxBem = 0.0F;
        } else if ((COMR_flgRxCRM && BCMR_bRxCrmIdtfRstOk && BCMR_flgTxBRM) ||
                   (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
                    (BCMR_tiCRMRxNgToOk_C / 0.01F - 1.0E-10F))) {
          COMR_flgRxCRM = false;
          BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGbFlow_IN_RxCRMAA;
          BCMR_stDChrgDebugOut = 7U;
          BCMR_flgTxBRM = false;
        } else {
          BCMR_stDChrgDebugOut = 6U;

          /* TxEnaBRM; */
          BCMR_flgTxBRM = true;
        }
        break;

       case BCMR_DChrgGbFlow_IN_RxCRMAA:
        break;

       default:
        BCMR_cntDcAftTxBem++;
        break;
      }
    }

    if (guard1) {
      BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
        BCMR_DChrgGbFlow_IN_ComTimeOut;
      BCMR_DC_enter_atomic_ComTimeOut();
    }
  }
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCMR_DChrgGbFlo_DChrgParaConfig(void)
{
  int32_T tmp;
  boolean_T guard1 = false;
  if (COMR_flgRxCRO && BCMR_bRxCroRdyOk && (!BCMR_flgTxBRO) &&
      (!COMR_bChrgStopActive)) {
    BCMR_stDChrgMode = 3U;
    BCMR_DChrgGbFlow_DW.is_DChrgRelayControl = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlow_IN_DChrging;
    BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
    COMR_flgRxCRO = false;
    BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGbFlow_IN_Init;
    BCMR_stDChrgDebugOut = 25U;
    BCMR_flgTxBCL = false;
  } else {
    guard1 = false;
    if (BCMR_flgTxBEM && (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 1)) {
      BCMR_cntDcAftTxBem++;
      guard1 = true;
    } else if (BCMR_flgTxBEM && (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 1)) {
      BCMR_cntDcAftTxBem++;
      guard1 = true;
    } else if (COMR_bChrgStopActive) {
      BCMR_DChrgGbFlow_DW.is_DChrgRelayControl = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlow_IN_DChrgStop;
      BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
      BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_Init_a;
      BCMR_stDChrgDebugOut = 40U;
    } else {
      switch (BCMR_DChrgGbFlow_DW.is_DChrgParaConfig) {
       case BCMR_DChrg_IN_DChrgRelayControl:
        if ((BCCR_stBmsCtrMode == 4) && (BCCR_stBmsDChrgCtrMode == 3)) {
          BCMR_DChrgGbFlow_DW.is_DChrgRelayControl =
            BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGbFlow_IN_TxBROAA;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;

          /* TxEnaBRO */
          BCMR_stDChrgDebugOut = 18U;
          BCMR_flgTxBRO = true;
          COMR_flgRxCML = false;
          BCMR_stBmsRdyBro = 170U;
          tmp = BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt + 1;
          if (tmp > 65535) {
            tmp = 65535;
          }

          BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = (uint16_T)tmp;
          BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e =
            BCMR_bDChrgIsoStopCmdBRO_C;
        } else if (((BCCR_stBmsCtrMode != 4) || (BCCR_stBmsDChrgCtrMode != 3)) &&
                   (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= 1000U)) {
          BCMR_stOtherErrBem = 1U;
          BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
          BCMR_stDChrgGbFlowTimeout = 4U;
          BCMR_DChrgGbFlow_DW.is_DChrgRelayControl =
            BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig =
            BCMR_DChrg_IN_TimeOutParaConfig;
          BCMR_stDChrgDebugOut = 24U;

          /* TxEnaBEM; */
          BCMR_flgTxBEM = true;
          BCMR_cntDcAftTxBem = 0.0F;
        } else if (BCMR_DChrgGbFlow_DW.is_DChrgRelayControl ==
                   BCMR_DChrgGbFlow_IN_DcChrgRelay) {
          /* TxEnaBRO; */
          BCMR_stDChrgDebugOut = 17U;
          BCMR_bDChrgRdy = true;
          tmp = BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt + 1;
          if (tmp > 65535) {
            tmp = 65535;
          }

          BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = (uint16_T)tmp;
        } else if (BCCR_stBmsCtrMode == 4) {
          BCMR_DChrgGbFlow_DW.is_DChrgRelayControl =
            BCMR_DChrgGbFlow_IN_DcChrgRelay;

          /* TxEnaBRO; */
          BCMR_stDChrgDebugOut = 16U;
          BCMR_bDChrgRdy = true;
          tmp = BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt + 1;
          if (tmp > 65535) {
            tmp = 65535;
          }

          BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = (uint16_T)tmp;
        } else {
          BCMR_stDChrgDebugOut = 15U;
          BCMR_bDChrgPwrUpReq = true;
          tmp = BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt + 1;
          if (tmp > 65535) {
            tmp = 65535;
          }

          BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = (uint16_T)tmp;
        }
        break;

       case BCMR_DChrgGbFlow_IN_Init_a:
        BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGbFlow_IN_TxBCP;
        BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
        BCMR_stDChrgDebugOut = 11U;

        /* TxEnaBCP; */
        COMR_flgRxCRM = false;
        BCMR_flgTxBCP = true;
        break;

       case BCMR_DChrgGbFlow_IN_RxCRO00:
        if (COMR_flgRxCRO && BCMR_bRxCroRdyOk) {
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGbFlow_IN_RxCROAA;
          BCMR_stDChrgDebugOut = 22U;

          /* TxEnaBRO; */
          BCMR_flgTxBRO = false;
        } else if ((!BCMR_bRxCroRdyOk) &&
                   (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
                    (BCMR_tiDcAftTxBroUtlRxCroOkTimout_C / 0.01F - 1.0E-10F))) {
          BCMR_stSpn3904TimeoutBem = 1U;
          BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
          BCMR_stDChrgGbFlowTimeout = 6U;
          COMR_flgRxCRO = false;
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig =
            BCMR_DChrg_IN_TimeOutParaConfig;
          BCMR_stDChrgDebugOut = 24U;

          /* TxEnaBEM; */
          BCMR_flgTxBEM = true;
          BCMR_cntDcAftTxBem = 0.0F;
        } else {
          /* TxEnaBRO; */
          BCMR_stDChrgDebugOut = 21U;
          BCMR_flgTxBRO = true;
          BCMR_stBmsRdyBro = 170U;
        }
        break;

       case BCMR_DChrgGbFlow_IN_RxCROAA:
        /* TxEnaBRO; */
        BCMR_stDChrgDebugOut = 23U;
        BCMR_flgTxBRO = false;
        break;

       case BCMR_DChrg_IN_TimeOutParaConfig:
        BCMR_cntDcAftTxBem++;
        break;

       case BCMR_DChrgGbFlow_IN_TxBCP:
        if (COMR_flgRxCML) {
          COMR_flgRxCML = false;
          COMR_flgRxCTS = false;
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGbFlow_IN_TxBRO00;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 12U;
          BCMR_flgTxBCP = false;
          BCMR_flgTxBRO = true;
          BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = 0U;
          BCMR_DChrgGbFlow_B.BCMR_stDChrgElockReq_p = 2U;
        } else {
          if ((!COMR_flgRxCML) && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >=
               (uint32_T)ceil(BCMR_tiDcAftTxBcpTimout_C / 0.01F - 1.0E-10F))) {
            BCMR_stSpn3903TimeoutBem = 1U;
            BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
            BCMR_stDChrgGbFlowTimeout = 3U;
            BCMR_DChrgGbFlow_DW.is_DChrgParaConfig =
              BCMR_DChrg_IN_TimeOutParaConfig;
            BCMR_stDChrgDebugOut = 24U;

            /* TxEnaBEM; */
            BCMR_flgTxBEM = true;
            BCMR_cntDcAftTxBem = 0.0F;
          }
        }
        break;

       case BCMR_DChrgGbFlow_IN_TxBRO00:
        if (BCMR_bStakeParaOk && (!BCMR_bDChrgFobd)) {
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig =
            BCMR_DChrg_IN_DChrgRelayControl;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_DChrgGbFlow_DW.is_DChrgRelayControl =
            BCMR_DChrgGbFlow_IN_MainRelay;
          BCMR_stDChrgDebugOut = 14U;
          BCMR_bDChrgPwrUpReq = true;
          tmp = BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt + 1;
          if (tmp > 65535) {
            tmp = 65535;
          }

          BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = (uint16_T)tmp;
        } else if (((!BCMR_bStakeParaOk) || BCMR_bDChrgFobd) &&
                   (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
                    (BCMR_tiDChrgParaOkDelay_C / 0.01F - 1.0E-10F))) {
          BCMR_stDChrgGbFlowTimeout = 7U;
          BCMR_stDChrgMode = 6U;
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig =
            BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlow_IN_DChrgStop;
          BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
          BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_Init_a;
          BCMR_stDChrgDebugOut = 40U;
        } else {
          BCMR_stDChrgDebugOut = 13U;

          /* TxEnaBRO; */
          BCMR_flgTxBRO = true;
          BCMR_stBmsRdyBro = 0U;
          tmp = BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt + 1;
          if (tmp > 65535) {
            tmp = 65535;
          }

          BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = (uint16_T)tmp;
        }
        break;

       default:
        if ((!COMR_flgRxCRO) && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >=
             (uint32_T)ceil(BCMR_tiDcAftTxBroUtlRxCroTimout_C / 0.01F - 1.0E-10F)))
        {
          BCMR_stSpn3904TimeoutBem = 1U;
          BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
          BCMR_stDChrgGbFlowTimeout = 5U;

          /* ||...Local_cntBroTxCnt > BCMR_tiAftBroTxTimout_C */
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig =
            BCMR_DChrg_IN_TimeOutParaConfig;
          BCMR_stDChrgDebugOut = 24U;

          /* TxEnaBEM; */
          BCMR_flgTxBEM = true;
          BCMR_cntDcAftTxBem = 0.0F;
        } else if (COMR_flgRxCRO && BCMR_bRxCroRdyNg) {
          COMR_flgRxCRO = false;
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGbFlow_IN_RxCRO00;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;

          /* TxEnaBRO; */
          BCMR_flgTxBRO = true;
          BCMR_stBmsRdyBro = 170U;
        } else if (COMR_flgRxCRO && BCMR_bRxCroRdyOk &&
                   (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
                    (BCMR_tiTxBROAAToRxCROAA_C / 0.01F - 1.0E-10F))) {
          BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGbFlow_IN_RxCROAA;
          BCMR_stDChrgDebugOut = 22U;

          /* TxEnaBRO; */
          BCMR_flgTxBRO = false;
        } else {
          /* TxEnaBRO */
          BCMR_stDChrgDebugOut = 19U;
          BCMR_flgTxBRO = true;
          BCMR_stBmsRdyBro = 170U;
          tmp = BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt + 1;
          if (tmp > 65535) {
            tmp = 65535;
          }

          BCMR_DChrgGbFlow_DW.Local_cntBroTxCnt = (uint16_T)tmp;
        }
        break;
      }
    }

    if (guard1) {
      BCMR_DChrgGbFlow_DW.is_DChrgRelayControl = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
        BCMR_DChrgGbFlow_IN_ComTimeOut;
      BCMR_DC_enter_atomic_ComTimeOut();
    }
  }
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCMR_DChrgGbFlow_DChrgStop(void)
{
  boolean_T guard1 = false;
  boolean_T guard2 = false;
  if (COMR_flgRxCST && BCMR_flgDChrgStopCActive && BCMR_flgTxBST &&
      (BCMR_DChrgGbFlow_DW.temporalCounter_i2 >= 10U)) {
    BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlow_IN_DChrgEnd;
    BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
    BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGbFlow_IN_Init;
    BCMR_stDChrgDebugOut = 51U;
    BCMR_cntDcAftTxBst++;
  } else {
    guard1 = false;
    guard2 = false;
    if (BCMR_flgTxBEM && (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 2)) {
      BCMR_cntDcAftTxBem++;
      if (((BCCR_stBmsDChrgCtrMode == 6) || (BCCR_stBmsDChrgCtrMode == 0)) &&
          ((BCCR_stBmsCtrMode == 7) || (BCCR_stBmsCtrMode == 14) ||
           (BCCR_stBmsCtrMode == 0))) {
        if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 2) {
          BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
            BCMR_DChrgG_IN_DChrgAbNormalEnd;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          B_enter_atomic_DChrgAbNormalEnd();
        } else if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv <= 1) {
          BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
            BCMR_DChrgGbF_IN_DChrgNormalEnd;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCM_enter_atomic_DChrgNormalEnd();
        } else {
          guard2 = true;
        }
      } else {
        guard2 = true;
      }
    } else {
      guard1 = true;
    }

    if (guard2) {
      if (((BCCR_stBmsCtrMode == 4) || (BCCR_stBmsDChrgCtrMode == 3)) &&
          (BCMR_DChrgGbFlow_DW.temporalCounter_i2 >= 500U)) {
        BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_RelayOpen;
        BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
        BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGbFlow_IN_Init;
        BCMR_stDChrgMode = 4U;
        BCMR_cntDcAftTxBst++;
        BCMR_cntDcAftRxCst++;
      } else {
        guard1 = true;
      }
    }

    if (guard1) {
      if (BCMR_flgTxBST && COMR_flgRxCST && BCMR_flgDChrgStopBActive &&
          (BCMR_DChrgGbFlow_DW.temporalCounter_i2 >= 10U)) {
        BCMR_flgTxBST = false;
        BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlow_IN_DChrgEnd;
        BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
        BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGbFlow_IN_Init;
        BCMR_stDChrgDebugOut = 51U;
        BCMR_cntDcAftTxBst++;
      } else {
        switch (BCMR_DChrgGbFlow_DW.is_DChrgStop) {
         case BCMR_DChrgGbFlow_IN_DChrgFul:
          if ((BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j || (BSER_rSocDspl >= 100.0F))
              && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
                  (BCMR_tiDChrgFulBCSToBST_C / 0.01F - 1.0E-10F))) {
            BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_TxBST;
            BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
            BCMR_stDChrgDebugOut = 42U;
            BCMR_flgTxBCL = false;
            BCMR_flgTxBCS = false;
            BCMR_flgTxBSM = false;
            BCMR_flgTxBST = true;
            BCMR_cntDcAftTxBst = 0.0F;
          } else {
            BCMR_cntDcAftTxBst++;
            BCMR_cntDcAftRxCst++;
            BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j = true;
          }
          break;

         case BCMR_DChrgGbFlow_IN_Init_a:
          if (COMR_flgRxCST) {
            BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_RxCST;
            BCMR_stDChrgDebugOut = 41U;
            BCMR_cntDcAftRxCst = 0.0F;
            BCMR_flgDChrgStopCActive = true;
          } else {
            if (BCMR_bDChrgStopEna || BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j ||
                BCMR_bDChrgFobd) {
              BCMR_flgDChrgStopBActive = true;
              if (BCMR_flgDChrgFulChk || BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j) {
                BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_DChrgFul;
                BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
                BCMR_stDChrgDebugOut = 100U;
                BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j = true;
                BCMR_cntDcAftTxBst++;
                BCMR_cntDcAftRxCst++;
              } else {
                if ((!BCMR_flgDChrgFulChk) &&
                    (!BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j)) {
                  BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_TxBST;
                  BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
                  BCMR_stDChrgDebugOut = 42U;
                  BCMR_flgTxBCL = false;
                  BCMR_flgTxBCS = false;
                  BCMR_flgTxBSM = false;
                  BCMR_flgTxBST = true;
                  BCMR_cntDcAftTxBst = 0.0F;
                }
              }
            }
          }
          break;

         case BCMR_DChrgGbFlow_IN_RxCST:
          BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_TxBST;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 42U;
          BCMR_flgTxBCL = false;
          BCMR_flgTxBCS = false;
          BCMR_flgTxBSM = false;
          BCMR_flgTxBST = true;
          BCMR_cntDcAftTxBst = 0.0F;
          break;

         case BCMR_DChrgG_IN_TimeOutDChrgStop:
          BCMR_cntDcAftTxBem++;
          break;

         default:
          if ((!COMR_flgRxCST) && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >=
               (uint32_T)ceil(BCMR_tiDcAftTxBstUtlRxCstTimout_C / 0.01F - 1.0E-10F)))
          {
            BCMR_stSpn3906TimeoutBem = 1U;
            BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 2U;
            BCMR_stDChrgGbFlowTimeout = 9U;
            BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgG_IN_TimeOutDChrgStop;
            BCMR_stDChrgDebugOut = 44U;

            /* TxEnaBEM; */
            BCMR_flgTxBEM = true;
            BCMR_cntDcAftTxBem = 0.0F;
          } else {
            BCMR_stDChrgDebugOut = 43U;

            /* TxEnaBST; */
            BCMR_cntDcAftTxBst++;
            BCMR_cntDcAftRxCst++;
            BCMR_flgTxBST = true;
          }
          break;
        }
      }
    }
  }
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCMR_DChrgGbFlow_MsgMutual(void)
{
  boolean_T guard1 = false;
  boolean_T guard2 = false;
  if (COMR_flgRxCEM) {
    BCMR_stOtherErrBem = 1U;
    BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
    BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrgRelayControl = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow = BCMR_DChrgGbFlow_IN_ComTimeOut;
    BCMR_DC_enter_atomic_ComTimeOut();
  } else if ((!BCMR_bDChrgWkup) && (!BCMR_bDChrgCnnt)) {
    BCMR_flgTxBEM = true;
    BCMR_stOtherErrBem = 1U;
    BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
    BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrgHandOvr = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrgRelayControl = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrgParaConfig = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
    BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow = BCMR_DChrgGbFlow_IN_ComTimeOut;
    BCMR_DC_enter_atomic_ComTimeOut();
  } else {
    guard1 = false;
    guard2 = false;
    switch (BCMR_DChrgGbFlow_DW.is_MsgMutual) {
     case BCMR_DChrgGbFlow_IN_DChrgEnd:
      if ((BSPR_iBattCurr > -5.0F) && BCMR_flgTxBSD) {
        COMR_flgRxCST = false;
        BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_RelayOpen;
        BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
        BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGbFlow_IN_Init;
        BCMR_stDChrgMode = 4U;
        BCMR_cntDcAftTxBst++;
        BCMR_cntDcAftRxCst++;
      } else if (BCMR_flgTxBEM && (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 2)) {
        BCMR_cntDcAftTxBem++;
        if (((BCCR_stBmsDChrgCtrMode == 6) || (BCCR_stBmsDChrgCtrMode == 0)) &&
            ((BCCR_stBmsCtrMode == 7) || (BCCR_stBmsCtrMode == 14) ||
             (BCCR_stBmsCtrMode == 0))) {
          if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 2) {
            BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
            BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
            BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
              BCMR_DChrgG_IN_DChrgAbNormalEnd;
            BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
            B_enter_atomic_DChrgAbNormalEnd();
          } else if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv <= 1) {
            BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
            BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
            BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
              BCMR_DChrgGbF_IN_DChrgNormalEnd;
            BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
            BCM_enter_atomic_DChrgNormalEnd();
          } else {
            guard2 = true;
          }
        } else {
          guard2 = true;
        }
      } else {
        guard1 = true;
      }
      break;

     case BCMR_DChrgGbFlo_IN_DChrgHandOvr:
      BCMR_DChrgGbFlow_DChrgHandOvr();
      break;

     case BCMR_DChrgGb_IN_DChrgParaConfig:
      BCMR_DChrgGbFlo_DChrgParaConfig();
      break;

     case BCMR_DChrgGbFlow_IN_DChrgStop:
      BCMR_DChrgGbFlow_DChrgStop();
      break;

     default:
      if (BCMR_bDChrgStopEna || COMR_flgRxCST || COMR_bChrgStopActive) {
        BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlow_IN_DChrgStop;
        BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
        BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_Init_a;
        BCMR_stDChrgDebugOut = 40U;
      } else if (BCMR_flgTxBEM && (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 1)) {
        BCMR_cntDcAftTxBem++;
        BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_ComTimeOut;
        BCMR_DC_enter_atomic_ComTimeOut();
      } else if (COMR_bChrgStopActive) {
        BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlow_IN_DChrgStop;
        BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
        BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_Init_a;
        BCMR_stDChrgDebugOut = 40U;
      } else if (BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j && ((BSER_rSocDspl >=
                   100.0F) || (BCMR_DChrgGbFlow_DW.temporalCounter_i2 >=
                   (uint32_T)ceil(BCMR_tiDChrgFulBCSToBST_C / 0.01F - 1.0E-10F))))
      {
        BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlow_IN_DChrgStop;
        BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
        BCMR_DChrgGbFlow_DW.is_DChrgStop = BCMR_DChrgGbFlow_IN_Init_a;
        BCMR_stDChrgDebugOut = 40U;
      } else {
        switch (BCMR_DChrgGbFlow_DW.is_DChrging) {
         case BCMR_DChrgGbFlow_IN_Init:
          BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGbFlow_IN_TxBCL_BCS;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 30U;

          /* TxEnaBCS;
             TxEnaBCL; */
          BCMR_flgTxBCL = true;
          BCMR_flgTxBCS = true;
          COMR_flgRxCRO = false;
          break;

         case BCMR_DChrgGbFlow_IN_RxCCS:
          if (!BCMR_bDChrgStopEna) {
            COMR_flgRxCCS = false;
            BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGbFlow_IN_TxBCL_BCS;
            BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
            BCMR_stDChrgDebugOut = 30U;

            /* TxEnaBCS;
               TxEnaBCL; */
            BCMR_flgTxBCL = true;
            BCMR_flgTxBCS = true;
            COMR_flgRxCRO = false;
          } else {
            BCMR_stDChrgDebugOut = 33U;

            /* TxEnaBSM */
            BCMR_flgTxBSM = true;
          }
          break;

         case BCMR_DChrgGb_IN_TimeOutDChrging:
          BCMR_cntDcAftTxBem++;
          break;

         default:
          if (COMR_flgRxCCS) {
            BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGbFlow_IN_RxCCS;
            BCMR_stDChrgDebugOut = 32U;

            /* TxEnaBSM */
            BCMR_flgTxBSM = true;
          } else if ((!COMR_flgRxCCS) && (BCMR_DChrgGbFlow_DW.temporalCounter_i1
                      >= (uint32_T)ceil(BCMR_tiDcAftRxCcsTimout_C / 0.01F -
                       1.0E-10F))) {
            BCMR_stSpn3905TimeoutBem = 1U;
            BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 1U;
            BCMR_stDChrgGbFlowTimeout = 8U;
            BCMR_DChrgGbFlow_DW.is_DChrging = BCMR_DChrgGb_IN_TimeOutDChrging;
            BCMR_stDChrgDebugOut = 36U;

            /* TxEnaBEM; */
            BCMR_flgTxBEM = true;
            BCMR_cntDcAftTxBem = 0.0F;
          } else {
            BCMR_stDChrgDebugOut = 31U;
            BCMR_DChrgGbFlow_B.BCMR_stDChrgElockReq_p = 2U;

            /* TxEnaBCS;
               TxEnaBCL; */
            BCMR_flgTxBCL = true;
            BCMR_flgTxBCS = true;
          }
          break;
        }
      }
      break;
    }

    if (guard2) {
      if (((BCCR_stBmsCtrMode == 4) || (BCCR_stBmsDChrgCtrMode == 3)) &&
          (BCMR_DChrgGbFlow_DW.temporalCounter_i2 >= 500U)) {
        BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_RelayOpen;
        BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
        BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGbFlow_IN_Init;
        BCMR_stDChrgMode = 4U;
        BCMR_cntDcAftTxBst++;
        BCMR_cntDcAftRxCst++;
      } else {
        guard1 = true;
      }
    }

    if (guard1) {
      switch (BCMR_DChrgGbFlow_DW.is_DChrgEnd) {
       case BCMR_DChrgGbFlow_IN_Init:
        if (COMR_flgRxCST) {
          BCMR_stDChrgMode = 4U;
          COMR_flgRxCST = false;
          BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGbFlow_IN_TxBSD;
          BCMR_stDChrgDebugOut = 52U;
          BCMR_cntDcAftTxBst++;
          BCMR_cntDcAftRxCst++;
          BCMR_flgTxBST = false;
          BCMR_flgTxBSD = true;
        }
        break;

       case BCMR_DChr_IN_TimeOutDChrgStop_g:
        BCMR_cntDcAftTxBem++;
        break;

       case BCMR_DChrgGbFlow_IN_TxBSD:
        if (BSPR_iBattCurr >= -5.0F) {
          BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChrgGbFlow_IN_WaitCurr;
          BCMR_stDChrgDebugOut = 53U;
          BCMR_cntDcAftTxBst++;
          BCMR_cntDcAftRxCst++;
        } else if ((BSPR_iBattCurr < -5.0F) && ((BCMR_bDChrgStopEna &&
                     (BCMR_cntDcAftTxBst > 100.0F)) || ((!BCMR_bDChrgStopEna) &&
          (BCMR_cntDcAftTxBst > 1000.0F)) || (BCMR_cntDcAftRxCst > 1000.0F))) {
          BCMR_stSpn3907TimeoutBem = 1U;
          BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 2U;
          BCMR_stDChrgGbFlowTimeout = 10U;
          BCMR_DChrgGbFlow_DW.is_DChrgEnd = BCMR_DChr_IN_TimeOutDChrgStop_g;
          BCMR_stDChrgDebugOut = 59U;

          /* TxEnaBEM; */
          BCMR_flgTxBEM = true;
          BCMR_cntDcAftTxBem = 0.0F;
        } else {
          BCMR_cntDcAftTxBst++;
          BCMR_cntDcAftRxCst++;
          BCMR_flgTxBSD = true;
        }
        break;

       default:
        BCMR_cntDcAftTxBst++;
        BCMR_cntDcAftRxCst++;
        break;
      }
    }
  }
}

/* Function for Chart: '<S3>/DcChrgStateFlow' */
static void BCMR_DChrgGbFlow_RelayOpen(void)
{
  boolean_T guard1 = false;
  guard1 = false;
  if ((((BCMR_cntTimeOutCnt == 0) || BCMR_flgReConnectFail ||
        (BCMR_cntTimeOutCnt >= 3) || (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 2)) &&
       ((BCCR_stBmsCtrMode == 7) || (BCCR_stBmsCtrMode == 14)) && COMR_flgRxCSD)
      || (BCMR_DChrgGbFlow_DW.temporalCounter_i2 >= (uint32_T)ceil
          (BCMR_tiDChrgSysExit_C / 0.01F - 1.0E-10F))) {
    if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 2) {
      BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_NonTimeOutOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_TimeOutDChrgEnd = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_TimeOutOpen_m = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
        BCMR_DChrgG_IN_DChrgAbNormalEnd;
      BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
      B_enter_atomic_DChrgAbNormalEnd();
    } else if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv <= 1) {
      BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_NonTimeOutOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_TimeOutDChrgEnd = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_TimeOutOpen_m = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
      BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
        BCMR_DChrgGbF_IN_DChrgNormalEnd;
      BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
      BCM_enter_atomic_DChrgNormalEnd();
    } else {
      guard1 = true;
    }
  } else {
    guard1 = true;
  }

  if (guard1) {
    switch (BCMR_DChrgGbFlow_DW.is_RelayOpen) {
     case BCMR_DChrgGbFlow_IN_Init:
      if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv == 0) {
        BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGbF_IN_NonTimeOutOpen;
        BCMR_DChrgGbFlow_DW.is_NonTimeOutOpen = BCMR_DChrgGbFlow_IN_WaitCurr;
        BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
        BCMR_stDChrgDebugOut = 60U;
      } else {
        if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv > 0) {
          BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGbFl_IN_TimeOutOpen_j;
          BCMR_DChrgGbFlow_DW.is_TimeOutOpen_m = BCMR_DChrgGbFlow_IN_WaitCurr;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 63U;
          BCMR_cntDcAftTxBem++;
        }
      }
      break;

     case BCMR_DChrgGbF_IN_NonTimeOutOpen:
      switch (BCMR_DChrgGbFlow_DW.is_NonTimeOutOpen) {
       case BCMR_DChrgGbFlow_IN_DcChrgRelay:
        if ((BCCR_stBmsDChrgCtrMode == 6) ||
            (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= 100U)) {
          BCMR_DChrgGbFlow_DW.is_NonTimeOutOpen = BCMR_DChrgGbFlow_IN_MainRelay;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 62U;
          BCMR_bDChrgPwrUpReq = false;
          BCMR_bDChrgPwrDwnReq = true;
        } else {
          BCMR_cntDcAftTxBst++;
          BCMR_cntDcAftRxCst++;
        }
        break;

       case BCMR_DChrgGbFlow_IN_MainRelay:
        if (((BCCR_stBmsCtrMode == 7) || (BCCR_stBmsCtrMode == 14)) &&
            COMR_flgRxCSD) {
          BCMR_DChrgGbFlow_DW.is_NonTimeOutOpen = BCMR_DChrgGbFlow_IN_RxCSD;
          BCMR_stDChrgDebugOut = 67U;
          BCMR_bDChrgPwrUpReq = false;
          BCMR_bDChrgPwrDwnReq = true;
          COMR_flgRxCSD = false;
        } else if ((!COMR_flgRxCSD) && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >=
                    (uint32_T)ceil(BCMR_tiDcAftTxBstUtlTxCsdTimout_C / 0.01F -
                     1.0E-10F))) {
          BCMR_stDChrgGbFlowTimeout = 11U;
          BCMR_DChrgGbFlow_DW.is_NonTimeOutOpen =
            BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGb_IN_TimeOutDChrgEnd;
          BCMR_DChrgGbFlow_DW.is_TimeOutDChrgEnd = BCMR_DChrgGbFlow_IN_Init;
          BCMR_stDChrgDebugOut = 69U;
        } else {
          BCMR_cntDcAftTxBst++;
          BCMR_cntDcAftRxCst++;
        }
        break;

       case BCMR_DChrgGbFlow_IN_RxCSD:
        break;

       default:
        if (BSPR_iBattCurr > -5.0F) {
          BCMR_DChrgGbFlow_DW.is_NonTimeOutOpen =
            BCMR_DChrgGbFlow_IN_DcChrgRelay;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 61U;
          BCMR_bDChrgRdy = false;
        } else if ((BSPR_iBattCurr <= -5.0F) &&
                   (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= 1000U)) {
          BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 2U;
          BCMR_DChrgGbFlow_DW.is_NonTimeOutOpen =
            BCMR_DChrgGbFlow_IN_DcChrgRelay;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 61U;
          BCMR_bDChrgRdy = false;
        } else {
          BCMR_cntDcAftTxBst++;
          BCMR_cntDcAftRxCst++;
        }
        break;
      }
      break;

     case BCMR_DChrgGb_IN_TimeOutDChrgEnd:
      if (BCMR_DChrgGbFlow_DW.is_TimeOutDChrgEnd == BCMR_DChrgGbFlow_IN_Init) {
        if ((BCMR_stDChrgGbFlowTimeout != 11) && (BCMR_stDChrgGbFlowTimeout !=
             12)) {
          BCMR_DChrgGbFlow_DW.is_TimeOutDChrgEnd =
            BCMR_DChrgGbFlo_IN_OtherTimeOut;
          BCMR_stSpn3907TimeoutBem = 0U;
        } else {
          if ((BCMR_stDChrgGbFlowTimeout == 11) || (BCMR_stDChrgGbFlowTimeout ==
               12)) {
            BCMR_DChrgGbFlow_DW.is_TimeOutDChrgEnd = BCMR_DChrgGbFlow_IN_SPN3907;
            BCMR_stDChrgDebugOut = 70U;
            BCMR_stSpn3907TimeoutBem = 1U;
            BCMR_flgTxBEM = true;
            BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 3U;
          }
        }
      }
      break;

     default:
      switch (BCMR_DChrgGbFlow_DW.is_TimeOutOpen_m) {
       case BCMR_DChrgGbFlow_IN_DcChrgRelay:
        if ((BCCR_stBmsDChrgCtrMode == 6) ||
            (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= 100U)) {
          BCMR_DChrgGbFlow_DW.is_TimeOutOpen_m = BCMR_DChrgGbFlow_IN_MainRelay;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 65U;
          BCMR_bDChrgPwrUpReq = false;
          BCMR_bDChrgPwrDwnReq = true;
          BCMR_cntDcAftTxBem++;
        } else {
          BCMR_cntDcAftTxBem++;
          BCMR_cntDcAftTxBst++;
          BCMR_cntDcAftRxCst++;
        }
        break;

       case BCMR_DChrgGbFlow_IN_MainRelay:
        if ((!COMR_flgRxCSD) && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >=
             (uint32_T)ceil(BCMR_tiDcAftTxBstUtlTxCsdTimout_C / 0.01F - 1.0E-10F)))
        {
          BCMR_stDChrgGbFlowTimeout = 12U;
          BCMR_DChrgGbFlow_DW.is_TimeOutOpen_m = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGb_IN_TimeOutDChrgEnd;
          BCMR_DChrgGbFlow_DW.is_TimeOutDChrgEnd = BCMR_DChrgGbFlow_IN_Init;
          BCMR_stDChrgDebugOut = 69U;
        } else if (((BCCR_stBmsCtrMode == 7) || (BCCR_stBmsCtrMode == 14)) &&
                   COMR_flgRxCSD) {
          BCMR_DChrgGbFlow_DW.is_TimeOutOpen_m = BCMR_DChrgGbFlow_IN_RxCSD;
          BCMR_stDChrgDebugOut = 68U;
          BCMR_bDChrgPwrUpReq = false;
          BCMR_bDChrgPwrDwnReq = true;
          COMR_flgRxCSD = false;
        } else {
          BCMR_cntDcAftTxBem++;
          BCMR_cntDcAftTxBst++;
          BCMR_cntDcAftRxCst++;
        }
        break;

       case BCMR_DChrgGbFlow_IN_RxCSD:
        break;

       default:
        if (BSPR_iBattCurr > -5.0F) {
          BCMR_DChrgGbFlow_DW.is_TimeOutOpen_m = BCMR_DChrgGbFlow_IN_DcChrgRelay;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 64U;
          BCMR_bDChrgRdy = false;
          BCMR_cntDcAftTxBem++;
        } else if ((BSPR_iBattCurr <= -5.0F) &&
                   (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= 1000U)) {
          BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 2U;
          BCMR_DChrgGbFlow_DW.is_TimeOutOpen_m = BCMR_DChrgGbFlow_IN_DcChrgRelay;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 64U;
          BCMR_bDChrgRdy = false;
          BCMR_cntDcAftTxBem++;
        } else {
          BCMR_cntDcAftTxBem++;
          BCMR_cntDcAftTxBst++;
          BCMR_cntDcAftRxCst++;
        }
        break;
      }
      break;
    }
  }
}

/* Model step function */
void BCMR_DChrgGbFlow_step(void)
{
  real32_T rtb_Switch1;
  boolean_T rtb_LogicalOperator_h;
  uint16_T rtb_Init;
  boolean_T rtb_RelationalOperator;
  int32_T tmp;
  uint8_T rtb_RelationalOperator_0;
  boolean_T guard1 = false;
  boolean_T guard2 = false;
  if (BCMR_DChrgGbFlow_DW.temporalCounter_i1 < MAX_uint32_T) {
    BCMR_DChrgGbFlow_DW.temporalCounter_i1++;
  }

  if (BCMR_DChrgGbFlow_DW.temporalCounter_i2 < MAX_uint32_T) {
    BCMR_DChrgGbFlow_DW.temporalCounter_i2++;
  }

  if (BCMR_DChrgGbFlow_DW.temporalCounter_i3 < MAX_uint32_T) {
    BCMR_DChrgGbFlow_DW.temporalCounter_i3++;
  }

  if (BCMR_DChrgGbFlow_DW.is_active_c1_BCMR_DChrgGbFlow == 0U) {
    BCMR_DChrgGbFlow_DW.is_active_c1_BCMR_DChrgGbFlow = 1U;
    BCMR_bDChrgAbrtWait = false;
    BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow = BCMR_DChrgGbFlow_IN_SysInit;
    BCMR_DChrg_enter_atomic_SysInit();
  } else {
    guard1 = false;
    guard2 = false;
    switch (BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow) {
     case BCMR_DChrgGbFlow_IN_ComTimeOut:
      BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
        BCMR_DChrgGbF_IN_DChrgRelayOpen;
      BCMR_DChrgGbFlow_DW.temporalCounter_i3 = 0U;
      BCMR_DChrgGbFlow_DW.is_DChrgRelayOpen = BCMR_DChrgGbFlow_IN_Init;
      BCMR_cntDcAftTxBem++;
      break;

     case BCMR_DChrgG_IN_DChrgAbNormalEnd:
      if (((!BCMR_bDChrgWkup) || (!BCMR_bDChrgCnnt)) &&
          (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
           (BCMR_tiDChrgEndToSleep_C / 0.01F - 1.0E-10F))) {
        BCMR_bDChrgAbrtWait = true;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_SysSleep;
        BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
        BCMR_DChr_enter_atomic_SysSleep();
      }
      break;

     case BCMR_DChrgGbF_IN_DChrgNormalEnd:
      if (BCMR_bDChrgWkup && BCMR_bDChrgCnnt && (BSER_rSocDspl < 100.0F) &&
          ((BCMR_cntTimeOutCnt < 3) || (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >=
            (uint32_T)ceil(BCMR_tiDChrgReCnntFailPendingTime_C / 0.01F - 1.0E-10F)))
          && (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
              (BCMR_tiNormEndToHandOvrTi_C / 0.01F - 1.0E-10F)) && (COMR_flgRxCHM ||
           (COMR_flgRxCRM && BCMR_bRxCrmIdtfRstNg))) {
        BCMR_bDChrgAbrtWait = true;
        BCMR_stDChrgMode = 1U;
        COMR_flgRxCEM = false;
        COMR_flgRxCCS = false;
        COMR_flgRxCRO = false;
        COMR_flgRxCST = false;
        COMR_flgRxCML = false;
        COMR_flgRxCSD = false;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_MsgMutual;
        BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlo_IN_DChrgHandOvr;
        BCM_enter_internal_DChrgHandOvr();
      } else if (((!BCMR_bDChrgWkup) || (!BCMR_bDChrgCnnt)) &&
                 (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
                  (BCMR_tiDChrgEndToSleep_C / 0.01F - 1.0E-10F))) {
        COMR_flgRxCEM = false;
        COMR_flgRxCCS = false;
        COMR_flgRxCRO = false;
        COMR_flgRxCST = false;
        COMR_flgRxCML = false;
        COMR_flgRxCSD = false;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_SysSleep;
        BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
        BCMR_DChr_enter_atomic_SysSleep();
      } else {
        COMR_flgRxCEM = false;
        COMR_flgRxCCS = false;
        COMR_flgRxCRO = false;
        COMR_flgRxCST = false;
        COMR_flgRxCML = false;
        COMR_flgRxCSD = false;
      }
      break;

     case BCMR_DChrgGbF_IN_DChrgRelayOpen:
      if (COMR_flgRxCRM && BCMR_bRxCrmIdtfRstNg &&
          (BCMR_DChrgGbFlow_DW.temporalCounter_i3 >= (uint32_T)ceil
           (BCMR_tiTimeOut5S_C / 0.01F - 1.0E-10F))) {
        tmp = BCMR_cntTimeOutCnt + 1;
        if (tmp > 255) {
          tmp = 255;
        }

        BCMR_cntTimeOutCnt = (uint8_T)tmp;
        BCMR_bDChrgAbrtWait = true;
        BCMR_flgTxBEM = false;
        BCMR_DChrgGbFlow_DW.is_DChrgRelayOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_TimeOutOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_DcChrgLvOn;
        BCMR_DC_enter_atomic_DcChrgLvOn();
      } else if ((!BCMR_bDChrgWkup) || (BCMR_cntTimeOutCnt >= 3) ||
                 BCMR_flgReConnectFail) {
        if (((BCCR_stBmsDChrgCtrMode == 6) || (BCCR_stBmsDChrgCtrMode == 0)) &&
            ((BCCR_stBmsCtrMode == 7) || (BCCR_stBmsCtrMode == 14) ||
             (BCCR_stBmsCtrMode == 0))) {
          if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv >= 2) {
            BCMR_DChrgGbFlow_DW.is_DChrgRelayOpen =
              BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
            BCMR_DChrgGbFlow_DW.is_TimeOutOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
            BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
              BCMR_DChrgG_IN_DChrgAbNormalEnd;
            BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
            B_enter_atomic_DChrgAbNormalEnd();
          } else if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv <= 1) {
            BCMR_DChrgGbFlow_DW.is_DChrgRelayOpen =
              BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
            BCMR_DChrgGbFlow_DW.is_TimeOutOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
            BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
              BCMR_DChrgGbF_IN_DChrgNormalEnd;
            BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
            BCM_enter_atomic_DChrgNormalEnd();
          } else {
            guard2 = true;
          }
        } else {
          guard2 = true;
        }
      } else {
        guard1 = true;
      }
      break;

     case BCMR_DChrgGbFlow_IN_DcChrgCnnt:
      if (BCMR_bDChrgWkup) {
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_DcChrgLvOn;
        BCMR_DC_enter_atomic_DcChrgLvOn();
      } else if (!BCMR_bDChrgCnnt) {
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow = BCMR_DChrgGbFlow_IN_SysInit;
        BCMR_DChrg_enter_atomic_SysInit();
      } else {
        BCMR_DChrgGbFlow_DW.BCMR_IsoSWTimeCnt += 0.01F;
        if (!(BCMR_DChrgGbFlow_DW.BCMR_IsoSWTimeCnt < BCMR_IsoSWTimeCntDlyTime_C))
        {
          BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e = false;
          BCMR_DChrgGbFlow_DW.BCMR_IsoSWTimeCnt = BCMR_IsoSWTimeCntDlyTime_C;
        }
      }
      break;

     case BCMR_DChrgGbFlow_IN_DcChrgLvOn:
      BCMR_stDChrgMode = 1U;
      COMR_flgRxCEM = false;
      BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow = BCMR_DChrgGbFlow_IN_MsgMutual;
      BCMR_DChrgGbFlow_DW.is_MsgMutual = BCMR_DChrgGbFlo_IN_DChrgHandOvr;
      BCM_enter_internal_DChrgHandOvr();
      break;

     case BCMR_DChrgGbFlow_IN_MsgMutual:
      BCMR_DChrgGbFlow_MsgMutual();
      break;

     case BCMR_DChrgGbFlow_IN_RelayOpen:
      BCMR_DChrgGbFlow_RelayOpen();
      break;

     case BCMR_DChrgGbFlow_IN_SysInit:
      if (BCMR_bDChrgCnnt) {
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_DcChrgCnnt;
        BCMR_stDChrgDebugOut = 1U;
        BCMR_stDChrgMode = 0U;
        BCMR_flgReConnectFail = false;
        BCMR_cntTimeOutCnt = 0U;
        BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e = BCMR_bDChrgIsoStopCmdLvOn_C;
        BCMR_DChrgGbFlow_DW.BCMR_IsoSWTimeCnt = 0.0F;
        if (!(BCMR_DChrgGbFlow_DW.BCMR_IsoSWTimeCnt < BCMR_IsoSWTimeCntDlyTime_C))
        {
          BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e = false;
          BCMR_DChrgGbFlow_DW.BCMR_IsoSWTimeCnt = BCMR_IsoSWTimeCntDlyTime_C;
        }
      } else {
        COMR_flgRxCEM = false;
        COMR_flgRxCHM = false;
        COMR_flgRxCRM = false;
        COMR_flgRxCCS = false;
        COMR_flgRxCRO = false;
        COMR_flgRxCST = false;
        COMR_flgRxCML = false;
        COMR_flgRxCSD = false;
      }
      break;

     default:
      if (BCMR_bDChrgCnnt && (BSER_rSocDspl < 100.0F) && ((BCMR_cntTimeOutCnt <
            3) || (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= (uint32_T)ceil
                   (BCMR_tiDChrgReCnntFailPendingTime_C / 0.01F - 1.0E-10F)))) {
        BCMR_bDChrgAbrtWait = true;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow = BCMR_DChrgGbFlow_IN_SysInit;
        BCMR_DChrg_enter_atomic_SysInit();
      } else {
        COMR_flgRxCEM = false;
        COMR_flgRxCHM = false;
        COMR_flgRxCRM = false;
        COMR_flgRxCCS = false;
        COMR_flgRxCRO = false;
        COMR_flgRxCST = false;
        COMR_flgRxCML = false;
        COMR_flgRxCSD = false;
      }
      break;
    }

    if (guard2) {
      if (((BCCR_stBmsCtrMode == 4) || (BCCR_stBmsDChrgCtrMode == 3)) &&
          (BCMR_DChrgGbFlow_DW.temporalCounter_i2 >= 500U)) {
        BCMR_DChrgGbFlow_DW.is_DChrgRelayOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_TimeOutOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
        BCMR_DChrgGbFlow_DW.is_c1_BCMR_DChrgGbFlow =
          BCMR_DChrgGbFlow_IN_RelayOpen;
        BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
        BCMR_DChrgGbFlow_DW.is_RelayOpen = BCMR_DChrgGbFlow_IN_Init;
        BCMR_stDChrgMode = 4U;
        BCMR_cntDcAftTxBst++;
        BCMR_cntDcAftRxCst++;
      } else {
        guard1 = true;
      }
    }

    if (guard1) {
      switch (BCMR_DChrgGbFlow_DW.is_DChrgRelayOpen) {
       case BCMR_DChrgGbFlow_IN_Init:
        if (BCMR_DChrgGbFlow_DW.BEM_TimeOutLv > 0) {
          BCMR_DChrgGbFlow_DW.is_DChrgRelayOpen =
            BCMR_DChrgGbFlow_IN_TimeOutOpen;
          BCMR_DChrgGbFlow_DW.temporalCounter_i2 = 0U;
          BCMR_DChrgGbFlow_DW.is_TimeOutOpen = BCMR_DChrgGbFlow_IN_WaitCurr_a;
          BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
          BCMR_stDChrgDebugOut = 80U;
          BCMR_cntDcAftTxBem++;
        }
        break;

       case BCMR_DChrgGbFl_IN_ReCnntTimeOut:
        break;

       default:
        if ((!COMR_flgRxCRM) && (BCMR_DChrgGbFlow_DW.temporalCounter_i2 >=
             (uint32_T)ceil(BCMR_tiComTimeOutLmt_C / 0.01F - 1.0E-10F))) {
          BCMR_stDChrgGbFlowTimeout = 13U;
          BCMR_DChrgGbFlow_DW.is_TimeOutOpen = BCMR_DChrgGb_IN_NO_ACTIVE_CHILD;
          BCMR_DChrgGbFlow_DW.is_DChrgRelayOpen =
            BCMR_DChrgGbFl_IN_ReCnntTimeOut;
          BCMR_flgReConnectFail = true;
          BCMR_stDChrgDebugOut = 83U;
        } else {
          switch (BCMR_DChrgGbFlow_DW.is_TimeOutOpen) {
           case BCMR_DChrgGbFlow_IN_DcChrgRelay:
            if ((BCCR_stBmsDChrgCtrMode == 6) ||
                (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= 100U)) {
              BCMR_DChrgGbFlow_DW.is_TimeOutOpen = BCMR_DChrgGbFlow_IN_WaitCRM;

              /* BCMR_flgTxBEM = false; */
              BCMR_stDChrgDebugOut = 82U;
            } else {
              BCMR_cntDcAftTxBem++;
            }
            break;

           case BCMR_DChrgGbFlow_IN_WaitCRM:
            break;

           default:
            if (BSPR_iBattCurr > -5.0F) {
              BCMR_DChrgGbFlow_DW.is_TimeOutOpen =
                BCMR_DChrgGbFlow_IN_DcChrgRelay;
              BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
              BCMR_stDChrgDebugOut = 81U;
              BCMR_bDChrgRdy = false;
              BCMR_cntDcAftTxBem++;
            } else if ((BSPR_iBattCurr <= -5.0F) &&
                       (BCMR_DChrgGbFlow_DW.temporalCounter_i1 >= 1000U)) {
              BCMR_DChrgGbFlow_DW.BEM_TimeOutLv = 2U;
              BCMR_DChrgGbFlow_DW.is_TimeOutOpen =
                BCMR_DChrgGbFlow_IN_DcChrgRelay;
              BCMR_DChrgGbFlow_DW.temporalCounter_i1 = 0U;
              BCMR_stDChrgDebugOut = 81U;
              BCMR_bDChrgRdy = false;
              BCMR_cntDcAftTxBem++;
            } else {
              BCMR_cntDcAftTxBem++;
            }
            break;
          }
        }
        break;
      }
    }
  }

  LcBCMR_ElockReq_flg = (((BCMR_stAChrgCnnt != 1) && (BMCR_stBmsModeCtrl != 5) &&
    COMR_bChrgStopActive) || ((BCMR_stDChrgDebugOut == 67) ||
    (BCMR_stDChrgDebugOut == 68)) || ((!BCMR_DChrgGbFlow_DW.StateName) &&
    LcBCMR_ElockReq_flg));
  rtb_LogicalOperator_h = !LcBCMR_ElockReq_flg;
  if (rtb_LogicalOperator_h || (BCMR_DChrgGbFlow_DW.FixPtUnitDelay2_DSTATE != 0))
  {
    rtb_Init = 0U;
  } else {
    rtb_Init = BCMR_DChrgGbFlow_DW.FixPtUnitDelay1_DSTATE;
  }

  rtb_RelationalOperator = (rtb_Init >= CcBCMR_ELockRequestDelay_ms);
  if (rtb_LogicalOperator_h) {
    BCMR_DChrgGbFlow_DW.FixPtUnitDelay1_DSTATE = 0U;
  } else {
    if (rtb_RelationalOperator) {
      rtb_RelationalOperator_0 = 0U;
    } else {
      rtb_RelationalOperator_0 = BCMR_RUNTIME_MS;
    }

    BCMR_DChrgGbFlow_DW.FixPtUnitDelay1_DSTATE = (uint16_T)((uint32_T)
      rtb_RelationalOperator_0 + rtb_Init);
  }

  BCMR_DChrgGbFlow_DW.FixPtUnitDelay2_DSTATE = 0U;
  BCMR_bDChrgFulRaw = (BCMR_DChrgGbFlow_B.BCMR_bDChrgFul_j ||
                       BCMR_flgDChrgFulChk);
  rtb_LogicalOperator_h = !BCMR_DChrgGbFlow_DW.Delay1_DSTATE;
  BCMR_DChrgGbFlow_DW.Delay1_DSTATE = BCMR_DChrgGbFlow_DW.Delay2_DSTATE;
  BCMR_bDChrgFul = ((BCMR_bDChrgFul || BCMR_bDChrgFulRaw) &&
                    (!BCMR_DChrgGbFlow_DW.Delay2_DSTATE));
  if (rtb_LogicalOperator_h && BCMR_DChrgGbFlow_DW.Delay2_DSTATE) {
    rtb_Switch1 = 0.0F;
  } else {
    if (BCMR_bDChrgFul) {
      rtb_Switch1 = BCMR_tiDChrgStateBase_C;
    } else {
      rtb_Switch1 = 0.0F;
    }

    rtb_Switch1 += BCMR_DChrgGbFlow_DW.UnitDelay_DSTATE;
  }

  BCMR_bDChrgIsoStopCmd = ((!!BCMR_bDChrgCnnt) &&
    BCMR_DChrgGbFlow_B.BCMR_bDChrgIsoStopCmd_e);
  if (!LcBCMR_ElockReq_flg) {
    BCMR_stDChrgElockReq = BCMR_DChrgGbFlow_B.BCMR_stDChrgElockReq_p;
  } else {
    BCMR_stDChrgElockReq = 1U;
  }

  BCMR_DChrgGbFlow_DW.StateName = rtb_RelationalOperator;
  BCMR_DChrgGbFlow_DW.Delay2_DSTATE = (rtb_Switch1 > BCMR_tiDChgFullHold_C);
  BCMR_DChrgGbFlow_DW.UnitDelay_DSTATE = rtb_Switch1;
  if (BCMR_DChrgGbFlow_DW.is_active_c3_BCMR_DChrgGbFlow == 0U) {
    BCMR_DChrgGbFlow_DW.is_active_c3_BCMR_DChrgGbFlow = 1U;
    BCMR_DChrgGbFlow_DW.is_c3_BCMR_DChrgGbFlow = BCMR_DChrgGbFlow_IN_Disable;
  } else if (BCMR_DChrgGbFlow_DW.is_c3_BCMR_DChrgGbFlow ==
             BCMR_DChrgGbFlow_IN_Disable) {
    if (BCMR_bDChrgCnnt) {
      BCMR_DChrgGbFlow_DW.is_c3_BCMR_DChrgGbFlow = BCMR_DChrgGbFlow_IN_Enable;
    }
  } else {
    if (!BCMR_bDChrgCnnt) {
      BCMR_DChrgGbFlow_DW.is_c3_BCMR_DChrgGbFlow = BCMR_DChrgGbFlow_IN_Disable;
    }
  }
}

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

  /* block I/O */

  /* exported global signals */
  BCMR_cntDcAftTxBst = 0.0F;
  BCMR_cntDcAftRxCst = 0.0F;
  BCMR_cntDcAftTxBem = 0.0F;
  BCMR_cntTimeOutCnt = 0U;

  /* custom signals */
  BCMR_stDChrgElockReq = ((uint8_T)0U);
  BCMR_stDChrgMode = ((uint8_T)0U);
  BCMR_stDChrgDebugOut = ((uint8_T)0U);
  BCMR_stBmsRdyBro = ((uint8_T)0U);
  BCMR_stSpn3901TimeoutBem = ((uint8_T)0U);
  BCMR_stSpn3902TimeoutBem = ((uint8_T)0U);
  BCMR_stSpn3903TimeoutBem = ((uint8_T)0U);
  BCMR_stSpn3904TimeoutBem = ((uint8_T)0U);
  BCMR_stSpn3905TimeoutBem = ((uint8_T)0U);
  BCMR_stSpn3906TimeoutBem = ((uint8_T)0U);
  BCMR_stSpn3907TimeoutBem = ((uint8_T)0U);
  BCMR_stOtherErrBem = ((uint8_T)0U);
  BCMR_stDChrgGbFlowTimeout = ((uint8_T)0U);
  BCMR_bDChrgFul = false;
  BCMR_bDChrgIsoStopCmd = false;
  BCMR_bDChrgPwrUpReq = false;
  BCMR_bDChrgRdy = false;
  BCMR_bDChrgPwrDwnReq = false;
  BCMR_flgTxBHM = false;
  BCMR_flgTxBCP = false;
  BCMR_flgTxBRO = false;
  BCMR_flgTxBRM = false;
  BCMR_flgTxBCL = false;
  BCMR_flgTxBCS = false;
  BCMR_flgTxBSM = false;
  BCMR_flgTxBST = false;
  BCMR_flgTxBEM = false;
  BCMR_flgTxBSD = false;
  BCMR_bDChrgAbrtWait = false;
  BCMR_flgReConnectFail = false;
  BCMR_flgDChrgVer2015 = false;
  BCMR_flgDChrgStopBActive = false;
  BCMR_flgDChrgStopCActive = false;
  BCMR_DChrgGbFlow_DW.FixPtUnitDelay2_DSTATE = 1U;
  BCMR_DChrgGbFlow_DW.Delay1_DSTATE = true;
}

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