Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#4381 closed defect (fixed)

OMEdit: A for loop in equations leads to vanishing of connection annotations (wires)

Reported by: janK Owned by: adeas31
Priority: normal Milestone: 1.12.0
Component: OMEdit Version:
Keywords: for loop connection annotations Cc:

Description (last modified by janK)

We just figured out another very strange bug in OMEdit. Consider the following example:

model test
  Modelica.Electrical.Analog.Basic.Ground ground1 annotation(
    Placement(visible = true, transformation(origin = {-30, -30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Ground ground2 annotation(
    Placement(visible = true, transformation(origin = {30, -30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Resistor resistor1 annotation(
    Placement(visible = true, transformation(origin = {30, 10}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));
  Modelica.Electrical.Analog.Basic.Capacitor capacitor1 annotation(
    Placement(visible = true, transformation(origin = {-30, 10}, extent = {{-10, -10}, {10, 10}}, rotation = -90)));

  Real a,b;
equation
  for i in 1:2 loop
    a = b;
  end for;
  connect(resistor1.n, ground2.p) annotation(
    Line(points = {{30, 0}, {30, 0}, {30, -20}, {30, -20}}, color = {0, 0, 255}));
  connect(capacitor1.p, resistor1.p) annotation(
    Line(points = {{-30, 20}, {-30, 20}, {-30, 30}, {30, 30}, {30, 20}, {30, 20}}, color = {0, 0, 255}));
  connect(capacitor1.n, ground1.p) annotation(
    Line(points = {{-30, 0}, {-30, 0}, {-30, -20}, {-30, -20}}, color = {0, 0, 255}));
  
  annotation(
    uses(Modelica(version = "3.2.2")));
end test;

The connection annotation between capacitor1 and ground1 is not shown. You can put a /* ... */ comment around the for loop block and the connection will be displayed corretly.

It is always the annotation of the last connection statement, which is not evaluated. I guess, that the internal iterator which evaluates the connection annotations somehow interprets also the for statement and then one annotation is missing in the end.

I hope this analysis helps to fix this issue.

Attachments (1)

test.mo (1.3 KB) - added by janK 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by janK

comment:1 Changed 7 years ago by janK

  • Description modified (diff)

comment:2 Changed 7 years ago by adeas31

  • Milestone changed from Future to 1.12.0
  • Resolution set to fixed
  • Status changed from new to closed

Fixed in e3fdafb/OMCompiler.

comment:3 Changed 7 years ago by janK

A comprehensive fix - well done!

Note: See TracTickets for help on using tickets.