/* Copyright (c) 20011 Hovanes Egiyan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _BaseIUParADC_HH_ #define _BaseIUParADC_HH_ extern "C" { #include #include #include #include }; #include #include #include #include #include "BaseIUVirtPar.hh" class BaseIUParADC : public BaseIUVirtPar { protected: //! Readback value after conversion to a real number double bpaReadValue; //! To-be-written value before being converted to integer double bpaWriteValue; //! Prohibit default constructor BaseIUParADC(); //! Get the deque after sending read request and process it to //! retrieve the parameter value on the board. If there was not //! message found then the return value is false. Otherwise it is true. virtual bool ProcessDeque( bool clearFlag = 0 ); public: static const unsigned bpaBitsADC; // Bits on ADC, basically define the number of bits static const unsigned bpaBitsDAC; // Bits on DAC, basically define the number of bits static const double bpaMaxVoltage; // Maximum voltage static const string bpaParType; static const int bpaComndByte; static map bpaExtraByteMap; //! Tolerance for each parameter to decide when to write to HW static map bpaTolerance; //! Calibration constant maps static map bpaScaleMap; static map bpaOffsetMap; //! Main constructor BaseIUParADC( string name, BaseIUModule& board ); //! Short constructor, no device no address BaseIUParADC( string name ); //! Copy constructor BaseIUParADC( const BaseIUParADC& par ); //! Destructor virtual ~BaseIUParADC(); //! Assignment operator BaseIUParADC& operator=( const BaseIUParADC& par ); //! Cloning function defined for polymorphism for copy constructor //! Invokes the copy constructor for this class and returns the //! the address of the resulting object virtual BaseIUVirtPar* CloneParameter(); //! Method to sync the parameter with the value on the hardware virtual bool Sync( bool dir = 0 ); //! Request read of this ADC for all boards on the bus virtual void ReadRequest( BaseIUDevice* dev, string name ); // Set the write values for this object from the write value of another parameter. // It is assumed that the two parameters are of the same class, otherwise the // program will seg. fault. virtual void SetWriteValueFrom( BaseIUVirtPar& fakePar ); //! Initialize the constants in the maps static int InitMaps(); virtual inline double GetDouble() { return GetReadValue(); } virtual inline double SetDouble( double val ) { return SetWriteValue( val ); } inline double GetReadValue() { MtxLock scopeLock( bmMutex ); return bpaReadValue; } inline double GetWriteValue() { MtxLock scopeLock( bmMutex ); return bpaWriteValue; } inline double SetWriteValue( double val ) { MtxLock scopeLock( bmMutex ); return ( bpaWriteValue = val ); } }; #endif // _BaseIUParADC_HH_