Jpp  18.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JDAQDriver.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <fstream>
4 #include <iomanip>
5 
6 #include "Jeep/JParser.hh"
7 #include "Jeep/JMessage.hh"
10 
13 
14 
15 /**
16  * \file
17  * Run control driver program.
18  * \author mdejong
19  */
20 int main(int argc, char* argv[])
21 {
22  using namespace std;
23 
24  string file_name;
25  string server;
26  string logger;
27  bool use_cout;
28  int timeout_s;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Run control driver program.");
34 
35  zap['f'] = make_field(file_name);
36  zap['H'] = make_field(server) = "localhost";
37  zap['M'] = make_field(logger) = "localhost";
38  zap['c'] = make_field(use_cout);
39  zap['t'] = make_field(timeout_s) = 10; // [s]
40  zap['d'] = make_field(debug) = 0;
41 
42  zap(argc, argv);
43  }
44  catch(const exception &error) {
45  FATAL(error.what() << endl);
46  }
47 
48 
49  using namespace KM3NETDAQ;
50 
51  if (server == "localhost") server = JSYSTEM::getHostname();
52  if (logger == "localhost") logger = JSYSTEM::getHostname();
53 
54  JClient::SERVER = server;
55  JClient::LOGGER = logger;
56 
57  JLogger* out = NULL;
58 
59  if (use_cout)
60  out = new JStreamLogger(cout);
61  else
62  out = new JControlHostLogger(logger);
63 
64  JDAQDriver driver(argv[0], server, out, debug, timeout_s);
65 
66  ifstream in(file_name.c_str());
67 
68  driver.run(in);
69 
70  in.close();
71 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
Simple driver for run control clients.
Definition: JDAQDriver.hh:35
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable SERVER localhost define_variable LOGGER if do_usage *then usage $script[host[local file]] fi case set_variable LOGGER
Definition: JStopDAQ.sh:23
void run()
Run driver with user input.
Definition: JDAQDriver.hh:306
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
General purpose messaging.
std::string getHostname()
Get host name.
Definition: JNetwork.hh:77
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
&set_variable SERVER
Definition: JStopDAQ.sh:29
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:46
int debug
debug level