Opened 8 years ago
Last modified 4 years ago
#4608 assigned defect
Unit string lost in Modelica.Media inheritance chain
| Reported by: | Francesco Casella | Owned by: | Adrian Pop |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.19.0 |
| Component: | Interactive Environment | Version: | v1.13.0-dev-nightly |
| Keywords: | Cc: | Adrian Pop |
Description
Please open the attached test package in OMEdit. Open M2 and double-click on m to set parameters.
p1 and p2 have the correct display unit. p3 doesn't show any unit information.
Now, p3 is of type Modelica.Media.Water.StandardWater.AbsolutePressure, which inherits from Modelica.SIunits.AbsolutePressure, that has unit="Pa" and displayUnit = "bar". This information is somhow lost in the inheritance chain.
Please make sure this information is passed correctly to the new API that will be rolled out in 1.13.0 and uses the new front end.
Attachments (2)
Change History (17)
by , 8 years ago
| Attachment: | TestParameterUnits.mo added |
|---|
comment:1 by , 7 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:2 by , 7 years ago
| Component: | New Instantiation → OMEdit |
|---|---|
| Resolution: | fixed |
| Status: | closed → reopened |
Indeed. However, OMEdit still doesn't show any display unit for p3 when editing the parameters of m.
@adrpo, can you please check that the new API works correctly in this case, and if so, can you please close this ticket?
comment:4 by , 6 years ago
| Component: | OMEdit → NF API |
|---|
follow-up: 7 comment:5 by , 6 years ago
| Component: | NF API → OMEdit |
|---|---|
| Owner: | changed from to |
| Status: | reopened → assigned |
I did some more analysis on omcommunication.log, using -d=newInst,nfAPI. An excerpt of it follows:
getComponents(TestParameterUnits.M2, useQuotes = true) 13:04:00:967
{{"TestParameterUnits.M1","m","", "public", "false", "false", "false", "false", "unspecified", "none", "unspecified","{}"}
} 13:04:00:967
getComponents(TestParameterUnits.M1, useQuotes = true) 13:04:00:976
{{"Modelica.SIunits.Pressure","p1","", "public", "false", "false", "false", "false", "parameter", "none", "unspecified","{}"},
{"Modelica.SIunits.AbsolutePressure","p2","", "public", "false", "false", "false", "false", "parameter", "none", "unspecified","{}"},
{"TestParameterUnits.M1.Medium.AbsolutePressure","p3","", "public", "false", "false", "false", "false", "parameter", "none", "unspecified","{}"}
} 13:04:01:351
Here, the three types of p1, p2, and p3 are listed correctly.
Later on, OMC is inquired about the displayUnit modifiers of the first two classes:
getDerivedClassModifierValue(Modelica.SIunits.Pressure,displayUnit) 13:10:25:884 ""bar"" 13:10:25:884 getDerivedClassModifierValue(Modelica.SIunits.AbsolutePressure,displayUnit) 13:10:25:885 "" 13:10:25:885
the first result is correct, the second is not, but then somehow (how?) OMEdit figures out that p2.displayUnit="bar" and shows it in the dialog. For some reason (which one?), the displayUnit of the type of p3 is not even inquired.
I guess there are issues here both with OMEdit and with getDerivedClassModifierValue. @adeas31, can you please check the OMEdit issue, and then hand this over to @adrpo for the nfAPI part?
Thanks!
by , 6 years ago
| Attachment: | script.mos added |
|---|
comment:6 by , 6 years ago
The new API fails to list the components if the component class is not found. This is rather bad for OMEdit. OMEdit can handle undefined classes and shows a red cross box for them. Once they are loaded then OMEdit automatically updates them.
I strongly recommend to consider this for new API. Just list the components of the class even if they are undefined.
comment:7 by , 6 years ago
Replying to casella:
I did some more analysis on
omcommunication.log, using-d=newInst,nfAPI. An excerpt of it follows:
getComponents(TestParameterUnits.M2, useQuotes = true) 13:04:00:967 {{"TestParameterUnits.M1","m","", "public", "false", "false", "false", "false", "unspecified", "none", "unspecified","{}"} } 13:04:00:967 getComponents(TestParameterUnits.M1, useQuotes = true) 13:04:00:976 {{"Modelica.SIunits.Pressure","p1","", "public", "false", "false", "false", "false", "parameter", "none", "unspecified","{}"}, {"Modelica.SIunits.AbsolutePressure","p2","", "public", "false", "false", "false", "false", "parameter", "none", "unspecified","{}"}, {"TestParameterUnits.M1.Medium.AbsolutePressure","p3","", "public", "false", "false", "false", "false", "parameter", "none", "unspecified","{}"} } 13:04:01:351Here, the three types of
p1,p2, andp3are listed correctly.
Later on, OMC is inquired about the
displayUnitmodifiers of the first two classes:
getDerivedClassModifierValue(Modelica.SIunits.Pressure,displayUnit) 13:10:25:884 ""bar"" 13:10:25:884 getDerivedClassModifierValue(Modelica.SIunits.AbsolutePressure,displayUnit) 13:10:25:885 "" 13:10:25:885the first result is correct, the second is not, but then somehow (how?) OMEdit figures out that
p2.displayUnit="bar"and shows it in the dialog. For some reason (which one?), thedisplayUnitof the type ofp3is not even inquired.
The second result is also true since Modelica.SIunits.AbsolutePressure doesn't have any displayUnit so in that case OMEdit tries to find it from the base class i.e., Modelica.SIunits.Pressure. For p3 we should also get bar but getInheritedClasses(TestParameterUnits.M1.Medium.AbsolutePressure) fails. If you look further below in the log you will see that p3 is inquired.
I guess there are issues here both with OMEdit and with
getDerivedClassModifierValue. @adeas31, can you please check the OMEdit issue, and then hand this over to @adrpo for the nfAPI part?
Thanks!
comment:8 by , 6 years ago
With PR: https://github.com/OpenModelica/OpenModelica/pull/298
we will get the components even if the types of the classes are not found.
getInheritedClasses(TestParameterUnits.M1.Medium.AbsolutePressure) is not using the NF yet, also it tries to search in the AST for class TestParameterUnits.M1.Medium.AbsolutePressure which of course will never be found. You would need to do proper lookup to find out that Medium is set to StandardWater and that StandardWater is actually a short class definition of WaterIF97_ph, fetch inherited classes of that one to reach Types where AbsolutePressure is defined and then fetch its modifier. I have to think about a solution for this one.
comment:9 by , 6 years ago
| Component: | OMEdit → Interactive Environment |
|---|---|
| Owner: | changed from to |
So we just need to fix getInheritedClasses and then we get the expected results in OMEdit.
comment:10 by , 6 years ago
| Milestone: | 1.14.0 → 1.15.0 |
|---|
Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2.
This issue, previously marked as blocker for 1.14.0, is rescheduled to 1.15.0
comment:11 by , 5 years ago
| Milestone: | 1.15.0 → 1.16.0 |
|---|
Release 1.15.0 was scrapped, because replaceable support eventually turned out to be more easily implemented in 1.16.0. Hence, all 1.15.0 tickets are rescheduled to 1.16.0

This works correctly in both the old and the new frontend as far as I can see.