Main Content

Import and Export Architecture Models

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

Similarly, you can export information about components, hierarchy of components, ports on components, connections between components, linked model references, variants, stereotypes on elements, interfaces, requirement links, and parameters.

Tip

To learn more about how System Composer concepts apply to systems engineering design, see System Composer Concepts.

Define 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 the component name.

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

  • ParentID is the parent component ID.

For example, Component_1_1 and Component_1_2 are children of Component_1.

NameIDParentID
root0 
Component_110
Component_1_121
Component_1_231
Component_240
Name = {'root';'Component_1';'Component_1_1';'Component_1_2';'Component_2'};
ID = {'0';'1';'2';'3';'4'};
ParentID = {'';'0';'1';'1';'0'};
components = table(Name,ID,ParentID)
components =

  5×3 table

          Name            ID       ParentID 
    _________________    _____    __________

    {'root'         }    {'0'}    {0×0 char}
    {'Component_1'  }    {'1'}    {'0'     }
    {'Component_1_1'}    {'2'}    {'1'     }
    {'Component_1_2'}    {'3'}    {'1'     }
    {'Component_2'  }    {'4'}    {'0'     }

Ports Table

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

  • Name is the port name.

  • Direction can be one of Input, Output, or Physical.

  • 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
Name = {'Port1';'Port2';'Port1_1';'Port1_2'};
Direction = {'Output';'Input';'Output';'Input'};
ID = {'1';'2';'3';'4'};
CompID = {'1';'4';'2';'3'};
ports = table(Name,Direction,ID,CompID)
ports =

  4×4 table

       Name        Direction      ID      CompID
    ___________    __________    _____    ______

    {'Port1'  }    {'Output'}    {'1'}    {'1'} 
    {'Port2'  }    {'Input' }    {'2'}    {'4'} 
    {'Port1_1'}    {'Output'}    {'3'}    {'2'} 
    {'Port1_2'}    {'Input' }    {'4'}    {'3'} 

Connections Table

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

  • Name is the connection name.

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

  • Kind is the kind of connection specified by Data by default or Physical. The Kind column is optional and will default to Data if undefined.

  • SourcePortID is the ID of the source port.

  • DestPortID is the ID of the destination port.

  • PortIDs are a comma-separated list of port IDs for physical ports that support nondirectional connections.

NameKindIDSourcePortIDDestPortIDPortIDs
Conn1Data112 
Conn2Data234 
Name = {'Conn1';'Conn2'};
Kind = {'Data';'Data'};
ID = {'1'; '2'};
SourcePortID = {'1';'3'};
DestPortID = {'2';'4'};
PortIDs = {'';''};
connections = table(Name,Kind,ID,SourcePortID,DestPortID,PortIDs)
connections =

  2×6 table

      Name         Kind       ID      SourcePortID    DestPortID     PortIDs  
    _________    ________    _____    ____________    __________    __________

    {'Conn1'}    {'Data'}    {'1'}       {'1'}          {'2'}       {0×0 char}
    {'Conn2'}    {'Data'}    {'2'}       {'3'}          {'4'}       {0×0 char} 

Import Basic Architecture

Import the basic architecture from the tables created above into System Composer from the MATLAB Command Window using the importModel function.

systemcomposer.importModel("importedModel",components,ports,connections);

The basic architecture model opens.

Basic architecture model.

Tip

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

Extend Basic Architecture Import

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

Import Data Interfaces and Map Ports to Interfaces

To define the data interfaces, 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, minimum, and maximum values are passed to the importModel function in a table format shown below.

NameIDParentIDDataTypeDimensionsUnitsComplexityMinimumMaximum
interface11 DataInterface     
elem121interface2     
interface23 DataInterface     
elem241double1""real"[]""[]"
elem351valueType3cmreal0100
valueType6 int323cmreal0100
interface37 PhysicalInterface     
elec87Connection: foundation.electrical.electrical      
mech97Connection: foundation.mechanical.mechanical.rotational     

Data interfaces interface1 and interface2 are defined with data elements elem1 and elem2 under interface1. Data element elem2 is typed by interface2, inheriting its structure. For more information, see Nest Interfaces to Reuse Data.

Note

Owned interfaces cannot be nested. You cannot define an owned interface as the data type of data elements. For more information, see Define Owned Interfaces Local to Ports.

This data interface interface1 includes a data element elem3, which is typed by a value type valueType and inherits its properties. For more information, see Create Value Types as Interfaces.

This physical interface interface3 includes physical elements elec and mech, which are typed under their respective physical domains. For more information, see Specify Physical Interfaces on Ports.

To map the added data interface to ports, add the column InterfaceID in the ports table and specify the data interface to be linked. For example, interface1 is mapped to Port1 as shown below.

