Main Content

Create and Manage Allocations Programmatically

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

  • An allocation establishes a directed relationship from architectural elements — components, ports, and connectors — in one model to architectural elements in another model.

    Resource-based allocation allows you to allocate functional architectural elements to logical architectural elements and logical architectural elements to physical architectural elements.

  • An allocation scenario contains a set of allocations between a source and a target model.

    Allocate between model elements in an allocation scenario. The default allocation scenario is called Scenario 1.

  • An allocation set consists of one or more allocation scenarios that describe various allocations between a source and a target model.

    Create an allocation set with allocation scenarios in the Allocation Editor. Allocation sets are saved as MLDATX files.

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.


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.


Create Allocations between Two Models

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

Get handles to 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 handle to 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');

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

% defaultScenario.deallocate(reportLow,reportingSystem);

See Also

| | | | |

Related Topics