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

📄 c6_lmdap_library_ncs.c

📁 m files for SIAM book, Numerical Computing with MATLAB
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Include files */
#include "LMdap_Library_NCS_sfun.h"
#include "c6_LMdap_Library_NCS.h"
#define CHARTINSTANCE_CHARTNUMBER       (chartInstance->chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER    (chartInstance->instanceNumber)
#include "LMdap_Library_NCS_sfun_debug_macros.h"

/* Type Definitions */

/* Named Constants */
#define c6_IN_NO_ACTIVE_CHILD           (0)

/* Variable Declarations */

/* Variable Definitions */

/* Function Declarations */
static void initialize_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance);
static void
initialize_params_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance);
static void enable_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance);
static void disable_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance);
static void finalize_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance);
static void sf_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance);
static void init_script_number_translation(uint32_T c6_machineNumber, uint32_T
 c6_chartNumber);
static real_T c6_mpower(SFc6_LMdap_Library_NCSInstanceStruct *chartInstance,
 real_T c6_a);
static const mxArray *c6_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_b_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_c_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_d_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_e_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_f_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_g_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_h_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_i_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_j_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_k_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_l_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_m_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_n_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_o_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_p_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_q_sf_marshall(void *chartInstanceVoid, void *c6_u);
static const mxArray *c6_r_sf_marshall(void *chartInstanceVoid, void *c6_u);
static void c6_info_helper(SFc6_LMdap_Library_NCSInstanceStruct *chartInstance,
 c6_ResolvedFunctionInfo c6_info[52]);
static void init_dsm_address_info(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance);

/* Function Definitions */
static void initialize_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance)
{
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  chartInstance->c6_is_active_c6_LMdap_Library_NCS = 0U;
}

static void
initialize_params_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance)
{
}

static void enable_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance)
{
}

static void disable_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance)
{
}

static void finalize_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance)
{
}

