www.pudn.com > pi_svpwm.zip > c3_mpc_svpwm.c, change:2014-03-20,size:47317b


/* Include files */ 
 
#include <stddef.h> 
#include "blas.h" 
#include "mpc_svpwm_sfun.h" 
#include "c3_mpc_svpwm.h" 
#define CHARTINSTANCE_CHARTNUMBER      (chartInstance->chartNumber) 
#define CHARTINSTANCE_INSTANCENUMBER   (chartInstance->instanceNumber) 
#include "mpc_svpwm_sfun_debug_macros.h" 
#define _SF_MEX_LISTEN_FOR_CTRL_C(S)   sf_mex_listen_for_ctrl_c(sfGlobalDebugInstanceStruct,S); 
 
/* Type Definitions */ 
 
/* Named Constants */ 
#define CALL_EVENT                     (-1) 
 
/* Variable Declarations */ 
 
/* Variable Definitions */ 
static const char * c3_debug_family_names[10] = { "C2r2s", "Iab", "nargin", 
  "nargout", "id_ref", "iq_ref", "cosu", "sinu", "iD_ref", "iQ_ref" }; 
 
/* Function Declarations */ 
static void initialize_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance); 
static void initialize_params_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance); 
static void enable_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance); 
static void disable_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance); 
static void c3_update_debugger_state_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance); 
static const mxArray *get_sim_state_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance); 
static void set_sim_state_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance, const mxArray *c3_st); 
static void finalize_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance); 
static void sf_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance); 
static void c3_chartstep_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance); 
static void initSimStructsc3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance); 
static void registerMessagesc3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance); 
static void init_script_number_translation(uint32_T c3_machineNumber, uint32_T 
  c3_chartNumber); 
static const mxArray *c3_sf_marshallOut(void *chartInstanceVoid, void *c3_inData); 
static real_T c3_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_iQ_ref, const char_T *c3_identifier); 
static real_T c3_b_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId); 
static void c3_sf_marshallIn(void *chartInstanceVoid, const mxArray 
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData); 
static const mxArray *c3_b_sf_marshallOut(void *chartInstanceVoid, void 
  *c3_inData); 
static void c3_c_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId, real_T c3_y[2]); 
static void c3_b_sf_marshallIn(void *chartInstanceVoid, const mxArray 
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData); 
static const mxArray *c3_c_sf_marshallOut(void *chartInstanceVoid, void 
  *c3_inData); 
static void c3_d_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId, real_T c3_y[4]); 
static void c3_c_sf_marshallIn(void *chartInstanceVoid, const mxArray 
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData); 
static void c3_eml_scalar_eg(SFc3_mpc_svpwmInstanceStruct *chartInstance); 
static const mxArray *c3_d_sf_marshallOut(void *chartInstanceVoid, void 
  *c3_inData); 
static int32_T c3_e_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId); 
static void c3_d_sf_marshallIn(void *chartInstanceVoid, const mxArray 
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData); 
static uint8_T c3_f_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_b_is_active_c3_mpc_svpwm, const char_T *c3_identifier); 
static uint8_T c3_g_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId); 
static void init_dsm_address_info(SFc3_mpc_svpwmInstanceStruct *chartInstance); 
 
/* Function Definitions */ 
static void initialize_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance) 
{ 
  chartInstance->c3_sfEvent = CALL_EVENT; 
  _sfTime_ = (real_T)ssGetT(chartInstance->S); 
  chartInstance->c3_is_active_c3_mpc_svpwm = 0U; 
} 
 
static void initialize_params_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance) 
{ 
} 
 
static void enable_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance) 
{ 
  _sfTime_ = (real_T)ssGetT(chartInstance->S); 
} 
 
static void disable_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance) 
{ 
  _sfTime_ = (real_T)ssGetT(chartInstance->S); 
} 
 
static void c3_update_debugger_state_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance) 
{ 
} 
 
static const mxArray *get_sim_state_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance) 
{ 
  const mxArray *c3_st; 
  const mxArray *c3_y = NULL; 
  real_T c3_hoistedGlobal; 
  real_T c3_u; 
  const mxArray *c3_b_y = NULL; 
  real_T c3_b_hoistedGlobal; 
  real_T c3_b_u; 
  const mxArray *c3_c_y = NULL; 
  uint8_T c3_c_hoistedGlobal; 
  uint8_T c3_c_u; 
  const mxArray *c3_d_y = NULL; 
  real_T *c3_iD_ref; 
  real_T *c3_iQ_ref; 
  c3_iQ_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2); 
  c3_iD_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1); 
  c3_st = NULL; 
  c3_st = NULL; 
  c3_y = NULL; 
  sf_mex_assign(&c3_y, sf_mex_createcellarray(3), FALSE); 
  c3_hoistedGlobal = *c3_iD_ref; 
  c3_u = c3_hoistedGlobal; 
  c3_b_y = NULL; 
  sf_mex_assign(&c3_b_y, sf_mex_create("y", &c3_u, 0, 0U, 0U, 0U, 0), FALSE); 
  sf_mex_setcell(c3_y, 0, c3_b_y); 
  c3_b_hoistedGlobal = *c3_iQ_ref; 
  c3_b_u = c3_b_hoistedGlobal; 
  c3_c_y = NULL; 
  sf_mex_assign(&c3_c_y, sf_mex_create("y", &c3_b_u, 0, 0U, 0U, 0U, 0), FALSE); 
  sf_mex_setcell(c3_y, 1, c3_c_y); 
  c3_c_hoistedGlobal = chartInstance->c3_is_active_c3_mpc_svpwm; 
  c3_c_u = c3_c_hoistedGlobal; 
  c3_d_y = NULL; 
  sf_mex_assign(&c3_d_y, sf_mex_create("y", &c3_c_u, 3, 0U, 0U, 0U, 0), FALSE); 
  sf_mex_setcell(c3_y, 2, c3_d_y); 
  sf_mex_assign(&c3_st, c3_y, FALSE); 
  return c3_st; 
} 
 
static void set_sim_state_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance, const mxArray *c3_st) 
{ 
  const mxArray *c3_u; 
  real_T *c3_iD_ref; 
  real_T *c3_iQ_ref; 
  c3_iQ_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2); 
  c3_iD_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1); 
  chartInstance->c3_doneDoubleBufferReInit = TRUE; 
  c3_u = sf_mex_dup(c3_st); 
  *c3_iD_ref = c3_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 
    0)), "iD_ref"); 
  *c3_iQ_ref = c3_emlrt_marshallIn(chartInstance, sf_mex_dup(sf_mex_getcell(c3_u, 
    1)), "iQ_ref"); 
  chartInstance->c3_is_active_c3_mpc_svpwm = c3_f_emlrt_marshallIn(chartInstance, 
    sf_mex_dup(sf_mex_getcell(c3_u, 2)), "is_active_c3_mpc_svpwm"); 
  sf_mex_destroy(&c3_u); 
  c3_update_debugger_state_c3_mpc_svpwm(chartInstance); 
  sf_mex_destroy(&c3_st); 
} 
 
static void finalize_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance) 
{ 
} 
 
