ifbConfig Class Reference

List of all members.

Public Member Functions

 ifbConfig ()
 ~ifbConfig ()
void ParseArgv (int argc, char **argv)
void Usage (std::string msg, int exitval)
void PrintConfig ()

Public Attributes

int Verbose
bool PrintAndQuit
bool CountAndQuit
bool AllowRotoErrors
double TimeStamp
double WindowSize
std::string BundleName
std::string RotoNode
std::string URLifbeam
double CacheWindow
double Epsilon
double DeltaCacheTime
int TClkTriggerEvent
int TClkTriggerDelay
int DtTolerance
std::string PrintOpts

Detailed Description

Definition at line 54 of file ifbtorr.cc.


Constructor & Destructor Documentation

ifbConfig::ifbConfig (  ) 

Definition at line 188 of file ifbtorr.cc.

00189   : Verbose(0)               // quiet
00190   , PrintAndQuit(false)      // quit after parsing argv and print config
00191   , CountAndQuit(false)      // count # of spills w/o rotorooter connection
00192   , AllowRotoErrors(false)   // continue after rotorooter connection/file errs
00193   , TimeStamp(0)             // user must supply starting time
00194   , WindowSize(8*60*60)      // default window is 8 hours
00195   , BundleName("NuMI_all")   // default bundle
00196   , RotoNode("minos-nearline.fnal.gov") // default where rotorooter is running
00197   // URL for ifbeam db connection, default "" allows code to choose own default
00198   // might be something like "http://dbweb3.fnal.gov:8088/ifbeam" to override
00199   , URLifbeam("")
00200   , CacheWindow(-1)          // use BeamFolder default by default
00201   , Epsilon(0.05)            // BeamFolder matching epsilon?
00202   , DeltaCacheTime(0.0001)   // start new cache this long after previous
00203   , TClkTriggerEvent(169)
00204   , TClkTriggerDelay(500)
00205   , DtTolerance(500)         // allowed time between spill and device times
00206                              // without complaint
00207   , PrintOpts("")
00208 {
00209   // example timestamp
00210   //   TimeStamp = 1373660869;  // Fri Jul 12 15:27:49 CDT 2013
00211   //                            // 2013-07-12 20:27:49 UTC
00212   //                            // 2013-07-12 15:27:49 local
00213 }

ifbConfig::~ifbConfig (  )  [inline]

Definition at line 57 of file ifbtorr.cc.

00057 { ; }


Member Function Documentation

void ifbConfig::ParseArgv ( int  argc,
char **  argv 
)

Definition at line 244 of file ifbtorr.cc.

References AllowRotoErrors, BundleName, CacheWindow, CountAndQuit, DeltaCacheTime, DtTolerance, Epsilon, option, ParseTimeString(), PrintAndQuit, PrintOpts, RotoNode, TClkTriggerDelay, TClkTriggerEvent, TimeStamp, URLifbeam, Usage(), Verbose, and WindowSize.

Referenced by main().

00244                                                {
00245 
00246   /*
00247    * Define the options
00248    *
00249    */
00250 
00251   static struct option long_opts[] = {
00252     { "help",         no_argument,       0, 'h' },
00253     { "timestamp",    required_argument, 0, 't' },
00254     { "timestring",   required_argument, 0, 'T' },
00255     { "window",       required_argument, 0, 'w' },
00256     { "bundle",       required_argument, 0, 'b' },
00257     { "rotonode",     required_argument, 0, 'r' },
00258     { "url",          required_argument, 0, 'u' },
00259     { "print-config", no_argument,       0, 'C' },
00260     { "count-spills", no_argument,       0, 'c' },
00261     { "verbose",      no_argument,       0, 'v' },
00262     { "bypass-roto",  no_argument,       0, 'A' },
00263     { "cache-window", required_argument, 0, 'z' },
00264     { "cache-delta",  required_argument, 0, 'd' },
00265     { "epsilon",      required_argument, 0, 'e' },
00266     { "tclk-event",   required_argument, 0, 'E' },
00267     { "tclk-delay",   required_argument, 0, 'D' },
00268     { "dt-tolerance", required_argument, 0, 'q' },
00269     { "print-opts",   required_argument, 0, 'P' },
00270     { 0, 0, 0, 0 } // signal end of list
00271   };
00272   const char short_opts[] = "ht:T:w:W:b:r:u:CcvAz:d:e:E:D:q:P:";
00273 
00274   /*
00275    * Parse the options
00276    *
00277    */
00278 
00279   // getopt_long stored the option index here
00280 #ifndef MACOSX
00281   optind = 0; // getopt.h: Reset getopt to start of arguments
00282 #else
00283   optind = 1; // skip 0th argument (executable) for MACOSX
00284 #endif
00285   int opt_index = 0;
00286   int c;
00287   while ((c = getopt_long(argc,argv,short_opts,long_opts,&opt_index)) != -1 ) {
00288     if (Verbose>1) {
00289       std::cout << " c from getopt_long " << c << " '" << (char)c << "'"
00290                 << " optarg \"" << (optarg?optarg:"") << "\""
00291                 << std::endl;
00292     }
00293     switch ( c ) {
00294     case 0: {
00295       // if option set a flag, do nothing else
00296       if ( long_opts[opt_index].flag != 0 ) {
00297         if (Verbose>1) {
00298           std::cout << " c==0  opt_index " << opt_index
00299                     << " flag " << long_opts[opt_index].flag << std::endl;
00300         }
00301         break;
00302       }
00303       std::string opt_name = long_opts[opt_index].name;
00304       if (Verbose>1) {
00305         std::cout << "c==0  opt_index " << opt_index
00306                   << " opt_name=\"" << opt_name
00307                   << "\" optarg=\"" << optarg << "\"" << std::endl;
00308       }
00309       break;
00310     }
00311     case 'h': {
00312       Usage("",0);
00313       break;
00314     }
00315     case 'C': {
00316       PrintAndQuit = true;
00317       break;
00318     }
00319     case 'c': {
00320       CountAndQuit = true;
00321       break;
00322     }
00323     case 'v': {
00324       ++Verbose;
00325       break;
00326     }
00327     case 'A': {
00328       AllowRotoErrors = true;
00329       break;
00330     }
00331     case 't': {
00332       TimeStamp = atof(optarg);
00333       break;
00334     }
00335     case 'T': {
00336       TimeStamp = ParseTimeString(optarg);
00337       break;
00338     }
00339     case 'w': {
00340       float wval;
00341       char units[128] = { 0 };
00342       //int nitems = 
00343         sscanf(optarg,"%f%s",&wval,units);
00344       switch ( units[0] ) {
00345       case 's':
00346         WindowSize = wval;
00347         break;
00348       case 'm':
00349         WindowSize = wval*60;
00350         break;
00351       case 'h':
00352         WindowSize = wval*60*60;
00353         break;
00354       case '\0': 
00355         // cout << "RWH no units, " << nitems << " nitems" << endl;
00356         WindowSize = wval*60*60;
00357         break;
00358       default: 
00359         std::ostringstream oss;
00360         oss << "ERROR, --window set with unknown units"
00361             << " \"" << units << "\"";
00362         Usage(oss.str(),1);
00363         break;
00364       } // done unit handling
00365       break;
00366     }
00367     case 'b': {
00368       BundleName = optarg;
00369       break;
00370     }
00371     case 'r': {
00372       RotoNode = optarg;
00373       break;
00374     }
00375     case 'u': {
00376       URLifbeam = optarg;
00377       break;
00378     }
00379     case 'd': {
00380       DeltaCacheTime = atof(optarg);
00381       break;
00382     }
00383     case 'z': {
00384       CacheWindow = atof(optarg);
00385       break;
00386     }
00387     case 'e': {
00388       Epsilon = atof(optarg);
00389       break;
00390     }
00391     case 'E': {
00392       TClkTriggerEvent = atoi(optarg);
00393       break;
00394     }
00395     case 'D': {
00396       TClkTriggerDelay = atoi(optarg);
00397       break;
00398     }
00399     case 'q': {
00400       DtTolerance = atoi(optarg);
00401       break;
00402     }
00403     case 'P': {
00404       PrintOpts = optarg;
00405       break;
00406     }
00407     default: {
00408       std::ostringstream oss;
00409       oss << "ERROR, unhandled/unrecognized option '" << (char)optopt << "' ("
00410           << optopt << ")";
00411       Usage(oss.str(),1);
00412     }
00413 
00414     } // end of switch(c)
00415   } // end of getopt_long
00416 
00417   if ( CountAndQuit ) {
00418     if ( PrintOpts != "" ) PrintOpts += ",";
00419     PrintOpts += "spillcnt";
00420   }
00421 
00422   // handle non-flag (positional) arguments
00423   // do this in a manner to support old positional arguments
00424   //   expect: [ timestamp [ bundle [ window ]]]
00425   // later args are optional
00426   if ( optind < argc ) {
00427     if (Verbose>1) {
00428       std::cout << "non-option (positional) ARGV-elements: " << std::endl;
00429     }
00430     int posindx = -1;
00431     while ( optind < argc ) {
00432       ++posindx;
00433       std::string arg = argv[optind++];
00434 
00435       if (Verbose>1) {
00436         std::string posname[] = { "TimeStamp", "WindowSize",
00437                                   "BundleName", "UNKNOWN" };
00438         std::string name = (posindx<3) ? posname[posindx] : "UNKNOWN";
00439         std::cout << "Set " << setw(10) << name
00440                   << " from positional arg[" << posindx
00441                   << "] \"" << arg << "\"" << std::endl;
00442       }
00443 
00444       switch ( posindx ) {
00445       case 0: {
00446         // convert time as float (in case user gave fractional time)
00447         TimeStamp = atof(arg.c_str());
00448         break;
00449       }
00450       case 1: {
00451         // original code assumed this would be in hours
00452         WindowSize = atof(arg.c_str())*60*60;
00453         break;
00454       }
00455       case 2: {
00456         BundleName = arg;
00457         break;
00458       }
00459       default: {
00460         Usage("ERROR, unexpected extra positional argument",1);
00461         break;
00462       }
00463       } // end of switch( posindx )
00464     } // end of while
00465   } // end of "if ( optind < argc )"
00466 
00467 }

