bcu-voltages-adapter.hh

Go to the documentation of this file.
00001 
00002 #ifndef __BCU_VOLTAGES_ADAPTER_HH__
00003 #define __BCU_VOLTAGES_ADAPTER_HH__
00004 
00014 #include <accdata.hh>
00015 #include <accvector.hh>
00016 #include <accdevexception.hh>
00017 
00018 
00019 
00020 using std::auto_ptr;
00021 
00022 namespace DeviceAccess
00023 {
00024 namespace EqModBCU
00025 {
00026 
00037 class E_API VOLTAGESDataAdapter
00038 {
00039 public:
00040 
00041   static auto_ptr<const VOLTAGESDataAdapter> createRcvP(const DeviceAccess::AccData& data)
00042   {
00043     if (data.size()>1) {
00044       throw(AccDevException(ODA_MOREDATA,ODA_OK,ACCDEV_ERRORLOCATION));
00045     }
00046     DeviceAccess::AccData& mutual_data = const_cast<DeviceAccess::AccData&>(data);
00047     return auto_ptr<const VOLTAGESDataAdapter>(new VOLTAGESDataAdapter(mutual_data,0));
00048   }
00049         
00050   static auto_ptr<VOLTAGESDataAdapter> createSndP(DeviceAccess::AccData& data)
00051   {
00052     data.assign(1,Float32());
00053 
00054     auto_ptr<VOLTAGESDataAdapter> p(new VOLTAGESDataAdapter(data,0));
00055     p->init();
00056     return p;
00057   }
00058 
00060   Float32 voltages() const {
00061     return (*_ptr)[_offset+0].convert(Float32());
00062   }
00063 
00065   void voltages(Float32 val) {
00066     (*_ptr)[_offset+0] = val;
00067   }
00068 
00069 
00071   VOLTAGESDataAdapter(DeviceAccess::AccData& data, size_t offset=0) : _ptr(&data), _offset(offset)
00072   {
00073   }
00074 
00076   void init() {
00077 
00078   }
00079 
00080 
00081 
00082 private:
00083   DeviceAccess::AccData* _ptr;
00084   size_t _offset;
00085 };
00086 
00088 typedef VOLTAGESDataAdapter ReadVOLTAGESDataAdapter;
00089 
00091 typedef auto_ptr<ReadVOLTAGESDataAdapter> ReadVOLTAGESDataP;
00092 
00094 typedef VOLTAGESDataAdapter WriteVOLTAGESDataAdapter;
00095 
00097 typedef auto_ptr<const WriteVOLTAGESDataAdapter> WriteVOLTAGESDataP;
00098 
00102 } // namespace EqModBCU
00103 } // namespace DeviceAccess
00104 
00105 #endif

Generated on Wed Dec 2 14:32:16 2009 for BCU - Equipment Model for Unilac Chopper by  doxygen 1.4.7