Main Content

Simulink.dictionary.archdata.AliasType

Edit Simulink alias types in Simulink data dictionary

Since R2023b

    Description

    Use a Simulink.dictionary.archdata.AliasType object to represent a Simulink.AliasType in the Architectural Data section of a data dictionary.

    Creation

    You can add a Simulink.dictionary.archdata.AliasType object to a data dictionary in two ways.

    • Interactively create a Simulink.dictionary.archdata.AliasType object by using the Architectural Data Editor.

    • Programmatically create a Simulink.dictionary.archdata.AliasType object by using the addAliasType function.

    archDataObj = Simulink.dictionary.archdata.create("dataDictionary.sldd");
    Temp = addAliasType(archDataObj,"Temp","BaseType","single")
    aliasTypeObj = 
    
      AliasType with properties:
    
               Name: 'myAlias'
           BaseType: 'double'
        Description: ''
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Properties

    expand all

    Name of the base data type that this alias renames, specified as a character vector or string scalar. You can specify the name of a standard data type, such as 'int8' or 'half', or the name of a custom data type, such as the name of another Simulink.AliasType object or the name of an enumeration.

    Example: 'int8'

    Example: 'myAlias'

    Data Types: char | string

    Specification to generate or import the type definition (typedef) in the generated code (Simulink® Coder™), specified as 'Auto', 'Exported', or 'Imported'.

    This table shows the effect of each option.

    ValueAction
    'Auto' (default)

    If no value is specified for HeaderFile, export the type definition to model_types.h. model is the model name.

    If a value is specified for HeaderFile, import the data type definition from the specified header file.

    'Exported'Export the data type definition to a header file, which can be specified in the HeaderFile property. If no value is specified for the HeaderFile, the header file name defaults to type.h. type is the data type name.
    'Imported'Import the data type definition from a header file, which can be specified in the HeaderFile property. If no value is specified for HeaderFile, the header file name defaults to type.h. type is the data type name.

    Set the data scope to Imported or Exported to avoid potential MISRA C™:2012 violations.

    For more information, see Control File Placement of Custom Data Types (Embedded Coder).

    Custom description of the data type alias, specified as a character vector.

    Example: 'This type alias corresponds to a uint8 data type.'

    Data Types: char

    Name of the header file that contains the type definition (typedef) in the generated code, specified as a character vector. If this property is specified, the specified name is used during code generation for importing or exporting. If this property is empty, the value defaults to type.h if DataScope is set to "Imported" or "Exported", or defaults to model_types.h if DataScope is set to "Auto".

    By default, the generated #include directive uses the preprocessor delimiter " instead of < and >. To generate the directive #include <myTypes.h>, specify HeaderFile as '<myTypes.h>'.

    For more information, see Control File Placement of Custom Data Types (Embedded Coder).

    Example: '<myHdr.h>'

    Example: 'myHdr'

    Example: 'myHdr.hpp'

    Data Types: char | string

    Name of the alias type object, specified as a character vector or string scalar.

    Example: addAliasType(archDataObj,"myAliasType")

    Data Types: char | string

    Architectural Data section containing the alias type, specified as a Simulink.dictionary.ArchitecturalData object.

    Example: Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Object Functions

    moveToDesignDataMove interfaces, data types, and constants in Architectural Data section of Simulink data dictionary to design data
    moveToDictionaryMove architectural data of Simulink data dictionary to another data dictionary
    showView architectural data of Simulink data dictionary in Architectural Data Editor
    destroyDelete data element and remove from data interface

    Examples

    collapse all

    To add a Simulink.AliasType to the data dictionary, use the addAliasType function. For more examples of architectural data management workflows and related functions, see Store Data in Architectural Data Section Programmatically.

    Create or open a data dictionary. This example uses a previously created data dictionary MyInterfaces.sldd.

    dictName = "myDictionary.sldd";
    archDataObj = Simulink.dictionary.archdata.open(dictName);
    

    Add alias types using the addAliasType function. Specify the name and base type by using either input arguments of the function.

    myAliasType = addAliasType(archDataObj,"aliasType",BaseType="single")
    myAliasType = 
    
      AliasType with properties:
    
               Name: 'aliasType'
           BaseType: 'single'
        Description: ''
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    You can use Simulink.AliasType objects defined in the base workspace to define Simulink.dictionary.archdata.AliasType objects.

    Create a Simulink.AliasType object referencing a fixed-point data type.

    myFixPtAlias = Simulink.AliasType;
    myFixPtAlias.BaseType = "fixdt(1,16,0)";
    myFixPtAlias.Description = 'A fixed point alias type to be stored in architectural data.'
    
    myFixPtAlias = 
    
      AliasType with properties:
    
        Description: 'A fixed point alias type to be stored in architectural data.'
          DataScope: 'Auto'
         HeaderFile: ''
           BaseType: 'fixdt(1,16,0)'

    Add the Simulink.AliasType object to the Architectural Data section of a data dictionary by using the addAliasType function.

    myArchDataAlias = addAliasType(archDataObj,"myNewAlias",...
        BaseType = "myFixPtAlias")
    myArchDataAlias = 
    
      AliasType with properties:
    
               Name: 'myNewAlias'
           BaseType: 'myFixPtAlias'
        Description: ''
              Owner: [1×1 Simulink.dictionary.ArchitecturalData]

    Version History

    Introduced in R2023b