void ifbConfig::PrintConfig (  ) 

Definition at line 214 of file ifbtorr.cc.

References AllowRotoErrors, BundleName, CacheWindow, CountAndQuit, DeltaCacheTime, DtTolerance, Epsilon, exename, LocalTimeString(), PrintAndQuit, PrintOpts, RotoNode, TClkTriggerDelay, TClkTriggerEvent, TimeStamp, URLifbeam, UTCTimeString(), Verbose, and WindowSize.

Referenced by main(), ifbProcBase::Run(), and Usage().

00214                             {
00215 
00216   long long tsec = (int)TimeStamp;
00217   long long tns  = (int)((TimeStamp - tsec)*1000000000);
00218 
00219   std::cout << exename << ": current configuration:" << std::endl
00220             << "  Verbose     " << Verbose 
00221             << "   " << ( (PrintAndQuit) ? "PrintAndQuit" : "" )
00222             << "   " << ( (CountAndQuit) ? "CountAndQuit" : "" )
00223             << "   " << ( (AllowRotoErrors) ? "AllowRotoErrors" : "" )
00224             << std::endl
00225             << "  TimeStamp   " << TimeStamp
00226             << " (" << tsec << "."
00227             << std::setfill('0') << std::setw(9) << tns
00228             << std::setfill(' ') << ")" << std::endl
00229             << "     " << UTCTimeString(TimeStamp) << std::endl
00230             << "     " << LocalTimeString(TimeStamp) << std::endl
00231             << "  WindowSize  " << WindowSize << " (seconds)" << std::endl
00232             << "  BundleName  \"" << BundleName << "\"" << std::endl
00233             << "  RotoNode    \"" << RotoNode << "\"" << std::endl
00234             << "  URLifbeam   \"" << URLifbeam << "\"" << std::endl
00235             << "  BeamFolder CacheWindow " << CacheWindow 
00236             << "  Epsilon " << Epsilon
00237             << "  DeltaCacheTime " << DeltaCacheTime << std::endl
00238             << "  TClkTrigger Event " << TClkTriggerEvent
00239             << "  Delay " << TClkTriggerDelay << std::endl
00240             << "  DtTolerance " << DtTolerance << std::endl
00241             << "  PrintOpts \"" << PrintOpts << "\"" << std::endl
00242             << std::endl;
00243 }

void ifbConfig::Usage ( std::string  msg,
int  exitval 
)

Definition at line 468 of file ifbtorr.cc.

References exename, exit(), and PrintConfig().

Referenced by ParseArgv().