static void sf_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct *chartInstance) 
{ 
  real_T *c3_id_ref; 
  real_T *c3_iq_ref; 
  real_T *c3_iD_ref; 
  real_T *c3_iQ_ref; 
  real_T *c3_cosu; 
  real_T *c3_sinu; 
  c3_sinu = (real_T *)ssGetInputPortSignal(chartInstance->S, 3); 
  c3_cosu = (real_T *)ssGetInputPortSignal(chartInstance->S, 2); 
  c3_iQ_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2); 
  c3_iD_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1); 
  c3_iq_ref = (real_T *)ssGetInputPortSignal(chartInstance->S, 1); 
  c3_id_ref = (real_T *)ssGetInputPortSignal(chartInstance->S, 0); 
  _sfTime_ = (real_T)ssGetT(chartInstance->S); 
  _SFD_CC_CALL(CHART_ENTER_SFUNCTION_TAG, 0U, chartInstance->c3_sfEvent); 
  _SFD_DATA_RANGE_CHECK(*c3_id_ref, 0U); 
  _SFD_DATA_RANGE_CHECK(*c3_iq_ref, 1U); 
  _SFD_DATA_RANGE_CHECK(*c3_iD_ref, 2U); 
  _SFD_DATA_RANGE_CHECK(*c3_iQ_ref, 3U); 
  _SFD_DATA_RANGE_CHECK(*c3_cosu, 4U); 
  _SFD_DATA_RANGE_CHECK(*c3_sinu, 5U); 
  chartInstance->c3_sfEvent = CALL_EVENT; 
  c3_chartstep_c3_mpc_svpwm(chartInstance); 
  _SFD_CHECK_FOR_STATE_INCONSISTENCY(_mpc_svpwmMachineNumber_, 
    chartInstance->chartNumber, chartInstance->instanceNumber); 
} 
 
static void c3_chartstep_c3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance) 
{ 
  real_T c3_hoistedGlobal; 
  real_T c3_b_hoistedGlobal; 
  real_T c3_c_hoistedGlobal; 
  real_T c3_d_hoistedGlobal; 
  real_T c3_id_ref; 
  real_T c3_iq_ref; 
  real_T c3_cosu; 
  real_T c3_sinu; 
  uint32_T c3_debug_family_var_map[10]; 
  real_T c3_C2r2s[4]; 
  real_T c3_Iab[2]; 
  real_T c3_nargin = 4.0; 
  real_T c3_nargout = 2.0; 
  real_T c3_iD_ref; 
  real_T c3_iQ_ref; 
  int32_T c3_i0; 
  real_T c3_a[4]; 
  real_T c3_b[2]; 
  int32_T c3_i1; 
  int32_T c3_i2; 
  int32_T c3_i3; 
  real_T c3_C[2]; 
  int32_T c3_i4; 
  int32_T c3_i5; 
  int32_T c3_i6; 
  int32_T c3_i7; 
  int32_T c3_i8; 
  int32_T c3_i9; 
  real_T *c3_b_id_ref; 
  real_T *c3_b_iq_ref; 
  real_T *c3_b_cosu; 
  real_T *c3_b_sinu; 
  real_T *c3_b_iD_ref; 
  real_T *c3_b_iQ_ref; 
  c3_b_sinu = (real_T *)ssGetInputPortSignal(chartInstance->S, 3); 
  c3_b_cosu = (real_T *)ssGetInputPortSignal(chartInstance->S, 2); 
  c3_b_iQ_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2); 
  c3_b_iD_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1); 
  c3_b_iq_ref = (real_T *)ssGetInputPortSignal(chartInstance->S, 1); 
  c3_b_id_ref = (real_T *)ssGetInputPortSignal(chartInstance->S, 0); 
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG, 0U, chartInstance->c3_sfEvent); 
  c3_hoistedGlobal = *c3_b_id_ref; 
  c3_b_hoistedGlobal = *c3_b_iq_ref; 
  c3_c_hoistedGlobal = *c3_b_cosu; 
  c3_d_hoistedGlobal = *c3_b_sinu; 
  c3_id_ref = c3_hoistedGlobal; 
  c3_iq_ref = c3_b_hoistedGlobal; 
  c3_cosu = c3_c_hoistedGlobal; 
  c3_sinu = c3_d_hoistedGlobal; 
  _SFD_SYMBOL_SCOPE_PUSH_EML(0U, 10U, 10U, c3_debug_family_names, 
    c3_debug_family_var_map); 
  _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(c3_C2r2s, 0U, c3_c_sf_marshallOut, 
    c3_c_sf_marshallIn); 
  _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(c3_Iab, 1U, c3_b_sf_marshallOut, 
    c3_b_sf_marshallIn); 
  _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_nargin, 2U, c3_sf_marshallOut, 
    c3_sf_marshallIn); 
  _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_nargout, 3U, c3_sf_marshallOut, 
    c3_sf_marshallIn); 
  _SFD_SYMBOL_SCOPE_ADD_EML(&c3_id_ref, 4U, c3_sf_marshallOut); 
  _SFD_SYMBOL_SCOPE_ADD_EML(&c3_iq_ref, 5U, c3_sf_marshallOut); 
  _SFD_SYMBOL_SCOPE_ADD_EML(&c3_cosu, 6U, c3_sf_marshallOut); 
  _SFD_SYMBOL_SCOPE_ADD_EML(&c3_sinu, 7U, c3_sf_marshallOut); 
  _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_iD_ref, 8U, c3_sf_marshallOut, 
    c3_sf_marshallIn); 
  _SFD_SYMBOL_SCOPE_ADD_EML_IMPORTABLE(&c3_iQ_ref, 9U, c3_sf_marshallOut, 
    c3_sf_marshallIn); 
  CV_EML_FCN(0, 0); 
  _SFD_EML_CALL(0U, chartInstance->c3_sfEvent, 2); 
  c3_C2r2s[0] = c3_cosu; 
  c3_C2r2s[2] = -c3_sinu; 
  c3_C2r2s[1] = c3_sinu; 
  c3_C2r2s[3] = c3_cosu; 
  _SFD_EML_CALL(0U, chartInstance->c3_sfEvent, 3); 
  for (c3_i0 = 0; c3_i0 < 4; c3_i0++) { 
    c3_a[c3_i0] = c3_C2r2s[c3_i0]; 
  } 
 
  c3_b[0] = c3_id_ref; 
  c3_b[1] = c3_iq_ref; 
  c3_eml_scalar_eg(chartInstance); 
  c3_eml_scalar_eg(chartInstance); 
  for (c3_i1 = 0; c3_i1 < 2; c3_i1++) { 
    c3_Iab[c3_i1] = 0.0; 
  } 
 
  for (c3_i2 = 0; c3_i2 < 2; c3_i2++) { 
    c3_Iab[c3_i2] = 0.0; 
  } 
 
  for (c3_i3 = 0; c3_i3 < 2; c3_i3++) { 
    c3_C[c3_i3] = c3_Iab[c3_i3]; 
  } 
 
  for (c3_i4 = 0; c3_i4 < 2; c3_i4++) { 
    c3_Iab[c3_i4] = c3_C[c3_i4]; 
  } 
 
  for (c3_i5 = 0; c3_i5 < 2; c3_i5++) { 
    c3_C[c3_i5] = c3_Iab[c3_i5]; 
  } 
 
  for (c3_i6 = 0; c3_i6 < 2; c3_i6++) { 
    c3_Iab[c3_i6] = c3_C[c3_i6]; 
  } 
 
  for (c3_i7 = 0; c3_i7 < 2; c3_i7++) { 
    c3_Iab[c3_i7] = 0.0; 
    c3_i8 = 0; 
    for (c3_i9 = 0; c3_i9 < 2; c3_i9++) { 
      c3_Iab[c3_i7] += c3_a[c3_i8 + c3_i7] * c3_b[c3_i9]; 
      c3_i8 += 2; 
    } 
  } 
 
  _SFD_EML_CALL(0U, chartInstance->c3_sfEvent, 4); 
  c3_iD_ref = c3_Iab[0]; 
  _SFD_EML_CALL(0U, chartInstance->c3_sfEvent, 5); 
  c3_iQ_ref = c3_Iab[1]; 
  _SFD_EML_CALL(0U, chartInstance->c3_sfEvent, -5); 
  _SFD_SYMBOL_SCOPE_POP(); 
  *c3_b_iD_ref = c3_iD_ref; 
  *c3_b_iQ_ref = c3_iQ_ref; 
  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG, 0U, chartInstance->c3_sfEvent); 
} 
 
