Main Content

ssSetInputPortDataType

Set the data type of an input port

Syntax

DTypeId ssSetInputPortDataType(SimStruct *S, int_T port, DTypeId id)

Arguments

S

SimStruct that represents an S-Function block.

port

Index of an input port.

id

ID of the data type accepted by port.

Returns

The data type ID specified by id. Returns -1 if id is DYNAMICALLY_TYPED.

Description

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
0SS_DOUBLE
1SS_SINGLE
2SS_INT8
3SS_UINT8
4SS_INT16
5SS_UINT16
6SS_INT32
7SS_UINT32
8SS_BOOLEAN

Integer values of 9 or greater represent custom data types such as fixed-point types, bus types, and enumerated data types. The meaning of each value depends on the number and kind of custom data types that you use in a model.

Note

The data type of an input port is double (real_T) by default.

Languages

C, C++

Examples

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.c used in sfcndemo_dtype_io and the S-function sdotproduct.c used in sfcndemo_sdotproduct for complete examples that use this function.

Version History

Introduced before R2006a