⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c3_mybldc_mdl2.c

📁 pid simulator for bldc
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Include files */
#include "mybldc_mdl2_sfun.h"
#include "c3_mybldc_mdl2.h"
#define CHARTINSTANCE_CHARTNUMBER       (chartInstance.chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER    (chartInstance.instanceNumber)
#include "mybldc_mdl2_sfun_debug_macros.h"

/* Type Definitions */

/* Named Constants */
#define c3_IN_NO_ACTIVE_CHILD           (0)
#define c3_IN_C                         (1)
#define c3_IN_C1                        (1)
#define c3_IN_C2                        (2)

/* Variable Declarations */

/* Variable Definitions */
static SFc3_mybldc_mdl2InstanceStruct chartInstance;

/* Function Declarations */
static void initialize_c3_mybldc_mdl2(void);
static void initialize_params_c3_mybldc_mdl2(void);
static void enable_c3_mybldc_mdl2(void);
static void disable_c3_mybldc_mdl2(void);
static void finalize_c3_mybldc_mdl2(void);
static void sf_c3_mybldc_mdl2(void);
static void store_current_config(void);
static void restore_last_major_step(void);
static void restore_before_last_major_step(void);
static real_T *c3_IW(void);
static real_T *c3_IWSTAR(void);
static real_T *c3_Q5(void);
static real_T *c3_Q2(void);
static void init_test_point_addr_map(void);
static void **get_test_point_address_map(void);
static rtwCAPI_ModelMappingInfo *get_test_point_mapping_info(void);

/* Function Definitions */
static void initialize_c3_mybldc_mdl2(void)
{
  uint8_T c3_previousEvent;
  chartInstance.c3_is_C = 0;
  chartInstance.c3_tp_C = 0;
  chartInstance.c3_tp_C1 = 0;
  chartInstance.c3_tp_C2 = 0;
  chartInstance.c3_is_active_c3_mybldc_mdl2 = 0;
  chartInstance.c3_is_c3_mybldc_mdl2 = 0;
  if(!(cdrGetOutputPortReusable(chartInstance.S, 1) != 0)) {
    *c3_Q5() = 0.0;
  }
  if(!(cdrGetOutputPortReusable(chartInstance.S, 2) != 0)) {
    *c3_Q2() = 0.0;
  }
  c3_previousEvent = _sfEvent_;
  _sfEvent_ = CALL_EVENT;
  c3_mybldc_mdl2();
  _sfEvent_ = c3_previousEvent;
  store_current_config();
  store_current_config();
}

static void initialize_params_c3_mybldc_mdl2(void)
{
}

static void enable_c3_mybldc_mdl2(void)
{
}

static void disable_c3_mybldc_mdl2(void)
{
}

static void finalize_c3_mybldc_mdl2(void)
{
}

static void sf_c3_mybldc_mdl2(void)
{
  uint8_T c3_previousEvent;
  _sfTime_ = (real_T)ssGetT(chartInstance.S);
  _SFD_DATA_RANGE_CHECK(*c3_IW(), 2U);
  _SFD_DATA_RANGE_CHECK(*c3_IWSTAR(), 0U);
  _SFD_DATA_RANGE_CHECK(*c3_Q5(), 1U);
  _SFD_DATA_RANGE_CHECK(*c3_Q2(), 3U);
  c3_previousEvent = _sfEvent_;
  _sfEvent_ = CALL_EVENT;
  c3_mybldc_mdl2();
  _sfEvent_ = c3_previousEvent;
}

