我正在使用来自Modelon的pyFMI来在systemC和其他工具之间进行仿真,比如说openModelica。
我们尝试获取和设置string类型的输入,但似乎不支持它。我们在description.xml文件中拥有的内容:
<ScalarVariable name="clock_timescale" valueReference="0" description="timescale of the internal clock manager" causality="parameter" variability="fixed" initial="exact">
<String start ="NS" />
</ScalarVariable>
<ScalarVariable name="clock_period" valueReference="4" description="period of the internal clock manager" causality="parameter" variability="fixed" initial="exact">
<Integer start ="20" />
</ScalarVariable>在这个示例中,clock_period是整数,clock_timescale是字符串。如果我们快速查看pyfmi日志,我们可以看到:
FMIL: module = Model, log level = 4: [logFmiCall][FMU status:OK]
fmi2GetInteger: clock_period = 20
FMIL: module = Model, log level = 4: [logFmiCall][FMU status:OK]
fmi2GetInteger: number_isready = 0
FMIL: module = Model, log level = 4: [logFmiCall][FMU status:OK]
fmi2GetInteger: number_port = 0
FMIL: module = Model, log level = 4: [logFmiCall][FMU status:OK]
fmi2GetInteger: result_port = 0
FMIL: module = Model, log level = 4: [logFmiCall][FMU status:OK]
fmi2GetInteger: result_isready = 0
FMIL: module = Model, log level = 4: [logFmiCall][FMU status:OK]
fmi2GetBoolean: reset = true
FMIL: module = Model, log level = 4: [logFmiCall][FMU status:OK]
fmi2DoStep: currentCommunicationPoint = 0 communicationStepSize=20, noSetFMUStatePriorToCurrentPoint =1, internal time=0我们可以看到,clock_period的getter是在fmi2doStep之前正确调用的,而不是clock_timescale的。
此外,如果我们试图设置字符串,则会获得以下错误:
Traceback (most recent call last):
File "coordinator.py", line 56, in <module>
model.set_string([0],['MS'])
File "fmi.pyx", line 3555, in pyfmi.fmi.FMUModelBase2.set_string (src/pyfmi/fmi.c:31090)
NotImplementedError有人知道为什么它似乎不被支持吗?还是计划得到支持?有什么办法让它起作用吗?
谢谢
发布于 2016-02-17 21:17:37
正如您已经看到的,使用PyFMI (VersionWeb2.2)设置和获取字符串是不受支持的,不幸的是,也没有让它正常工作的诀窍。
不过,在下一个版本中,它将得到支持。如果使用开发版本(从源代码构建),这些特性已经实现并可用。
https://stackoverflow.com/questions/35460453
复制相似问题