/* 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_buft41 Scicos discrete event memory block * Type 4 simulation function ver 1.0 - scilab-4.1 * 31 Mars 2007 - INRIA - Author : A.Layec */ /* REVISION HISTORY : * $Log$ */ #include "scicos_block.h" #include "machine.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] : compteur échantillon * z[1] : date d'activation précédente * z[2..2+n-1] : mot mémoire * * paramètre entier : ipar[0] : longueur du mot mémoire (n) * ipar[1] : option : 1 : calcul du jitter period */ /*prototype*/ void z_buft41(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[0]; /*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[2+j]=t-block->z[1]; } else { block->z[2+j]=t; } /*met en mémoire la date d'activation*/ block->z[1]=t; /*incrémente compteur échantillons*/ j++; /*Test valeur compteur échantillons*/ if(j==n) j=0; /*mémorise compteur dans z[n+1]*/ block->z[0]=(double)j; } }