synchronizeChanges - Synchronize changes of models in allocation set - MATLAB (original) (raw)

This example shows how to synchronize changes for models used in an allocation set.

Create two new models with a component each.

mSource = systemcomposer.createModel('Source_Model_Allocation'); systemcomposer.openModel('Source_Model_Allocation'); sourceComp = mSource.Architecture.addComponent('Source_Component'); mTarget = systemcomposer.createModel('Target_Model_Allocation'); systemcomposer.openModel('Target_Model_Allocation'); targetComp = mTarget.Architecture.addComponent('Target_Component');

Create the allocation set with name MyAllocation.

allocSet = systemcomposer.allocation.createAllocationSet('MyAllocation',... 'Source_Model_Allocation','Target_Model_Allocation');

Get the default allocation scenario.

defaultScenario = allocSet.getScenario('Scenario 1');

Allocate components between models.

allocation = defaultScenario.allocate(sourceComp,targetComp);

Update the models with new components.

sourceComp2 = mSource.Architecture.addComponent('Source_Component_2'); targetComp2 = mTarget.Architecture.addComponent('Target_Component_2');

Synchronize changes from models in allocation set.

synchronizeChanges(allocSet)

Allocate new components between models.

allocation2 = defaultScenario.allocate(sourceComp2,targetComp2);

Open the allocation editor.

systemcomposer.allocation.editor

Arrange the models so the components appear on the canvas.

Simulink.BlockDiagram.arrangeSystem('Source_Model_Allocation') Simulink.BlockDiagram.arrangeSystem('Target_Model_Allocation')

Save the models and allocation set.

save(mSource) save(mTarget) save(allocSet)