[Scilab-users] Generic_block3

Clément David clement.david at scilab-enterprises.com
Wed Feb 20 16:26:51 CET 2013


Hello Peter,

To get the first output port, use GetRealOutPortPtrs(blk, 1) and to get
the second, use GetRealOutPortPtrs(blk, 2).

In your current code, you might access the first and second element of
the first input port. For more information take a look at the
documentation [1].

[1]: http://help.scilab.org/docs/5.4.0/en_US/C_struct.html

Regards,

> #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.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-- 
Clément DAVID
Development Engineer / Account Manager
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Mobile: +33.6.26.26.51.90
Phone: +33.2.90.22.78.96
http://www.scilab-enterprises.com




More information about the users mailing list