Opened 6 years ago
Last modified 5 years ago
#5448 reopened defect
OMEdit fails to open model, previously Totally Saved
Reported by: | Owned by: | Adeel Asghar | |
---|---|---|---|
Priority: | normal | Milestone: | 2.0.0 |
Component: | Documentation | Version: | v1.14.0-dev-nightly |
Keywords: | Cc: |
Description
Open model with dependencies on some libraries, Save Total, Open the saved file -> error: Unable to load the file/library.
"Only single non-structured entity is allowed to be stored in the file."
This kinda breaks the idea of Save Total, isnt it?
Attachments (4)
Change History (23)
by , 6 years ago
Attachment: | Smith_patSpec.mo added |
---|
comment:1 by , 6 years ago
@filip, Could you also add the source files that were used to produced the save total'd model? This would allow to actually reproduce the issue
comment:2 by , 6 years ago
@casella Hi Francesco! Sure, here it is https://gist.github.com/filip-jezek/5404c3dc3687e31ae932e7bbd479f680
The Model2 contains the Model1. Model2 is TotalSaved into Model2Total. The Model2Total could not be opened.
comment:3 by , 6 years ago
Milestone: | Future → 1.14.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
@adeas31, can you please take care of this or reassign it to somebody else who could? I'm not sure if this is an OMEdit issue or and interactive environment issue.
Thanks!
comment:4 by , 6 years ago
Yes, saveTotal is not intended to use in OMEdit but rather in mos-scripting. OMEdit only accepts valid Modelica files whereas omc also accepts file with multiple classes on the top-level.
comment:5 by , 6 years ago
Ah, ok. I was also puzzled as Filip by the fact that OMEdit won't load Save Total files.
As usual, this is fine, as long as it is documented :)
See PR #109, @adeas31 can you please check, merge, and then close the ticket?
Thanks!
comment:6 by , 6 years ago
Component: | *unknown* → Documentation |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
comment:7 by , 5 years ago
Milestone: | 1.14.0 → 2.0.0 |
---|---|
Resolution: | fixed |
Status: | closed → reopened |
Version: | v1.13.2 → v1.14.0-dev-nightly |
This error happened to me on 1.14.0-dev-26584-gae23951b15.
comment:9 by , 5 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
DidnT read the whole comments. Sorry
comment:10 by , 5 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:11 by , 5 years ago
In fact, it would be even better if OMEdit also caught the
Only single non-structured entity is allowed to be stored in the file.
message and printed out something like
Only single non-structured entity is allowed to be stored in the file.
If the file was generated by the API function saveTotalModel(), you can only load it with the API function loadFile() in a script or in the interactive environment, not in OMEdit
follow-ups: 13 14 comment:12 by , 5 years ago
It is a bit strange that we can save through the GUI a file that we cannot read back through the GUI itself.
If the saved total is not a "valid modelica file" (comment 4) maybe it would have a different extension (say mot)?
In that case opening a "mot" file could be done using the code currently used for loadFile() in a script.
As far as I can tell this should be straightforward to implement given the existing loadFile() code.
The only drawback is that the "mot" would be an internal OM standard, not a Modelica standard format. But it is already like this, isn't it?
comment:13 by , 5 years ago
Replying to anonymous:
It is a bit strange that we can save through the GUI a file that we cannot read back through the GUI itself.
Indeed.
If the saved total is not a "valid modelica file" (comment 4) maybe it would have a different extension (say mot)?
That's a good idea.
In that case opening a "mot" file could be done using the code currently used for loadFile() in a script.
See my comment in PR 314
As far as I can tell this should be straightforward to implement given the existing loadFile() code.
The only drawback is that the "mot" would be an internal OM standard, not a Modelica standard format. But it is already like this, isn't it?
Indeed.
comment:14 by , 5 years ago
In that case opening a "mot" file could be done using the code currently used for loadFile() in a script.
Not sure that this was clear enough.
I meant that using the same code of loadFile() in script should be easy to implement a GUI loading routine for "mot". This way, I think, the existing command open Model/Library Files() could be used to read such "mot" files.
follow-up: 16 comment:15 by , 5 years ago
Well, as I see, the problem is not in the improper usage of saveTotal, but in OM not importing a valid modelica file. Consider file test.mo:
model A Boolean a = true; end A; model B Boolean b = false; end B;
that is, two models without encapsulated package. Dymola loads fine, OM raises an error and fails to open it. I was unable (please point me out otherwise) a clause in Modelica specification which disallows this.
The motivation is opening a number of supporting libraries within one file, which is simply generated (from both OM and other tools, such as Dymola). The workaround is writing a mos doing this, but still: OM is unable to open a valid .MO.
comment:16 by , 5 years ago
Replying to Filip Ježek:
Well, as I see, the problem is not in the improper usage of saveTotal, but in OM not importing a valid modelica file. Consider file test.mo:
model A Boolean a = true; end A; model B Boolean b = false; end B;that is, two models without encapsulated package. Dymola loads fine, OM raises an error and fails to open it. I was unable (please point me out otherwise) a clause in Modelica specification which disallows this.
See Section 13.2.: "package/classes are mapped into directories or files" (i.e., one directory or one file for each package or class, as I understand it).
See also Section 13.2.2.2:
- When mapping a package or class-hierarchy to a file [e.g. the file A.mo ], that file shall only define a single class [ A ] with a name matching the name of the nonstructured entity.
- A ".mo" file defining more than one class cannot be part of the mapping to file-structure and it is an error if it is loaded from the MODELICAPATH
comment:17 by , 5 years ago
Ok, thanks for pointing me, i clearly overlooked that. That solves the issue then.
F/
comment:18 by , 5 years ago
Well. It might be that OMEdit should ask the user if the file should be opened (read-only) anyway. That should not interfere with its ability to save the file again...
comment:19 by , 5 years ago
We are trying to adhere strictly to the specification. From this point of view, I guess OMC should not accept a .mo file which is invalid according to it.
I am personally in favour of the .mot
file option.
The file, saved by Save Total, error during the load.