Here is a minimum working example of some expandable connector usage occuring in my models:
model TestExpandableConnector
expandable connector ControlBus
extends Modelica.Icons.SignalBus;
Real signal1;
Real signal2;
end ControlBus;
ControlBus controlBus;
// example models to connect signals to
Modelica.Blocks.Math.Gain gain1;
Modelica.Blocks.Math.Gain gain2;
// and so on
equation
connect(controlBus.signal1, gain1.u);
connect(controlBus.signal2, gain2.u);
// and so on
end TestExpandableConnector;
This works fine and no concerns here.
Note that normally this model would be created in the diagram layer with graphical objects and connections between the bus and the components (gains in this case).
While the above example is trivial, in many real world examples I have many connections emerging from that one expandable connector. This quickly can become messy in the diagram layer and I'm trying to learn/develop some best practices here for cleaning up the diagrams.
One option seems to be to use the RealExpression block in a way almost equivalent to Simulink's From/Goto elements. For example:
model TestExpandableConnectorRevised
expandable connector ControlBus
extends Modelica.Icons.SignalBus;
Real signal1;
Real signal2;
end ControlBus;
ControlBus controlBus;
// example models to connect signals to
Modelica.Blocks.Math.Gain gain1;
Modelica.Blocks.Math.Gain gain2;
// and so on
// using RealEpressions like goto tags
Modelica.Blocks.Sources.RealExpression realExpression1(y=controlBus.signal1);
Modelica.Blocks.Sources.RealExpression realExpression2(y=controlBus.signal2);
// and so on
equation
connect(realExpression1.y, gain1.u);
connect(realExpression2.y, gain2.u);
// and so on
end TestExpandableConnectorRevised;
Now with this change, Dymola complains about this being illegal since causality cannot be determined. I seem to be able to resolve this last issue by either 1) adding the "input" prefix to the signal1 and signal2 declarations in the bus, or 2) positioning the declaration for the realExpressions before the contolBus declaration (this 2nd solution is a bit odd to me).
Overall, I'm reasonably happy with these solutions from a decluttering my diagram point of view, but they also feel at least a little bit "hacky". My basic goal in this question is to inquire if this approach is OK or if it's a bad idea? Additionally, if there are any other suggestions regarding how to handle the organization of all the connections in a big model (especially with expandable connectors), I'm all ears. As an additional thought, it seems to a me that a more dedicated "From/Goto" feature for the Modelica language might be really nice in Modelica, purely for the purpose of decluttering diagrams but being exactly equivalent to a connect statement under the hood.
