ssSetRunTimeParamInfo

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.

param

Index of a run-time parameter.

info

ssParamRec structure 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 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.

name

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).

nDimensions

Number of dimensions that this parameter has.

dimensions

Array giving the size of each dimension of the parameter.

dataTypeId

Data type of the parameter. For a list of built-in data types, see ssGetInputPortDataType.

complexSignal

Specifies whether this parameter has complex numbers (true) or real numbers (false) as values.

data

Pointer 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 representing the parameter elements. Complex Simulink® signals are stored interleaved. Likewise complex run-time parameters must be stored interleaved. Note that mxArrays stores the real and complex parts of complex matrices as two separate contiguous pieces of data instead of interleaving the real and complex parts.

    Note   ssSetRunTimeParamInfo must 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.

dataAttributes

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).

nDlgParamIndices

Number of dialog parameters used to compute this run-time parameter.

dlgParamIndices

Indices of dialog parameters used to compute this run-time parameter.

transformed

Specifies the relationship between this run-time parameter and the dialog parameters specified by dlgParamIndices. This field can 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, 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 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 Simulink Coder product writes k out to the Simulink Coder file as an int8 variable with an initial value of 2.

outputAsMatrix

Specifies whether to write the values of this parameter out to the model.rtw file as a matrix (true) or as a vector (false).

Languages

C, C++

Was this topic helpful?