0

我需要在我的应用程序中从xcos ( Scilab ) 运行控制模型。

因此,控制算法工程师可以开发她的控制模型并在 xcos 的可视化环境中对其进行测试。开发的模型可以直接合并到应用程序中。

如何在我的 python 应用程序中加载和运行xcos模型?文档很差。

4

1 回答 1

1

运行 sccos 模型

我对 XCOS 没有太多经验。但是您可以尝试scicos_simulate 文档中提到的方法。

importXcosDiagram("SCI/modules/xcos/demos/batch_simulation.zcos")

typeof(scs_m) //The diagram data structure

//This diagram uses 3 context variables : 
//  Amplitude : the sin function amplitude
//  Pulsation : the sin function pulsation
//  Tf        : the final simulation time
scs_m.props.context; //the embedded definition

//first batch simulation with the parameters embedded in the diagram 
scicos_simulate(scs_m);
// Change the final time value
Context.Tf=10;
scicos_simulate(scs_m,Context);
// without display
Context.Tf=10;
Context.Pulsation=9;
scicos_simulate(scs_m,list(),Context,'nw');
//get the variable created by the "from workspace block"
counter

用脚本启动 scilab

您可以制作一个运行模型的 Scilab 脚本并使用该脚本调用 Scilab。另请参阅调用-an-external-command-in-python

from subprocess import call
call(["scilab", "-f run_my_xcos.sci"])     

来自 Python 的调用

还有一种用于 scilab 调用的 python api,所以你可以使用它。

于 2014-07-02T12:01:53.553 回答