artdaq  v3_06_00
RootNetOutput_module.cc
1 
2 #include "artdaq/ArtModules/ArtdaqOutput.hh"
3 
4 #include "artdaq/ArtModules/NetMonTransportService.h"
5 #include "artdaq/DAQdata/NetMonHeader.hh"
6 
7 // if TRACE_NAME has varible, it is safest to define after includes
8 #define TRACE_NAME (app_name + "_RootNetOutput").c_str()
9 
10 namespace art {
11 class RootNetOutput;
12 }
13 
20 {
21 public:
29  explicit RootNetOutput(fhicl::ParameterSet const& ps);
30 
35 
36 protected:
43  virtual void SendMessage(artdaq::Fragment::sequence_id_t sequence_id, artdaq::Fragment::type_t messageType, TBufferFile& msg);
44 };
45 
46 art::RootNetOutput::RootNetOutput(fhicl::ParameterSet const& ps)
47  : ArtdaqOutput(ps)
48 {
49  TLOG(TLVL_DEBUG) << "Begin: RootNetOutput::RootNetOutput(ParameterSet const& ps)";
50  ServiceHandle<NetMonTransportService> transport;
51  transport->connect();
52  TLOG(TLVL_DEBUG) << "End: RootNetOutput::RootNetOutput(ParameterSet const& ps)";
53 }
54 
56 {
57  TLOG(TLVL_DEBUG) << "Begin: RootNetOutput::~RootNetOutput()";
58  ServiceHandle<NetMonTransportService> transport;
59  transport->disconnect();
60  TLOG(TLVL_DEBUG) << "End: RootNetOutput::~RootNetOutput()";
61 }
62 
63 void art::RootNetOutput::SendMessage(artdaq::Fragment::sequence_id_t sequence_id, artdaq::Fragment::type_t messageType, TBufferFile& msg)
64 {
65  //
66  // Send message.
67  //
68  {
69  ServiceHandle<NetMonTransportService> transport;
70  if (!transport.get())
71  {
72  TLOG(TLVL_ERROR) << "Could not get handle to NetMonTransportService!";
73  return;
74  }
75  TLOG(TLVL_WRITE) << "RootNetOutput::SendMessage Sending a message with type code "
76  << artdaq::detail::RawFragmentHeader::SystemTypeToString(messageType);
77  transport->sendMessage(sequence_id, messageType, msg);
78  TLOG(TLVL_WRITE) << "RootNetOutput::SendMessage: Message sent.";
79  }
80 }
81 
82 DEFINE_ART_MODULE(art::RootNetOutput)
This is the base class for artdaq OutputModules, providing the serialization interface for art Events...
Definition: ArtdaqOutput.hh:99
virtual void SendMessage(artdaq::Fragment::sequence_id_t sequence_id, artdaq::Fragment::type_t messageType, TBufferFile &msg)
Send a message using DataSenderManager
~RootNetOutput()
RootNetOutput Destructor.
An art::OutputModule which sends events using DataSenderManager. This module is designed for transpor...
RootNetOutput(fhicl::ParameterSet const &ps)
RootNetOutput Constructor.