static void initSimStructsc3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance) 
{ 
} 
 
static void registerMessagesc3_mpc_svpwm(SFc3_mpc_svpwmInstanceStruct 
  *chartInstance) 
{ 
} 
 
static void init_script_number_translation(uint32_T c3_machineNumber, uint32_T 
  c3_chartNumber) 
{ 
} 
 
static const mxArray *c3_sf_marshallOut(void *chartInstanceVoid, void *c3_inData) 
{ 
  const mxArray *c3_mxArrayOutData = NULL; 
  real_T c3_u; 
  const mxArray *c3_y = NULL; 
  SFc3_mpc_svpwmInstanceStruct *chartInstance; 
  chartInstance = (SFc3_mpc_svpwmInstanceStruct *)chartInstanceVoid; 
  c3_mxArrayOutData = NULL; 
  c3_u = *(real_T *)c3_inData; 
  c3_y = NULL; 
  sf_mex_assign(&c3_y, sf_mex_create("y", &c3_u, 0, 0U, 0U, 0U, 0), FALSE); 
  sf_mex_assign(&c3_mxArrayOutData, c3_y, FALSE); 
  return c3_mxArrayOutData; 
} 
 
static real_T c3_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_iQ_ref, const char_T *c3_identifier) 
{ 
  real_T c3_y; 
  emlrtMsgIdentifier c3_thisId; 
  c3_thisId.fIdentifier = c3_identifier; 
  c3_thisId.fParent = NULL; 
  c3_y = c3_b_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_iQ_ref), &c3_thisId); 
  sf_mex_destroy(&c3_iQ_ref); 
  return c3_y; 
} 
 
static real_T c3_b_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId) 
{ 
  real_T c3_y; 
  real_T c3_d0; 
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), &c3_d0, 1, 0, 0U, 0, 0U, 0); 
  c3_y = c3_d0; 
  sf_mex_destroy(&c3_u); 
  return c3_y; 
} 
 
static void c3_sf_marshallIn(void *chartInstanceVoid, const mxArray 
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData) 
{ 
  const mxArray *c3_iQ_ref; 
  const char_T *c3_identifier; 
  emlrtMsgIdentifier c3_thisId; 
  real_T c3_y; 
  SFc3_mpc_svpwmInstanceStruct *chartInstance; 
  chartInstance = (SFc3_mpc_svpwmInstanceStruct *)chartInstanceVoid; 
  c3_iQ_ref = sf_mex_dup(c3_mxArrayInData); 
  c3_identifier = c3_varName; 
  c3_thisId.fIdentifier = c3_identifier; 
  c3_thisId.fParent = NULL; 
  c3_y = c3_b_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_iQ_ref), &c3_thisId); 
  sf_mex_destroy(&c3_iQ_ref); 
  *(real_T *)c3_outData = c3_y; 
  sf_mex_destroy(&c3_mxArrayInData); 
} 
 
static const mxArray *c3_b_sf_marshallOut(void *chartInstanceVoid, void 
  *c3_inData) 
{ 
  const mxArray *c3_mxArrayOutData = NULL; 
  int32_T c3_i10; 
  real_T c3_b_inData[2]; 
  int32_T c3_i11; 
  real_T c3_u[2]; 
  const mxArray *c3_y = NULL; 
  SFc3_mpc_svpwmInstanceStruct *chartInstance; 
  chartInstance = (SFc3_mpc_svpwmInstanceStruct *)chartInstanceVoid; 
  c3_mxArrayOutData = NULL; 
  for (c3_i10 = 0; c3_i10 < 2; c3_i10++) { 
    c3_b_inData[c3_i10] = (*(real_T (*)[2])c3_inData)[c3_i10]; 
  } 
 
  for (c3_i11 = 0; c3_i11 < 2; c3_i11++) { 
    c3_u[c3_i11] = c3_b_inData[c3_i11]; 
  } 
 
  c3_y = NULL; 
  sf_mex_assign(&c3_y, sf_mex_create("y", c3_u, 0, 0U, 1U, 0U, 1, 2), FALSE); 
  sf_mex_assign(&c3_mxArrayOutData, c3_y, FALSE); 
  return c3_mxArrayOutData; 
} 
 
static void c3_c_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId, real_T c3_y[2]) 
{ 
  real_T c3_dv0[2]; 
  int32_T c3_i12; 
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), c3_dv0, 1, 0, 0U, 1, 0U, 1, 2); 
  for (c3_i12 = 0; c3_i12 < 2; c3_i12++) { 
    c3_y[c3_i12] = c3_dv0[c3_i12]; 
  } 
 
  sf_mex_destroy(&c3_u); 
} 
 
static void c3_b_sf_marshallIn(void *chartInstanceVoid, const mxArray 
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData) 
{ 
  const mxArray *c3_Iab; 
  const char_T *c3_identifier; 
  emlrtMsgIdentifier c3_thisId; 
  real_T c3_y[2]; 
  int32_T c3_i13; 
  SFc3_mpc_svpwmInstanceStruct *chartInstance; 
  chartInstance = (SFc3_mpc_svpwmInstanceStruct *)chartInstanceVoid; 
  c3_Iab = sf_mex_dup(c3_mxArrayInData); 
  c3_identifier = c3_varName; 
  c3_thisId.fIdentifier = c3_identifier; 
  c3_thisId.fParent = NULL; 
  c3_c_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_Iab), &c3_thisId, c3_y); 
  sf_mex_destroy(&c3_Iab); 
  for (c3_i13 = 0; c3_i13 < 2; c3_i13++) { 
    (*(real_T (*)[2])c3_outData)[c3_i13] = c3_y[c3_i13]; 
  } 
 
  sf_mex_destroy(&c3_mxArrayInData); 
} 
 
static const mxArray *c3_c_sf_marshallOut(void *chartInstanceVoid, void 
  *c3_inData) 
{ 
  const mxArray *c3_mxArrayOutData = NULL; 
  int32_T c3_i14; 
  int32_T c3_i15; 
  int32_T c3_i16; 
  real_T c3_b_inData[4]; 
  int32_T c3_i17; 
  int32_T c3_i18; 
  int32_T c3_i19; 
  real_T c3_u[4]; 
  const mxArray *c3_y = NULL; 
  SFc3_mpc_svpwmInstanceStruct *chartInstance; 
  chartInstance = (SFc3_mpc_svpwmInstanceStruct *)chartInstanceVoid; 
  c3_mxArrayOutData = NULL; 
  c3_i14 = 0; 
  for (c3_i15 = 0; c3_i15 < 2; c3_i15++) { 
    for (c3_i16 = 0; c3_i16 < 2; c3_i16++) { 
      c3_b_inData[c3_i16 + c3_i14] = (*(real_T (*)[4])c3_inData)[c3_i16 + c3_i14]; 
    } 
 
    c3_i14 += 2; 
  } 
 
  c3_i17 = 0; 
  for (c3_i18 = 0; c3_i18 < 2; c3_i18++) { 
    for (c3_i19 = 0; c3_i19 < 2; c3_i19++) { 
      c3_u[c3_i19 + c3_i17] = c3_b_inData[c3_i19 + c3_i17]; 
    } 
 
    c3_i17 += 2; 
  } 
 
  c3_y = NULL; 
  sf_mex_assign(&c3_y, sf_mex_create("y", c3_u, 0, 0U, 1U, 0U, 2, 2, 2), FALSE); 
  sf_mex_assign(&c3_mxArrayOutData, c3_y, FALSE); 
  return c3_mxArrayOutData; 
} 
 
