Reputation: 363
I'm trying to use an array expandable connector in the following way:
model MWE
expandable connector ControlBus
extends Modelica.Icons.SignalBus;
end ControlBus;
ControlBus controlBus[1];
Modelica.Blocks.Math.Gain gain(k=1);
equation
connect(gain.u, controlBus[1].a);
end MWE;
...however Dymola throws an error about not finding member 'a' in record extension.
Strangely, if i declare an integer parameter after the controlBus declaration (not before!) and use that to specify the size of the controlBus it works as expected with no errors:
model MWE
expandable connector ControlBus
extends Modelica.Icons.SignalBus;
end ControlBus;
ControlBus controlBus[k];
Modelica.Blocks.Math.Gain gain(k=1);
parameter Integer k=1;
equation
connect(gain.u, controlBus[1].a);
end MWE;
My main question is whether having an array expandable connector is allowed in Modelica? If so, any issues with my first approach or does Dymola have some bug (that apparently happens to be overcome by the workaround in the second approach)?
EDIT: adding another related example where the declaration order appears to make a difference with expandable connectors:
model MWE
expandable connector ControlBus
Real variable;
end ControlBus;
ControlBus controlBus;
Modelica.Blocks.Sources.RealExpression realExpression(y=controlBus.variable);
end MWE;
Here Dymola gives a warning on check but will compile. However, had I declared controlBus after realExpression it wouldn't have complained.
Upvotes: 2
Views: 140
Reputation: 12517
There is nothing making this example illegal in Modelica; a
is an undeclared member of the expandable connector component controlBus[1]
.
https://specification.modelica.org/maint/3.5/connectors-and-connections.html#expandable-connectors
It seems that Dymola needs to be improved to handle this case, and assuming nothing odd happens that will be done in the next regular release.
Upvotes: 1