otsdaq_mu2e  v2_04_02
DataGenReceiver.hh
1 #ifndef artdaq_ots_Generators_DataGenReceiver_hh
2 #define artdaq_ots_Generators_DataGenReceiver_hh
3 
4 // Some C++ conventions used:
5 
6 // -Append a "_" to every private member function and variable
7 
8 #include "artdaq/Application/CommandableFragmentGenerator.hh"
9 
10 #include <chrono>
11 
12 #include "artdaq-core/Data/Fragments.hh"
13 #include "fhiclcpp/fwd.h"
14 //#include "artdaq-ots/Generators/UDPReceiver.hh"
15 #include "otsdaq-core/DataManager/DataConsumer.h"
16 
17 #include <arpa/inet.h>
18 #include <netinet/in.h>
19 #include <sys/socket.h>
20 #include <sys/types.h>
21 #include <unistd.h>
22 
23 #include <array>
24 #include <atomic>
25 #include <list>
26 #include <queue>
27 
28 namespace ots
29 {
30 class DataGenReceiver : public ots::DataConsumer,
31  public artdaq::CommandableFragmentGenerator
32 {
33  public:
34  explicit DataGenReceiver(fhicl::ParameterSet const& ps);
35 
36  bool getNext_(artdaq::FragmentPtrs& output) override;
37 
38  void startProcessingData(std::string runNumber) { ; }
39  void stopProcessingData(void) { ; }
40  void resumeProcessingData(void) { ; }
41  void pauseProcessingData(void) { ; }
42 
43  void start() override;
44  virtual void stop() override;
45  virtual void stopNoMutex() override;
46 
47  private:
48  bool workLoopThread(toolbox::task::WorkLoop* workLoop) { return false; }
49  void ProcessData_(artdaq::FragmentPtrs& frags);
50  std::string buffer_;
51 
52  // FHiCL-configurable variables. Note that the C++ variable names
53  // are the FHiCL variable names with a "_" appended
54  bool rawOutput_;
55  std::string rawPath_;
56  int dataport_;
57  std::string ip_;
58  uint8_t expectedPacketNumber_;
59  bool sendCommands_;
60  double fragmentWindow_;
61  std::chrono::high_resolution_clock::time_point lastFrag_;
62 };
63 } // namespace ots
64 
65 #endif /* artdaq_demo_Generators_ToySimulator_hh */