/[PAMELA software]/YodaProfiler/src/R2-D2.cpp
ViewVC logotype

Diff of /YodaProfiler/src/R2-D2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by mocchiut, Tue Nov 7 12:17:45 2006 UTC revision 1.4 by mocchiut, Mon Nov 20 09:11:59 2006 UTC
# Line 45  void r2d2usage(){ Line 45  void r2d2usage(){
45    printf("\n -runatDB time    returns run number which contains the given DB time\n");    printf("\n -runatDB time    returns run number which contains the given DB time\n");
46    printf("\n -tsfile file     yoda filename for the time sync (to be used with -obt)\n");    printf("\n -tsfile file     yoda filename for the time sync (to be used with -obt)\n");
47    printf("\n -obt OBT         OBT in ms returns a date (to be used with -tsfile)\n");    printf("\n -obt OBT         OBT in ms returns a date (to be used with -tsfile)\n");
48      printf("\n -getRTime OBT    OBT in ms returns Resurs time (to be used with -tsfile)\n");
49    printf("\n -dumpTLEfor date save into file tle.txt the TLE for the given date,\n");    printf("\n -dumpTLEfor date save into file tle.txt the TLE for the given date,\n");
50    printf("\n                  for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");    printf("\n                  for date use the SQL format \"yyyy-mm-dd hh:mm:ss\" \n");
51    printf("\nExamples: \n");    printf("\nExamples: \n");
# Line 88  int main(int numinp, char *inps[]){ Line 89  int main(int numinp, char *inps[]){
89    TString tletime = "1970-01-01 00:00:00";    TString tletime = "1970-01-01 00:00:00";
90    UInt_t dbti = 0;    UInt_t dbti = 0;
91    Bool_t convert = false;    Bool_t convert = false;
92      Bool_t convres = false;
93    Bool_t ruti = false;    Bool_t ruti = false;
94    Bool_t dtle = false;    Bool_t dtle = false;
95    Bool_t ruti2 = false;    Bool_t ruti2 = false;
# Line 96  int main(int numinp, char *inps[]){ Line 98  int main(int numinp, char *inps[]){
98    //    //
99    UInt_t runtime2 = 0;    UInt_t runtime2 = 0;
100    UInt_t obt = 0;    UInt_t obt = 0;
101      UInt_t res = 0;
102    TString tsfile = "";    TString tsfile = "";
103    //    //
104    TSQLResult *pResult;    TSQLResult *pResult;
# Line 171  int main(int numinp, char *inps[]){ Line 174  int main(int numinp, char *inps[]){
174          obt = (UInt_t)atoll(inps[i+1]);          obt = (UInt_t)atoll(inps[i+1]);
175        };        };
176        //        //
177         if ( !strcmp(inps[i],"-getRTime") ) {
178            convres = true;
179            if ( numinp-1 < i+1 ){
180              r2d2usage();
181              exit(-3);
182            };
183            res = (UInt_t)atoll(inps[i+1]);
184          };
185          //
186        //        //
187        if ( !strcmp(inps[i],"-tzone") ) {        if ( !strcmp(inps[i],"-tzone") ) {
188          if ( numinp-1 < i+1 ){          if ( numinp-1 < i+1 ){
# Line 254  int main(int numinp, char *inps[]){ Line 266  int main(int numinp, char *inps[]){
266      printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone,dbti).Data(),tzone.Data());      printf("\n DB time %u is %s %s \n",dbti,dbtime->ConvertTime(tzone,dbti).Data(),tzone.Data());
267    };    };
268    //    //
269    //    // convert OBT to date
270    //    //
271    if ( convobt && convobtts ){    if ( convobt && convobtts ){
272      UInt_t id = 0;      UInt_t id = 0;
# Line 270  int main(int numinp, char *inps[]){ Line 282  int main(int numinp, char *inps[]){
282          delete pResult;                delete pResult;      
283          GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc);          GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc);
284          UInt_t abtime = ctime->DBabsTime(obt);          UInt_t abtime = ctime->DBabsTime(obt);
         TString UTC="UTC";  
285          TString thetime = dbtime->ConvertTime(tzone,abtime);          TString thetime = dbtime->ConvertTime(tzone,abtime);
286          printf("\n OBT %u in the file %s corresponds to DBtime %u and date %s %s \n",obt,tsfile.Data(),abtime,thetime.Data(),tzone.Data());          printf("\n OBT %u in the file %s corresponds to DBtime %u and date %s %s \n",obt,tsfile.Data(),abtime,thetime.Data(),tzone.Data());
287          delete ctime;          delete ctime;
288        };        };
289      };      };
290    };    };
291    if ( (convobt && !convobtts) || (convobtts && !convobt) ){    if ( (convobt && !convobtts) ){
292      printf("\n To convert a OBT to a date you must provide both OBT and file to be used for time sync \n");      printf("\n To convert a OBT to a date you must provide both OBT and file to be used for time sync \n");
293    };    };
294    //    //
295      // convert OBT to Resurs seconds
296      //
297      if ( convres && convobtts ){
298        UInt_t id = 0;
299        myquery.str("");
300        myquery << "select ";
301        myquery << " ID";
302        myquery << " from GL_ROOT where NAME=\"" << tsfile.Data() << "\";";    
303        pResult = dbc->Query(myquery.str().c_str());
304        if ( pResult ){
305          Row = pResult->Next();      
306          if ( Row ){
307            id = (UInt_t)atoll(Row->GetField(0));
308            delete pResult;      
309            GL_TIMESYNC *ctime = new GL_TIMESYNC(id,"ID",dbc);
310            UInt_t restime = ctime->ResursTime(res);
311            //UInt_t abtime = ctime->DBabsTime(obt);
312            //
313            //      TString thetime = dbtime->ConvertTime(tzone,abtime);
314            printf("\n OBT %u in the file %s corresponds to Resurs time %u  \n",res,tsfile.Data(),restime);
315            delete ctime;
316          };
317        };
318      };
319      if ( (convres && !convobtts) ){
320        printf("\n To convert a OBT to the Resurs time you must provide both OBT and file to be used for time sync \n");
321      };
322      //
323    // Which run contains the date "runtime"?    // Which run contains the date "runtime"?
324    //    //
325    if ( ruti ){    if ( ruti ){
# Line 338  int main(int numinp, char *inps[]){ Line 377  int main(int numinp, char *inps[]){
377    if ( dtle ){    if ( dtle ){
378      //      //
379      //      //
380      TDatime ti = TDatime(runtime.Data());      TDatime ti = TDatime(tletime.Data());
381      //      //
382      TTimeStamp *time = new TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0);      TTimeStamp *time = new TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0);
383      //      //

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.23