主要内容

Use Enumerated Data in a C Function Block

R2026b

This example shows how to define and use enumerated data in a C Function block. In this example, a series of traffic lights are defined in an Enumerated Constant block using the Data Type Assistant. The code that controls the traffic lights is written in the Output pane of the Simulation tab of the C Function block dialog box. In the Ports and Parameters table, the data types of the block inputs and outputs are defined as Enum: classname. In this example, the enumerations are defined in the class TrafficLightColor_t, so the type is defined as Enum: TrafficLightColor_t.

open_system('CFunctionEnum')

Output Code to Switch Traffic Lights

Ports and Parameters Table to Define Enumerations

See Also

Objects

Blocks