Real-Time Workshop | ![]() ![]() |
Symbolic Names for Block States
To determine the variable or field name generated for a block's state, you can either:
Default Block State Naming Convention
If you do not define a symbolic name for a block state, Real-Time Workshop uses the following default naming convention:
BlockType
is the name of the block type (e.g., Discrete_Filter).
#
is a unique ID number (#
) assigned by Real-Time Workshop if multiple instances of the same block type appear in the model. The ID number is appended to BlockType
.
For example, consider the model shown in Figure 5-15.
Figure 5-15: Model with Two Discrete Filter Block States
We will examine code generated for the states of the two Discrete Filter blocks. Assume that:
Auto
storage class (and is therefore stored in the DWork
vector).
ExportedGlobal
storage class.
The initialization code for the states of the two Discrete Filter blocks would be as shown in the following code fragment.
/* DiscreteFilter Block: <Root>/Discrete Filter */ rtDWork.Discrete_Filter_DSTATE = 0.0; /* DiscreteFilter Block: <Root>/Discrete Filter1 */ Discrete_Filter1_DSTATE = 0.0;
User-Defined Block State Names
Using the State Properties dialog box, you can define your own symbolic name for a block state. To do this:
Top_filter
is entered.
The following state initialization code was generated from the example model shown in Figure 5-7, under the following conditions:
Top_filter
, and Auto
storage class (and is therefore stored in the DWork
vector.)
Lower_filter
, and ExportedGlobal
storage class.
![]() | Using the State Properties Dialog Box to Interface States to External Code | Block States and Simulink Signal Objects | ![]() |