如何拥有可替换类型的因果连接器?

How to have a causal connector with a replaceable type?

虽然 Advanced Modelica Tutorial: Developing Modelica Libraries 来自 2003 年,但我仍然相信第 29 页的代码会给出 connector (RealPort) 和 replaceable type 的因果关系:

connector RealPort
  replaceable type SignalType = Real;
  extends SignalType;
end RealPort;

虽然此代码适用于 Wolfram SystemModeler 的当前版本,但 Open Modelica v1.16.0-dev.03 (64-bit) 抱怨并给出以下错误:

Class 'SignalType' in 'extends SignalType' is replaceable, the base class name must be transitively non-replaceable.

那么,关于传递不可替换性,谁是正确的?如何正确地做到这一点?

参考文献:

上面的 class 不是传递不可替换的,因此翻译应该失败。

不可替换规则意在避免的问题是一组模型如:

connector RealPort
  replaceable type SignalType = Real;
  extends SignalType;
end RealPort;

type MySignal
  type SignalType=Integer;
  extends Real(...);
end MySignal;

connector MyPort=RealPort(redeclare type SignalType=MySignal);

那些 classes 的问题是 MyPort 中的 SignalType 似乎同时是两个东西,并且不清楚问题是在哪里引入的,因为重新声明似乎与约束 class 和原来的 class 看起来不错。

(传递只是意味着你可以有中间不可替换的 classes 来混淆事情。)

A​​drian Pop 的解决方案是一个很好的解决方案。