edgetrig.c File Reference

#include "scicos_block.h"
#include <math.h>
#include "sciprint.h"

Include dependency graph for edgetrig.c:

Go to the source code of this file.

Functions

void edgetrig (scicos_block *block, int flag)


Function Documentation

void edgetrig ( scicos_block block,
int  flag 
)

Definition at line 5 of file edgetrig.c.

References scicos_block::inptr, scicos_block::ipar, scicos_block::ng, scicos_block::outptr, sciprint(), set_block_error(), scicos_block::z, and z.

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 }

Here is the call graph for this function:


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