/[PAMELA software]/YodaProfiler/src/GLTables.cpp
ViewVC logotype

Diff of /YodaProfiler/src/GLTables.cpp

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

revision 1.10 by mocchiut, Tue Sep 19 09:18:46 2006 UTC revision 1.15 by mocchiut, Tue Oct 31 15:36:04 2006 UTC
# Line 6  Line 6 
6   */   */
7  //  //
8  #include <sstream>  #include <sstream>
9    #include <iostream>
10  //  //
11  #include <TFile.h>  #include <TFile.h>
12  #include <TTree.h>  #include <TTree.h>
# Line 13  Line 14 
14  #include <PscuHeader.h>  #include <PscuHeader.h>
15  //  //
16  #include <GLTables.h>  #include <GLTables.h>
17    #include <sgp4.h>
18  //  //
19  ClassImp(GL_TRK_CALIB);  ClassImp(GL_TRK_CALIB);
20  ClassImp(GL_RUN);  ClassImp(GL_RUN);
# Line 21  ClassImp(GL_PARAM); Line 23  ClassImp(GL_PARAM);
23  ClassImp(GL_S4_CALIB);  ClassImp(GL_S4_CALIB);
24  ClassImp(GL_CALO_CALIB);  ClassImp(GL_CALO_CALIB);
25  ClassImp(GL_TIMESYNC);  ClassImp(GL_TIMESYNC);
26    ClassImp(GL_TLE);
27  //  //
28  using namespace std;  using namespace std;
29    
# Line 155  GL_TIMESYNC::GL_TIMESYNC(){ Line 158  GL_TIMESYNC::GL_TIMESYNC(){
158    OBT0     = 0;    OBT0     = 0;
159    TIMESYNC = 0;    TIMESYNC = 0;
160    TYPE     = 0;    TYPE     = 0;
161  }// ****************************************************  }
162    
163    GL_TLE::GL_TLE(){
164    }
165    
166    // ****************************************************
167    
168  void GL_RUN::SetEV_FROM(UInt_t evfrom){  void GL_RUN::SetEV_FROM(UInt_t evfrom){
169    EV_FROM = evfrom;    EV_FROM = evfrom;
# Line 366  void GL_RUN::Set_GL_RUN(TSQLRow *Row){ Line 373  void GL_RUN::Set_GL_RUN(TSQLRow *Row){
373    
374  }  }
375    
376    /**
377     * This method delete the run from the "FromTable" table and store it in the GL_RUN_TRASH table
378     * If IDRUN is 0 "this->ID" run is used.
379     *
380     **/
381    Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){
382      // MySQL variables
383      TSQLResult *pResult;
384      TSQLRow *Row;
385      stringstream myquery;
386      //
387      if ( !IDRUN ) IDRUN = ID;
388      if ( !IDRUN ) return 1;
389      // ----------------
390      myquery.str("");
391      myquery << " INSERT INTO GL_RUN_TRASH (";  
392      myquery << "ID";
393      myquery << ",ID_RUN_FRAG";
394      myquery << ",ID_ROOT_L0";
395      myquery << ",ID_ROOT_L2";
396      myquery << ",RUNHEADER_TIME";
397      myquery << ",RUNTRAILER_TIME";
398      myquery << ",RUNHEADER_OBT";
399      myquery << ",RUNTRAILER_OBT";
400      myquery << ",RUNHEADER_PKT";
401      myquery << ",RUNTRAILER_PKT";
402      myquery << ",BOOT_NUMBER";
403      myquery << ",EV_FROM";
404      myquery << ",EV_TO";
405      myquery << ",NEVENTS";
406      myquery << ",PKT_COUNTER";
407      myquery << ",PKT_READY_COUNTER";
408      myquery << ",COMPILATIONTIMESTAMP";
409      myquery << ",FAV_WRK_SCHEDULE";
410      myquery << ",EFF_WRK_SCHEDULE";
411      myquery << ",PRH_VAR_TRG_MODE_A";
412      myquery << ",PRH_VAR_TRG_MODE_B";
413      myquery << ",ACQ_BUILD_INFO";
414      myquery << ",ACQ_VAR_INFO";
415      myquery << ",RM_ACQ_AFTER_CALIB";
416      myquery << ",RM_ACQ_SETTING_MODE";
417      myquery << ",TRK_CALIB_USED";
418      myquery << ",CAL_DSP_MASK";
419      myquery << ",LAST_TIMESYNC";
420      myquery << ",OBT_TIMESYNC";
421      myquery << ",VALIDATION";
422      myquery << ",INSERT_TIME";
423      myquery << ") SELECT * FROM ";
424      myquery << FromTable.Data();
425      myquery << " WHERE ID=";
426      myquery << (UInt_t)IDRUN << ";";
427      //
428      //  printf("1myquery is %s \n",myquery.str().c_str());
429      //
430      dbc->Query(myquery.str().c_str());
431      //
432      // retrieve this ID_TRASH
433      //
434      myquery.str("");
435      myquery << " SELECT ID_TRASH,ID_ROOT_L0,ID_ROOT_L2 FROM GL_RUN_TRASH ORDER BY ID_TRASH DESC LIMIT 1";  
436      pResult = dbc->Query(myquery.str().c_str());
437      //
438      UInt_t idtrash = 0;
439      UInt_t idl0 = 0;
440      UInt_t idl2 = 0;
441      //
442      Row = pResult->Next();      
443      if( Row != NULL ){
444        idtrash = (UInt_t)atoll(Row->GetField(0));
445        idl0 = (UInt_t)atoll(Row->GetField(1));
446        idl2 = (UInt_t)atoll(Row->GetField(2));    
447      };
448      //
449      TString fileL0 = "";
450      TString fileL2 = "";
451      myquery.str("");
452      myquery << " SELECT NAME FROM GL_ROOT WHERE ID=";
453      myquery <<  idl0 << ";";
454      //
455      //  printf("2myquery is %s \n",myquery.str().c_str());
456      //
457      pResult = dbc->Query(myquery.str().c_str());
458      //
459      Row = pResult->Next();      
460      if( Row != NULL ){
461        fileL0 = (TString)Row->GetField(0);
462      };
463      //
464      //
465      //
466      myquery.str("");
467      myquery << " SELECT NAME FROM GL_ROOT WHERE ID=";
468      myquery << idl2 << ";";
469      //
470      //  printf("3myquery is %s \n",myquery.str().c_str());
471      //
472      pResult = dbc->Query(myquery.str().c_str());
473      //
474      Row = pResult->Next();      
475      if( Row != NULL ){
476        fileL2 = (TString)Row->GetField(0);
477      };
478      //
479      //
480      //
481      myquery.str("");
482      myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL0='";
483      myquery <<  fileL0.Data() << "' where ID_TRASH=";
484      myquery << idtrash << ";";
485      //
486      //  printf("4myquery is %s \n",myquery.str().c_str());
487      //
488      dbc->Query(myquery.str().c_str());
489      //
490      myquery.str("");
491      myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='";
492      myquery <<  fileL2.Data() << "' where ID_TRASH=";
493      myquery << idtrash << ";";
494      //
495      //  printf("4myquery is %s \n",myquery.str().c_str());
496      //
497      dbc->Query(myquery.str().c_str());
498      //
499      myquery.str("");
500      myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='";
501      myquery <<  FromTable.Data() << "' where ID_TRASH=";
502      myquery << idtrash << ";";
503      //
504      //  printf("4myquery is %s \n",myquery.str().c_str());
505      //
506      //
507      dbc->Query(myquery.str().c_str());
508      //
509      myquery.str("");
510      myquery << " DELETE FROM ";
511      myquery <<  FromTable.Data() << " where ID=";
512      myquery << IDRUN << ";";
513      //
514      //  printf("5myquery is %s \n",myquery.str().c_str());
515      //
516      //
517      dbc->Query(myquery.str().c_str());
518      //
519      return 0;
520    };
521    
522    
523    
524    /**
525     * This method restore a run from the GL_RUN_TRASH table.
526     * If ID is 0 "this->ID" is used; if "ToTable" is empty BELONG_TO field of GL_RUN_TRASH is used.
527     *
528     **/
529    Int_t GL_RUN::RestoreRun(TSQLServer *dbc,UInt_t IDRUN,TString ToTable){
530      // insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11;
531      //insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO  , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11;
532      // MySQL variables
533      TSQLResult *pResult;
534      TSQLRow *Row;
535      stringstream myquery;
536      //
537      if ( !IDRUN ) IDRUN = ID;
538      if ( !IDRUN ) return 1;
539      //
540      if ( !strcmp(ToTable.Data(),"") ){
541        //    
542        myquery.str("");
543        myquery << " SELECT BELONGED_TO FROM GL_RUN_TRASH WHERE ID=";
544        myquery << (UInt_t)IDRUN << ";";
545        //
546        printf(" qui? myquery is %s \n",myquery.str().c_str());
547        //
548        pResult = dbc->Query(myquery.str().c_str());
549        //
550        Row = pResult->Next();      
551        if( Row != NULL ){
552         ToTable = (TString)Row->GetField(0);
553        } else {
554          return 1;
555        };
556      };
557      // ----------------
558      myquery.str("");
559      myquery << " INSERT INTO ";
560      myquery << ToTable.Data();
561      myquery << " (";  
562      myquery << "ID";
563      myquery << ",ID_RUN_FRAG";
564      myquery << ",ID_ROOT_L0";
565      myquery << ",ID_ROOT_L2";
566      myquery << ",RUNHEADER_TIME";
567      myquery << ",RUNTRAILER_TIME";
568      myquery << ",RUNHEADER_OBT";
569      myquery << ",RUNTRAILER_OBT";
570      myquery << ",RUNHEADER_PKT";
571      myquery << ",RUNTRAILER_PKT";
572      myquery << ",BOOT_NUMBER";
573      myquery << ",EV_FROM";
574      myquery << ",EV_TO";
575      myquery << ",NEVENTS";
576      myquery << ",PKT_COUNTER";
577      myquery << ",PKT_READY_COUNTER";
578      myquery << ",COMPILATIONTIMESTAMP";
579      myquery << ",FAV_WRK_SCHEDULE";
580      myquery << ",EFF_WRK_SCHEDULE";
581      myquery << ",PRH_VAR_TRG_MODE_A";
582      myquery << ",PRH_VAR_TRG_MODE_B";
583      myquery << ",ACQ_BUILD_INFO";
584      myquery << ",ACQ_VAR_INFO";
585      myquery << ",RM_ACQ_AFTER_CALIB";
586      myquery << ",RM_ACQ_SETTING_MODE";
587      myquery << ",TRK_CALIB_USED";
588      myquery << ",CAL_DSP_MASK";
589      myquery << ",LAST_TIMESYNC";
590      myquery << ",OBT_TIMESYNC";
591      myquery << ",VALIDATION";
592      myquery << ",INSERT_TIME";
593      myquery << ") SELECT ";
594      myquery << "ID";
595      myquery << ",ID_RUN_FRAG";
596      myquery << ",ID_ROOT_L0";
597      myquery << ",ID_ROOT_L2";
598      myquery << ",RUNHEADER_TIME";
599      myquery << ",RUNTRAILER_TIME";
600      myquery << ",RUNHEADER_OBT";
601      myquery << ",RUNTRAILER_OBT";
602      myquery << ",RUNHEADER_PKT";
603      myquery << ",RUNTRAILER_PKT";
604      myquery << ",BOOT_NUMBER";
605      myquery << ",EV_FROM";
606      myquery << ",EV_TO";
607      myquery << ",NEVENTS";
608      myquery << ",PKT_COUNTER";
609      myquery << ",PKT_READY_COUNTER";
610      myquery << ",COMPILATIONTIMESTAMP";
611      myquery << ",FAV_WRK_SCHEDULE";
612      myquery << ",EFF_WRK_SCHEDULE";
613      myquery << ",PRH_VAR_TRG_MODE_A";
614      myquery << ",PRH_VAR_TRG_MODE_B";
615      myquery << ",ACQ_BUILD_INFO";
616      myquery << ",ACQ_VAR_INFO";
617      myquery << ",RM_ACQ_AFTER_CALIB";
618      myquery << ",RM_ACQ_SETTING_MODE";
619      myquery << ",TRK_CALIB_USED";
620      myquery << ",CAL_DSP_MASK";
621      myquery << ",LAST_TIMESYNC";
622      myquery << ",OBT_TIMESYNC";
623      myquery << ",VALIDATION";
624      myquery << ",INSERT_TIME";
625      myquery << " FROM GL_RUN_TRASH ";
626      myquery << " WHERE BELONGED_TO='GL_RUN_FRAGMENTS' AND ID=";
627      myquery << (UInt_t)IDRUN << ";";
628      //
629      //  printf("5myquery is %s \n",myquery.str().c_str());
630      //
631      dbc->Query(myquery.str().c_str());
632      //
633      //
634      myquery.str("");
635      myquery << " DELETE FROM GL_RUN_TRASH where BELONGED_TO='GL_RUN_FRAGMENTS' AND ID=";
636      myquery << IDRUN << ";";
637      //
638      dbc->Query(myquery.str().c_str());
639      //
640      return 0;
641    };
642    
643  /**  /**
644   * Function to fill the GL_RUN  table of the DB.   * Function to fill the GL_RUN  table of the DB.
# Line 992  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1265  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1265    TSQLResult *pResult;    TSQLResult *pResult;
1266    TSQLRow *Row;    TSQLRow *Row;
1267    stringstream myquery;    stringstream myquery;
1268      stringstream rname;
1269      rname.str("");
1270    // ----------------    // ----------------
1271    myquery.str("");    myquery.str("");
1272    myquery << "select ";    myquery << "select ";
# Line 1008  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1283  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1283        stringstream fname;        stringstream fname;
1284        fname.str("");        fname.str("");
1285        fname << Row->GetField(0) << "/" << Row->GetField(1);        fname << Row->GetField(0) << "/" << Row->GetField(1);
1286          rname << Row->GetField(1);
1287        file = new TFile(fname.str().c_str(),"READ");        file = new TFile(fname.str().c_str(),"READ");
1288        idraw = (UInt_t)atoll(Row->GetField(2));        idraw = (UInt_t)atoll(Row->GetField(2));
1289      };      };
# Line 1029  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1305  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1305    //    //
1306    UInt_t t0 = 0;    UInt_t t0 = 0;
1307    //    //
1308    myquery.str("");    //
1309    myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= "    stringstream oss;
1310        << idraw << " AND TO_ID_RAW >= "    oss.str("");
1311        << idraw << ";";    oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='"
1312    pResult = dbc->Query(myquery.str().c_str());        << rname.str().c_str() << "';";
1313    if ( pResult ){    //  if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
1314      pResult = dbc->Query(oss.str().c_str());
1315      Row = pResult->Next();
1316      //
1317      TString name=rname.str().c_str();
1318      UInt_t dworbit = 0;
1319      Int_t nlength = name.Length();
1320      if ( nlength < 5 ) return;
1321      TString dwo = 0;
1322      for (Int_t i = 0; i<5; i++){
1323        dwo.Append(name[i],1);
1324      };
1325      if ( dwo.IsDigit() ){
1326        dworbit = (UInt_t)dwo.Atoi();
1327      } else {
1328        dwo="";
1329        for (Int_t i = 8; i<13; i++){
1330          dwo.Append(name[i],1);
1331        };    
1332        if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi();
1333      };
1334      // if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data());  
1335      //
1336      if ( !Row ){
1337        oss.str("");
1338        oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "
1339            << dworbit << " order by FROM_ORBIT desc limit 1;";
1340        //    if ( IsDebug() ) printf(" %s \n",oss.str().c_str());
1341        pResult = dbc->Query(oss.str().c_str());
1342      Row = pResult->Next();      Row = pResult->Next();
1343      if ( Row ){      if ( !Row ){
1344        //        printf(" ERROR FROM GLTables! cannot determine Resurs offset \n");
1345        t0 = (UInt_t)TDatime(Row->GetField(0)).Convert();        return;
       //  
1346      };      };
1347    };    };
1348    //    //
1349      t0 = (UInt_t)TDatime(Row->GetField(0)).Convert();
1350      //
1351      //  myquery.str("");
1352      //   myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= "
1353      //       << idraw << " AND TO_ID_RAW >= "
1354      //       << idraw << ";";
1355      //   pResult = dbc->Query(myquery.str().c_str());
1356      //   if ( pResult ){
1357      //     Row = pResult->Next();
1358      //     if ( Row ){
1359      //       //
1360      //       t0 = (UInt_t)TDatime(Row->GetField(0)).Convert();
1361      //       //
1362      //     };
1363      //   };
1364      //
1365    //    //
1366    // look for the correct timesync entry    // look for the correct timesync entry
1367    //    //
# Line 1120  TString GL_TIMESYNC::ConvertTime(TString Line 1439  TString GL_TIMESYNC::ConvertTime(TString
1439    TString rtime;    TString rtime;
1440    Bool_t found = false;    Bool_t found = false;
1441    //    //
1442    time->Set(dbt,false); // MSK = Moscow Winter Time    time->Set(dbt,false); // UTC (Coordinated Universal Time)  
1443    //    //
1444    if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){    if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){
1445      //      //
1446      UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3 hs      UInt_t timeMSK = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time
1447      time->Set(timeUTC,false);      time->Set(timeMSK,false);
1448      found = true;      found = true;
1449      //      //
1450    };    };
1451    //    //
1452    if ( !strcmp(tzone.Data(),"CET") ){    if ( !strcmp(tzone.Data(),"CET") ){
1453      //      //
1454      UInt_t timeCET = time->Convert() - 60*60*2; // CET (Central European Time) = Moscow Winter Time - 2 hs      UInt_t timeCET = time->Convert() + 60*60*1; // CET (Central European Time) = UTC + 1 hs
1455      time->Set(timeCET,false);      time->Set(timeCET,false);
1456      found = true;      found = true;
1457      //      //
# Line 1140  TString GL_TIMESYNC::ConvertTime(TString Line 1459  TString GL_TIMESYNC::ConvertTime(TString
1459    //    //
1460    if ( !strcmp(tzone.Data(),"CEST") ){    if ( !strcmp(tzone.Data(),"CEST") ){
1461      //      //
1462      UInt_t timeCEST = time->Convert() - 60*60*1; // CEST (Central European Summer Time) = Moscow Winter Time - 1 h      UInt_t timeCEST = time->Convert() + 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h
1463      time->Set(timeCEST,false);      time->Set(timeCEST,false);
1464      found = true;      found = true;
1465      //      //
1466    };    };
1467    //    //
1468    if ( !strcmp(tzone.Data(),"MSD") ){    if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST")){
1469      //      //
1470      UInt_t timeMSD = time->Convert() + 60*60*1; // MSD (Moscow Summer Time) = Moscow Winter Time + 1 h      UInt_t timeMSD = time->Convert() + 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h
1471      time->Set(timeMSD,false);      time->Set(timeMSD,false);
1472      found = true;      found = true;
1473      //      //
1474    };    };
1475    //    //
1476    if ( !found && strcmp(tzone.Data(),"MSK") && strcmp(tzone.Data(),"") ){    if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){
1477      printf("\n Unknown time zone %s using MSK \n",tzone.Data());      printf("\n Unknown time zone %s using UTC \n",tzone.Data());
1478      tzone = "MSK";      tzone = "UTC";
1479    };    };
1480    //    //
1481    rtime = time->AsSQLString();    rtime = time->AsSQLString();
# Line 1179  TString GL_TIMESYNC::UnConvertTime(TStri Line 1498  TString GL_TIMESYNC::UnConvertTime(TStri
1498    //    //
1499    Bool_t found = false;    Bool_t found = false;
1500    //    //
1501    time->Set(dbt,false); // MSK = Moscow Winter Time    time->Set(dbt,false); // tzone
1502    //    //
1503    if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){    if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){
1504      //      //
1505      UInt_t timeUTC = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) +3 hs = Moscow Winter Time      UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs
1506      time->Set(timeUTC,false);      time->Set(timeUTC,false);
1507      found = true;      found = true;
1508      //      //
# Line 1191  TString GL_TIMESYNC::UnConvertTime(TStri Line 1510  TString GL_TIMESYNC::UnConvertTime(TStri
1510    //    //
1511    if ( !strcmp(tzone.Data(),"CET") ){    if ( !strcmp(tzone.Data(),"CET") ){
1512      //      //
1513      UInt_t timeCET = time->Convert() + 60*60*2; // CET (Central European Time) + 2 hs = Moscow Winter Time        UInt_t timeCET = time->Convert() - 60*60*1; // CET (Central European Time) - 1 hs = UTC  
1514      time->Set(timeCET,false);      time->Set(timeCET,false);
1515      found = true;      found = true;
1516      //      //
# Line 1199  TString GL_TIMESYNC::UnConvertTime(TStri Line 1518  TString GL_TIMESYNC::UnConvertTime(TStri
1518    //    //
1519    if ( !strcmp(tzone.Data(),"CEST") ){    if ( !strcmp(tzone.Data(),"CEST") ){
1520      //      //
1521      UInt_t timeCEST = time->Convert() + 60*60*1; // CEST (Central European Summer Time) + 1 h = Moscow Winter Time      UInt_t timeCEST = time->Convert() - 60*60*2; // CEST (Central European Summer Time) - 2 h = UTC
1522      time->Set(timeCEST,false);      time->Set(timeCEST,false);
1523      found = true;      found = true;
1524      //      //
# Line 1207  TString GL_TIMESYNC::UnConvertTime(TStri Line 1526  TString GL_TIMESYNC::UnConvertTime(TStri
1526    //    //
1527    if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){    if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){
1528      //      //
1529      UInt_t timeMSD = time->Convert() - 60*60*1; // MSD (Moscow Summer Time) - 1 h = Moscow Winter Time      UInt_t timeMSD = time->Convert() - 60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC
1530      time->Set(timeMSD,false);      time->Set(timeMSD,false);
1531      found = true;      found = true;
1532      //      //
1533    };    };
1534    //    //
1535    if ( !found && strcmp(tzone.Data(),"MSK") && strcmp(tzone.Data(),"") ){    if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){
1536      //      //
1537      printf("\n Unknown time zone %s using MSK \n",tzone.Data());      printf("\n Unknown time zone %s using UTC \n",tzone.Data());
1538      tzone = "MSK";      tzone = "UTC";
1539    };    };
1540    //    //
1541    rtime = time->AsSQLString();    rtime = time->AsSQLString();
1542    //    //
1543    return(rtime);    return(rtime);
1544  }  }
1545    
1546    
1547    // ****************************************************
1548    /**
1549     * Function to query the GL_TLE table of the DB.
1550     *
1551     * time is the unix time for which a good tle is requested.
1552     *
1553     * Return the pointer to a cTle object that has the closest and
1554     * previous date compared with time.
1555     *
1556     * If errors occurs it returns NULL.
1557     */
1558    cTle* GL_TLE::Query_GL_TLE(UInt_t time, TSQLServer *dbc){
1559      stringstream myquery;
1560      myquery.str("");
1561    
1562      myquery << "SELECT TLE1, TLE2, TLE3 FROM GL_TLE "
1563              << "WHERE FROM_TIME < FROM_UNIXTIME(" << time << ") ORDER BY FROM_TIME DESC LIMIT 1;";  
1564    
1565    
1566      return Query_GL_TLE_go(myquery.str(), dbc);
1567    }
1568    
1569    
1570    // ****************************************************
1571    /**
1572     * Function to query the GL_TLE table of the DB.
1573     *
1574     * date is a datetime format YYYY-MM-DD hh:mm:ss for which a good tle
1575     * is requested.
1576     *
1577     * Return the pointer to a cTle object that has the closest and
1578     * previous date compared with time.
1579     *
1580     * If errors occurs it returns NULL.
1581     */
1582    cTle* GL_TLE::Query_GL_TLE(TString date, TSQLServer *dbc){
1583      stringstream myquery;
1584      myquery.str("");
1585    
1586      myquery << "SELECT TLE1, TLE2, TLE3 FROM GL_TLE "
1587              << "WHERE FROM_TIME < '" << date.Data() << "' ORDER BY FROM_TIME DESC LIMIT 1;";  
1588    
1589    
1590      return Query_GL_TLE_go(myquery.str(), dbc);
1591    }
1592    
1593    
1594    // ****************************************************
1595    /**
1596     * Private function used by Query_GL_TLE methods.
1597     *
1598     * myquery is the query string.
1599     *
1600     * Return the pointer to a cTle object that has the closest and
1601     * previous date compared with time.
1602     *
1603     * If errors occurs it returns NULL.
1604     */
1605    cTle* GL_TLE::Query_GL_TLE_go(TString myquery, TSQLServer *dbc){
1606      cTle *tle;
1607      string tle1, tle2, tle3;
1608    
1609      // MySQL variables
1610      TSQLResult *result;
1611      TSQLRow *row;
1612    
1613      result = dbc->Query(myquery.Data());
1614      if(! result->GetRowCount() ) return NULL;
1615    
1616      row = result->Next();
1617      tle1 = row->GetField(0);
1618      tle2 = row->GetField(1);
1619      tle3 = row->GetField(2);
1620    
1621      tle = new cTle(tle1, tle2, tle3);
1622    
1623      delete result;
1624      delete row;
1625    
1626      return tle;
1627    }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.23