/* 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_buf Scicos discret memory block * Type 4 simulation function ver 1.0 - scilab-3.0 * 17 janvier 2005 - IRCOM GROUP - Author : A.Layec * 29 mars 2007 - INRIA - Author : A.Layec * Révision */ /* REVISION HISTORY : * $Log$ */ #include "scicos_block.h" /* Cette fonction de simulation est un buffer * qui mémorise la valeur de son entrée régulière * dans le vecteur des états discrets z * * entrée régulière : u[0..nu-1] * sortie régulière : néant * entrée évènementielle : Date de déclenchement * sortie évènementielle : néant * * état discret : z[0..ipar[0]-1] : mot mémoire * z[ipar[0]] : compteur * paramètre entier : ipar[0] : taille du mot mémoire */ /*prototype*/ void z_buf(scicos_block *block,int flag) { /*déclaration des variables*/ int i,j; /*seulement sur flag 2*/ if(flag==2) { /*récupère valeur du compteur échantillons*/ j=(int)block->z[block->ipar[0]]; /*Test valeur compteur échantillons*/ if (j+block->insz[0]<block->ipar[0]) { /*met en mémoire la(les) valeur(s) du port réguliers*/ for(i=0;i<block->insz[0];i++) { block->z[j+i]=block->inptr[0][i]; } /*incrémente compteur échantillons*/ j=j+block->insz[0]; } else { /*met en mémoire à la fin du buffer*/ for(i=0;i<block->ipar[0]-j;i++) { block->z[j+i]=block->inptr[0][i]; } /*met en mémoire au début du buffer*/ for(i=block->ipar[0]-j;i<block->insz[0];i++) { block->z[j+i-block->ipar[0]]=block->inptr[0][i]; } /*met à jour compteur échantillons*/ j=block->insz[0]-block->ipar[0]+j; } /*mémorise compteur dans z[n+1]*/ block->z[block->ipar[0]]=j; } }