/* Function: mdlInitializeSizes =============================================== * Abstract: * Setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { slDataTypeAccess *dta = ssGetDataTypeAccess(S); int udtId; ssSetNumSFcnParams(S, 0); /* Number of expected parameters */ if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { /* Return if number of expected != number of actual parameters */ return; } /* Obtain an integer datatype ID for the udt (user-defined type) "Data" */ udtId = ssRegisterDataType(S, "Data"); if ( udtId == INVALID_DTYPE_ID ) return; /* Register the size of the udt */ if (!ssSetDataTypeSize(S, udtId, sizeof(Data))) return; /* Register the zero of the udt */ if (!ssSetDataTypeZero(S, udtId, &zero)) return; /* Register the convert-between datatype function defined above */ if (!dtaSetConvertBetweenFcn(dta, ssGetPath(S), udtId, &DataCnvBtw)) return; /* Register the is-positive datatype function defined above*/ if (!dtaSetIsPositiveFcn(dta, ssGetPath(S), udtId, &DataIsPos)) return; /* Set input-port properties */ if (!ssSetNumInputPorts(S, 1)) return; ssSetInputPortWidth(S, 0, 1); ssSetInputPortDataType(S, 0, SS_DOUBLE); ssSetInputPortDirectFeedThrough(S, 0, 1); /* Set output port properties */ if (!ssSetNumOutputPorts(S, 1)) return; ssSetOutputPortDataType(S, 0, udtId); ssSetOutputPortWidth(S, 0, 1); /* Set miscellaneous properties */ ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); /* specify the sim state compliance to be same as a built-in block */ ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE); ssSetOptions(S, SS_OPTION_WORKS_WITH_CODE_REUSE | SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME | SS_OPTION_SFUNCTION_INLINED_FOR_RTW); }
/* Function: mdlInitializeSizes =============================================== * Abstract: * The sizes information is used by Simulink to determine the S-function * block's characteristics (number of inputs, outputs, states, etc.). */ static void mdlInitializeSizes(SimStruct *S) { ssSetNumSFcnParams(S, 0); /* Number of expected parameters */ if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { /* Return if number of expected != number of actual parameters */ return; } if (!ssSetNumInputPorts(S, 1)) return; ssSetInputPortWidth(S, 0, 1); ssSetInputPortRequiredContiguous(S, 0, true); /*direct input signal access*/ ssSetInputPortDirectFeedThrough(S, 0, 0); if (!ssSetNumOutputPorts(S, 2)) return; ssSetOutputPortWidth(S, 0, 1); ssSetOutputPortWidth(S, 1, 1); ssSetNumSampleTimes(S, 1); /* * Create a DWork data structure. */ { int dtId; /* * Use caution to avoid name conflicts when registering the * data type name. The suggested naming convention is to use * a common prefix based on your Blockset's name for each data type * registered by S-functions in your blocks set. If the S-function * is not part of a blockset, then use your company's name as a prefix. * The data type name is limited to 31 characters. */ dtId = ssRegisterDataType(S, "ExampleCounterStateStruct"); if (dtId == INVALID_DTYPE_ID ) return; /* Register the size of the udt */ if (!ssSetDataTypeSize(S, dtId, sizeof(CounterStateStruct))) return; ssSetNumDWork(S,1); ssSetDWorkDataType(S, 0, dtId); ssSetDWorkWidth(S, 0, 1); ssSetDWorkName(S, 0, "CSStruct"); /*optional name, less than 16 chars*/ } /* specify the sim state compliance to be same as a built-in block */ ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE); ssSetOptions(S, SS_OPTION_WORKS_WITH_CODE_REUSE | SS_OPTION_RUNTIME_EXCEPTION_FREE_CODE | SS_OPTION_USE_TLC_WITH_ACCELERATOR); }
static void mdlInitializeSizes(SimStruct *S) { int_T status; // for new type definition DTypeId COM_HANDLE_id; // for new type definition HANDLE handle_aux; // for new type definition //====================================================== new type definition COM_HANDLE_id = ssRegisterDataType(S, "COM_HANDLE"); if(COM_HANDLE_id == INVALID_DTYPE_ID) return; status = ssSetDataTypeSize(S, COM_HANDLE_id, sizeof(handle_aux)); if(status == 0) return; status = ssSetDataTypeZero(S, COM_HANDLE_id, &handle_aux); if(status == 0) return; //=============================================================== parameters ssSetNumSFcnParams(S, 2); // 2 parameters: // - COM port // - baudrate //Parameter mismatch will be reported by Simulink if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return; //=================================================================== inputs if (!ssSetNumInputPorts(S, 0)) return; // 0 inputs //================================================================== outputs if (!ssSetNumOutputPorts(S, 1)) return; // 1 outputs: // - COM handle ////////////////////////////// com handle ////////////////////////////// ssSetOutputPortWidth(S,0,1); // input 1 width ssSetOutputPortDataType(S, 0, COM_HANDLE_id); // input 1 datatype //============================================================= sample times ssSetNumSampleTimes( S, 1); // number of sample times //============================================================= work vectors ssSetNumRWork(S, 0); // 0 real work vector elements ssSetNumIWork(S, 0); // 0 work vector elements ssSetNumPWork(S, 1); // 1 pwork vector elements: // - COM handle ssSetNumModes(S, 0); // 0 mode work vector elements ssSetNumNonsampledZCs(S, 0); // 0 nonsampled zero crossings }
/* Function: mdlInitializeSizes =============================================== * Abstract: * Setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { slDataTypeAccess *dta = ssGetDataTypeAccess(S); int udtId; ssSetNumSFcnParams(S, 0); /* Number of expected parameters */ if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { /* Return if number of expected != number of actual parameters */ return; } /* Obtain an integer datatype ID for the udt (user-defined type) "Data" */ udtId = ssRegisterDataType(S, "Data"); if ( udtId == INVALID_DTYPE_ID ) return; /* Register the size of the udt */ if (!ssSetDataTypeSize(S, udtId, sizeof(Data))) return; /* Register the zero of the udt */ if (!ssSetDataTypeZero(S, udtId, &zero)) return; /* Set input-port properties */ if (!ssSetNumInputPorts(S, 1)) return; ssSetInputPortWidth(S, 0, 1); ssSetInputPortDataType(S, 0, SS_DOUBLE); ssSetInputPortDirectFeedThrough(S, 0, 1); /* Set output port properties */ if (!ssSetNumOutputPorts(S, 1)) return; ssSetOutputPortDataType(S, 0, udtId); ssSetOutputPortWidth(S, 0, 1); /* Set miscellaneous properties */ ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); /* specify the sim state compliance to be same as a built-in block */ ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE); ssSetOptions(S, SS_OPTION_WORKS_WITH_CODE_REUSE); }
static void mdlSetWorkWidths_c3_MPC_framework(SimStruct *S) { if(sim_mode_is_rtw_gen(S)) { int_T chartIsInlinable = (int_T)sf_is_chart_inlinable("MPC_framework",3); ssSetStateflowIsInlinable(S,chartIsInlinable); ssSetEnableFcnIsTrivial(S,1); ssSetDisableFcnIsTrivial(S,1); ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop("MPC_framework",3,"gatewayCannotBeInlinedMultipleTimes")); if(chartIsInlinable) { ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 2, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 3, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 4, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 5, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 6, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 7, SS_REUSABLE_AND_LOCAL); sf_mark_chart_expressionable_inputs(S,"MPC_framework",3,8); sf_mark_chart_reusable_outputs(S,"MPC_framework",3,3); } if (!sf_is_chart_instance_optimized_out("MPC_framework",3)) { int dtId; char *chartInstanceTypedefName = sf_chart_instance_typedef_name("MPC_framework",3); 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,(1607393255U)); ssSetChecksum1(S,(1677787762U)); ssSetChecksum2(S,(2097080131U)); ssSetChecksum3(S,(3166642993U)); ssSetExplicitFCSSCtrl(S,1); }
static void mdlSetWorkWidths_c2_object_tracker_intensity(SimStruct *S) { if(sim_mode_is_rtw_gen(S)) { int_T chartIsInlinable = (int_T)sf_is_chart_inlinable("object_tracker_intensity",2); ssSetStateflowIsInlinable(S,chartIsInlinable); ssSetEnableFcnIsTrivial(S,1); ssSetDisableFcnIsTrivial(S,1); ssSetNotMultipleInlinable(S,sf_rtw_info_uint_prop("object_tracker_intensity",2,"gatewayCannotBeInlinedMultipleTimes")); if(chartIsInlinable) { ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 2, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 3, SS_REUSABLE_AND_LOCAL); sf_mark_chart_expressionable_inputs(S,"object_tracker_intensity",2,4); sf_mark_chart_reusable_outputs(S,"object_tracker_intensity",2,3); } if (!sf_is_chart_instance_optimized_out("object_tracker_intensity",2)) { int dtId; char *chartInstanceTypedefName = sf_chart_instance_typedef_name("object_tracker_intensity",2); 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,(1312153194U)); ssSetChecksum1(S,(1014398065U)); ssSetChecksum2(S,(1024726701U)); ssSetChecksum3(S,(2475745997U)); ssSetExplicitFCSSCtrl(S,1); }