Older Custom Storage Classes (Prior to Release 14)

Introduction

In releases prior to Real-Time Workshop Embedded Coder version 4.0 (MATLAB Release 14), custom storage classes were implemented with special Simulink.CustomSignal and Simulink.CustomParameter classes. This section describes these older classes.

Simulink.CustomParameter Class

This class is a subclass of Simulink.Parameter. Objects of this class have expanded RTWInfo properties. The properties of Simulink.CustomParameter objects are:

Simulink.CustomSignal Class

This class is a subclass of Simulink.Signal. Objects of this class have expanded RTWInfo properties. The properties of Simulink.CustomSignal objects are:

The following tables summarize the predefined custom storage classes for Simulink.CustomSignal and Simulink.CustomParameter objects. The entry for each class indicates

The first three classes, shown in Const, ConstVolatile, and Volatile Storage Classes (Prior to Release 14), insert type qualifiers in the data declaration.

Const, ConstVolatile, and Volatile Storage Classes (Prior to Release 14)

Class
Name
PurposeParametersSignalsData
Types
ComplexWide

Const

Use const
type qualifier
in declaration

Y

N

any

Y

Y

ConstVolatile

Use
const volatile
type qualifier
in declaration

Y

N

any

Y

Y

Volatile

Use volatile
type qualifier
in declaration

Y

Y

any

Y

Y

The second set of three classes, shown in ExportToFile, ImportFromFile, and Internal Storage Classes (Prior to Release 14), handles issues of data scope and file partitioning.

ExportToFile, ImportFromFile, and Internal Storage Classes (Prior to Release 14)

Class
Name
PurposeParametersSignalsData
Types
ComplexWide

ExportToFile

Generate and include
files, with user-specified
name, containing global
variable declarations and
definitions

Y

Y

any

Y

Y

ImportFromFile

Include predefined
header files containing
global variable
declarations

Y

Y

any

Y

Y

Internal

Declare and define global
variables whose scope is
limited to Real-Time Workshop generated code

Y

Y

any

Y

Y

The final three classes, shown in BitField, Define, and Struct Storage Classes (Prior to Release 14), specify the data structure or construct used to represent the data.

BitField, Define, and Struct Storage Classes (Prior to Release 14)

Class
Name
PurposeParametersSignalsData
types
ComplexWide

BitField

Embed Boolean data
in a named bit field

Y

Y

Boolean

N

N

Define

Represent parameters
with a #define macro

Y

N

any

N

N

Struct

Embed data in a named
struct to encapsulate
sets of data

Y

Y

any

N

Y

Instance-Specific Attributes for Older Storage Classes

Some custom storage classes have attributes that are exclusive to the class. These attributes are made visible as members of the RTWInfo.CustomAttributes field. For example, the BitField class has a BitFieldName attribute (RTWInfo.CustomAttributes.BitFieldName).

Additional Properties of Custom Storage Classes (Prior to Release 14) summarizes the storage classes with additional attributes, and the meaning of those attributes. Attributes marked optional have default values and may be left unassigned.

Additional Properties of Custom Storage Classes (Prior to Release 14)

Storage Class
Name
Additional PropertiesDescriptionOptional
(has default)

ExportToFile

FileName

String. Defines the name of the generated header file within which the global variable declaration should reside. If unspecified, the declaration is placed in model_export.h by default.

Y

ImportFromFile

FileName

String. Defines the name of the generated header file which to be used in #include directive.

N

ImportFromFile

IncludeDelimeter

Enumerated. Defines delimiter used for filename in the #include directive. Delimiter is either double quotes (for example, #include "vars.h") or angle brackets (for example, #include <vars.h>). The default is quotes.

Y

BitField

BitFieldName

String. Defines name of bit field in which data is embedded; if unassigned, the name defaults to rt_BitField.

Y

Struct

StructName

String. Defines name of the struct in which data is embedded; if unassigned, the name defaults to rt_Struct.

Y

Assigning a Custom Storage Class to Data

You can create custom parameter or signal objects from the MATLAB command line. For example, the following commands create a custom parameter object p and a custom signal object s:

p = Simulink.CustomParameter
s = Simulink.CustomSignal

After creating the object, set the RTWInfo.CustomStorageClass and RTWInfo.CustomAttributes fields. For example, the following commands sets these fields for the custom parameter object p:

p.RTWInfo.CustomStorageClass = 'ExportToFile'
p.RTWInfo.CustomAttributes.FileName = 'testfile.h'

Finally, make sure that the RTWInfo.StorageClass property is set to Custom. If you inadvertently set this property to some other value, the custom storage properties are ignored.

Code Generation with Older Custom Storage Classes

The procedure for generating code with data objects that have a custom storage class is similar to the procedure for code generation using Simulink data objects that have built-in storage classes. If you are unfamiliar with this procedure, see the discussion of Simulink data objects in the Working with Data section of the Real-Time Workshop documentation.

To generate code with custom storage classes, you must

  1. Create one or more data objects of class Simulink.CustomParameter or Simulink.CustomSignal.

  2. Set the custom storage class property of the objects, as well as the class-specific attributes (if any) of the objects.

  3. Reference these objects as block parameters, signals, block states, or Data Store memory.

When generating code from a model employing custom storage classes, make sure that the Ignore custom storage classes option is not selected. This is the default for the Real-Time Workshop Embedded Coder software.

When Ignore custom storage classes is selected:

Ignore custom storage classes lets you switch to a target that does not support CSCs, such as the generic real-time target (GRT), without having to reconfigure your parameter and signal objects.

When using the Real-Time Workshop Embedded Coder software, you can control the Ignore custom storage classes option with the check box in the Real-Time Workshop pane of the Configuration Parameters dialog box.

If you are using a target that does not have a check box for this option (such as a custom target) you can enter the option directly into the TLC options field in the Real-Time Workshop pane of the Configuration Parameters dialog box. The following example turns the option on:

-aIgnoreCustomStorageClasses=1

Compatibility Issues for Older Custom Storage Classes

In Release 14, the full functionality of the Simulink.CustomSignal and Simulink.CustomParameter classes was added to the Simulink.Signal and Simulink.Parameter classes. You should consider replacing the use of Simulink.CustomSignal and Simulink.CustomParameter objects by using equivalent Simulink.Signal and Simulink.Parameter objects.

If you prefer, you can continue to use the Simulink.CustomSignal and Simulink.CustomParameter classes in the current release. Note that the following changes have been implemented in these classes:

Converting Older Packages to Use CSC Registration Files

A Simulink data class package can be associated with one or more CSC definitions. In Release 14, the linkage between a set of CSC definitions and a package is formed when a CSC registration file (csc_registration.m) is located in the package directory.

Prior to Release 14, user-defined CSCs were created by designing custom packages that included the CSC definitions as part of the package.

The Simulink Data Class Designer supports conversion of older packages to the use of CSC registration files. When such a package is selected in Data Class Designer, a special conversion button is displayed on the Custom Storage Classes pane. This button lets you invoke a conversion procedure; you can then write out all files and directories required to define the package, including a CSC registration file. To convert a package:

  1. You should make a complete backup copy of the package directory before converting the package. After backing up the directory, remove the @ prefix from the backup directory name and make sure that the backup directory is not on the MATLAB path.

  2. Open the Simulink Data Class Designer by typing the following command at the MATLAB command prompt:

    sldataclassdesigner
  3. The Data Class Designer loads all packages that exist on the MATLAB path. Select the package to be converted from the Package name menu. Then, click OK.

  4. If you want to store the converted package in a different directory than the original package, enter the desired path in the Parent directory field. This step is optional.

    The figure below shows the package my_converted_package. The package definition is stored in d:\work\testConversion.

  5. Click on the Custom Storage Classes pane. The pane displays a message indicating that the package contains obsolete CSC definitions, as shown in this figure.

    Below the message text, the pane also contains a button captioned Convert Package to Use CSC Registration File. This button invokes a script that converts the package to use a CSC registration file.

    Note that this button does not actually create the CSC registration file. That happens when the package files are written out, as described below.

  6. Click Convert Package to Use CSC Registration File. After conversion, the appearance of the pane changes, as shown below.

  7. Click Confirm Changes. In the Confirm Changes pane, select the package you converted. Add the parent directory to the MATLAB path if necessary. Then, click Write Selected.

  8. Click Close.

  9. You can now view and edit the CSCs belonging to your package in the Custom Storage Class Designer. To do so, type the following command at the MATLAB prompt:

    cscdesigner

    The Custom Storage Class Designer loads all packages that have a CSC registration file.

  10. Select your converted package from the Select package menu.

    The figure below shows the Custom Storage Class Designer displaying the CSCs defined in the package my_converted_package. See Designing Custom Storage Classes and Memory Sections for a description of the operation of the Custom Storage Class Designer.

  11. Restart your MATLAB session to ensure that your converted package is accessible.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS