Public Member Functions | Protected Attributes | Private Member Functions | List of all members
dune::FelixFragmentCompressed Class Reference

#include <FelixFragment.hh>

Inheritance diagram for dune::FelixFragmentCompressed:
dune::FelixFragmentBase

Public Member Functions

 FelixFragmentCompressed (const artdaq::Fragment &fragment)
 
 ~FelixFragmentCompressed ()
 
uint8_t sof (const unsigned &frame_ID=0) const
 
uint8_t version (const unsigned &frame_ID=0) const
 
uint8_t fiber_no (const unsigned &frame_ID=0) const
 
uint8_t slot_no (const unsigned &frame_ID=0) const
 
uint8_t crate_no (const unsigned &frame_ID=0) const
 
uint8_t mm (const unsigned &frame_ID=0) const
 
uint8_t oos (const unsigned &frame_ID=0) const
 
uint16_t wib_errors (const unsigned &frame_ID=0) const
 
uint64_t timestamp (const unsigned &frame_ID=0) const
 
uint16_t wib_counter (const unsigned &frame_ID=0) const
 
uint8_t s1_error (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint8_t s2_error (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint16_t checksum_a (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint16_t checksum_b (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint16_t coldata_convert_count (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint16_t error_register (const unsigned &frame_ID, const uint8_t &block_num) const
 
uint8_t hdr (const unsigned &frame_ID, const uint8_t &block_num, const uint8_t &hdr_num) const
 
adc_t get_ADC (const unsigned &frame_ID, const uint8_t channel_ID) const
 
void print_timestamps () const
 
void print (const unsigned i) const
 
void print_frames () const
 
size_t total_words () const
 
size_t total_frames () const
 
size_t total_adc_values () const
 
const artdaq::Fragment uncompressed_fragment () const
 
- Public Member Functions inherited from dune::FelixFragmentBase
 FelixFragmentBase (const artdaq::Fragment &fragment)
 
virtual ~FelixFragmentBase ()
 
virtual size_t adc_range (int daq_adc_bits=12)
 
const uint8_t * dataBeginBytes () const
 
size_t dataSizeBytes () const
 

Protected Attributes

artdaq::Fragment uncompfrag_
 
const FelixFragmentBaseflxfrag
 
- Protected Attributes inherited from dune::FelixFragmentBase
Metadata meta_
 
const void * artdaq_Fragment_
 
size_t sizeBytes_
 

Private Member Functions

int decompress_copy (const artdaq::Fragment &src, artdaq::Fragment &dst)
 
int internal_inflate (const void *src, uint srcLen, void *dst, uint dstLen)
 

Detailed Description

Definition at line 498 of file FelixFragment.hh.

Constructor & Destructor Documentation

dune::FelixFragmentCompressed::FelixFragmentCompressed ( const artdaq::Fragment &  fragment)
inline

Definition at line 573 of file FelixFragment.hh.

574  : FelixFragmentBase(fragment) {
575  // Decompress.
576  decompress_copy(fragment, uncompfrag_);
577  // std::cout << decompress_copy(fragment, uncompfrag_) << " returned from
578  // decompress_copy\n";
579 
580  // Update metadata.
581  meta_.compressed = 0;
582  uncompfrag_.setMetadata(meta_);
583  if (meta_.reordered) {
584  flxfrag = new FelixFragmentReordered(uncompfrag_);
585  } else {
586  flxfrag = new FelixFragmentUnordered(uncompfrag_);
587  }
588  }
FelixFragmentBase(const artdaq::Fragment &fragment)
int decompress_copy(const artdaq::Fragment &src, artdaq::Fragment &dst)
const FelixFragmentBase * flxfrag
dune::FelixFragmentCompressed::~FelixFragmentCompressed ( )
inline

Definition at line 590 of file FelixFragment.hh.

590 { delete flxfrag; }
const FelixFragmentBase * flxfrag

Member Function Documentation

uint16_t dune::FelixFragmentCompressed::checksum_a ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 631 of file FelixFragment.hh.

632  {
633  return flxfrag->checksum_a(frame_ID, block_num);
634  }
const FelixFragmentBase * flxfrag
virtual uint16_t checksum_a(const unsigned &frame_ID, const uint8_t &block_num) const =0
uint16_t dune::FelixFragmentCompressed::checksum_b ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 635 of file FelixFragment.hh.

636  {
637  return flxfrag->checksum_b(frame_ID, block_num);
638  }
const FelixFragmentBase * flxfrag
virtual uint16_t checksum_b(const unsigned &frame_ID, const uint8_t &block_num) const =0
uint16_t dune::FelixFragmentCompressed::coldata_convert_count ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 639 of file FelixFragment.hh.

640  {
641  return flxfrag->coldata_convert_count(frame_ID, block_num);
642  }
virtual uint16_t coldata_convert_count(const unsigned &frame_ID, const uint8_t &block_num) const =0
const FelixFragmentBase * flxfrag
uint8_t dune::FelixFragmentCompressed::crate_no ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 605 of file FelixFragment.hh.

605  {
606  return flxfrag->crate_no(frame_ID);
607  }
const FelixFragmentBase * flxfrag
virtual uint8_t crate_no(const unsigned &frame_ID=0) const =0
int dune::FelixFragmentCompressed::decompress_copy ( const artdaq::Fragment &  src,
artdaq::Fragment &  dst 
)
inlineprivate

Definition at line 500 of file FelixFragment.hh.

500  {
501  // Determine and reserve new fragment size.
502  long unsigned int uncompSizeBytes;
503  if (meta_.reordered) {
504  uncompSizeBytes = meta_.num_frames * (sizeof(dune::WIBHeader) +
505  4 * sizeof(dune::ColdataHeader) +
506  256 * sizeof(dune::adc_t));
507  // Account for bitfields
508  uncompSizeBytes += (meta_.num_frames + 7) / 8;
509  } else {
510  uncompSizeBytes = meta_.num_frames * sizeof(dune::FelixFrame);
511  }
512  dst.resizeBytes(uncompSizeBytes);
513 
514  int num_bytes = internal_inflate(src.dataBeginBytes(), src.dataSizeBytes(),
515  dst.dataBeginBytes(), dst.dataSizeBytes());
516 
517  return num_bytes;
518  }
uint16_t adc_t
Definition: FelixFormat.hh:18
int internal_inflate(const void *src, uint srcLen, void *dst, uint dstLen)
uint16_t dune::FelixFragmentCompressed::error_register ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 643 of file FelixFragment.hh.

644  {
645  return flxfrag->error_register(frame_ID, block_num);
646  }
const FelixFragmentBase * flxfrag
virtual uint16_t error_register(const unsigned &frame_ID, const uint8_t &block_num) const =0
uint8_t dune::FelixFragmentCompressed::fiber_no ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 599 of file FelixFragment.hh.

599  {
600  return flxfrag->fiber_no(frame_ID);
601  }
virtual uint8_t fiber_no(const unsigned &frame_ID=0) const =0
const FelixFragmentBase * flxfrag
adc_t dune::FelixFragmentCompressed::get_ADC ( const unsigned &  frame_ID,
const uint8_t  channel_ID 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 653 of file FelixFragment.hh.

653  {
654  return flxfrag->get_ADC(frame_ID, channel_ID);
655  }
virtual adc_t get_ADC(const unsigned &frame_ID, const uint8_t channel_ID) const =0
const FelixFragmentBase * flxfrag
uint8_t dune::FelixFragmentCompressed::hdr ( const unsigned &  frame_ID,
const uint8_t &  block_num,
const uint8_t &  hdr_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 647 of file FelixFragment.hh.

648  {
649  return flxfrag->hdr(frame_ID, block_num, hdr_num);
650  }
virtual uint8_t hdr(const unsigned &frame_ID, const uint8_t &block_num, const uint8_t &hdr_num) const =0
const FelixFragmentBase * flxfrag
int dune::FelixFragmentCompressed::internal_inflate ( const void *  src,
uint  srcLen,
void *  dst,
uint  dstLen 
)
inlineprivate

Definition at line 520 of file FelixFragment.hh.

520  {
521  z_stream strm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
522  strm.total_in = strm.avail_in = srcLen;
523  strm.total_out = strm.avail_out = dstLen;
524  strm.next_in = (Bytef*)src;
525  strm.next_out = (Bytef*)dst;
526 
527  strm.zalloc = Z_NULL;
528  strm.zfree = Z_NULL;
529  strm.opaque = Z_NULL;
530 
531  unsigned read = 0;
532  unsigned write = 0;
533  int err = 0;
534 
535  while (read < srcLen && write < dstLen) {
536  strm.next_in = (Bytef*)src + read;
537  strm.next_out = (Bytef*)dst + write;
538 
539  unsigned to_read = srcLen - read;
540  unsigned to_write = dstLen - write;
541 
542  if (to_read < 20) {
543  // This cant possibly be a frag
544  break;
545  }
546 
547  strm.total_in = strm.avail_in = to_read;
548  strm.total_out = strm.avail_out = to_write;
549 
550  inflateInit2(&strm, MAX_WBITS | 16);
551  err = inflate(&strm, Z_FINISH);
552  // Just return the source if data error.
553  if (err == Z_DATA_ERROR) {
554  std::cout << "Warning: decompression data error. Returning compressed "
555  "fragment.\n";
556  memcpy(dst, src, srcLen);
557  return srcLen;
558  }
559  inflateEnd(&strm);
560 
561  read += to_read - strm.avail_in;
562  write += to_write - strm.avail_out;
563 
564  if (err < 0) {
565  break;
566  }
567  }
568 
569  return write;
570  }
size_t write(int, const char *, size_t)
Writes count bytes from buf to the filedescriptor fd.
void err(const char *fmt,...)
Definition: message.cpp:226
int read(int, char *, size_t)
Read bytes from a file descriptor.
uint8_t dune::FelixFragmentCompressed::mm ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 608 of file FelixFragment.hh.

608  {
609  return flxfrag->mm(frame_ID);
610  }
virtual uint8_t mm(const unsigned &frame_ID=0) const =0
const FelixFragmentBase * flxfrag
uint8_t dune::FelixFragmentCompressed::oos ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 611 of file FelixFragment.hh.

611  {
612  return flxfrag->oos(frame_ID);
613  }
virtual uint8_t oos(const unsigned &frame_ID=0) const =0
const FelixFragmentBase * flxfrag
void dune::FelixFragmentCompressed::print ( const unsigned  i) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 660 of file FelixFragment.hh.

660 { return flxfrag->print(i); }
virtual void print(const unsigned i) const =0
const FelixFragmentBase * flxfrag
void dune::FelixFragmentCompressed::print_frames ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 662 of file FelixFragment.hh.

662 { return flxfrag->print_frames(); }
virtual void print_frames() const =0
const FelixFragmentBase * flxfrag
void dune::FelixFragmentCompressed::print_timestamps ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 658 of file FelixFragment.hh.

658 { return flxfrag->print_timestamps(); }
virtual void print_timestamps() const =0
const FelixFragmentBase * flxfrag
uint8_t dune::FelixFragmentCompressed::s1_error ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 625 of file FelixFragment.hh.

625  {
626  return flxfrag->s1_error(frame_ID, block_num);
627  }
virtual uint8_t s1_error(const unsigned &frame_ID, const uint8_t &block_num) const =0
const FelixFragmentBase * flxfrag
uint8_t dune::FelixFragmentCompressed::s2_error ( const unsigned &  frame_ID,
const uint8_t &  block_num 
) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 628 of file FelixFragment.hh.

628  {
629  return flxfrag->s2_error(frame_ID, block_num);
630  }
const FelixFragmentBase * flxfrag
virtual uint8_t s2_error(const unsigned &frame_ID, const uint8_t &block_num) const =0
uint8_t dune::FelixFragmentCompressed::slot_no ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 602 of file FelixFragment.hh.

602  {
603  return flxfrag->slot_no(frame_ID);
604  }
virtual uint8_t slot_no(const unsigned &frame_ID=0) const =0
const FelixFragmentBase * flxfrag
uint8_t dune::FelixFragmentCompressed::sof ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 593 of file FelixFragment.hh.

593  {
594  return flxfrag->sof(frame_ID);
595  }
const FelixFragmentBase * flxfrag
virtual uint8_t sof(const unsigned &frame_ID=0) const =0
uint64_t dune::FelixFragmentCompressed::timestamp ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 617 of file FelixFragment.hh.

617  {
618  return flxfrag->timestamp(frame_ID);
619  }
virtual uint64_t timestamp(const unsigned &frame_ID=0) const =0
const FelixFragmentBase * flxfrag
size_t dune::FelixFragmentCompressed::total_adc_values ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 669 of file FelixFragment.hh.

669 { return flxfrag->total_adc_values(); }
const FelixFragmentBase * flxfrag
virtual size_t total_adc_values() const =0
size_t dune::FelixFragmentCompressed::total_frames ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 667 of file FelixFragment.hh.

667 { return flxfrag->total_frames(); }
virtual size_t total_frames() const =0
const FelixFragmentBase * flxfrag
size_t dune::FelixFragmentCompressed::total_words ( ) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 665 of file FelixFragment.hh.

665 { return flxfrag->total_words(); }
virtual size_t total_words() const =0
const FelixFragmentBase * flxfrag
const artdaq::Fragment dune::FelixFragmentCompressed::uncompressed_fragment ( ) const
inline

Definition at line 672 of file FelixFragment.hh.

672 { return uncompfrag_; }
uint8_t dune::FelixFragmentCompressed::version ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 596 of file FelixFragment.hh.

596  {
597  return flxfrag->version(frame_ID);
598  }
const FelixFragmentBase * flxfrag
virtual uint8_t version(const unsigned &frame_ID=0) const =0
uint16_t dune::FelixFragmentCompressed::wib_counter ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 620 of file FelixFragment.hh.

620  {
621  return flxfrag->wib_counter(frame_ID);
622  }
const FelixFragmentBase * flxfrag
virtual uint16_t wib_counter(const unsigned &frame_ID=0) const =0
uint16_t dune::FelixFragmentCompressed::wib_errors ( const unsigned &  frame_ID = 0) const
inlinevirtual

Implements dune::FelixFragmentBase.

Definition at line 614 of file FelixFragment.hh.

614  {
615  return flxfrag->wib_errors(frame_ID);
616  }
virtual uint16_t wib_errors(const unsigned &frame_ID=0) const =0
const FelixFragmentBase * flxfrag

Member Data Documentation

const FelixFragmentBase* dune::FelixFragmentCompressed::flxfrag
protected

Definition at line 678 of file FelixFragment.hh.

artdaq::Fragment dune::FelixFragmentCompressed::uncompfrag_
protected

Definition at line 676 of file FelixFragment.hh.


The documentation for this class was generated from the following file: