artdaq_demo  v3_06_00
ToySimulator.hh
1 #ifndef artdaq_demo_Generators_ToySimulator_hh
2 #define artdaq_demo_Generators_ToySimulator_hh
3 
4 
5 // Some C++ conventions used:
6 
7 // -Append a "_" to every private member function and variable
8 
9 #include "fhiclcpp/fwd.h"
10 #include "artdaq-core/Data/Fragment.hh"
11 #include "artdaq/Generators/CommandableFragmentGenerator.hh"
12 #include "artdaq-core-demo/Overlays/ToyFragment.hh"
13 #include "artdaq-core-demo/Overlays/FragmentType.hh"
14 
15 #include "ToyHardwareInterface/ToyHardwareInterface.hh"
16 
17 #include <random>
18 #include <vector>
19 #include <atomic>
20 
21 namespace demo
22 {
38  {
39  public:
49  explicit ToySimulator(fhicl::ParameterSet const& ps);
50 
54  virtual ~ToySimulator();
55 
56  private:
57 
65  bool getNext_(artdaq::FragmentPtrs& output) override;
66 
67  // The start, stop and stopNoMutex methods are declared pure
68  // virtual in CommandableFragmentGenerator and therefore MUST be
69  // overridden; note that stopNoMutex() doesn't do anything here
70 
76  void start() override;
77 
83  void stop() override;
84 
89  void stopNoMutex() override {}
90 
91  std::unique_ptr<ToyHardwareInterface> hardware_interface_;
93  int timestampScale_;
94  int rollover_subrun_interval_;
95 
96  ToyFragment::Metadata metadata_;
97 
98  // buffer_ points to the buffer which the hardware interface will
99  // fill. Notice that it's a raw pointer rather than a smart
100  // pointer as the API to ToyHardwareInterface was chosen to be a
101  // C++03-style API for greater realism
102 
103  char* readout_buffer_;
104 
105  FragmentType fragment_type_;
106  ToyHardwareInterface::DistributionType distribution_type_;
107  int generated_fragments_per_event_;
108  bool exception_on_config_;
109  bool dies_on_config_;
110  };
111 }
112 
113 #endif /* artdaq_demo_Generators_ToySimulator_hh */
detail::RawFragmentHeader::timestamp_t timestamp_t
DistributionType
Allow for the selection of output distribution.
std::list< FragmentPtr > FragmentPtrs
ToySimulator(fhicl::ParameterSet const &ps)
ToySimulator Constructor.
virtual ~ToySimulator()
Shutdown the ToySimulator.
ToySimulator is a simple type of fragment generator intended to be studied by new users of artdaq as ...
Definition: ToySimulator.hh:37