Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
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
23namespace {
24
25 using namespace JPP;
26
27 /**
28 * Auxiliary class to control object throughput.
29 */
30 struct JRegulator_t :
31 public JRegulator,
32 public JTimekeeper
33 {
34 /**
35 * Constructor.
36 *
37 * \param rate_Hz rate [Hz]
38 * \param time_s time [s]
39 */
40 JRegulator_t(const double rate_Hz,
41 const double time_s)
42 {
43 setInterval((long long int) (1.0e6 / rate_Hz));
44
45 t1 = getLocalTime() + (localtime_t) (1.0e6 * time_s);
46 }
47
48
49 /**
50 * Accept.
51 *
52 * \return true
53 */
54 virtual bool accept() const
55 {
56 if ((bool) (*this)) {
57
58 this->wait();
59
60 return true;
61 }
62
63 return false;
64 }
65
66
67 /**
68 * Type conversion operator.
69 *
70 * \return true if within time; else false
71 */
72 inline operator bool() const
73 {
74 return getLocalTime() < t1;
75 }
76
77
78 protected:
79 localtime_t t1;
80 };
81}
82
83
84/**
85 * \file
86 * Auxiliary program to send objects to JLigier.cc server.
87 * The option <tt>-H <hostname>[:port]</tt> correponds to the hostname and the port of the server, respectively.
88 * \author mdejong
89 */
90int main(int argc, const char *argv[])
91{
92 using namespace std;
93 using namespace JPP;
94
95 typedef JDAQTypes_t typelist;
96
98 string hostname;
99 JROOTClassSelector selector;
100 double rate_Hz;
101 double time_s;
102 int debug;
103 bool eof;
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 zap['C'] = JPARSER::not_initialised();
116 zap['e'] = make_field(eof);
117
118 zap(argc, argv);
119 }
120 catch(const exception &error) {
121 FATAL(error.what() << endl);
122 }
123
125
126 for (JRegulator_t regulator(rate_Hz, time_s); regulator; inputFile.rewind()) {
127 inputFile | JValve<typelist>(selector) | regulator | out;
128 if (eof) {
129 break;
130 }
131 }
132
133}
Fixed parameters and ControlHost tags for KM3NeT DAQ.
General purpose messaging.
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Implementation of pipe operation for object iterators.
int main(int argc, const char *argv[])
ROOT TTree parameter settings of various packages.
Scheduling of actions via fixed latency intervals.
Time keeper.
Interface for controlling object throughput.
Definition JRegulator.hh:20
Auxiliary class for selection of data type.
Definition JValve.hh:23
Implemenation of object output through ControlHost.
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual void rewind() override
Rewind.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::set< JROOTClassSelector > getROOTClassSelection(const bool option=false)
Get ROOT class selection.
static const JLocalTime getLocalTime
Function object to get local time in micro seconds.
long long int localtime_t
Type definition of local time.
Type list.
Definition JTypeList.hh:23
Empty structure for specification of parser element that is not initialised (i.e. does require input)...
Definition JParser.hh:74
Auxiliary class to select ROOT class based on class name.