artdaq  v3_02_01
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  };
34 #if MESSAGEFACILITY_HEX_VERSION >= 0x20103
35  using Parameters = fhicl::WrappedTable<Config>;
36 #endif
37 
38 
42  virtual ~NetMonTransportService();
43 
48  NetMonTransportService(fhicl::ParameterSet const& pset, art::ActivityRegistry&);
49 
55  void connect() override;
56 
62  void disconnect() override;
63 
67  void listen() override;
68 
75  void sendMessage(uint64_t sequenceId, uint8_t messageType, TBufferFile& msg) override;
76 
81  void receiveMessage(TBufferFile*& msg) override;
82 
83  void receiveInitMessage(TBufferFile*& msg) override;
84 
89  size_t dataReceiverCount() const { return sender_ptr_->destinationCount(); }
90 private:
91  fhicl::ParameterSet data_pset_;
92  bool init_received_;
93  double init_timeout_s_;
94 
95  std::unique_ptr<artdaq::DataSenderManager> sender_ptr_;
96  std::unique_ptr<artdaq::SharedMemoryEventReceiver> incoming_events_;
97  std::unique_ptr<std::vector<artdaq::Fragment>> recvd_fragments_;
98 };
99 
100 DECLARE_ART_SERVICE_INTERFACE_IMPL(NetMonTransportService, NetMonTransportServiceInterface, LEGACY)
101 #endif /* artdaq_ArtModules_NetMonTransportService_h */
102 
103 // Local Variables:
104 // mode: c++
105 // 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...
void listen() override
Listen for connections. This method is a No-Op.