WOLFRAM SYSTEMMODELER TUTORIAL

Model CenterComponent Browser

Introduction | Class Browser | Class Window | Graphical Views | Modelica Text View | Component Browser | Variable Views | Reliability View | Messages View | Kernel Command View | Documentation Center | Functional Mock-up Interface | Keyboard Shortcuts | Kernel Commands

The component browser on the right-hand side of the model editor lists all components of the currently open class in a tree view. The components are grouped with respect to the class in which they are declared. Base classes in the component browser are recognized by the "extends" prefix before their name.

Components and classes with no declared components appear as leaves in the tree view, while components and classes containing components are represented as branches. To expand a component or class, click the symbol to the left of its icon (or name if no icon is available). Clicking the symbol of an expanded component or class will collapse it again.

The tree view has two columns where the first column shows the icon (if available) and the name of the class or component, while the second column shows the component type for components and the full hierarchical name for classes. The second column showing type information is not visible by default. See the section Toggling Column Visibility on how to toggle the visibility of the columns.

1.gif

The components of the Modelica.Mechanics.Rotational.Examples.CoupledClutches model.

Toggling Column Visibility

The columns of the component browser can be toggled on and off by right-clicking the column header. This will bring up a popup menu from which you can choose the name of the column to show or hide. By default, only the Name column is shown.

2.gif

Toggling the visibility of component browser columns.

Sorting Components

The items in the component browser can be sorted by name or type. By default the components are sorted by name in ascending order, which is indicated by the arrow pointing upward in the right corner of the Name column title.

To sort the items by type in ascending order, click once on the Type column title (if the Type column is not visible, see this section on how to toggle the visibility of the columns). Click the Type column title a second time to sort the components by type in descending order.

Note how the pointing direction of the arrow switches when toggling between the ascending and descending sorting orders.

3.gif

Sorting the components in the component browser by their type.

Editing Classes

The base classes and the classes of the components listed in the component browser can be edited by right-clicking on a class or component and choosing Open Class from the popup menu. The class will be opened in a new class window unless already open.

Removing Components

The component browser can also be used to remove components from a class. First, make sure that the active view of the class window is either the Icon View or the Diagram View. Select the component(s) to remove, and choose Edit Delete or right-click the component's name and choose Delete from the popup menu. Note that it is not possible to delete individual inherited components, nor is it possible to delete components while editing a class in the Modelica Text View.

To remove all components inherited from a specific extended class you can remove the inheritance relationship by selecting the extended class in the component browser and deleting it. For more information, see the section on removing inheritance relationships.

Removing Inheritance Relationships

The component browser groups components with regard to their declaration class, making it easy to see from what class components are inherited. By selecting an extended class in the component browser and choosing Edit Delete, the inheritance relationship can be removed. The class will be removed from the list of extended classes, causing all components inherited from that class to be removed.

The list of extended classes can also be edited from the Class Properties dialog box, where you may also add classes; see the section on editing class properties.

Note that it is not possible to remove an inheritance relationship using the component browser while editing a class in the Modelica Text View.

Renaming Components

A component (or extended class) can be renamed from the component browser by right-clicking it, choosing Rename from the popup menu, and editing the name in the properties dialog box. It is also possible to rename a component by selecting it and pressing the F2 key.

When renaming a class or component using the properties dialog box, all references to the renamed class or component, for instance in connection equations, will be updated automatically in all currently loaded classes. When the renaming operation is completed, a list of all classes that were modified due to references to the renamed class or component is shown.

Note that it is not possible to rename a component or class using the component browser while editing a class in the Modelica Text View, nor is it possible to rename an inherited component.

Changing the Type of Components

The type of a component can be changed if the component is declared in the class of the active class window, or if the component is declared as replaceable. Although the result is the same, there is a slight difference.

In the former case, the type specifier of the declaration is simply substituted in the class in which the component is declared, while in the latter case, the type of the component is changed by introducing a redeclare modification in the class of the active class window. This makes it possible to replace a component somewhere in the component hierarchy without actually changing the definition of the class in which it is declared.

For instance, if we have a system board model with an integrated circuit (IC) component whose internal transistor components are replaceable, we can change the type of a transistor component without affecting other models using the IC component. The reason for this is that the redeclare modification that actually changes the type of the transistor component is introduced in the system board model.

By default components are not replaceable. For information on how to make a component replaceable, see how to edit component properties.

To change the type of a component, right-click the component in the component browser and choose Redeclare... from the popup menu.

4.gif

Selecting a component to change its type.

In the dialog box that is shown, enter the new type of the component and click OK. It is also possible to drag a class from the Class Browser and drop it in the text box.

5.gif

Changing the type of a component.

Note that the Modelica language restricts the possibilities when changing the type of a component using a redeclare modification. One of the more basic requirements is that the new type must have an interface compatible with the interface of the original declaration.

Providing a Set of Candidate Components for Redeclarations

If you develop a model with replaceable components you may want to provide a set of candidate components for the user to choose from when a component is redeclared. This can be done using the choices annotation, which is a standard Modelica annotation.

If, for instance, we have an electrical model of a main board with a CPU, we can make the CPU replaceable and introduce a choices annotation with configurations of pin-compatible processors, making it possible for a user of the main board to easily test the main board with different processors. The choices annotation will be an annotation for the CPU component in the main board model.

In the example above, we provide three candidates for the redeclaration. A MC68000 CPU at 8MHz, a MC68000 CPU at 16MHz, and a MC68010 CPU at 16MHz. When the user adds the main board as a component in his computer model, changing the CPU becomes a matter of right-clicking the CPU, choosing Redeclare from the menu, and then selecting the new processor from a list of candidates. As can be seen in the screen shot below, the strings in the choices annotation represent the candidates when redeclaring the CPU component.

6.gif

Redeclaring a component with a choices annotation.

Editing the Properties of Components

The properties of a component (or base class) can be edited by right-clicking the name of the item and choosing Properties from the popup menu, or by selecting the item and choosing Properties from the Edit menu.

For more information on the Component Properties dialog box, see this section. For more information on the Class Properties dialog box, see how to edit properties of classes. Note that it is not possible to edit the properties of a component or class while editing a class in the Modelica Text View.

Adding Graphical Representations for Components

When adding a component to a class in the Modelica Text View you may notice that the component does not appear in the Diagram View unless you specify a graphical annotation for it. The graphical annotation describes the placement of the component in the Diagram View, and for connector components, also their placement in the Icon View.

The model editor can generate a graphical annotation for a component if you drag the component from the component browser and drop it in the Diagram View. If the component is a connector component, it will also appear in the Icon View.

Graphical annotations for several components can be generated at once by dragging a selection of components from the component browser and dropping them in the Diagram View. The components will then be laid out in a grid.

Graphical annotations for existing connections will also be generated, if missing, when graphical annotations for connected components are generated.

Introduction | Class Browser | Class Window | Graphical Views | Modelica Text View | Component Browser | Variable Views | Reliability View | Messages View | Kernel Command View | Documentation Center | Functional Mock-up Interface | Keyboard Shortcuts | Kernel Commands