/*
 * File: rt_sys_P417_SWTL_App_19.c
 *
 * Code generated for Simulink model 'P417_SWTL_App'.
 *
 * Model version                  : 1.148
 * Simulink Coder version         : 8.13 (R2017b) 24-Jul-2017
 * C/C++ source code generated on : Tue Dec 20 16:43:44 2022
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "rt_sys_P417_SWTL_App_19.h"

/* Include model header file for global data */
#include "P417_SWTL_App.h"
#include "P417_SWTL_App_private.h"

/* Named constants for Chart: '<S84>/Value_Debounce_Chart' */
#define P417_SWTL_App_IN_Default_output ((uint8_T)1U)
#define P417_SWTL_App_IN_Update_output ((uint8_T)2U)
#define P417_SWTL_App_IN_input_changed ((uint8_T)3U)
#define P417_SWTL__IN_NO_ACTIVE_CHILD_h ((uint8_T)0U)

/*
 * System initialize for atomic system:
 *    '<S84>/Value_Debounce_Chart'
 *    '<S66>/Value_Debounce_Chart'
 *    '<S72>/Value_Debounce_Chart'
 *    '<S78>/Value_Debounce_Chart'
 *    '<S63>/Value_Debounce_Chart'
 *    '<S75>/Value_Debounce_Chart'
 *    '<S57>/Value_Debounce_Chart'
 *    '<S60>/Value_Debounce_Chart'
 *    '<S69>/Value_Debounce_Chart'
 *    '<S81>/Value_Debounce_Chart'
 *    ...
 */
void P417__Value_Debounce_Chart_Init(uint8_T *rty_output,
  DW_Value_Debounce_Chart_P417__T *localDW)
{
  localDW->temporalCounter_i1 = 0U;
  localDW->is_active_c1_Debounce_Models = 0U;
  localDW->is_c1_Debounce_Models = P417_SWTL__IN_NO_ACTIVE_CHILD_h;
  localDW->temp_state = 0U;
  *rty_output = 0U;
}

/*
 * Output and update for atomic system:
 *    '<S84>/Value_Debounce_Chart'
 *    '<S66>/Value_Debounce_Chart'
 *    '<S72>/Value_Debounce_Chart'
 *    '<S78>/Value_Debounce_Chart'
 *    '<S63>/Value_Debounce_Chart'
 *    '<S75>/Value_Debounce_Chart'
 *    '<S57>/Value_Debounce_Chart'
 *    '<S60>/Value_Debounce_Chart'
 *    '<S69>/Value_Debounce_Chart'
 *    '<S81>/Value_Debounce_Chart'
 *    ...
 */
void P417_SWTL__Value_Debounce_Chart(uint8_T rtu_input, uint8_T rtu_change_flag,
  uint8_T *rty_output, DW_Value_Debounce_Chart_P417__T *localDW, uint8_T
  rtp_Debounce_count)
{
  /* Chart: '<S84>/Value_Debounce_Chart' */
  if (localDW->temporalCounter_i1 < 255U) {
    localDW->temporalCounter_i1++;
  }

  if (localDW->is_active_c1_Debounce_Models == 0U) {
    localDW->is_active_c1_Debounce_Models = 1U;
    localDW->is_c1_Debounce_Models = P417_SWTL_App_IN_Default_output;
    *rty_output = rtu_input;
  } else {
    switch (localDW->is_c1_Debounce_Models) {
     case P417_SWTL_App_IN_Default_output:
      if (rtu_change_flag == 1) {
        localDW->temp_state = rtu_input;
        localDW->is_c1_Debounce_Models = P417_SWTL_App_IN_input_changed;
        localDW->temporalCounter_i1 = 0U;
      }
      break;

     case P417_SWTL_App_IN_Update_output:
      if (rtu_change_flag == 1) {
        localDW->temp_state = rtu_input;
        localDW->is_c1_Debounce_Models = P417_SWTL_App_IN_input_changed;
        localDW->temporalCounter_i1 = 0U;
      }
      break;

     default:
      if (localDW->temporalCounter_i1 >= rtp_Debounce_count) {
        localDW->is_c1_Debounce_Models = P417_SWTL_App_IN_Update_output;
        *rty_output = localDW->temp_state;
      } else {
        if (rtu_change_flag == 1) {
          localDW->temp_state = rtu_input;
          localDW->is_c1_Debounce_Models = P417_SWTL_App_IN_input_changed;
          localDW->temporalCounter_i1 = 0U;
        }
      }
      break;
    }
  }

  /* End of Chart: '<S84>/Value_Debounce_Chart' */
}

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