[Scilab-users] Generic_block3

pepe peter.balazovic at yahoo.com
Wed Feb 20 12:13:32 CET 2013


Hello,

I want to find out how to use correctly generic_block3. I am using C
function within this block as follow

#include "scicos_block4.h" 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
 
#define r_IN(n, i)    ((GetRealInPortPtrs(blk, n+1))[(i)]) 
#define r_OUT(n, i)   ((GetRealOutPortPtrs(blk, n+1))[(i)]) 
// inputs 
#define in1      (r_IN(0,0))         // integrator input 
#define in2      (r_IN(1,0))         // integrator input 

// states 
#define X1       (GetState(blk)[0])          // integrator state 
#define X2       (GetState(blk)[1])          // integrator state
 
#define Xdot1    (GetDerState(blk)[0])       // derivative of the integrator
output 
#define Xdot2    (GetDerState(blk)[1])       // derivative of the integrator
output 

// outputs 
#define out1     (r_OUT(0, 0))       // integrator output 
#define out2   (r_OUT(1, 0))       // integrator gain 

void myC_block(scicos_block *blk, int flag)  
{ 
 
  switch (flag) 
    { 
    case DerivativeState: 
      Xdot1 =  in1;
      Xdot2 =  in1;
      break; 
 
    case OutputUpdate:
     out1 = X1;
     out2 = X2;
     break; 
   } 
 }
This C function runs correctly within block.

If I change e.g. output declaration as follow

#define Y			((SCSREAL_COP *)GetRealOutPortPtrs(blk, 1))

and used as

Y[0] //first output
Y[1]  //second output

then the function compiles and runs under xcos but there is warning and
output is always zero.

warning:
scicosim error: Type not yet supported for outtb.

Do you have any advice what can be wrong? How to use and handle
inputs/outputs/states etc... correctly within C-function?

Thank you!

Peter




--
View this message in context: http://mailinglists.scilab.org/Generic-block3-tp4025973.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list