📄 c1_model16to02.c
字号:
/* Include files */
#include "model16to02_sfun.h"
#include "c1_model16to02.h"
#define CHARTINSTANCE_CHARTNUMBER (chartInstance.chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER (chartInstance.instanceNumber)
#include "model16to02_sfun_debug_macros.h"
/* Type Definitions */
/* Named Constants */
#define c1_IN_NO_ACTIVE_CHILD (0)
#define c1_IN_state_of_motion (1)
#define c1_IN_stuck (2)
#define c1_IN_sliding (1)
/* Variable Declarations */
/* Variable Definitions */
static SFc1_model16to02InstanceStruct chartInstance;
/* Function Declarations */
static void initialize_c1_model16to02(void);
static void enable_c1_model16to02(void);
static void disable_c1_model16to02(void);
static void finalize_c1_model16to02(void);
static void sf_c1_model16to02(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 *c1_stuck(void);
static real_T *c1_novelocity(void);
static real_T *c1_Fsum(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_c1_model16to02(void)
{
chartInstance.c1_is_state_of_motion = 0;
chartInstance.c1_tp_state_of_motion = 0;
chartInstance.c1_tp_sliding = 0;
chartInstance.c1_tp_stuck = 0;
chartInstance.c1_is_active_c1_model16to02 = 0;
chartInstance.c1_is_c1_model16to02 = 0;
if(!(cdrGetOutputPortReusable(chartInstance.S, 1) != 0)) {
*c1_stuck() = 0.0;
}
store_current_config();
store_current_config();
}
static void enable_c1_model16to02(void)
{
}
static void disable_c1_model16to02(void)
{
}
static void finalize_c1_model16to02(void)
{
}
static void sf_c1_model16to02(void)
{
uint8_T c1_previousEvent;
_sfTime_ = (real_T)ssGetT(chartInstance.S);
_SFD_DATA_RANGE_CHECK(smodel16to02LocalData.m_Fstatic, 0U);
_SFD_DATA_RANGE_CHECK_MIN_MAX(*c1_stuck(), 2U, 0.0, 1.0);
_SFD_DATA_RANGE_CHECK(*c1_novelocity(), 3U);
_SFD_DATA_RANGE_CHECK(*c1_Fsum(), 1U);
c1_previousEvent = _sfEvent_;
_sfEvent_ = CALL_EVENT;
_SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG,0);
if(chartInstance.c1_is_active_c1_model16to02 == 0) {
_SFD_CC_CALL(CHART_ENTER_ENTRY_FUNCTION_TAG,0);
chartInstance.c1_is_active_c1_model16to02 = 1;
_SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
chartInstance.c1_is_c1_model16to02 = (uint8_T)c1_IN_state_of_motion;
_SFD_CS_CALL(STATE_ACTIVE_TAG,2);
chartInstance.c1_tp_state_of_motion = 1;
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG,0);
chartInstance.c1_is_state_of_motion = (uint8_T)c1_IN_stuck;
_SFD_CS_CALL(STATE_ACTIVE_TAG,1);
chartInstance.c1_tp_stuck = 1;
*c1_stuck() = 1.0;
_SFD_DATA_RANGE_CHECK_MIN_MAX(*c1_stuck(), 2U, 0.0, 1.0);
} else {
_SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,2);
switch(chartInstance.c1_is_state_of_motion) {
case c1_IN_sliding:
CV_STATE_EVAL(2,0,1);
_SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,0);
if(CV_TRANSITION_EVAL(1U, (_SFD_CCP_CALL(1,0,(*c1_novelocity())) != 0) &&
(_SFD_CCP_CALL(1,1,(fabs(*c1_Fsum()) <=
smodel16to02LocalData.m_Fstatic)) != 0)) != 0) {
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG,1);
chartInstance.c1_tp_sliding = 0;
chartInstance.c1_is_state_of_motion = (uint8_T)c1_IN_NO_ACTIVE_CHILD;
_SFD_CS_CALL(STATE_INACTIVE_TAG,0);
chartInstance.c1_is_state_of_motion = (uint8_T)c1_IN_stuck;
_SFD_CS_CALL(STATE_ACTIVE_TAG,1);
chartInstance.c1_tp_stuck = 1;
*c1_stuck() = 1.0;
_SFD_DATA_RANGE_CHECK_MIN_MAX(*c1_stuck(), 2U, 0.0, 1.0);
}
_SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
break;
case c1_IN_stuck:
CV_STATE_EVAL(2,0,2);
_SFD_CS_CALL(STATE_ENTER_DURING_FUNCTION_TAG,1);
if(CV_TRANSITION_EVAL(2U, (int32_T)_SFD_CCP_CALL(2,0,(fabs(*c1_Fsum()) >
smodel16to02LocalData.m_Fstatic))) != 0) {
_SFD_CT_CALL(TRANSITION_ACTIVE_TAG,2);
chartInstance.c1_tp_stuck = 0;
chartInstance.c1_is_state_of_motion = (uint8_T)c1_IN_NO_ACTIVE_CHILD;
_SFD_CS_CALL(STATE_INACTIVE_TAG,1);
chartInstance.c1_is_state_of_motion = (uint8_T)c1_IN_sliding;
_SFD_CS_CALL(STATE_ACTIVE_TAG,0);
chartInstance.c1_tp_sliding = 1;
*c1_stuck() = 0.0;
_SFD_DATA_RANGE_CHECK_MIN_MAX(*c1_stuck(), 2U, 0.0, 1.0);
}
_SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,1);
break;
default:
CV_STATE_EVAL(2,0,0);
break;
}
_SFD_CS_CALL(EXIT_OUT_OF_FUNCTION_TAG,2);
}
_SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,0);
_sfEvent_ = c1_previousEvent;
}
static void store_current_config(void)
{
chartInstance.c1_tp_state_of_motion_shadow2 =
chartInstance.c1_tp_state_of_motion_shadow1;
chartInstance.c1_tp_state_of_motion_shadow1 =
chartInstance.c1_tp_state_of_motion;
chartInstance.c1_tp_stuck_shadow2 = chartInstance.c1_tp_stuck_shadow1;
chartInstance.c1_tp_stuck_shadow1 = chartInstance.c1_tp_stuck;
chartInstance.c1_tp_sliding_shadow2 = chartInstance.c1_tp_sliding_shadow1;
chartInstance.c1_tp_sliding_shadow1 = chartInstance.c1_tp_sliding;
chartInstance.c1_is_active_c1_model16to02_shadow2 =
chartInstance.c1_is_active_c1_model16to02_shadow1;
chartInstance.c1_is_active_c1_model16to02_shadow1 =
chartInstance.c1_is_active_c1_model16to02;
chartInstance.c1_is_c1_model16to02_shadow2 =
chartInstance.c1_is_c1_model16to02_shadow1;
chartInstance.c1_is_c1_model16to02_shadow1 =
chartInstance.c1_is_c1_model16to02;
chartInstance.c1_is_state_of_motion_shadow2 =
chartInstance.c1_is_state_of_motion_shadow1;
chartInstance.c1_is_state_of_motion_shadow1 =
chartInstance.c1_is_state_of_motion;
chartInstance.c1_stuck_shadow2 = chartInstance.c1_stuck_shadow1;
chartInstance.c1_stuck_shadow1 = *c1_stuck();
sf_debug_store_current_state_configuration(_model16to02MachineNumber_,
chartInstance.chartNumber, chartInstance.instanceNumber);
}
static void restore_last_major_step(void)
{
chartInstance.c1_tp_state_of_motion =
chartInstance.c1_tp_state_of_motion_shadow1;
chartInstance.c1_tp_stuck = chartInstance.c1_tp_stuck_shadow1;
chartInstance.c1_tp_sliding = chartInstance.c1_tp_sliding_shadow1;
chartInstance.c1_is_active_c1_model16to02 =
chartInstance.c1_is_active_c1_model16to02_shadow1;
chartInstance.c1_is_c1_model16to02 =
chartInstance.c1_is_c1_model16to02_shadow1;
chartInstance.c1_is_state_of_motion =
chartInstance.c1_is_state_of_motion_shadow1;
*c1_stuck() = chartInstance.c1_stuck_shadow1;
sf_debug_restore_previous_state_configuration(_model16to02MachineNumber_,
chartInstance.chartNumber, chartInstance.instanceNumber);
}
static void restore_before_last_major_step(void)
{
chartInstance.c1_tp_state_of_motion =
chartInstance.c1_tp_state_of_motion_shadow2;
chartInstance.c1_tp_stuck = chartInstance.c1_tp_stuck_shadow2;
chartInstance.c1_tp_sliding = chartInstance.c1_tp_sliding_shadow2;
chartInstance.c1_is_active_c1_model16to02 =
chartInstance.c1_is_active_c1_model16to02_shadow2;
chartInstance.c1_is_c1_model16to02 =
chartInstance.c1_is_c1_model16to02_shadow2;
chartInstance.c1_is_state_of_motion =
chartInstance.c1_is_state_of_motion_shadow2;
*c1_stuck() = chartInstance.c1_stuck_shadow2;
sf_debug_restore_previous_state_configuration2(_model16to02MachineNumber_,
chartInstance.chartNumber, chartInstance.instanceNumber);
}
static real_T *c1_stuck(void)
{
return (real_T *)ssGetOutputPortSignal(chartInstance.S, 1);
}
static real_T *c1_novelocity(void)
{
return (real_T *)ssGetInputPortSignal(chartInstance.S, 0);
}
static real_T *c1_Fsum(void)
{
return (real_T *)ssGetInputPortSignal(chartInstance.S, 1);
}
static void init_test_point_addr_map(void)
{
chartInstance.c1_testPointAddrMap[0] = &chartInstance.c1_tp_state_of_motion;
chartInstance.c1_testPointAddrMap[1] = &chartInstance.c1_tp_sliding;
chartInstance.c1_testPointAddrMap[2] = &chartInstance.c1_tp_stuck;
}
static void **get_test_point_address_map(void)
{
return &chartInstance.c1_testPointAddrMap[0];
}
static rtwCAPI_ModelMappingInfo *get_test_point_mapping_info(void)
{
return &chartInstance.c1_testPointMappingInfo;
}
/* SFunction Glue Code */
static void init_test_point_mapping_info(SimStruct *S);
void sf_c1_model16to02_get_check_sum(mxArray *plhs[])
{
((real_T *)mxGetPr((plhs[0])))[0] = (real_T)(616685526U);
((real_T *)mxGetPr((plhs[0])))[1] = (real_T)(324833157U);
((real_T *)mxGetPr((plhs[0])))[2] = (real_T)(2270801914U);
((real_T *)mxGetPr((plhs[0])))[3] = (real_T)(4266405528U);
}
mxArray *sf_c1_model16to02_get_autoinheritance_info(void)
{
const char *autoinheritanceInfoStructFieldNames[] =
{"checksum","inputTypes","outputSizes","outputTypes"};
mxArray *mxAutoinheritanceInfo = NULL;
mxArray *mxChecksum = NULL;
mxArray *mxInputTypes = NULL;
mxArray *mxOutputSizes = NULL;
mxArray *mxOutputTypes = 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);
((real_T *)mxGetPr((mxInputTypes)))[0] = (real_T)(10U);
((real_T *)mxGetPr((mxInputTypes)))[1] = (real_T)(10U);
mxOutputSizes = mxCreateDoubleMatrix(2,1,mxREAL);
mxOutputTypes = mxCreateDoubleMatrix(1,1,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);
mxSetFieldByNumber(mxAutoinheritanceInfo,0,0,mxChecksum);
mxSetFieldByNumber(mxAutoinheritanceInfo,0,1,mxInputTypes);
mxSetFieldByNumber(mxAutoinheritanceInfo,0,2,mxOutputSizes);
mxSetFieldByNumber(mxAutoinheritanceInfo,0,3,mxOutputTypes);
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(_model16to02MachineNumber_,
1,
3,
3,
3,
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(_model16to02MachineNumber_,chartInstance.chartNumber,0);
sf_debug_set_chart_event_thresholds(_model16to02MachineNumber_,
chartInstance.chartNumber,
0,
0,
0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -