Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

proportional_integral_controller.h

Go to the documentation of this file.
00001 /*
00002 Arroyo - software for the simulation of electromagnetic wave propagation
00003 through turbulence and optics.
00004 
00005 Copyright (c) 2000-2004 California Institute of Technology.  Written by
00006 Dr. Matthew Britton.  For comments or questions about this software,
00007 please contact the author at mbritton@astro.caltech.edu.
00008 
00009 This program is free software; you can redistribute it and/or modify it
00010 under the terms of the GNU General Public License as  published by the
00011 Free Software Foundation; either version 2 of the License, or (at your
00012 option) any later version.
00013 
00014 This program is provided "as is" and distributed in the hope that it
00015 will be useful, but WITHOUT ANY WARRANTY; without even the implied
00016 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  In no
00017 event shall California Institute of Technology be liable to any party
00018 for direct, indirect, special, incidental or consequential damages,
00019 including lost profits, arising out of the use of this software and its
00020 documentation, even if the California Institute of Technology has been
00021 advised of the possibility of such damage.   The California Institute of
00022 Technology has no obligation to provide maintenance, support, updates,
00023 enhancements or modifications.  See the GNU General Public License for
00024 more details.
00025 
00026 You should have received a copy of the GNU General Public License along
00027 with this program; if not, write to the Free Software
00028 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00029 */
00030 
00031 #ifndef PROPORTIONAL_INTEGRAL_CONTROLLER_H
00032 #define PROPORTIONAL_INTEGRAL_CONTROLLER_H
00033 
00034 #include <vector>
00035 #include <ostream>
00036 #include <iofits.h>
00037 
00038 namespace Arroyo {
00039 
00040   using std::vector;
00041   using std::ostream;
00042 
00080 
00081 
00082   template<class input, class output, class proportional_gain, class integral_gain>
00083     class proportional_integral_controller {
00084 
00085     private:
00086 
00087     static bool factory_registration;
00088 
00089     protected:
00090 
00091     // proportional gain
00092     proportional_gain propgain;
00093 
00094     // last input for proportional update
00095     input last_input;
00096 
00097     // integral gain 
00098     integral_gain intgain;
00099 
00102     proportional_integral_controller(){};
00103 
00104     public:
00105     
00108     proportional_integral_controller(const proportional_integral_controller & picntrlr);
00109 
00112     proportional_integral_controller(const char * filename);
00113 
00116     proportional_integral_controller(const iofits & iof);
00117 
00120     proportional_integral_controller(const input & init,
00121                                      const proportional_gain & pgain, 
00122                                      const integral_gain & igain);
00123 
00126     ~proportional_integral_controller(){};
00127 
00130     proportional_integral_controller & operator=(const proportional_integral_controller & picntrlr);
00131 
00134     void update(const input & i, output & o);
00135     
00136   };
00137 
00138 
00139   template<class input, class output, class proportional_gain, class integral_gain> 
00140     proportional_integral_controller<input, output, proportional_gain, integral_gain>::
00141     proportional_integral_controller(const proportional_integral_controller<input, output, proportional_gain, integral_gain> & picntrlr){
00142     this->operator=(picntrlr);
00143   }
00144 
00145   template<class input, class output, class proportional_gain, class integral_gain> 
00146     proportional_integral_controller<input, output, proportional_gain, integral_gain>::
00147     proportional_integral_controller(const char * filename){
00148     this->read(filename);
00149   }
00150 
00151   template<class input, class output, class proportional_gain, class integral_gain> 
00152     proportional_integral_controller<input, output, proportional_gain, integral_gain>::
00153     proportional_integral_controller(const iofits & iof){
00154     this->read(iof);
00155   }
00156 
00157   template<class input, class output, class proportional_gain, class integral_gain> 
00158     proportional_integral_controller<input, output, proportional_gain, integral_gain>::
00159     proportional_integral_controller(const input & init, 
00160                                      const proportional_gain & propg, 
00161                                      const integral_gain & intg){
00162     last_input = init;
00163     propgain = propg;
00164     intgain = intg;
00165   }
00166 
00167   template<class input, class output, class proportional_gain, class integral_gain> 
00168     proportional_integral_controller<input, output, proportional_gain, integral_gain> & 
00169     proportional_integral_controller<input, output, proportional_gain, integral_gain>::
00170     operator=(const proportional_integral_controller<input, output, proportional_gain, integral_gain> & picntrlr){
00171     if(this==&picntrlr)
00172       return(*this);
00173 
00174     last_input = picntrlr.last_input;
00175     propgain = picntrlr.propgain;
00176     intgain = picntrlr.intgain;
00177 
00178     return(*this);
00179   }
00180 
00181   template<class input, class output, class proportional_gain, class integral_gain> 
00182     void proportional_integral_controller<input, output, proportional_gain, integral_gain>::
00183     update(const input & i, output & o){
00184     o += i*intgain + (i - last_input)*propgain;
00185     last_input = i;
00186   }
00187 
00188 }
00189 
00190 #endif

Generated on Thu Nov 29 17:16:30 2007 for arroyo by  doxygen 1.3.9.1