00001 /* 00002 * rb8510_dac12.h - dual 12-bit DAC (RB8510). 00003 * 00004 * This file is part of the Rulbus Device Class Library (RDCL). 00005 * 00006 * Copyright (C) 2003-2004, Leiden University. 00007 * 00008 * This library is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * The library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with mngdriver; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 * $Id: rb8510_dac12.h 2 2004-10-12 11:54:15Z moene $ 00023 */ 00024 00025 #ifndef __RB8510_DAC12_H 00026 #define __RB8510_DAC12_H 00027 00028 #ifndef __RULBUSDEVICE_H 00029 #include "RulbusDevice.h" // for class RulbusDevice 00030 #endif 00031 00032 namespace Rulbus 00033 { 00034 DECLARE_CLASS( RB8510_Dac12 ); // the 12-bit DAC class type 00035 00163 class RB8510_Dac12 : public RulbusDevice 00164 { 00165 public: // public methods 00166 typedef Int Value; 00167 00170 00171 RB8510_Dac12( 00172 NameCref aName, 00173 Addr aAddr = DEF_ADDR, 00174 Rack aRack = DEF_RACK, 00175 bool aBipolarFlag = DEF_BIP, 00176 Real aVoltPerBit = DEF_VPB ); 00177 00178 ~RB8510_Dac12(); 00179 00183 00184 Volt voltage() const; 00185 Value value() const; 00186 00187 bool isBipolar() const; 00188 float voltperbit() const; 00189 00193 00194 void setVoltage ( Volt aVoltage ); 00195 void setValue ( Value aValue ); 00196 00198 00199 protected: // protected methods 00202 00203 RB8510_Dac12(); 00204 RB8510_Dac12( RB8510_Dac12Cref rhs ); 00205 RB8510_Dac12Ref operator= ( RB8510_Dac12Cref rhs ); 00206 00208 00209 public: // public data 00212 00213 static const Addr DEF_ADDR = 0xD0; 00214 // static const Rack DEF_RACK = 0; ///< default rack 00215 static const bool DEF_BIP = true; 00216 static const Real DEF_VPB /* = 5e-3 */; 00217 00221 00222 static const Value LIM_MINVAL = 0x0000; 00223 static const Value LIM_MAXVAL = 0x0FFF; 00224 static const Value LIM_BIPVAL = 0x0800; 00225 00227 00228 private: // private data 00231 Value theRegister; 00232 bool theBipolarFlag; 00233 Real theVoltPerBit; 00234 00238 00239 static const int OFF_MSB = 0; 00240 static const int OFF_LSB = 1; 00241 00242 static const int ADR_WIDTH = OFF_LSB + 1; 00243 00245 }; 00246 00248 00253 inline RB8510_Dac12::Value RB8510_Dac12::value() const 00254 { 00255 return theRegister; 00256 } 00257 00262 inline bool RB8510_Dac12::isBipolar() const 00263 { 00264 return theBipolarFlag; 00265 } 00266 00271 inline float RB8510_Dac12::voltperbit() const 00272 { 00273 return theVoltPerBit; 00274 } 00275 00280 inline RB8510_Dac12Ref to_rb8510( RulbusDevicePtr p ) 00281 { 00282 return PROXY_CAST<RB8510_Dac12Ref>( *p ); 00283 } 00284 00289 inline RB8510_Dac12Ptr to_rb8510_ptr( RulbusDevicePtr p ) 00290 { 00291 return PROXY_CAST<RB8510_Dac12Ptr>( p ); 00292 } 00293 00294 } // namespace Rulbus 00295 00296 #endif // __RB8510_DAC12_H 00297 00298 /* 00299 * end of file 00300 */ 00301