c1_servo_demo.c
上传用户:m_sun_001
上传日期:2014-07-30
资源大小:1115k
文件大小:34k
源码类别:

matlab例程

开发平台:

Matlab

  1. /* Include files */
  2. #include "servo_demo_sfun.h"
  3. #include "c1_servo_demo.h"
  4. #define CHARTINSTANCE_CHARTNUMBER       (chartInstance.chartNumber)
  5. #define CHARTINSTANCE_INSTANCENUMBER    (chartInstance.instanceNumber)
  6. #include "servo_demo_sfun_debug_macros.h"
  7. /* Type Definitions */
  8. /* Named Constants */
  9. #define c1_IN_NO_ACTIVE_CHILD           (0)
  10. #define c1_IN_energize_solenoid         (1)
  11. #define c1_IN_pull_in_current           (1)
  12. #define c1_IN_regulate_hold_current     (2)
  13. #define c1_IN_freewheel                 (1)
  14. #define c1_IN_solenoid_off              (2)
  15. #define c1_IN_hold                      (2)
  16. /* Variable Declarations */
  17. /* Variable Definitions */
  18. static SFc1_servo_demoInstanceStruct chartInstance;
  19. /* Function Declarations */
  20. static void initialize_c1_servo_demo(void);
  21. static void enable_c1_servo_demo(void);
  22. static void disable_c1_servo_demo(void);
  23. static void finalize_c1_servo_demo(void);
  24. static void sf_c1_servo_demo(void);
  25. static int32_T c1__s32_uminus__(int32_T c1_b);
  26. static real_T *c1_v(void);
  27. static real_T *c1_duty_cycle(void);
  28. static real_T *c1_i(void);
  29. static void init_test_point_addr_map(void);
  30. static void **get_test_point_address_map(void);
  31. static rtwCAPI_ModelMappingInfo *get_test_point_mapping_info(void);
  32. /* Function Definitions */
  33. static void initialize_c1_servo_demo(void)
  34. {
  35.   chartInstance.c1_is_energize_solenoid = 0;
  36.   chartInstance.c1_tp_energize_solenoid = 0;
  37.   chartInstance.c1_tp_pull_in_current = 0;
  38.   chartInstance.c1_is_regulate_hold_current = 0;
  39.   chartInstance.c1_tp_regulate_hold_current = 0;
  40.   chartInstance.c1_tp_freewheel = 0;
  41.   chartInstance.c1_tp_hold = 0;
  42.   chartInstance.c1_tp_solenoid_off = 0;
  43.   chartInstance.c1_is_active_c1_servo_demo = 0;
  44.   chartInstance.c1_is_c1_servo_demo = 0;
  45.   chartInstance.c1_ton = 0.0;
  46.   chartInstance.c1_toff = 0.0;
  47.   if(!(cdrGetOutputPortReusable(chartInstance.S, 1) != 0)) {
  48.     *c1_v() = 0.0;
  49.   }
  50.   {
  51.     real_T c1_sf_d6;
  52.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): Error evaluating chart workspace data 'Tpwm' in the chart's parent workspace.n");
  53.     sf_mex_import(sf_mex_get_sfun_param(chartInstance.S, 2),
  54.      "sf_mex_get_sfun_param", &c1_sf_d6, 0, 0U, 0, 0);
  55.     chartInstance.c1_Tpwm = c1_sf_d6;
  56.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): ");
  57.   }
  58.   {
  59.     real_T c1_sf_d5;
  60.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): Error evaluating chart workspace data 'Ipull' in the chart's parent workspace.n");
  61.     sf_mex_import(sf_mex_get_sfun_param(chartInstance.S, 1),
  62.      "sf_mex_get_sfun_param", &c1_sf_d5, 0, 0U, 0, 0);
  63.     chartInstance.c1_Ipull = c1_sf_d5;
  64.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): ");
  65.   }
  66.   {
  67.     real_T c1_sf_d4;
  68.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): Error evaluating chart workspace data 'Ihold' in the chart's parent workspace.n");
  69.     sf_mex_import(sf_mex_get_sfun_param(chartInstance.S, 0),
  70.      "sf_mex_get_sfun_param", &c1_sf_d4, 0, 0U, 0, 0);
  71.     chartInstance.c1_Ihold = c1_sf_d4;
  72.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): ");
  73.   }
  74.   {
  75.     real_T c1_sf_d3;
  76.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): Error evaluating chart workspace data 'deltai' in the chart's parent workspace.n");
  77.     sf_mex_import(sf_mex_get_sfun_param(chartInstance.S, 6),
  78.      "sf_mex_get_sfun_param", &c1_sf_d3, 0, 0U, 0, 0);
  79.     chartInstance.c1_deltai = c1_sf_d3;
  80.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): ");
  81.   }
  82.   {
  83.     real_T c1_sf_d2;
  84.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): Error evaluating chart workspace data 'Vs' in the chart's parent workspace.n");
  85.     sf_mex_import(sf_mex_get_sfun_param(chartInstance.S, 4),
  86.      "sf_mex_get_sfun_param", &c1_sf_d2, 0, 0U, 0, 0);
  87.     chartInstance.c1_Vs = c1_sf_d2;
  88.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): ");
  89.   }
  90.   {
  91.     real_T c1_sf_d1;
  92.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): Error evaluating chart workspace data 'Vz' in the chart's parent workspace.n");
  93.     sf_mex_import(sf_mex_get_sfun_param(chartInstance.S, 5),
  94.      "sf_mex_get_sfun_param", &c1_sf_d1, 0, 0U, 0, 0);
  95.     chartInstance.c1_Vz = c1_sf_d1;
  96.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): ");
  97.   }
  98.   {
  99.     real_T c1_sf_d0;
  100.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): Error evaluating chart workspace data 'Vd' in the chart's parent workspace.n");
  101.     sf_mex_import(sf_mex_get_sfun_param(chartInstance.S, 3),
  102.      "sf_mex_get_sfun_param", &c1_sf_d0, 0, 0U, 0, 0);
  103.     chartInstance.c1_Vd = c1_sf_d0;
  104.     sf_set_error_prefix_string("Stateflow Runtime Error (chart): ");
  105.   }
  106. }
  107. static void enable_c1_servo_demo(void)
  108. {
  109. }
  110. static void disable_c1_servo_demo(void)
  111. {
  112. }
  113. static void finalize_c1_servo_demo(void)
  114. {
  115. }
  116. static void sf_c1_servo_demo(void)
  117. {
  118.   uint8_T c1_previousEvent;
  119.   _sfTime_ = (real_T)ssGetT(chartInstance.S);
  120.   _SFD_DATA_RANGE_CHECK(*c1_v(), 6U);
  121.   _SFD_DATA_RANGE_CHECK_MIN_MAX(*c1_duty_cycle(), 0U, 0.0, 100.0);
  122.   _SFD_DATA_RANGE_CHECK(chartInstance.c1_ton, 3U);
  123.   _SFD_DATA_RANGE_CHECK(chartInstance.c1_toff, 7U);
  124.   _SFD_DATA_RANGE_CHECK(chartInstance.c1_Tpwm, 5U);
  125.   _SFD_DATA_RANGE_CHECK(chartInstance.c1_Ipull, 1U);
  126.   _SFD_DATA_RANGE_CHECK(chartInstance.c1_Ihold, 4U);
  127.   _SFD_DATA_RANGE_CHECK(chartInstance.c1_deltai, 11U);
  128.   _SFD_DATA_RANGE_CHECK(chartInstance.c1_Vs, 8U);
  129.   _SFD_DATA_RANGE_CHECK(chartInstance.c1_Vz, 9U);
  130.   _SFD_DATA_RANGE_CHECK(chartInstance.c1_Vd, 2U);
  131.   _SFD_DATA_RANGE_CHECK(*c1_i(), 10U);
  132.   c1_previousEvent = _sfEvent_;
  133.   _sfEvent_ = CALL_EVENT;
  134.   _SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG,0);
  135.   if(chartInstance.c1_is_active_c1_servo_demo == 0) {
  136.     _SFD_CC_CALL(CHART_ENTER_ENTRY_FUNCTION_TAG,0);
  137.     chartInstance.c1_is_active_c1_servo_demo = 1;
  138.     _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
  139.     _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,4);
  140.     chartInstance.c1_ton = 0.0;
  141.     _SFD_DATA_RANGE_CHECK(chartInstance.c1_ton, 3U);
  142.     _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,0);
  143.     chartInstance.c1_toff = chartInstance.c1_ton + *c1_duty_cycle() *
  144.       chartInstance.c1_Tpwm / 100.0;
  145.     _SFD_DATA_RANGE_CHECK(chartInstance.c1_toff, 7U);
  146.     chartInstance.c1_is_c1_servo_demo = (uint8_T)c1_IN_energize_solenoid;
  147.     _SFD_CS_CALL(STATE_ACTIVE_TAG,1);
  148.     chartInstance.c1_tp_energize_solenoid = 1;
  149.     _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,3);
  150.     chartInstance.c1_is_energize_solenoid = (uint8_T)c1_IN_pull_in_current;
  151.     _SFD_CS_CALL(STATE_ACTIVE_TAG,2);
  152.     chartInstance.c1_tp_pull_in_current = 1;
  153.     *c1_v() = chartInstance.c1_Vs;
  154.     _SFD_DATA_RANGE_CHECK(*c1_v(), 6U);
  155.   } else {
  156.     switch(chartInstance.c1_is_c1_servo_demo) {
  157.      case c1_IN_energize_solenoid:
  158.       CV_CHART_EVAL(0,0,1);
  159.       _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,1);
  160.       if(CV_TRANSITION_EVAL(2U, (int32_T)_SFD_CCP_CALL(2,0,(_sfTime_ >
  161.           chartInstance.c1_toff))) != 0) {
  162.         _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,2);
  163.         chartInstance.c1_ton += chartInstance.c1_Tpwm;
  164.         _SFD_DATA_RANGE_CHECK(chartInstance.c1_ton, 3U);
  165.         switch(chartInstance.c1_is_energize_solenoid) {
  166.          case c1_IN_pull_in_current:
  167.           CV_STATE_EVAL(1,1,1);
  168.           chartInstance.c1_tp_pull_in_current = 0;
  169.           chartInstance.c1_is_energize_solenoid = (uint8_T)c1_IN_NO_ACTIVE_CHILD;
  170.           _SFD_CS_CALL(STATE_INACTIVE_TAG,2);
  171.           break;
  172.          case c1_IN_regulate_hold_current:
  173.           CV_STATE_EVAL(1,1,2);
  174.           switch(chartInstance.c1_is_regulate_hold_current) {
  175.            case c1_IN_freewheel:
  176.             CV_STATE_EVAL(5,1,1);
  177.             chartInstance.c1_tp_freewheel = 0;
  178.             chartInstance.c1_is_regulate_hold_current =
  179.               (uint8_T)c1_IN_NO_ACTIVE_CHILD;
  180.             _SFD_CS_CALL(STATE_INACTIVE_TAG,4);
  181.             break;
  182.            case c1_IN_hold:
  183.             CV_STATE_EVAL(5,1,2);
  184.             chartInstance.c1_tp_hold = 0;
  185.             chartInstance.c1_is_regulate_hold_current =
  186.               (uint8_T)c1_IN_NO_ACTIVE_CHILD;
  187.             _SFD_CS_CALL(STATE_INACTIVE_TAG,3);
  188.             break;
  189.            default:
  190.             CV_STATE_EVAL(5,1,0);
  191.             break;
  192.           }
  193.           chartInstance.c1_tp_regulate_hold_current = 0;
  194.           chartInstance.c1_is_energize_solenoid = (uint8_T)c1_IN_NO_ACTIVE_CHILD;
  195.           _SFD_CS_CALL(STATE_INACTIVE_TAG,5);
  196.           break;
  197.          default:
  198.           CV_STATE_EVAL(1,1,0);
  199.           break;
  200.         }
  201.         chartInstance.c1_tp_energize_solenoid = 0;
  202.         chartInstance.c1_is_c1_servo_demo = (uint8_T)c1_IN_NO_ACTIVE_CHILD;
  203.         _SFD_CS_CALL(STATE_INACTIVE_TAG,1);
  204.         chartInstance.c1_is_c1_servo_demo = (uint8_T)c1_IN_solenoid_off;
  205.         _SFD_CS_CALL(STATE_ACTIVE_TAG,0);
  206.         chartInstance.c1_tp_solenoid_off = 1;
  207.         *c1_v() = (real_T)c1__s32_uminus__(*c1_i() > 0.0) * chartInstance.c1_Vz;
  208.         _SFD_DATA_RANGE_CHECK(*c1_v(), 6U);
  209.       } else {
  210.         switch(chartInstance.c1_is_energize_solenoid) {
  211.          case c1_IN_pull_in_current:
  212.           CV_STATE_EVAL(1,0,1);
  213.           _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,2);
  214.           if(CV_TRANSITION_EVAL(6U, (int32_T)_SFD_CCP_CALL(6,0,(*c1_i() >=
  215.               chartInstance.c1_Ipull))) != 0) {
  216.             _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,6);
  217.             chartInstance.c1_tp_pull_in_current = 0;
  218.             chartInstance.c1_is_energize_solenoid =
  219.               (uint8_T)c1_IN_NO_ACTIVE_CHILD;
  220.             _SFD_CS_CALL(STATE_INACTIVE_TAG,2);
  221.             chartInstance.c1_is_energize_solenoid =
  222.               (uint8_T)c1_IN_regulate_hold_current;
  223.             _SFD_CS_CALL(STATE_ACTIVE_TAG,5);
  224.             chartInstance.c1_tp_regulate_hold_current = 1;
  225.             _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,8);
  226.             chartInstance.c1_is_regulate_hold_current = (uint8_T)c1_IN_freewheel;
  227.             _SFD_CS_CALL(STATE_ACTIVE_TAG,4);
  228.             chartInstance.c1_tp_freewheel = 1;
  229.             *c1_v() = (real_T)c1__s32_uminus__(*c1_i() > 0.0) *
  230.               chartInstance.c1_Vd;
  231.             _SFD_DATA_RANGE_CHECK(*c1_v(), 6U);
  232.           }
  233.           _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,2);
  234.           break;
  235.          case c1_IN_regulate_hold_current:
  236.           CV_STATE_EVAL(1,0,2);
  237.           _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,5);
  238.           switch(chartInstance.c1_is_regulate_hold_current) {
  239.            case c1_IN_freewheel:
  240.             CV_STATE_EVAL(5,0,1);
  241.             _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,4);
  242.             if(CV_TRANSITION_EVAL(1U, (int32_T)_SFD_CCP_CALL(1,0,(*c1_i() <=
  243.                 chartInstance.c1_Ihold - chartInstance.c1_deltai))) != 0) {
  244.               _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,1);
  245.               chartInstance.c1_tp_freewheel = 0;
  246.               chartInstance.c1_is_regulate_hold_current =
  247.                 (uint8_T)c1_IN_NO_ACTIVE_CHILD;
  248.               _SFD_CS_CALL(STATE_INACTIVE_TAG,4);
  249.               chartInstance.c1_is_regulate_hold_current = (uint8_T)c1_IN_hold;
  250.               _SFD_CS_CALL(STATE_ACTIVE_TAG,3);
  251.               chartInstance.c1_tp_hold = 1;
  252.               *c1_v() = chartInstance.c1_Vs;
  253.               _SFD_DATA_RANGE_CHECK(*c1_v(), 6U);
  254.             } else {
  255.               *c1_v() = (real_T)c1__s32_uminus__(*c1_i() > 0.0) *
  256.                 chartInstance.c1_Vd;
  257.               _SFD_DATA_RANGE_CHECK(*c1_v(), 6U);
  258.             }
  259.             _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,4);
  260.             break;
  261.            case c1_IN_hold:
  262.             CV_STATE_EVAL(5,0,2);
  263.             _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,3);
  264.             if(CV_TRANSITION_EVAL(5U, (int32_T)_SFD_CCP_CALL(5,0,(*c1_i() >=
  265.                 chartInstance.c1_Ihold + chartInstance.c1_deltai))) != 0) {
  266.               _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,5);
  267.               chartInstance.c1_tp_hold = 0;
  268.               chartInstance.c1_is_regulate_hold_current =
  269.                 (uint8_T)c1_IN_NO_ACTIVE_CHILD;
  270.               _SFD_CS_CALL(STATE_INACTIVE_TAG,3);
  271.               chartInstance.c1_is_regulate_hold_current =
  272.                 (uint8_T)c1_IN_freewheel;
  273.               _SFD_CS_CALL(STATE_ACTIVE_TAG,4);
  274.               chartInstance.c1_tp_freewheel = 1;
  275.               *c1_v() = (real_T)c1__s32_uminus__(*c1_i() > 0.0) *
  276.                 chartInstance.c1_Vd;
  277.               _SFD_DATA_RANGE_CHECK(*c1_v(), 6U);
  278.             }
  279.             _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,3);
  280.             break;
  281.            default:
  282.             CV_STATE_EVAL(5,0,0);
  283.             break;
  284.           }
  285.           _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,5);
  286.           break;
  287.          default:
  288.           CV_STATE_EVAL(1,0,0);
  289.           break;
  290.         }
  291.       }
  292.       _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,1);
  293.       break;
  294.      case c1_IN_solenoid_off:
  295.       CV_CHART_EVAL(0,0,2);
  296.       _SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,0);
  297.       if(CV_TRANSITION_EVAL(7U, (int32_T)_SFD_CCP_CALL(7,0,(_sfTime_ >=
  298.           chartInstance.c1_ton))) != 0) {
  299.         _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,7);
  300.         _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,0);
  301.         chartInstance.c1_toff = chartInstance.c1_ton + *c1_duty_cycle() *
  302.           chartInstance.c1_Tpwm / 100.0;
  303.         _SFD_DATA_RANGE_CHECK(chartInstance.c1_toff, 7U);
  304.         chartInstance.c1_tp_solenoid_off = 0;
  305.         chartInstance.c1_is_c1_servo_demo = (uint8_T)c1_IN_NO_ACTIVE_CHILD;
  306.         _SFD_CS_CALL(STATE_INACTIVE_TAG,0);
  307.         chartInstance.c1_is_c1_servo_demo = (uint8_T)c1_IN_energize_solenoid;
  308.         _SFD_CS_CALL(STATE_ACTIVE_TAG,1);
  309.         chartInstance.c1_tp_energize_solenoid = 1;
  310.         _SFD_CT_CALL(TRANSITION_ACTIVE_TAG,3);
  311.         chartInstance.c1_is_energize_solenoid = (uint8_T)c1_IN_pull_in_current;
  312.         _SFD_CS_CALL(STATE_ACTIVE_TAG,2);
  313.         chartInstance.c1_tp_pull_in_current = 1;
  314.         *c1_v() = chartInstance.c1_Vs;
  315.         _SFD_DATA_RANGE_CHECK(*c1_v(), 6U);
  316.       } else {
  317.         *c1_v() = (real_T)c1__s32_uminus__(*c1_i() > 0.0) * chartInstance.c1_Vz;
  318.         _SFD_DATA_RANGE_CHECK(*c1_v(), 6U);
  319.       }
  320.       _SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
  321.       break;
  322.      default:
  323.       CV_CHART_EVAL(0,0,0);
  324.       break;
  325.     }
  326.   }
  327.   _SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
  328.   _sfEvent_ = c1_previousEvent;
  329. }
  330. static int32_T c1__s32_uminus__(int32_T c1_b)
  331. {
  332.   if(c1_b < -2147483647) {
  333.     sf_debug_overflow_detection(0);
  334.   }
  335.   return -c1_b;
  336. }
  337. static real_T *c1_v(void)
  338. {
  339.   return (real_T *)ssGetOutputPortSignal(chartInstance.S, 1);
  340. }
  341. static real_T *c1_duty_cycle(void)
  342. {
  343.   return (real_T *)ssGetInputPortSignal(chartInstance.S, 0);
  344. }
  345. static real_T *c1_i(void)
  346. {
  347.   return (real_T *)ssGetInputPortSignal(chartInstance.S, 1);
  348. }
  349. static void init_test_point_addr_map(void)
  350. {
  351.   chartInstance.c1_testPointAddrMap[0] = &chartInstance.c1_ton;
  352.   chartInstance.c1_testPointAddrMap[1] = &chartInstance.c1_toff;
  353.   chartInstance.c1_testPointAddrMap[2] = &chartInstance.c1_tp_energize_solenoid;
  354.   chartInstance.c1_testPointAddrMap[3] = &chartInstance.c1_tp_pull_in_current;
  355.   chartInstance.c1_testPointAddrMap[4] =
  356.     &chartInstance.c1_tp_regulate_hold_current;
  357.   chartInstance.c1_testPointAddrMap[5] = &chartInstance.c1_tp_freewheel;
  358.   chartInstance.c1_testPointAddrMap[6] = &chartInstance.c1_tp_hold;
  359.   chartInstance.c1_testPointAddrMap[7] = &chartInstance.c1_tp_solenoid_off;
  360. }
  361. static void **get_test_point_address_map(void)
  362. {
  363.   return &chartInstance.c1_testPointAddrMap[0];
  364. }
  365. static rtwCAPI_ModelMappingInfo *get_test_point_mapping_info(void)
  366. {
  367.   return &chartInstance.c1_testPointMappingInfo;
  368. }
  369. /* SFunction Glue Code */
  370. static void init_test_point_mapping_info(SimStruct *S);
  371. void sf_c1_servo_demo_get_check_sum(mxArray *plhs[])
  372. {
  373.   ((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(2490158668U);
  374.   ((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(1102783992U);
  375.   ((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(2657140794U);
  376.   ((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(3802580316U);
  377. }
  378. mxArray *sf_c1_servo_demo_get_autoinheritance_info(void)
  379. {
  380.   const char *autoinheritanceInfoStructFieldNames[] =
  381.   {"checksum","inputTypes","outputSizes","outputTypes"};
  382.   mxArray *mxAutoinheritanceInfo = NULL;
  383.   mxArray *mxChecksum = NULL;
  384.   mxArray *mxInputTypes = NULL;
  385.   mxArray *mxOutputSizes = NULL;
  386.   mxArray *mxOutputTypes = NULL;
  387.   mxAutoinheritanceInfo = mxCreateStructMatrix(1,1,
  388.    sizeof(autoinheritanceInfoStructFieldNames)/sizeof(char *),
  389.    autoinheritanceInfoStructFieldNames);
  390.   mxChecksum = mxCreateDoubleMatrix(4,1,mxREAL);
  391.   ((real_T *)mxGetPr((mxChecksum)))[0] = (real_T)(0U);
  392.   ((real_T *)mxGetPr((mxChecksum)))[1] = (real_T)(0U);
  393.   ((real_T *)mxGetPr((mxChecksum)))[2] = (real_T)(0U);
  394.   ((real_T *)mxGetPr((mxChecksum)))[3] = (real_T)(0U);
  395.   mxInputTypes = mxCreateDoubleMatrix(1,2,mxREAL);
  396.   ((real_T *)mxGetPr((mxInputTypes)))[0] = (real_T)(10U);
  397.   ((real_T *)mxGetPr((mxInputTypes)))[1] = (real_T)(10U);
  398.   mxOutputSizes = mxCreateDoubleMatrix(2,1,mxREAL);
  399.   mxOutputTypes = mxCreateDoubleMatrix(1,1,mxREAL);
  400.   ((real_T *)mxGetPr((mxOutputSizes)))[0] = (real_T)(1U);
  401.   ((real_T *)mxGetPr((mxOutputSizes)))[1] = (real_T)(1U);
  402.   ((real_T *)mxGetPr((mxOutputTypes)))[0] = (real_T)(10U);
  403.   mxSetFieldByNumber(mxAutoinheritanceInfo,0,0,mxChecksum);
  404.   mxSetFieldByNumber(mxAutoinheritanceInfo,0,1,mxInputTypes);
  405.   mxSetFieldByNumber(mxAutoinheritanceInfo,0,2,mxOutputSizes);
  406.   mxSetFieldByNumber(mxAutoinheritanceInfo,0,3,mxOutputTypes);
  407.   return(mxAutoinheritanceInfo);
  408. }
  409. static void chart_debug_initialization(SimStruct *S)
  410. {
  411.   if(ssIsFirstInitCond(S)) {
  412.     /* do this only if simulation is starting */
  413.     if(!sim_mode_is_rtw_gen(S)) {
  414.       {
  415.         unsigned int chartAlreadyPresent;
  416.         chartAlreadyPresent =
  417.           sf_debug_initialize_chart(_servo_demoMachineNumber_,
  418.          1,
  419.          6,
  420.          9,
  421.          12,
  422.          0,
  423.          0,
  424.          0,
  425.          0,
  426.          &(chartInstance.chartNumber),
  427.          &(chartInstance.instanceNumber),
  428.          ssGetPath(S),
  429.          (void *)S);
  430.         if(chartAlreadyPresent==0) {
  431.           /* this is the first instance */
  432.           sf_debug_set_chart_disable_implicit_casting(_servo_demoMachineNumber_,chartInstance.chartNumber,0);
  433.           sf_debug_set_chart_event_thresholds(_servo_demoMachineNumber_,
  434.            chartInstance.chartNumber,
  435.            0,
  436.            0,
  437.            0);
  438.           _SFD_SET_DATA_PROPS(6,2,0,1,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"v",0);
  439.           _SFD_SET_DATA_PROPS(0,1,1,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"duty_cycle",0);
  440.           _SFD_SET_DATA_PROPS(3,0,0,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"ton",0);
  441.           _SFD_SET_DATA_PROPS(7,0,0,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"toff",0);
  442.           _SFD_SET_DATA_PROPS(5,10,0,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"Tpwm",0);
  443.           _SFD_SET_DATA_PROPS(1,10,0,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"Ipull",0);
  444.           _SFD_SET_DATA_PROPS(4,10,0,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"Ihold",0);
  445.           _SFD_SET_DATA_PROPS(11,10,0,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"deltai",0);
  446.           _SFD_SET_DATA_PROPS(8,10,0,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"Vs",0);
  447.           _SFD_SET_DATA_PROPS(9,10,0,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"Vz",0);
  448.           _SFD_SET_DATA_PROPS(2,10,0,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"Vd",0);
  449.           _SFD_SET_DATA_PROPS(10,1,1,0,SF_DOUBLE,0,NULL,0,0.0,1.0,0,"i",0);
  450.           _SFD_STATE_INFO(1,0,0);
  451.           _SFD_STATE_INFO(2,0,0);
  452.           _SFD_STATE_INFO(5,0,0);
  453.           _SFD_STATE_INFO(4,0,0);
  454.           _SFD_STATE_INFO(3,0,0);
  455.           _SFD_STATE_INFO(0,0,0);
  456.           _SFD_CH_SUBSTATE_COUNT(2);
  457.           _SFD_CH_SUBSTATE_DECOMP(0);
  458.           _SFD_CH_SUBSTATE_INDEX(0,1);
  459.           _SFD_CH_SUBSTATE_INDEX(1,0);
  460.           _SFD_ST_SUBSTATE_COUNT(1,2);
  461.           _SFD_ST_SUBSTATE_INDEX(1,0,2);
  462.           _SFD_ST_SUBSTATE_INDEX(1,1,5);
  463.           _SFD_ST_SUBSTATE_COUNT(2,0);
  464.           _SFD_ST_SUBSTATE_COUNT(5,2);
  465.           _SFD_ST_SUBSTATE_INDEX(5,0,4);
  466.           _SFD_ST_SUBSTATE_INDEX(5,1,3);
  467.           _SFD_ST_SUBSTATE_COUNT(4,0);
  468.           _SFD_ST_SUBSTATE_COUNT(3,0);
  469.           _SFD_ST_SUBSTATE_COUNT(0,0);
  470.         }
  471.         _SFD_CV_INIT_CHART(2,1,0,0);
  472.         {
  473.           _SFD_CV_INIT_STATE(1,2,1,1,0,0,NULL,NULL);
  474.         }
  475.         {
  476.           _SFD_CV_INIT_STATE(2,0,0,0,0,0,NULL,NULL);
  477.         }
  478.         {
  479.           _SFD_CV_INIT_STATE(5,2,1,1,0,0,NULL,NULL);
  480.         }
  481.         {
  482.           _SFD_CV_INIT_STATE(4,0,0,0,0,0,NULL,NULL);
  483.         }
  484.         {
  485.           _SFD_CV_INIT_STATE(3,0,0,0,0,0,NULL,NULL);
  486.         }
  487.         {
  488.           _SFD_CV_INIT_STATE(0,0,0,0,0,0,NULL,NULL);
  489.         }
  490.         _SFD_CV_INIT_TRANS(4,0,NULL,NULL,0,NULL);
  491.         _SFD_CV_INIT_TRANS(3,0,NULL,NULL,0,NULL);
  492.         {
  493.           static unsigned int sStartGuardMap[] = {2};
  494.           static unsigned int sEndGuardMap[] = {12};
  495.           static int sPostFixPredicateTree[] = {0};
  496.           _SFD_CV_INIT_TRANS(6,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,&(sPostFixPredicateTree[0]));
  497.         }
  498.         _SFD_CV_INIT_TRANS(0,0,NULL,NULL,0,NULL);
  499.         {
  500.           static unsigned int sStartGuardMap[] = {2};
  501.           static unsigned int sEndGuardMap[] = {10};
  502.           static int sPostFixPredicateTree[] = {0};
  503.           _SFD_CV_INIT_TRANS(7,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,&(sPostFixPredicateTree[0]));
  504.         }
  505.         _SFD_CV_INIT_TRANS(8,0,NULL,NULL,0,NULL);
  506.         {
  507.           static unsigned int sStartGuardMap[] = {2};
  508.           static unsigned int sEndGuardMap[] = {10};
  509.           static int sPostFixPredicateTree[] = {0};
  510.           _SFD_CV_INIT_TRANS(2,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,&(sPostFixPredicateTree[0]));
  511.         }
  512.         {
  513.           static unsigned int sStartGuardMap[] = {2};
  514.           static unsigned int sEndGuardMap[] = {21};
  515.           static int sPostFixPredicateTree[] = {0};
  516.           _SFD_CV_INIT_TRANS(1,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,&(sPostFixPredicateTree[0]));
  517.         }
  518.         {
  519.           static unsigned int sStartGuardMap[] = {2};
  520.           static unsigned int sEndGuardMap[] = {21};
  521.           static int sPostFixPredicateTree[] = {0};
  522.           _SFD_CV_INIT_TRANS(5,1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),1,&(sPostFixPredicateTree[0]));
  523.         }
  524.         _SFD_TRANS_COV_WTS(4,0,0,1,0);
  525.         if(chartAlreadyPresent==0)
  526.         {
  527.           _SFD_TRANS_COV_MAPS(4,
  528.            0,NULL,NULL,
  529.            0,NULL,NULL,
  530.            1,NULL,NULL,
  531.            0,NULL,NULL);
  532.         }
  533.         _SFD_TRANS_COV_WTS(3,0,0,0,0);
  534.         if(chartAlreadyPresent==0)
  535.         {
  536.           _SFD_TRANS_COV_MAPS(3,
  537.            0,NULL,NULL,
  538.            0,NULL,NULL,
  539.            0,NULL,NULL,
  540.            0,NULL,NULL);
  541.         }
  542.         _SFD_TRANS_COV_WTS(6,0,1,0,0);
  543.         if(chartAlreadyPresent==0)
  544.         {
  545.           static unsigned int sStartGuardMap[] = {2};
  546.           static unsigned int sEndGuardMap[] = {12};
  547.           _SFD_TRANS_COV_MAPS(6,
  548.            0,NULL,NULL,
  549.            1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
  550.            0,NULL,NULL,
  551.            0,NULL,NULL);
  552.         }
  553.         _SFD_TRANS_COV_WTS(0,0,0,1,0);
  554.         if(chartAlreadyPresent==0)
  555.         {
  556.           _SFD_TRANS_COV_MAPS(0,
  557.            0,NULL,NULL,
  558.            0,NULL,NULL,
  559.            1,NULL,NULL,
  560.            0,NULL,NULL);
  561.         }
  562.         _SFD_TRANS_COV_WTS(7,0,1,0,0);
  563.         if(chartAlreadyPresent==0)
  564.         {
  565.           static unsigned int sStartGuardMap[] = {2};
  566.           static unsigned int sEndGuardMap[] = {10};
  567.           _SFD_TRANS_COV_MAPS(7,
  568.            0,NULL,NULL,
  569.            1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
  570.            0,NULL,NULL,
  571.            0,NULL,NULL);
  572.         }
  573.         _SFD_TRANS_COV_WTS(8,0,0,0,0);
  574.         if(chartAlreadyPresent==0)
  575.         {
  576.           _SFD_TRANS_COV_MAPS(8,
  577.            0,NULL,NULL,
  578.            0,NULL,NULL,
  579.            0,NULL,NULL,
  580.            0,NULL,NULL);
  581.         }
  582.         _SFD_TRANS_COV_WTS(2,0,1,1,0);
  583.         if(chartAlreadyPresent==0)
  584.         {
  585.           static unsigned int sStartGuardMap[] = {2};
  586.           static unsigned int sEndGuardMap[] = {10};
  587.           _SFD_TRANS_COV_MAPS(2,
  588.            0,NULL,NULL,
  589.            1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
  590.            1,NULL,NULL,
  591.            0,NULL,NULL);
  592.         }
  593.         _SFD_TRANS_COV_WTS(1,0,1,0,0);
  594.         if(chartAlreadyPresent==0)
  595.         {
  596.           static unsigned int sStartGuardMap[] = {2};
  597.           static unsigned int sEndGuardMap[] = {21};
  598.           _SFD_TRANS_COV_MAPS(1,
  599.            0,NULL,NULL,
  600.            1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
  601.            0,NULL,NULL,
  602.            0,NULL,NULL);
  603.         }
  604.         _SFD_TRANS_COV_WTS(5,0,1,0,0);
  605.         if(chartAlreadyPresent==0)
  606.         {
  607.           static unsigned int sStartGuardMap[] = {2};
  608.           static unsigned int sEndGuardMap[] = {21};
  609.           _SFD_TRANS_COV_MAPS(5,
  610.            0,NULL,NULL,
  611.            1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
  612.            0,NULL,NULL,
  613.            0,NULL,NULL);
  614.         }
  615.         _SFD_SET_DATA_VALUE_PTR(6U, c1_v());
  616.         _SFD_SET_DATA_VALUE_PTR(0U, c1_duty_cycle());
  617.         _SFD_SET_DATA_VALUE_PTR(3U, &chartInstance.c1_ton);
  618.         _SFD_SET_DATA_VALUE_PTR(7U, &chartInstance.c1_toff);
  619.         _SFD_SET_DATA_VALUE_PTR(5U, &chartInstance.c1_Tpwm);
  620.         _SFD_SET_DATA_VALUE_PTR(1U, &chartInstance.c1_Ipull);
  621.         _SFD_SET_DATA_VALUE_PTR(4U, &chartInstance.c1_Ihold);
  622.         _SFD_SET_DATA_VALUE_PTR(11U, &chartInstance.c1_deltai);
  623.         _SFD_SET_DATA_VALUE_PTR(8U, &chartInstance.c1_Vs);
  624.         _SFD_SET_DATA_VALUE_PTR(9U, &chartInstance.c1_Vz);
  625.         _SFD_SET_DATA_VALUE_PTR(2U, &chartInstance.c1_Vd);
  626.         _SFD_SET_DATA_VALUE_PTR(10U, c1_i());
  627.       }
  628.     }
  629.   } else {
  630.     sf_debug_reset_current_state_configuration(_servo_demoMachineNumber_,chartInstance.chartNumber,chartInstance.instanceNumber);
  631.   }
  632. }
  633. static void sf_opaque_initialize_c1_servo_demo(void *chartInstanceVar)
  634. {
  635.   chart_debug_initialization(chartInstance.S);
  636.   initialize_c1_servo_demo();
  637. }
  638. static void sf_opaque_enable_c1_servo_demo(void *chartInstanceVar)
  639. {
  640.   enable_c1_servo_demo();
  641. }
  642. static void sf_opaque_disable_c1_servo_demo(void *chartInstanceVar)
  643. {
  644.   disable_c1_servo_demo();
  645. }
  646. static void sf_opaque_gateway_c1_servo_demo(void *chartInstanceVar)
  647. {
  648.   sf_c1_servo_demo();
  649. }
  650. static void sf_opaque_terminate_c1_servo_demo(void *chartInstanceVar)
  651. {
  652.   finalize_c1_servo_demo();
  653. }
  654. static void mdlSetWorkWidths_c1_servo_demo(SimStruct *S)
  655. {
  656.   /* Actual parameters from chart:
  657.      Ihold Ipull Tpwm Vd Vs Vz deltai 
  658.    */
  659.   const char_T *rtParamNames[] = {"p1","p2","p3","p4","p5","p6","p7"};
  660.   ssSetNumRunTimeParams(S,ssGetSFcnParamsCount(S));
  661.   /* registration for Ihold*/
  662.   ssRegDlgParamAsRunTimeParam(S, 0, 0, rtParamNames[0], SS_DOUBLE);
  663.   /* registration for Ipull*/
  664.   ssRegDlgParamAsRunTimeParam(S, 1, 1, rtParamNames[1], SS_DOUBLE);
  665.   /* registration for Tpwm*/
  666.   ssRegDlgParamAsRunTimeParam(S, 2, 2, rtParamNames[2], SS_DOUBLE);
  667.   /* registration for Vd*/
  668.   ssRegDlgParamAsRunTimeParam(S, 3, 3, rtParamNames[3], SS_DOUBLE);
  669.   /* registration for Vs*/
  670.   ssRegDlgParamAsRunTimeParam(S, 4, 4, rtParamNames[4], SS_DOUBLE);
  671.   /* registration for Vz*/
  672.   ssRegDlgParamAsRunTimeParam(S, 5, 5, rtParamNames[5], SS_DOUBLE);
  673.   /* registration for deltai*/
  674.   ssRegDlgParamAsRunTimeParam(S, 6, 6, rtParamNames[6], SS_DOUBLE);
  675.   if(sim_mode_is_rtw_gen(S)) {
  676.     int_T chartIsInlinable =
  677.       (int_T)sf_is_chart_inlinable("servo_demo",1);
  678.     int_T chartIsMultiInstanced =
  679.       (int_T)sf_is_chart_multi_instanced("servo_demo",1);
  680.     ssSetStateflowIsInlinable(S,chartIsInlinable);
  681.     ssSetEnableFcnIsTrivial(S,1);
  682.     ssSetDisableFcnIsTrivial(S,1);
  683.     if(chartIsInlinable) {
  684.       ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
  685.       ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL);
  686.       sf_mark_chart_expressionable_inputs(S,"servo_demo",1,2);
  687.       sf_mark_chart_reusable_outputs(S,"servo_demo",1,1);
  688.     }
  689.     if (!sf_is_chart_instance_optimized_out("servo_demo",1)) {
  690.       int dtId;
  691.       char *chartInstanceTypedefName =
  692.         sf_chart_instance_typedef_name("servo_demo",1);
  693.       dtId = ssRegisterDataType(S, chartInstanceTypedefName);
  694.       if (dtId == INVALID_DTYPE_ID ) return;
  695.       /* Register the size of the udt */
  696.       if (!ssSetDataTypeSize(S, dtId, 8)) return;
  697.       if(!ssSetNumDWork(S,1)) return;
  698.       ssSetDWorkDataType(S, 0, dtId);
  699.       ssSetDWorkWidth(S, 0, 1);
  700.       ssSetDWorkName(S, 0, "ChartInstance"); /*optional name, less than 16 chars*/
  701.       sf_set_rtw_identifier(S);
  702.     }
  703.     ssSetHasSubFunctions(S,!(chartIsInlinable));
  704.     ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
  705.   }
  706.   ssSetChecksum0(S,(2490158668U));
  707.   ssSetChecksum1(S,(1102783992U));
  708.   ssSetChecksum2(S,(2657140794U));
  709.   ssSetChecksum3(S,(3802580316U));
  710.   ssSetExplicitFCSSCtrl(S,1);
  711. }
  712. static void mdlRTW_c1_servo_demo(SimStruct *S)
  713. {
  714.   sf_write_symbol_mapping(S, "servo_demo", 1);
  715.   ssWriteRTWStrParam(S, "StateflowChartType", "Stateflow");
  716. }
  717. static void mdlStart_c1_servo_demo(SimStruct *S)
  718. {
  719.   chartInstance.chartInfo.chartInstance = NULL;
  720.   chartInstance.chartInfo.isEMLChart = 0;
  721.   chartInstance.chartInfo.chartInitialized = 0;
  722.   chartInstance.chartInfo.sFunctionGateway = sf_opaque_gateway_c1_servo_demo;
  723.   chartInstance.chartInfo.initializeChart = sf_opaque_initialize_c1_servo_demo;
  724.   chartInstance.chartInfo.terminateChart = sf_opaque_terminate_c1_servo_demo;
  725.   chartInstance.chartInfo.enableChart = sf_opaque_enable_c1_servo_demo;
  726.   chartInstance.chartInfo.disableChart = sf_opaque_disable_c1_servo_demo;
  727.   chartInstance.chartInfo.mdlRTW = mdlRTW_c1_servo_demo;
  728.   chartInstance.chartInfo.mdlStart = mdlStart_c1_servo_demo;
  729.   chartInstance.chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c1_servo_demo;
  730.   chartInstance.chartInfo.restoreLastMajorStepConfiguration = NULL;
  731.   chartInstance.chartInfo.restoreBeforeLastMajorStepConfiguration = NULL;
  732.   chartInstance.chartInfo.storeCurrentConfiguration = NULL;
  733.   chartInstance.S = S;
  734.   ssSetUserData(S,(void *)(&(chartInstance.chartInfo))); /* register the chart instance with simstruct */
  735.   if(!sim_mode_is_rtw_gen(S)) {
  736.     init_test_point_mapping_info(S);
  737.   }
  738. }
  739. void c1_servo_demo_method_dispatcher(SimStruct *S, int_T method, void *data)
  740. {
  741.   switch (method) {
  742.    case SS_CALL_MDL_START:
  743.     mdlStart_c1_servo_demo(S);
  744.     break;
  745.    case SS_CALL_MDL_SET_WORK_WIDTHS:
  746.     mdlSetWorkWidths_c1_servo_demo(S);
  747.     break;
  748.    default:
  749.     /* Unhandled method */
  750.     sf_mex_error_message("Stateflow Internal Error:n"
  751.      "Error calling c1_servo_demo_method_dispatcher.n"
  752.      "Can't handle method %d.n", method);
  753.     break;
  754.   }
  755. }
  756. static const rtwCAPI_DataTypeMap dataTypeMap[] = {
  757.   /* cName, mwName, numElements, elemMapIndex, dataSize, slDataId, isComplex, isPointer */
  758.   {"real_T", "real_T", 0, 0, sizeof(real_T), SS_DOUBLE, 0, 0},
  759.   {"uint8_T", "uint8_T", 0, 0, sizeof(uint8_T), SS_UINT8, 0, 0}
  760. };
  761. static real_T fixPtSlopeBiasVals[2] = {
  762.   0,
  763.   1
  764. };
  765. static const rtwCAPI_FixPtMap fixedPointMap[] = {
  766.   /* *fracSlope, *bias, scaleType, exponent, isSigned */
  767.   {NULL, NULL, rtwCAPI_FIX_RESERVED, 0, 0}
  768. };
  769. static const rtwCAPI_DimensionMap dimensionMap[] = {
  770.   /* dataOrientation, dimArrayIndex, numDims*/
  771.   {rtwCAPI_SCALAR, 0, 2}
  772. };
  773. static const uint_T dimensionArray[] = {
  774.   1, 1
  775. };
  776. static real_T sfCAPIsampleTimeZero = 0.0;
  777. static const rtwCAPI_SampleTimeMap sampleTimeMap[] = {
  778.   /* *period, *offset, taskId, contextTid, mode */
  779.   {&sfCAPIsampleTimeZero, &sfCAPIsampleTimeZero, 0, 0, 0}
  780. };
  781. static const rtwCAPI_Signals testPointSignals[] = {
  782.   /* addrMapIndex, sysNum, SFRelativePath, dataName, portNumber, dataTypeIndex, dimIndex, fixPtIdx, sTimeIndex */
  783.   {0, 0,"StateflowChart/ton", "ton", 0, 0, 0, 0, 0},
  784.   {1, 0,"StateflowChart/toff", "toff", 0, 0, 0, 0, 0},
  785.   {2, 0, "StateflowChart/energize_solenoid", "energize_solenoid", 0, 1, 0, 0, 0},
  786.   {3, 0, "StateflowChart/energize_solenoid.pull_in_current", "pull_in_current",
  787.     0, 1, 0, 0, 0},
  788.   {4, 0, "StateflowChart/energize_solenoid.regulate_hold_current",
  789.     "regulate_hold_current", 0, 1, 0, 0, 0},
  790.   {5, 0, "StateflowChart/energize_solenoid.regulate_hold_current.freewheel",
  791.     "freewheel", 0, 1, 0, 0, 0},
  792.   {6, 0, "StateflowChart/energize_solenoid.regulate_hold_current.hold", "hold",
  793.     0, 1, 0, 0, 0},
  794.   {7, 0, "StateflowChart/solenoid_off", "solenoid_off", 0, 1, 0, 0, 0}
  795. };
  796. static rtwCAPI_ModelMappingStaticInfo testPointMappingStaticInfo = {
  797.   /* block signal monitoring */
  798.   {
  799.     testPointSignals,                   /* Block signals Array  */
  800.     8                                   /* Num Block IO signals */
  801.   },
  802.   /* parameter tuning */
  803.   {
  804.     NULL,                               /* Block parameters Array    */
  805.     0,                                  /* Num block parameters      */
  806.     NULL,                               /* Variable parameters Array */
  807.     0                                   /* Num variable parameters   */
  808.   },
  809.   /* block states */
  810.   {
  811.     NULL,                               /* Block States array        */
  812.     0                                   /* Num Block States          */
  813.   },
  814.   /* Static maps */
  815.   {
  816.     dataTypeMap,                        /* Data Type Map            */
  817.     dimensionMap,                       /* Data Dimension Map       */
  818.     fixedPointMap,                      /* Fixed Point Map          */
  819.     NULL,                               /* Structure Element map    */
  820.     sampleTimeMap,                      /* Sample Times Map         */
  821.     dimensionArray                      /* Dimension Array          */
  822.   },
  823.   /* Target type */
  824.   "float"
  825. };
  826. static void init_test_point_mapping_info(SimStruct *S) {
  827.   rtwCAPI_ModelMappingInfo *testPointMappingInfo;
  828.   void **testPointAddrMap;
  829.   init_test_point_addr_map();
  830.   testPointMappingInfo = get_test_point_mapping_info();
  831.   testPointAddrMap = get_test_point_address_map();
  832.   rtwCAPI_SetStaticMap(*testPointMappingInfo, &testPointMappingStaticInfo);
  833.   rtwCAPI_SetPath(*testPointMappingInfo, "");
  834.   rtwCAPI_SetFullPath(*testPointMappingInfo, NULL);
  835.   rtwCAPI_SetDataAddressMap(*testPointMappingInfo, testPointAddrMap);
  836.   rtwCAPI_SetChildMMIArray(*testPointMappingInfo, NULL);
  837.   rtwCAPI_SetChildMMIArrayLen(*testPointMappingInfo, 0);
  838.   ssSetModelMappingInfoPtr(S, testPointMappingInfo);
  839. }