Comparing Libraries or Other Classes, and Merging Different Versions of a Library

You can compare Modelica libraries with the same name but with different versions, as well as other classes with the same name but with different versions. For Modelica libraries, you can also:

  • Compare the resources of the two versions.
  • Merge two versions of a library into a third version.

Important: This command does not support comparing libraries or other classes with different names. For doing this, use the command Compare and Merge Classes. For more information, see Comparing and Merging Classes.

  1. From the Behavior Tools section of the action bar, click Open Comparison Tool .
    The Library Comparison Tool appears.
  2. In the Library Comparison Tool, load the first class or library to be compared in any of the following ways:
    • To load a class or library in session, drag it from the Package Browser into the comparison tool.
    • To load a library from the database, do the following:
      1. From the dialog box, click Load Library to Compare from the Data Base .

        The Content Chooser dialog box appears.

        For more about the Content Chooser, see Selecting Objects Using the Content Chooser.

      2. From the top bar, search for the Modelica library.

        For information on how to search for a Modelica library, see the search part of Open with Search.

        The Search Results panel appears.

      3. From the panel, select the library.
    The first source class is loaded in the tool. The following is displayed in the dialog:
    • In the first column:
      • A collapsed class tree of the loaded class.
      • If the class is a library and has resources, also a collapsed tree of the resources.
    • In the second column, the name of the class.
  3. Select the second version of the class any of the following ways:
    • To select a class in the session, perform, for the second source class, the corresponding action as in Step 2.
    • To select a class from the database, perform, for the second source class, the corresponding action as in Step 2.
    • To select, as the second source class, another version of a class already selected as the first source class, do the following:
      1. In the dialog, click Load Another Version of This Library from the Database .

        The Revision Selector dialog box appears. This dialog box displays all revisions of the selected library in the database.

        Notes:
        • The library of the revision you already selected in the previous step is displayed with gray text and cannot be selected.
        • For the library, currently only the revisions are displayed. To see both revisions and the corresponding Modelica versions, perform, from the top bar, a search for the library. As an example, to search for a library MyLib, enter dbl:*MyLib* and then click Search.
        • For more information about the Revision Selector, see Collaborative Lifecycle User's Guide: Creating Revisions and Branches: Revision Explorer.

      2. Select the library to compare.
      3. Click OK to validate.
    The second source class is loaded in the Library Comparison Tool. The following is changed and added in the dialog:
    • In the first column:
      • The class tree is changed to be the union of the two classes compared, to display the difference between the classes.
      • If present, the second tree, the resources tree, is changed to be the union of the resources, to display the differences between the resources of the libraries.
    • A third column is added, with the name of the second class.
    • The second and the third column display the differences found between the classes.
  4. Use the tool to investigate any differences between the compared classes.

    The following color indications are possible:

    Color Meaning
    White The node is present in both classes and have exactly the same content.
    Yellow There is at least one difference in the children of the node. You can expand the node to investigate.
    Blue
    • For the class tree: The Modelica text inside this class differs. See the below steps for possible action.
    • For the resource tree: The resource differs, last modification time and resource size is presented in the cells.
    Green The node exists in this class, but not in the compared class.
    Red The node does not exist in this class, but exists in the compared class.
    Tips:
    • You can hide nodes with no differences by clicking Show/Hide Nodes with No Differences
    • You can search the tree by entering text in the search field in the upper part of the dialog box.

  5. To compare Modelica text for a class, select, in the dialog box, in the tree, the node of the class to compare, and click Compare Modelica Text.

    The node must be blue with the text Modelica text is different.

    A Compare Class Panel appears, comparing the Modelica text of two instances of the class. Differences are indicated the following way:
    • Any line that differs, is indicated by a blue line in the beginning of the text.
    • Any difference in the text is underlined and colored red.
    Tip: To make it easier to compare the text, you can hide the annotations by activating Hide Annotation. Note that if there are differences in the annotations, this command hides these differences as well.

    The following table illustrates the comparison between Text 1 (the leftmost column) and Text 2 (the rightmost column). The middle columns illustrate the displayed result in the Compare Class Panel.

    Text 1 in class Text 1 in tool Text 2 in tool Text 2 in class
    A A A A
    B1 B1 B B
    C1 C1 C C
    D D D D
    G E E
    H F F
    J G G G
    K H H1 H1
    I1 I1
    J1 J1
    K K K
  6. Optional: To merge two versions of the same library using an external tool, do the following:

    Important: You can merge libraries of different versions without using an external tool, and also handle resources, see next step.

    Only libraries colored blue with the text Modelica text is different can be merged.

    Note: Merging is actually performed by using the functionality of the command Merge Modelica Classes, which is integrated in the comparison tool.

    1. Make sure that you have installed and selected any supported external tool for merging corresponding to the command Merge Modelica Classes. For details, see Comparing and Merging Classes.
    2. Make sure that you have created a target class for the result of the merge.

      Notes:

    3. In the dialog, select the class to be merged.
    4. In the dialog, click Compare And Merge Modelica Classes Using an External Comparison Tool .
      The Compare and Merge Modelica Classes dialog box appears, prefilled with the two classes to merge.
    5. In the Compare and Merge Modelica Classes dialog box, do the following:

      1. Click the Target class input field to select it.
      2. From the Package Browser, click the class where the merged class is to be stored.
      3. Click OK to perform the merge.
        Important:
        • Dymola Behavior Modeling cannot be used while the external tool is running.
        • If you create a merged file, you must save the result in the external tool before closing it.

  7. Optional: To merge two libraries of different versions without using an external tool, do the following:

    Notes:
    • You can only merge libraries, not classes.
    • If a library in session is used for the merge, changes you have not saved before activating the merge are included, for the classes selected for the merge.
    • When working with merging, you cannot perform any other action.

    1. Click Activate Merge.
      The following is the result:
      • A third column appears in the middle of the pane, representing the library that is the result of the merge.
      • By default, the middle column is a copy of the library version in the left column.
      • For any nodes that differs between the two versions to merge, two radio buttons appear in the middle column, one to the left and one to the right.
    2. For the middle column, configure the merge. For the lines that have radio buttons, you can:

      • For a line with the text Expand to see differences, expand the node to see the differences for that node.
      • For any line, click the radio button to the right to specify that the content in the column to the right is the content in the merged library.
      • For any line, click the radio button to the left to specify that the content in the column to the left is the content in the merged library.
        Note: By default, the middle column is a copy of the column to the left.

      The following is the result:
      • The radio buttons in the middle column display the selected merges in the following way:
        • Activated, with blue circle: The class is selected for the merge, with all its children, if any.
        • Activated, with orange circle: The class is selected for the merge, but with some child classes selected from the other merge source or not selected for the merge.
        • Cleared, white: The class is not selected for the merge.
      • The colors of the nodes and classes in the middle column change dynamically depending on your selections.
      Note: The expanded items in the panel is the lowest level of merging. You cannot, for example, merge Modelica text in classes.
    3. When finished editing, click Save Library and Load It in Session.
      The Save Merge Action dialog box appears.
    4. Specify the revision of the library that is the result of the merge, in any of the following ways:

      • To overwrite the revision of the library currently is session, select Overwrite Library in Session <library name and revision>.
        Note: This alternative is only available if one of the library versions you are using for the merge is dragged from the Package Browser.
      • To create a new revision, select Create New Library Revision, and then do the following:
        1. To specify the Modelica version, select the Modelica version from the list, or enter the Modelica version.
          Note: The new library is a new revision of the version you selected.
        2. Select on which revision your library is to be created.

    5. Click OK.
      The result is depending on the selection in the previous step:
      • If you selected to overwrite the library in session, that library revision is overwritten both in session and in the database by the merge.
      • If you selected to create a new revision, two results are possible:
        • If you have used a library in the session for the merge, that revision is unloaded from the session and replaced by the created revision from the merge. This revision is also saved as a new revision in the database.
          Note: If you have made unsaved changes of this library before doing the merge, you have an opportunity to save your unsaved changes before overwriting that library.
        • If both library revisions used for the merge are fetched from the database, the result of the merge is saved as a new revision in the database. This revision is opened in session.