/* Include files */

#include "ADP_sfun.h"
#include "c6_ADP.h"
#define CHARTINSTANCE_CHARTNUMBER      (chartInstance->chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER   (chartInstance->instanceNumber)
#include "ADP_sfun_debug_macros.h"
#define _SF_MEX_LISTEN_FOR_CTRL_C(S)   sf_mex_listen_for_ctrl_c_with_debugger(S, sfGlobalDebugInstanceStruct);

static void chart_debug_initialization(SimStruct *S, unsigned int
  fullDebuggerInitialization);
static void chart_debug_initialize_data_addresses(SimStruct *S);
static const mxArray* sf_opaque_get_hover_data_for_msg(void *chartInstance,
  int32_T msgSSID);

/* Type Definitions */

/* Named Constants */
#define CALL_EVENT                     (-1)
#define c6_IN_NO_ACTIVE_CHILD          ((uint8_T)0U)
#define c6_const_Const100ms            ((uint8_T)10U)
#define c6_const_Const20ms             ((uint8_T)2U)
#define c6_const_Const500ms            ((uint8_T)50U)
#define c6_const_Const1000ms           ((uint8_T)100U)

/* Variable Declarations */

/* Variable Definitions */
static real_T _sfTime_;

/* Function Declarations */
static void initialize_c6_ADP(SFc6_ADPInstanceStruct *chartInstance);
static void initialize_params_c6_ADP(SFc6_ADPInstanceStruct *chartInstance);
static void enable_c6_ADP(SFc6_ADPInstanceStruct *chartInstance);
static void disable_c6_ADP(SFc6_ADPInstanceStruct *chartInstance);
static void c6_update_debugger_state_c6_ADP(SFc6_ADPInstanceStruct
  *chartInstance);
static const mxArray *get_sim_state_c6_ADP(SFc6_ADPInstanceStruct *chartInstance);
static void set_sim_state_c6_ADP(SFc6_ADPInstanceStruct *chartInstance, const
  mxArray *c6_st);
static void c6_set_sim_state_side_effects_c6_ADP(SFc6_ADPInstanceStruct
  *chartInstance);
static void finalize_c6_ADP(SFc6_ADPInstanceStruct *chartInstance);
static void sf_gateway_c6_ADP(SFc6_ADPInstanceStruct *chartInstance);
static void mdl_start_c6_ADP(SFc6_ADPInstanceStruct *chartInstance);
static void initSimStructsc6_ADP(SFc6_ADPInstanceStruct *chartInstance);
static void init_script_number_translation(uint32_T c6_machineNumber, uint32_T
  c6_chartNumber, uint32_T c6_instanceNumber);
static const mxArray *c6_sf_marshallOut(void *chartInstanceVoid, void *c6_inData);
static int32_T c6_emlrt_marshallIn(SFc6_ADPInstanceStruct *chartInstance, const
  mxArray *c6_u, const emlrtMsgIdentifier *c6_parentId);
static void c6_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c6_mxArrayInData, const char_T *c6_varName, void *c6_outData);
static const mxArray *c6_b_sf_marshallOut(void *chartInstanceVoid, void
  *c6_inData);
static uint8_T c6_b_emlrt_marshallIn(SFc6_ADPInstanceStruct *chartInstance,
  const mxArray *c6_b_TimeCounter20ms, const char_T *c6_identifier);
static uint8_T c6_c_emlrt_marshallIn(SFc6_ADPInstanceStruct *chartInstance,
  const mxArray *c6_u, const emlrtMsgIdentifier *c6_parentId);
static void c6_b_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c6_mxArrayInData, const char_T *c6_varName, void *c6_outData);
static const mxArray *c6_d_emlrt_marshallIn(SFc6_ADPInstanceStruct
  *chartInstance, const mxArray *c6_b_setSimStateSideEffectsInfo, const char_T
  *c6_identifier);
static const mxArray *c6_e_emlrt_marshallIn(SFc6_ADPInstanceStruct
  *chartInstance, const mxArray *c6_u, const emlrtMsgIdentifier *c6_parentId);
static const mxArray *sf_get_hover_data_for_msg(SFc6_ADPInstanceStruct
  *chartInstance, int32_T c6_ssid);
static void c6_init_sf_message_store_memory(SFc6_ADPInstanceStruct
  *chartInstance);
static int32_T c6__s32_add__(SFc6_ADPInstanceStruct *chartInstance, int32_T c6_b,
  int32_T c6_c, uint32_T c6_ssid_src_loc, int32_T c6_offset_src_loc, int32_T
  c6_length_src_loc);
static void init_dsm_address_info(SFc6_ADPInstanceStruct *chartInstance);
static void init_simulink_io_address(SFc6_ADPInstanceStruct *chartInstance);

/* Function Definitions */
static void initialize_c6_ADP(SFc6_ADPInstanceStruct *chartInstance)
{
  if (sf_is_first_init_cond(chartInstance->S)) {
    initSimStructsc6_ADP(chartInstance);
    chart_debug_initialize_data_addresses(chartInstance->S);
  }

  chartInstance->c6_sfEvent = CALL_EVENT;
  _sfTime_ = sf_get_time(chartInstance->S);
  chartInstance->c6_doSetSimStateSideEffects = 0U;
  chartInstance->c6_setSimStateSideEffectsInfo = NULL;
  chartInstance->c6_is_active_c6_ADP = 0U;
  chartInstance->c6_TimeCounter20ms = 0U;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter20ms, 2U);
  chartInstance->c6_TimeCounter100ms = 0U;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter100ms, 1U);
  chartInstance->c6_TimeCounter500ms = 0U;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter500ms, 3U);
  chartInstance->c6_TimeCounter1000ms = 0U;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter1000ms, 0U);
  chartInstance->c6_Const100ms = 10U;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_Const100ms, 5U);
  chartInstance->c6_Const20ms = 2U;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_Const20ms, 6U);
  chartInstance->c6_Const500ms = 50U;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_Const500ms, 7U);
  chartInstance->c6_Const1000ms = 100U;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_Const1000ms, 4U);
}

static void initialize_params_c6_ADP(SFc6_ADPInstanceStruct *chartInstance)
{
  (void)chartInstance;
}

static void enable_c6_ADP(SFc6_ADPInstanceStruct *chartInstance)
{
  _sfTime_ = sf_get_time(chartInstance->S);
  sf_call_output_fcn_enable(chartInstance->S, 0, "ADP_2AD_100ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 1, "ADP_2BB_100ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 2, "ADP_2DF_100ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 3, "ADP_3AA_1000ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 4, "ADP_050_10ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 5, "ADP_17D_20ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 6, "ADP_2F1_100ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 7, "ADP_195_20ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 8, "ADP_37F_500ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 9, "ADP_28D_20ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 10, "ADP_3C2_10ms", 0);
  sf_call_output_fcn_enable(chartInstance->S, 11, "ADP_3A0_10ms", 0);
}

