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, and requirement links.
Similarly, you can export information about components, hierarchy of components, ports on components, connections between components, linked model references, variants, stereotypes on elements, interfaces, and requirement links.
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.
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.
For example, Component_1_1
and Component_1_2
are
children of Component_1
.
Name | ID | ParentID |
---|---|---|
root | 0 | |
Component_1 | 1 | 0 |
Component_1_1 | 2 | 1 |
Component_1_2 | 3 | 1 |
Component_2 | 4 | 0 |
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.
Name | Direction | ID | CompID |
---|---|---|---|
Port1 | Output | 1 | 1 |
Port2 | Input | 2 | 4 |
Port1_1 | Output | 3 | 2 |
Port1_2 | Input | 4 | 3 |
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.
Name | ID | SourcePortID | DestPortID |
---|---|---|---|
Conn1 | 1 | 1 | 2 |
Conn2 | 2 | 3 | 4 |
Import the basic architecture from the tables created above into System Composer from the MATLAB Command Window.
systemcomposer.importModel('importedModel',components,ports,connections)
The basic architecture model opens.
Tip
The tables do not include information about the model's visual layout. You can arrange the components manually or use Architecture > Arrange > Arrange Automatically.
You can import other model elements into the basic structure tables.
To define the 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, and minimum and maximum values are
passed to the importModel
function in a table format shown
below.
Name | Parent | DataType | Dimensions | Units | Complexity | Minimum | Maximum |
---|---|---|---|---|---|---|---|
interface1 | |||||||
elem1 | interface1 | interface3 | 1 | "" | real | "[]" | "[]" |
interface2 | 1 | 1 | "" | real | "[]" | "[]" | |
elem2 | interface1 | 1 | 1 | "" | 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. For example,
interface1
is mapped to Port1
as shown below.
Name | Direction | ID | CompID | InterfaceName |
---|---|---|---|---|
Port1 | Output | 1 | 1 | interface1 |
Port2 | Input | 2 | 4 | interface2 |
Port1_1 | Output | 3 | 2 | "" |
Port1_2 | Input | 4 | 3 | interface1 |
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.
Name | ID | ParentID | ReferenceModelName | ComponentType | ActiveChoice | VariantControl | VariantCondition | StereotypeName |
---|---|---|---|---|---|---|---|---|
root | 0 | |||||||
Component1 | C1 | 0 | ||||||
VarComp | V2 | 0 | Variant | Choice2 | ||||
Choice1 | C6 | V2 | petrol | |||||
Choice2 | C7 | V2 | diesel | |||||
Component3 | C3 | 0 | ||||||
Component1_1 | C4 | C1 | ||||||
Component1_2 | C5 | C1 |
Pass the modified components
table along with the port and
connections tables to the importModel
function.
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.
Name | ID | ParentID | StereotypeNames | UAVComponent_OnboardElement_Mass | AVComponent_OnboardElement_Power |
---|---|---|---|---|---|
root | 0 | ||||
Component_1 | 1 | 0 | UAVComponent.OnboardElement | 0.93{kg} | 0.65{mW} |
Component_1_1 | 2 | 1 | |||
Component_1_2 | 3 | 1 | UAVComponent.OnboardElement | 0.93{kg} | "" |
Component_2 | 4 | 0 |
To assign requirement links to the model, add a requirementLinks
table with these required columns:
Label
is the name of the requirement.
SourceID
is the architecture 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.
Label | SourceID | DestinationType | DestinationID | Type |
---|---|---|---|---|
rset#1 | components:1 | linktype_rmi_slreq | C:\Temp\rset.slreqx#1 | Implement |
rset#2 | components:0 | linktype_rmi_slreq | C:\Temp\rset.slreqx#2 | Implement |
rset#3 | ports:1 | linktype_rmi_slreq | C:\Temp\rset.slreqx#3 | Implement |
rset#4 | ports:3 | linktype_rmi_slreq | C:\Temp\rset.slreqx#4 | Implement |
In the connections
table, you can specify multiple signal interface
elements as the source element or destination element. Connections can be formed from a root
architecture to a component port, from a component port to a root architecture, or between
two root architecture ports of the same architecture.
The interface element mobile
with nested element
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.
Name | ID | SourcePortID | DestPortID | SourceElement | DestinationElement |
RootToComp1 | 1 | 5 | 4 | mobile.elem | |
RootToComp2 | 2 | 5 | 1 | mobile.alt | |
Comp1ToRoot | 3 | 2 | 6 | interface | |
Comp2ToRoot | 4 | 3 | 6 | mobile.alt | |
RootToRoot | 5 | 5 | 6 | mobile,mobile.alt |
To export a model, pass the model name and as an argument to the
exportModel
function. The function returns a structure containing four
tables components
, ports
,
connections
, portInterfaces
, and
requirementLinks
.
>> 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.