Main Content

Import and Export Architectures

In System Composer™, an architecture is fully defined by three sets of information:

  • Component information

  • Port information

  • Connection information

You can import an architecture into System Composer when this information is defined in or converted into MATLAB® tables.

In this example, the architecture information of a simple unmanned aerial vehicle (UAV) system is defined in a Microsoft® Excel® spreadsheet and is used to create a System Composer architecture model. It also links elements to the specified system level requirement. You can modify the files in this example to import architectures defined in external tools, when the data includes the required information. The example also shows how to export this architecture information from System Composer architecture model to an Excel spreadsheet.

Architecture Definition Data

You can characterize the architecture as a network of components and import by defining components, ports, connections, interfaces and requirement links in MATLAB tables. The components table must include name, unique ID, and parent component ID for each component. The spreadsheet can also include other relevant information required to construct the architecture hierarchy for referenced model, and stereotype qualifier names. The ports table must include port name, direction, component, and port ID information. Port interface information may also be required to assign ports to components. The connections table includes information to connect ports. At a minimum, this table must include the connection ID, source port ID, and destination port ID.

The systemcomposer.importModel(importModelName) function:

  • Reads stereotype names from the components table and loads the profiles

  • Creates components and attaches ports

  • Creates connections using the connection map

  • Sets interfaces on ports

  • Links elements to specified requirements (requires a Requirements Toolbox™ license)

  • Saves referenced models

  • Saves the architecture model

Instantiate adapter class to read from Excel.

modelName = "simpleUAVArchitecture";

ImportModelFromExcel function reads the Excel file and creates the MATLAB tables.

importAdapter = ImportModelFromExcel("SmallUAVModel.xls","Components", ...
    "Ports","Connections","PortInterfaces","RequirementLinks");
importAdapter.readTableFromExcel();

Import an Architecture

model = systemcomposer.importModel(modelName,importAdapter.Components, ...
    importAdapter.Ports,importAdapter.Connections,importAdapter.Interfaces, ...
    importAdapter.RequirementLinks);

Auto-arrange blocks in the generated model.

Simulink.BlockDiagram.arrangeSystem(modelName)

scExampleImportExport_01.png

Export an Architecture

You can export an architecture to MATLAB tables and then convert the tables to an external file.

exportedSet = systemcomposer.exportModel(modelName);

The output of the function is a structure that contains the component table, port table, connection table, the interface table, and the requirement links table. Save this structure to an Excel file.

SaveToExcel("ExportedUAVModel",exportedSet);

See Also

| |

Related Topics