Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
PuzzledFrame Class Reference

#include <puzzled_frame.hh>

Inheritance diagram for PuzzledFrame:
benchmark::chronometrable

Public Types

typedef std::map< unsigned int, CLBDataGram * > container_t
 

Public Member Functions

 PuzzledFrame ()
 
 ~PuzzledFrame ()
 
void setTimer (const Timer &exp)
 
void setSeqNumber (unsigned int seqnumber)
 
void setDataType (unsigned int datatype)
 
void setDetectorId (unsigned int detector_id)
 
void setFrameIndex (frame_idx_t frame_idx)
 
bool insert (CLBDataGram *datagram)
 
bool hasExpired () const
 
bool hasExpiredWrt (Timer const &t) const
 
void getFrame (Frame &frame)
 
void reset ()
 
uint32_t frameLength () const
 
uint32_t frameDomStatus (int i=1) const
 

Static Public Attributes

static boost::atomic< unsigned int > n_obj
 

Private Attributes

container_t m_container
 
Timer m_expiration
 
unsigned int m_seqnumber
 
unsigned int m_detector_id
 
unsigned int m_datatype
 
unsigned int m_totalsize
 
frame_idx_t m_frame_idx
 

Detailed Description

Author
cpellegrino

Definition at line 18 of file puzzled_frame.hh.

Member Typedef Documentation

◆ container_t

Definition at line 22 of file puzzled_frame.hh.

Constructor & Destructor Documentation

◆ PuzzledFrame()

PuzzledFrame::PuzzledFrame ( )
inline

Definition at line 41 of file puzzled_frame.hh.

42 :
43 m_seqnumber(0),
45 m_datatype(0),
46 m_totalsize(0),
48 {
49 ++n_obj;
50 }
unsigned int m_totalsize
static boost::atomic< unsigned int > n_obj
unsigned int m_datatype
unsigned int m_detector_id
unsigned int m_seqnumber
frame_idx_t m_frame_idx

◆ ~PuzzledFrame()

PuzzledFrame::~PuzzledFrame ( )
inline

Definition at line 52 of file puzzled_frame.hh.

53 {
54 reset();
55 --n_obj;
56 }

Member Function Documentation

◆ setTimer()

void PuzzledFrame::setTimer ( const Timer & exp)
inline

Definition at line 58 of file puzzled_frame.hh.

59 {
60 m_expiration.set(exp);
61 }
void set(long int seconds, long int useconds)
Definition timer.cc:27

◆ setSeqNumber()

void PuzzledFrame::setSeqNumber ( unsigned int seqnumber)
inline

Definition at line 63 of file puzzled_frame.hh.

64 {
65 m_seqnumber = seqnumber;
66 }

◆ setDataType()

void PuzzledFrame::setDataType ( unsigned int datatype)
inline

Definition at line 68 of file puzzled_frame.hh.

69 {
70 m_datatype = datatype;
71 }

◆ setDetectorId()

void PuzzledFrame::setDetectorId ( unsigned int detector_id)
inline

Definition at line 73 of file puzzled_frame.hh.

74 {
75 m_detector_id = detector_id;
76 }

◆ setFrameIndex()

void PuzzledFrame::setFrameIndex ( frame_idx_t frame_idx)
inline

Definition at line 78 of file puzzled_frame.hh.

79 {
80 m_frame_idx = frame_idx;
81 }

◆ insert()

bool PuzzledFrame::insert ( CLBDataGram * datagram)

Definition at line 61 of file puzzled_frame.cc.

