Opened 8 years ago
Closed 20 months ago
#4243 closed defect (fixed)
Cannot put complex signal on expandable (bus) connector
Reported by: | Owned by: | Adeel Asghar | |
---|---|---|---|
Priority: | low | Milestone: | Future |
Component: | Frontend | Version: | |
Keywords: | Cc: | a.haumer@… |
Description
Consider the following example
package ComplexBus extends Modelica.Icons.Package; model Example extends Modelica.Icons.Example; Bus bus annotation (Placement(transformation(extent={{-10,-10},{10,10}}), iconTransformation(extent={{-10,-10},{10,10}}))); Modelica.ComplexBlocks.Sources.ComplexConstant const(k(re=1, im=2)) annotation (Placement(transformation(extent={{-60,-10},{-40,10}}))); equation connect(const.y, bus.compl) annotation (Line(points={{-39,0},{-19.5,0},{0,0}}, color={85,170,255}), Text( string="%second", index=1, extent={{6,3},{6,3}})); annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false))); end Example; expandable connector Bus extends Modelica.Icons.SignalBus; annotation (Icon(coordinateSystem(preserveAspectRatio=false)), Diagram(coordinateSystem(preserveAspectRatio=false))); end Bus; annotation (uses(Modelica(version="3.2.2"))); end ComplexBus;
When checking ComplexBus.Example
the following error message is triggered:
[1] 22:18:33 Translation Error [ComplexBus: 10:5-13:31]: Failed to instantiate equation connect(const.y, bus.compl) annotation(Text(string = "%second", index = 1, extent = {{6, 3}, {6, 3}}));. [2] 22:18:33 Translation Error Error occurred while flattening model ComplexBus.Example
Consequently, the example model cannot be simulated.
The error occurs using:
OMEdit 1.12.0~dev-154-g354a8d1 Connected to OpenModelica 1.12.0~dev-321-g9addb54 Linux Mint 18.1 64bit
Change History (8)
comment:1 by , 8 years ago
comment:2 by , 8 years ago
The specification says that the expandable connectors can contain only scalar variables and other connectors.
Is unclear if you can connect a record or a complex type to the expandable connectors.
However, we should consider this anyway. What happens if you connect the "im" and "re" to the bus?
comment:3 by , 8 years ago
Thanks for the hint. In the MSL specification 3.3 revision 1 it reads on page 101:
Before generating connection equations non-parameter scalar variables and non-parameter array elements declared in expandable connectors are marked as only being potentially present. A non-parameter array element may be declared with array dimensions “:” indicating that the size is unknown. This applies to both variables of simple types, and variables of structured types.
Is this the paragraph you refer to?
One alternative implementation were to specify the complex quantity on the bus class definition
expandable connector Bus extends Modelica.Icons.SignalBus; Complex compl; end Bus;
This should then be in line with the Modelica specification and OpenModelica simulates the example then with no complaints.
Unfortunately we cannot simply change the structure from one complex variable to two real variables due to backwards compatibility reasons.
comment:4 by , 8 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
For now I am happy with the current status as there exists a workaround.
comment:5 by , 8 years ago
Priority: | high → low |
---|---|
Resolution: | worksforme |
Status: | closed → reopened |
Please leave it open so we don't forget about it. I'll change the priority to low.
comment:7 by , 8 years ago
Component: | OMEdit → Frontend |
---|
comment:8 by , 20 months ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Even after removing the text from the annotation the error remains:
Check of
ComplexBus.Example
leads to