4

In Modelica, it is possible to define annotations attached to an object, such as a connector, that change their graphical appearance.

Is it possible to also define how the connection from one connector to the other will look like? Such as two instances of the connector class "foo" will always have a dashed line as a connection, while two of the class "bar" will have a thicker full line.

So far, I noticed that the connections lines take the color of the outside stroke color of the connector, but that's it. And I did not find anything in the documentation related to this.

Gerome Pistre
  • 457
  • 6
  • 15

2 Answers2

4

Yes, it is possible:

If you take a look at Modelica.Blocks.Examples.BusUsage_Utilities.ControlBus you will se that extends from an icon (Modelica.Icons.SignalBus) and places a small yellow rectangle on top of the icon:

Icon with rectangle

If you modify the rectangle specification in the annotation of the connector the visible lines between the connectors will be displayed with the rectangle style, e.g.

changing connection appearance via annotation

The connected ControlBusses look like this: Connection between ControlBusses

On the information layer of Modelica.Blocks.Examples.BusUsage there are a few remarks on the subject.

Best regards, Rene Just Nielsen

Rene Just Nielsen
  • 3,023
  • 12
  • 15
2

In addition to the answer by Rene Just Nielsen, conditional assignments are also possible, as shown for the LinePattern in the following example:

parameter Boolean dashy=true;
.....
equation
  connect(pipe3.port_b,pipe4. port_a) annotation (Line(
      points={{20,0},{20,0},{20,10},{0,10},{0,16},{0,20},{0,20}},
      color={0,127,255},
      thickness=0.5,
      pattern=if dashy then LinePattern.Dash else LinePattern.Solid));

The same idea also works elsewhere, for icons, connections, connectors, and attributes like thicknes, color, visibility. That way you can set the Boolean to a different value in your two classes, or if you need more choices than just true and false, use an enumeration or even a comparison like if m_flow<0.

matth
  • 2,568
  • 2
  • 21
  • 41