- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
最佳答案
Dymola 为模型文档动态生成此信息,但我不知道有什么方法可以检索它。
ModelManagement
库(随 Dymola 一起提供并包含在标准许可证中)允许从加载的类中提取此类信息。但是,使用起来有点痛苦。问题是这个库中的大多数函数只分析类的确切代码——不考虑扩展类。因此,您必须自己循环扩展类。
下面是一个示例,它试图获取类的所有组件定义,包括从扩展类继承的组件定义。对于每个组件,都会返回一个具有多个属性的字典,这对应于 Dymola 中的记录 ModelManagement.Structure.AST.ComponentAttributes
。它包含组件名称、描述、可变性、前缀 input
和 output
等信息。
因此,对于您的示例类 Modelica.Math.sin
,可以使用字典键 isOutput
和 isInput
轻松识别输入和输出。
但请注意,这不适用于像 Modelica.Blocks.Interfaces.RealInput
这样的 block 的输入和输出连接器 - 以及像电针这样的因果连接器。你必须自己实现一些东西来识别那些。
下面的代码只是使用固定的类路径来列出 Modelica.Blocks.Continuous.Integrator
的所有输入和输出连接器。此外,它还输出所有参数。
import pprint
from dymola.dymola_interface import DymolaInterface
def get_extends(dym, c):
""" return a list with all extended classes (including inherited extends) """
extends = dym.ExecuteCommand(f'ModelManagement.Structure.AST.ExtendsInClassAttributes("{c}")')
for e in extends.copy():
sub_extends = get_extends(dym, e['fullTypeName'])
# only add sub-extends if they are not already in the list
for s in sub_extends:
if not any(s['fullTypeName'] == tmp_e['fullTypeName'] for tmp_e in extends):
extends.append(s)
return extends
def get_components(dym, c):
""" return a list with all components in a class (including inherited ones )"""
# get components defined in the class itself
comp = dym.ExecuteCommand(f'ModelManagement.Structure.AST.ComponentsInClassAttributes("{c}")')
# get components defined in extended classes itself
for e in get_extends(dym, c):
comp.extend(dym.ExecuteCommand(
f'ModelManagement.Structure.AST.ComponentsInClassAttributes("{e["fullTypeName"]}")'))
return comp
if __name__ == '__main__':
modelica_class = 'Modelica.Blocks.Continuous.Integrator'
# get all components in the model
dymola = DymolaInterface(showwindow=False)
components = get_components(dymola, modelica_class)
dymola.close()
# extract inputs and parameters
inputs = ['Modelica.Blocks.Interfaces.RealInput', 'Modelica.Blocks.Interfaces.BooleanInput',
'Modelica.Blocks.Interfaces.BooleanInput']
inputs = [c for c in components if c['fullTypeName'] in inputs]
parameters = [c for c in components if c['variability'] == 'parameter']
print('-------- inputs ------------')
pprint.pprint(inputs)
print('\n\n-------- parameters ------------')
pprint.pprint(parameters)
关于python - 从 python 脚本重现 Dymola 信息层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58627324/
这是在 https://stackoverflow.com/questions/12639454/make-scalacheck-tests-deterministic 中作为“奖金问题”提出的,但没
我的项目使用 Angular 6 和 Leaflet 1.2。 我想重现当用户在 Leaflet map 上保持右键或左键单击时的拖动效果。例如,我希望在不断按下空格键时能够开始拖动 map 。 我已
我们正在将我们的用户身份验证从提供的 .NET 实现迁移到我们自己的系统。 我们希望能够支持存在于 aspNet_Membership 表中的旧密码。 Password 和 Salt 位于该表中,因此
我有一个二进制文件,它在 99% 的时间里都运行良好。有时,我无法理解,它会因这个输出而崩溃。在我重新启动之后,一切正常。 二进制是一个模板系统。它读取了一些带有占位符的模板,例如{%foo%} 或
我试图在 c 中重现 strcpy 的行为,我的问题是该函数有效但它在末尾附加了额外的东西。 char *ft_strcpy(char * dst, const char * src) { in
我最近遇到了可怕的 UserPreferenceChanged 事件 UI 卡住问题,随后我解决了可能的原因,例如: 调用单个控件而不是主应用程序表单(参见 https://stackoverflow
在 Scala 编程中,我可以读到 ==运算符的行为就像是这样定义的: final def == (that: Any): Boolean = if (null eq this) {null eq t
我正在和我的 friend 一起开发 Django 项目。该项目依赖于一些 python 模块。我在 virtualenv 中安装了 django 和其他依赖项。 django 项目的代码位于一个存储
关于spark的大多数问题都使用show作为代码示例,没有生成数据帧的代码,如下所示: df.show() +-------+--------+----------+ |USER_ID|locatio
我正在尝试重现 java.lang.OutOfMemoryError: unable to create new native thread但是使用 -Xss VM 参数。我猜想如果我们有大量线程,并
我正在尝试在自定义 alertView 中插入表格 View 。我需要实现与默认警报相同的样式。从 Debug View Hierarchy 我几乎复制了样式,但我无法弄清楚 Apple 如何设置模糊
标准是否保证如果 std::mt19937 被相同的数字播种,它会在所有平台上产生相同的数字序列? 换句话说,它的实现是否由标准明确定义,或者像 std::rand() 一样被视为实现细节? 最佳答案
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的
我有一个网站可以从 BingPreview/1.0b* 获得访问,这很可能是 Bing 的机器人。 我收到一个错误,它似乎无法找到我非常确定应该存在的 DOM 元素。我没有从任何其他浏览器(在所有主要
有谁知道如何重现 new Notes new scanning feature在 iOS 11 中?? AVFoundation 是否用于相机? 摄像头如何检测纸张/文档/卡片的形状? 他们如何实时放
您好! 作为使用 Objective-C 开发 iPhone 应用程序的初学者,我想知道重新创建 iPhone SMS 应用程序 UI(带有消息气泡等的用户界面)的最简单方法是什么 我考虑过将 UIT
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: How can the built-in range function take a single argu
虽然这很可能是我自己犯的错误,但有人可以帮助我。我有一个包含 6 个数据点的极坐标图,在绘制时仅显示 5 个数据点。如果这是一个问题,我会在 GitHub 上打开 1,但我在想,如果它归结于我糟糕的代
我正在尝试使用 rCharts 重现简单的示例绘图库 sankey图表。我发现this example from scratch并尝试重现它,但是,我遇到了一些问题。 首先,我尝试在没有任何内容的情况
进入 Haskell,我试图重现 numpy's reshape 之类的东西与列表。具体来说,给定一个平面列表,将其 reshape 为一个 n 维列表: import numpy as np a =
我是一名优秀的程序员,十分优秀!