Set the data type of an input port
DTypeId ssSetInputPortDataType(SimStruct *S, int_T port, DTypeId id)
Use this function in mdlInitializeSizes to set the data type of the input port specified by port. If the input port data type is inherited from the block connected to the port, set the data type to DYNAMICALLY_TYPED. In this case, the S-function must provide mdlSetInputPortDataType and mdlSetDefaultPortDataTypes methods to enable the data type to be set correctly during signal propagation.
The following table is a list of built-in data types associated with the index DTypeId.
|Integer Data Type ID (DTypeId)||Built-in Data Type|
Suppose that you want to create an S-function with two input ports, the first of which inherits its data type from the driving block and the second of which accepts inputs of type int8_T. The following code sets up the data types.
ssSetInputPortDataType(S, 0, DYNAMICALLY_TYPED) ssSetInputPortDataType(S, 1, SS_INT8)
See the S-function sfun_dtype_io.csfun_dtype_io.c used in sfcndemo_dtype_iosfcndemo_dtype_io and the S-function sdotproduct.csdotproduct.c used in sfcndemo_sdotproductsfcndemo_sdotproduct for complete examples that use this function.