28{
   31 
   33  string      usr;
   34  string      pwd;
   35  string      cookie;
   36  string      detid;
   38 
   39  try {
   40 
   41    JParser<> zap(
"Example program for compass calibration.");
 
   42    
   47    zap[
'D'] = 
make_field(detid,        
"Detector identifier")  = 
"";
 
   49 
   50    zap(argc, argv);
   51  }
   52  catch(const exception &error) {
   53    FATAL(error.what() << endl);
 
   54  }
   55 
   56 
   58  
   59  try {
   60 
   61    JDB::reset(usr, pwd, cookie);
   62 
   63    ResultSet& rs  = 
getResultSet(getTable<JAHRSCalibration>());
 
   64 
   66 
   67    rs.Close();
   68  }
   69  catch(const exception& error) {
   70    FATAL(error.what() << endl);
 
   71  }
   72 
   74 
   75  JDBToolkit::initialise(getUPI, PBS::AHRS);
   76 
   77 
   79 
   80  if (detid != "") {
   81 
   82    DEBUG(
"Reading database table " << getTable<JDetectorIntegration_t>() << endl);
 
   83 
   84    try {
   85 
   86      JDB::reset(usr, pwd, cookie);
   87 
   88      detid = getDetector<string>(detid);
   89 
   90      ResultSet& rs  = 
getResultSet(getTable<JDetectorIntegration_t>());
 
   91 
   94      }
   95    }
   96    catch(const exception& error) {
   97      FATAL(error.what() << endl);
 
   98    }
   99 
  101  }
  102 
  103 
  105 
  107 
  108 
  110 
  112 
  113    vector<JAHRSCalibration>::const_iterator q = p; 
  114 
  115    for (++q; q != 
calibration.end() && q->SERIALNUMBER == p->SERIALNUMBER; ++q) {}
 
  116 
  118    const JLocation_t location = router.getLocation(upi);
 
  119 
  121 
  122      for (vector<JAHRSCalibration>::const_iterator i = p; i != q; ++i) {
  123 
  125 
  126          if (i != p) {
  127            WARNING(
"AHRS " << location << 
' ' << upi << 
' ' 
  128                    << "invalid calibration"          << ' '
  129                    << p->TESTEND << 
" v" << 
getVersion(p->TESTNAME) << 
" -> " 
  130                    << i->TESTEND << 
" v" << 
getVersion(i->TESTNAME) << endl);
 
  132          }
  133 
  134          zmap[location] = *i;
  135 
  136          break;
  137        }
  138      }
  139    }
  140 
  141    for (vector<JAHRSCalibration>::const_iterator i = p; i != q; ++i) {
  142 
  143      const bool valid = 
is_valid(*i) || (i != p);
 
  144 
  145      if (
debug >= debug_t) {
 
  146 
  147        cout << setw(8)  << i->SERIALNUMBER         << ' '
  148             << setw(22) << left << upi << right    << ' '
  149             << setw(8)  << i->TESTEND              << ' '
  150             << setw(8)  << i->FIRMWARE_VERSION     << ' '
  152             << setw(10) << i->TESTOPID             << ' ' 
  153             << (valid ? "" : "*") << endl;
  154 
  155        if (!valid) {
  156          
  157        }
  158      }
  159    }
  160 
  161    p = q;
  162  }
  163 
  165 
  169 
  170    cout << location << "  ";
  171 
  173    
  175 
  176    if (
distance(r1.first, r1.second) == 1) {
 
  177 
  179 
  180      if (
distance(r2.first, r2.second) == 1) {
 
  181        cout << setw(22) << left << 
detector[r2.first->second].container.getUPI() << right << 
' ';
 
  182        cout << setw(22) << left << 
detector[r1.first->second].container.getUPI() << right << 
' ';
 
  183        cout << setw(22) << left << upi                                           << right << ' ';
  184      }
  185    }
  186 
  187    cout << setw(3)  << (
calibration.FIRMWARE_VERSION != 
"" ?
 
  189                         "?")                            << ' ';
  192    cout << endl;
  193  }
  194 
  195  return 0;
  196}
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
 
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
 
Utility class to parse command line options.
 
int getVersion(const std::string &version)
Get numerical value of AHRS calibration version.
 
ResultSet & getResultSet(const std::string &query)
Get result set.
 
JUPIHelper & getUPI()
Auxiliary function for helper object initialisation.
 
std::vector< JServer > getServernames()
Get list of names of available database servers.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
bool is_valid(const json &js)
Check validity of JSon data.
 
Auxiliary data structure for sorting of AHRS calibrations.
 
Auxiliary data structure to check validity of AHRS calibration data.
 
Auxiliary data structure for location of product in detector.
 
bool is_valid() const
Check validity of location.
 
Auxiliary class to map UPI to location in detector.
 
Wrapper class for server name.
 
Universal product identifier (UPI).