24 #include "cheetah/psrdada/DadaClientBase.h" 25 #include "panda/Log.h" 26 #include "panda/Error.h" 36 membuf::membuf(
char* begin,
char* end)
38 this->setg(begin, begin, end);
39 this->setp(begin, end);
42 char* membuf::reader_position()
const 47 char* membuf::writer_position()
const 52 std::string generate_logger_tag(std::string
const& basename)
54 auto gen = std::mt19937{std::random_device{}()};
55 auto dist = std::uniform_int_distribution<int>{100000000, 999999999};
56 std::stringstream name;
57 name << basename <<
"_" << dist(gen);
65 , _log(detail::generate_logger_tag(logger_name))
67 std::stringstream _key_string_stream;
68 _key_string_stream.exceptions(std::ifstream::failbit);
69 _key_string_stream <<
"["<< std::hex << _key << std::dec <<
"]["<<_log.
name()<<
"] ";
70 _id = _key_string_stream.str();
74 DadaClientBase::~DadaClientBase()
84 return ipcbuf_get_bufsz((ipcbuf_t *) _hdu->data_block);
89 return ipcbuf_get_bufsz(_hdu->header_block);
94 return ipcbuf_get_nbufs((ipcbuf_t *) _hdu->data_block);
99 return ipcbuf_get_nbufs(_hdu->header_block);
104 PANDA_LOG_DEBUG << this->
id() <<
"Connecting to dada buffer";
106 dada_hdu_set_key(_hdu, _key);
107 if (dada_hdu_connect (_hdu) < 0)
109 _log.
write(LOG_ERR,
"could not connect to hdu\n");
110 throw panda::Error(
"Unable to connect to hdu");
121 PANDA_LOG_DEBUG << this->
id() <<
"Disconnecting from dada buffer";
122 if (dada_hdu_disconnect (_hdu) < 0)
124 _log.
write(LOG_ERR,
"could not disconnect from hdu\n");
125 throw panda::Error(
"Unable to disconnect from hdu");
127 dada_hdu_destroy(_hdu);
void disconnect()
Disconnect from ring buffer.
std::size_t data_buffer_size() const
Get the sizes of each data block in the ring buffer.
void reconnect()
Reconnect to the ring buffer.
std::string const & name() const
Return the name of the logger.
DadaClientBase(key_t key, std::string const &logger_name)
Create a new basic DADA client instance.
Some limits and constants for FLDO.
std::size_t data_buffer_count() const
Get the number of data blocks in the ring buffer.
void connect()
Connect to ring buffer.
std::size_t header_buffer_size() const
Get the sizes of each header block in the ring buffer.
multilog_t * native_handle()
Get a native handle to the wrapped multilog_t pointer.
std::string const & id() const
Return a string identifier based on the buffer key and log name.
void write(int priority, const char *format, Args &&... args)
Write to the log.
std::size_t header_buffer_count() const
Get the number of header blocks in the ring buffer.