Computational routine
eng


pevtdly

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.
 */
 
/* pevtdly Scicos Phase Modulator Event block
 * Type 2 simulation function ver 1.0 - scilab-3.0
 * 7 octobre 2003 - IRCOM GROUP - Author : A.Layec
 * 14 janvier 2005 : passage type4/rajout option
 */
 
/* REVISION HISTORY :
 * $Log$
 */
 
#include "scicos_block.h"
#include <math.h>
#define M_PI		3.14159265358979323846

/* Cette fonction de simulation calcul des instants de transistion
 * modulée en phase.
 * Entrées régulières : delta_{phi}
 * Sorties régulières : néant
 * Entrées évènementielles : instant de déclenchement
 * Sortie évènementielles : evout[0] : horloge fixe
 *                         evout[1] u tvec[2] : sortie modulée
 * paramères : rpar[0] : période de déclenchement
 *
 * nb : la mémoire z[0] est utilisée pour savoir sur quel port tvec[1]
 *     ou tvec[2] l'événement modulé doit être dirigé.
 */

/*prototype*/
void pevtdly(scicos_block *block,int flag)
{
 /*déclaration*/
 double T; /*période fixe*/
 double *u;
 /*récupération de l'adresse du port d'entrée*/
 u=(double *)block->inptr[0];

 /*récupération des paramètres*/
 T=block->rpar[0];
 
 /*le flag 3 calcul les dates de sorties*/
 if (flag==3)
 {
  /*calcul de l'horloge fixe.*/
  block->evout[0]=T;
  /*Test sur valeur d'entrée*/
  if (u[0]<(2*M_PI) && u[0]>-(2*M_PI))
  {
   /*test sur z[0]*/
   if(block->z[0]==0) /*si z[0]=1 alors calcul evout[1]*/
   {
    block->z[0]=1;
    block->evout[1]=T*(1+(u[0]/(2*M_PI)));
   }
   else /*sinon calcul tvec[2]*/
   {
    block->z[0]=0;
    block->evout[2]=T*(1+(u[0]/(2*M_PI)));
   }
  }
 }
}