static void disable_c6_ADP(SFc6_ADPInstanceStruct *chartInstance)
{
  _sfTime_ = sf_get_time(chartInstance->S);
  sf_call_output_fcn_disable(chartInstance->S, 0, "ADP_2AD_100ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 1, "ADP_2BB_100ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 2, "ADP_2DF_100ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 3, "ADP_3AA_1000ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 4, "ADP_050_10ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 5, "ADP_17D_20ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 6, "ADP_2F1_100ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 7, "ADP_195_20ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 8, "ADP_37F_500ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 9, "ADP_28D_20ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 10, "ADP_3C2_10ms", 0);
  sf_call_output_fcn_disable(chartInstance->S, 11, "ADP_3A0_10ms", 0);
}

static void c6_update_debugger_state_c6_ADP(SFc6_ADPInstanceStruct
  *chartInstance)
{
  (void)chartInstance;
}

static const mxArray *get_sim_state_c6_ADP(SFc6_ADPInstanceStruct *chartInstance)
{
  const mxArray *c6_st;
  const mxArray *c6_y = NULL;
  uint8_T c6_hoistedGlobal;
  const mxArray *c6_b_y = NULL;
  uint8_T c6_b_hoistedGlobal;
  const mxArray *c6_c_y = NULL;
  uint8_T c6_c_hoistedGlobal;
  const mxArray *c6_d_y = NULL;
  uint8_T c6_d_hoistedGlobal;
  const mxArray *c6_e_y = NULL;
  uint8_T c6_e_hoistedGlobal;
  const mxArray *c6_f_y = NULL;
  c6_st = NULL;
  c6_st = NULL;
  c6_y = NULL;
  sf_mex_assign(&c6_y, sf_mex_createcellmatrix(5, 1), false);
  c6_hoistedGlobal = chartInstance->c6_TimeCounter1000ms;
  c6_b_y = NULL;
  sf_mex_assign(&c6_b_y, sf_mex_create("y", &c6_hoistedGlobal, 3, 0U, 0U, 0U, 0),
                false);
  sf_mex_setcell(c6_y, 0, c6_b_y);
  c6_b_hoistedGlobal = chartInstance->c6_TimeCounter100ms;
  c6_c_y = NULL;
  sf_mex_assign(&c6_c_y, sf_mex_create("y", &c6_b_hoistedGlobal, 3, 0U, 0U, 0U,
    0), false);
  sf_mex_setcell(c6_y, 1, c6_c_y);
  c6_c_hoistedGlobal = chartInstance->c6_TimeCounter20ms;
  c6_d_y = NULL;
  sf_mex_assign(&c6_d_y, sf_mex_create("y", &c6_c_hoistedGlobal, 3, 0U, 0U, 0U,
    0), false);
  sf_mex_setcell(c6_y, 2, c6_d_y);
  c6_d_hoistedGlobal = chartInstance->c6_TimeCounter500ms;
  c6_e_y = NULL;
  sf_mex_assign(&c6_e_y, sf_mex_create("y", &c6_d_hoistedGlobal, 3, 0U, 0U, 0U,
    0), false);
  sf_mex_setcell(c6_y, 3, c6_e_y);
  c6_e_hoistedGlobal = chartInstance->c6_is_active_c6_ADP;
  c6_f_y = NULL;
  sf_mex_assign(&c6_f_y, sf_mex_create("y", &c6_e_hoistedGlobal, 3, 0U, 0U, 0U,
    0), false);
  sf_mex_setcell(c6_y, 4, c6_f_y);
  sf_mex_assign(&c6_st, c6_y, false);
  return c6_st;
}

static void set_sim_state_c6_ADP(SFc6_ADPInstanceStruct *chartInstance, const
  mxArray *c6_st)
{
  const mxArray *c6_u;
  chartInstance->c6_doneDoubleBufferReInit = true;
  c6_u = sf_mex_dup(c6_st);
  chartInstance->c6_TimeCounter1000ms = c6_b_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c6_u, 0)), "TimeCounter1000ms");
  chartInstance->c6_TimeCounter100ms = c6_b_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c6_u, 1)), "TimeCounter100ms");
  chartInstance->c6_TimeCounter20ms = c6_b_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c6_u, 2)), "TimeCounter20ms");
  chartInstance->c6_TimeCounter500ms = c6_b_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c6_u, 3)), "TimeCounter500ms");
  chartInstance->c6_is_active_c6_ADP = c6_b_emlrt_marshallIn(chartInstance,
    sf_mex_dup(sf_mex_getcell(c6_u, 4)), "is_active_c6_ADP");
  sf_mex_assign(&chartInstance->c6_setSimStateSideEffectsInfo,
                c6_d_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell
    (c6_u, 5)), "setSimStateSideEffectsInfo"), true);
  sf_mex_destroy(&c6_u);
  chartInstance->c6_doSetSimStateSideEffects = 1U;
  c6_update_debugger_state_c6_ADP(chartInstance);
  sf_mex_destroy(&c6_st);
}

static void c6_set_sim_state_side_effects_c6_ADP(SFc6_ADPInstanceStruct
  *chartInstance)
{
  if (chartInstance->c6_doSetSimStateSideEffects != 0) {
    chartInstance->c6_doSetSimStateSideEffects = 0U;
  }
}

static void finalize_c6_ADP(SFc6_ADPInstanceStruct *chartInstance)
{
  sf_mex_destroy(&chartInstance->c6_setSimStateSideEffectsInfo);
}

