Jpp  18.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRegurgitate.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
6 #include "JDAQ/JDAQEventIO.hh"
8 
10 #include "JSupport/JSupport.hh"
11 
13 #include "JLang/JPipe.hh"
14 #include "JLang/JValve.hh"
15 
16 #include "JDAQ/JDAQTags.hh"
18 
19 #include "Jeep/JTimekeeper.hh"
20 #include "Jeep/JParser.hh"
21 #include "Jeep/JMessage.hh"
22 
23 
24 namespace {
25 
26  using namespace JPP;
27 
28  /**
29  * Auxiliary class to control object throughput.
30  */
31  struct JRegulator_t :
32  public JRegulator,
33  public JTimekeeper
34  {
35  /**
36  * Constructor.
37  *
38  * \param rate_Hz rate [Hz]
39  * \param time_s time [s]
40  */
41  JRegulator_t(const double rate_Hz,
42  const double time_s)
43  {
44  setInterval((long long int) (1.0e6 / rate_Hz));
45 
46  t1 = getLocalTime() + (localtime_t) (1.0e6 * time_s);
47  }
48 
49 
50  /**
51  * Accept.
52  *
53  * \return true
54  */
55  virtual bool accept() const
56  {
57  if ((bool) (*this)) {
58 
59  this->wait();
60 
61  return true;
62  }
63 
64  return false;
65  }
66 
67 
68  /**
69  * Type conversion operator.
70  *
71  * \return true if within time; else false
72  */
73  inline operator bool() const
74  {
75  return getLocalTime() < t1;
76  }
77 
78 
79  protected:
80  localtime_t t1;
81  };
82 }
83 
84 
85 /**
86  * \file
87  * Auxiliary program to send objects to JLigier.cc server.
88  * The option <tt>-H <hostname>[:port]</tt> correponds to the hostname and the port of the server, respectively.
89  * \author mdejong
90  */
91 int main(int argc, const char *argv[])
92 {
93  using namespace std;
94  using namespace JPP;
95 
96  typedef JDAQTypes_t typelist;
97 
99  string hostname;
100  JROOTClassSelector selector;
101  double rate_Hz;
102  double time_s;
103  int debug;
104 
105  try {
106 
107  JParser<> zap("Auxiliary program to send objects to JLigier server.");
108 
109  zap['f'] = make_field(inputFile);
110  zap['H'] = make_field(hostname) = "localhost";
111  zap['C'] = make_field(selector) = getROOTClassSelection<typelist>();
112  zap['R'] = make_field(rate_Hz);
113  zap['T'] = make_field(time_s);
114  zap['d'] = make_field(debug) = 1;
115 
116  zap['C'] = JPARSER::not_initialised();
117 
118  zap(argc, argv);
119  }
120  catch(const exception &error) {
121  FATAL(error.what() << endl);
122  }
123 
124 
126 
127  for (JRegulator_t regulator(rate_Hz, time_s); regulator; inputFile.rewind()) {
128  inputFile | JValve<typelist>(selector) | regulator | out;
129  }
130 }
131 
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
ROOT TTree parameter settings of various packages.
Auxiliary class to select ROOT class based on class name.
Time keeper.
Definition: JTimekeeper.hh:34
Auxiliary class for selection of data type.
Type list.
Definition: JTypeList.hh:22
Scheduling of actions via fixed latency intervals.
Interface for controlling object throughput.
Definition: JRegulator.hh:18
static const JLocalTime getLocalTime
Function object to get local time in micro seconds.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Implementation of pipe operation for object iterators.
General purpose messaging.
long long int localtime_t
Type definition of local time.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Empty structure for specification of parser element that is not initialised (i.e. does require input)...
Definition: JParser.hh:89
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
Implemenation of object output through ControlHost.
bool accept(const Trk &trk, const Evt &evt)
Event selection.
Fixed parameters and ControlHost tags for KM3NeT DAQ.
int debug
debug level