static void c3_d_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId, real_T c3_y[4]) 
{ 
  real_T c3_dv1[4]; 
  int32_T c3_i20; 
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), c3_dv1, 1, 0, 0U, 1, 0U, 2, 2, 2); 
  for (c3_i20 = 0; c3_i20 < 4; c3_i20++) { 
    c3_y[c3_i20] = c3_dv1[c3_i20]; 
  } 
 
  sf_mex_destroy(&c3_u); 
} 
 
static void c3_c_sf_marshallIn(void *chartInstanceVoid, const mxArray 
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData) 
{ 
  const mxArray *c3_C2r2s; 
  const char_T *c3_identifier; 
  emlrtMsgIdentifier c3_thisId; 
  real_T c3_y[4]; 
  int32_T c3_i21; 
  int32_T c3_i22; 
  int32_T c3_i23; 
  SFc3_mpc_svpwmInstanceStruct *chartInstance; 
  chartInstance = (SFc3_mpc_svpwmInstanceStruct *)chartInstanceVoid; 
  c3_C2r2s = sf_mex_dup(c3_mxArrayInData); 
  c3_identifier = c3_varName; 
  c3_thisId.fIdentifier = c3_identifier; 
  c3_thisId.fParent = NULL; 
  c3_d_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_C2r2s), &c3_thisId, c3_y); 
  sf_mex_destroy(&c3_C2r2s); 
  c3_i21 = 0; 
  for (c3_i22 = 0; c3_i22 < 2; c3_i22++) { 
    for (c3_i23 = 0; c3_i23 < 2; c3_i23++) { 
      (*(real_T (*)[4])c3_outData)[c3_i23 + c3_i21] = c3_y[c3_i23 + c3_i21]; 
    } 
 
    c3_i21 += 2; 
  } 
 
  sf_mex_destroy(&c3_mxArrayInData); 
} 
 
const mxArray *sf_c3_mpc_svpwm_get_eml_resolved_functions_info(void) 
{ 
  const mxArray *c3_nameCaptureInfo; 
  c3_ResolvedFunctionInfo c3_info[9]; 
  c3_ResolvedFunctionInfo (*c3_b_info)[9]; 
  const mxArray *c3_m0 = NULL; 
  int32_T c3_i24; 
  c3_ResolvedFunctionInfo *c3_r0; 
  c3_nameCaptureInfo = NULL; 
  c3_nameCaptureInfo = NULL; 
  c3_b_info = (c3_ResolvedFunctionInfo (*)[9])c3_info; 
  (*c3_b_info)[0].context = ""; 
  (*c3_b_info)[0].name = "mtimes"; 
  (*c3_b_info)[0].dominantType = "double"; 
  (*c3_b_info)[0].resolved = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m"; 
  (*c3_b_info)[0].fileTimeLo = 1289494492U; 
  (*c3_b_info)[0].fileTimeHi = 0U; 
  (*c3_b_info)[0].mFileTimeLo = 0U; 
  (*c3_b_info)[0].mFileTimeHi = 0U; 
  (*c3_b_info)[1].context = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m"; 
  (*c3_b_info)[1].name = "eml_index_class"; 
  (*c3_b_info)[1].dominantType = ""; 
  (*c3_b_info)[1].resolved = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_index_class.m"; 
  (*c3_b_info)[1].fileTimeLo = 1323145378U; 
  (*c3_b_info)[1].fileTimeHi = 0U; 
  (*c3_b_info)[1].mFileTimeLo = 0U; 
  (*c3_b_info)[1].mFileTimeHi = 0U; 
  (*c3_b_info)[2].context = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m"; 
  (*c3_b_info)[2].name = "eml_scalar_eg"; 
  (*c3_b_info)[2].dominantType = "double"; 
  (*c3_b_info)[2].resolved = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_scalar_eg.m"; 
  (*c3_b_info)[2].fileTimeLo = 1286797196U; 
  (*c3_b_info)[2].fileTimeHi = 0U; 
  (*c3_b_info)[2].mFileTimeLo = 0U; 
  (*c3_b_info)[2].mFileTimeHi = 0U; 
  (*c3_b_info)[3].context = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m"; 
  (*c3_b_info)[3].name = "eml_xgemm"; 
  (*c3_b_info)[3].dominantType = "char"; 
  (*c3_b_info)[3].resolved = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/blas/eml_xgemm.m"; 
  (*c3_b_info)[3].fileTimeLo = 1299051572U; 
  (*c3_b_info)[3].fileTimeHi = 0U; 
  (*c3_b_info)[3].mFileTimeLo = 0U; 
  (*c3_b_info)[3].mFileTimeHi = 0U; 
  (*c3_b_info)[4].context = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/blas/eml_xgemm.m"; 
  (*c3_b_info)[4].name = "eml_blas_inline"; 
  (*c3_b_info)[4].dominantType = ""; 
  (*c3_b_info)[4].resolved = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/blas/eml_blas_inline.m"; 
  (*c3_b_info)[4].fileTimeLo = 1299051568U; 
  (*c3_b_info)[4].fileTimeHi = 0U; 
  (*c3_b_info)[4].mFileTimeLo = 0U; 
  (*c3_b_info)[4].mFileTimeHi = 0U; 
  (*c3_b_info)[5].context = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/blas/external/eml_blas_xgemm.m!below_threshold"; 
  (*c3_b_info)[5].name = "mtimes"; 
  (*c3_b_info)[5].dominantType = "double"; 
  (*c3_b_info)[5].resolved = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/ops/mtimes.m"; 
  (*c3_b_info)[5].fileTimeLo = 1289494492U; 
  (*c3_b_info)[5].fileTimeHi = 0U; 
  (*c3_b_info)[5].mFileTimeLo = 0U; 
  (*c3_b_info)[5].mFileTimeHi = 0U; 
  (*c3_b_info)[6].context = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/blas/external/eml_blas_xgemm.m"; 
  (*c3_b_info)[6].name = "eml_index_class"; 
  (*c3_b_info)[6].dominantType = ""; 
  (*c3_b_info)[6].resolved = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_index_class.m"; 
  (*c3_b_info)[6].fileTimeLo = 1323145378U; 
  (*c3_b_info)[6].fileTimeHi = 0U; 
  (*c3_b_info)[6].mFileTimeLo = 0U; 
  (*c3_b_info)[6].mFileTimeHi = 0U; 
  (*c3_b_info)[7].context = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/blas/external/eml_blas_xgemm.m"; 
  (*c3_b_info)[7].name = "eml_scalar_eg"; 
  (*c3_b_info)[7].dominantType = "double"; 
  (*c3_b_info)[7].resolved = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/eml_scalar_eg.m"; 
  (*c3_b_info)[7].fileTimeLo = 1286797196U; 
  (*c3_b_info)[7].fileTimeHi = 0U; 
  (*c3_b_info)[7].mFileTimeLo = 0U; 
  (*c3_b_info)[7].mFileTimeHi = 0U; 
  (*c3_b_info)[8].context = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/blas/external/eml_blas_xgemm.m"; 
  (*c3_b_info)[8].name = "eml_refblas_xgemm"; 
  (*c3_b_info)[8].dominantType = "char"; 
  (*c3_b_info)[8].resolved = 
    "[ILXE]$matlabroot$/toolbox/eml/lib/matlab/eml/blas/refblas/eml_refblas_xgemm.m"; 
  (*c3_b_info)[8].fileTimeLo = 1299051574U; 
  (*c3_b_info)[8].fileTimeHi = 0U; 
  (*c3_b_info)[8].mFileTimeLo = 0U; 
  (*c3_b_info)[8].mFileTimeHi = 0U; 
  sf_mex_assign(&c3_m0, sf_mex_createstruct("nameCaptureInfo", 1, 9), FALSE); 
  for (c3_i24 = 0; c3_i24 < 9; c3_i24++) { 
    c3_r0 = &c3_info[c3_i24]; 
    sf_mex_addfield(c3_m0, sf_mex_create("nameCaptureInfo", c3_r0->context, 15, 
      0U, 0U, 0U, 2, 1, strlen(c3_r0->context)), "context", "nameCaptureInfo", 
                    c3_i24); 
    sf_mex_addfield(c3_m0, sf_mex_create("nameCaptureInfo", c3_r0->name, 15, 0U, 
      0U, 0U, 2, 1, strlen(c3_r0->name)), "name", "nameCaptureInfo", c3_i24); 
    sf_mex_addfield(c3_m0, sf_mex_create("nameCaptureInfo", c3_r0->dominantType, 
      15, 0U, 0U, 0U, 2, 1, strlen(c3_r0->dominantType)), "dominantType", 
                    "nameCaptureInfo", c3_i24); 
    sf_mex_addfield(c3_m0, sf_mex_create("nameCaptureInfo", c3_r0->resolved, 15, 
      0U, 0U, 0U, 2, 1, strlen(c3_r0->resolved)), "resolved", "nameCaptureInfo", 
                    c3_i24); 
    sf_mex_addfield(c3_m0, sf_mex_create("nameCaptureInfo", &c3_r0->fileTimeLo, 
      7, 0U, 0U, 0U, 0), "fileTimeLo", "nameCaptureInfo", c3_i24); 
    sf_mex_addfield(c3_m0, sf_mex_create("nameCaptureInfo", &c3_r0->fileTimeHi, 
      7, 0U, 0U, 0U, 0), "fileTimeHi", "nameCaptureInfo", c3_i24); 
    sf_mex_addfield(c3_m0, sf_mex_create("nameCaptureInfo", &c3_r0->mFileTimeLo, 
      7, 0U, 0U, 0U, 0), "mFileTimeLo", "nameCaptureInfo", c3_i24); 
    sf_mex_addfield(c3_m0, sf_mex_create("nameCaptureInfo", &c3_r0->mFileTimeHi, 
      7, 0U, 0U, 0U, 0), "mFileTimeHi", "nameCaptureInfo", c3_i24); 
  } 
 
  sf_mex_assign(&c3_nameCaptureInfo, c3_m0, FALSE); 
  sf_mex_emlrtNameCapturePostProcessR2012a(&c3_nameCaptureInfo); 
  return c3_nameCaptureInfo; 
} 
 
