Writing S-Functions | ![]() ![]() |
Specify the attributes of a run-time parameter.
Syntax
void ssSetRunTimeParamInfo(SimStruct *S, int_T param, ssParamRec *info)
Arguments
S
SimStruct representing an S-function block.
Description
Use this function in mdlSetWorkWidths
or mdlProcessParameters
to specify information about a run-time parameter. Use a ssParamRec
structure to pass the parameter attributes to the function.
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.
Name of the parameter. This must point to persistent memory. Do not set to a local variable (static char name[32]
or strings name are okay).
Array giving the size of each dimension of the parameter
Data type of the parameter. For built-in data types, see BuiltInDTypeId
in simstruc_types.h.
Specifies whether this parameter has complex numbers (TRUE
) or real numbers (FALSE
) as values.
Pointer to 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 representing the parameter elements. Complex Simulink signals are store interleaved. Likewise complex run-time parameters must be stored interleaved. Note that mxArrays
store the real and complex parts of complex matrices as two separate contiguous pieces of data instead of interleaving the real and complex parts.
The 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).
Number of dialog parameters used to compute this run-time parameter.
Indices of dialog parameters used to compute this run-time parameter
Specifies the relationship between this run-time parameter and the dialog parameters specified by dlgParamIndices
. This field may have any of the following values defined by TransformFlag
in simstruc.h
.
RTPARAM_NOT_TRANSFORMED
Specifies that this run-time parameter corresponds to a single dialog parameter (nDialogParamIndices
is one) and has the same value as the dialog parameter.
RTPARAM_TRANSFORMED
Specifies 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_TUNABLE
Specifies that this run-time parameter corresponds to a single tunable dialog parameter (nDialogParamIndices
is one) and that the run-time parameter's value or data type differs from the dialog parameter's. During code generation, Real-Time Workshop writes the data type and value of the run-time parameter (rather than the dialog parameter) out to the Real-Time Workshop file. For example, suppose that the dialog parameter contains a workspace variable, k
, of type double
and value 1
. Further, suppose the S-function sets the data type of the corresponding run-time variable to int8
and the run-time parameter's value to 2
. In this case, during code generation, the Real-Time Workshop writes k
out to the Real-Time Workshop file as an int8
variable with an initial value of 2
.
Specifies whether to write the value(s) of this parameter out to the model.rtw
file has a matrix (TRUE
) or as a vector (FALSE
).
Languages
See Also
mdlSetWorkWidths, mdlProcessParameters, ssGetNumRumTimeParams, ssGetRunTimeParamInfo
![]() | ssSetPlacementGroup | ssSetSampleTime | ![]() |