Abstract class to define a DAQ hardware interface. More...
#include <BaseDaq.hh>
Public Types | |
enum | STATUS { NORMAL = 0, INIT_FAILURE, BUS_ERROR, COMM_ERROR, GENERIC_ERROR } |
defines possible status conditions of the daq More... | |
Public Member Functions | |
BaseDaq () throw (std::runtime_error) | |
Default constructor. Throws exception if more than one constructed. | |
virtual | ~BaseDaq () |
Virtual destructor. | |
STATUS | GetStatus () |
Get the status of the DAQ. | |
void | ResetStatus () |
Resets Status to normal. | |
virtual int | Initialize ()=0 |
Initializes hardware for a run. | |
virtual int | Update ()=0 |
virtual int | Calibrate () |
virtual int | StartRun () |
RawEventPtr | GetNextEvent (int timeout=-1) |
int | GetEventsReady () |
Queries how many events are waiting in the memory buffer. | |
virtual int | EndRun (bool force=false) |
void | operator() () |
called ONLY by the boost thread; should not be called directly ever | |
Protected Member Functions | |
virtual void | DataAcquisitionLoop ()=0 |
void | PostEvent (RawEventPtr event) |
Send a new RawEvent to whoever is waiting. | |
Protected Attributes | |
STATUS | _status |
the status of the daq | |
bool | _is_running |
is the daq running? | |
boost::thread | _daq_thread |
thread controlling the daq | |
std::queue< RawEventPtr > | _events_queue |
queue of raw events | |
boost::mutex | _queue_mutex |
mutex governing the events queue | |
boost::condition_variable | _event_ready |
condition signalling new event | |
boost::condition_variable | _event_taken |
signal a spot ready in queue | |
int | _n_queuesize_warnings |
number of queue overflow warnings generated | |
Static Protected Attributes | |
static bool | _is_constructed = false |
does an instance already exist? | |
static const size_t | MAX_QUEUE_SIZE = 10 |
max events allowed in queue |
Abstract class to define a DAQ hardware interface.
This class is an interface between the main DAQ program and the underlying subprocesses which handle threads, etc. Throws error if instantiated more than once at a time.
Definition at line 28 of file BaseDaq.hh.
enum BaseDaq::STATUS |
defines possible status conditions of the daq
Definition at line 34 of file BaseDaq.hh.
virtual int BaseDaq::Initialize | ( | ) | [pure virtual] |
Initializes hardware for a run.
Must be overriden by concrete implementation Returns 0 if no error occurred.
Implemented in V172X_Daq.
virtual int BaseDaq::Update | ( | ) | [pure virtual] |
Updates the parameters after initlialization has occurred but before starting the run. Must be overridden by concrete implementation Returns 0 if no error encountered
Implemented in V172X_Daq.
virtual int BaseDaq::Calibrate | ( | ) | [inline, virtual] |
Performs generic calibration tasks. Returns 0 if no errors
Definition at line 74 of file BaseDaq.hh.
int BaseDaq::StartRun | ( | ) | [virtual] |
Prepares for run, launches seperate thread which (calls operator()() which calls DataAcquistionLoop(). Clear all memory buffers, get the hardware into a ready state, and wait for a trigger Returns 0 if no failure encountered.
Definition at line 43 of file BaseDaq.cc.
RawEventPtr BaseDaq::GetNextEvent | ( | int | timeout = -1 |
) |
Checks to see if the next event is ready, and if so, returns it. If not ready, it sleeps the current thread and waits for notification that a new event is ready. If timeout (microsec) expires, returns null
Definition at line 82 of file BaseDaq.cc.
int BaseDaq::EndRun | ( | bool | force = false |
) | [virtual] |
Run is aborted.
Statistics on the total amount of live time, data downloaded, triggers handled, dead time, etc. are made available to the DAQ. All threads, instances, etc. created by StartRun are cleared. All digitizers are reset.
Definition at line 63 of file BaseDaq.cc.
virtual void BaseDaq::DataAcquisitionLoop | ( | ) | [protected, pure virtual] |
This is the main acquisition loop which must be overridden by the concrete implementation. Called by StartRun. Incoming events should be pushed into the _events_queue
Implemented in V172X_Daq.