static void sf_gateway_c6_ADP(SFc6_ADPInstanceStruct *chartInstance)
{
  int32_T c6_i0;
  int32_T c6_i1;
  int32_T c6_i2;
  int32_T c6_i3;
  boolean_T c6_out;
  boolean_T c6_b_out;
  boolean_T c6_c_out;
  boolean_T c6_d_out;
  c6_set_sim_state_side_effects_c6_ADP(chartInstance);
  _SFD_SYMBOL_SCOPE_PUSH(0U, 0U);
  _sfTime_ = sf_get_time(chartInstance->S);
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 0U, chartInstance->c6_sfEvent);
  chartInstance->c6_sfEvent = CALL_EVENT;
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 0U, chartInstance->c6_sfEvent);
  _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 3U, chartInstance->c6_sfEvent);
  _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 1U, chartInstance->c6_sfEvent);
  sf_call_output_fcn_call(chartInstance->S, 4, "ADP_050_10ms", 0);
  sf_call_output_fcn_call(chartInstance->S, 10, "ADP_3C2_10ms", 0);
  sf_call_output_fcn_call(chartInstance->S, 11, "ADP_3A0_10ms", 0);
  _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 2U, chartInstance->c6_sfEvent);
  c6_i0 = c6__s32_add__(chartInstance, (int32_T)
                        chartInstance->c6_TimeCounter20ms, 1, 151U, 2U, 18U);
  if (CV_SATURATION_EVAL(5, 2, 1, 0, c6_i0 < 0)) {
    c6_i0 = 0;
    _SFD_OVERFLOW_DETECTION(SFDB_SATURATE, 151U, 2U, 18U);
  } else {
    if (c6_i0 > 255) {
      c6_i0 = 255;
      _SFD_OVERFLOW_DETECTION(SFDB_SATURATE, 151U, 2U, 18U);
    }
  }

  chartInstance->c6_TimeCounter20ms = (uint8_T)c6_i0;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter20ms, 2U);
  c6_i1 = c6__s32_add__(chartInstance, (int32_T)
                        chartInstance->c6_TimeCounter100ms, 1, 151U, 22U, 19U);
  if (CV_SATURATION_EVAL(5, 2, 0, 0, c6_i1 < 0)) {
    c6_i1 = 0;
    _SFD_OVERFLOW_DETECTION(SFDB_SATURATE, 151U, 22U, 19U);
  } else {
    if (c6_i1 > 255) {
      c6_i1 = 255;
      _SFD_OVERFLOW_DETECTION(SFDB_SATURATE, 151U, 22U, 19U);
    }
  }

  chartInstance->c6_TimeCounter100ms = (uint8_T)c6_i1;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter100ms, 1U);
  c6_i2 = c6__s32_add__(chartInstance, (int32_T)
                        chartInstance->c6_TimeCounter500ms, 1, 151U, 43U, 19U);
  if (CV_SATURATION_EVAL(5, 2, 2, 0, c6_i2 < 0)) {
    c6_i2 = 0;
    _SFD_OVERFLOW_DETECTION(SFDB_SATURATE, 151U, 43U, 19U);
  } else {
    if (c6_i2 > 255) {
      c6_i2 = 255;
      _SFD_OVERFLOW_DETECTION(SFDB_SATURATE, 151U, 43U, 19U);
    }
  }

  chartInstance->c6_TimeCounter500ms = (uint8_T)c6_i2;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter500ms, 3U);
  c6_i3 = c6__s32_add__(chartInstance, (int32_T)
                        chartInstance->c6_TimeCounter1000ms, 1, 151U, 64U, 20U);
  if (CV_SATURATION_EVAL(5, 2, 3, 0, c6_i3 < 0)) {
    c6_i3 = 0;
    _SFD_OVERFLOW_DETECTION(SFDB_SATURATE, 151U, 64U, 20U);
  } else {
    if (c6_i3 > 255) {
      c6_i3 = 255;
      _SFD_OVERFLOW_DETECTION(SFDB_SATURATE, 151U, 64U, 20U);
    }
  }

  chartInstance->c6_TimeCounter1000ms = (uint8_T)c6_i3;
  _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter1000ms, 0U);
  _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 0U, chartInstance->c6_sfEvent);
  c6_out = (CV_TRANSITION_EVAL(0U, (int32_T)(_SFD_CCP_CALL(5U, 0U, 0, (boolean_T)
    CV_RELATIONAL_EVAL(5U, 0U, 0, (real_T)chartInstance->c6_TimeCounter20ms,
                       (real_T)c6_const_Const20ms, 0, 5U,
                       chartInstance->c6_TimeCounter20ms >= c6_const_Const20ms)
    != 0U, chartInstance->c6_sfEvent) != 0U)) != 0);
  if (c6_out) {
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 0U, chartInstance->c6_sfEvent);
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 4U, chartInstance->c6_sfEvent);
    sf_call_output_fcn_call(chartInstance->S, 5, "ADP_17D_20ms", 0);
    sf_call_output_fcn_call(chartInstance->S, 7, "ADP_195_20ms", 0);
    sf_call_output_fcn_call(chartInstance->S, 9, "ADP_28D_20ms", 0);
    chartInstance->c6_TimeCounter20ms = 0U;
    _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter20ms, 2U);
  } else {
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 5U, chartInstance->c6_sfEvent);
  }

  _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 6U, chartInstance->c6_sfEvent);
  c6_b_out = (CV_TRANSITION_EVAL(6U, (int32_T)(_SFD_CCP_CALL(5U, 6U, 0,
    (boolean_T)CV_RELATIONAL_EVAL(5U, 6U, 0, (real_T)
    chartInstance->c6_TimeCounter100ms, (real_T)c6_const_Const100ms, 0, 5U,
    chartInstance->c6_TimeCounter100ms >= c6_const_Const100ms) != 0U,
    chartInstance->c6_sfEvent) != 0U)) != 0);
  if (c6_b_out) {
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 6U, chartInstance->c6_sfEvent);
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 7U, chartInstance->c6_sfEvent);
    sf_call_output_fcn_call(chartInstance->S, 0, "ADP_2AD_100ms", 0);
    sf_call_output_fcn_call(chartInstance->S, 1, "ADP_2BB_100ms", 0);
    sf_call_output_fcn_call(chartInstance->S, 2, "ADP_2DF_100ms", 0);
    sf_call_output_fcn_call(chartInstance->S, 6, "ADP_2F1_100ms", 0);
    chartInstance->c6_TimeCounter100ms = 0U;
    _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter100ms, 1U);
  } else {
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 8U, chartInstance->c6_sfEvent);
  }

  _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 9U, chartInstance->c6_sfEvent);
  c6_c_out = (CV_TRANSITION_EVAL(9U, (int32_T)(_SFD_CCP_CALL(5U, 9U, 0,
    (boolean_T)CV_RELATIONAL_EVAL(5U, 9U, 0, (real_T)
    chartInstance->c6_TimeCounter500ms, (real_T)c6_const_Const500ms, 0, 5U,
    chartInstance->c6_TimeCounter500ms >= c6_const_Const500ms) != 0U,
    chartInstance->c6_sfEvent) != 0U)) != 0);
  if (c6_c_out) {
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 9U, chartInstance->c6_sfEvent);
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 11U, chartInstance->c6_sfEvent);
    sf_call_output_fcn_call(chartInstance->S, 8, "ADP_37F_500ms", 0);
    chartInstance->c6_TimeCounter500ms = 0U;
    _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter500ms, 3U);
  } else {
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 10U, chartInstance->c6_sfEvent);
  }

  _SFD_CT_CALL(TRANSITION_BEFORE_PROCESSING_TAG, 12U, chartInstance->c6_sfEvent);
  c6_d_out = (CV_TRANSITION_EVAL(12U, (int32_T)(_SFD_CCP_CALL(5U, 12U, 0,
    (boolean_T)CV_RELATIONAL_EVAL(5U, 12U, 0, (real_T)
    chartInstance->c6_TimeCounter1000ms, (real_T)c6_const_Const1000ms, 0, 5U,
    chartInstance->c6_TimeCounter1000ms >= c6_const_Const1000ms) != 0U,
    chartInstance->c6_sfEvent) != 0U)) != 0);
  if (c6_d_out) {
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 12U, chartInstance->c6_sfEvent);
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 13U, chartInstance->c6_sfEvent);
    sf_call_output_fcn_call(chartInstance->S, 3, "ADP_3AA_1000ms", 0);
    chartInstance->c6_TimeCounter1000ms = 0U;
    _SFD_DATA_RANGE_CHECK((real_T)chartInstance->c6_TimeCounter1000ms, 0U);
  } else {
    _SFD_CT_CALL(TRANSITION_ACTIVE_TAG, 14U, chartInstance->c6_sfEvent);
  }

  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 0U, chartInstance->c6_sfEvent);
  _SFD_SYMBOL_SCOPE_POP();
  _SFD_CHECK_FOR_STATE_INCONSISTENCY(_ADPMachineNumber_,
    chartInstance->chartNumber, chartInstance->instanceNumber);
}

