/[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.31 by mocchiut, Sun Sep 9 18:59:41 2007 UTC revision 1.33 by mocchiut, Fri Oct 19 07:48:18 2007 UTC
# Line 264  GL_S4_CALIB::GL_S4_CALIB(){ Line 264  GL_S4_CALIB::GL_S4_CALIB(){
264  GL_TIMESYNC::GL_TIMESYNC(){  GL_TIMESYNC::GL_TIMESYNC(){
265    obtfirst = 0;    obtfirst = 0;
266    pktfirst = 0;    pktfirst = 0;
267    toffset  = 0;    ID_RESURS_OFFSET  = 0;
268    //  ID       = 0;    ID       = 0;
269    //  ID_RAW   = 0;    ID_RAW   = 0;
270    OBT0     = 0;    OBT0     = 0;
271    TIMESYNC = 0;    TIMESYNC = 0;
272    TYPE     = 0;    TYPE     = 0;
# Line 1499  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1499  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1499    TString name=rname.str().c_str();    TString name=rname.str().c_str();
1500    UInt_t dworbit = 0;    UInt_t dworbit = 0;
1501    Int_t nlength = name.Length();    Int_t nlength = name.Length();
   if ( nlength < 5 ) return;  
   TString dwo = 0;  
   for (Int_t i = 0; i<5; i++){  
     dwo.Append(name[i],1);  
   };  
   if ( dwo.IsDigit() ){  
     dworbit = (UInt_t)dwo.Atoi();  
   } else {  
     dwo="";  
     for (Int_t i = 8; i<13; i++){  
       dwo.Append(name[i],1);  
     };      
     if ( dwo.IsDigit() ){  
       dworbit = (UInt_t)dwo.Atoi();  
     } else {  
       dworbit = 1;  
     };  
   };  
1502    //    //
1503      // Is not a special file
1504    //    //
1505    if ( !Row ){    if ( !Row ){
1506        delete pResult;      
1507        //
1508        // New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset
1509        //
1510      oss.str("");      oss.str("");
1511      oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "      oss << "SELECT ID_RESURS_OFFSET from GL_TIMESYNC where ID_RAW=" << idraw <<";";
         << dworbit << " order by FROM_ORBIT desc limit 1;";  
1512      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;        if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;  
1513      this->GetGLTABLES()->AddQ();      this->GetGLTABLES()->AddQ();
1514      pResult = dbc->Query(oss.str().c_str());      pResult = dbc->Query(oss.str().c_str());
1515      Row = pResult->Next();      Bool_t fndit = false;
1516      if ( !Row ){      if ( pResult ){
1517        printf(" ERROR FROM GLTables! cannot determine Resurs offset \n");        Row = pResult->Next();
1518        return;        if ( Row ){
1519            oss.str("");
1520            oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE ID="
1521                << Row->GetField(0) << ";";
1522            if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;  
1523            this->GetGLTABLES()->AddQ();
1524            pResult = dbc->Query(oss.str().c_str());
1525            if ( pResult ){
1526              Row = pResult->Next();
1527              if ( Row ){
1528                //      printf(" GREAT! the DB structure is the new one! \n");
1529                fndit = true;
1530                dworbit = 1;
1531              };
1532            };
1533          };
1534        };
1535        if ( !fndit ){
1536          delete pResult;      
1537          //
1538          printf(" OK, you got an error because this is the old database\n Using backward compability code, hence you can continue safetly \n");
1539          //
1540          // Old code, we must trust the filename
1541          //
1542          if ( nlength < 5 ) return;
1543          TString dwo = 0;
1544          for (Int_t i = 0; i<5; i++){
1545            dwo.Append(name[i],1);
1546          };
1547          if ( dwo.IsDigit() ){
1548            dworbit = (UInt_t)dwo.Atoi();
1549          } else {
1550            dwo="";
1551            for (Int_t i = 8; i<13; i++){
1552              dwo.Append(name[i],1);
1553            };    
1554            if ( dwo.IsDigit() ){
1555              dworbit = (UInt_t)dwo.Atoi();
1556            } else {
1557              dworbit = 1;
1558            };
1559          };    
1560          //
1561          oss.str("");
1562          oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< "
1563              << dworbit << " order by FROM_ORBIT desc limit 1;";
1564          if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;  
1565          this->GetGLTABLES()->AddQ();
1566          pResult = dbc->Query(oss.str().c_str());
1567          Row = pResult->Next();
1568          if ( !Row ){
1569            printf(" ERROR FROM GLTables! cannot determine Resurs offset \n");
1570            return;
1571          };
1572      };      };
1573    };    };
1574    //    //

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.23