首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用pyFMI获取/设置FMU的字符串

使用pyFMI获取/设置FMU的字符串
EN

Stack Overflow用户
提问于 2016-02-17 15:10:08
回答 1查看 358关注 0票数 1

我正在使用来自Modelon的pyFMI来在systemC和其他工具之间进行仿真,比如说openModelica。

我们尝试获取和设置string类型的输入,但似乎不支持它。我们在description.xml文件中拥有的内容:

代码语言:javascript
复制
<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日志,我们可以看到:

代码语言:javascript
复制
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的。

此外,如果我们试图设置字符串,则会获得以下错误:

代码语言:javascript
复制
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

有人知道为什么它似乎不被支持吗?还是计划得到支持?有什么办法让它起作用吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-17 21:17:37

正如您已经看到的,使用PyFMI (VersionWeb2.2)设置和获取字符串是不受支持的,不幸的是,也没有让它正常工作的诀窍。

不过,在下一个版本中,它将得到支持。如果使用开发版本(从源代码构建),这些特性已经实现并可用。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35460453

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档