Create and Manage Allocations Programmatically - MATLAB & Simulink (original) (raw)

Main Content

This example shows how to create and manage System Composer™ allocations using the Allocation Editor and programmatic interfaces.

In systems engineering, an architectural system is commonly described on different levels. Functional architectures [1] describe the high-level functions of a system. Logical architectures [2] describe the logical components of a system and how data is exchanged between them. You can use allocations to establish relationships from functional components to logical components and to indicate deployment strategies.

To create allocations interactively, see Create and Manage Allocations Interactively.

Create and Manage Allocations Using Tire Pressure Monitoring System

This example uses the Tire Pressure Monitoring System (TPMS) project. To open the project, use this command.

openProject("scExampleTirePressureMonitorSystem");

Create New Allocation Set

You can create an allocation set using the Allocation Editor. In this example, TPMS_FunctionalArchitecture.slx is the source model and TPMS_LogicalArchitecture.slx is the target model.

To create an allocation set for these models, use this command.

allocSet = systemcomposer.allocation.createAllocationSet(... 'FunctionalToLogical', ...% Name of the allocation set 'TPMS_FunctionalArchitecture', ... % Source model 'TPMS_LogicalArchitecture' ... % Target model );

To see the allocation set, open the Allocation Editor by using this command.

systemcomposer.allocation.editor

Create Allocations Between Two Models

This example shows how to programmatically create allocations between two models in the TPMS project.

Get systemcomposer.arch.Component objects for the reporting functions in the functional architecture model.

functionalArch = systemcomposer.loadModel('TPMS_FunctionalArchitecture'); reportLevels = functionalArch.lookup('Path',... 'TPMS_FunctionalArchitecture/Report Tire Pressure Levels'); reportLow = functionalArch.lookup('Path',... 'TPMS_FunctionalArchitecture/Report Low Tire Pressure');

Get the systemcomposer.arch.Component object for the TPMS reporting system component in the logical architecture model.

logicalArch = systemcomposer.loadModel('TPMS_LogicalArchitecture'); reportingSystem = logicalArch.lookup('Path',... 'TPMS_LogicalArchitecture/TPMS Reporting System');

Create the allocations in the default scenario that is created.

defaultScenario = allocSet.getScenario('Scenario 1'); alloc = defaultScenario.allocate(reportLevels,reportingSystem); defaultScenario.allocate(reportLow,reportingSystem);

Optionally, you can delete the allocation between reporting low tire pressure and reporting system.

% defaultScenario.deallocate(reportLow,reportingSystem);

Use Stereotypes on Allocations

This example shows how to programmatically apply stereotypes to allocations and use stereotypes to parameterize allocations.

allocSet.applyProfile("TPMSProfile") alloc.applyStereotype("TPMSProfile.FunctionalAllocation") setProperty(alloc,"TPMSProfile.FunctionalAllocation.IsImplemented","true")

See Also

Objects

Functions

Topics