62{
63 //Test collision: is m_container[idx] empty?
64 unsigned int const idx = datagram->getUDPSequenceNumber();
65
66 container_t::const_iterator const it = m_container.find(idx);
67
68 if (it != m_container.end()) {
69 LOG_DEBUG << "Datagram collision. idx: " << idx << '\n'
70 << "container.size(): " << m_container.size() << '\n'
71 << "INFO:\n" << *datagram->getCLBCommonHeader();
72
73 Log::Counter::get().add("collision");
75 return false;
76 }
77
78 if (!m_totalsize) {
79 benchmark::chrono_swap(*datagram, *this);
80 }
81
82 m_container.insert(m_container.end(), container_t::value_type(idx, datagram));
83
84 m_totalsize += datagram->size();
85
86 return true;
87}
const CLBCommonHeader * getCLBCommonHeader() const
size_t size() const
uint32_t getUDPSequenceNumber() const
void putDataGram(CLBDataGram *p)
static InBufferCollector & getCollector()
void add(std::string const &tag)
Definition log.hh:60
static Counter & get()
Definition log.hh:53
container_t m_container
#define LOG_DEBUG
Definition log.hh:109
void chrono_swap(chronometrable &input, chronometrable &output)

◆ hasExpired()

bool PuzzledFrame::hasExpired ( ) const
inline

Definition at line 85 of file puzzled_frame.hh.

86 {
87 return m_expiration.hasExpired();
88 }
bool hasExpired() const
Definition timer.cc:21

◆ hasExpiredWrt()

bool PuzzledFrame::hasExpiredWrt ( Timer const & t) const
inline

Definition at line 90 of file puzzled_frame.hh.

91 {
93 }
bool hasExpiredWrt(Timer const &t) const
Definition timer.cc:7

◆ getFrame()

void PuzzledFrame::getFrame ( Frame & frame)

Definition at line 304 of file puzzled_frame.cc.

305{
307 benchmark::chrono_swap(*this, frame);
308
309 CLBCommonHeader const*const clb_header
310 = m_container.begin()->second->getCLBCommonHeader();
311
312 int const frame_length = frameLength();
313
314 // test the frame length
315 // must be greater than 0
316 if (frame_length < 0) {
317 LOG_DEBUG << "Anomalous frame size: " << frame_length << '\n'
318 << "Read total size: " << m_totalsize << '\n'
319 << "container.size(): " << m_container.size();
320
321 Log::Counter::get().add("wrong size");
322 frame.clear();
323 return;
324 }
325
326 frame.m_seqnumber = m_seqnumber;
327 frame.resize(frame_length);
328
329 DAQCommonHeader& daq_header = *static_cast<DAQCommonHeader*>(
330 static_cast<void*>(
331 &frame.front()));
332
333 // initialise the parts of the DAQCommonHeader that are already known
334 // before the assembling of the data.
335
336 daq_header.DataType = clb_header->dataType();
337
339
340 daq_header.RunNumber = clb_header->runNumber();
341
342 daq_header.SequenceNumber = m_seqnumber;
343
344 daq_header.Timestamp.Sec = clb_header->timeStamp().sec();
345 daq_header.Timestamp.Tics = clb_header->timeStamp().tics();
346
347 daq_header.DOMIdentifier = clb_header->domIdentifier();
348
349 daq_header.NumberOfPackets = m_container.size();
350 daq_header.HighestPacketNumber
351 = m_container.rbegin()
352 ->second
353 ->getCLBCommonHeader()
354 ->udpSequenceNumber();
355
356 daq_header.DOMStatus1 = frameDomStatus(1);
357 daq_header.DOMStatus2 = frameDomStatus(2);
358 daq_header.DOMStatus3 = 0;
359 daq_header.DOMStatus4 = 0;
360
361 if (is_optical(daq_header.DataType)) {
362 if (
363 !(
364 m_container.size() > 1
365 || m_container.begin()->second->getCLBCommonHeader()->udpSequenceNumber() == 0
366 )
367 ) {
368 LOG_DEBUG << "Optical frame "
369 << m_frame_idx
370 << " contains too few data to be assembled. Ignored.";
371
372 Log::Counter::get().add("skipd oframe");
373 frame.resize(0);
374 } else {
376 }
377 } else if (is_acoustic(daq_header.DataType)) {
378 if (m_container.begin()->second->getUDPSequenceNumber() != 0) {
379 LOG_DEBUG << "Acoustic frame "
380 << m_frame_idx
381 << " without infoword. Ignored.";
382
383 Log::Counter::get().add("skipd aframe");
384 frame.resize(0);
385 } else if (m_container.begin()->second->size() <= sizeof(CLBCommonHeader)) {
386 frame.resize(0);
387 } else {
389 }
390 } else {
391 throw std::runtime_error("Unknown data type");
392 }
393
394 daq_header.FrameLength = frame.size();
395 daq_header.NumberOfItems = calculate_number_of_items(frame);
396}
unsigned int m_seqnumber
Definition frame.hh:14
uint32_t frameDomStatus(int i=1) const
uint32_t frameLength() const
bool is_acoustic(unsigned int dt)
bool is_optical(unsigned int dt)
void chrono_set(chronometrable &chr)
void buildAcou(PuzzledFrame::container_t const &c, frame_idx_t frame_idx, Frame &frame)
uint32_t calculate_number_of_items(Frame const &frame)
void buildOpto(PuzzledFrame::container_t const &c, frame_idx_t frame_idx, Frame &frame)
uint32_t dataType() const
UTCTime timeStamp() const
uint32_t runNumber() const
uint32_t domIdentifier() const
uint32_t Sec
Definition utctime.hh:14
uint32_t sec() const
Definition utctime.hh:17
uint32_t Tics
Definition utctime.hh:15
uint32_t tics() const
Definition utctime.hh:22

