otsdaq  v2_04_01
OtsDataSaverConsumer_processor.cc
1 #include "otsdaq-core/DataProcessorPlugins/OtsDataSaverConsumer.h"
2 #include "otsdaq-core/Macros/ProcessorPluginMacros.h"
3 
4 using namespace ots;
5 
6 //========================================================================================================================
7 OtsDataSaverConsumer::OtsDataSaverConsumer(
8  std::string supervisorApplicationUID,
9  std::string bufferUID,
10  std::string processorUID,
11  const ConfigurationTree& theXDAQContextConfigTree,
12  const std::string& configurationPath)
13  : WorkLoop(processorUID)
14  , RawDataSaverConsumerBase(supervisorApplicationUID,
15  bufferUID,
16  processorUID,
17  theXDAQContextConfigTree,
18  configurationPath)
19 {
20 }
21 
22 //========================================================================================================================
23 OtsDataSaverConsumer::~OtsDataSaverConsumer(void) {}
24 
25 //========================================================================================================================
26 void OtsDataSaverConsumer::writeHeader(void) {}
27 
28 //========================================================================================================================
29 // add one byte quad-word count before each packet
30 void OtsDataSaverConsumer::writePacketHeader(const std::string& data)
31 {
32  unsigned char quadWordsCount = (data.length() - 2) / 8;
33  outFile_.write((char*)&quadWordsCount, 1);
34 
35  // packetTypes is data[0]
36  // seqId is in data[1] position
37 
38  if(quadWordsCount)
39  {
40  unsigned char seqId = data[1];
41  if(!(lastSeqId_ + 1 == seqId || (lastSeqId_ == 255 && seqId == 0)))
42  {
43  __COUT__ << "?????? NOOOO Missing Packets: " << (unsigned int)lastSeqId_
44  << " v " << (unsigned int)seqId << __E__;
45  }
46  lastSeqId_ = seqId;
47  }
48 }
49 
50 DEFINE_OTS_PROCESSOR(OtsDataSaverConsumer)