static void mdl_start_c6_ADP(SFc6_ADPInstanceStruct *chartInstance)
{
  c6_init_sf_message_store_memory(chartInstance);
  sim_mode_is_external(chartInstance->S);
}

static void initSimStructsc6_ADP(SFc6_ADPInstanceStruct *chartInstance)
{
  (void)chartInstance;
}

static void init_script_number_translation(uint32_T c6_machineNumber, uint32_T
  c6_chartNumber, uint32_T c6_instanceNumber)
{
  (void)(c6_machineNumber);
  (void)(c6_chartNumber);
  (void)(c6_instanceNumber);
}

const mxArray *sf_c6_ADP_get_eml_resolved_functions_info(void)
{
  const mxArray *c6_nameCaptureInfo = NULL;
  c6_nameCaptureInfo = NULL;
  sf_mex_assign(&c6_nameCaptureInfo, sf_mex_create("nameCaptureInfo", NULL, 0,
    0U, 1U, 0U, 2, 0, 1), false);
  return c6_nameCaptureInfo;
}

static const mxArray *c6_sf_marshallOut(void *chartInstanceVoid, void *c6_inData)
{
  const mxArray *c6_mxArrayOutData;
  int32_T c6_u;
  const mxArray *c6_y = NULL;
  SFc6_ADPInstanceStruct *chartInstance;
  chartInstance = (SFc6_ADPInstanceStruct *)chartInstanceVoid;
  c6_mxArrayOutData = NULL;
  c6_mxArrayOutData = NULL;
  c6_u = *(int32_T *)c6_inData;
  c6_y = NULL;
  sf_mex_assign(&c6_y, sf_mex_create("y", &c6_u, 6, 0U, 0U, 0U, 0), false);
  sf_mex_assign(&c6_mxArrayOutData, c6_y, false);
  return c6_mxArrayOutData;
}

static int32_T c6_emlrt_marshallIn(SFc6_ADPInstanceStruct *chartInstance, const
  mxArray *c6_u, const emlrtMsgIdentifier *c6_parentId)
{
  int32_T c6_y;
  int32_T c6_i4;
  (void)chartInstance;
  sf_mex_import(c6_parentId, sf_mex_dup(c6_u), &c6_i4, 1, 6, 0U, 0, 0U, 0);
  c6_y = c6_i4;
  sf_mex_destroy(&c6_u);
  return c6_y;
}

static void c6_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c6_mxArrayInData, const char_T *c6_varName, void *c6_outData)
{
  const mxArray *c6_b_sfEvent;
  emlrtMsgIdentifier c6_thisId;
  int32_T c6_y;
  SFc6_ADPInstanceStruct *chartInstance;
  chartInstance = (SFc6_ADPInstanceStruct *)chartInstanceVoid;
  c6_b_sfEvent = sf_mex_dup(c6_mxArrayInData);
  c6_thisId.fIdentifier = (const char *)c6_varName;
  c6_thisId.fParent = NULL;
  c6_thisId.bParentIsCell = false;
  c6_y = c6_emlrt_marshallIn(chartInstance, sf_mex_dup(c6_b_sfEvent), &c6_thisId);
  sf_mex_destroy(&c6_b_sfEvent);
  *(int32_T *)c6_outData = c6_y;
  sf_mex_destroy(&c6_mxArrayInData);
}

static const mxArray *c6_b_sf_marshallOut(void *chartInstanceVoid, void
  *c6_inData)
{
  const mxArray *c6_mxArrayOutData;
  uint8_T c6_u;
  const mxArray *c6_y = NULL;
  SFc6_ADPInstanceStruct *chartInstance;
  chartInstance = (SFc6_ADPInstanceStruct *)chartInstanceVoid;
  c6_mxArrayOutData = NULL;
  c6_mxArrayOutData = NULL;
  c6_u = *(uint8_T *)c6_inData;
  c6_y = NULL;
  sf_mex_assign(&c6_y, sf_mex_create("y", &c6_u, 3, 0U, 0U, 0U, 0), false);
  sf_mex_assign(&c6_mxArrayOutData, c6_y, false);
  return c6_mxArrayOutData;
}

static uint8_T c6_b_emlrt_marshallIn(SFc6_ADPInstanceStruct *chartInstance,
  const mxArray *c6_b_TimeCounter20ms, const char_T *c6_identifier)
{
  uint8_T c6_y;
  emlrtMsgIdentifier c6_thisId;
  c6_thisId.fIdentifier = (const char *)c6_identifier;
  c6_thisId.fParent = NULL;
  c6_thisId.bParentIsCell = false;
  c6_y = c6_c_emlrt_marshallIn(chartInstance, sf_mex_dup(c6_b_TimeCounter20ms),
    &c6_thisId);
  sf_mex_destroy(&c6_b_TimeCounter20ms);
  return c6_y;
}

static uint8_T c6_c_emlrt_marshallIn(SFc6_ADPInstanceStruct *chartInstance,
  const mxArray *c6_u, const emlrtMsgIdentifier *c6_parentId)
{
  uint8_T c6_y;
  uint8_T c6_u0;
  (void)chartInstance;
  sf_mex_import(c6_parentId, sf_mex_dup(c6_u), &c6_u0, 1, 3, 0U, 0, 0U, 0);
  c6_y = c6_u0;
  sf_mex_destroy(&c6_u);
  return c6_y;
}

static void c6_b_sf_marshallIn(void *chartInstanceVoid, const mxArray
  *c6_mxArrayInData, const char_T *c6_varName, void *c6_outData)
{
  const mxArray *c6_b_TimeCounter20ms;
  emlrtMsgIdentifier c6_thisId;
  uint8_T c6_y;
  SFc6_ADPInstanceStruct *chartInstance;
  chartInstance = (SFc6_ADPInstanceStruct *)chartInstanceVoid;
  c6_b_TimeCounter20ms = sf_mex_dup(c6_mxArrayInData);
  c6_thisId.fIdentifier = (const char *)c6_varName;
  c6_thisId.fParent = NULL;
  c6_thisId.bParentIsCell = false;
  c6_y = c6_c_emlrt_marshallIn(chartInstance, sf_mex_dup(c6_b_TimeCounter20ms),
    &c6_thisId);
  sf_mex_destroy(&c6_b_TimeCounter20ms);
  *(uint8_T *)c6_outData = c6_y;
  sf_mex_destroy(&c6_mxArrayInData);
}

static const mxArray *c6_d_emlrt_marshallIn(SFc6_ADPInstanceStruct
  *chartInstance, const mxArray *c6_b_setSimStateSideEffectsInfo, const char_T
  *c6_identifier)
{
  const mxArray *c6_y = NULL;
  emlrtMsgIdentifier c6_thisId;
  c6_y = NULL;
  c6_thisId.fIdentifier = (const char *)c6_identifier;
  c6_thisId.fParent = NULL;
  c6_thisId.bParentIsCell = false;
  sf_mex_assign(&c6_y, c6_e_emlrt_marshallIn(chartInstance, sf_mex_dup
    (c6_b_setSimStateSideEffectsInfo), &c6_thisId), false);
  sf_mex_destroy(&c6_b_setSimStateSideEffectsInfo);
  return c6_y;
}

static const mxArray *c6_e_emlrt_marshallIn(SFc6_ADPInstanceStruct
  *chartInstance, const mxArray *c6_u, const emlrtMsgIdentifier *c6_parentId)
{
  const mxArray *c6_y = NULL;
  (void)chartInstance;
  (void)c6_parentId;
  c6_y = NULL;
  sf_mex_assign(&c6_y, sf_mex_duplicatearraysafe(&c6_u), false);
  sf_mex_destroy(&c6_u);
  return c6_y;
}

static const mxArray *sf_get_hover_data_for_msg(SFc6_ADPInstanceStruct
  *chartInstance, int32_T c6_ssid)
{
  (void)chartInstance;
  (void)c6_ssid;
  return NULL;
}

static void c6_init_sf_message_store_memory(SFc6_ADPInstanceStruct
  *chartInstance)
{
  (void)chartInstance;
}

static int32_T c6__s32_add__(SFc6_ADPInstanceStruct *chartInstance, int32_T c6_b,
  int32_T c6_c, uint32_T c6_ssid_src_loc, int32_T c6_offset_src_loc, int32_T
  c6_length_src_loc)
{
  int32_T c6_a;
  (void)chartInstance;
  c6_a = c6_b + c6_c;
  if (((c6_a ^ c6_b) & (c6_a ^ c6_c)) < 0) {
    _SFD_OVERFLOW_DETECTION(SFDB_OVERFLOW, c6_ssid_src_loc, c6_offset_src_loc,
      c6_length_src_loc);
  }

  return c6_a;
}

static void init_dsm_address_info(SFc6_ADPInstanceStruct *chartInstance)
{
  (void)chartInstance;
}

static void init_simulink_io_address(SFc6_ADPInstanceStruct *chartInstance)
{
  chartInstance->c6_fEmlrtCtx = (void *)sfrtGetEmlrtCtx(chartInstance->S);
}

/* SFunction Glue Code */
#ifdef utFree
#undef utFree
#endif

#ifdef utMalloc
#undef utMalloc
#endif

#ifdef __cplusplus

extern "C" void *utMalloc(size_t size);
extern "C" void utFree(void*);

#else

extern void *utMalloc(size_t size);
extern void utFree(void*);

#endif

void sf_c6_ADP_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(3171834564U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(1763103840U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(3821874131U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(4106068068U);
}

mxArray* sf_c6_ADP_get_post_codegen_info(void);
mxArray *sf_c6_ADP_get_autoinheritance_info(void)
{
  const char *autoinheritanceFields[] = { "checksum", "inputs", "parameters",
    "outputs", "locals", "postCodegenInfo" };

  mxArray *mxAutoinheritanceInfo = mxCreateStructMatrix(1, 1, sizeof
    (autoinheritanceFields)/sizeof(autoinheritanceFields[0]),
    autoinheritanceFields);

  {
    mxArray *mxChecksum = mxCreateString("DKZYLrRRZMBUciWUavJkYB");
    mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum);
  }

  {
    mxSetField(mxAutoinheritanceInfo,0,"inputs",mxCreateDoubleMatrix(0,0,mxREAL));
  }

  {
    mxSetField(mxAutoinheritanceInfo,0,"parameters",mxCreateDoubleMatrix(0,0,
                mxREAL));
  }

  {
    mxSetField(mxAutoinheritanceInfo,0,"outputs",mxCreateDoubleMatrix(0,0,mxREAL));
  }

  {
    mxSetField(mxAutoinheritanceInfo,0,"locals",mxCreateDoubleMatrix(0,0,mxREAL));
  }

  {
    mxArray* mxPostCodegenInfo = sf_c6_ADP_get_post_codegen_info();
    mxSetField(mxAutoinheritanceInfo,0,"postCodegenInfo",mxPostCodegenInfo);
  }

  return(mxAutoinheritanceInfo);
}

mxArray *sf_c6_ADP_third_party_uses_info(void)
{
  mxArray * mxcell3p = mxCreateCellMatrix(1,0);
  return(mxcell3p);
}

mxArray *sf_c6_ADP_jit_fallback_info(void)
{
  const char *infoFields[] = { "fallbackType", "fallbackReason",
    "hiddenFallbackType", "hiddenFallbackReason", "incompatibleSymbol" };

  mxArray *mxInfo = mxCreateStructMatrix(1, 1, 5, infoFields);
  mxArray *fallbackType = mxCreateString("pre");
  mxArray *fallbackReason = mxCreateString("needsCoverage");
  mxArray *hiddenFallbackType = mxCreateString("none");
  mxArray *hiddenFallbackReason = mxCreateString("");
  mxArray *incompatibleSymbol = mxCreateString("");
  mxSetField(mxInfo, 0, infoFields[0], fallbackType);
  mxSetField(mxInfo, 0, infoFields[1], fallbackReason);
  mxSetField(mxInfo, 0, infoFields[2], hiddenFallbackType);
  mxSetField(mxInfo, 0, infoFields[3], hiddenFallbackReason);
  mxSetField(mxInfo, 0, infoFields[4], incompatibleSymbol);
  return mxInfo;
}

mxArray *sf_c6_ADP_updateBuildInfo_args_info(void)
{
  mxArray *mxBIArgs = mxCreateCellMatrix(1,0);
  return mxBIArgs;
}

mxArray* sf_c6_ADP_get_post_codegen_info(void)
{
  const char* fieldNames[] = { "exportedFunctionsUsedByThisChart",
    "exportedFunctionsChecksum" };

  mwSize dims[2] = { 1, 1 };

  mxArray* mxPostCodegenInfo = mxCreateStructArray(2, dims, sizeof(fieldNames)/
    sizeof(fieldNames[0]), fieldNames);

  {
    mxArray* mxExportedFunctionsChecksum = mxCreateString("");
    mwSize exp_dims[2] = { 0, 1 };

    mxArray* mxExportedFunctionsUsedByThisChart = mxCreateCellArray(2, exp_dims);
    mxSetField(mxPostCodegenInfo, 0, "exportedFunctionsUsedByThisChart",
               mxExportedFunctionsUsedByThisChart);
    mxSetField(mxPostCodegenInfo, 0, "exportedFunctionsChecksum",
               mxExportedFunctionsChecksum);
  }

  return mxPostCodegenInfo;
}

static const mxArray *sf_get_sim_state_info_c6_ADP(void)
{
  const char *infoFields[] = { "chartChecksum", "varInfo" };

  mxArray *mxInfo = mxCreateStructMatrix(1, 1, 2, infoFields);
  const char *infoEncStr[] = {
    "100 S1x5'type','srcId','name','auxInfo'{{M[3],M[508],T\"TimeCounter1000ms\",},{M[3],M[499],T\"TimeCounter100ms\",},{M[3],M[497],T\"TimeCounter20ms\",},{M[3],M[502],T\"TimeCounter500ms\",},{M[8],M[0],T\"is_active_c6_ADP\",}}"
  };

  mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 5, 10);
  mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL);
  sf_c6_ADP_get_check_sum(&mxChecksum);
  mxSetField(mxInfo, 0, infoFields[0], mxChecksum);
  mxSetField(mxInfo, 0, infoFields[1], mxVarInfo);
  return mxInfo;
}

