DADABuffer.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2002 - 2024 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 #ifndef __DADABuffer_h
10 #define __DADABuffer_h
11 
12 #include "dsp/File.h"
13 #include "dada_hdu.h"
14 
15 namespace dsp {
16 
18 
20  class DADABuffer : public File
21  {
22 
23  public:
24 
26  DADABuffer ();
27 
29  ~DADABuffer ();
30 
32 
41  bool is_valid (const char* filename) const;
42 
44  virtual void open_file (const char* filename);
45 
47  virtual void open_key (const std::string& key);
48 
50  void load_header ();
51 
53 
54  virtual void reopen ();
55 
57  virtual void close ();
58 
60  virtual void seek (int64_t offset, int whence = 0);
61 
63  virtual void set_block_size (uint64_t _size);
64 
66  virtual bool eod() const override;
67 
69  virtual void set_info (Observation* obs) { info = obs; }
70 
72  void rewind ();
73 
74  protected:
76  void disconnect ();
77 
79  virtual int64_t load_bytes (unsigned char* buffer, uint64_t bytes);
80 
82  virtual int64_t seek_bytes (uint64_t bytes);
83 
85  virtual void set_total_samples ();
86 
88  dada_hdu_t* hdu = nullptr;
89 
91  bool passive = false;
92 
94  unsigned byte_resolution = 1;
95 
96  private:
97 
98  /*
99  The following methods and attributes are used only if CUDA is enabled
100  */
101 
103  int64_t load_bytes_device (unsigned char* device_memory, uint64_t bytes, void * device_handle);
104 
106  void set_require_registered_memory() { require_registered_memory = true; };
107 
109  unsigned zero_input = 0;
110 
112  void* zeroed_buffer = nullptr;
113 
115  uint64_t zeroed_buffer_size = 0;
116 
118  bool require_registered_memory = false;
119 
121  bool registered_memory = false;
122 
123  };
124 
125 }
126 
127 #endif // !defined(__DADABuffer_h)
~DADABuffer()
Destructor.
Definition: DADABuffer.C:43
virtual int64_t load_bytes(unsigned char *buffer, uint64_t bytes)
Load bytes from shared memory.
Definition: DADABuffer.C:377
virtual int64_t seek_bytes(uint64_t bytes)
Set the offset in shared memory.
Definition: DADABuffer.C:442
Contains all Baseband Data Reduction Library classes.
Definition: ASCIIObservation.h:17
virtual void set_block_size(uint64_t _size)
Ensure that block_size is an integer multiple of resolution.
Definition: DADABuffer.C:472
bool passive
Passive viewing mode.
Definition: DADABuffer.h:101
Loads BitSeries data from file.
Definition: File.h:38
bool is_valid(const char *filename) const
Returns true if the ASCII contents of file describe a valid DADA ring buffer.
Definition: DADABuffer.C:144
virtual void close()
Close the DADA connection.
Definition: DADABuffer.C:56
virtual void open_file(const char *filename)
Read the DADA key information from the specified filename.
Definition: DADABuffer.C:199
virtual void seek(int64_t offset, int whence=0)
Seek to the specified time sample.
Definition: DADABuffer.C:457
virtual bool eod() const
Return true when end of data has been reached.
Definition: Seekable.C:59
virtual void set_total_samples()
Over-ride File::set_total_samples.
Definition: DADABuffer.C:493
virtual void reopen()
Re-open using the current key.
Definition: DADABuffer.C:306
virtual void seek(int64_t offset, int whence=0)
Seek to the specified time sample.
Definition: Input.C:282
A container for storing digitized (generally not floating point) data
Definition: BitSeries.h:35
unsigned byte_resolution
The byte resolution.
Definition: DADABuffer.h:104
void rewind()
Reset DADAbuffer.
Definition: DADABuffer.C:127
void set_overlap_buffer(BitSeries *)
Buffer used to store overlap (useful in multi-threaded applications)
Definition: Seekable.C:323
dada_hdu_t * hdu
Shared memory interface.
Definition: DADABuffer.h:98
Reference::To< Observation > info
Information about the data source (passed on to BitSeries in load)
Definition: Input.h:171
void load_header()
Load the next header block and parse it.
Definition: DADABuffer.C:353
virtual void open_key(const std::string &key)
Open the DADA ring buffer via the key.
Definition: DADABuffer.C:233
virtual void set_info(Observation *obs)
Get the information about the data source.
Definition: DADABuffer.h:79
void disconnect()
Disconnect from the DADA ring buffer.
Definition: DADABuffer.C:73
Parses Observation attributes from an ASCII header.
Definition: ASCIIObservation.h:29
virtual void set_block_size(uint64_t _size)
Set the number of time samples to load on each load_block.
Definition: Input.C:399
virtual bool eod() const override
End-of-data is defined by primary read client (passive viewer)
Definition: DADABuffer.C:485
DADABuffer()
Constructor.
Definition: DADABuffer.C:32

Generated using doxygen 1.8.17