📄 c1_sim_netcon.c
字号:
if(chartAlreadyPresent==0)
{
static unsigned int sStartGuardMap[] = {2,13};
static unsigned int sEndGuardMap[] = {9,17};
_SFD_TRANS_COV_MAPS(10,
0,NULL,NULL,
2,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
3,NULL,NULL,
0,NULL,NULL);
}
_SFD_TRANS_COV_WTS(12,0,2,3,0);
if(chartAlreadyPresent==0)
{
static unsigned int sStartGuardMap[] = {2,13};
static unsigned int sEndGuardMap[] = {9,17};
_SFD_TRANS_COV_MAPS(12,
0,NULL,NULL,
2,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
3,NULL,NULL,
0,NULL,NULL);
}
_SFD_TRANS_COV_WTS(3,0,2,3,0);
if(chartAlreadyPresent==0)
{
static unsigned int sStartGuardMap[] = {2,13};
static unsigned int sEndGuardMap[] = {9,17};
_SFD_TRANS_COV_MAPS(3,
0,NULL,NULL,
2,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
3,NULL,NULL,
0,NULL,NULL);
}
_SFD_TRANS_COV_WTS(1,0,1,0,0);
if(chartAlreadyPresent==0)
{
static unsigned int sStartGuardMap[] = {1};
static unsigned int sEndGuardMap[] = {5};
_SFD_TRANS_COV_MAPS(1,
0,NULL,NULL,
1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
0,NULL,NULL,
0,NULL,NULL);
}
_SFD_TRANS_COV_WTS(16,0,0,3,0);
if(chartAlreadyPresent==0)
{
_SFD_TRANS_COV_MAPS(16,
0,NULL,NULL,
0,NULL,NULL,
3,NULL,NULL,
0,NULL,NULL);
}
_SFD_TRANS_COV_WTS(9,0,1,0,0);
if(chartAlreadyPresent==0)
{
static unsigned int sStartGuardMap[] = {1};
static unsigned int sEndGuardMap[] = {5};
_SFD_TRANS_COV_MAPS(9,
0,NULL,NULL,
1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
0,NULL,NULL,
0,NULL,NULL);
}
_SFD_TRANS_COV_WTS(11,0,1,0,0);
if(chartAlreadyPresent==0)
{
static unsigned int sStartGuardMap[] = {1};
static unsigned int sEndGuardMap[] = {5};
_SFD_TRANS_COV_MAPS(11,
0,NULL,NULL,
1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
0,NULL,NULL,
0,NULL,NULL);
}
_SFD_TRANS_COV_WTS(2,0,1,0,0);
if(chartAlreadyPresent==0)
{
static unsigned int sStartGuardMap[] = {1};
static unsigned int sEndGuardMap[] = {5};
_SFD_TRANS_COV_MAPS(2,
0,NULL,NULL,
1,&(sStartGuardMap[0]),&(sEndGuardMap[0]),
0,NULL,NULL,
0,NULL,NULL);
}
_SFD_TRANS_COV_WTS(14,0,0,1,0);
if(chartAlreadyPresent==0)
{
_SFD_TRANS_COV_MAPS(14,
0,NULL,NULL,
0,NULL,NULL,
1,NULL,NULL,
0,NULL,NULL);
}
_SFD_SET_DATA_VALUE_PTR(3U, &chartInstance.c1_count);
_SFD_SET_DATA_VALUE_PTR(1U, &chartInstance.c1_code);
_SFD_SET_DATA_VALUE_PTR(2U, &chartInstance.c1_convec);
_SFD_SET_DATA_VALUE_PTR(0U, &chartInstance.c1_i);
}
}
} else {
sf_debug_reset_current_state_configuration(_sim_netconMachineNumber_,chartInstance.chartNumber,chartInstance.instanceNumber);
}
}
static void sf_opaque_initialize_c1_sim_netcon(void *chartInstanceVar)
{
chart_debug_initialization(chartInstance.S);
initialize_c1_sim_netcon();
}
static void sf_opaque_enable_c1_sim_netcon(void *chartInstanceVar)
{
enable_c1_sim_netcon();
}
static void sf_opaque_disable_c1_sim_netcon(void *chartInstanceVar)
{
disable_c1_sim_netcon();
}
static void sf_opaque_gateway_c1_sim_netcon(void *chartInstanceVar)
{
sf_c1_sim_netcon();
}
static void sf_opaque_terminate_c1_sim_netcon(void *chartInstanceVar)
{
finalize_c1_sim_netcon();
}
static void mdlSetWorkWidths_c1_sim_netcon(SimStruct *S)
{
if(sim_mode_is_rtw_gen(S)) {
int_T chartIsInlinable =
(int_T)sf_is_chart_inlinable("sim_netcon",1);
int_T chartIsMultiInstanced =
(int_T)sf_is_chart_multi_instanced("sim_netcon",1);
ssSetStateflowIsInlinable(S,chartIsInlinable);
ssSetEnableFcnIsTrivial(S,1);
ssSetDisableFcnIsTrivial(S,1);
if(chartIsInlinable) {
}
ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL);
if (!sf_is_chart_instance_optimized_out("sim_netcon",1)) {
int dtId;
char *chartInstanceTypedefName =
sf_chart_instance_typedef_name("sim_netcon",1);
dtId = ssRegisterDataType(S, chartInstanceTypedefName);
if (dtId == INVALID_DTYPE_ID ) return;
/* Register the size of the udt */
if (!ssSetDataTypeSize(S, dtId, 8)) return;
if(!ssSetNumDWork(S,1)) return;
ssSetDWorkDataType(S, 0, dtId);
ssSetDWorkWidth(S, 0, 1);
ssSetDWorkName(S, 0, "ChartInstance"); /*optional name, less than 16 chars*/
sf_set_rtw_identifier(S);
}
ssSetHasSubFunctions(S,!(chartIsInlinable));
ssSetOptions(S,ssGetOptions(S)|SS_OPTION_WORKS_WITH_CODE_REUSE);
}
ssSetChecksum0(S,(2285184278U));
ssSetChecksum1(S,(2140700920U));
ssSetChecksum2(S,(628357428U));
ssSetChecksum3(S,(282070357U));
ssSetExplicitFCSSCtrl(S,1);
}
static void mdlRTW_c1_sim_netcon(SimStruct *S)
{
sf_write_symbol_mapping(S, "sim_netcon", 1);
ssWriteRTWStrParam(S, "StateflowChartType", "Stateflow");
}
static void mdlStart_c1_sim_netcon(SimStruct *S)
{
chartInstance.chartInfo.chartInstance = NULL;
chartInstance.chartInfo.isEMLChart = 0;
chartInstance.chartInfo.chartInitialized = 0;
chartInstance.chartInfo.sFunctionGateway = sf_opaque_gateway_c1_sim_netcon;
chartInstance.chartInfo.initializeChart = sf_opaque_initialize_c1_sim_netcon;
chartInstance.chartInfo.terminateChart = sf_opaque_terminate_c1_sim_netcon;
chartInstance.chartInfo.enableChart = sf_opaque_enable_c1_sim_netcon;
chartInstance.chartInfo.disableChart = sf_opaque_disable_c1_sim_netcon;
chartInstance.chartInfo.mdlRTW = mdlRTW_c1_sim_netcon;
chartInstance.chartInfo.mdlStart = mdlStart_c1_sim_netcon;
chartInstance.chartInfo.mdlSetWorkWidths = mdlSetWorkWidths_c1_sim_netcon;
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 */
if(!sim_mode_is_rtw_gen(S)) {
init_test_point_mapping_info(S);
}
}
void c1_sim_netcon_method_dispatcher(SimStruct *S, int_T method, void *data)
{
switch (method) {
case SS_CALL_MDL_START:
mdlStart_c1_sim_netcon(S);
break;
case SS_CALL_MDL_SET_WORK_WIDTHS:
mdlSetWorkWidths_c1_sim_netcon(S);
break;
default:
/* Unhandled method */
sf_mex_error_message("Stateflow Internal Error:\n"
"Error calling c1_sim_netcon_method_dispatcher.\n"
"Can't handle method %d.\n", method);
break;
}
}
static const rtwCAPI_DataTypeMap dataTypeMap[] = {
/* cName, mwName, numElements, elemMapIndex, dataSize, slDataId, isComplex, isPointer */
{"uint16_T", "uint16_T", 0, 0, sizeof(uint16_T), SS_UINT16, 0, 0},
{"uint8_T", "uint8_T", 0, 0, sizeof(uint8_T), SS_UINT8, 0, 0}
};
static real_T fixPtSlopeBiasVals[2] = {
0,
1
};
static const rtwCAPI_FixPtMap fixedPointMap[] = {
/* *fracSlope, *bias, scaleType, exponent, isSigned */
{NULL, NULL, rtwCAPI_FIX_RESERVED, 0, 0}
};
static const rtwCAPI_DimensionMap dimensionMap[] = {
/* dataOrientation, dimArrayIndex, numDims*/
{rtwCAPI_SCALAR, 0, 2},
{rtwCAPI_VECTOR, 2, 2}
};
static const uint_T dimensionArray[] = {
1, 1,
2, 1
};
static real_T sfCAPIsampleTimeZero = 0.0;
static const rtwCAPI_SampleTimeMap sampleTimeMap[] = {
/* *period, *offset, taskId, contextTid, mode */
{&sfCAPIsampleTimeZero, &sfCAPIsampleTimeZero, 0, 0, 0}
};
static const rtwCAPI_Signals testPointSignals[] = {
/* addrMapIndex, sysNum, SFRelativePath, dataName, portNumber, dataTypeIndex, dimIndex, fixPtIdx, sTimeIndex */
{0, 0,"StateflowChart/count", "count", 0, 0, 0, 0, 0},
{1, 0,"StateflowChart/code", "code", 0, 1, 0, 0, 0},
{2, 0,"StateflowChart/convec", "convec", 0, 1, 1, 0, 0},
{3, 0,"StateflowChart/i", "i", 0, 1, 0, 0, 0},
{4, 0, "StateflowChart/Road", "Road", 0, 1, 0, 0, 0},
{5, 0, "StateflowChart/Road.S0", "S0", 0, 1, 0, 0, 0},
{6, 0, "StateflowChart/Road.S1", "S1", 0, 1, 0, 0, 0},
{7, 0, "StateflowChart/Road.S2", "S2", 0, 1, 0, 0, 0},
{8, 0, "StateflowChart/Road.S3", "S3", 0, 1, 0, 0, 0}
};
static rtwCAPI_ModelMappingStaticInfo testPointMappingStaticInfo = {
/* block signal monitoring */
{
testPointSignals, /* Block signals Array */
9 /* Num Block IO signals */
},
/* parameter tuning */
{
NULL, /* Block parameters Array */
0, /* Num block parameters */
NULL, /* Variable parameters Array */
0 /* Num variable parameters */
},
/* block states */
{
NULL, /* Block States array */
0 /* Num Block States */
},
/* Static maps */
{
dataTypeMap, /* Data Type Map */
dimensionMap, /* Data Dimension Map */
fixedPointMap, /* Fixed Point Map */
NULL, /* Structure Element map */
sampleTimeMap, /* Sample Times Map */
dimensionArray /* Dimension Array */
},
/* Target type */
"float"
};
static void init_test_point_mapping_info(SimStruct *S) {
rtwCAPI_ModelMappingInfo *testPointMappingInfo;
void **testPointAddrMap;
init_test_point_addr_map();
testPointMappingInfo = get_test_point_mapping_info();
testPointAddrMap = get_test_point_address_map();
rtwCAPI_SetStaticMap(*testPointMappingInfo, &testPointMappingStaticInfo);
rtwCAPI_SetPath(*testPointMappingInfo, "");
rtwCAPI_SetFullPath(*testPointMappingInfo, NULL);
rtwCAPI_SetDataAddressMap(*testPointMappingInfo, testPointAddrMap);
rtwCAPI_SetChildMMIArray(*testPointMappingInfo, NULL);
rtwCAPI_SetChildMMIArrayLen(*testPointMappingInfo, 0);
ssSetModelMappingInfoPtr(S, testPointMappingInfo);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -