无连接器执行初始化优先级

发布于 2025-02-05 09:31:57 字数 866 浏览 2 评论 0原文

是否可以在OpenModelica中执行模型的初始化优先级?例如,假设以下简单模型注册每个模型的名称和值:

function registerModel
  input String name;
  input Real value;
  external "C" registermodel_c(name, value) annotation(Library="registermodelicamodels");
end registerModel

function printRegistered
  external "C" printregistered_c() annotation(Library="registermodelicamodels");
end printRegistered

model a
  parameter Real n;
initial algorithm
  registerModel(getInstanceName(), n);
end a;

model b
  a a1(n=10);
  a a2(n=20);
  a a3(n=30);
end b;

model c
  b b1;
initial algorithm
  printRegistered();
end c;

假设PRINTREGISTREDED打印所有已注册的registermodel查询。现在,如果模型C被模拟,PRINTREGISTERDED将不会打印任何东西。是否有命令可以在b1内部执行初始算法模型c的部分。

PS使用连接器可能会解决该问题(不是首选),但我想知道是否还有其他方法可以解决此问题。

Is it possible to enforce the precedence of initialization of models in openModelica? For instance assume the following simple model that registers the name and value of each model:

function registerModel
  input String name;
  input Real value;
  external "C" registermodel_c(name, value) annotation(Library="registermodelicamodels");
end registerModel

function printRegistered
  external "C" printregistered_c() annotation(Library="registermodelicamodels");
end printRegistered

model a
  parameter Real n;
initial algorithm
  registerModel(getInstanceName(), n);
end a;

model b
  a a1(n=10);
  a a2(n=20);
  a a3(n=30);
end b;

model c
  b b1;
initial algorithm
  printRegistered();
end c;

Assume that printRegistered prints all the registered registerModel queries. Now if model c is simulated, printRegistered would not print anything. Is there a command to enforce initialization of b1 inside the initial algorithm section of model c.

p.s. using connectors might solve the issue (not prefered) but I wonder if there is any other way to tackle this problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文