Contenu principal

Compare and Merge System Composer Architecture Models

Since R2022a

This example shows how to use the System Composer Comparison Tool to compare two System Composer™ architecture models. You can view and merge the System Composer architecture model differences in the resulting comparison report.

This example demonstrates how to use the Comparison Tool to:

  • Compare and review changes in architecture model files.

  • Visualize and highlight changes in the System Composer Editor.

  • Export the comparison results to send for peer review.

  • Use merge mode to port or restore changes in different architecture models.

The models in this example represent a mobile robot hardware architecture. For more information about the model, see Compose and Analyze Systems Using Architecture Models.

Compare Architecture Models

A colleague made changes to the architecture model scMobileRobotHardwareArchitecture and saved the resulting model as scMobileRobotHardwareArchitectureEdited. To compare the architecture model files, in the Files panel, select the two files. Right-click either file and select Compare Selected Files/Folders.

Alternatively, use the visdiff function to compare the scMobileRobotHardwareArchitecture and scMobileRobotHardwareArchitectureEdited models.

visdiff('scMobileRobotHardwareArchitecture','scMobileRobotHardwareArchitectureEdited');

Review Comparison Results

The Comparison Tool shows a report that only includes the differences between the two architecture models, not the complete model hierarchies.

The report colors the modified items in purple, the inserted items in blue, and the deleted items in yellow.

A comparison report is on the left and the compared architecture models are opened on the right.

Step Through Differences

To step through the differences in the report, use the Next and Previous navigation buttons on the Comparison tab:

  • The report goes through the changes one by one. If the selected item in the Left tree has a match, the item is also selected in the Right tree.

  • MATLAB® displays both models next to the report. If possible, the report highlights the selected items in both System Composer architecture models.

To control highlighting in models, on the Comparison tab, in the Highlight section, select or clear the check box Always Highlight. You can click the Highlight Now button to highlight the currently selected report node at any time.

To learn more about specific changes, in the comparison report, you can select a row. The tool shows the details in a pane on the bottom of the report. As you click each row of the comparison report, the corresponding open architecture models on the right are highlighted.

Compare Structural Differences

The Architecture section of the System Composer comparison report includes changes to components, ports, and connectors. This section also includes changes to component types, port types, and any owned interfaces added to ports. The comparison report displays:

  • A new physical port named Temperature Control added to the Power Supply Board component and connected to the Battery Pack component

  • The Controller component that is converted to a Stateflow® chart component

  • A new port named Wheel Stud connected from the Wheels component to the Mobile Robot Case component

  • A port on the Target Machine component renamed from Commands to Command

  • A new owned interface with elements Signal and Message owned by the Command output port

A left and right comparison report for structural changes.

Compare Interface Differences

The Interfaces section of the System Composer comparison report includes changes to interfaces stored locally to the model. The comparison report displays:

  • Three new value type interfaces called RedPhase, GreenPhase, and BluePhase

  • A new Colors data interface with three data elements: R, G, and B

  • A new physical interface named ThermalMeasure with the physical element Heat

A left and right comparison report for interface changes.

Tip: When you save interface definitions and other model data in a Simulink® data dictionary, you use the Comparison Tool to compare and merge architecture data of Simulink data dictionaries.

Compare View Differences

The Architecture Views section of the System Composer comparison report includes added or deleted architecture views and shows whether the view mode has changed between Component Diagram, Component Hierarchy, or Architecture Hierarchy. The comparison report displays:

  • The new BatteryPack view and the components that are displayed within it: Power Supply Board, Battery Pack, and Charge Board

  • Changes to the existing views Life Expectancy and Mobile Robot due to renaming the Battery component to Battery Pack

A eft and right comparison report for view changes.

Export, Print, and Save Architecture Model Comparison Results

You can save architecture model comparison results as reports or workspace variables.

To save comparison results in a report, on the Comparison tab, click Publish and choose the report format: HTML, Word, PDF or PDF/A. PDF/A comparison reports are not supported on Linux®.

Merge Changes in Architecture Models

In the comparison report, you can use merge mode to port changes between architecture models using two-way merge.

To port changes in architecture models:

  1. On the Comparison tab, click Merge Mode. The Comparison Tool expands the first change and opens a Target pane at the bottom of the report. This action also creates a third file, targetFile, which can contain the changes from either the left model (scMobileRobotHardwareArchitecture) or right model (scMobileRobotHardwareArchitectureEdited).

  2. Use the buttons in the Target tree to select the differences to keep in the target file.

  3. Click Next to navigate to the next difference.

The two-way merge tool is open with the comparison report of two architecture models and the Target pane open.

When you finish merging changes, save your choices in the temporary targetFile file using the Save Result button. To cancel all operations instead, click Return to Comparison without saving the file. Inspect your changes in the System Composer Editor.

See Also

Functions

Tools

See Also

Topics