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)
Change History (19)
comment:1 by , 11 years ago
Component: | Backend → OMEdit |
---|---|
Owner: | changed from | to
Priority: | high → normal |
comment:2 by , 11 years ago
Component: | OMEdit → Interactive Environment |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:3 by , 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 , 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 , 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 , 11 years ago
Attachment: | Dialog-annotation-handling-OMC.png added |
---|
by , 11 years ago
Attachment: | Dialog-annotation-handling-DYM.png added |
---|
by , 11 years ago
by , 11 years ago
Attachment: | script.mos added |
---|
comment:6 by , 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:8 by , 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 , 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 , 11 years ago
Component: | Interactive Environment → OMEdit |
---|---|
Owner: | changed from | to
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 , 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 , 11 years ago
It is working in OpenModelica1.9.1Nightly r18573
Great fix - Thanks!
Best Regards
Jan
comment:13 by , 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 , 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 , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
It is because OMC is not able to parse such annotations,