edgetrig.c

Go to the documentation of this file.
00001 #include "scicos_block.h"
00002 #include <math.h>
00003 #include "sciprint.h"
00004 
00005 void edgetrig(scicos_block *block,int flag)
00006 {
00007   double z= block->z[0],u=block->inptr[0][0];
00008   if(flag==2||flag==6){
00009     block->z[0]=u;
00010   }else if(flag==1){
00011     if(block->ipar[0]!=0){
00012       z=z*block->ipar[0];
00013       u=u*block->ipar[0];
00014       if(((z<=0)&(u>0))||((z<0)&(u>=0))) {
00015         block->outptr[0][0]=1.;
00016       }else{
00017         block->outptr[0][0]=0.;
00018       }
00019     } else{ /* rising and falling edge */
00020       if(((z<=0)&(u>0))||((z<0)&(u>=0))||((z>0)&(u<=0))||((z>=0)&(u<0))){
00021         block->outptr[0][0]=1.;
00022       }else{
00023         block->outptr[0][0]=0.;
00024       }
00025     }
00026   }else if (flag==4) {
00027     if (block->ng>0){
00028       set_block_error(-1);
00029       sciprint("Trigger block must have discrete time input.");
00030       return;
00031     }
00032   }
00033 }

Generated on Sun Mar 4 15:03:59 2007 for Scilab [trunk] by  doxygen 1.5.1