00468                                                 {
00469 
00470   std::cout 
00471     << std::endl
00472     << "Usage:  " << exename << " [OPTIONS] [ timestamp [ window(hours) [ bundle ]]]\n"
00473     << "  Read data from IFBeam DB, reformat and send to MINOS beam rotorooter.\n"
00474     << "Mandatory arguments to long options are mandatory for short options.\n"
00475     << "   -h, --help              display this help and exit\n"
00476     << "   -t, --timestamp=TIME    starting time in seconds since epoch\n"
00477     << "   -T, --timestring='YYYY-MM-DD hh:mm:ss'\n"
00478     << "   -w, --window=VAL        window time (default units hours)\n"
00479     << "                           use VALs or VALm for sec, min; e.g. 3600s\n"
00480     << "   -b, --bundle=NAME       bundle name\n"
00481     << "   -r, --rotonode=MACHINE  node where rotorooter is running\n"
00482     << "   -u, --url=IFB_URL       URL for IF Beam DB connection\n"
00483     << "   -C, --print-config      print configuration and exit\n"
00484     << "   -v, --verbose           increase verbosity\n"
00485     << "   -c, --count-spills      simply count spills w/ no rotorooter\n"
00486     << "   -z, --cache-window      BeamFolder cache window size (-1=default[1200])\n"
00487     << "   -d, --cache-delta       start new BF cache Delta after previous\n"
00488     << "   -e, --epsilon           BeamFolder epsilon\n"
00489     << "   -E, --tclk-event=EVENT  'event' (A9?) associated w/ block [169]\n"
00490     << "   -D, --tclk-delay=DELAY  'delay' associated w/ block [500]\n"
00491     << "   -q, --dt-tolerance=MS   complain about spill/device time diff\n"
00492     << "   -P, --print-opts=POPTS  what extra to print\n"
00493     << "       --bypass-roto       continue after rotorooter connection/file errors\n"
00494 
00495 
00496     << "Use of positional arguments is a deprecated feature, use flags instead.\n"
00497     << "PrintOpts POPTS is a comma separated string of things to print\n"
00498     << "     times    = all timestamps\n"
00499     << "     devices  = final list of devices w/ spill counts\n"
00500     << "     missing  = device only if it was missing from some spills\n"
00501     << "     dt       = excursion extremes between spill and device time (ms)\n"
00502     << "     spillcnt = # of spills\n"
00503     << std::endl;
00504   PrintConfig();
00505   if ( msg != "" ) std::cout << exename << ": " << msg << std::endl;
00506   if ( exitval >= 0 ) exit(exitval);
00507 }


Member Data Documentation

Definition at line 65 of file ifbtorr.cc.

Referenced by ifbProcRoto::Init(), ParseArgv(), and PrintConfig().

std::string ifbConfig::BundleName

Definition at line 68 of file ifbtorr.cc.

Referenced by ifbProcBase::ifbProcBase(), ParseArgv(), and PrintConfig().

Definition at line 71 of file ifbtorr.cc.

Referenced by ifbProcBase::ifbProcBase(), ifbProcBase::NewCache(), ParseArgv(), and PrintConfig().

Definition at line 64 of file ifbtorr.cc.

Referenced by main(), ParseArgv(), and PrintConfig().

Definition at line 73 of file ifbtorr.cc.

Referenced by ParseArgv(), PrintConfig(), and ifbProcBase::ScanWindow().

Definition at line 76 of file ifbtorr.cc.

Referenced by ifbProcRoto::CompareSpillDeviceTimes(), ParseArgv(), and PrintConfig().

Definition at line 72 of file ifbtorr.cc.

Referenced by ifbProcBase::ifbProcBase(), ParseArgv(), and PrintConfig().

Definition at line 63 of file ifbtorr.cc.

Referenced by main(), ParseArgv(), and PrintConfig().

std::string ifbConfig::PrintOpts
std::string ifbConfig::RotoNode

Definition at line 69 of file ifbtorr.cc.

Referenced by ifbProcRoto::Init(), ParseArgv(), and PrintConfig().

Definition at line 75 of file ifbtorr.cc.

Referenced by ParseArgv(), PrintConfig(), and ifbProcRoto::SpillInit().

Definition at line 74 of file ifbtorr.cc.

Referenced by ParseArgv(), PrintConfig(), and ifbProcRoto::SpillInit().

Definition at line 66 of file ifbtorr.cc.

Referenced by ifbProcRoto::Init(), ParseArgv(), PrintConfig(), and ifbProcBase::Run().

std::string ifbConfig::URLifbeam

Definition at line 70 of file ifbtorr.cc.

Referenced by ifbProcBase::ifbProcBase(), ParseArgv(), and PrintConfig().

Definition at line 67 of file ifbtorr.cc.

Referenced by ParseArgv(), PrintConfig(), and ifbProcBase::Run().


The documentation for this class was generated from the following file:

Generated on 19 Jan 2018 for loon by  doxygen 1.6.1