Computational routine
eng


convps

File content


/* Modnumlib Scicos interfacing function
 * Copyright (C) 2009-2011 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.
 */
 
/* convsp Scicos Convertisseur parralèle série
 * Type 2 simulation function ver 1.0 - scilab-2.6&2.7
 * 21 décembre 2003 - IRCOM GROUP - Author : A.Layec
 */

 /* REVISION HISTORY :
 * $Log$
 */

#include "machine.h"

/* Cette fonction réalise la conversion "parallèle-série". Le vecteur d'entrée de taille
 * nu est lu périodiquement par pas de 1 block.
 *
 * entrées régulières : u[0..nu-1] : vecteur d'entrée de taille nu
 * sorties régulières : y[0] : vecteur de sortie de taille 1
 * état discret : z[0] : compteurs échantillons
 */

/*prototype*/
void convps(flag,nevprt,t,xd,x,nx,z,nz,tvec,ntvec,rpar,nrpar,
            ipar,nipar,inptr,insz,nin,outptr,outsz,nout)

int *flag,*nevprt,*nx,*nz,*ntvec,*nrpar,ipar[],*nipar,insz[],*nin,outsz[],*nout;
double x[],xd[],z[],tvec[],rpar[];
double *inptr[],*outptr[],*t;
{
  /*Déclaration*/
  double *y;
  double *u;

  /*Récupération des adresses des ports réguliers*/
  y=(double *)outptr[0];
  u=(double *)inptr[0];

  /*Uniquement sur flag 1*/
  if(*flag==1)
  {
   /*Test valeur compteur échantillons*/
   if((int)z[0]==insz[0])
   {
    /*lit position 0*/
    y[0]=u[0];
   }
   else
   {
    /*Lit position z[0] de u[]*/
    y[0]=u[(int)z[0]];
   }
  /*fprintf(stderr,"insz[0]=%d, a=%d, u[a]=%f, y[0]=%f\n", insz[0],a, u[a],y[0]);*/
  }
  else if(*flag==2)
  {
   /*Test valeur compteur échantillons*/
   if((int)z[0]==insz[0])
   {
    /*RAZ compteur*/
    z[0]=1.;
   }
   else
   {
    /*Incrémente compteur*/
    z[0]++;
   }
  }
}