ssSetRunTimeParamInfo
Specify the attributes of a run-time parameter
Syntax
void ssSetRunTimeParamInfo(SimStruct *S, int_T param, ssParamRec *info)
Arguments
SSimStruct that represents an S-Function block.
paramIndex of a run-time parameter.
infossParamRecstructure containing the attributes of the run-time parameter.
Description
Use this function in mdlSetWorkWidths to specify information
about a run-time parameter. Use an ssParamRec structure to pass the parameter attributes
to the function. See Create and Update S-Function Run-Time Parameters for more information.
ssParamRec Structure
The simstruc.h macro defines this structure as
follows:
typedef struct ssParamRec_tag {
const char *name;
int_T nDimensions;
int_T *dimensions;
DTypeId dataTypeId;
boolean_T complexSignal;
void *data;
const void *dataAttributes;
int_T nDlgParamIndices;
int_T *dlgParamIndices;
TransformedFlag transformed; /* Transformed status */
boolean_T outputAsMatrix; /* Write out parameter
* as a vector (false)
* [default] or a matrix (true)
*/
} ssParamRec;
The record contains the following fields.
nameName of the parameter. This must point to persistent memory. Do not set to a local variable (
static char name[32]or character vector name are okay).nDimensionsNumber of dimensions that this parameter has.
dimensionsArray giving the size of each dimension of the parameter.
dataTypeIdData type of the parameter. For a list of built-in data types, see ssGetInputPortDataType.
complexSignalSpecifies whether this parameter has complex numbers (true) or real numbers (false) as values.
dataPointer to the value of this run-time parameter. If the parameter is a vector or matrix or a complex number, this field points to an array of values that represents the parameter elements. Complex Simulink® signals are stored interleaved. Likewise complex run-time parameters must be stored interleaved. Note that
mxArraysstores the real and complex parts of complex matrices as two separate contiguous pieces of data instead of interleaving the real and complex parts.Note
ssSetRunTimeParamInfomust set this field to the parameter's actual value. This is necessary for Simulink Coder™ to perform the parameter pooling optimization correctly. If you fail to set the data field at the time of registration and then fill it in at a later juncture, you might see an error indicating that some parameters were incorrectly pooled with each other.dataAttributesThe data attributes pointer is a persistent storage location where the S-function can store additional information describing the data and then recover this information later (potentially in a different function).
nDlgParamIndicesNumber of dialog parameters used to compute this run-time parameter.
dlgParamIndicesIndices of dialog parameters used to compute this run-time parameter.
transformedSpecifies the relationship between this run-time parameter and the dialog parameters specified by
dlgParamIndices. This field can have any of the following values defined byTransformFlaginsimstruc.h.RTPARAM_NOT_TRANSFORMEDSpecifies that this run-time parameter corresponds to a single dialog parameter (
nDialogParamIndicesis one) and has the same value as the dialog parameter.RTPARAM_TRANSFORMEDSpecifies that the value of this run-time parameter depends on the values of multiple dialog parameters (
nDialogParamIndices > 1) or that this run-time parameter corresponds to one dialog parameter but has a different value or data type.RTPARAM_MAKE_TRANSFORMED_TUNABLESpecifies that this run-time parameter corresponds to a single tunable dialog parameter (
nDialogParamIndicesis one) and that the run-time parameter's value or data type differs from the dialog parameter's. During code generation, the Simulink Coder product writes the data type and value of the run-time parameter (rather than the dialog parameter) out to the Simulink Coder file. For example, suppose that the dialog parameter contains a workspace variablekof typedoubleand value1. Further, suppose the S-function sets the data type of the corresponding run-time variable toint8and the run-time parameter's value to2. In this case, during code generation, the Simulink Coder product writeskout to the Simulink Coder file as anint8variable with an initial value of2.
outputAsMatrixSpecifies whether to write the values of this parameter out to the
file as a matrix (true) or as a vector (false).model.rtw
Languages
C, C++
Examples
See the S-function sfun_runtime4.c used in sfcndemo_runtime.
Version History
Introduced before R2006a