static const mxArray* sf_opaque_get_hover_data_for_msg(void* chartInstance,
  int32_T msgSSID)
{
  return sf_get_hover_data_for_msg( (SFc6_ADPInstanceStruct *) chartInstance,
    msgSSID);
}

static void chart_debug_initialization(SimStruct *S, unsigned int
  fullDebuggerInitialization)
{
  if (!sim_mode_is_rtw_gen(S)) {
    SFc6_ADPInstanceStruct *chartInstance = (SFc6_ADPInstanceStruct *)
      sf_get_chart_instance_ptr(S);
    if (ssIsFirstInitCond(S) && fullDebuggerInitialization==1) {
      /* do this only if simulation is starting */
      {
        unsigned int chartAlreadyPresent;
        chartAlreadyPresent = sf_debug_initialize_chart
          (sfGlobalDebugInstanceStruct,
           _ADPMachineNumber_,
           6,
           0,
           15,
           0,
           8,
           12,
           0,
           0,
           0,
           0,
           &chartInstance->chartNumber,
           &chartInstance->instanceNumber,
           (void *)S);

        /* Each instance must initialize its own list of scripts */
        init_script_number_translation(_ADPMachineNumber_,
          chartInstance->chartNumber,chartInstance->instanceNumber);
        if (chartAlreadyPresent==0) {
          /* this is the first instance */
          sf_debug_set_chart_disable_implicit_casting
            (sfGlobalDebugInstanceStruct,_ADPMachineNumber_,
             chartInstance->chartNumber,1);
          sf_debug_set_chart_event_thresholds(sfGlobalDebugInstanceStruct,
            _ADPMachineNumber_,
            chartInstance->chartNumber,
            12,
            12,
            12);
          _SFD_SET_DATA_PROPS(0,0,0,0,"TimeCounter1000ms");
          _SFD_SET_DATA_PROPS(1,0,0,0,"TimeCounter100ms");
          _SFD_SET_DATA_PROPS(2,0,0,0,"TimeCounter20ms");
          _SFD_SET_DATA_PROPS(3,0,0,0,"TimeCounter500ms");
          _SFD_SET_DATA_PROPS(4,7,0,0,"Const1000ms");
          _SFD_SET_DATA_PROPS(5,7,0,0,"Const100ms");
          _SFD_SET_DATA_PROPS(6,7,0,0,"Const20ms");
          _SFD_SET_DATA_PROPS(7,7,0,0,"Const500ms");
          _SFD_EVENT_SCOPE(0,2);
          _SFD_EVENT_SCOPE(1,2);
          _SFD_EVENT_SCOPE(2,2);
          _SFD_EVENT_SCOPE(3,2);
          _SFD_EVENT_SCOPE(4,2);
          _SFD_EVENT_SCOPE(5,2);
          _SFD_EVENT_SCOPE(6,2);
          _SFD_EVENT_SCOPE(7,2);
          _SFD_EVENT_SCOPE(8,2);
          _SFD_EVENT_SCOPE(9,2);
          _SFD_EVENT_SCOPE(10,2);
          _SFD_EVENT_SCOPE(11,2);
          _SFD_CH_SUBSTATE_COUNT(0);
          _SFD_CH_SUBSTATE_DECOMP(0);
        }

        _SFD_CV_INIT_CHART(0,0,0,0);
        _SFD_CV_INIT_TRANS(3,0,NULL,NULL,0,NULL);
        _SFD_CV_INIT_TRANS(1,0,NULL,NULL,0,NULL);
        _SFD_CV_INIT_TRANS(2,0,NULL,NULL,0,NULL);

        {
          static unsigned int sStartSaturateMap[] = { 22, 2, 43, 64 };

          static unsigned int sEndSaturateMap[] = { 41, 20, 62, 84 };

          _SFD_CV_INIT_TRANSITION_SATURATION(2,4,&(sStartSaturateMap[0]),
            &(sEndSaturateMap[0]));
        }

        {
          static unsigned int sStartGuardMap[] = { 1 };

          static unsigned int sEndGuardMap[] = { 29 };

          static int sPostFixPredicateTree[] = { 0 };

          _SFD_CV_INIT_TRANS(0,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,
                             &(sPostFixPredicateTree[0]));
        }

        {
          static unsigned int sStartRelationalopMap[] = { 1 };

          static unsigned int sEndRelationalopMap[] = { 29 };

          static int sRelationalopEps[] = { 0 };

          static int sRelationalopType[] = { 5 };

          _SFD_CV_INIT_TRANSITION_RELATIONALOP(0,1,&(sStartRelationalopMap[0]),
            &(sEndRelationalopMap[0]),&(sRelationalopEps[0]),
            &(sRelationalopType[0]));
        }

        _SFD_CV_INIT_TRANS(5,0,NULL,NULL,0,NULL);
        _SFD_CV_INIT_TRANS(4,0,NULL,NULL,0,NULL);

        {
          static unsigned int sStartGuardMap[] = { 1 };

          static unsigned int sEndGuardMap[] = { 31 };

          static int sPostFixPredicateTree[] = { 0 };

          _SFD_CV_INIT_TRANS(6,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,
                             &(sPostFixPredicateTree[0]));
        }

        {
          static unsigned int sStartRelationalopMap[] = { 1 };

          static unsigned int sEndRelationalopMap[] = { 31 };

          static int sRelationalopEps[] = { 0 };

          static int sRelationalopType[] = { 5 };

          _SFD_CV_INIT_TRANSITION_RELATIONALOP(6,1,&(sStartRelationalopMap[0]),
            &(sEndRelationalopMap[0]),&(sRelationalopEps[0]),
            &(sRelationalopType[0]));
        }

        _SFD_CV_INIT_TRANS(8,0,NULL,NULL,0,NULL);
        _SFD_CV_INIT_TRANS(7,0,NULL,NULL,0,NULL);

        {
          static unsigned int sStartGuardMap[] = { 1 };

          static unsigned int sEndGuardMap[] = { 31 };

          static int sPostFixPredicateTree[] = { 0 };

          _SFD_CV_INIT_TRANS(9,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,
                             &(sPostFixPredicateTree[0]));
        }

        {
          static unsigned int sStartRelationalopMap[] = { 1 };

          static unsigned int sEndRelationalopMap[] = { 31 };

          static int sRelationalopEps[] = { 0 };

          static int sRelationalopType[] = { 5 };

          _SFD_CV_INIT_TRANSITION_RELATIONALOP(9,1,&(sStartRelationalopMap[0]),
            &(sEndRelationalopMap[0]),&(sRelationalopEps[0]),
            &(sRelationalopType[0]));
        }

        _SFD_CV_INIT_TRANS(10,0,NULL,NULL,0,NULL);
        _SFD_CV_INIT_TRANS(11,0,NULL,NULL,0,NULL);

        {
          static unsigned int sStartGuardMap[] = { 1 };

          static unsigned int sEndGuardMap[] = { 33 };

          static int sPostFixPredicateTree[] = { 0 };

          _SFD_CV_INIT_TRANS(12,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,
                             &(sPostFixPredicateTree[0]));
        }

        {
          static unsigned int sStartRelationalopMap[] = { 1 };

          static unsigned int sEndRelationalopMap[] = { 33 };

          static int sRelationalopEps[] = { 0 };

          static int sRelationalopType[] = { 5 };

          _SFD_CV_INIT_TRANSITION_RELATIONALOP(12,1,&(sStartRelationalopMap[0]),
            &(sEndRelationalopMap[0]),&(sRelationalopEps[0]),
            &(sRelationalopType[0]));
        }

        _SFD_CV_INIT_TRANS(14,0,NULL,NULL,0,NULL);
        _SFD_CV_INIT_TRANS(13,0,NULL,NULL,0,NULL);
        _SFD_SET_DATA_COMPILED_PROPS(0,SF_UINT8,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c6_b_sf_marshallOut,(MexInFcnForType)c6_b_sf_marshallIn);
        _SFD_SET_DATA_COMPILED_PROPS(1,SF_UINT8,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c6_b_sf_marshallOut,(MexInFcnForType)c6_b_sf_marshallIn);
        _SFD_SET_DATA_COMPILED_PROPS(2,SF_UINT8,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c6_b_sf_marshallOut,(MexInFcnForType)c6_b_sf_marshallIn);
        _SFD_SET_DATA_COMPILED_PROPS(3,SF_UINT8,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c6_b_sf_marshallOut,(MexInFcnForType)c6_b_sf_marshallIn);
        _SFD_SET_DATA_COMPILED_PROPS(4,SF_UINT8,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c6_b_sf_marshallOut,(MexInFcnForType)NULL);
        _SFD_SET_DATA_COMPILED_PROPS(5,SF_UINT8,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c6_b_sf_marshallOut,(MexInFcnForType)NULL);
        _SFD_SET_DATA_COMPILED_PROPS(6,SF_UINT8,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c6_b_sf_marshallOut,(MexInFcnForType)NULL);
        _SFD_SET_DATA_COMPILED_PROPS(7,SF_UINT8,0,NULL,0,0,0,0.0,1.0,0,0,
          (MexFcnForType)c6_b_sf_marshallOut,(MexInFcnForType)NULL);
      }
    } else {
      sf_debug_reset_current_state_configuration(sfGlobalDebugInstanceStruct,
        _ADPMachineNumber_,chartInstance->chartNumber,
        chartInstance->instanceNumber);
    }
  }
}