NameDirectionIDCompIDInterfaceID
Port1Output11interface1
Port2Input24interface2
Port1_1Output32""
Port1_2Input43interface1

Import Variant Components, Stateflow Behaviors, or Reference 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. For more information, see Create Variants.

Add a variant component VarComp using component type Variant with choices Choice1 and Choice2. Set Choice2 as the active choice.

To add a referenced Simulink® model, change the component type to Behavior and specify the reference model name simulink_model.

To add a Stateflow® chart behavior on a component, change the component type to StateflowBehavior. If System Composer does not detect a license or installation of Stateflow, a Composition component is imported instead.

NameIDParentIDReferenceModelNameComponentTypeActiveChoiceVariantControlVariantCondition
root0      
Component1C10simulink_modelBehavior   
VarCompV20 VariantChoice2  
Choice1C6V2   petrol 
Choice2C7V2   diesel 
Component3C30 StateflowBehavior   
Component1_1C4C1     
Component1_2C5C1     

Pass the modified components table along with the ports 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 with a name defined using the profile name, stereotype name, and property name. For example, name the column UAVComponent_OnboardElement_Mass for a UAVComponent profile, a OnBoardElement stereotype, and a Mass property.

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. For more information, see Define and Style Stereotypes in Profiles.

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

Assign Requirement Links on Imported Model

To assign requirement links to the model, add a requirementLinks table with these required columns:

  • Label is the name of the requirement.

  • ID is the ID of the requirement.

  • SourceID is the architectural element to which the requirement is attached.

  • DestinationType is how requirements are saved.

  • DestinationID is where the requirement is located.

  • Type is the requirement type.

For more information, see Manage Requirements.

LabelIDSourceIDDestinationTypeDestinationIDType
rset#11components:1 linktype_rmi_slreqC:\Temp\rset.slreqx#1Implement
rset#22components:0 linktype_rmi_slreqC:\Temp\rset.slreqx#2Implement
rset#33ports:1linktype_rmi_slreqC:\Temp\rset.slreqx#3Implement
rset#44ports:3linktype_rmi_slreqC:\Temp\rset.slreqx#4Implement

A Requirements Toolbox™ license is required to import requirement links into a System Composer architecture model.

Specify Elements on Architecture Port

In the connections table, you can specify different kinds of signal interface elements as source elements or destination elements. Connections can be formed from a root architecture port to a component port, from a component port to a root architecture port, or between two root architecture ports of the same architecture.

Interface design with nested interface.

The nested interface element mobile.elem is the source element for the connection between an architecture port and a component port. The nested element mobile.alt is the destination element for the connection between an architecture port and a component port. The interface element mobile and the nested element mobile.alt are source elements for the connection between two architecture ports of the same architecture.

For more information, see Specify Source Element or Destination Element for Ports.

NameIDSourcePortIDDestPortIDSourceElementDestinationElement
RootToComp1154mobile.elem 
RootToComp2251mobile.alt 
Comp1ToRoot326 interface
Comp2ToRoot436 mobile.alt
RootToRoot556mobile,mobile.alt 

Import Parameters with Parameter Value Types

In the parameters table, you can specify parameters and their values. Parameters can exist on the architectures of components and then be promoted to the root architecture of the model.

For parameters on Reference Component blocks, the parameters table shows the minimum set of columns because the complete parameter value type is defined on the referenced model. The minimum set of columns are:

  • Name is the name of the parameter.

  • ID is the ID of the parameter.

  • Parent is the parent type (Component or Architecture) with a colon and then the parent ID.

  • Value is the parameter value.

For more information, see Author Parameters in System Composer Using Parameter Editor.

NameIDParentValueUnitsTypeComplexityMinimumMaximumPromotedTo
Pressure1Component:120psidoublereal0100Component:0

Define Architecture Domain for Software Architectures

To specify that the architecture to be imported is a software architecture, specify the domain field of the import structure as "Software". For more information, see Import and Export Software Architectures.

Export Architecture

To export a model, pass the model name as an argument to the exportModel function. The function returns a structure containing tables: components, ports, connections, portInterfaces, requirementLinks, and parameters, and the field domain that is a character vector that represents the type of architecture being exported. The value of domain is 'System' for architecture models or 'Software' for software architecture models.

exportedSet = systemcomposer.exportModel(modelName)

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

exportedSet = 

  struct with fields:

          components: [3×4 table]
               ports: [3×5 table]
         connections: [1×4 table]
      portInterfaces: [3×9 table]
    requirementLinks: [4×15 table]
          parameters: [6×9 table]
              domain: 'System'

If you import requirements to the model using an external file, in order to export and reimport those requirements, redirect reference requirement links within the model.

You can use the systemcomposer.updateLinksToReferenceRequirements function in System Composer to make the requirement links point to imported referenced requirements instead of external documents.

See Also

Apps

Functions

Related Topics