Message Boards Message Boards

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

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

Hi everybody,

I am creating a library for System Dynamics modeling which unlike the existing free library by Cellier is making use of acausal connectors. For "Flow" - Elements I have a generic flow class that defines the interfaces:

partial model GenericFlow "Flow Template with replaceable ports"
    replaceable FlowPort portA "Flow from/to Stock A";
    replaceable FlowPort portB "Flow to/from Stock B";
end GenericFlow;

Its Icon looks like this and includes the magenta colored connectors:

GenericFlow-Icon

For some special cases I will use different ports (e.g. class SpecialFlowPort). As an example I do have a class called "Outflow" which will redeclare the connector class used for portA:

model Outflow "Outflow from a stock"
    extends Interfaces.GenericFlow(redeclare Interfaces.SpecialFlowPort portA);
    [...]
end Outflow;

Its icon will automatically show the red colored SpecialFlowPort that has been exchanged for portA (left side):

Outflow-Icon

Now if I am using this component in a new model (drag and drop) it will show the original magenta colored FlowPort connector again and also show that class name upon hovering over the port connector. (Note: The correct SpecialFlowPort is used though as a connection to a (correctly colored) magenta port (FlowPort - connector) is prohibited.)

Why will the redeclared connector class not be used in the model-diagram?

UPDATE:

Here is a picture of the class Outflow with the false color for the left side port showing (i.e. magenta instead of red):

Why is the wrong color and the wrong class name given in the model diagram?

I have cross-posted this question now on Stack Overflow to increase my chances of getting an answer.

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 for clarification. Nonetheless even if the "like" is reduced to simply a "pat on the back" a very old verdict from social science is: You cannot not communicate/not send a message.

The absence of a pat on the back remains simply that: no pat - where it could have been the cheapest form of customer relationship management there is. ;-)

Guido

Daniel and Otto,

thank you both very much for answering my question.

As an afterthought: As long-time user ot Mathematica I am of course very observant with regard to patterns. I do note that for my last posts regarding WSM (e.g. unit checking, operator records, inheriting annotation for redeclared connectors) not a single post -- including the questions themselves -- I wrote has received any "likes" (the currency of the online society as we know it these days)! ;-)

Certainly, I could have improved upon my questions - I had forgotten to make the example complete in this case but in general I fail to see my questions being "stupid" or "of little interest". This very case has in fact been a report of a very legitimate "issue" with WSM as there should quite clearly have been inheritance. (I do unfortunately note that Wolfram makes great efforts to report about "features" while known issues to my knowledge are never made public (not to say put under the carpet)? A case of "marketing communication asymmetry" ...)

Regarding my questions I observe that the pretty much identical cross-posts on Stack Overflow -- a place not really known for being exorbitantly friendly and uncritical -- received upvotes right away. So, not to receive any upvotes here "within the family" is far from being a very encouraging user experience to be honest.

Best regards, Guido

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

Daniel and Otto,

thank you both very much for answering my question.

As an afterthought: As long-time user ot Mathematica I am of course very observant with regard to patterns. I do note that for my last posts regarding WSM (e.g. unit checking, operator records, inheriting annotation for redeclared connectors) not a single post -- including the questions themselves -- I wrote has received any "likes" (the currency of the online society as we know it these days)! ;-)

Certainly, I could have improved upon my questions - I had forgotten to make the example complete in this case but in general I fail to see my questions being "stupid" or "of little interest". This very case has in fact been a report of a very legitimate "issue" with WSM as there should quite clearly have been inheritance. (I do unfortunately note that Wolfram makes great efforts to report about "features" while known issues to my knowledge are never made public (not to say put under the carpet)? A case of "Marketing communication asymmetrie ...)

Regarding my questions I observe that the pretty much identical cross-posts on Stack Overflow -- a place not really known for being exorbitantly friendly and uncritical -- received upvotes right away. So, not to receive any upvotes here "within the family" is far from being a very encouraging user experience to be honest.

Best regards, Guido

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

Group Abstract Group Abstract