NSCL DDAS  12.1-001
Support for XIA DDAS at FRIB
DDASSorter.h
Go to the documentation of this file.
1 /*
2  This software is Copyright by the Board of Trustees of Michigan
3  State University (c) Copyright 2017.
4 
5  You may use this software under the terms of the GNU public license
6  (GPL). The terms of this license are described at:
7 
8  http://www.gnu.org/licenses/gpl.txt
9 
10  Authors:
11  Ron Fox
12  Giordano Cerriza
13  NSCL
14  Michigan State University
15  East Lansing, MI 48824-1321
16 */
17 
23 #ifndef DDASSORTER_H
24 #define DDASSORTER_H
25 
26 #include <deque>
27 
28 #include <CRingBufferChunkAccess.h>
29 
30 class CRingBuffer;
31 
32 namespace DDASReadout {
33  class BufferArena;
34  class ReferenceCountedBuffer;
35  class ZeroCopyHit;
36  class HitManager;
37 }
38 
39 
40 typedef struct _RingItemHeader *pRingItemHeader;
41 
56 {
57 private:
58  CRingBuffer& m_source;
59  CRingBuffer& m_sink;
60  DDASReadout::HitManager* m_pHits;
61  DDASReadout::BufferArena* m_pArena;
62  std::deque<DDASReadout::ZeroCopyHit*> m_hits;
63  uint32_t m_sid;
64  double m_lastEmittedTimestamp;
65 
66 public:
73  DDASSorter(CRingBuffer& source, CRingBuffer& sink, float window=10.0);
75  ~DDASSorter();
76 
78  void operator()();
79 
80 private:
85  void processChunk(CRingBufferChunkAccess::Chunk& chunk);
90  void outputRingItem(pRingItemHeader pItem);
97  void processHits(pRingItemHeader pItem);
99  void flushHitManager();
105  DDASReadout::ZeroCopyHit* allocateHit();
111  void freeHit(DDASReadout::ZeroCopyHit* pHit);
113  void outputHit(DDASReadout::ZeroCopyHit* pHit);
114 };
115 
116 #endif
struct _RingItemHeader * pRingItemHeader
Definition: DDASSorter.h:40
Provides a class for memory management in reference-counted buffers.
Definition: BufferArena.h:51
Collect hits from modules and retains them in a sorted deque.
Definition: HitManager.h:49
This class extends RawChannel to produce a raw channel that is zero-copied from a reference counted b...
Definition: ZeroCopyHit.h:55
Class to manage data flow and timestamp ordering.
Definition: DDASSorter.h:56
DDASSorter(CRingBuffer &source, CRingBuffer &sink, float window=10.0)
Constructor.
Definition: DDASSorter.cpp:44
~DDASSorter()
Destructor.
Definition: DDASSorter.cpp:56
void operator()()
Defines the dataflow of the sorter.
Definition: DDASSorter.cpp:67
Definition: BufferArena.cpp:29