Opened 9 years ago

Last modified 9 years ago

#3591 new defect

OMEdit fails when opening "total save" model

Reported by: bthiele Owned by: adeas31
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)

PID_ControllerTotal.mo (33.9 KB) - added by bthiele 9 years ago.

Download all attachments as: .zip

Change History (10)

Changed 9 years ago by bthiele

comment:1 follow-up: Changed 9 years ago by 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. Adeel, maybe we could support such files with multiple classes at the top level by making them read-only.

comment:2 Changed 9 years ago by adeas31

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 in reply to: ↑ 1 Changed 9 years ago by adeas31

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?

comment:4 follow-up: Changed 9 years ago by adrpo

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 in reply to: ↑ 4 Changed 9 years ago by adeas31

Replying to adrpo:

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.

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 Changed 9 years ago by adrpo

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 Changed 9 years ago by adrpo

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.

comment:8 follow-up: Changed 9 years ago by 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.

comment:9 in reply to: ↑ 8 Changed 9 years ago by adrpo

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 :)

Note: See TracTickets for help on using tickets.