static void chart_debug_initialize_data_addresses(SimStruct *S)
{
  if (!sim_mode_is_rtw_gen(S)) {
    SFc6_ADPInstanceStruct *chartInstance = (SFc6_ADPInstanceStruct *)
      sf_get_chart_instance_ptr(S);
    if (ssIsFirstInitCond(S)) {
      /* do this only if simulation is starting and after we know the addresses of all data */
      {
        _SFD_SET_DATA_VALUE_PTR(2U, (void *)&chartInstance->c6_TimeCounter20ms);
        _SFD_SET_DATA_VALUE_PTR(5U, (void *)&chartInstance->c6_Const100ms);
        _SFD_SET_DATA_VALUE_PTR(1U, (void *)&chartInstance->c6_TimeCounter100ms);
        _SFD_SET_DATA_VALUE_PTR(6U, (void *)&chartInstance->c6_Const20ms);
        _SFD_SET_DATA_VALUE_PTR(7U, (void *)&chartInstance->c6_Const500ms);
        _SFD_SET_DATA_VALUE_PTR(3U, (void *)&chartInstance->c6_TimeCounter500ms);
        _SFD_SET_DATA_VALUE_PTR(0U, (void *)&chartInstance->c6_TimeCounter1000ms);
        _SFD_SET_DATA_VALUE_PTR(4U, (void *)&chartInstance->c6_Const1000ms);
      }
    }
  }
}

static const char* sf_get_instance_specialization(void)
{
  return "skY6fCCtYI6wJcmc2ovt1vF";
}

