Analog.h

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile$
00027  * Date modified: $Date: 2005-01-15 18:00:37 -0600 (Sat, 15 Jan 2005) $
00028  * Version:       $Revision: 16622 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #ifndef _GADGET_ANALOG_H_
00034 #define _GADGET_ANALOG_H_
00035 
00036 #include <gadget/gadgetConfig.h>
00037 #include <vector>
00038 
00039 #include <gadget/Type/AnalogData.h>
00040 #include <gadget/Type/SampleBuffer.h>
00041 
00042 #include <jccl/Config/ConfigElement.h>
00043 #include <vpr/IO/SerializableObject.h>
00044 
00045 
00046 namespace gadget
00047 {
00048 
00049 const unsigned short MSG_DATA_ANALOG = 421;
00050 
00065 class GADGET_CLASS_API Analog : public vpr::SerializableObject
00066 {
00067 public:
00068    typedef gadget::SampleBuffer<AnalogData> SampleBuffer_t;
00069 
00070 public:
00071 
00077    Analog();
00078 
00079    virtual ~Analog();
00080 
00082    virtual vpr::ReturnStatus writeObject(vpr::ObjectWriter* writer);
00083 
00085    virtual vpr::ReturnStatus readObject(vpr::ObjectReader* reader);
00086 
00097    virtual bool config(jccl::ConfigElementPtr element);
00098 
00119    AnalogData getAnalogData(int devNum = 0);
00120 
00132    void addAnalogSample(const std::vector< AnalogData >& anaSample);
00133 
00141    void swapAnalogBuffers();
00142 
00146    const SampleBuffer_t::buffer_t& getAnalogDataBuffer();
00147 
00148    virtual std::string getInputTypeName();
00149 
00150 protected:
00155    void normalizeMinToMax(const float& plainJaneValue,
00156                           float& normedFromMinToMax);
00157 
00158 protected:
00164    float getMin() const;
00165    float getMax() const;
00166    void setMin(float mIn);
00167    void setMax(float mAx);
00168 
00169    // gadget::SampleBuffer<T> is not copyable, so neither are we.
00170    Analog(const gadget::Analog& d)
00171       : vpr::SerializableObject(d)
00172    {;}
00173 
00174    void operator=(const gadget::Analog&) {;}
00175 
00176 private:
00177    float mMin, mMax;
00178 
00179 private:
00180    SampleBuffer_t    mAnalogSamples;  
00181    AnalogData        mDefaultValue;   
00182 };
00183 
00184 } // End of gadget namespace
00185 
00186 
00187 #endif   /* _GADGET_ANALOG_H_ */

Generated on Thu Jan 4 10:41:54 2007 for Gadgeteer by  doxygen 1.5.1