Jpp  17.0.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAHRSCalibration.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 
4 #include "JDB/JDB.hh"
5 #include "JDB/JDBToolkit.hh"
6 #include "JDB/JSelector.hh"
9 
10 #include "Jeep/JParser.hh"
11 #include "Jeep/JMessage.hh"
12 
13 
14 /**
15  * \file
16  *
17  * Auxiliary program to store AHRS calibration data on local disk.
18  * \author mdejong
19  */
20 int main(int argc, char **argv)
21 {
22  using namespace std;
23  using namespace JPP;
24 
25  JServer server;
26  string usr;
27  string pwd;
28  string cookie;
29  int option;
30  string detid;
31  string outputFile;
32  int debug;
33 
34  try {
35 
36  JParser<> zap("Auxiliary program to store AHRS calibration data on local disk.");
37 
38  zap['s'] = make_field(server) = getServernames();
39  zap['u'] = make_field(usr) = "";
40  zap['!'] = make_field(pwd) = "";
41  zap['C'] = make_field(cookie) = "";
42  zap['O'] = make_field(option) = 0;
43  zap['D'] = make_field(detid);
44  zap['o'] = make_field(outputFile) = "ahrs_calibration.txt";
45  zap['d'] = make_field(debug) = 2;
46 
47  zap(argc, argv);
48  }
49  catch(const exception &error) {
50  FATAL(error.what() << endl);
51  }
52 
53 
54  try {
55 
56  JDB::reset(usr, pwd, cookie);
57 
58  STATUS("Reading AHRS calibration data... " << flush);
59 
60  const JAHRSCalibration_t calibration(getDetector<int>(detid), option);
61 
62  STATUS("OK" << endl);
63 
64  if (outputFile != "") {
65 
66  STATUS("Storing AHRS calibration data to " << outputFile << "... " << flush);
67 
68  calibration.store(outputFile.c_str());
69 
70  STATUS("OK" << endl);
71 
72  } else {
73 
74  cout << calibration << endl;
75  }
76  }
77  catch(const exception& error) {
78  FATAL(error.what() << endl);
79  }
80 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
#define STATUS(A)
Definition: JMessage.hh:63
string outputFile
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:66
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
void reset(T &value)
Reset value.
Utility class to parse command line options.
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:98