Opened 11 years ago

Closed 11 years ago

#2524 closed defect (fixed)

Erroneous parameter group identification in OMEDIT

Reported by: massimo ceraolo Owned by: Adeel Asghar
Priority: normal Milestone: 1.9.1
Component: OMEdit Version: trunk
Keywords: Cc:

Description

Consider the component
Modelica.Blocks.Sources.CombiTimeTable
its code contains the following rows

  parameter Boolean tableOnFile = false "= true, if table is defined on file or in function usertab" annotation(Dialog(group = "Table data definition"));
  parameter Real table[:,:] = fill(0.0, 0, 2) "Table matrix (time = first column; e.g., table=[0,2])" annotation(Dialog(group = "Table data definition", enable = not tableOnFile));
  parameter String tableName = "NoName" "Table name on file or in function usertab (see docu)" annotation(Dialog(group = "Table data definition", enable = tableOnFile));
  parameter String fileName = "NoName" "File where matrix is stored" annotation(Dialog(group = "Table data definition", enable = tableOnFile, loadSelector(filter = "Text files (*.txt);;MATLAB MAT-files (*.mat)", caption = "Open file in which table is present")));
  parameter Boolean verboseRead = true "= true, if info message that file is loading is to be printed" annotation(Dialog(group = "Table data definition", enable = tableOnFile));

However, in OMEdit (r18553) only "tableOnFile" is inserted in "Table data definition" group, while the others are in the generic "Parameters" group.

Attachments (4)

Dialog-annotation-handling-OMC.png (30.3 KB ) - added by Adrian Pop 11 years ago.
Dialog-annotation-handling-DYM.png (27.7 KB ) - added by Adrian Pop 11 years ago.
M.mo (786 bytes ) - added by Adeel Asghar 11 years ago.
script.mos (81 bytes ) - added by Adeel Asghar 11 years ago.

Download all attachments as: .zip

Change History (19)

comment:1 by massimo ceraolo, 11 years ago

Component: BackendOMEdit
Owner: changed from probably noone to Adeel Asghar
Priority: highnormal

comment:2 by Adeel Asghar, 11 years ago

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

It is because OMC is not able to parse such annotations,

annotation(Dialog(group = "Table data definition", enable = not tableOnFile));

comment:3 by Adrian Pop, 11 years ago

Parsing is OK, otherwise you could not load the model.
I guess you mean we don't have an API for querying the Dialog annotations.
We should be able to add some new API for it if that's the case.

comment:4 by Adeel Asghar, 11 years ago

Yeah i mean we can't query it.
We do have an API for it,

getComponentAnnotations

but if the annotation use some parameter then it fails as it is in the above example,

enable = not tableOnFile

I think we need to instantiate it.

comment:5 by Adrian Pop, 11 years ago

That is not true. As far as I know we do instantiate if there are parameters in the annotation. By default tableOnFile is false.
What ceraolo means with this bug is that all the parameters in that class should be inside the "Table data definition" part in the Parameters dialog. See attachments (I'll add them shortly).

by Adrian Pop, 11 years ago

by Adrian Pop, 11 years ago

by Adeel Asghar, 11 years ago

Attachment: M.mo added

by Adeel Asghar, 11 years ago

Attachment: script.mos added

comment:6 by Adeel Asghar, 11 years ago

Run the attached script with M.mo,

adeas31@IDA-LIU085 /c
$ /c/OpenModelica/trunk/build/bin/omc.exe script.mos 
true
""
{{Dialog("General","Table data definition",true,false,"",false)},{Dialog(error)},{Dialog(error)},{Dialog(error)}}

I can't group components if OMC returns me "error".

comment:7 by Adrian Pop, 11 years ago

Good. Now we're getting somewhere :)
I'll have a look.

comment:8 by Adrian Pop, 11 years ago

Does this look ok? The problem was that we evaluated these annotations in an empty environment. Now we do it in the instantiated class if needed.

adrpo@ida-liu050 ~/dev/OpenModelicaNoChanges/build/bin/b
$ ../omc +showErrorMessages +d=failtrace,ceval script.mos 
true
""
{{Dialog("General","Table data definition",true,false,false,"","","","","",false)},
 {Dialog("General","Table data definition",true,false,false,"","","","","",false)},
 {Dialog("General","Table data definition",false,false,false,"","","","","",false)},
 {Dialog("General","Table data definition",false,false,false,"Text files (*.txt);;MATLAB MAT-files (*.mat)","Open file in which table is present","","","",false)}}

Note that I had to update Dialog to have more stuff in it as Modelica Spec 3.2 rev 2 has more stuff in the Dialog annotation:

record Dialog
   parameter String tab = \"General\";
   parameter String group = \"Parameters\";
   parameter Boolean enable = true;
   parameter Boolean showStartAttribute = false;
   parameter Boolean colorSelector = false;
   parameter Selector loadSelector;
   parameter Selector saveSelector;
   parameter String groupImage = \"\";
   parameter Boolean connectorSizing = false;
end Dialog;

record Selector
  parameter String filter=\"\";
  parameter String caption=\"\";
end Selector;

Before it did not have:

   parameter Boolean colorSelector = false;
   parameter Selector loadSelector;
   parameter Selector saveSelector;

So, after my commit you will need to update OMEdit to handle the new components.

comment:9 by Adeel Asghar, 11 years ago

I think it will work.
Just commit your changes and if it doesn't work I will adjust the code.

comment:10 by Adrian Pop, 11 years ago

Component: Interactive EnvironmentOMEdit
Owner: changed from Adrian Pop to Adeel Asghar

Committed r18573. Note that the new components in Dialog annotation record are placed in the middle, so your OMEdit parsing might need changing.

comment:11 by Adeel Asghar, 11 years ago

I did a small test and it seems like OMEdit handles your new changes gracefully.

Ceraolo can you please test the new nightly build? If there is any problem just let me know.

comment:12 by jan.kokert, 11 years ago

It is working in OpenModelica1.9.1Nightly r18573
Great fix - Thanks!
Best Regards
Jan

comment:13 by massimo ceraolo, 11 years ago

Hi all,
Thank you for addressing and solving lightning fast this issue. I've checked and it works as intended.

May I add an additional comment on the topic of parameters window?
Consider again component
Modelica.Blocks.Sources.CombiTimeTable

In OMEdit, also parameters t_min, t_max and nout are shown and can be changed from the parameters window. However they are defined as "final" and therefore (ASAIK) are not allowed to be be changed by the final user.
Don't you agree that it is better not to show final parameters in the parameters windows?

Just an idea, taken from other Modelica simulation tools.

comment:14 by Adrian Pop, 11 years ago

I think is better to close this bug and open a new one about final parameters.
One idea would be to show the final parameters but grayed out (no edit possible or at least edit with a warning).

comment:15 by massimo ceraolo, 11 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.