首页 > 解决方案 > 从 Modelica 类中读取/设置 Dymola 标志

问题描述

我有一个调用外部 C 函数的 Modelica 函数。目前,我只能使用设置运行它Advanced.CompileWith64 = 2

我想以Advanced.CompileWith64在调用外部函数之前将标志设置为值 2 的方式包装此函数,然后将其设置为其原始值。

从概念上讲,是这样的:

function myFunctionWithWrapper
  ...
algorithm
  originalFlagValue := readFlag(CompileWith64)
  setFlag(CompileWith64, requiredFlagValue) "set Advanced.CompileWith64 = 2"
  myExternalFunction(...)
  setFlag(CompileWith64, originalFlagValue)
end myFunctionWithWrapper

有没有办法从 Modelica 类中读取和设置 Dymola 标志?

标签: modelicadymola

解决方案


在带有注释的函数中,__Dymola_interactive=true您可以使用它们的常规路径简单地访问这些标志。

function setFlag

protected 
  Integer old_val;

algorithm 

  old_val :=Advanced.CompileWith64;
  Advanced.CompileWith64 :=2;
  // do something
  Advanced.CompileWith64 :=old_val;

  annotation(__Dymola_interactive=true);
end setFlag;

推荐阅读