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) was primarily 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.

However, one may also have array-array connections. In general, the normative text says

a tool may set the parameter value in a modifier automatically, if used as dimension size of a vector of connectors

So, in the case 2. described above, I would say that the wanted behaviour is that one first drags the And component (which has default nu = 0), then, when graphically connecting the input and1.u to the output of booleanExpression1.y, one should first be asked if the two entire arrays should be connected, or rather some of their individual components.

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.

In the second case, one should select which individual array element to pick on the non-connectorSize'd connector, while the standard connectorSizing mechanism should be used on and1.u.

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. This may be a problem, because there is not enough information available to infer the size of the parameter with connectorSizing = true (and.nu, in this case).

In this case, I would also suggest to ask first if one wants to connect a scalar element or the entire array connector and1.u to a connector on the expandable connector. In the first case, the standard connectorSizing mechanism is applied. In the other case, the pop-up window should probably also ask for the value of the connectorSizing=true parameter (nu), because the size of the other connector is not available locally when using an expandable connector.

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

Last edited 5 years ago by Francesco Casella (previous) (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.