Importing and Exporting Architecture Models

To build a System Composer™ model, you can import information about components, ports, and connections in a predefined format using MATLAB tables. You can extend these tables and add information like applied stereotypes, property values, linked referenced models, variant components, and interfaces.

Similarly, you can export information about components, hierarchy of components, ports on components, connections between components, linked referenced models, variants, stereotypes on elements, and interfaces.

Define a Basic Architecture

The minimum required structure for a System Composer model consists of these sets of information:

  • Components table

  • Ports table

  • Connections table

To import additional elements, you need to add columns to the tables and add specific values for these elements.

Components Table

The information about components is passed as values in a MATLAB table against predefined column names, where:

  • Name is component name.

  • ID is a user-defined ID used to map child components and add ports to components.

  • ParentID is parent component ID.

NameIDParentID
root0 
Component_110
Component_1_121
Component_1_231
Component_240

Ports Table

The information about ports is passed as values in a MATLAB table against predefined column names, where:

  • Name is port name.

  • Direction is an input or output port direction.

  • ID is a user-defined port ID used to map ports to port connections.

  • CompID is the ID of the component to which the port is added. It is the component passed in the components table.

NameDirectionIDCompID
Port1Output11
Port2Input24
Port1_1Output32
Port1_2Input43

Connections Table

The information about connections is passed as values in a MATLAB table against predefined column names, where:

  • Name is connection name.

  • ID is connection ID used to check that the connections are properly created during the import process.

  • SourcePortID is the ID of the source port.

  • DestPortID is the ID of the destination port.

NameIDSourcePortIDDestPortID
Conn1112
Conn2234

Import a Basic Architecture

Import the basic architecture from the tables created above.

systemcomposer.importModel('importedModel', components, ports, connections)

The basic architecture model opens.

Note

The tables do not include information about the model's visual layout. You can arrange the components manually or use Architecture > Arrange > Arrange Automatically.

Extend the Basic Architecture Import

You can import other model elements into the basic structure tables.

  • Import interfaces and map ports to interfaces

  • Add variant components and choices

  • Apply stereotypes and set property values on imported model names

Import Interfaces and Map Ports to Interfaces

To define the interfaces and add interface names in the ports table to associate ports to corresponding portInterfaces table. Create a table similar to components, ports, and connections . Information like interface name, associated element name along with data type, dimensions, units, complexity, and minimum and maximum values are passed to the importModel function in a table format shown below.

NameParentDataTypeDimensionsUnitsComplexityMinimumMaximum
interface1       
elem1interface1interface31""real"[]""[]"
interface2 11""real"[]""[]"
elem2interface111""real"[]""[]"

Note

Anonymous interfaces cannot be the data type of elements.

To map the added interface to ports, add column InterfaceName in the ports table to specify the name of interface to be linked.

NameDirectionIDCompIDInterfaceName
Port1Output11interface1
Port2Input24interface2
Port1_1Output32""
Port1_2Input43interface1

Import Variant Components

You can add variant components just like any other component in the components table, except you specify the name of the active variant. Add choices as child components to the variant components. Specify the variant choices as string values in the VariantControl column. You can enter expressions in the VariantCondition column.

Next example shows how to add a variant component VarComp with choices Choice1 and Choice2 and set Choice2 as active choice.

NameIDParentIDReferenceModelNameComponentTypeActiveChoiceVariantControlVariantConditionStereotypeName
root0       
Component1C10      
VarCompV20 VariantChoice2   
Choice1C6V2   petrol  
Choice2C7V2   diesel  
Component3C30      
Component1_1C4C1      
Component1_2C5C1      

Pass the modified components table along with the port and connections tables to the importModel function.

Apply Stereotypes and Set Property Values on Imported Model

To apply stereotypes on components, ports, and connections, add a StereotypeNames column to the components table. To set the properties for the stereotypes, add a column in the format ProfileName_StereotypeName_PropertyName.

You set the property values in the format value{units}. Units and values are populated from the default values defined in the loaded profile file.

NameIDParentIDStereotypeNamesUAVComponent_OnboardElement_MassAVComponent_OnboardElement_Power
root0    
Component_110UAVComponent.OnboardElement0.93{kg}0.65{mW}
Component_1_121   
Component_1_231UAVComponent.OnboardElement0.93{kg}""
Component_240   

Export an Architecture

To export a model, pass the model name as an argument to the exportModel function. The function returns a structure containing four tables components, ports, connections, and portInterfaces.

>> exportedSet = systemcomposer.exportModel(modelName)

You can export the set to MATLAB tables and then convert those tables to external file formats, including Microsoft® Excel®, databases, or XMI.

See Also

|