Opened 13 years ago
Closed 9 years ago
#1367 closed defect (fixed)
Constants that are arrays in packages should be copied in the flattened model
Reported by: | adrpo | Owned by: | adrpo |
---|---|---|---|
Priority: | critical | Milestone: | 1.9.3 |
Component: | Instantiation | Version: | trunk |
Keywords: | Cc: | adrpo |
Description
See for example flattening of: Modelica.Electrical.Digital.Examples.Multiplexer.
It contains equations:
MUX.Not1.auxiliary = D.Tables.NotTable[MUX.Not1.x];
but D.Tables.NotTable is nowhere to be found in the flattened model
as is a package constant that is an array which is indexed by a variable\\
We should copy the array constant from the package in the local model and
replace all references to it to the local constant which should become part
of the DAE\\
See for example /trunk/libraries/msl31/simulate/Modelica.Electrical.Digital.Examples.mos
Change History (5)
comment:1 Changed 13 years ago by adrpo
comment:2 Changed 13 years ago by adrpo
An easier example:
package P type E = enumeration('A', 'B', 'C', 'D'); constant E x[4] = {E.'D', E.'C', E.'B', E.'A'}; constant Real y[4] = {1, 2, 3, 4}; end P; model ArrayEnums Real a = P.x[integer(time)]; Real b = P.y[integer(time)]; end ArrayEnums;
which wrongly generates:
adrpo@kafka ~/dev/OpenModelicaBackend/build/bin/enums $ ../omc ArrayEnums.mo class ArrayEnums Real a = Real(P.x[integer(time)]); Real b = P.y[integer(time)]; end ArrayEnums;
comment:3 Changed 13 years ago by adrpo
Another example:
package P type E = enumeration('A', 'B', 'C', 'D'); constant E x[4] = {E.'D', E.'C', E.'B', E.'A'}; constant Real y[4] = {1, 2, 3, 4}; end P; function getArrayFromPackage output P.E x[4]; algorithm x := P.x; end getArrayFromPackage; model ArrayEnums P.E a = P.x[integer(time)]; Real b = P.y[integer(time)]; P.E[4] c = getArrayFromPackage(); end ArrayEnums;
which gives:
adrpo@kafka ~/dev/OpenModelicaBackend/build/bin/enums $ ../omc ArrayEnums.mo function getArrayFromPackage output enumeration('A', 'B', 'C', 'D')[4] x; algorithm x := {P.E.'D',P.E.'C',P.E.'B',P.E.'A'}; end getArrayFromPackage; class ArrayEnums enumeration('A', 'B', 'C', 'D') a = P.x[integer(time)]; Real b = P.y[integer(time)]; enumeration('A', 'B', 'C', 'D') c[1] = P.E.'D'; enumeration('A', 'B', 'C', 'D') c[2] = P.E.'C'; enumeration('A', 'B', 'C', 'D') c[3] = P.E.'B'; enumeration('A', 'B', 'C', 'D') c[4] = P.E.'A'; end ArrayEnums;
comment:4 Changed 9 years ago by hkiel
- Cc changed from adrpo, adrpo to adrpo
- Milestone changed from White December to 1.9.3
comment:5 Changed 9 years ago by adrpo
- Resolution set to fixed
- Status changed from new to closed
Duplicate of #2858.
Seems this happens only for arrays of enums.
Arrays of other basic types are copied in the flattened DAE.