static void sf_opaque_initialize_c6_ADP(void *chartInstanceVar)
{
  chart_debug_initialization(((SFc6_ADPInstanceStruct*) chartInstanceVar)->S,0);
  initialize_params_c6_ADP((SFc6_ADPInstanceStruct*) chartInstanceVar);
  initialize_c6_ADP((SFc6_ADPInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_enable_c6_ADP(void *chartInstanceVar)
{
  enable_c6_ADP((SFc6_ADPInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_disable_c6_ADP(void *chartInstanceVar)
{
  disable_c6_ADP((SFc6_ADPInstanceStruct*) chartInstanceVar);
}

static void sf_opaque_gateway_c6_ADP(void *chartInstanceVar)
{
  sf_gateway_c6_ADP((SFc6_ADPInstanceStruct*) chartInstanceVar);
}

static const mxArray* sf_opaque_get_sim_state_c6_ADP(SimStruct* S)
{
  return get_sim_state_c6_ADP((SFc6_ADPInstanceStruct *)
    sf_get_chart_instance_ptr(S));     /* raw sim ctx */
}

static void sf_opaque_set_sim_state_c6_ADP(SimStruct* S, const mxArray *st)
{
  set_sim_state_c6_ADP((SFc6_ADPInstanceStruct*)sf_get_chart_instance_ptr(S), st);
}

static void sf_opaque_terminate_c6_ADP(void *chartInstanceVar)
{
  if (chartInstanceVar!=NULL) {
    SimStruct *S = ((SFc6_ADPInstanceStruct*) chartInstanceVar)->S;
    if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
      sf_clear_rtw_identifier(S);
      unload_ADP_optimization_info();
    }

    finalize_c6_ADP((SFc6_ADPInstanceStruct*) chartInstanceVar);
    utFree(chartInstanceVar);
    if (ssGetUserData(S)!= NULL) {
      sf_free_ChartRunTimeInfo(S);
    }

    ssSetUserData(S,NULL);
  }
}

static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar)
{
  initSimStructsc6_ADP((SFc6_ADPInstanceStruct*) chartInstanceVar);
}

extern unsigned int sf_machine_global_initializer_called(void);
static void mdlProcessParameters_c6_ADP(SimStruct *S)
{
  int i;
  for (i=0;i<ssGetNumRunTimeParams(S);i++) {
    if (ssGetSFcnParamTunable(S,i)) {
      ssUpdateDlgParamAsRunTimeParam(S,i);
    }
  }

  if (sf_machine_global_initializer_called()) {
    initialize_params_c6_ADP((SFc6_ADPInstanceStruct*)sf_get_chart_instance_ptr
      (S));
  }
}

static void mdlSetWorkWidths_c6_ADP(SimStruct *S)
{
  ssSetInputPortDirectFeedThrough(S, 0, 1);
  ssSetStatesModifiedOnlyInUpdate(S, 0);
  ssSetBlockIsPurelyCombinatorial_wrapper(S, 0);
  ssMdlUpdateIsEmpty(S, 1);
  if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) {
    mxArray *infoStruct = load_ADP_optimization_info(sim_mode_is_rtw_gen(S),
      sim_mode_is_modelref_sim(S), sim_mode_is_external(S));
    int_T chartIsInlinable =
      (int_T)sf_is_chart_inlinable(sf_get_instance_specialization(),infoStruct,6);
    ssSetStateflowIsInlinable(S,chartIsInlinable);
    ssSetRTWCG(S,1);
    ssSetEnableFcnIsTrivial(S,1);
    ssSetDisableFcnIsTrivial(S,1);
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop
      (sf_get_instance_specialization(),infoStruct,6,
       "gatewayCannotBeInlinedMultipleTimes"));
    sf_set_chart_accesses_machine_info(S, sf_get_instance_specialization(),
      infoStruct, 6);
    sf_update_buildInfo(S, sf_get_instance_specialization(),infoStruct,6);
    sf_mark_output_events_with_multiple_callers(S,sf_get_instance_specialization
      (),infoStruct,6,12);
    if (chartIsInlinable) {
    }

    {
      unsigned int outPortIdx;
      for (outPortIdx=1; outPortIdx<=0; ++outPortIdx) {
        ssSetOutputPortOptimizeInIR(S, outPortIdx, 1U);
      }
    }

    sf_set_rtw_dwork_info(S,sf_get_instance_specialization(),infoStruct,6);
    sf_register_codegen_names_for_scoped_functions_defined_by_chart(S);
    ssSetHasSubFunctions(S,!(chartIsInlinable));
  } else {
  }

  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  ssSetChecksum0(S,(4128325450U));
  ssSetChecksum1(S,(3420336328U));
  ssSetChecksum2(S,(3804462684U));
  ssSetChecksum3(S,(1403994749U));
  ssSetmdlDerivatives(S, NULL);
  ssSetExplicitFCSSCtrl(S,1);
  ssSetStateSemanticsClassicAndSynchronous(S, true);
  ssSupportsMultipleExecInstances(S,1);
}

static void mdlRTW_c6_ADP(SimStruct *S)
{
  if (sim_mode_is_rtw_gen(S)) {
    ssWriteRTWStrParam(S, "StateflowChartType", "Stateflow");
  }
}

static void mdlStart_c6_ADP(SimStruct *S)
{
  SFc6_ADPInstanceStruct *chartInstance;
  chartInstance = (SFc6_ADPInstanceStruct *)utMalloc(sizeof
    (SFc6_ADPInstanceStruct));
  if (chartInstance==NULL) {
    sf_mex_error_message("Could not allocate memory for chart instance.");
  }

  memset(chartInstance, 0, sizeof(SFc6_ADPInstanceStruct));
  chartInstance->chartInfo.chartInstance = chartInstance;
  chartInstance->chartInfo.isEMLChart = 0;
  chartInstance->chartInfo.chartInitialized = 0;
  chartInstance->chartInfo.sFunctionGateway = sf_opaque_gateway_c6_ADP;
  chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c6_ADP;
  chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c6_ADP;
  chartInstance->chartInfo.enableChart = sf_opaque_enable_c6_ADP;
  chartInstance->chartInfo.disableChart = sf_opaque_disable_c6_ADP;
  chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c6_ADP;
  chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c6_ADP;
  chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c6_ADP;
  chartInstance->chartInfo.zeroCrossings = NULL;
  chartInstance->chartInfo.outputs = NULL;
  chartInstance->chartInfo.derivatives = NULL;
  chartInstance->chartInfo.mdlRTW = mdlRTW_c6_ADP;
  chartInstance->chartInfo.mdlStart = mdlStart_c6_ADP;
  chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c6_ADP;
  chartInstance->chartInfo.callGetHoverDataForMsg =
    sf_opaque_get_hover_data_for_msg;
  chartInstance->chartInfo.extModeExec = NULL;
  chartInstance->chartInfo.restoreLastMajorStepConfiguration = NULL;
  chartInstance->chartInfo.restoreBeforeLastMajorStepConfiguration = NULL;
  chartInstance->chartInfo.storeCurrentConfiguration = NULL;
  chartInstance->chartInfo.callAtomicSubchartUserFcn = NULL;
  chartInstance->chartInfo.callAtomicSubchartAutoFcn = NULL;
  chartInstance->chartInfo.debugInstance = sfGlobalDebugInstanceStruct;
  chartInstance->S = S;
  sf_init_ChartRunTimeInfo(S, &(chartInstance->chartInfo), false, 0);
  init_dsm_address_info(chartInstance);
  init_simulink_io_address(chartInstance);
  if (!sim_mode_is_rtw_gen(S)) {
  }

  chart_debug_initialization(S,1);
  mdl_start_c6_ADP(chartInstance);
}

void c6_ADP_method_dispatcher(SimStruct *S, int_T method, void *data)
{
  switch (method) {
   case SS_CALL_MDL_START:
    mdlStart_c6_ADP(S);
    break;

   case SS_CALL_MDL_SET_WORK_WIDTHS:
    mdlSetWorkWidths_c6_ADP(S);
    break;

   case SS_CALL_MDL_PROCESS_PARAMETERS:
    mdlProcessParameters_c6_ADP(S);
    break;

   default:
    /* Unhandled method */
    sf_mex_error_message("Stateflow Internal Error:\n"
                         "Error calling c6_ADP_method_dispatcher.\n"
                         "Can't handle method %d.\n", method);
    break;
  }
}
