BaseDaq.hh

Go to the documentation of this file.
00001 
00007 #ifndef BASEDAQ_h
00008 #define BASEDAQ_h
00009 
00010 #include <queue>
00011 #include <string>
00012 #include <stdexcept>
00013 #include "boost/thread/thread.hpp"
00014 #include "boost/thread/condition.hpp"
00015 #include "boost/thread/mutex.hpp"
00016 #include "RawEvent.hh"
00017 
00018 
00028 class BaseDaq 
00029 {
00030 public:
00034   enum STATUS{ 
00035     NORMAL=0, 
00036     INIT_FAILURE, 
00037     BUS_ERROR, 
00038     COMM_ERROR, 
00039     GENERIC_ERROR 
00040   };
00041   
00042 
00044   BaseDaq() throw(std::runtime_error);
00045   
00047   virtual ~BaseDaq();
00048   
00050   STATUS GetStatus(){ return _status; }
00051   
00053   void ResetStatus(){ _status=NORMAL; }
00054 
00061   virtual int Initialize() = 0;
00062   
00069   virtual int Update() = 0;
00070   
00074   virtual int Calibrate() {return 0;}
00075   
00082   virtual int StartRun();
00083    
00088   RawEventPtr GetNextEvent(int timeout=-1);
00089   
00091   int GetEventsReady(){ return _events_queue.size(); }
00092   
00101   virtual int EndRun(bool force=false);
00102 
00103 
00105   void operator()(){ DataAcquisitionLoop(); }
00106 
00107 protected:
00108   
00114   virtual void DataAcquisitionLoop()=0;
00116   void PostEvent(RawEventPtr event);
00117   
00118   static bool _is_constructed; 
00119   STATUS _status; 
00120   
00121   bool _is_running; 
00122   boost::thread _daq_thread; 
00123   std::queue<RawEventPtr> _events_queue; 
00124   boost::mutex _queue_mutex; 
00125   boost::condition_variable _event_ready; 
00126   boost::condition_variable _event_taken; 
00127   static const size_t MAX_QUEUE_SIZE = 10; 
00128   int _n_queuesize_warnings;   
00129 };
00130 
00131 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on 20 Jun 2014 for daqman by  doxygen 1.6.1