Real-Time Workshop | ![]() ![]() |
Signal Objects
This section discusses how to use signal objects in code generation.
Configuring Signal Objects for Code Generation
In configuring signal objects for code generation, you use the following code generation options and signal object properties:
RTWInfo.StorageClass
. The storage classes defined for signal objects, and their effect on code generation, are the same for model signals and signal objects (see Storage Classes for Signals).
Effect of Storage Classes on Code Generation for Signal Objects
The way in which Real-Time Workshop uses storage classes to determine how signals are stored is the same with and without signal objects. However, if a signal's label resolves to a signal object, the object's RTWInfo.StorageClass
property is used in place of the port configuration of the signal.
The default storage class is Auto
. If the storage type is Auto
, Real-Time Workshop follows the Signal storage reuse, Buffer reuse, and Local block outputs code generation options to determine whether signal objects are stored in reusable and/or local variables. Make sure that these options are set correctly for your application.
To generate a a test point or externally interfaceable signal storage declaration, use an explicit RTWInfo.StorageClass
assignment. For example, setting the storage class to SimulinkGlobal, as in the following command, is equivalent to declaring a signal as a test point.
Example of Signal Object Code Generation
The discussion and code examples in this section refers to the model shown in Figure 5-7.
Figure 5-7: Example Model With Signal Object
To configure a signal object, you must first create it and associate it with a labelled signal in your model. To do this:
Simulink.Signal
. In this example, the signal object is an instance of the example class SimulinkDemos.Signal, which is provided with Simulink. For the definition of SimulinkDemos.Signal, see the directory matlabroot
/toolbox/simulink/simdemos/@SimulinkDemos
.
RTWInfo.StorageClass
property as follows.
Table 5-7 shows, for each setting of RTWInfo.StorageClass
, the variable declaration and the code generated for Sine Wave output (SinSig
) of the model shown in Figure 5-7.
Storage Class |
Declaration |
Code |
![]() | Parameter Object Configuration Quick Reference Diagram | Signal Object Configuration Quick Reference Diagram | ![]() |