Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

modulator.h

00001 /***************************************************************************
00002                           modulator.h  -  description
00003                              -------------------
00004     begin                : Mon Aug 11 2000
00005     copyright            : (C) 2000 by Michael Peeters
00006     email                : Michael.Peeters@vub.ac.be
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef MODULATOR_H
00019 #define MODULATOR_H 
00020 
00021 #include "numerictypes.h"
00022 #include "numerictraits.h"
00023 #include "vectorfunction.h"
00024 #include "timeframe.h"
00025 #include "parameter.h"
00026 #include "cycler.h"
00027 #include "ticktock.h"
00028 #include <string>
00029 
00030 namespace MODEL {
00031 
00032   class TimeFrame;
00033   
00045   class Modulator : public TickTock {
00046   public:
00047         template<integer dims, typename nelem, class NT  >
00048         Modulator(TimeFrame&
00049                           T,VectorFunction<dims,nelem,NT> & v, string param)
00050           : TickTock(T,T.get_dt()) // a modulator has the same resolution !
00051         {
00052           Parameter p=v.get_parameter(param);
00053           _p=&p;
00054         }
00055 
00057         virtual void tick() {(*_p)=modulate();}
00058 
00060         virtual number modulate(void)=0;
00061         
00062   private:
00063         number* _p;
00064 
00065   };
00066 
00067   //--------------------------------------------------------------------------------
00068 
00070   class LinearMod : public Modulator{
00071   public:
00072         template<integer dims, typename nelem, class NT  >
00073         LinearMod( TimeFrame& T,
00074                            VectorFunction<dims,nelem,NT>& v, 
00075                            string param,
00076                            number start,number end, 
00077                            time from, time until ) : 
00078           Modulator(T,v,param), 
00079           st(start), 
00080           en(end), d(en-st), f (from), u(until/2.),du(u-f) {}
00081 
00082         virtual number modulate();
00083           
00084   private:
00085         number st;
00086         number en;
00087         number d;
00088         time f;
00089         time u;
00090         time du;
00091   };
00092 
00093   //--------------------------------------------------------------------------------
00096   class BlockMod : public Modulator{
00097   public:
00098         template<integer dims, typename nelem, class NT  >
00099         BlockMod( TimeFrame& T,
00100                            VectorFunction<dims,nelem,NT>& v, 
00101                            string param,
00102                            number low,number high, 
00103                            time period) : 
00104           Modulator(T,v,param), 
00105           l(low), h(high), p(period){}
00106 
00107         virtual number modulate(void);
00108           
00109   private:
00110         number l;
00111         number h;
00112         time p;
00113   };
00114 
00115   //-------------------------------------------------------------------------------
00118   class StepMod : public Modulator {
00119   public:
00120         template<integer dims, typename nelem, class NT  >
00121         StepMod( TimeFrame& T,
00122                          VectorFunction<dims,nelem,NT>& v, 
00123                          string param,
00124                          number start,number end, 
00125                          time at) 
00126           : Modulator(T,v,param), st(start), en(end), a (at) {}
00127 
00128         virtual number modulate();
00129 
00130   private:
00131         number st;
00132         number en;
00133         time a;
00134   };
00135 
00136   // ------------------------------------------------------------
00137 
00142   class TriangleFadeMod : public Modulator{
00143   public:
00144         template<integer dims, typename nelem, class NT  >
00145         TriangleFadeMod( TimeFrame& T,
00146                            VectorFunction<dims,nelem,NT>& v, 
00147                            string param,
00148                            number start,number end, 
00149                            time period, number deltapar, integer stay) : 
00150           Modulator(T,v,param), 
00151           st(start), 
00152           en(end), d(en-st), p(period), dp (deltapar), s(stay),cs(1) 
00153         { last_t=get_time(); in_t=0; }
00154 
00155         virtual number modulate();
00156           
00157   private:
00158         number st;
00159         number en;
00160         number d;
00161         time p ;
00162         number dp ;
00163         integer s;
00164 
00165         integer cs;
00166         time last_t;
00167         time in_t;
00168         
00169   };
00170 
00171 
00172 } // end namespace
00173 #endif
00174 
00175 /*********************************************************************
00176 $Id: modulator.h,v 1.1 2001/05/22 10:54:55 mpeeters Exp $
00177 **********************************************************************
00178 
00179 $Log: modulator.h,v $
00180 Revision 1.1  2001/05/22 10:54:55  mpeeters
00181 Moved sources and headers for libModel to model/ subdirectory, in an attempt to rationalize the source tree. This should make things "netter".
00182 
00183 Revision 1.2  2000/09/15 10:26:31  mpeeters
00184 Cleaned out header and added CVS tails to files, removed superfuous
00185 @author comments, inserted dates
00186 
00187 *********************************************************************/

To get the sources or tarballs, please go to SourceForge or you can use the CVS repository.

More Info? Michael Peeters. Also, check our research website: www.alna.vub.ac.be

Last update: June 2002.


Looking for Open Source? Check out SourceForge Logo !