Jpp  18.5.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JCLBID.cc File Reference

Example program for module identification. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JDB/JDB.hh"
#include "JDB/JSelector.hh"
#include "JDB/JSelectorSupportkit.hh"
#include "JDB/JDetectorIntegration_t.hh"
#include "JDB/JProductRouter.hh"
#include "JDB/JCLBID.hh"
#include "JDB/JDBToolkit.hh"
#include "JLang/JComparator.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program for module identification.

Author
mdejong

Definition in file JCLBID.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file JCLBID.cc.

28 {
29  using namespace std;
30  using namespace JPP;
31 
32  JServer server;
33  string usr;
34  string pwd;
35  string cookie;
36  string detectorFile;
37  int debug;
38 
39  try {
40 
41  JParser<> zap("Example program for module identification.");
42 
43  zap['s'] = make_field(server) = getServernames();
44  zap['u'] = make_field(usr) = "";
45  zap['!'] = make_field(pwd) = "";
46  zap['C'] = make_field(cookie) = "";
47  zap['a'] = make_field(detectorFile);
48  zap['d'] = make_field(debug) = 3;
49 
50  zap(argc, argv);
51  }
52  catch(const exception &error) {
53  FATAL(error.what() << endl);
54  }
55 
56 
57  JDetectorIntegration_t detector;
58 
59  DEBUG("Reading database table " << getTable<JDetectorIntegration_t>() << endl);
60 
61  try {
62 
63  JDB::reset(usr, pwd, cookie);
64 
65  ResultSet& rs = getResultSet(getTable<JDetectorIntegration_t>());
66 
67  if (! (rs >> detector)) {
68  THROW(JDatabaseException, "Error reading " << getTable<JDetectorIntegration_t>());
69  }
70  }
71  catch(const exception& error) {
72  FATAL(error.what() << endl);
73  }
74 
75 
76  JDetector detx;
77 
78  try {
79  load(detectorFile, detx);
80  }
81  catch(const JException& error) {
82  FATAL(error);
83  }
84 
85 
86  detector.configure(getDetector(detx.getID()));
87 
88  const JProductRouter router(detector, PBS::CLB_SEQUENCES);
89 
91 
92  for (JDetectorIntegration_t::range_const_iterator i = range.first; i != range.second; ++i) {
93 
94  const JUPI_t upi = detector[i->second].content.getUPI();
95  const JLocation_t location = router.getLocation(upi);
96 
97  cout << setw(24) << left << upi << right << ' '
98  << setw(4) << location.string << ' '
99  << setw(2) << location.floor << ' '
100  << setw(10) << getCLBID(upi) << ' ';
101 
102  for (JDetector::const_iterator module = detx.begin(); module != detx.end(); ++module) {
103 
104  if (module->getString() == location.string &&
105  module->getFloor() == location.floor) {
106 
107  cout << setw(10) << module->getID();
108 
109  break;
110  }
111  }
112 
113  cout << endl;
114  }
115 
116  return 0;
117 }
Utility class to parse command line options.
Definition: JParser.hh:1514
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:378
JRange< int > range_type
static const JPBS_t CLB(3, 4, 3, 2)
PBS of central-logic board
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
JCLBIDHelper & getCLBID()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:426
static const JPBSSequences CLB_SEQUENCES
PBS sequences for central-logic board.
#define FATAL(A)
Definition: JMessage.hh:67
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
void reset(T &value)
Reset value.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
ResultSet & getResultSet(const std::string &query)
Get result set.
Definition: JDB.hh:436
std::vector< JServer > getServernames()
Get list of names of available database servers.
Definition: JDB.hh:106
do set_variable DETECTOR_TXT $WORKDIR detector
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62