Opened 5 years ago

Closed 5 years ago

#5628 closed defect (fixed)

OMEdit doesn't allow to choose the array element when a connection is made from graphical view

Reported by: Andrea.bartolini Owned by: Adeel Asghar
Priority: blocker Milestone: 1.14.0
Component: OMEdit Version: v1.14.0-dev-nightly
Keywords: Cc: Francesco Casella

Description

in the current nightly OMEdit doesn't allow to choose the array element when a connection to an array connector is made from graphical view.
The automatic selection of the array element is made instead (in ascending order).

This may lead to misbehavior of model in some cases, and some bugs are present in this new feature.

1)[misbehavior] there are models in which different order of the connection of scalar outputs to an input array changes the behavior of the model itself. In this case the impossibility to choose the element order of the connections to the array may lead the model to work not properly.

2)[bug] if you try to connect an array output to an array input this is what you obtain:

Before connection:

model test
  Modelica.Blocks.MathBoolean.And and1(nu = 3)  annotation(...);
  Modelica.Blocks.Sources.BooleanExpression booleanExpression1[3] annotation(...);
equation
end test;

After connection:

model test
  Modelica.Blocks.MathBoolean.And and1(nu = 1)  annotation(...);
  Modelica.Blocks.Sources.BooleanExpression booleanExpression1[2] annotation(...);
equation
  connect(booleanExpression1.y, and1.u[1]) annotation(...);
end test;

OMEdid has arbitrarily changed the dimension of and1 and the result is wrong

3)[bug] same behavior is obtained when you try to connect an expandable connector to an array input:

expandable connector:

expandable connector Bus annotation(...);
end Bus;


before connection:

model M
  Modelica.Blocks.MathBoolean.And and1(nu=3) annotation(...);
  test.Bus bus1 annotation(...);
equation
end M;

after connection:

model M
  Modelica.Blocks.MathBoolean.And and1(nu= 1) annotation(...);
  test.Bus bus1 annotation(...);
equation
  connect(bus1, and1.u[1]) annotation(...);
end M;

In this case two errors are obtained, the first is the same of the previous case, the second is that not any element of the expandable connector may be selected.

In my opinion the possibility to select the array and the expandable connector element should be restored (as was been in the past), and the user should be choose what kind of graphical connection method it wants to use, for example via a new flag in the OMEdit setting.

OMEdit - OpenModelica Connection Editor
Connected to OpenModelica 1.14.0~dev-26688-gbe00c7f
sysop Ubuntu 18.04

Change History (5)

comment:1 by Adeel Asghar, 5 years ago

Priority: blockerhigh

This is because of the connectorSizing annotation set on nu. I won't consider them bugs instead these are the new features :).

comment:2 by Francesco Casella, 5 years ago

Priority: highblocker

The connectorSizing annotation (see Section 18.7 of the Specification) is meant to automatize the following scenario:

  • a component m has a array of connectors c[N]
  • the size of the array N is an Integer parameter with the connectorSizing = true annotation
  • when you graphically connect m.c to a scalar connector, the parameter is N is automatically increased by one, and a connection to the corresponding scalar element is generated

When connecting m.c to another connector array m2.c, this mechanism should obviously not be used, and a simple connect(m.c, m2.c) statement should be generated (case 2), unless also the size of m2.c is a parameter with the connectorSizing = true annotation, see Rule 1 in 18.7.

When connecting m.c to an expandable connector, OMEdit doesn't know the type of the other connector, because the other connector is implicitly defined by the connect statement. In this case, I would suggest that a pop-up window shows up, asking whether one wants to connect to a scalar connector on the expandable connector (in which case the connectorSizing mechanism should be used), or to an array connector on the expandable connector, in which case a connect statement between two array connectors should be generated.

It would be nice to get this for 1.14.0, so that the newly introduced feature is correct.

Version 1, edited 5 years ago by Francesco Casella (previous) (next) (diff)

comment:3 by Francesco Casella, 5 years ago

See suggestion in ticket:5629#comment:2 for a temporary fix.

comment:4 by Adeel Asghar, 5 years ago

I pushed in a fix for connectorSizing in 422e08e/OpenModelica. Please test this as I guess there are still some cases which are not handled properly.

In the first case, nu should automatically be set to 3, which is the size of the other connector, and a connect(booleanExpression1.y, and1.u) statement should be added.

We can't do that since and1.u can be connected to some other connector as well. So making a connection connect(booleanExpression1.y, and1.u) is not good. Instead I make a connection connect(booleanExpression1.y, and1.u[1:3]) or connect(booleanExpression1.y, and1.u[2:4]) the size of the range depends on the size of the other connector.

comment:5 by Andrea Bartolini, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.