00001 #ifndef artdaq_ArtModules_NetMonTransportService_h
00002 #define artdaq_ArtModules_NetMonTransportService_h
00003
00004 #include "art/Framework/Services/Registry/ServiceMacros.h"
00005
00006 #include "artdaq/ArtModules/NetMonTransportServiceInterface.h"
00007 #include "artdaq/DAQrate/DataSenderManager.hh"
00008 #include "artdaq-core/Core/SharedMemoryEventReceiver.hh"
00009
00010
00011
00016 class NetMonTransportService : public NetMonTransportServiceInterface
00017 {
00018 public:
00022 struct Config
00023 {
00025 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 };
00027 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 };
00029 fhicl::Atom<int> rank{ fhicl::Name{"rank"}, fhicl::Comment{"Rank of this artdaq application. Used for data transfers"} };
00031 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 };
00032 fhicl::TableFragment<artdaq::DataSenderManager::Config> dataSenderConfig;
00033 };
00034 #if MESSAGEFACILITY_HEX_VERSION >= 0x20103
00035 using Parameters = fhicl::WrappedTable<Config>;
00036 #endif
00037
00038
00042 virtual ~NetMonTransportService();
00043
00048 NetMonTransportService(fhicl::ParameterSet const& pset, art::ActivityRegistry&);
00049
00055 void connect() override;
00056
00062 void disconnect() override;
00063
00067 void listen() override;
00068
00075 void sendMessage(uint64_t sequenceId, uint8_t messageType, TBufferFile& msg) override;
00076
00081 void receiveMessage(TBufferFile*& msg) override;
00082
00083 void receiveInitMessage(TBufferFile*& msg) override;
00084
00089 size_t dataReceiverCount() const { return sender_ptr_->destinationCount(); }
00090 private:
00091 fhicl::ParameterSet data_pset_;
00092 bool init_received_;
00093 double init_timeout_s_;
00094
00095 std::unique_ptr<artdaq::DataSenderManager> sender_ptr_;
00096 std::unique_ptr<artdaq::SharedMemoryEventReceiver> incoming_events_;
00097 std::unique_ptr<std::vector<artdaq::Fragment>> recvd_fragments_;
00098 };
00099
00100 DECLARE_ART_SERVICE_INTERFACE_IMPL(NetMonTransportService, NetMonTransportServiceInterface, LEGACY)
00101 #endif
00102
00103
00104
00105