Opened 9 years ago
Last modified 9 years ago
#3591 new defect
OMEdit fails when opening "total save" model
Reported by: | Bernhard Thiele | Owned by: | Adeel Asghar |
---|---|---|---|
Priority: | low | Milestone: | Future |
Component: | OMEdit | Version: | |
Keywords: | Cc: |
Description
The attached model is created by using File->Save Total
on the model Modelica.Blocks.Examples.PID_Controller
.
It works to simulate the model using scripting:
loadFile("PID_ControllerTotal.mo"); simulate(PID_Controller_total);
However, it is not possible to open the model in OMEdit. Trying to open it results in an error message, similar to
Only single nonstructured entity is allowed to be stored in the file PID_ControllerTotal.mo
Attachments (1)
Change History (10)
by , 9 years ago
Attachment: | PID_ControllerTotal.mo added |
---|
follow-up: 3 comment:1 by , 9 years ago
comment:2 by , 9 years ago
This is not new. It was in OMEdit from a long time and it is because of Modelica specification section 13.2.2.2 Mapping a Package/Class Hierarchy into a Single File (Nonstructured Entity) which says,
"A nonstructured entity [e.g. the file A.mo] shall contain only a stored-definition that defines a class [A] with a name matching the name of the nonstructured entity. In a file hierarchy the files shall have the extension “.mo”."
Generate better code from save total API.
comment:3 by , 9 years ago
Replying to adrpo:
I think this is a new restriction on OMEdit so that is easier to implement indentation preserving things. The problem is that we cannot change the export so that we encapsulate anything in a package.
Why this is a problem?
follow-up: 5 comment:4 by , 9 years ago
Because when you generate code from a total model you in general have at the top level:
Modelica ModelicaServices Etc
I think that any Modelica tool (including Dymola) does it in the same way.
Also, the grammar allows it even thou' maybe other parts of the specification doesn't.
I think we should remove this restriction if possible (maybe make it a warning only).
comment:5 by , 9 years ago
Replying to adrpo:
Because when you generate code from a total model you in general have at the top level:
Modelica ModelicaServices EtcI think that any Modelica tool (including Dymola) does it in the same way.
Well Dymola does the same and also allows loading back the file but then make some change in the model and save it again, all the top level packages are removed from the file.
Also, the grammar allows it even thou' maybe other parts of the specification doesn't.
I think we should remove this restriction if possible (maybe make it a warning only).
No, how do you save two or more top level classes in one file?
comment:6 by , 9 years ago
The grammar says:
stored_definition: [ within [ name ] ";" ] // within is optional { [ final ] class_definition ";" } // means 0 or more class definitions
So saving any number of top level classes in one file is fine:
within ; package A end A; package B end B; package C end C;
I'll open a ticket on the Modelica website about this as it needs to be cleared.
comment:7 by , 9 years ago
Opened #m:1854 about this.
Note that what you quoted from the spec:
"A nonstructured entity [e.g. the file A.mo] shall contain only a stored-definition that defines a class [A] with a name matching the name of the nonstructured entity. In a file hierarchy the files shall have the extension “.mo”."
can be read a bit differently and could be interpreted as saying it shall only exits ONE class with name A in the A.mo file.
follow-up: 9 comment:8 by , 9 years ago
That is exactly how i want it to be interpreted. I don't care if the class name is A or not but there should be only one class per file.
comment:9 by , 9 years ago
Replying to adeas31:
That is exactly how i want it to be interpreted. I don't care if the class name is A or not but there should be only one class per file.
No. What I meant is that it can be interpreted as you can have multiple classes but just one with name A :)
I think this is a new restriction on OMEdit so that is easier to implement indentation preserving things. The problem is that we cannot change the export so that we encapsulate anything in a package. Adeel, maybe we could support such files with multiple classes at the top level by making them read-only.