为什么在重新声明时不继承连接器的图形注释?

Why are graphical annotations for connectors not inherited upon redeclaration?

我正在为 System Dynamics modeling which unlike the existing free library by Cellier 创建一个库,正在使用 非因果连接器。对于 "Flow" - 元素,我有一个 GenericFlow class 定义接口:

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;

洋红色 FlowPort 连接器声明为 replaceable - System Modeler 中的图标如下所示:

对于某些特殊情况,我将使用不同的端口,一个名为 SpecialFlowPort 连接器 ,显示为红色方块。举个例子,下面是一个名为 Outflow 的 class,它将重新声明用于其端口之一(即端口 A)的连接器 class:

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

它的图标会自动显示红色的 SpecialFlowPort 已经换成了 portA(在左边):

但是,当我在新模型中使用此组件(拖放)时,它会显示两个洋红色端口,将鼠标悬停在这些端口上时,System Modeler 会将 class 名称命名为 FlowPort - 不是 SpecialFlowPort:

虽然组件的行为是正确的,但洋红色 FlowPort 端口与 Outflow 所示的左侧端口的连接是被禁止的。

我是不是做错了什么?为什么在模型中使用时未显示重新声明的连接器的 class 的图形注释正确显示?

更新:

Wolfram MathCore 的 Otto Tronarp 正确 noted 上面的示例不完整,因为我没有包含图形注释(这通常使代码不可读,但在这种情况下非常重要)。

所以为了给出一个 SSCCE 我将在这里包括他的例子:

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; 

在 WSM 4.3 的模型图中使用此包中定义的 class Outflow 将显示错误的图形注释(例如,两个绿色而不是一个红色和一个绿色连接器)。

来自 Wolfram Community 上 Wolfram MatheCore 的人 posted 这是与 Wolfram System Modeler 5.1 版有关的问题:

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.