static void sf_c6_LMdap_Library_NCS(SFc6_LMdap_Library_NCSInstanceStruct
 *chartInstance)
{
  int32_T c6_i0;
  uint8_T c6_previousEvent;
  int32_T c6_i1;
  real_T c6_e[2];
  real_T c6_Njets;
  real_T c6_DB;
  real_T c6_alph;
  real_T c6_alphs;
  real_T c6_u;
  real_T c6_x3;
  real_T c6_x2;
  real_T c6_x1;
  real_T c6_accels;
  real_T c6_accel;
  real_T c6_ac;
  real_T c6_tcalc;
  real_T c6_tcalc1;
  real_T c6_Coastfct2;
  real_T c6_Firefct2;
  real_T c6_Coastfct1;
  real_T c6_Firefct1;
  real_T c6_A;
  real_T c6_B;
  real_T c6_x;
  real_T c6_y;
  real_T c6_b_A;
  real_T c6_b_B;
  real_T c6_b_x;
  real_T c6_b_y;
  real_T c6_c_y;
  real_T c6_c_A;
  real_T c6_c_B;
  real_T c6_c_x;
  real_T c6_d_y;
  real_T c6_e_y;
  real_T c6_d_A;
  real_T c6_d_B;
  real_T c6_d_x;
  real_T c6_f_y;
  real_T c6_g_y;
  real_T c6_e_A;
  real_T c6_e_B;
  real_T c6_e_x;
  real_T c6_h_y;
  real_T c6_i_y;
  real_T c6_f_A;
  real_T c6_f_B;
  real_T c6_f_x;
  real_T c6_j_y;
  real_T c6_g_A;
  real_T c6_g_B;
  real_T c6_g_x;
  real_T c6_k_y;
  real_T c6_h_A;
  real_T c6_h_B;
  real_T c6_h_x;
  real_T c6_l_y;
  real_T c6_i_A;
  real_T c6_i_B;
  real_T c6_i_x;
  real_T c6_m_y;
  real_T c6_n_y;
  real_T c6_j_x;
  real_T c6_o_y;
  real_T c6_k_x;
  int32_T c6_i2;
  static char c6_cv0[31] = { 'E', 'm', 'b', 'e', 'd', 'd', 'e', 'd', 'M', 'A',
    'T', 'L', 'A', 'B', ':', 's', 'q', 'r', 't', ':', 'd',
    'o', 'm', 'a', 'i', 'n', 'E', 'r', 'r', 'o', 'r' };
  char c6_b_x1[31];
  int32_T c6_i3;
  static char c6_cv1[77] = { 'D', 'o', 'm', 'a', 'i', 'n', ' ', 'e', 'r', 'r',
    'o', 'r', '.', ' ', 'T', 'o', ' ', 'c', 'o', 'm', 'p',
    'u', 't', 'e', ' ', 'c', 'o', 'm', 'p', 'l', 'e', 'x', ' ', 'r', 'e', 's',
    'u', 'l', 't', 's', ' ', 'f',
    'r', 'o', 'm', ' ', 'r', 'e', 'a', 'l', ' ', 'x', ',', ' ', 'u', 's', 'e',
    ' ', '\'', 's', 'q', 'r', 't'
    , '(', 'c', 'o', 'm', 'p', 'l', 'e', 'x', '(', 'x', ')', ')', '\'', '.' };
  char c6_b_x2[77];
  int32_T c6_i4;
  char c6_b_u[31];
  const mxArray *c6_p_y = NULL;
  int32_T c6_i5;
  char c6_c_u[77];
  const mxArray *c6_q_y = NULL;
  real_T *c6_b_Njets;
  real_T *c6_b_DB;
  real_T *c6_b_alph;
  real_T *c6_b_alphs;
  real_T *c6_b_Firefct1;
  real_T *c6_b_Coastfct1;
  real_T *c6_b_Firefct2;
  real_T *c6_b_Coastfct2;
  real_T *c6_b_tcalc1;
  real_T *c6_b_tcalc;
  real_T (*c6_b_e)[2];
  c6_b_Coastfct2 = (real_T *)ssGetOutputPortSignal(chartInstance->S, 4);
  c6_b_alph = (real_T *)ssGetInputPortSignal(chartInstance->S, 3);
  c6_b_Firefct1 = (real_T *)ssGetOutputPortSignal(chartInstance->S, 1);
  c6_b_Coastfct1 = (real_T *)ssGetOutputPortSignal(chartInstance->S, 2);
  c6_b_Firefct2 = (real_T *)ssGetOutputPortSignal(chartInstance->S, 3);
  c6_b_Njets = (real_T *)ssGetInputPortSignal(chartInstance->S, 1);
  c6_b_DB = (real_T *)ssGetInputPortSignal(chartInstance->S, 2);
  c6_b_tcalc1 = (real_T *)ssGetOutputPortSignal(chartInstance->S, 5);
  c6_b_alphs = (real_T *)ssGetInputPortSignal(chartInstance->S, 4);
  c6_b_e = (real_T (*)[2])ssGetInputPortSignal(chartInstance->S, 0);
  c6_b_tcalc = (real_T *)ssGetOutputPortSignal(chartInstance->S, 6);
  _sfTime_ = (real_T)ssGetT(chartInstance->S);
  for(c6_i0 = 0; c6_i0 < 2; c6_i0 = c6_i0 + 1) {
    _SFD_DATA_RANGE_CHECK((*c6_b_e)[c6_i0], 0U);
  }
  _SFD_DATA_RANGE_CHECK(*c6_b_Njets, 4U);
  _SFD_DATA_RANGE_CHECK(*c6_b_DB, 2U);
  _SFD_DATA_RANGE_CHECK(*c6_b_alph, 1U);
  _SFD_DATA_RANGE_CHECK(*c6_b_alphs, 7U);
  _SFD_DATA_RANGE_CHECK(*c6_b_Firefct1, 8U);
  _SFD_DATA_RANGE_CHECK(*c6_b_Coastfct1, 3U);
  _SFD_DATA_RANGE_CHECK(*c6_b_Firefct2, 9U);
  _SFD_DATA_RANGE_CHECK(*c6_b_Coastfct2, 10U);
  _SFD_DATA_RANGE_CHECK(*c6_b_tcalc1, 5U);
  _SFD_DATA_RANGE_CHECK(*c6_b_tcalc, 6U);
  c6_previousEvent = _sfEvent_;
  _sfEvent_ = CALL_EVENT;
  _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG,1);
  for(c6_i1 = 0; c6_i1 < 2; c6_i1 = c6_i1 + 1) {
    c6_e[c6_i1] = (*c6_b_e)[c6_i1];
  }
  c6_Njets = *c6_b_Njets;
  c6_DB = *c6_b_DB;
  c6_alph = *c6_b_alph;
  c6_alphs = *c6_b_alphs;
  sf_debug_symbol_scope_push(18U, 0U);
  sf_debug_symbol_scope_add("u", &c6_u, c6_r_sf_marshall);
  sf_debug_symbol_scope_add("x3", &c6_x3, c6_q_sf_marshall);
  sf_debug_symbol_scope_add("x2", &c6_x2, c6_p_sf_marshall);
  sf_debug_symbol_scope_add("x1", &c6_x1, c6_o_sf_marshall);
  sf_debug_symbol_scope_add("accels", &c6_accels, c6_n_sf_marshall);
  sf_debug_symbol_scope_add("accel", &c6_accel, c6_m_sf_marshall);
  sf_debug_symbol_scope_add("ac", &c6_ac, c6_l_sf_marshall);
  sf_debug_symbol_scope_add("tcalc", &c6_tcalc, c6_k_sf_marshall);
  sf_debug_symbol_scope_add("tcalc1", &c6_tcalc1, c6_j_sf_marshall);
  sf_debug_symbol_scope_add("Coastfct2", &c6_Coastfct2, c6_i_sf_marshall);
  sf_debug_symbol_scope_add("Firefct2", &c6_Firefct2, c6_h_sf_marshall);
  sf_debug_symbol_scope_add("Coastfct1", &c6_Coastfct1, c6_g_sf_marshall);
  sf_debug_symbol_scope_add("Firefct1", &c6_Firefct1, c6_f_sf_marshall);
  sf_debug_symbol_scope_add("alphs", &c6_alphs, c6_e_sf_marshall);
  sf_debug_symbol_scope_add("alph", &c6_alph, c6_d_sf_marshall);
  sf_debug_symbol_scope_add("DB", &c6_DB, c6_c_sf_marshall);
  sf_debug_symbol_scope_add("Njets", &c6_Njets, c6_b_sf_marshall);
  sf_debug_symbol_scope_add("e", &c6_e, c6_sf_marshall);
  CV_EML_FCN(0, 0);
  /*  Time at full accel for e_dot = 0 (cross the e axis) is tcalc1. */
  /*     (This time is positive in RHP and negative in the LHP, and */
  /*     this is accounted for in the calculation of the total on time */
  /*     in the Stateflow chart). */
  /*  The intersection of the switch curve and the "on" trajectory */
  /*     determines the value of xdot at the switch curve.  This value */
  /*     divided by the acceleration is the time needed to go from */
  /*     the e axis crossing to the switch curve (tcalc).  The two times */
  /*     tcalc and tcalc1 are added together in the State Chart.   */
  /*     Note that the square plus or minus value are accounted for */
  /*     in the State Chart (when in the RHP we add  tcalc and tcalc1,  */
  /*     and in the LHP we subtract tcalc1 (which is <0) from  */
  /*     tcalc (>0 always). */
  /*     Constants used in the calculations: */
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,20);
  c6_A = 2.0 * c6_alphs;
  c6_B = c6_alph + c6_alphs;
  c6_x = c6_A;
  c6_y = c6_B;
  c6_ac = c6_x / c6_y;
  /*     Changable constants used in the calculation: */
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,23);
  c6_accel = c6_Njets * c6_alph;
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,24);
  c6_accels = c6_Njets * c6_alphs;
  /*    Evaluate the location in the phase plane w.r.t the 4 parabolas: */
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,27);
  c6_b_A = c6_mpower(chartInstance, c6_e[1]);
  c6_b_B = 2.0 * c6_accel;
  c6_b_x = c6_b_A;
  c6_b_y = c6_b_B;
  c6_c_y = c6_b_x / c6_b_y;
  c6_Firefct1 = (c6_e[0] - c6_DB) + c6_c_y;
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,28);
  c6_c_A = c6_mpower(chartInstance, c6_e[1]);
  c6_c_B = 2.0 * c6_accels;
  c6_c_x = c6_c_A;
  c6_d_y = c6_c_B;
  c6_e_y = c6_c_x / c6_d_y;
  c6_Coastfct1 = (c6_e[0] - c6_DB) - c6_e_y;
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,29);
  c6_d_A = c6_mpower(chartInstance, c6_e[1]);
  c6_d_B = 2.0 * c6_accel;
  c6_d_x = c6_d_A;
  c6_f_y = c6_d_B;
  c6_g_y = c6_d_x / c6_f_y;
  c6_Firefct2 = (c6_e[0] + c6_DB) - c6_g_y;
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,30);
  c6_e_A = c6_mpower(chartInstance, c6_e[1]);
  c6_e_B = 2.0 * c6_accels;
  c6_e_x = c6_e_A;
  c6_h_y = c6_e_B;
  c6_i_y = c6_e_x / c6_h_y;
  c6_Coastfct2 = (c6_e[0] + c6_DB) + c6_i_y;
  /*    Compute the on time for a jet firing based on phase plane locations: */
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,34);
  c6_f_A = c6_e[0];
  c6_f_B = c6_accel;
  c6_f_x = c6_f_A;
  c6_j_y = c6_f_B;
  c6_x1 = c6_f_x / c6_j_y;
  /*  Scal position for jet on time calc. */
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,35);
  c6_g_A = c6_e[1];
  c6_g_B = c6_accel;
  c6_g_x = c6_g_A;
  c6_k_y = c6_g_B;
  c6_x2 = c6_g_x / c6_k_y;
  /*  Time at full accel for e_dot = 0. */
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,36);
  c6_h_A = c6_DB;
  c6_h_B = c6_accel;
  c6_h_x = c6_h_A;
  c6_l_y = c6_h_B;
  c6_x3 = c6_h_x / c6_l_y;
  /*  Scale Dead Band for on time calc. */
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,37);
  c6_tcalc1 = c6_x2;
  /*  Time to reach the e axis from edot. */
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,38);
  c6_i_A = c6_mpower(chartInstance, c6_x2);
  c6_i_B = 2.0;
  c6_i_x = c6_i_A;
  c6_m_y = c6_i_B;
  c6_n_y = c6_i_x / c6_m_y;
  c6_j_x = c6_x1;
  c6_o_y = fabs(c6_j_x);
  c6_u = ((c6_o_y + c6_n_y) - c6_x3) * c6_ac;

⌨️ 快捷键说明

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