Opened 10 years ago
Last modified 8 years ago
#2850 new defect
Redeclared models use wrong icon
Reported by: | Owned by: | Adeel Asghar | |
---|---|---|---|
Priority: | blocker | Milestone: | 2.0.0 |
Component: | OMEdit | Version: | trunk |
Keywords: | Cc: | Adrian Pop |
Description
I created a base object, and then extended it to create other objects. I then used the base as a replaceable object inside another model. So, far so good. If I then create another model, based on that, but redeclare that object, OMEdit shows the "lower" object, and not the extended one. That means, for example, that I can't see new connections that have been added by extending.
The underlying code works fine, but there is no graphical way to make connections to this object, since I can see the ports, and can't click on them to connect. But, if I do the connections, by editing the text file, the actual simulations does run fine.
As the above is probably not as clear as I would like, I have generated a simple test case.
In the attached, Test2 does not run, since I have not made the extra connection (and the connection is not shown) and Test3 does work, but again, there is no visible connection between the second sine source, and the object. But, more specifically, Test2 and Test3 both show an object that appears to be "ObjectSuper1" but the code behaves, correctly, as though these are "ObjectSuper2". So OMEdit, should be showing the icons for these as "ObjectSuper2".
I believe that I am correctly using replaceable, extends and redeclare, but that OMEdit, is not following them correctly.
I am using OMEdit 22485 on a Mac.
Attachments (4)
Change History (13)
by , 10 years ago
Attachment: | TestPartial.mo added |
---|
comment:1 by , 10 years ago
Just to be even more explicit. "ObjectSuper2" has two real inputs, and "ObjectSuper1" has just one.
In Test2 and Test3, I am using ObjectSuper2, but only a single real input is visible, and only that one can be clicked on for GUI connections in OMEdit.
But, the connection can be correctly made by editing the text file, it just can not be seen, or shown in OMEdit.
comment:2 by , 10 years ago
The component ObjectSuper11
you see in Test2
& Test3
are actually instances of ObjectSuper1
coming from Test1
base class. So don't mix it with ObjectSuper2
. The confusion is there because you have named the redeclared component of ObjectSuper2
as objectsuper11
.
The reason why you don't see the icon of redeclared component is because your component doesn't have any placement annotation. So actually the component is part of the model so of course you can add connections manually but since it doesn't have the placement annotation that is why you can't see it.
Check the attached TestPartialUpdated.mo. I have only added a placement annotation and i think everything looks & works fine.
by , 10 years ago
Attachment: | TestPartialUpdated.mo added |
---|
comment:3 by , 10 years ago
I see that the updated version is showing correctly, as you said. But, the first part of your explanation still has me a bit confused.
I am trying to make two versions of a model (Test1 and Test 3). The first one should have an ObjectSuper1 and the second should have an ObjectSuper2. That's what I thought I did, and what the code seems to do. But, I think that you are saying that Test3 has an instance of ObjectSuport1? While I thought that I had replaced that (which is why I was surprised to see the icon for it).
I named that component objectsuper11 and then used the same name, because I thought that is the correct way to replace it.
Is there a different way to do that? Am I misunderstanding something?
by , 10 years ago
Attachment: | TestPartialNew.mo added |
---|
by , 10 years ago
Attachment: | TestPartial.Test3.png added |
---|
comment:4 by , 10 years ago
Cc: | added |
---|
Now i understand what you are trying to do. See the new attached file and look at TestPartial.Test3
. The correct way to do is,
extends TestPartial.Test1(redeclare TestPartial.ObjectSuper2 objectsuper11);
The new file works fine in Dymola (See the attached screenshot). However, it doesn't work properly in OMEdit. I think we don't have any support for it.
Adrian, do we have any API to get the redeclare information?
follow-up: 6 comment:5 by , 10 years ago
Are these two ways to extend different?
For the functionality, in OMEdit, they give the same results (both calculated and graphically). It seems like, as I was expecting, that there is just a single instant of objectsuper11 and it is of type ObjectSuper2.
Just to be explicit, although I think you do understand what I am trying to do:
I want to make a component, and the a second version of that component.
I then want to make a model that uses the first version of the component. Finally, I want a second version of model that replaces that version with the second version of the component.
In other words, I want pump1 then I want to extend that to make pump2. Then, I want to build plant1 using pump1, and finally, I want to extend plant1 (to make plant3), and to have plant3 use pump2 in place of pump1.
If we are understanding each other, I believe that the functionality in OMC is working fine in my original example, as well as in your edited version. But, the graphics in OMEdit, aren't doing the right thing. But, a work around is to use placement, as you showed in TestPartialUpdated.mo.
Is that correct?
comment:6 by , 10 years ago
Replying to Adam Dershowitz <dersh@…>:
Are these two ways to extend different?
No. I think the way used in TestPartial.Test2
is wrong. Dymola gives error for it,
Hiding extended classes requires subtype But missing component b. For element objectsuper11 found at Modelica Text: line 4 Conflict with element from Modelica Text: line 25 Context: TestPartial.Test2 Modelica Text: near line 1
OMC runs it fine. Perhaps Adrian can check this thing.
For the functionality, in OMEdit, they give the same results (both calculated and graphically). It seems like, as I was expecting, that there is just a single instant of objectsuper11 and it is of type ObjectSuper2.
Just to be explicit, although I think you do understand what I am trying to do:
I want to make a component, and the a second version of that component.
I then want to make a model that uses the first version of the component. Finally, I want a second version of model that replaces that version with the second version of the component.
In other words, I want pump1 then I want to extend that to make pump2. Then, I want to build plant1 using pump1, and finally, I want to extend plant1 (to make plant3), and to have plant3 use pump2 in place of pump1.
If we are understanding each other, I believe that the functionality in OMC is working fine in my original example, as well as in your edited version. But, the graphics in OMEdit, aren't doing the right thing. But, a work around is to use placement, as you showed in TestPartialUpdated.mo.
OMEdit doesn't handle the graphics for replaceable and redeclared components well. That should be fixed. There is another ticket for it as well #2079.
Is that correct?
comment:7 by , 10 years ago
OpenModelica does not have support for redeclares yet in OMEdit.
I'm working on a new API that will give access to an actual instance
where redeclares can be queried but it will take a while to implement.
Also, OpenModelica does not currently check if the redeclared component
or class is subtype of the original. That will be fixed too.
Yes, there are 2 ways of redeclaring (either you give it as a modifier
in extends or you use something called element redeclare by just giving
redeclare T x; or redeclare model T=X in the current class which will
basically redeclare the original that comes from extends).
Dymola is a bit off when you use redeclare as element (which is actually a
modifier for the extends) and it gives that "Hiding extended classes" message.
It should be something like "redeclare as element requires subtype".
comment:8 by , 10 years ago
Also, as far as I know subtypes should be allowed for redeclare
as element but Dymola wants equivalent types (exactly the same
components).
comment:9 by , 8 years ago
Milestone: | Future → 2.0.0 |
---|---|
Priority: | normal → blocker |
Changed priority to blocker for 2.0.0. We should really handle replaceable objects satisfactorily in that version.
Test Case showing wrong icon