artdaq_demo  v3_00_01
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/Application/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 {
37  class ToySimulator : public artdaq::CommandableFragmentGenerator
38  {
39  public:
48  explicit ToySimulator(fhicl::ParameterSet const& ps);
49 
53  virtual ~ToySimulator();
54 
55  private:
56 
64  bool getNext_(artdaq::FragmentPtrs& output) override;
65 
66  // The start, stop and stopNoMutex methods are declared pure
67  // virtual in CommandableFragmentGenerator and therefore MUST be
68  // overridden; note that stopNoMutex() doesn't do anything here
69 
75  void start() override;
76 
82  void stop() override;
83 
88  void stopNoMutex() override {}
89 
90  std::unique_ptr<ToyHardwareInterface> hardware_interface_;
91  artdaq::Fragment::timestamp_t timestamp_;
92  int timestampScale_;
93 
94  ToyFragment::Metadata metadata_;
95 
96  // buffer_ points to the buffer which the hardware interface will
97  // fill. Notice that it's a raw pointer rather than a smart
98  // pointer as the API to ToyHardwareInterface was chosen to be a
99  // C++03-style API for greater realism
100 
101  char* readout_buffer_;
102 
103  FragmentType fragment_type_;
104  ToyHardwareInterface::DistributionType distribution_type_;
105  };
106 }
107 
108 #endif /* artdaq_demo_Generators_ToySimulator_hh */
DistributionType
Allow for the selection of output distribution.
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