Group Abstract Group Abstract

Message Boards Message Boards

2
|
11.6K Views
|
7 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Why are graphical annotations for connectors not inherited (redeclaration)?

7 Replies

I'm sorry I din't read your description carefully enough, the bug you describe is still present in 5.1.

If I'm not misstaken there is a big difference between upvotes on Stack Overflow and likes here in that upvotes actually has a clear functional role and affects how content is sorted and displayed. So on Stack Overflow the community is built upon the up voting mechanism. Whereas in this forum it's unclear (at least for me) if likes here has any community benefits at all besides being a pat at the back for the poster.

Best regards, Otto

POSTED BY: Otto Tronarp

Thank you very much for this report. It does indeed seem like Model Center does not properly render redeclared connectors inside components. It is something we will look into.

As a work-around you could create multiple versions of your component class with different set of connectors, and make the instances of the component class replaceable. Not sure if this would be an acceptable work-around for you, but it should work.

POSTED BY: Daniel Hedberg

Hi Otto,

my bad and you are right about the annotations which in this case make it a „complete example“. I still have to get used to Modelica and including annotations do make code highly unreadable imo - a reason for usually being collapsed.

But, the simple fact remains that the example does not work in Version 4.3 which is quite irritating.

BTW, in Version 4.3 a simple typo like extending the same class (circular definition) will crash System Modeler and a restart will not work also because the faulty model is automatically loaded, e.g.

model newClass  „some class“
    extends newClass; // a typo here, should have been oldClass...
end newClass;

Note: This is just indicative, I cannot find the original code as I had to go back in history using Dropbox to restart...

Renaming something in text mode can also quickly crash WSM 4.3 - I have not seen a really convincing Refactor-functionality as renaming a class name for example will not update its name in existing connect-equations.

The interplay WSM 4.3 - Mathematica 11.3 is not smooth either ... so I will have to see whether 5.1 is worth it. After all, System Dynamics — „inductive“ — modeling is probably not the typical use case and some people call me a „weirdo“ for trying. ;-)

Guido

Edit: Is there a published list of known issues with WSM 4.3 - that would help greatly.

Another way of increasing the chances of getting an answer is to provide a complete example of the problem. I'm assuming you are meaning something like this:

package ConnectorsTest
  partial model GenericFlow "Flow Template with replaceable ports"
    replaceable FlowPort portA "Flow from/to Stock A" annotation(Placement(visible = true, transformation(origin = {-66.537, 24.02}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
    replaceable FlowPort portB "Flow to/from Stock B" annotation(Placement(visible = true, transformation(origin = {110, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, -0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  end GenericFlow;

  model Outflow "Outflow from a stock"
    extends GenericFlow(redeclare SpecialFlowPort portA);
  end Outflow;

  connector FlowPort
    annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics = {Rectangle(visible = true, origin = {0, 5}, fillColor = {107, 255, 252}, fillPattern = FillPattern.Solid, extent = {{-50, -55}, {50, 55}})}));
  end FlowPort;

  connector SpecialFlowPort
    annotation(Icon(coordinateSystem(extent = {{-100, -100}, {100, 100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {10, 10}), graphics = {Rectangle(visible = true, origin = {0, 5}, fillColor = {246, 114, 123}, fillPattern = FillPattern.Solid, extent = {{-50, -55}, {50, 55}})}));
  end SpecialFlowPort;
end ConnectorsTest;

That should indeed work and it does, at least in WSM 5.1. Perhaps you have an older version? 5.0 contained a lot of improvements regarding replaceable/redeclare.

Otto

POSTED BY: Otto Tronarp
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard