Products & Services Solutions Academia Support User Community Company

Learn more about Real-Time Workshop Embedded Coder   

Creating Packages that Support CSC Definitions

You can create a package and associate your own CSC definitions with classes contained in the package. You do this by creating a data object package containing classes derived from Simulink.Parameter or Simulink.Signal. The procedure below shows how to create and configure such a package. For additional information, see Subclassing Simulink Data Classes.

  1. Open the Simulink Data Class Designer by choosing Tools > Data Class Designer in the model window, or typing the following at the MATLAB command prompt:

    sldataclassdesigner
  2. The Data Class Designer loads all packages that exist on the MATLAB path.

  3. To create a new package, click New next to the Package name field. If desired, edit the Package name. Then, click OK.

  4. In the Parent directory field, enter the path to the directory where you want to store the new package.

      Note   Do not create class package directories under matlabroot. Packages in these directories are treated as built-in and will not be visible in the Data Class Designer.

  5. Click on the Classes tab.

  6. Create a new class by clicking New next to the Class name field. If desired, edit the Class name. Then, click OK.

  7. In the Derived from menus, select Simulink.Signal or Simulink.Parameter.

  8. The Create your own custom storage classes for this class option is now enabled. This option is enabled when the selected class is derived from Simulink.Signal or Simulink.Parameter. You must select this option to create CSCs for the new class. If the Create your own custom storage classes for this class option is not selected, the new class inherits the CSCs of the parent class.

      Note   To create a CSC registration file for a package, the Create your own custom storage classes for this class option must be selected for at least one of the classes in the package.

    In the figure below, a new package called mypkg has been created. This package contains a new class, derived from Simulink.Signal, called sig. The Create your own custom storage classes for this class option is selected.

    Complete instructions for using the Data Class Designer appear in Subclassing Simulink Data Classes in the Simulink documentation. See also the instructions that appear when you click the Custom Storage Classes tab.

  9. If desired, repeat steps 6–8 to add other derived classes to the package and associate CSCs with them.

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

    The package directories and files, including the CSC registration file, are written out to the parent directory.

  11. Click Close.

  12. You can now view and edit the CSCs belonging to your package in the Custom Storage Class Designer, which you open with the MATLAB command cscdesigner. Initially, the package contains only the Default CSC definition, as shown in the figure below.

  13. Add and edit your CSC and memory section definitions, as described in Designing Custom Storage Classes and Memory Sections. After you have created CSC definitions for your package, you can instantiate objects of the classes belonging to your package, and assign CSCs to them.

    You need to restart your MATLAB session before you can use the new CSCs with objects of your new classes.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

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