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:
00019 struct Config
00020 {
00021 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 };
00022 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 };
00023 fhicl::Atom<int> rank{ fhicl::Name{"rank"}, fhicl::Comment{"Rank of this artdaq application. Used for data transfers"} };
00024 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 };
00025 fhicl::TableFragment<artdaq::DataSenderManager::Config> dataSenderConfig;
00026 };
00027 #if MESSAGEFACILITY_HEX_VERSION >= 0x20103
00028 using Parameters = fhicl::WrappedTable<Config>;
00029 #endif
00030
00031
00035 virtual ~NetMonTransportService();
00036
00046 NetMonTransportService(fhicl::ParameterSet const& pset, art::ActivityRegistry&);
00047
00053 void connect() override;
00054
00060 void disconnect() override;
00061
00065 void listen() override;
00066
00073 void sendMessage(uint64_t sequenceId, uint8_t messageType, TBufferFile& msg) override;
00074
00079 void receiveMessage(TBufferFile*& msg) override;
00080
00081 void receiveInitMessage(TBufferFile*& msg) override;
00082
00087 size_t dataReceiverCount() const { return sender_ptr_->destinationCount(); }
00088 private:
00089 fhicl::ParameterSet data_pset_;
00090 bool init_received_;
00091 double init_timeout_s_;
00092
00093 std::unique_ptr<artdaq::DataSenderManager> sender_ptr_;
00094 std::unique_ptr<artdaq::SharedMemoryEventReceiver> incoming_events_;
00095 std::unique_ptr<std::vector<artdaq::Fragment>> recvd_fragments_;
00096 };
00097
00098 DECLARE_ART_SERVICE_INTERFACE_IMPL(NetMonTransportService, NetMonTransportServiceInterface, LEGACY)
00099 #endif
00100
00101
00102
00103