modelica - 从 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 标志?
解决方案
在带有注释的函数中,__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;
推荐阅读
- flutter - 颤动中带有同步融合的烛台
- java - 从第一个大写字母拆分字符串
- performance - 如何将入站流量解锁到elasticsearch(7.8)
- javascript - 元素隐式具有“任何”类型,因为“字符串”类型的表达式不能用于索引类型“BGColors”
- github-actions - 在 GitHub Actions 中捕获标准错误
- python - PySpark:管道失败,出现“java.util.NoSuchElementException:Param generateMissingLabels 不存在”。
- laravel - 类 Illuminate\Support\Collection 的对象无法在 Laravel 8 中转换为 int
- javascript - 在for循环中使用innerText,这在javascript中不起作用
- reactjs - 图表中的小数到 toFixed()
- matlab - 为什么这个程序(对于两个矩阵的乘积)不起作用?