◆ reset()

void PuzzledFrame::reset ( )

Definition at line 398 of file puzzled_frame.cc.

399{
400 for (
401 container_t::const_iterator it = m_container.begin(), et = m_container.end();
402 it != et;
403 ++it
404 )
405 {
407 }
408
409 m_container.clear();
410
411 m_totalsize = 0;
412 m_seqnumber = 0;
413 m_detector_id = 0;
414 m_datatype = 0;
415 m_frame_idx = 0;
416}

◆ frameLength()

uint32_t PuzzledFrame::frameLength ( ) const
inline

Definition at line 99 of file puzzled_frame.hh.

100 {
101 return m_totalsize +
102 sizeof(DAQCommonHeader) -
103 sizeof(CLBCommonHeader) * m_container.size();
104 }

◆ frameDomStatus()

uint32_t PuzzledFrame::frameDomStatus ( int i = 1) const

Definition at line 21 of file puzzled_frame.cc.

22{
23 uint32_t dom_status = 0;
24 for (
25 container_t::const_iterator it = m_container.begin(), et = m_container.end();
26 it != et;
27 ++it
28 ) {
29 const CLBCommonHeader* const clb_header = it->second->getCLBCommonHeader();
30 dom_status = dom_status | clb_header->domStatus(i);
31 }
32 return dom_status;
33}
uint32_t domStatus(int n=1) const

Member Data Documentation

◆ m_container

container_t PuzzledFrame::m_container
private

Definition at line 26 of file puzzled_frame.hh.

◆ m_expiration

Timer PuzzledFrame::m_expiration
private

Definition at line 28 of file puzzled_frame.hh.

◆ m_seqnumber

unsigned int PuzzledFrame::m_seqnumber
private

Definition at line 29 of file puzzled_frame.hh.

◆ m_detector_id

unsigned int PuzzledFrame::m_detector_id
private

Definition at line 30 of file puzzled_frame.hh.

◆ m_datatype

unsigned int PuzzledFrame::m_datatype
private

Definition at line 31 of file puzzled_frame.hh.

◆ m_totalsize

unsigned int PuzzledFrame::m_totalsize
private

Definition at line 33 of file puzzled_frame.hh.

◆ m_frame_idx

frame_idx_t PuzzledFrame::m_frame_idx
private

Definition at line 35 of file puzzled_frame.hh.

◆ n_obj

boost::atomic< unsigned int > PuzzledFrame::n_obj
static
Author
cpellegrino

Definition at line 39 of file puzzled_frame.hh.


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