void c3_mybldc_mdl2(void)
{
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG,2);
  if(chartInstance.c3_is_active_c3_mybldc_mdl2 == 0) {
    _SFD_CC_CALL(CHART_ENTER_ENTRY_FUNCTION_TAG,2);
    chartInstance.c3_is_active_c3_mybldc_mdl2 = 1;
    _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,2);
    if(CV_TRANSITION_EVAL(0U, (int32_T)_SFD_CCP_CALL(0,0,(1))) != 0) {
      _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,0);
      chartInstance.c3_is_c3_mybldc_mdl2 = (uint8_T)c3_IN_C;
      _SFD_CS_CALL(STATE_ACTIVE_TAG,0);
      chartInstance.c3_tp_C = 1;
      if(CV_TRANSITION_EVAL(2U, (int32_T)_SFD_CCP_CALL(2,0,(1))) != 0) {
        _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,2);
        chartInstance.c3_is_C = (uint8_T)c3_IN_C1;
        _SFD_CS_CALL(STATE_ACTIVE_TAG,2);
        chartInstance.c3_tp_C1 = 1;
      }
    }
  } else {
    _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,0);
    switch(chartInstance.c3_is_C) {
     case c3_IN_C1:
      CV_STATE_EVAL(0,0,1);
      _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,2);
      if(CV_TRANSITION_EVAL(1U, (int32_T)_SFD_CCP_CALL(1,0,(*c3_IW() >
          *c3_IWSTAR()))) != 0) {
        _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,1);
        chartInstance.c3_tp_C1 = 0;
        chartInstance.c3_is_C = (uint8_T)c3_IN_NO_ACTIVE_CHILD;
        _SFD_CS_CALL(STATE_INACTIVE_TAG,2);
        chartInstance.c3_is_C = (uint8_T)c3_IN_C2;
        _SFD_CS_CALL(STATE_ACTIVE_TAG,1);
        chartInstance.c3_tp_C2 = 1;
      } else {
        *c3_Q5() = 1.0;
        _SFD_DATA_RANGE_CHECK(*c3_Q5(), 1U);
        *c3_Q2() = 0.0;
        _SFD_DATA_RANGE_CHECK(*c3_Q2(), 3U);
      }
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,2);
      break;
     case c3_IN_C2:
      CV_STATE_EVAL(0,0,2);
      _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,1);
      if(CV_TRANSITION_EVAL(3U, (int32_T)_SFD_CCP_CALL(3,0,(*c3_IW() <
          *c3_IWSTAR()))) != 0) {
        _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,3);
        chartInstance.c3_tp_C2 = 0;
        chartInstance.c3_is_C = (uint8_T)c3_IN_NO_ACTIVE_CHILD;
        _SFD_CS_CALL(STATE_INACTIVE_TAG,1);
        chartInstance.c3_is_C = (uint8_T)c3_IN_C1;
        _SFD_CS_CALL(STATE_ACTIVE_TAG,2);
        chartInstance.c3_tp_C1 = 1;
      } else {
        *c3_Q5() = 0.0;
        _SFD_DATA_RANGE_CHECK(*c3_Q5(), 1U);
        *c3_Q2() = 1.0;
        _SFD_DATA_RANGE_CHECK(*c3_Q2(), 3U);
      }
      _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,1);
      break;
     default:
      CV_STATE_EVAL(0,0,0);
      break;
    }
    _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
  }
  _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,2);
}

static void store_current_config(void)
{
  chartInstance.c3_tp_C_shadow2 = chartInstance.c3_tp_C_shadow1;
  chartInstance.c3_tp_C_shadow1 = chartInstance.c3_tp_C;
  chartInstance.c3_tp_C1_shadow2 = chartInstance.c3_tp_C1_shadow1;
  chartInstance.c3_tp_C1_shadow1 = chartInstance.c3_tp_C1;
  chartInstance.c3_tp_C2_shadow2 = chartInstance.c3_tp_C2_shadow1;
  chartInstance.c3_tp_C2_shadow1 = chartInstance.c3_tp_C2;
  chartInstance.c3_is_active_c3_mybldc_mdl2_shadow2 =
    chartInstance.c3_is_active_c3_mybldc_mdl2_shadow1;
  chartInstance.c3_is_active_c3_mybldc_mdl2_shadow1 =
    chartInstance.c3_is_active_c3_mybldc_mdl2;
  chartInstance.c3_is_c3_mybldc_mdl2_shadow2 =
    chartInstance.c3_is_c3_mybldc_mdl2_shadow1;
  chartInstance.c3_is_c3_mybldc_mdl2_shadow1 =
    chartInstance.c3_is_c3_mybldc_mdl2;
  chartInstance.c3_is_C_shadow2 = chartInstance.c3_is_C_shadow1;
  chartInstance.c3_is_C_shadow1 = chartInstance.c3_is_C;
  chartInstance.c3_Q5_shadow2 = chartInstance.c3_Q5_shadow1;
  chartInstance.c3_Q5_shadow1 = *c3_Q5();
  chartInstance.c3_Q2_shadow2 = chartInstance.c3_Q2_shadow1;
  chartInstance.c3_Q2_shadow1 = *c3_Q2();
  sf_debug_store_current_state_configuration(_mybldc_mdl2MachineNumber_,
   chartInstance.chartNumber, chartInstance.instanceNumber);
}

static void restore_last_major_step(void)
{
  chartInstance.c3_tp_C = chartInstance.c3_tp_C_shadow1;
  chartInstance.c3_tp_C1 = chartInstance.c3_tp_C1_shadow1;
  chartInstance.c3_tp_C2 = chartInstance.c3_tp_C2_shadow1;
  chartInstance.c3_is_active_c3_mybldc_mdl2 =
    chartInstance.c3_is_active_c3_mybldc_mdl2_shadow1;
  chartInstance.c3_is_c3_mybldc_mdl2 =
    chartInstance.c3_is_c3_mybldc_mdl2_shadow1;
  chartInstance.c3_is_C = chartInstance.c3_is_C_shadow1;
  *c3_Q5() = chartInstance.c3_Q5_shadow1;
  *c3_Q2() = chartInstance.c3_Q2_shadow1;
  sf_debug_restore_previous_state_configuration(_mybldc_mdl2MachineNumber_,
   chartInstance.chartNumber, chartInstance.instanceNumber);
}

static void restore_before_last_major_step(void)
{
  chartInstance.c3_tp_C = chartInstance.c3_tp_C_shadow2;
  chartInstance.c3_tp_C1 = chartInstance.c3_tp_C1_shadow2;
  chartInstance.c3_tp_C2 = chartInstance.c3_tp_C2_shadow2;
  chartInstance.c3_is_active_c3_mybldc_mdl2 =
    chartInstance.c3_is_active_c3_mybldc_mdl2_shadow2;
  chartInstance.c3_is_c3_mybldc_mdl2 =
    chartInstance.c3_is_c3_mybldc_mdl2_shadow2;
  chartInstance.c3_is_C = chartInstance.c3_is_C_shadow2;
  *c3_Q5() = chartInstance.c3_Q5_shadow2;
  *c3_Q2() = chartInstance.c3_Q2_shadow2;
  sf_debug_restore_previous_state_configuration2(_mybldc_mdl2MachineNumber_,
   chartInstance.chartNumber, chartInstance.instanceNumber);
}

static real_T *c3_IW(void)
{
  return (real_T *)ssGetInputPortSignal(chartInstance.S, 0);
}

static real_T *c3_IWSTAR(void)
{
  return (real_T *)ssGetInputPortSignal(chartInstance.S, 1);
}

static real_T *c3_Q5(void)
{
  return (real_T *)ssGetOutputPortSignal(chartInstance.S, 1);
}

static real_T *c3_Q2(void)
{
  return (real_T *)ssGetOutputPortSignal(chartInstance.S, 2);
}

static void init_test_point_addr_map(void)
{
  chartInstance.c3_testPointAddrMap[0] = &chartInstance.c3_tp_C;
  chartInstance.c3_testPointAddrMap[1] = &chartInstance.c3_tp_C1;
  chartInstance.c3_testPointAddrMap[2] = &chartInstance.c3_tp_C2;
}

static void **get_test_point_address_map(void)
{
  return &chartInstance.c3_testPointAddrMap[0];
}

static rtwCAPI_ModelMappingInfo *get_test_point_mapping_info(void)
{
  return &chartInstance.c3_testPointMappingInfo;
}

/* SFunction Glue Code */
static void init_test_point_mapping_info(SimStruct *S);
void sf_c3_mybldc_mdl2_get_check_sum(mxArray *plhs[])
{
  ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(1538355029U);
  ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(4111667460U);
  ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(1828672607U);
  ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(1004566360U);
}

mxArray *sf_c3_mybldc_mdl2_get_autoinheritance_info(void)
{
  const char *autoinheritanceInfoStructFieldNames[] =
  {"checksum","inputTypes","inputComplexities","parameterTypes","parameterComplexities","outputSizes","outputTypes","outputComplexities"};
  mxArray *mxAutoinheritanceInfo = NULL;
  mxArray *mxChecksum = NULL;
  mxArray *mxInputTypes = NULL;
  mxArray *mxInputComplexities = NULL;
  mxArray *mxParameterTypes = NULL;
  mxArray *mxParameterComplexities = NULL;
  mxArray *mxOutputSizes = NULL;
  mxArray *mxOutputTypes = NULL;
  mxArray *mxOutputComplexities = NULL;

  mxAutoinheritanceInfo = mxCreateStructMatrix(1,1,
   sizeof(autoinheritanceInfoStructFieldNames)/sizeof(char *),
   autoinheritanceInfoStructFieldNames);

  mxChecksum = mxCreateDoubleMatrix(4,1,mxREAL);
  ((real_T *)mxGetPr((mxChecksum)))[0] = (real_T)(0U);
  ((real_T *)mxGetPr((mxChecksum)))[1] = (real_T)(0U);
  ((real_T *)mxGetPr((mxChecksum)))[2] = (real_T)(0U);
  ((real_T *)mxGetPr((mxChecksum)))[3] = (real_T)(0U);

  mxInputTypes = mxCreateDoubleMatrix(1,2,mxREAL);
  mxInputComplexities = mxCreateDoubleMatrix(1,2,mxREAL);
  ((real_T *)mxGetPr((mxInputTypes)))[0] = (real_T)(10U);
  ((real_T *)mxGetPr((mxInputComplexities)))[0] = (real_T)(0U);
  ((real_T *)mxGetPr((mxInputTypes)))[1] = (real_T)(10U);
  ((real_T *)mxGetPr((mxInputComplexities)))[1] = (real_T)(0U);

  mxParameterTypes = mxCreateDoubleMatrix(1,0,mxREAL);
  mxParameterComplexities = mxCreateDoubleMatrix(1,0,mxREAL);

  mxOutputSizes = mxCreateDoubleMatrix(2,2,mxREAL);
  mxOutputTypes = mxCreateDoubleMatrix(1,2,mxREAL);
  mxOutputComplexities = mxCreateDoubleMatrix(1,2,mxREAL);
  ((real_T *)mxGetPr((mxOutputSizes)))[0] = (real_T)(1U);
  ((real_T *)mxGetPr((mxOutputSizes)))[1] = (real_T)(1U);
  ((real_T *)mxGetPr((mxOutputTypes)))[0] = (real_T)(10U);
  ((real_T *)mxGetPr((mxOutputComplexities)))[0] = (real_T)(0U);
  ((real_T *)mxGetPr((mxOutputSizes)))[2] = (real_T)(1U);
  ((real_T *)mxGetPr((mxOutputSizes)))[3] = (real_T)(1U);
  ((real_T *)mxGetPr((mxOutputTypes)))[1] = (real_T)(10U);
  ((real_T *)mxGetPr((mxOutputComplexities)))[1] = (real_T)(0U);

  mxSetFieldByNumber(mxAutoinheritanceInfo,0,0,mxChecksum);
  mxSetFieldByNumber(mxAutoinheritanceInfo,0,1,mxInputTypes);
  mxSetFieldByNumber(mxAutoinheritanceInfo,0,2,mxInputComplexities);
  mxSetFieldByNumber(mxAutoinheritanceInfo,0,3,mxParameterTypes);
  mxSetFieldByNumber(mxAutoinheritanceInfo,0,4,mxParameterComplexities);
  mxSetFieldByNumber(mxAutoinheritanceInfo,0,5,mxOutputSizes);
  mxSetFieldByNumber(mxAutoinheritanceInfo,0,6,mxOutputTypes);
  mxSetFieldByNumber(mxAutoinheritanceInfo,0,7,mxOutputComplexities);

  return(mxAutoinheritanceInfo);
}

static void chart_debug_initialization(SimStruct *S)
{
  if(ssIsFirstInitCond(S)) {
    /* do this only if simulation is starting */
    if(!sim_mode_is_rtw_gen(S)) {
      {
        unsigned int chartAlreadyPresent;
        chartAlreadyPresent =
          sf_debug_initialize_chart(_mybldc_mdl2MachineNumber_,
         3,
         3,
         4,
         4,
         0,
         0,
         0,
         0,
         &(chartInstance.chartNumber),
         &(chartInstance.instanceNumber),
         ssGetPath(S),
         (void *)S);
        if(chartAlreadyPresent==0) {
          /* this is the first instance */
          sf_debug_set_chart_disable_implicit_casting(_mybldc_mdl2MachineNumber_,chartInstance.chartNumber,0);
          sf_debug_set_chart_event_thresholds(_mybldc_mdl2MachineNumber_,
           chartInstance.chartNumber,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -