artdaq  v3_05_00
NetMonTransportService.h
1 #ifndef artdaq_ArtModules_NetMonTransportService_h
2 #define artdaq_ArtModules_NetMonTransportService_h
3 
4 #include "art/Framework/Services/Registry/ServiceMacros.h"
5 
6 #include "artdaq/ArtModules/NetMonTransportServiceInterface.h"
7 #include "artdaq/DAQrate/DataSenderManager.hh"
8 #include "artdaq-core/Core/SharedMemoryEventReceiver.hh"
9 
10 // ----------------------------------------------------------------------
11 
17 {
18 public:
22  struct Config
23  {
25  fhicl::Atom<uint32_t> shared_memory_key{ fhicl::Name{"shared_memory_key"},fhicl::Comment{"Key to use when connecting to shared memory. Will default to 0xBEE70000 + getppid()."},0xBEE70000 };
27  fhicl::Atom<uint32_t> broadcast_shared_memory_key{ fhicl::Name{ "broadcast_shared_memory_key" },fhicl::Comment{ "Key to use when connecting to broadcast shared memory. Will default to 0xCEE70000 + getppid()."},0xCEE70000 };
29  fhicl::Atom<int> rank{ fhicl::Name{"rank"}, fhicl::Comment{"Rank of this artdaq application. Used for data transfers"} };
31  fhicl::Atom<double> init_fragment_timeout{ fhicl::Name{"init_fragment_timeout_seconds"}, fhicl::Comment{"Amount of time to wait, in seconds, for init Fragment to arrive"}, 1.0 };
32  fhicl::TableFragment<artdaq::DataSenderManager::Config> dataSenderConfig;
33  };
35  using Parameters = fhicl::WrappedTable<Config>;
36 
37 
41  virtual ~NetMonTransportService();
42 
47  NetMonTransportService(fhicl::ParameterSet const& pset, art::ActivityRegistry&);
48 
54  void connect() override;
55 
61  void disconnect() override;
62 
66  void listen() override;
67 
74  void sendMessage(uint64_t sequenceId, uint8_t messageType, TBufferFile& msg) override;
75 
80  void receiveMessage(TBufferFile*& msg) override;
81 
82  void receiveInitMessage(TBufferFile*& msg) override;
83 
88  size_t dataReceiverCount() const { return sender_ptr_->destinationCount(); }
89 private:
90  fhicl::ParameterSet data_pset_;
91  bool init_received_;
92  double init_timeout_s_;
93 
94  std::unique_ptr<artdaq::DataSenderManager> sender_ptr_;
95  std::unique_ptr<artdaq::SharedMemoryEventReceiver> incoming_events_;
96  std::unique_ptr<std::vector<artdaq::Fragment>> recvd_fragments_;
97 
98  void setupEventReceiver_();
99 };
100 
101 DECLARE_ART_SERVICE_INTERFACE_IMPL(NetMonTransportService, NetMonTransportServiceInterface, LEGACY)
102 #endif /* artdaq_ArtModules_NetMonTransportService_h */
103 
104 // Local Variables:
105 // mode: c++
106 // End:
void receiveInitMessage(TBufferFile *&msg) override
Receive the init message.
fhicl::Atom< int > rank
&quot;rank&quot; (OPTIONAL) : The rank of this applicaiton, for use by non - artdaq applications running NetMon...
fhicl::Atom< double > init_fragment_timeout
&quot;init_fragment_timeout_seconds&quot; (Default: 1.0): Amount of time to wait, in seconds, for init Fragment to arrive
void sendMessage(uint64_t sequenceId, uint8_t messageType, TBufferFile &msg) override
Send ROOT data, wrapped in an artdaq::Fragment object.
fhicl::TableFragment< artdaq::DataSenderManager::Config > dataSenderConfig
Configuration for DataSenderManager. See artdaq::DataSenderManager::Config.
fhicl::Atom< uint32_t > broadcast_shared_memory_key
&quot;shared_memory_key&quot; (Default: 0xCEE70000 + pid): Key to use when connecting to broadcast shared memor...
NetMonTransportService extends NetMonTransportServiceInterface. It sends events using DataSenderManag...
void receiveMessage(TBufferFile *&msg) override
Receive data from the ConcurrentQueue.
Allowed Configuration parameters of NetMonTransportService. May be used for configuration validation ...
fhicl::Atom< uint32_t > shared_memory_key
&quot;shared_memory_key&quot; (Default: 0xBEE70000 + pid): Key to use when connecting to shared memory...
size_t dataReceiverCount() const
Get the number of data receivers.
void connect() override
Reconnect the NetMonTransportService.
virtual ~NetMonTransportService()
NetMonTransportService Destructor. Calls disconnect().
NetMonTransportService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)
NetMonTransportService Constructor.
void disconnect() override
Disconnects the NetMonTranportService.
Interface for NetMonTranportService. This interface is declared to art as part of the required regist...
fhicl::WrappedTable< Config > Parameters
Used for ParameterSet validation (if desired)
void listen() override
Listen for connections. This method is a No-Op.