static void c3_eml_scalar_eg(SFc3_mpc_svpwmInstanceStruct *chartInstance) 
{ 
} 
 
static const mxArray *c3_d_sf_marshallOut(void *chartInstanceVoid, void 
  *c3_inData) 
{ 
  const mxArray *c3_mxArrayOutData = NULL; 
  int32_T c3_u; 
  const mxArray *c3_y = NULL; 
  SFc3_mpc_svpwmInstanceStruct *chartInstance; 
  chartInstance = (SFc3_mpc_svpwmInstanceStruct *)chartInstanceVoid; 
  c3_mxArrayOutData = NULL; 
  c3_u = *(int32_T *)c3_inData; 
  c3_y = NULL; 
  sf_mex_assign(&c3_y, sf_mex_create("y", &c3_u, 6, 0U, 0U, 0U, 0), FALSE); 
  sf_mex_assign(&c3_mxArrayOutData, c3_y, FALSE); 
  return c3_mxArrayOutData; 
} 
 
static int32_T c3_e_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId) 
{ 
  int32_T c3_y; 
  int32_T c3_i25; 
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), &c3_i25, 1, 6, 0U, 0, 0U, 0); 
  c3_y = c3_i25; 
  sf_mex_destroy(&c3_u); 
  return c3_y; 
} 
 
static void c3_d_sf_marshallIn(void *chartInstanceVoid, const mxArray 
  *c3_mxArrayInData, const char_T *c3_varName, void *c3_outData) 
{ 
  const mxArray *c3_b_sfEvent; 
  const char_T *c3_identifier; 
  emlrtMsgIdentifier c3_thisId; 
  int32_T c3_y; 
  SFc3_mpc_svpwmInstanceStruct *chartInstance; 
  chartInstance = (SFc3_mpc_svpwmInstanceStruct *)chartInstanceVoid; 
  c3_b_sfEvent = sf_mex_dup(c3_mxArrayInData); 
  c3_identifier = c3_varName; 
  c3_thisId.fIdentifier = c3_identifier; 
  c3_thisId.fParent = NULL; 
  c3_y = c3_e_emlrt_marshallIn(chartInstance, sf_mex_dup(c3_b_sfEvent), 
    &c3_thisId); 
  sf_mex_destroy(&c3_b_sfEvent); 
  *(int32_T *)c3_outData = c3_y; 
  sf_mex_destroy(&c3_mxArrayInData); 
} 
 
static uint8_T c3_f_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_b_is_active_c3_mpc_svpwm, const char_T *c3_identifier) 
{ 
  uint8_T c3_y; 
  emlrtMsgIdentifier c3_thisId; 
  c3_thisId.fIdentifier = c3_identifier; 
  c3_thisId.fParent = NULL; 
  c3_y = c3_g_emlrt_marshallIn(chartInstance, sf_mex_dup 
    (c3_b_is_active_c3_mpc_svpwm), &c3_thisId); 
  sf_mex_destroy(&c3_b_is_active_c3_mpc_svpwm); 
  return c3_y; 
} 
 
static uint8_T c3_g_emlrt_marshallIn(SFc3_mpc_svpwmInstanceStruct *chartInstance, 
  const mxArray *c3_u, const emlrtMsgIdentifier *c3_parentId) 
{ 
  uint8_T c3_y; 
  uint8_T c3_u0; 
  sf_mex_import(c3_parentId, sf_mex_dup(c3_u), &c3_u0, 1, 3, 0U, 0, 0U, 0); 
  c3_y = c3_u0; 
  sf_mex_destroy(&c3_u); 
  return c3_y; 
} 
 
static void init_dsm_address_info(SFc3_mpc_svpwmInstanceStruct *chartInstance) 
{ 
} 
 
