artdaq_mfextensions  v1_03_03a
ReceiverManager.cc
1 #include "mfextensions/Binaries/ReceiverManager.hh"
2 
3 #include <iostream>
4 #include "fhiclcpp/ParameterSet.h"
5 #include "mfextensions/Receivers/makeMVReceiver.hh"
6 
7 mfviewer::ReceiverManager::ReceiverManager(fhicl::ParameterSet pset) {
8  qRegisterMetaType<qt_mf_msg>("qt_mf_msg");
9  std::vector<std::string> names = pset.get_pset_names();
10  for (auto name : names) {
11  std::string pluginType = "unknown";
12  try {
13  fhicl::ParameterSet plugin_pset = pset.get<fhicl::ParameterSet>(name);
14  pluginType = plugin_pset.get<std::string>("receiverType", "unknown");
15  std::unique_ptr<mfviewer::MVReceiver> rcvr = makeMVReceiver(pluginType, plugin_pset);
16  connect(rcvr.get(), SIGNAL(NewMessage(qt_mf_msg const&)), this, SLOT(onNewMessage(qt_mf_msg const&)));
17  receivers_.push_back(std::move(rcvr));
18  } catch (...) {
19  std::cerr << "ReceiverManager: Unable to load receiver plugin with name " << name << " and plugin type "
20  << pluginType << std::endl;
21  }
22  }
23 }
24 
26  stop();
27  for (auto& i : receivers_) i.reset(nullptr);
28 }
29 
31  for (auto& receiver : receivers_) {
32  receiver->stop();
33  }
34  for (auto& receiver : receivers_) {
35  receiver->wait();
36  }
37 }
38 
40  for (auto& receiver : receivers_) {
41  receiver->start();
42  }
43 }
44 
45 void mfviewer::ReceiverManager::onNewMessage(qt_mf_msg const& mfmsg) { emit newMessage(mfmsg); }
ReceiverManager(fhicl::ParameterSet pset)
ReceiverManager Constructor
void start()
Start all receivers
Qt wrapper around MessageFacility message
Definition: qt_mf_msg.hh:30
virtual ~ReceiverManager()
ReceiverManager Destructor
void stop()
Stop all receivers