Computational routine
eng
z_buft
/* 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.
*/
/* z_buft Scicos discrete event memory block
* Type 2 simulation function ver 1.0 - scilab-2.6&2.7
* 7 Avril 2004 - IRCOM GROUP - Author : A.Layec
* 4 Mai 2005 : passage type 4
*/
/* REVISION HISTORY :
* $Log$
*/
#include "scicos_block.h"
/* Cette fonction de simulation est un buffer qui mémorise
* les dates de déclenchement dans le vecteur des états discrets z
* si le paramètre entier ipar[1] est placé à 1 alors la
* fonction calcul les écarts temporels entre chaques activation
*
* entrée régulière : néant
* sortie régulière : néant
* entrée évènementielle : Date de déclenchement
* sortie évènementielle : néant
*
* état discret : z[0..n-1] : mot mémoire
* z[n] : date d'activatation précédente
* z[n+1] : compteur échantillon
* paramètre entier : ipar[0] : longueur du mot mémoire (n)
* ipar[1] : option : 1 : auto-calcul du jitter period
*/
/*prototype*/
void z_buft(scicos_block *block,int flag)
{
/*déclaration des variables*/
int j,n;
double t;
/*le flag 2 mémorise t dans z[]*/
if(flag==2)
{
/*récupération de la longeur du mot mémoire*/
n=block->ipar[0];
/*récupère valeur du compteur échantillons*/
j=(int)block->z[n+1];
/*récupère la date d'activation*/
t=get_scicos_time();
/*met en mémoire dans z ou calcule la période jitter*/
if (block->ipar[1]==1)
block->z[j]=t-block->z[n];
else
block->z[j]=t;
/*met en mémoire la date d'activation*/
block->z[n]=t;
/*incrémente compteur échantillons*/
j++;
/*Test valeur compteur échantillons*/
if(j>=n) j=0;
/*mémorise compteur dans z[n+1]*/
block->z[n+1]=(double)j;
}
}