Computational routine
eng


dac

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.
 */
 
/* dac Scicos Digital to Analog Converter block
 * Type 4 simulation function ver 1.0 - scilab-3.0
 * 8 Mars 2006 - INRIA - Author : A.Layec
 */

/* REVISION HISTORY :
 * $Log$
 */

#include <scicos/scicos_block.h>
#include "modnum_lib.h"

/* Cette fonction de calcul réalise la convertion numérique analogique.
 *
 *
 * entrée régulière : u[0..nu-1] vecteur des entrées régulières à convertir
 * sortie régulière : y[0..ny-1] vecteur des sorties converties
 *
 * entrée évènementielle : Dates de déclenchement
 * sortie évènementeille : néant
 *
 * paramètre entier : ipar[0..nu-1]     : Nombre de bits de la valeur entière de sortie
 *                    ipar[nu..2*nu-1]  : flag code complément à 2
 *                                        0 : nombre entier non signé
 *                                        1 : nombre entier signé
 *
 * paramètre réel : rpar[0..nu-1]      : pas (ou quantum)
 *                  rpar[nu..2*nu-1]   : valeur minimale ou débute la conversion
 */

/*prototype*/
void dac(scicos_block *block,int flag)
{
  /*Déclaration des variables*/
  double *u,*y;

  int nu;

  int nbit;
  int cc2;

  double q;
  double vmin;

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

  /*Récupération de la taille du port d'entrée régulier*/
  nu=block->insz[0];

  /*Récupère le nombre de bit*/
  nbit=block->ipar[0];
  /*Récupère le type de code*/
  cc2=block->ipar[nu];

  /*Récupère le quantum*/
  q=block->rpar[0];
  /*Récupère la grandeur minimale d'entrée*/
  vmin=block->rpar[nu];

  /*Appel routine dacv_c*/
  dacv_c(&nu,&nbit,&cc2,&q,&vmin,&u[0],&y[0]);
}