cscilabxcos

How to pass simulation context into Scilab C block?


I have been developing my own function block in Scilab/Xcos on the C block basis and I have been struggling with passing parameters defined in the simulation context into the C code. Does anybody know how to do that? Thanks in advance for any ideas.


Solution

  • I have found functional solution. Let's say I have following parameters defined in the simulation context: T, RS, RR, LL, LM, pp, K. In case I place instance of the C block into the simulation and double click on it following window opens

    enter image description here

    Then I fill in the parameters which I want to pass into the C block instance (text field Real parameters vector). The parameters values are then accessible in the C language code inside the C block via block->rpar[0] (parameter Ts), block->rpar[1] (parameter RS), block->rpar[2] (parameter RR), block->rpar[3] (parameter LL), block->rpar[4] (parameter LM), block->rpar[5] (parameter pp), block->rpar[6] (parameter K)`.