In System Composer, an architecture is fully defined by four sets of information:
In this example, architecture information of a small UAV system is defined in an Excel spreadsheet and is used to create a System Composer architecture model.
External Source Files
# Element : Name of the element. Either can be component or port name.
# Parent : Name of the parent element.
# Class : Can be either component or port(Input/Output direction of the port).
# Domain : Mapped as component property. Property "Manufacturer" defined in the
profile UAVComponent under Stereotype PartDescriptor maps to Domain values
in excel source file.
# Kind : Mapped as component property. Property "ModelName" defined in the
profile UAVComponent under Stereotype PartDescriptor maps to Kind values
in excel source file.
# InterfaceName : If class is of port type. InterfaceName maps to name of the interface
linked to port.
# ConnectedTo : In case of port type, it specifies the connection to
other port defined in format "ComponentName::PortName".
# Name : Name of the interface or element.
# Parent : Name of the parent interface Name(Applicable only for elements) .
# Datatype : Datatype of element. Can be another interface in format
Bus: InterfaceName
# Dimensions : Dimensions of the element.
# Units : Unit property of the element.
# Minimum : Minimum value of the element.
# Maximum : Maximum value of the element.
Step 1. Instantiate the ModelBuilder
Class
You can instantiate the ModelBuilder
class with a profile name.
Specify the name of the model to build.
Specify the name of the profile.
Specify the name of the source file to read architecture information.
Instantiate the ModelBuilder
.
Step 2. Build Interface Data Definitions
Reading the information in the external source file DataDefinitions.xlsx
to build the interface data model.
Create MATLAB® tables from the Excel source file.
Force readtable
to start reading from the second row.
The systemcomposer.io.IdService
class generates unique ID
for a given key.
In the case of interfaces, add the interface name to the model builder.
Get the unique interface ID
.
getID(container,key)
generates or returns (if key is already present) same value for input key within the container.
Use builder.addInterface
to add the interface to the data dictionary.
In the case of an element, read the element properties and add the element to the parent interface.
The ElementID
is unique within a interface. Append E
at the start of an ID
for uniformity. The generated ID
for an input element is unique within parent interface name as a container.
Set the data type, dimensions, units, minimum, and maximum properties of the element.
Make sure that input to builder utility function is always a string.
Use builder.addElementInInterface
to add an element with properties in the interface.
Step 3. Build Architecture Specifications
Architecture specifications are created by MATLAB tables from the Excel source file.
Iterate over each row in the table.
Read each row of the Excel file and columns.
Populate the contents of the table.
The Root ID
is by default set as zero.
Use builder.addComponent
to add a component.
Read the property values.
Use builder.setComponentProperty
to set stereotype and property values.
In this example, concatenation of the port name and parent component name is used as key to generate unique IDs for ports.
For ports on root architecture, the compID
is assumed as 0
.
Use builder.addPort
to add a port.
The InterfaceName
specifies the name of the interface linked to the port.
Get the interface ID.
getID
will return the same IDs already generated while adding interface in Step 2.
Use builder.addInterfaceToPort
to map interface to port.
Read the ConnectedTo
information to build connections between components.
ConnectedTo
is in the format:
(DestinationComponentName::DestinationPortName)
For this example, consider the current port as source of the connection.
Get the port ID of the connected port.
In this example, port ID is generated by concatenating the port name and the parent component name. If the port ID is already generated, the getID
function returns the same ID for the input key.
Populate the connection table.
Use builder.addConnection
to add connections.
Step 3. Import Model from Populated Tables with builder.build
Function
Clean up artifacts.
Copyright 2020 The bat365, Inc.