0

I need to run the control model from xcos (Scilab) in my application.

So, a control-algorithm engineer can develop her control models and test them in the visual environment of xcos. The developed model could be directly incorporated into the application.

How to load and run a xcos model inside my python application? The documentation is very poor.

Daniel
  • 36,007
  • 3
  • 31
  • 64
Skarab
  • 6,511
  • 11
  • 44
  • 81

1 Answers1

1

Run scicos model

I have not a lot of experience with XCOS. But you could try something as mentioned in scicos_simulate documentation.

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

Start scilab with script

You could make a Scilab script that runs the model and call Scilab with the script. See also calling-an-external-command-in-python

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

Calls from Python

There is also a kind of python api for scilab calls, so you might use that.

Community
  • 1
  • 1
spoorcc
  • 2,639
  • 2
  • 17
  • 26