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