#include #include #include #include "JDAQ/JDAQTimesliceIO.hh" #include "JDAQ/JDAQEventIO.hh" #include "JDAQ/JDAQSummarysliceIO.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JSupport.hh" #include "JROOT/JROOTClassSelector.hh" #include "JLang/JPipe.hh" #include "JLang/JValve.hh" #include "JDAQ/JDAQTags.hh" #include "JNet/JControlHostObjectOutput.hh" #include "Jeep/JTimekeeper.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { using namespace JPP; /** * Auxiliary class to control object throughput. */ struct JRegulator_t : public JRegulator, public JTimekeeper { /** * Constructor. * * \param rate_Hz rate [Hz] * \param time_s time [s] */ JRegulator_t(const double rate_Hz, const double time_s) { setInterval((long long int) (1.0e6 / rate_Hz)); t1 = getLocalTime() + (localtime_t) (1.0e6 * time_s); } /** * Accept. * * \return true */ virtual bool accept() const { if ((bool) (*this)) { this->wait(); return true; } return false; } /** * Type conversion operator. * * \return true if within time; else false */ inline operator bool() const { return getLocalTime() < t1; } protected: localtime_t t1; }; } /** * \file * Auxiliary program to send objects to JLigier.cc server. * The option -H \[:port] correponds to the hostname and the port of the server, respectively. * \author mdejong */ int main(int argc, const char *argv[]) { using namespace std; using namespace JPP; typedef JDAQTypes_t typelist; JMultipleFileScanner inputFile; string hostname; JROOTClassSelector selector; double rate_Hz; double time_s; int debug; bool eof; try { JParser<> zap("Auxiliary program to send objects to JLigier server."); zap['f'] = make_field(inputFile); zap['H'] = make_field(hostname) = "localhost"; zap['C'] = make_field(selector) = getROOTClassSelection(); zap['R'] = make_field(rate_Hz); zap['T'] = make_field(time_s); zap['d'] = make_field(debug) = 1; zap['C'] = JPARSER::not_initialised(); zap['e'] = make_field(eof); zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JControlHostObjectOutput out(hostname); for (JRegulator_t regulator(rate_Hz, time_s); regulator; inputFile.rewind()) { inputFile | JValve(selector) | regulator | out; if (eof) { break; } } }