/* 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_c3_mpc_svpwm_get_check_sum(mxArray *plhs[]) 
{ 
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(46669577U); 
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(1634413583U); 
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(652778154U); 
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(3667063902U); 
} 
 
mxArray *sf_c3_mpc_svpwm_get_autoinheritance_info(void) 
{ 
  const char *autoinheritanceFields[] = { "checksum", "inputs", "parameters", 
    "outputs", "locals" }; 
 
  mxArray *mxAutoinheritanceInfo = mxCreateStructMatrix(1,1,5, 
    autoinheritanceFields); 
 
  { 
    mxArray *mxChecksum = mxCreateString("WRXIxHd0o7XokhQgsyjtXE"); 
    mxSetField(mxAutoinheritanceInfo,0,"checksum",mxChecksum); 
  } 
 
  { 
    const char *dataFields[] = { "size", "type", "complexity" }; 
 
    mxArray *mxData = mxCreateStructMatrix(1,4,3,dataFields); 
 
    { 
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL); 
      double *pr = mxGetPr(mxSize); 
      pr[0] = (double)(1); 
      pr[1] = (double)(1); 
      mxSetField(mxData,0,"size",mxSize); 
    } 
 
    { 
      const char *typeFields[] = { "base", "fixpt" }; 
 
      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields); 
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10)); 
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL)); 
      mxSetField(mxData,0,"type",mxType); 
    } 
 
    mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0)); 
 
    { 
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL); 
      double *pr = mxGetPr(mxSize); 
      pr[0] = (double)(1); 
      pr[1] = (double)(1); 
      mxSetField(mxData,1,"size",mxSize); 
    } 
 
    { 
      const char *typeFields[] = { "base", "fixpt" }; 
 
      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields); 
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10)); 
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL)); 
      mxSetField(mxData,1,"type",mxType); 
    } 
 
    mxSetField(mxData,1,"complexity",mxCreateDoubleScalar(0)); 
 
    { 
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL); 
      double *pr = mxGetPr(mxSize); 
      pr[0] = (double)(1); 
      pr[1] = (double)(1); 
      mxSetField(mxData,2,"size",mxSize); 
    } 
 
    { 
      const char *typeFields[] = { "base", "fixpt" }; 
 
      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields); 
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10)); 
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL)); 
      mxSetField(mxData,2,"type",mxType); 
    } 
 
    mxSetField(mxData,2,"complexity",mxCreateDoubleScalar(0)); 
 
    { 
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL); 
      double *pr = mxGetPr(mxSize); 
      pr[0] = (double)(1); 
      pr[1] = (double)(1); 
      mxSetField(mxData,3,"size",mxSize); 
    } 
 
    { 
      const char *typeFields[] = { "base", "fixpt" }; 
 
      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields); 
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10)); 
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL)); 
      mxSetField(mxData,3,"type",mxType); 
    } 
 
    mxSetField(mxData,3,"complexity",mxCreateDoubleScalar(0)); 
    mxSetField(mxAutoinheritanceInfo,0,"inputs",mxData); 
  } 
 
  { 
    mxSetField(mxAutoinheritanceInfo,0,"parameters",mxCreateDoubleMatrix(0,0, 
                mxREAL)); 
  } 
 
  { 
    const char *dataFields[] = { "size", "type", "complexity" }; 
 
    mxArray *mxData = mxCreateStructMatrix(1,2,3,dataFields); 
 
    { 
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL); 
      double *pr = mxGetPr(mxSize); 
      pr[0] = (double)(1); 
      pr[1] = (double)(1); 
      mxSetField(mxData,0,"size",mxSize); 
    } 
 
    { 
      const char *typeFields[] = { "base", "fixpt" }; 
 
      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields); 
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10)); 
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL)); 
      mxSetField(mxData,0,"type",mxType); 
    } 
 
    mxSetField(mxData,0,"complexity",mxCreateDoubleScalar(0)); 
 
    { 
      mxArray *mxSize = mxCreateDoubleMatrix(1,2,mxREAL); 
      double *pr = mxGetPr(mxSize); 
      pr[0] = (double)(1); 
      pr[1] = (double)(1); 
      mxSetField(mxData,1,"size",mxSize); 
    } 
 
    { 
      const char *typeFields[] = { "base", "fixpt" }; 
 
      mxArray *mxType = mxCreateStructMatrix(1,1,2,typeFields); 
      mxSetField(mxType,0,"base",mxCreateDoubleScalar(10)); 
      mxSetField(mxType,0,"fixpt",mxCreateDoubleMatrix(0,0,mxREAL)); 
      mxSetField(mxData,1,"type",mxType); 
    } 
 
    mxSetField(mxData,1,"complexity",mxCreateDoubleScalar(0)); 
    mxSetField(mxAutoinheritanceInfo,0,"outputs",mxData); 
  } 
 
  { 
    mxSetField(mxAutoinheritanceInfo,0,"locals",mxCreateDoubleMatrix(0,0,mxREAL)); 
  } 
 
  return(mxAutoinheritanceInfo); 
} 
 
mxArray *sf_c3_mpc_svpwm_third_party_uses_info(void) 
{ 
  mxArray * mxcell3p = mxCreateCellMatrix(1,0); 
  return(mxcell3p); 
} 
 
static const mxArray *sf_get_sim_state_info_c3_mpc_svpwm(void) 
{ 
  const char *infoFields[] = { "chartChecksum", "varInfo" }; 
 
  mxArray *mxInfo = mxCreateStructMatrix(1, 1, 2, infoFields); 
  const char *infoEncStr[] = { 
    "100 S1x3'type','srcId','name','auxInfo'{{M[1],M[12],T\"iD_ref\",},{M[1],M[13],T\"iQ_ref\",},{M[8],M[0],T\"is_active_c3_mpc_svpwm\",}}" 
  }; 
 
  mxArray *mxVarInfo = sf_mex_decode_encoded_mx_struct_array(infoEncStr, 3, 10); 
  mxArray *mxChecksum = mxCreateDoubleMatrix(1, 4, mxREAL); 
  sf_c3_mpc_svpwm_get_check_sum(&mxChecksum); 
  mxSetField(mxInfo, 0, infoFields[0], mxChecksum); 
  mxSetField(mxInfo, 0, infoFields[1], mxVarInfo); 
  return mxInfo; 
} 
 
static void chart_debug_initialization(SimStruct *S, unsigned int 
  fullDebuggerInitialization) 
{ 
  if (!sim_mode_is_rtw_gen(S)) { 
    SFc3_mpc_svpwmInstanceStruct *chartInstance; 
    chartInstance = (SFc3_mpc_svpwmInstanceStruct *) ((ChartInfoStruct *) 
      (ssGetUserData(S)))->chartInstance; 
    if (ssIsFirstInitCond(S) && fullDebuggerInitialization==1) { 
      /* do this only if simulation is starting */ 
      { 
        unsigned int chartAlreadyPresent; 
        chartAlreadyPresent = sf_debug_initialize_chart 
          (sfGlobalDebugInstanceStruct, 
           _mpc_svpwmMachineNumber_, 
           3, 
           1, 
           1, 
           6, 
           0, 
           0, 
           0, 
           0, 
           0, 
           &(chartInstance->chartNumber), 
           &(chartInstance->instanceNumber), 
           ssGetPath(S), 
           (void *)S); 
        if (chartAlreadyPresent==0) { 
          /* this is the first instance */ 
          init_script_number_translation(_mpc_svpwmMachineNumber_, 
            chartInstance->chartNumber); 
          sf_debug_set_chart_disable_implicit_casting 
            (sfGlobalDebugInstanceStruct,_mpc_svpwmMachineNumber_, 
             chartInstance->chartNumber,1); 
          sf_debug_set_chart_event_thresholds(sfGlobalDebugInstanceStruct, 
            _mpc_svpwmMachineNumber_, 
            chartInstance->chartNumber, 
            0, 
            0, 
            0); 
          _SFD_SET_DATA_PROPS(0,1,1,0,"id_ref"); 
          _SFD_SET_DATA_PROPS(1,1,1,0,"iq_ref"); 
          _SFD_SET_DATA_PROPS(2,2,0,1,"iD_ref"); 
          _SFD_SET_DATA_PROPS(3,2,0,1,"iQ_ref"); 
          _SFD_SET_DATA_PROPS(4,1,1,0,"cosu"); 
          _SFD_SET_DATA_PROPS(5,1,1,0,"sinu"); 
          _SFD_STATE_INFO(0,0,2); 
          _SFD_CH_SUBSTATE_COUNT(0); 
          _SFD_CH_SUBSTATE_DECOMP(0); 
        } 
 
        _SFD_CV_INIT_CHART(0,0,0,0); 
 
        { 
          _SFD_CV_INIT_STATE(0,0,0,0,0,0,NULL,NULL); 
        } 
 
        _SFD_CV_INIT_TRANS(0,0,NULL,NULL,0,NULL); 
 
        /* Initialization of MATLAB Function Model Coverage */ 
        _SFD_CV_INIT_EML(0,1,1,0,0,0,0,0,0,0,0); 
        _SFD_CV_INIT_EML_FCN(0,0,"eML_blk_kernel",0,-1,152); 
        _SFD_TRANS_COV_WTS(0,0,0,1,0); 
        if (chartAlreadyPresent==0) { 
          _SFD_TRANS_COV_MAPS(0, 
                              0,NULL,NULL, 
                              0,NULL,NULL, 
                              1,NULL,NULL, 
                              0,NULL,NULL); 
        } 
 
        _SFD_SET_DATA_COMPILED_PROPS(0,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0, 
          (MexFcnForType)c3_sf_marshallOut,(MexInFcnForType)NULL); 
        _SFD_SET_DATA_COMPILED_PROPS(1,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0, 
          (MexFcnForType)c3_sf_marshallOut,(MexInFcnForType)NULL); 
        _SFD_SET_DATA_COMPILED_PROPS(2,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0, 
          (MexFcnForType)c3_sf_marshallOut,(MexInFcnForType)c3_sf_marshallIn); 
        _SFD_SET_DATA_COMPILED_PROPS(3,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0, 
          (MexFcnForType)c3_sf_marshallOut,(MexInFcnForType)c3_sf_marshallIn); 
        _SFD_SET_DATA_COMPILED_PROPS(4,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0, 
          (MexFcnForType)c3_sf_marshallOut,(MexInFcnForType)NULL); 
        _SFD_SET_DATA_COMPILED_PROPS(5,SF_DOUBLE,0,NULL,0,0,0,0.0,1.0,0,0, 
          (MexFcnForType)c3_sf_marshallOut,(MexInFcnForType)NULL); 
 
        { 
          real_T *c3_id_ref; 
          real_T *c3_iq_ref; 
          real_T *c3_iD_ref; 
          real_T *c3_iQ_ref; 
          real_T *c3_cosu; 
          real_T *c3_sinu; 
          c3_sinu = (real_T *)ssGetInputPortSignal(chartInstance->S, 3); 
          c3_cosu = (real_T *)ssGetInputPortSignal(chartInstance->S, 2); 
          c3_iQ_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2); 
          c3_iD_ref = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1); 
          c3_iq_ref = (real_T *)ssGetInputPortSignal(chartInstance->S, 1); 
          c3_id_ref = (real_T *)ssGetInputPortSignal(chartInstance->S, 0); 
          _SFD_SET_DATA_VALUE_PTR(0U, c3_id_ref); 
          _SFD_SET_DATA_VALUE_PTR(1U, c3_iq_ref); 
          _SFD_SET_DATA_VALUE_PTR(2U, c3_iD_ref); 
          _SFD_SET_DATA_VALUE_PTR(3U, c3_iQ_ref); 
          _SFD_SET_DATA_VALUE_PTR(4U, c3_cosu); 
          _SFD_SET_DATA_VALUE_PTR(5U, c3_sinu); 
        } 
      } 
    } else { 
      sf_debug_reset_current_state_configuration(sfGlobalDebugInstanceStruct, 
        _mpc_svpwmMachineNumber_,chartInstance->chartNumber, 
        chartInstance->instanceNumber); 
    } 
  } 
} 
 
