Dymola 中的库启动脚本 [英] Library Startup Skript in Dymola

查看:64
本文介绍了Dymola 中的库启动脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Dymola,我正在寻找一种在加载库时自动执行脚本的方法.目的是使用 defineUnitConversion() 命令定义附加的 displayUnit,这些命令特定于加载的库.我仍然认为在其他一些情况下这可能会有所帮助.

Using Dymola, I'm looking for a way to automatically execute a script when loading a library. The intention is to define additional displayUnits using the defineUnitConversion() command, which are specific to the library that is loaded. Still I think there are quite some other cases where this could be helpful.

我在这方面的发现:

  • 我知道可以向 DymolaInstallDir/insert/displayUnits.mos 中的文件添加转换,但这带来了必须在每台新计算机上或在Dymola 的更新.我想避免这种情况.
  • 除此之外,我只找到了 libraryinfo.mos 文件,该文件似乎是在 Dymola 启动期间读取的.因此,我认为这不是放置转换的正确位置,因为它包含有关库的一般信息,并且应该只包含相应的函数.
  • I know that it is possible to add conversions to the file in DymolaInstallDir/insert/displayUnits.mos but this comes with the disadvantage that is has to be done again on every new computer or after an update of Dymola. I would like to avoid this.
  • Other than that I only found the libraryinfo.mos file, which seems to be read during the start-up of Dymola. Therefore I assume it is not the right place to put the conversions, as it contains general information about the library and should only contain the respective functions.

推荐答案

Dymola 2022 有一个新的(特定于工具的)功能,正好涵盖了这个用例.Dymola 2022 版本中提到了它库启动脚本"部分中的注释第 24 页.

Dymola 2022 has a new (tool-specific) feature that covers exactly this use-case. It is mentioned in the Dymola 2022 release notes in the section "Library startup script" on page 24.

它基本上引入了一个新的注释,它允许指定一个 .mos 脚本的路径,该脚本在加载相应的库时执行.以下是发行说明中的​​示例:

It basically introduces the a new annotation, which allows to specify a path to a .mos script, which is executed, when the respective library is loaded. Here is the example from the release notes:

package ThisPack
 annotation(__Dymola_startup =
 "modelica://ThisPack/Resources/Scripts/Dymola/startup.mos");
end ThisPack;

也可以通过 UI 设置注释...

The annotation can also be set via the UI...

这篇关于Dymola 中的库启动脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