Opened 7 years ago

Last modified 3 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)

TestParameterUnits.mo (450 bytes ) - added by Francesco Casella 7 years ago.
script.mos (168 bytes ) - added by Adeel Asghar 5 years ago.

Download all attachments as: .zip

Change History (17)

by Francesco Casella, 7 years ago

Attachment: TestParameterUnits.mo added

comment:1 by Per Östlund, 6 years ago

Resolution: fixed
Status: newclosed

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

comment:2 by Francesco Casella, 6 years ago

Component: New InstantiationOMEdit
Resolution: fixed
Status: closedreopened

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 ticke?

Version 0, edited 6 years ago by Francesco Casella (next)

comment:3 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0

comment:4 by Francesco Casella, 5 years ago

Component: OMEditNF API

comment:5 by Francesco Casella, 5 years ago

Component: NF APIOMEdit
Owner: changed from Per Östlund to Adeel Asghar
Status: reopenedassigned

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 Adeel Asghar, 5 years ago

Attachment: script.mos added

comment:6 by Adeel Asghar, 5 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.

in reply to:  5 comment:7 by Adeel Asghar, 5 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: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.

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 Adrian Pop, 5 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 Adeel Asghar, 5 years ago

Component: OMEditInteractive Environment
Owner: changed from Adeel Asghar to Adrian Pop

So we just need to fix getInheritedClasses and then we get the expected results in OMEdit.

comment:10 by Francesco Casella, 5 years ago

Milestone: 1.14.01.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 Francesco Casella, 4 years ago

Milestone: 1.15.01.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

comment:12 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:13 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Rescheduled to 1.18.0

comment:14 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

comment:15 by Francesco Casella, 3 years ago

Milestone: 1.19.0

1.18.0 blocker tickets moved to 1.19.0

Note: See TracTickets for help on using tickets.