surecht
/* Modnumlib Scicos interfacing function
* Copyright (C) 2009 Alan Layec
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* surecht Scicos temporal oversamplig and zero insert block
* Type 4 simulation function ver 1.0 - scilab-3.0
* 21 décembre 2004 Author : - IRCOM GROUP - A.Layec
*/
/* REVISION HISTORY :
* $Log$
*/
#include "modnum_lib.h"
#include "scicos_block.h"
/* Entrée régulière : signal à surechantilonner
* Sortie régulière : signal suréchantilonné
* Entrée évènementielle : néant
* Sortie évènementielle : néant
*
* Paramètres entier : insz[0] : taille du vecteur en entrée
* ipar[0] : nombre d'échantillons
* ipar[1] : option
* 0/1 : traitement séquentiel
* 2/3 : traitement vectoriel
* 0/2 : pas d'insertion de zéro
* 1/3 : insertion zéro
*
* état discret : z[0] : valeur initiale du numéro échantillons
*/
/*prototype*/
void surecht(scicos_block *block,int flag)
{
/*déclaration des variables*/
double *y;
double *u;
int i,opt,nu,nech,ny;
int mu=1;
int counter;
/*Récupération des adresses des ports réguliers*/
y=(double *)block->outptr[0];
u=(double *)block->inptr[0];
/*récupération du nombre d'échantillons*/
nu=block->insz[0];
nech=block->ipar[0];
ny=block->outsz[0];
opt=block->ipar[1];
/* Le flag 1 teste la valeur du compteur échantillon
* et délivre u[] dans y[] quand le compteur
* arrive à la valeur ipar[0]
*/
if(flag==1)
{/*Vector*/
if (opt==2||opt==3)
{
opt=opt-2;
counter=(int)block->z[0];
/*Appel routine surecht_c*/
surecht_c(&opt,&nu,&mu,&nech,&counter,&u[0],&y[0]);
}
/*scalar*/
else if(opt==0)
{
/*si z[]=ipar[0] y[]=u[]*/
if((int)block->z[0]==nech)
{
block->z[0]=1; /*RAZ compteur*/
for(i=0;i<block->insz[0];i++) y[i]=u[i];
}
/*si z[]!=ipar[0] y[]=0*/
else
{
for(i=0;i<block->insz[0];i++) y[i]=0;
block->z[0]++; /*incrémente compteur*/
}
}
else if(opt==1)
{
for(i=0;i<block->insz[0];i++) y[i]=u[i];
}
}
}