FairRoot/PandaRoot
PndMQTopix4Sink.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
15 #include <boost/thread.hpp>
16 #include <boost/bind.hpp>
17 #include <boost/archive/binary_iarchive.hpp>
18 #include <PndMQTopix4Sink.h>
19 
20 #include "baseMQtools.h"
21 
22 #include "FairMQLogger.h"
23 #include "mrfdata_8b.h"
24 #include "PndSdsDigiTopix4.h"
25 
26 #include <TH2.h>
27 #include <TCanvas.h>
28 
29 
30 using namespace std;
31 
32 PndMQTopix4Sink::PndMQTopix4Sink() : fHasBoostSerialization(false)
33 {
34  //gSystem->ResetSignal(kSigInterrupt);
35  //gSystem->ResetSignal(kSigTermination);
36 
37  using namespace baseMQ::tools::resolve;
38  // coverity[pointless_expression]: suppress coverity warnings on apparant if(const).
39  if (has_BoostSerialization<PndSdsDigiTopix4, void(boost::archive::binary_iarchive&, const unsigned int)>::value == 1)
41 }
42 
43 //void PndMQTopix4Sink::CustomCleanup(void *data, void *object)
44 //{
45 // delete (string*)object;
46 //}
47 
49 {
50  LOG(INFO) << "Boost Serialization "<< fHasBoostSerialization;
52  FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
53  int receivedMsgs = 0;
54 
55  while (CheckCurrentState(RUNNING))
56  {
57  FairMQMessage* msg = fTransportFactory->CreateMessage();
58 
59  if (dataInChannel.Receive(msg) > 0)
60  {
61  LOG(INFO) << "Received Message: ";
62  LOG(INFO) << receivedMsgs++;
63  LOG(INFO) << msg->GetSize();
64 
65  string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
66  istringstream ibuffer(msgStr);
67 
68  boost::archive::binary_iarchive InputArchive(ibuffer);
69 
70  try {
71  InputArchive >> fTopixData;
72  }
73  catch (boost::archive::archive_exception& e)
74  {
75  LOG(ERROR) << e.what();
76  }
77 
78  LOG(INFO) << "TopixData: " << fTopixData.size();
79 
80  if (fTopixData.size() > 0){
81  // ostringstream obuffer;
82  // boost::archive::binary_oarchive OutputArchive(obuffer);
83  // OutputArchive << frames.front();
84  // int outputSize = obuffer.str().length();
85  // unique_ptr<FairMQMessage> msg2(fTransportFactory->CreateMessage(const_cast<char*>(obuffer.str().c_str()), outputSize, CustomCleanup, &obuffer));
86  // fChannels.at("data-out").at(0).Send(msg);
87  LOG(INFO) << "Data: " << fTopixData.size() << " " << fTopixData.front() << std::endl;
88  }
89  delete(msg);
90 
91 
92  if (fTopixData.size() > 0)
93  fTopixData.clear();
94  }
95  }
96  }
97 }
98 
100 {
101 }
Data class to store the digi output of a pixel module.
virtual void Run()
virtual ~PndMQTopix4Sink()
std::vector< PndSdsDigiTopix4 > fTopixData