static const char* sf_get_instance_specialization(void) 
{ 
  return "YSNwkGTdDD2rO2NvaQPGtC"; 
} 
 
static void sf_opaque_initialize_c3_mpc_svpwm(void *chartInstanceVar) 
{ 
  chart_debug_initialization(((SFc3_mpc_svpwmInstanceStruct*) chartInstanceVar 
    )->S,0); 
  initialize_params_c3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) 
    chartInstanceVar); 
  initialize_c3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) chartInstanceVar); 
} 
 
static void sf_opaque_enable_c3_mpc_svpwm(void *chartInstanceVar) 
{ 
  enable_c3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) chartInstanceVar); 
} 
 
static void sf_opaque_disable_c3_mpc_svpwm(void *chartInstanceVar) 
{ 
  disable_c3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) chartInstanceVar); 
} 
 
static void sf_opaque_gateway_c3_mpc_svpwm(void *chartInstanceVar) 
{ 
  sf_c3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) chartInstanceVar); 
} 
 
extern const mxArray* sf_internal_get_sim_state_c3_mpc_svpwm(SimStruct* S) 
{ 
  ChartInfoStruct *chartInfo = (ChartInfoStruct*) ssGetUserData(S); 
  mxArray *plhs[1] = { NULL }; 
 
  mxArray *prhs[4]; 
  int mxError = 0; 
  prhs[0] = mxCreateString("chart_simctx_raw2high"); 
  prhs[1] = mxCreateDoubleScalar(ssGetSFuncBlockHandle(S)); 
  prhs[2] = (mxArray*) get_sim_state_c3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) 
    chartInfo->chartInstance);         /* raw sim ctx */ 
  prhs[3] = (mxArray*) sf_get_sim_state_info_c3_mpc_svpwm();/* state var info */ 
  mxError = sf_mex_call_matlab(1, plhs, 4, prhs, "sfprivate"); 
  mxDestroyArray(prhs[0]); 
  mxDestroyArray(prhs[1]); 
  mxDestroyArray(prhs[2]); 
  mxDestroyArray(prhs[3]); 
  if (mxError || plhs[0] == NULL) { 
    sf_mex_error_message("Stateflow Internal Error: \nError calling 'chart_simctx_raw2high'.\n"); 
  } 
 
  return plhs[0]; 
} 
 
extern void sf_internal_set_sim_state_c3_mpc_svpwm(SimStruct* S, const mxArray 
  *st) 
{ 
  ChartInfoStruct *chartInfo = (ChartInfoStruct*) ssGetUserData(S); 
  mxArray *plhs[1] = { NULL }; 
 
  mxArray *prhs[4]; 
  int mxError = 0; 
  prhs[0] = mxCreateString("chart_simctx_high2raw"); 
  prhs[1] = mxCreateDoubleScalar(ssGetSFuncBlockHandle(S)); 
  prhs[2] = mxDuplicateArray(st);      /* high level simctx */ 
  prhs[3] = (mxArray*) sf_get_sim_state_info_c3_mpc_svpwm();/* state var info */ 
  mxError = sf_mex_call_matlab(1, plhs, 4, prhs, "sfprivate"); 
  mxDestroyArray(prhs[0]); 
  mxDestroyArray(prhs[1]); 
  mxDestroyArray(prhs[2]); 
  mxDestroyArray(prhs[3]); 
  if (mxError || plhs[0] == NULL) { 
    sf_mex_error_message("Stateflow Internal Error: \nError calling 'chart_simctx_high2raw'.\n"); 
  } 
 
  set_sim_state_c3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) 
    chartInfo->chartInstance, mxDuplicateArray(plhs[0])); 
  mxDestroyArray(plhs[0]); 
} 
 
static const mxArray* sf_opaque_get_sim_state_c3_mpc_svpwm(SimStruct* S) 
{ 
  return sf_internal_get_sim_state_c3_mpc_svpwm(S); 
} 
 
static void sf_opaque_set_sim_state_c3_mpc_svpwm(SimStruct* S, const mxArray *st) 
{ 
  sf_internal_set_sim_state_c3_mpc_svpwm(S, st); 
} 
 
