/* Function: mdlInitializeSizes =============================================== * Abstract: * Setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { DECL_AND_INIT_DIMSINFO(inputDimsInfo); DECL_AND_INIT_DIMSINFO(outputDimsInfo); ssSetNumSFcnParams(S, NPARAMS); if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; /* Parameter mismatch will be reported by Simulink */ } ssSetNumContStates(S, NUM_CONT_STATES); ssSetNumDiscStates(S, NUM_DISC_STATES); if (!ssSetNumInputPorts(S, NUM_INPUTS)) return; /*Input Port 0 */ /* Register xref_bus datatype for Input port 0 */ #if defined(MATLAB_MEX_FILE) if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) { DTypeId dataTypeIdReg; ssRegisterTypeFromNamedObject(S, "xref_bus", &dataTypeIdReg); if(dataTypeIdReg == INVALID_DTYPE_ID) return; ssSetInputPortDataType(S,0, dataTypeIdReg); } #endif ssSetInputPortWidth(S, 0, INPUT_0_WIDTH); ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX); ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/ ssSetBusInputAsStruct(S, 0,IN_0_BUS_BASED); ssSetInputPortBusMode(S, 0, SL_BUS_MODE); /*Input Port 1 */ /* Register x_bus datatype for Input port 1 */ #if defined(MATLAB_MEX_FILE) if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) { DTypeId dataTypeIdReg; ssRegisterTypeFromNamedObject(S, "x_bus", &dataTypeIdReg); if(dataTypeIdReg == INVALID_DTYPE_ID) return; ssSetInputPortDataType(S,1, dataTypeIdReg); } #endif ssSetInputPortWidth(S, 1, INPUT_1_WIDTH); ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX); ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/ ssSetBusInputAsStruct(S, 1,IN_1_BUS_BASED); ssSetInputPortBusMode(S, 1, SL_BUS_MODE); if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return; /* Register u_bus datatype for Output port 0 */ #if defined(MATLAB_MEX_FILE) if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) { DTypeId dataTypeIdReg; ssRegisterTypeFromNamedObject(S, "u_bus", &dataTypeIdReg); if(dataTypeIdReg == INVALID_DTYPE_ID) return; ssSetOutputPortDataType(S,0, dataTypeIdReg); } #endif ssSetBusOutputObjectName(S, 0, (void *) "u_bus"); ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH); ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX); ssSetBusOutputAsStruct(S, 0,OUT_0_BUS_BASED); ssSetOutputPortBusMode(S, 0, SL_BUS_MODE); if (ssRTWGenIsCodeGen(S)) { isSimulationTarget = GetRTWEnvironmentMode(S); if (isSimulationTarget==-1) { ssSetErrorStatus(S, " Unable to determine a valid code generation environment mode"); return; } isSimulationTarget |= ssRTWGenIsModelReferenceSimTarget(S); } /* Set the number of dworks */ if (!isDWorkPresent) { if (!ssSetNumDWork(S, 0)) return; } else { if (!ssSetNumDWork(S, 3)) return; } if (isDWorkPresent) { /* * Configure the dwork 0 (u0."BUS") */ #if defined(MATLAB_MEX_FILE) if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) { DTypeId dataTypeIdReg; ssRegisterTypeFromNamedObject(S, "xref_bus", &dataTypeIdReg); if (dataTypeIdReg == INVALID_DTYPE_ID) return; ssSetDWorkDataType(S, 0, dataTypeIdReg); } #endif ssSetDWorkUsageType(S, 0, SS_DWORK_USED_AS_DWORK); ssSetDWorkName(S, 0, "u0BUS"); ssSetDWorkWidth(S, 0, DYNAMICALLY_SIZED); ssSetDWorkComplexSignal(S, 0, COMPLEX_NO); /* * Configure the dwork 1 (u1."BUS") */ #if defined(MATLAB_MEX_FILE) if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) { DTypeId dataTypeIdReg; ssRegisterTypeFromNamedObject(S, "x_bus", &dataTypeIdReg); if (dataTypeIdReg == INVALID_DTYPE_ID) return; ssSetDWorkDataType(S, 1, dataTypeIdReg); } #endif ssSetDWorkUsageType(S, 1, SS_DWORK_USED_AS_DWORK); ssSetDWorkName(S, 1, "u1BUS"); ssSetDWorkWidth(S, 1, DYNAMICALLY_SIZED); ssSetDWorkComplexSignal(S, 1, COMPLEX_NO); /* * Configure the dwork 2 (y0BUS) */ #if defined(MATLAB_MEX_FILE) if (ssGetSimMode(S) != SS_SIMMODE_SIZES_CALL_ONLY) { DTypeId dataTypeIdReg; ssRegisterTypeFromNamedObject(S, "u_bus", &dataTypeIdReg); if (dataTypeIdReg == INVALID_DTYPE_ID) return; ssSetDWorkDataType(S, 2, dataTypeIdReg); } #endif ssSetDWorkUsageType(S, 2, SS_DWORK_USED_AS_DWORK); ssSetDWorkName(S, 2, "y0BUS"); ssSetDWorkWidth(S, 2, DYNAMICALLY_SIZED); ssSetDWorkComplexSignal(S, 2, COMPLEX_NO); } ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); /* Take care when specifying exception free code - see sfuntmpl_doc.c */ ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_WORKS_WITH_CODE_REUSE)); }
/* Function: mdlInitializeSizes =============================================== * Abstract: * Setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { DECL_AND_INIT_DIMSINFO(inputDimsInfo); DECL_AND_INIT_DIMSINFO(outputDimsInfo); ssSetNumSFcnParams(S, NPARAMS); if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; /* Parameter mismatch will be reported by Simulink */ } ssSetNumContStates(S, NUM_CONT_STATES); ssSetNumDiscStates(S, NUM_DISC_STATES); if (!ssSetNumInputPorts(S, NUM_INPUTS)) return; /*Input Port 0 */ ssSetInputPortWidth(S, 0, INPUT_0_WIDTH); /* */ ssSetInputPortDataType(S, 0, SS_UINT8); ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX); ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/ /*Input Port 1 */ ssSetInputPortWidth(S, 1, INPUT_1_WIDTH); ssSetInputPortDataType(S, 1, SS_UINT8); ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX); ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/ /*Input Port 2 */ ssSetInputPortWidth(S, 2, INPUT_2_WIDTH); /* */ ssSetInputPortDataType(S, 2, SS_UINT8); ssSetInputPortComplexSignal(S, 2, INPUT_2_COMPLEX); ssSetInputPortDirectFeedThrough(S, 2, INPUT_2_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 2, 1); /*direct input signal access*/ if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return; /* Output Port 0 */ ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH); ssSetOutputPortDataType(S, 0, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX); /* Output Port 1 */ ssSetOutputPortWidth(S, 1, OUTPUT_1_WIDTH); ssSetOutputPortDataType(S, 1, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_COMPLEX); ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); ssSetSimulinkVersionGeneratedIn(S, "8.4"); /* Take care when specifying exception free code - see sfuntmpl_doc.c */ ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_WORKS_WITH_CODE_REUSE)); }
static void mdlInitializeSizes(SimStruct *S) { ssSetNumSFcnParams(S, NUM_PARAMS); if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) return; /* Inputs: */ if (!ssSetNumInputPorts(S, 2)) return; ssSetInputPortDataType(S, 0, DYNAMICALLY_TYPED); ssSetInputPortDataType(S, 1, DYNAMICALLY_TYPED); if(!ssSetInputPortDimensionInfo(S, 0, DYNAMIC_DIMENSION)) return; if(!ssSetInputPortDimensionInfo(S, 1, DYNAMIC_DIMENSION)) return; ssSetInputPortFrameData(S, 0, FRAME_INHERITED); ssSetInputPortFrameData(S, 1, FRAME_INHERITED); ssSetInputPortComplexSignal(S, 0, COMPLEX_INHERITED); ssSetInputPortComplexSignal(S, 1, COMPLEX_INHERITED); ssSetInputPortDirectFeedThrough(S, 0, 1); ssSetInputPortDirectFeedThrough(S, 1, 1); ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); ssSetInputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL); ssSetInputPortOverWritable(S, 0, 1); ssSetInputPortOverWritable(S, 1, 1); /* Outputs: */ if (!ssSetNumOutputPorts(S, 1)) return; ssSetOutputPortDataType(S, 0, DYNAMICALLY_TYPED); if(!ssSetOutputPortVectorDimension(S, 0, 1)) return; ssSetOutputPortFrameData(S, 0, FRAME_NO); ssSetOutputPortComplexSignal(S, 0, COMPLEX_INHERITED); ssSetOutputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); ssSetNumSampleTimes(S, 1); /* 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_EXCEPTION_FREE_CODE | SS_OPTION_CAN_BE_CALLED_CONDITIONALLY | SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_NONVOLATILE); }
/* Function: propPortComplexity =========================================== */ void propPortComplexity(SimStruct *S) { CSignal_T cY = ssGetOutputPortComplexSignal( S, 0); CSignal_T cU = ssGetInputPortComplexSignal( S, 0); /* if input is complex, then output must be complex */ if ( cU == COMPLEX_YES ) { /* if output complexity is not known then set it */ if ( cY == COMPLEX_INHERITED ) { ssSetOutputPortComplexSignal(S, 0, COMPLEX_YES); } /* if the output is real, then an error has occurred */ else if ( cY == COMPLEX_NO ) { ssSetErrorStatus(S,"Output is REAL, but input is COMPLEX."); return; } } /* if input is real then output must be real */ else if( cU == COMPLEX_NO ) { /* if output complexity is not known then set it */ if ( cY == COMPLEX_INHERITED ) { ssSetOutputPortComplexSignal(S, 0, COMPLEX_NO); } /* if the output is complex, then an error has occurred */ else if ( cY == COMPLEX_YES ) { ssSetErrorStatus(S,"Output is COMPLEX, but input is REAL."); return; } } else /* Input is COMPLEX_INHERITED) */ { if ( cY == COMPLEX_NO ) { ssSetInputPortComplexSignal(S, 0, COMPLEX_NO ); } else if ( cY == COMPLEX_YES ) { ssSetInputPortComplexSignal(S, 0, COMPLEX_YES ); } } }
/* Function: mdlInitializeSizes =============================================== * Abstract: * Setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { DECL_AND_INIT_DIMSINFO(inputDimsInfo); DECL_AND_INIT_DIMSINFO(outputDimsInfo); ssSetNumSFcnParams(S, NPARAMS); if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; /* Parameter mismatch will be reported by Simulink */ } ssSetNumContStates(S, NUM_CONT_STATES); ssSetNumDiscStates(S, NUM_DISC_STATES); if (!ssSetNumInputPorts(S, NUM_INPUTS)) return; /*Input Port 0 */ inputDimsInfo.width = INPUT_0_WIDTH; ssSetInputPortDimensionInfo(S, 0, &inputDimsInfo); ssSetInputPortMatrixDimensions( S , 0, INPUT_0_WIDTH, INPUT_DIMS_0_COL); ssSetInputPortFrameData(S, 0, IN_0_FRAME_BASED); ssSetInputPortDataType(S, 0, SS_SINGLE); ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX); ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/ /*Input Port 1 */ inputDimsInfo.width = INPUT_1_WIDTH; ssSetInputPortDimensionInfo(S, 1, &inputDimsInfo); ssSetInputPortMatrixDimensions( S , 1, INPUT_1_WIDTH, INPUT_DIMS_1_COL); ssSetInputPortFrameData(S, 1, IN_1_FRAME_BASED); ssSetInputPortDataType(S, 1, SS_INT32); ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX); ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/ if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return; ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); /* Take care when specifying exception free code - see sfuntmpl_doc.c */ ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_WORKS_WITH_CODE_REUSE)); }
static void mdlSetInputPortComplexSignal(SimStruct *S, int_T port, int_T iPortComplexSignal) { int_T oPortComplexSignal = ssGetOutputPortComplexSignal(S,0); /* Set the complex signal of the input ports */ ssSetInputPortComplexSignal(S, port, iPortComplexSignal); if(iPortComplexSignal == COMPLEX_YES){ /* Output port must be a complex signal */ if(oPortComplexSignal == COMPLEX_INHERITED){ ssSetOutputPortComplexSignal(S, 0, COMPLEX_YES); }else if(oPortComplexSignal == COMPLEX_NO){ ssSetErrorStatus(S, "Output port must be complex."); } }else if(oPortComplexSignal != COMPLEX_NO){ /* * The current input port is a real signal. If the other input port * is a real signal, the output port must be a real signal. */ int_T otherPort = (port == 0)? 1 : 0; int_T otherPortComplexSignal = ssGetInputPortComplexSignal(S, otherPort); if(otherPortComplexSignal == COMPLEX_NO){ /* Both input ports are real signals */ if(oPortComplexSignal == COMPLEX_INHERITED){ ssSetOutputPortComplexSignal(S, 0, COMPLEX_NO); }else if(oPortComplexSignal == COMPLEX_YES){ ssSetErrorStatus(S, "Output port must be real."); } } } }
void mdlInitializeSizes(SimStruct *S) /* ======================================================================== */ { /* parameters */ ssSetNumSFcnParams(S, NUM_PARAMS); #if defined(MATLAB_MEX_FILE) if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) { mdlCheckParameters(S); if (ssGetErrorStatus(S) != NULL) return; } else return; #endif ssSetSFcnParamTunable(S, FREQUENCY, SS_PRM_SIM_ONLY_TUNABLE); ssSetSFcnParamTunable(S, BANDWIDTH, SS_PRM_NOT_TUNABLE); ssSetSFcnParamTunable(S, TXVGA_GAIN, SS_PRM_SIM_ONLY_TUNABLE); /* ports */ ssSetNumSampleTimes(S, 1); if (!ssSetNumOutputPorts(S, 0) || !ssSetNumInputPorts(S, 1)) return; ssSetInputPortWidth(S, 0, DYNAMICALLY_SIZED); ssSetInputPortComplexSignal(S, 0, COMPLEX_YES); ssSetInputPortDataType(S, 0, SS_INT8); ssSetInputPortDirectFeedThrough(S, 0, true); ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); /* work Vectors */ ssSetNumPWork(S, P_WORK_LENGTH); ssSetNumIWork(S, 0); ssSetNumRWork(S, NUM_PARAMS); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE); ssSetOptions(S, 0); }
static void mdlInitializeSizes( SimStruct *S ) /* ======================================================================== */ { int_T port; /* set number of expected parameters and check for a mismatch. */ ssSetNumSFcnParams( S, NUM_PARAMS ); #if defined(MATLAB_MEX_FILE) if ( ssGetNumSFcnParams( S ) == ssGetSFcnParamsCount( S ) ) { mdlCheckParameters( S ); if ( ssGetErrorStatus( S ) != NULL ) return; }else { return; } #endif /* sampling */ ssSetNumSampleTimes( S, PORT_BASED_SAMPLE_TIMES ); /* Set number of input ports and tunability */ ssSetSFcnParamTunable( S, DEVICE_INDEX, SS_PRM_NOT_TUNABLE ); /* set the resulting number of ports */ if ( !ssSetNumInputPorts( S, 1 ) ) return; port = 0; { const Frame_T inputsFrames = ( (double) mxGetScalar( ssGetSFcnParam( S, USE_FRAMES ) ) > 0.0) ? FRAME_YES : FRAME_NO; double sample_time = 1 / mxGetScalar( ssGetSFcnParam( S, SAMPLE_RATE ) ); const int_T buf_length = (int_T) (double) mxGetScalar( ssGetSFcnParam( S, FRAME_LENGTH ) ); const time_T period = (time_T) (sample_time * buf_length); ssSetInputPortMatrixDimensions( S, port, buf_length, 1 ); ssSetInputPortComplexSignal( S, port, COMPLEX_YES ); ssSetInputPortDataType( S, port, SS_DOUBLE ); ssSetInputPortFrameData( S, port, inputsFrames ); ssSetInputPortDirectFeedThrough( S, port, 1 ); ssSetInputPortSampleTime( S, port, period ); ssSetInputPortOffsetTime( S, port, 0.0 ); } /* Set number of output ports */ if ( !ssSetNumOutputPorts( S, 0 ) ) return; /* data port properties */ /* Prepare work Vectors */ ssSetNumPWork( S, P_WORK_LENGTH ); ssSetNumIWork( S, I_WORK_LENGTH ); ssSetNumRWork( S, R_WORK_LENGTH ); 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, 0 ); }
static void set_input_port (SimStruct *S, int_T num, DTypeId type) { ssSetInputPortWidth (S, num, 1); ssSetInputPortDataType (S, num, type); ssSetInputPortComplexSignal (S, num, COMPLEX_NO); ssSetInputPortDirectFeedThrough (S, num, 1); ssSetInputPortRequiredContiguous (S, num, 1); /*direct input signal access*/ }
/* Function: mdlSetInputPortComplexSignal ==================================== */ static void mdlSetInputPortComplexSignal(SimStruct *S, int portIndex, CSignal_T cSignalSetting) { ssSetInputPortComplexSignal( S, portIndex, cSignalSetting); propPortComplexity(S); } /* mdlSetInputPortComplexSignal */
/* Function: mdlInitializeSizes =============================================== * Abstract: * Setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { DECL_AND_INIT_DIMSINFO(inputDimsInfo); DECL_AND_INIT_DIMSINFO(outputDimsInfo); ssSetNumSFcnParams(S, NPARAMS); /* Number of expected parameters */ #if defined(MATLAB_MEX_FILE) if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) { mdlCheckParameters(S); if (ssGetErrorStatus(S) != NULL) { return; } } else { return; /* Parameter mismatch will be reported by Simulink */ } #endif ssSetNumContStates(S, NUM_CONT_STATES); ssSetNumDiscStates(S, NUM_DISC_STATES); if (!ssSetNumInputPorts(S, NUM_INPUTS)) return; inputDimsInfo.width = INPUT_0_WIDTH; ssSetInputPortDimensionInfo(S, 0, &inputDimsInfo); ssSetInputPortFrameData(S, 0, IN_0_FRAME_BASED); ssSetInputPortDataType(S, 0, SS_UINT32); ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX); ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/ if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return; outputDimsInfo.width = OUTPUT_0_WIDTH; ssSetOutputPortDimensionInfo(S, 0, &outputDimsInfo); ssSetOutputPortFrameData(S, 0, OUT_0_FRAME_BASED); ssSetOutputPortDataType(S, 0, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX); ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX); ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); /* Take care when specifying exception free code - see sfuntmpl_doc.c */ ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_WORKS_WITH_CODE_REUSE)); }
/* Function: mdlInitializeSizes =============================================== * Abstract: * Call mdlCheckParameters to verify that the parameters are okay, * then setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { ssSetNumSFcnParams(S, 0); /* Number of expected parameters */ ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); if (!ssSetNumInputPorts(S, 1)) return; ssSetInputPortDirectFeedThrough(S, 0, 1); if (!ssSetNumOutputPorts(S, 6)) return; ssSetInputPortWidth (S, 0, DYNAMICALLY_SIZED); ssSetInputPortComplexSignal(S, 0, COMPLEX_INHERITED); ssSetOutputPortWidth (S, 0, DYNAMICALLY_SIZED); ssSetOutputPortComplexSignal(S, 0, COMPLEX_INHERITED); ssSetOutputPortWidth (S, 1, DYNAMICALLY_SIZED); ssSetOutputPortComplexSignal(S, 1, COMPLEX_INHERITED); ssSetOutputPortWidth (S, 2, DYNAMICALLY_SIZED); ssSetOutputPortComplexSignal(S, 2, COMPLEX_INHERITED); ssSetOutputPortWidth (S, 3, DYNAMICALLY_SIZED); ssSetOutputPortComplexSignal(S, 3, COMPLEX_INHERITED); ssSetOutputPortWidth (S, 4, DYNAMICALLY_SIZED); ssSetOutputPortComplexSignal(S, 4, COMPLEX_INHERITED); ssSetOutputPortWidth (S, 5, DYNAMICALLY_SIZED); ssSetOutputPortComplexSignal(S, 5, COMPLEX_INHERITED); 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); /* Take care when specifying exception free code - see sfuntmpl_doc.c */ ssSetOptions(S, SS_OPTION_WORKS_WITH_CODE_REUSE | SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_EXCEPTION_FREE_CODE); }
static void mdlSetOutputPortComplexSignal(SimStruct *S, int_T port, int_T oPortComplexSignal) { /* Set the complex signal of the output ports */ ssSetOutputPortComplexSignal(S, 0, oPortComplexSignal); if(oPortComplexSignal == COMPLEX_NO){ /* All inputs must be real */ int_T i; for (i = 0; i < 2; i++) { int_T iPortComplexSignal = ssGetInputPortComplexSignal(S, i); if(iPortComplexSignal == COMPLEX_INHERITED){ ssSetInputPortComplexSignal(S, i, COMPLEX_NO); } else if(iPortComplexSignal == COMPLEX_YES){ ssSetErrorStatus(S, "The output port is a 'real' signal. " "All input ports must be 'real' signals."); } } }else{ /* * Output port is a complex signal. Report an error, if all * inputs are real. */ int_T i; boolean_T realInputs = true; for (i = 0; i < 2; i++) { if(ssGetInputPortComplexSignal(S, i) != COMPLEX_NO){ realInputs = false; break; } } if(realInputs){ ssSetErrorStatus(S, "Input port and output port complex signal " "mismatch. All input ports are 'real' signal. " "The output port must be a 'real' signal."); } } }
/* 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) { /* Number of expected parameters */ ssSetNumSFcnParams(S, 0); /* * Set the number of pworks. */ ssSetNumPWork(S, 0); /* * Set the number of dworks. */ if (!ssSetNumDWork(S, 0)) return; /* * Set the number of input ports. */ if (!ssSetNumInputPorts(S, 1)) return; /* * Configure the input port 1 */ ssSetInputPortDataType(S, 0, SS_INT32); ssSetInputPortWidth(S, 0, 1); ssSetInputPortComplexSignal(S, 0, COMPLEX_NO); ssSetInputPortDirectFeedThrough(S, 0, 1); ssSetInputPortAcceptExprInRTW(S, 0, 1); ssSetInputPortOverWritable(S, 0, 1); ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); ssSetInputPortRequiredContiguous(S, 0, 1); /* * Set the number of output ports. */ if (!ssSetNumOutputPorts(S, 1)) return; /* * Configure the output port 1 */ ssSetOutputPortDataType(S, 0, SS_INT32); ssSetOutputPortWidth(S, 0, 1); ssSetOutputPortComplexSignal(S, 0, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 0, 1); /* * Register reserved identifiers to avoid name conflict */ if (ssRTWGenIsCodeGen(S)) { /* * Register reserved identifier for StartFcnSpec */ ssRegMdlInfo(S, (char*)"createAdder", MDL_INFO_ID_RESERVED, 0, 0, (void*) ssGetPath(S)); /* * Register reserved identifier for OutputFcnSpec */ ssRegMdlInfo(S, (char*)"adderOutput", MDL_INFO_ID_RESERVED, 0, 0, (void*) ssGetPath(S)); /* * Register reserved identifier for TerminateFcnSpec */ ssRegMdlInfo(S, (char*)"deleteAdder", MDL_INFO_ID_RESERVED, 0, 0, (void*) ssGetPath(S)); /* * Register reserved identifier for wrappers */ if (ssRTWGenIsModelReferenceSimTarget(S)) { /* * Register reserved identifier for StartFcnSpec for SimulationTarget */ ssRegMdlInfo(S, (char*)"sldemo_sfun_adder_cpp_wrapper_start", MDL_INFO_ID_RESERVED, 0, 0, (void*) ssGetPath(S)); /* * Register reserved identifier for OutputFcnSpec for SimulationTarget */ ssRegMdlInfo(S, (char*)"sldemo_sfun_adder_cpp_wrapper_output", MDL_INFO_ID_RESERVED, 0, 0, (void*) ssGetPath(S)); /* * Register reserved identifier for TerminateFcnSpec for SimulationTarget */ ssRegMdlInfo(S, (char*)"sldemo_sfun_adder_cpp_wrapper_terminate", MDL_INFO_ID_RESERVED, 0, 0, (void*) ssGetPath(S)); } } /* * This S-function can be used in referenced model simulating in normal mode. */ ssSetModelReferenceNormalModeSupport(S, MDL_START_AND_MDL_PROCESS_PARAMS_OK); /* * Set the number of sample time. */ ssSetNumSampleTimes(S, 1); /* * All options have the form SS_OPTION_<name> and are documented in * matlabroot/simulink/include/simstruc.h. The options should be * bitwise or'd together as in * ssSetOptions(S, (SS_OPTION_name1 | SS_OPTION_name2)) */ ssSetOptions(S, SS_OPTION_CAN_BE_CALLED_CONDITIONALLY | SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_WORKS_WITH_CODE_REUSE | SS_OPTION_SFUNCTION_INLINED_FOR_RTW | SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME); }
/* Function: mdlInitializeSizes =============================================== * Abstract: * Setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { DECL_AND_INIT_DIMSINFO(inputDimsInfo); DECL_AND_INIT_DIMSINFO(outputDimsInfo); ssSetNumSFcnParams(S, NPARAMS); /* Number of expected parameters */ #if defined(MATLAB_MEX_FILE) if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) { mdlCheckParameters(S); if (ssGetErrorStatus(S) != NULL) { return; } } else { return; /* Parameter mismatch will be reported by Simulink */ } #endif ssSetSimStateCompliance(S, USE_DEFAULT_SIM_STATE); ssSetNumContStates(S, NUM_CONT_STATES); ssSetNumDiscStates(S, NUM_DISC_STATES); if (!ssSetNumInputPorts(S, NUM_INPUTS)) return; /*Input Port 0 */ ssSetInputPortWidth(S, 0, INPUT_0_WIDTH); /* */ ssSetInputPortDataType(S, 0, SS_DOUBLE); ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX); ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/ /*Input Port 1 */ ssSetInputPortWidth(S, 1, INPUT_1_WIDTH); /* */ ssSetInputPortDataType(S, 1, SS_DOUBLE); ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX); ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/ /*Input Port 2 */ ssSetInputPortWidth(S, 2, INPUT_2_WIDTH); /* */ ssSetInputPortDataType(S, 2, SS_DOUBLE); ssSetInputPortComplexSignal(S, 2, INPUT_2_COMPLEX); ssSetInputPortDirectFeedThrough(S, 2, INPUT_2_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 2, 1); /*direct input signal access*/ /*Input Port 3 */ ssSetInputPortWidth(S, 3, INPUT_3_WIDTH); /* */ ssSetInputPortDataType(S, 3, SS_DOUBLE); ssSetInputPortComplexSignal(S, 3, INPUT_3_COMPLEX); ssSetInputPortDirectFeedThrough(S, 3, INPUT_3_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 3, 1); /*direct input signal access*/ /*Input Port 4 */ ssSetInputPortWidth(S, 4, INPUT_4_WIDTH); /* */ ssSetInputPortDataType(S, 4, SS_DOUBLE); ssSetInputPortComplexSignal(S, 4, INPUT_4_COMPLEX); ssSetInputPortDirectFeedThrough(S, 4, INPUT_4_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 4, 1); /*direct input signal access*/ if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return; /* Output Port 0 */ ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH); ssSetOutputPortDataType(S, 0, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX); ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); /* Take care when specifying exception free code - see sfuntmpl_doc.c */ ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_WORKS_WITH_CODE_REUSE)); }
/* Function: mdlInitializeSizes =============================================== * Abstract: * Setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { DECL_AND_INIT_DIMSINFO(inputDimsInfo); DECL_AND_INIT_DIMSINFO(outputDimsInfo); ssSetNumSFcnParams(S, NPARAMS); if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; /* Parameter mismatch will be reported by Simulink */ } ssSetNumContStates(S, NUM_CONT_STATES); ssSetNumDiscStates(S, NUM_DISC_STATES); if (!ssSetNumInputPorts(S, NUM_INPUTS)) return; /*Input Port 0 */ inputDimsInfo.width = INPUT_0_WIDTH; ssSetInputPortDimensionInfo(S, 0, &inputDimsInfo); ssSetInputPortMatrixDimensions( S , 0, INPUT_0_WIDTH, INPUT_DIMS_0_COL); ssSetInputPortFrameData(S, 0, IN_0_FRAME_BASED); ssSetInputPortDataType(S, 0, SS_DOUBLE); ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX); ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/ /*Input Port 1 */ inputDimsInfo.width = INPUT_1_WIDTH; ssSetInputPortDimensionInfo(S, 1, &inputDimsInfo); ssSetInputPortMatrixDimensions( S , 1, INPUT_1_WIDTH, INPUT_DIMS_1_COL); ssSetInputPortFrameData(S, 1, IN_1_FRAME_BASED); ssSetInputPortDataType(S, 1, SS_DOUBLE); ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX); ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/ /*Input Port 2 */ inputDimsInfo.width = INPUT_2_WIDTH; ssSetInputPortDimensionInfo(S, 2, &inputDimsInfo); ssSetInputPortMatrixDimensions( S , 2, INPUT_2_WIDTH, INPUT_DIMS_2_COL); ssSetInputPortFrameData(S, 2, IN_2_FRAME_BASED); ssSetInputPortDataType(S, 2, SS_DOUBLE); ssSetInputPortComplexSignal(S, 2, INPUT_2_COMPLEX); ssSetInputPortDirectFeedThrough(S, 2, INPUT_2_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 2, 1); /*direct input signal access*/ /*Input Port 3 */ inputDimsInfo.width = INPUT_3_WIDTH; ssSetInputPortDimensionInfo(S, 3, &inputDimsInfo); ssSetInputPortMatrixDimensions( S , 3, INPUT_3_WIDTH, INPUT_DIMS_3_COL); ssSetInputPortFrameData(S, 3, IN_3_FRAME_BASED); ssSetInputPortDataType(S, 3, SS_DOUBLE); ssSetInputPortComplexSignal(S, 3, INPUT_3_COMPLEX); ssSetInputPortDirectFeedThrough(S, 3, INPUT_3_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 3, 1); /*direct input signal access*/ /*Input Port 4 */ inputDimsInfo.width = INPUT_4_WIDTH; ssSetInputPortDimensionInfo(S, 4, &inputDimsInfo); ssSetInputPortMatrixDimensions( S , 4, INPUT_4_WIDTH, INPUT_DIMS_4_COL); ssSetInputPortFrameData(S, 4, IN_4_FRAME_BASED); ssSetInputPortDataType(S, 4, SS_DOUBLE); ssSetInputPortComplexSignal(S, 4, INPUT_4_COMPLEX); ssSetInputPortDirectFeedThrough(S, 4, INPUT_4_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 4, 1); /*direct input signal access*/ /*Input Port 5 */ ssSetInputPortWidth(S, 5, INPUT_5_WIDTH); /* */ ssSetInputPortDataType(S, 5, SS_DOUBLE); ssSetInputPortComplexSignal(S, 5, INPUT_5_COMPLEX); ssSetInputPortDirectFeedThrough(S, 5, INPUT_5_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 5, 1); /*direct input signal access*/ /*Input Port 6 */ ssSetInputPortWidth(S, 6, INPUT_6_WIDTH); /* */ ssSetInputPortDataType(S, 6, SS_DOUBLE); ssSetInputPortComplexSignal(S, 6, INPUT_6_COMPLEX); ssSetInputPortDirectFeedThrough(S, 6, INPUT_6_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 6, 1); /*direct input signal access*/ /*Input Port 7 */ inputDimsInfo.width = INPUT_7_WIDTH; ssSetInputPortDimensionInfo(S, 7, &inputDimsInfo); ssSetInputPortMatrixDimensions( S ,7, INPUT_7_WIDTH, INPUT_DIMS_7_COL); ssSetInputPortFrameData(S, 7, IN_7_FRAME_BASED); ssSetInputPortDataType(S, 7, SS_DOUBLE); ssSetInputPortComplexSignal(S, 7, INPUT_7_COMPLEX); ssSetInputPortDirectFeedThrough(S, 7, INPUT_7_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 7, 1); /*direct input signal access*/ /*Input Port 8 */ inputDimsInfo.width = INPUT_8_WIDTH; ssSetInputPortDimensionInfo(S, 8, &inputDimsInfo); ssSetInputPortMatrixDimensions( S ,8, INPUT_8_WIDTH, INPUT_DIMS_8_COL); ssSetInputPortFrameData(S, 8, IN_8_FRAME_BASED); ssSetInputPortDataType(S, 8, SS_DOUBLE); ssSetInputPortComplexSignal(S, 8, INPUT_8_COMPLEX); ssSetInputPortDirectFeedThrough(S, 8, INPUT_8_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 8, 1); /*direct input signal access*/ /*Input Port 9 */ inputDimsInfo.width = INPUT_9_WIDTH; ssSetInputPortDimensionInfo(S, 9, &inputDimsInfo); ssSetInputPortMatrixDimensions( S ,9, INPUT_9_WIDTH, INPUT_DIMS_9_COL); ssSetInputPortFrameData(S, 9, IN_9_FRAME_BASED); ssSetInputPortDataType(S, 9, SS_DOUBLE); ssSetInputPortComplexSignal(S, 9, INPUT_9_COMPLEX); ssSetInputPortDirectFeedThrough(S, 9, INPUT_9_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 9, 1); /*direct input signal access*/ /*Input Port 10 */ inputDimsInfo.width = INPUT_10_WIDTH; ssSetInputPortDimensionInfo(S, 10, &inputDimsInfo); ssSetInputPortMatrixDimensions( S ,10, INPUT_10_WIDTH, INPUT_DIMS_10_COL); ssSetInputPortFrameData(S, 10, IN_10_FRAME_BASED); ssSetInputPortDataType(S, 10, SS_UINT8); ssSetInputPortComplexSignal(S, 10, INPUT_10_COMPLEX); ssSetInputPortDirectFeedThrough(S, 10, INPUT_10_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 10, 1); /*direct input signal access*/ /*Input Port 11 */ inputDimsInfo.width = INPUT_11_WIDTH; ssSetInputPortDimensionInfo(S, 11, &inputDimsInfo); ssSetInputPortMatrixDimensions( S ,11, INPUT_11_WIDTH, INPUT_DIMS_11_COL); ssSetInputPortFrameData(S, 11, IN_11_FRAME_BASED); ssSetInputPortDataType(S, 11, SS_UINT8); ssSetInputPortComplexSignal(S, 11, INPUT_11_COMPLEX); ssSetInputPortDirectFeedThrough(S, 11, INPUT_11_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 11, 1); /*direct input signal access*/ /*Input Port 12 */ inputDimsInfo.width = INPUT_12_WIDTH; ssSetInputPortDimensionInfo(S, 12, &inputDimsInfo); ssSetInputPortMatrixDimensions( S ,12, INPUT_12_WIDTH, INPUT_DIMS_12_COL); ssSetInputPortFrameData(S, 12, IN_12_FRAME_BASED); ssSetInputPortDataType(S, 12, SS_UINT8); ssSetInputPortComplexSignal(S, 12, INPUT_12_COMPLEX); ssSetInputPortDirectFeedThrough(S, 12, INPUT_12_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 12, 1); /*direct input signal access*/ if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return; ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); /* Take care when specifying exception free code - see sfuntmpl_doc.c */ ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_WORKS_WITH_CODE_REUSE)); }
/* 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) { int_T nInputPorts = 1; /* number of input ports */ int_T nOutputPorts = 1; /* number of output ports */ int_T needsInput = 1; /* direct feed through */ int_T inputPortIdx = 0; int_T outputPortIdx = 0; ssSetNumSFcnParams(S, 0); /* Number of expected parameters */ if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; } if (ssGetErrorStatus(S) != NULL) return; /* Register the number and type of states the S-Function uses */ ssSetNumContStates( S, 0); /* number of continuous states */ ssSetNumDiscStates( S, 0); /* number of discrete states */ /* * Configure the input ports. First set the number of input ports. */ if (!ssSetNumInputPorts(S, nInputPorts)) return; if(!ssSetInputPortDimensionInfo(S, inputPortIdx, DYNAMIC_DIMENSION)) return; ssSetInputPortWidth(S, inputPortIdx, DYNAMICALLY_SIZED); ssSetInputPortRequiredContiguous(S, inputPortIdx, TRUE); /*direct input signal access*/ ssSetInputPortDataType(S, inputPortIdx,DYNAMICALLY_TYPED); ssSetInputPortDirectFeedThrough(S, inputPortIdx,TRUE); ssSetInputPortOverWritable(S, inputPortIdx, FALSE); ssSetInputPortReusable(S, inputPortIdx,TRUE); ssSetInputPortComplexSignal( S, inputPortIdx, COMPLEX_INHERITED); /* * Configure the output ports. First set the number of output ports. */ if (!ssSetNumOutputPorts(S, nOutputPorts)) return; if(!ssSetOutputPortDimensionInfo(S,outputPortIdx,DYNAMIC_DIMENSION)) return; ssSetOutputPortWidth(S, outputPortIdx, DYNAMICALLY_SIZED); /* register data type */ ssSetOutputPortDataType( S, outputPortIdx, DYNAMICALLY_TYPED ); ssSetOutputPortReusable( S, outputPortIdx, TRUE); ssSetOutputPortComplexSignal(S, outputPortIdx, COMPLEX_INHERITED ); ssSetNumSampleTimes( S, 1); /* number of sample times */ /* * Set size of the work vectors. */ ssSetNumRWork( S, 0); /* number of real work vector elements */ ssSetNumIWork( S, 0); /* number of integer work vector elements*/ ssSetNumPWork( S, 0); /* number of pointer work vector elements*/ ssSetNumModes( S, 0); /* number of mode work vector elements */ ssSetNumNonsampledZCs( S, 0); /* number of nonsampled zero crossings */ ssSetOptions( S, 0); /* general options (SS_OPTION_xx) */ ssFxpSetU32BitRegionCompliant(S, 1); } /* end mdlInitializeSizes */
/* Function: mdlInitializeSizes =============================================== * Abstract: * Setup sizes of the various vectors. */ static void mdlInitializeSizes(SimStruct *S) { DECL_AND_INIT_DIMSINFO(inputDimsInfo); DECL_AND_INIT_DIMSINFO(outputDimsInfo); ssSetNumSFcnParams(S, NPARAMS); /* Number of expected parameters */ #if defined(MATLAB_MEX_FILE) if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) { mdlCheckParameters(S); if (ssGetErrorStatus(S) != NULL) { return; } } else { return; /* Parameter mismatch will be reported by Simulink */ } #endif ssSetNumContStates(S, NUM_CONT_STATES); ssSetNumDiscStates(S, NUM_DISC_STATES); if (!ssSetNumInputPorts(S, NUM_INPUTS)) return; /*Input Port 0 */ ssSetInputPortWidth(S, 0, INPUT_0_WIDTH); /* */ ssSetInputPortDataType(S, 0, SS_DOUBLE); ssSetInputPortComplexSignal(S, 0, INPUT_0_COMPLEX); ssSetInputPortDirectFeedThrough(S, 0, INPUT_0_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/ /*Input Port 1 */ ssSetInputPortWidth(S, 1, INPUT_1_WIDTH); /* */ ssSetInputPortDataType(S, 1, SS_DOUBLE); ssSetInputPortComplexSignal(S, 1, INPUT_1_COMPLEX); ssSetInputPortDirectFeedThrough(S, 1, INPUT_1_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 1, 1); /*direct input signal access*/ /*Input Port 2 */ ssSetInputPortWidth(S, 2, INPUT_2_WIDTH); /* */ ssSetInputPortDataType(S, 2, SS_DOUBLE); ssSetInputPortComplexSignal(S, 2, INPUT_2_COMPLEX); ssSetInputPortDirectFeedThrough(S, 2, INPUT_2_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 2, 1); /*direct input signal access*/ /*Input Port 3 */ ssSetInputPortWidth(S, 3, INPUT_3_WIDTH); /* */ ssSetInputPortDataType(S, 3, SS_DOUBLE); ssSetInputPortComplexSignal(S, 3, INPUT_3_COMPLEX); ssSetInputPortDirectFeedThrough(S, 3, INPUT_3_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 3, 1); /*direct input signal access*/ /*Input Port 4 */ ssSetInputPortWidth(S, 4, INPUT_4_WIDTH); /* */ ssSetInputPortDataType(S, 4, SS_DOUBLE); ssSetInputPortComplexSignal(S, 4, INPUT_4_COMPLEX); ssSetInputPortDirectFeedThrough(S, 4, INPUT_4_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 4, 1); /*direct input signal access*/ /*Input Port 5 */ ssSetInputPortWidth(S, 5, INPUT_5_WIDTH); /* */ ssSetInputPortDataType(S, 5, SS_DOUBLE); ssSetInputPortComplexSignal(S, 5, INPUT_5_COMPLEX); ssSetInputPortDirectFeedThrough(S, 5, INPUT_5_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 5, 1); /*direct input signal access*/ /*Input Port 6 */ ssSetInputPortWidth(S, 6, INPUT_6_WIDTH); /* */ ssSetInputPortDataType(S, 6, SS_DOUBLE); ssSetInputPortComplexSignal(S, 6, INPUT_6_COMPLEX); ssSetInputPortDirectFeedThrough(S, 6, INPUT_6_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 6, 1); /*direct input signal access*/ /*Input Port 7 */ ssSetInputPortWidth(S, 7, INPUT_7_WIDTH); /* */ ssSetInputPortDataType(S, 7, SS_DOUBLE); ssSetInputPortComplexSignal(S, 7, INPUT_7_COMPLEX); ssSetInputPortDirectFeedThrough(S, 7, INPUT_7_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 7, 1); /*direct input signal access*/ /*Input Port 8 */ ssSetInputPortWidth(S, 8, INPUT_8_WIDTH); /* */ ssSetInputPortDataType(S, 8, SS_DOUBLE); ssSetInputPortComplexSignal(S, 8, INPUT_8_COMPLEX); ssSetInputPortDirectFeedThrough(S, 8, INPUT_8_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 8, 1); /*direct input signal access*/ /*Input Port 9 */ ssSetInputPortWidth(S, 9, INPUT_9_WIDTH); /* */ ssSetInputPortDataType(S, 9, SS_DOUBLE); ssSetInputPortComplexSignal(S, 9, INPUT_9_COMPLEX); ssSetInputPortDirectFeedThrough(S, 9, INPUT_9_FEEDTHROUGH); ssSetInputPortRequiredContiguous(S, 9, 1); /*direct input signal access*/ if (!ssSetNumOutputPorts(S, NUM_OUTPUTS)) return; /* Output Port 0 */ ssSetOutputPortWidth(S, 0, OUTPUT_0_WIDTH); ssSetOutputPortDataType(S, 0, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 0, OUTPUT_0_COMPLEX); /* Output Port 1 */ ssSetOutputPortWidth(S, 1, OUTPUT_1_WIDTH); ssSetOutputPortDataType(S, 1, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 1, OUTPUT_1_COMPLEX); /* Output Port 2 */ ssSetOutputPortWidth(S, 2, OUTPUT_2_WIDTH); ssSetOutputPortDataType(S, 2, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 2, OUTPUT_2_COMPLEX); /* Output Port 3 */ ssSetOutputPortWidth(S, 3, OUTPUT_3_WIDTH); ssSetOutputPortDataType(S, 3, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 3, OUTPUT_3_COMPLEX); /* Output Port 4 */ ssSetOutputPortWidth(S, 4, OUTPUT_4_WIDTH); ssSetOutputPortDataType(S, 4, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 4, OUTPUT_4_COMPLEX); /* Output Port 5 */ ssSetOutputPortWidth(S, 5, OUTPUT_5_WIDTH); ssSetOutputPortDataType(S, 5, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 5, OUTPUT_5_COMPLEX); /* Output Port 6 */ ssSetOutputPortWidth(S, 6, OUTPUT_6_WIDTH); ssSetOutputPortDataType(S, 6, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 6, OUTPUT_6_COMPLEX); /* Output Port 7 */ ssSetOutputPortWidth(S, 7, OUTPUT_7_WIDTH); ssSetOutputPortDataType(S, 7, SS_DOUBLE); ssSetOutputPortComplexSignal(S, 7, OUTPUT_7_COMPLEX); ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 0); ssSetNumIWork(S, 0); ssSetNumPWork(S, 0); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); /*initialzation of sizes related to DWork Vectors*/ ssSetNumDWork(S,NDWORKS); /*DWork vector 1*/ ssSetDWorkWidth(S, 0, DWORK_0_WIDTH); ssSetDWorkDataType(S, 0, SS_DOUBLE); ssSetDWorkWidth(S, 1, DWORK_1_WIDTH); ssSetDWorkDataType(S, 1, SS_DOUBLE); ssSetDWorkWidth(S, 2, DWORK_2_WIDTH); ssSetDWorkDataType(S, 2, SS_DOUBLE); ssSetDWorkWidth(S, 3, DWORK_3_WIDTH); ssSetDWorkDataType(S, 3, SS_DOUBLE); ssSetDWorkWidth(S, 4, DWORK_4_WIDTH); ssSetDWorkDataType(S, 4, SS_DOUBLE); ssSetDWorkWidth(S, 5, DWORK_5_WIDTH); ssSetDWorkDataType(S, 5, SS_DOUBLE); ssSetDWorkWidth(S, 6, DWORK_6_WIDTH); ssSetDWorkDataType(S, 6, SS_DOUBLE); ssSetDWorkWidth(S, 7, DWORK_7_WIDTH); ssSetDWorkDataType(S, 7, SS_DOUBLE); ssSetDWorkWidth(S, 8, DWORK_8_WIDTH); ssSetDWorkDataType(S, 8, SS_DOUBLE); ssSetDWorkWidth(S, 9, DWORK_9_WIDTH); ssSetDWorkDataType(S, 9, SS_DOUBLE); ssSetDWorkWidth(S, 10, DWORK_10_WIDTH); ssSetDWorkDataType(S, 10, SS_DOUBLE); ssSetDWorkWidth(S, 11, DWORK_11_WIDTH); ssSetDWorkDataType(S, 11, SS_DOUBLE); ssSetDWorkWidth(S, 12, DWORK_12_WIDTH); ssSetDWorkDataType(S, 12, SS_DOUBLE); ssSetDWorkWidth(S, 13, DWORK_13_WIDTH); ssSetDWorkDataType(S, 13, SS_DOUBLE); ssSetDWorkWidth(S, 14, DWORK_14_WIDTH); ssSetDWorkDataType(S, 14, SS_DOUBLE); ssSetDWorkWidth(S, 15, DWORK_15_WIDTH); ssSetDWorkDataType(S, 15, SS_DOUBLE); ssSetDWorkWidth(S, 16, DWORK_16_WIDTH); ssSetDWorkDataType(S, 16, SS_DOUBLE); ssSetDWorkWidth(S, 17, DWORK_17_WIDTH); ssSetDWorkDataType(S, 17, SS_DOUBLE); ssSetDWorkWidth(S, 18, DWORK_18_WIDTH); ssSetDWorkDataType(S, 18, SS_DOUBLE); ssSetDWorkWidth(S, 19, DWORK_19_WIDTH); ssSetDWorkDataType(S, 19, SS_DOUBLE); ssSetDWorkWidth(S, 20, DWORK_20_WIDTH); ssSetDWorkDataType(S, 20, SS_DOUBLE); ssSetDWorkWidth(S, 21, DWORK_21_WIDTH); ssSetDWorkDataType(S, 21, SS_DOUBLE); ssSetDWorkWidth(S, 22, DWORK_22_WIDTH); ssSetDWorkDataType(S, 22, SS_DOUBLE); ssSetDWorkWidth(S, 23, DWORK_23_WIDTH); ssSetDWorkDataType(S, 23, SS_DOUBLE); /* Take care when specifying exception free code - see sfuntmpl_doc.c */ ssSetOptions(S, (SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_WORKS_WITH_CODE_REUSE)); }
static void mdlInitializeSizes(SimStruct *S) { int_T param; int_T nports_in = 1; int_T nports_out = 2; int_T idxin_x0 = 0; int_T idxin_params = 0; int_T idxin_reset = 0; int_T idxout_time = 0; ssSetNumSFcnParams(S, NPARAMS); /* Number of expected parameters */ #if defined(MATLAB_MEX_FILE) if (ssGetNumSFcnParams(S) == ssGetSFcnParamsCount(S)) { mdlCheckParameters(S); if (ssGetErrorStatus(S) != NULL) return; } else return; /* Parameter mismatch will be reported by Simulink */ #endif for( param=0; param<NPARAMS; param++ ) { ssSetSFcnParamTunable(S,param,false); } ssSetNumSampleTimes(S, 1); ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); ssSetNumRWork(S, 0); ssSetNumIWork(S, DYNAMICALLY_SIZED); ssSetNumPWork(S, DYNAMICALLY_SIZED); ssSetNumDWork(S, DYNAMICALLY_SIZED); ssSetNumModes(S, 0); ssSetNumNonsampledZCs(S, 0); if( intval(mxGetScalar(paramInitialConditionSource)) > 1 ) { idxin_x0 = nports_in++; } if( intval(mxGetScalar(paramSpecificationsSource)) == 3 ) { idxin_params = nports_in++; } if( intval(mxGetScalar(paramExternalReset)) > 1 ) { idxin_reset = nports_in++; } if( intval(mxGetScalar(paramOutputTime)) > 0 ) { idxout_time = nports_out++; } if( !ssSetNumInputPorts(S, nports_in) ) return; if( !ssSetNumOutputPorts(S, nports_out) ) return; ssSetInputPortWidth(S, 0, DYNAMICALLY_SIZED); ssSetInputPortDataType(S, 0, SS_DOUBLE ); ssSetInputPortComplexSignal(S, 0, 0); ssSetInputPortDirectFeedThrough(S, 0, 1); ssSetInputPortRequiredContiguous(S, 0, 1); /*direct input signal access*/ ssSetOutputPortWidth(S, 0, 1); ssSetOutputPortWidth(S, 1, DYNAMICALLY_SIZED); ssSetOutputPortDataType(S, 1, SS_DOUBLE); if( idxin_x0 ) { ssSetInputPortWidth(S, idxin_x0, DYNAMICALLY_SIZED); ssSetInputPortDataType(S, idxin_x0, SS_DOUBLE ); ssSetInputPortComplexSignal(S, idxin_x0, 0); ssSetInputPortDirectFeedThrough(S, idxin_x0, 1); ssSetInputPortRequiredContiguous(S, idxin_x0, 1); /*direct input signal access*/ } if( idxin_params ) { ssSetInputPortWidth(S, idxin_params, 2); ssSetInputPortDataType(S, idxin_params, SS_DOUBLE ); ssSetInputPortComplexSignal(S, idxin_params, 0); ssSetInputPortDirectFeedThrough(S, idxin_params, 1); } if( idxin_reset ) { ssSetInputPortWidth(S, idxin_reset, 1); ssSetInputPortDataType(S, idxin_reset, SS_BOOLEAN ); ssSetInputPortComplexSignal(S, idxin_reset, 0); ssSetInputPortDirectFeedThrough(S, idxin_reset, 1); } if( idxout_time ) { ssSetOutputPortWidth(S, idxout_time, 1); ssSetOutputPortDataType(S, idxout_time, SS_DOUBLE); } /* Take care when specifying exception free code - see sfuntmpl_doc.c */ /* ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_CALL_TERMINATE_ON_EXIT ); */ ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE ); }
/* 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) { /* Number of expected parameters */ ssSetNumSFcnParams(S, 0); /* * Set the number of pworks. */ ssSetNumPWork(S, 0); /* * Set the number of dworks. */ if (!ssSetNumDWork(S, 0)) return; /* * Set the number of input ports. */ if (!ssSetNumInputPorts(S, 1)) return; /* * Configure the input port 1 */ ssSetInputPortDataType(S, 0, SS_UINT32); ssSetInputPortWidth(S, 0, 2); ssSetInputPortComplexSignal(S, 0, COMPLEX_NO); ssSetInputPortDirectFeedThrough(S, 0, 1); ssSetInputPortAcceptExprInRTW(S, 0, 0); ssSetInputPortOverWritable(S, 0, 0); ssSetInputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); ssSetInputPortRequiredContiguous(S, 0, 1); /* * Set the number of output ports. */ if (!ssSetNumOutputPorts(S, 22)) return; /* * Configure the output port 1 */ ssSetOutputPortDataType(S, 0, SS_UINT32); ssSetOutputPortWidth(S, 0, 1); ssSetOutputPortComplexSignal(S, 0, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 0, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 0, 0); /* * Configure the output port 2 */ ssSetOutputPortDataType(S, 1, SS_UINT32); ssSetOutputPortWidth(S, 1, 1); ssSetOutputPortComplexSignal(S, 1, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 1, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 1, 0); /* * Configure the output port 3 */ ssSetOutputPortDataType(S, 2, SS_UINT32); ssSetOutputPortWidth(S, 2, 1); ssSetOutputPortComplexSignal(S, 2, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 2, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 2, 0); /* * Configure the output port 4 */ ssSetOutputPortDataType(S, 3, SS_UINT32); ssSetOutputPortWidth(S, 3, 1); ssSetOutputPortComplexSignal(S, 3, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 3, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 3, 0); /* * Configure the output port 5 */ ssSetOutputPortDataType(S, 4, SS_DOUBLE); ssSetOutputPortWidth(S, 4, 1); ssSetOutputPortComplexSignal(S, 4, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 4, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 4, 0); /* * Configure the output port 6 */ ssSetOutputPortDataType(S, 5, SS_DOUBLE); ssSetOutputPortWidth(S, 5, 1); ssSetOutputPortComplexSignal(S, 5, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 5, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 5, 0); /* * Configure the output port 7 */ ssSetOutputPortDataType(S, 6, SS_DOUBLE); ssSetOutputPortWidth(S, 6, 1); ssSetOutputPortComplexSignal(S, 6, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 6, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 6, 0); /* * Configure the output port 8 */ ssSetOutputPortDataType(S, 7, SS_DOUBLE); ssSetOutputPortWidth(S, 7, 1); ssSetOutputPortComplexSignal(S, 7, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 7, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 7, 0); /* * Configure the output port 9 */ ssSetOutputPortDataType(S, 8, SS_DOUBLE); ssSetOutputPortWidth(S, 8, 1); ssSetOutputPortComplexSignal(S, 8, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 8, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 8, 0); /* * Configure the output port 10 */ ssSetOutputPortDataType(S, 9, SS_DOUBLE); ssSetOutputPortWidth(S, 9, 1); ssSetOutputPortComplexSignal(S, 9, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 9, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 9, 0); /* * Configure the output port 11 */ ssSetOutputPortDataType(S, 10, SS_DOUBLE); ssSetOutputPortWidth(S, 10, 1); ssSetOutputPortComplexSignal(S, 10, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 10, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 10, 0); /* * Configure the output port 12 */ ssSetOutputPortDataType(S, 11, SS_DOUBLE); ssSetOutputPortWidth(S, 11, 1); ssSetOutputPortComplexSignal(S, 11, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 11, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 11, 0); /* * Configure the output port 13 */ ssSetOutputPortDataType(S, 12, SS_DOUBLE); ssSetOutputPortWidth(S, 12, 1); ssSetOutputPortComplexSignal(S, 12, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 12, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 12, 0); /* * Configure the output port 14 */ ssSetOutputPortDataType(S, 13, SS_DOUBLE); ssSetOutputPortWidth(S, 13, 1); ssSetOutputPortComplexSignal(S, 13, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 13, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 13, 0); /* * Configure the output port 15 */ ssSetOutputPortDataType(S, 14, SS_DOUBLE); ssSetOutputPortWidth(S, 14, 1); ssSetOutputPortComplexSignal(S, 14, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 14, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 14, 0); /* * Configure the output port 16 */ ssSetOutputPortDataType(S, 15, SS_DOUBLE); ssSetOutputPortWidth(S, 15, 1); ssSetOutputPortComplexSignal(S, 15, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 15, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 15, 0); /* * Configure the output port 17 */ ssSetOutputPortDataType(S, 16, SS_DOUBLE); ssSetOutputPortWidth(S, 16, 1); ssSetOutputPortComplexSignal(S, 16, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 16, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 16, 0); /* * Configure the output port 18 */ ssSetOutputPortDataType(S, 17, SS_DOUBLE); ssSetOutputPortWidth(S, 17, 1); ssSetOutputPortComplexSignal(S, 17, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 17, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 17, 0); /* * Configure the output port 19 */ ssSetOutputPortDataType(S, 18, SS_DOUBLE); ssSetOutputPortWidth(S, 18, 1); ssSetOutputPortComplexSignal(S, 18, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 18, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 18, 0); /* * Configure the output port 20 */ ssSetOutputPortDataType(S, 19, SS_DOUBLE); ssSetOutputPortWidth(S, 19, 1); ssSetOutputPortComplexSignal(S, 19, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 19, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 19, 0); /* * Configure the output port 21 */ ssSetOutputPortDataType(S, 20, SS_DOUBLE); ssSetOutputPortWidth(S, 20, 1); ssSetOutputPortComplexSignal(S, 20, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 20, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 20, 0); /* * Configure the output port 22 */ ssSetOutputPortDataType(S, 21, SS_UINT32); ssSetOutputPortWidth(S, 21, 1); ssSetOutputPortComplexSignal(S, 21, COMPLEX_NO); ssSetOutputPortOptimOpts(S, 21, SS_REUSABLE_AND_LOCAL); ssSetOutputPortOutputExprInRTW(S, 21, 0); /* * Register reserved identifiers to avoid name conflict */ if (ssRTWGenIsCodeGen(S)) { /* * Register reserved identifier for StartFcnSpec */ ssRegMdlInfo(S, "openFile", MDL_INFO_ID_RESERVED, 0, 0, ssGetPath(S)); /* * Register reserved identifier for OutputFcnSpec */ ssRegMdlInfo(S, "DrugLibraryReader", MDL_INFO_ID_RESERVED, 0, 0, ssGetPath(S)); /* * Register reserved identifier for TerminateFcnSpec */ ssRegMdlInfo(S, "closeFile", MDL_INFO_ID_RESERVED, 0, 0, ssGetPath(S)); } /* * This S-function can be used in referenced model simulating in normal mode. */ ssSetModelReferenceNormalModeSupport(S, MDL_START_AND_MDL_PROCESS_PARAMS_OK); /* * Set the number of sample time. */ ssSetNumSampleTimes(S, 1); /* * All options have the form SS_OPTION_<name> and are documented in * matlabroot/simulink/include/simstruc.h. The options should be * bitwise or'd together as in * ssSetOptions(S, (SS_OPTION_name1 | SS_OPTION_name2)) */ ssSetOptions(S, SS_OPTION_USE_TLC_WITH_ACCELERATOR | SS_OPTION_CAN_BE_CALLED_CONDITIONALLY | SS_OPTION_EXCEPTION_FREE_CODE | SS_OPTION_WORKS_WITH_CODE_REUSE | SS_OPTION_SFUNCTION_INLINED_FOR_RTW | SS_OPTION_DISALLOW_CONSTANT_SAMPLE_TIME); }