Creating Packages with CSC Definitions

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

  1. Open the Simulink Data Class Designer by typing the following command 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.

  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.

    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.

  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.

  


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