static void sf_opaque_terminate_c3_mpc_svpwm(void *chartInstanceVar) 
{ 
  if (chartInstanceVar!=NULL) { 
    SimStruct *S = ((SFc3_mpc_svpwmInstanceStruct*) chartInstanceVar)->S; 
    if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) { 
      sf_clear_rtw_identifier(S); 
      unload_mpc_svpwm_optimization_info(); 
    } 
 
    finalize_c3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) chartInstanceVar); 
    utFree((void *)chartInstanceVar); 
    ssSetUserData(S,NULL); 
  } 
} 
 
static void sf_opaque_init_subchart_simstructs(void *chartInstanceVar) 
{ 
  initSimStructsc3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) chartInstanceVar); 
} 
 
extern unsigned int sf_machine_global_initializer_called(void); 
static void mdlProcessParameters_c3_mpc_svpwm(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_c3_mpc_svpwm((SFc3_mpc_svpwmInstanceStruct*) 
      (((ChartInfoStruct *)ssGetUserData(S))->chartInstance)); 
  } 
} 
 
static void mdlSetWorkWidths_c3_mpc_svpwm(SimStruct *S) 
{ 
  if (sim_mode_is_rtw_gen(S) || sim_mode_is_external(S)) { 
    mxArray *infoStruct = load_mpc_svpwm_optimization_info(); 
    int_T chartIsInlinable = 
      (int_T)sf_is_chart_inlinable(S,sf_get_instance_specialization(),infoStruct, 
      3); 
    ssSetStateflowIsInlinable(S,chartIsInlinable); 
    ssSetRTWCG(S,sf_rtw_info_uint_prop(S,sf_get_instance_specialization(), 
                infoStruct,3,"RTWCG")); 
    ssSetEnableFcnIsTrivial(S,1); 
    ssSetDisableFcnIsTrivial(S,1); 
    ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop(S, 
      sf_get_instance_specialization(),infoStruct,3, 
      "gatewayCannotBeInlinedMultipleTimes")); 
    sf_update_buildInfo(S,sf_get_instance_specialization(),infoStruct,3); 
    if (chartIsInlinable) { 
      ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); 
      ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL); 
      ssSetInputPortOptimOpts(S, 2, SS_REUSABLE_AND_LOCAL); 
      ssSetInputPortOptimOpts(S, 3, SS_REUSABLE_AND_LOCAL); 
      sf_mark_chart_expressionable_inputs(S,sf_get_instance_specialization(), 
        infoStruct,3,4); 
      sf_mark_chart_reusable_outputs(S,sf_get_instance_specialization(), 
        infoStruct,3,2); 
    } 
 
    { 
      unsigned int outPortIdx; 
      for (outPortIdx=1; outPortIdx<=2; ++outPortIdx) { 
        ssSetOutputPortOptimizeInIR(S, outPortIdx, 1U); 
      } 
    } 
 
    { 
      unsigned int inPortIdx; 
      for (inPortIdx=0; inPortIdx < 4; ++inPortIdx) { 
        ssSetInputPortOptimizeInIR(S, inPortIdx, 1U); 
      } 
    } 
 
    sf_set_rtw_dwork_info(S,sf_get_instance_specialization(),infoStruct,3); 
    ssSetHasSubFunctions(S,!(chartIsInlinable)); 
  } else { 
  } 
 
  ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE); 
  ssSetChecksum0(S,(2257712896U)); 
  ssSetChecksum1(S,(710611485U)); 
  ssSetChecksum2(S,(3236180050U)); 
  ssSetChecksum3(S,(1598505367U)); 
  ssSetmdlDerivatives(S, NULL); 
  ssSetExplicitFCSSCtrl(S,1); 
  ssSupportsMultipleExecInstances(S,1); 
} 
 
static void mdlRTW_c3_mpc_svpwm(SimStruct *S) 
{ 
  if (sim_mode_is_rtw_gen(S)) { 
    ssWriteRTWStrParam(S, "StateflowChartType", "Embedded MATLAB"); 
  } 
} 
 
static void mdlStart_c3_mpc_svpwm(SimStruct *S) 
{ 
  SFc3_mpc_svpwmInstanceStruct *chartInstance; 
  chartInstance = (SFc3_mpc_svpwmInstanceStruct *)utMalloc(sizeof 
    (SFc3_mpc_svpwmInstanceStruct)); 
  memset(chartInstance, 0, sizeof(SFc3_mpc_svpwmInstanceStruct)); 
  if (chartInstance==NULL) { 
    sf_mex_error_message("Could not allocate memory for chart instance."); 
  } 
 
  chartInstance->chartInfo.chartInstance = chartInstance; 
  chartInstance->chartInfo.isEMLChart = 1; 
  chartInstance->chartInfo.chartInitialized = 0; 
  chartInstance->chartInfo.sFunctionGateway = sf_opaque_gateway_c3_mpc_svpwm; 
  chartInstance->chartInfo.initializeChart = sf_opaque_initialize_c3_mpc_svpwm; 
  chartInstance->chartInfo.terminateChart = sf_opaque_terminate_c3_mpc_svpwm; 
  chartInstance->chartInfo.enableChart = sf_opaque_enable_c3_mpc_svpwm; 
  chartInstance->chartInfo.disableChart = sf_opaque_disable_c3_mpc_svpwm; 
  chartInstance->chartInfo.getSimState = sf_opaque_get_sim_state_c3_mpc_svpwm; 
  chartInstance->chartInfo.setSimState = sf_opaque_set_sim_state_c3_mpc_svpwm; 
  chartInstance->chartInfo.getSimStateInfo = sf_get_sim_state_info_c3_mpc_svpwm; 
  chartInstance->chartInfo.zeroCrossings = NULL; 
  chartInstance->chartInfo.outputs = NULL; 
  chartInstance->chartInfo.derivatives = NULL; 
  chartInstance->chartInfo.mdlRTW = mdlRTW_c3_mpc_svpwm; 
  chartInstance->chartInfo.mdlStart = mdlStart_c3_mpc_svpwm; 
  chartInstance->chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c3_mpc_svpwm; 
  chartInstance->chartInfo.extModeExec = NULL; 
  chartInstance->chartInfo.restoreLastMajorStepConfiguration = NULL; 
  chartInstance->chartInfo.restoreBeforeLastMajorStepConfiguration = NULL; 
  chartInstance->chartInfo.storeCurrentConfiguration = NULL; 
  chartInstance->S = S; 
  ssSetUserData(S,(void *)(&(chartInstance->chartInfo)));/* register the chart instance with simstruct */ 
  init_dsm_address_info(chartInstance); 
  if (!sim_mode_is_rtw_gen(S)) { 
  } 
 
  sf_opaque_init_subchart_simstructs(chartInstance->chartInfo.chartInstance); 
  chart_debug_initialization(S,1); 
} 
 
void c3_mpc_svpwm_method_dispatcher(SimStruct *S, int_T method, void *data) 
{ 
  switch (method) { 
   case SS_CALL_MDL_START: 
    mdlStart_c3_mpc_svpwm(S); 
    break; 
 
   case SS_CALL_MDL_SET_WORK_WIDTHS: 
    mdlSetWorkWidths_c3_mpc_svpwm(S); 
    break; 
 
   case SS_CALL_MDL_PROCESS_PARAMETERS: 
    mdlProcessParameters_c3_mpc_svpwm(S); 
    break; 
 
   default: 
    /* Unhandled method */ 
    sf_mex_error_message("Stateflow Internal Error:\n" 
                         "Error calling c3_mpc_svpwm_method_dispatcher.\n" 
                         "Can't handle method %d.\n", method); 
    break; 
  } 
}