/[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.25 by mocchiut, Fri Mar 23 08:17:26 2007 UTC revision 1.30 by mocchiut, Fri Sep 7 21:10:57 2007 UTC
# Line 49  void GL_TABLES::Set(TString host, TStrin Line 49  void GL_TABLES::Set(TString host, TStrin
49    fNquery = 0;    fNquery = 0;
50  };  };
51    
52  Bool_t GL_TABLES::IsConnected(TSQLServer *dbc){  Bool_t GL_TABLES::IsConnected(TSQLServer *&dbc){
53    //    //
54    //    //
55    //    //
# Line 59  Bool_t GL_TABLES::IsConnected(TSQLServer Line 59  Bool_t GL_TABLES::IsConnected(TSQLServer
59    //    //
60    //    //
61    //    //
62    //  printf(" host is %s \n",fHost->Data());    //    printf(" host is %s \n",fHost->Data());
63    //    //
64    stringstream myquery;      stringstream myquery;  
65    myquery.str("");    myquery.str("");
66    myquery << "show databases;";    myquery << "show databases;";
67    dbc->Query(myquery.str().c_str());    if ( dbc ){
68    fNquery++;      if ( dbc->IsConnected() ){
69    //        dbc->Query(myquery.str().c_str());
70    if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){        fNquery++;
71      // is connected        if ( !(dbc->GetErrorCode()) ){
72      return true;          //      printf("ok\n");
73    } else {          //
74            //  if ( (dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006) ){
75            //    if ( !(dbc->GetErrorCode()) ){
76            // is connected
77            return true;
78            //    };
79          };
80        };
81      };
82      //  printf("porca di quella \n");
83      if ( true ) {
84      //      //
85      printf(" WARNING: Lost connection to DB! try to recover... \n");      printf(" WARNING: Lost connection to DB! try to recover... \n");
86      //      //
# Line 84  Bool_t GL_TABLES::IsConnected(TSQLServer Line 94  Bool_t GL_TABLES::IsConnected(TSQLServer
94      myquery << "show databases;";      myquery << "show databases;";
95      dbc->Query(myquery.str().c_str());      dbc->Query(myquery.str().c_str());
96      fNquery++;      fNquery++;
97        //    printf(" e riporca di quella \n");
98      //      //
99      if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){      //    if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){
100        if ( !(dbc->GetErrorCode()) ){
101        //        //
102        printf(" ...connection recovered, I can continue! \n");        printf(" ...connection recovered, I can continue! \n");
103        //        //
# Line 1145  Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, Line 1157  Int_t GL_ROOT::Query_GL_ROOT(UInt_t id,
1157            if(t==0) ID     = (UInt_t)atoll(Row->GetField(t));            if(t==0) ID     = (UInt_t)atoll(Row->GetField(t));
1158            if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t));            if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t));
1159            if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t));            if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t));
1160            if(t==3) PATH   = Row->GetField(t);            if(t==3) PATH   = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/';
1161            if(t==4) NAME   = Row->GetField(t);            if(t==4) NAME   = Row->GetField(t);
1162        };        };
1163    };    };
# Line 1171  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U Line 1183  Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(U
1183    myquery.str("");    myquery.str("");
1184    myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2,BOOT_NUMBER,VALIDATION from GL_TRK_CALIB where FROM_TIME <= "<< time;    myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2,BOOT_NUMBER,VALIDATION from GL_TRK_CALIB where FROM_TIME <= "<< time;
1185  //  myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";      // RIVEDERE LA VALIDAZIONE!!!  //  myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";      // RIVEDERE LA VALIDAZIONE!!!
1186      myquery << " and EV_ROOT_CALIBTRK1>=0 and EV_ROOT_CALIBTRK2>=0 "; // EM! SE MANCA UN PACCHETTO DEI DUE IL PROCESSAMENTO CRASHA... DA RIVEDERE LA VALIDAZIONE      
1187    myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";          myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";      
1188    //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";          //  myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";      
1189    if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
# Line 1354  Int_t GL_PARAM::Query_GL_PARAM(UInt_t ti Line 1367  Int_t GL_PARAM::Query_GL_PARAM(UInt_t ti
1367        if( Row == NULL ) break;        if( Row == NULL ) break;
1368        for( t = 0; t < pResult->GetFieldCount(); t++){        for( t = 0; t < pResult->GetFieldCount(); t++){
1369          if (t==0) ID        = (UInt_t)atoll(Row->GetField(t));          if (t==0) ID        = (UInt_t)atoll(Row->GetField(t));
1370            if (t==1) PATH      = Row->GetField(t);// put in fpath the path to that file          if (t==1) PATH      = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/';// put in fpath the path to that file
1371            if (t==2) NAME      = Row->GetField(t);            if (t==2) NAME      = Row->GetField(t);
1372            if (t==3) DESCR     = Row->GetField(t);            if (t==3) DESCR     = Row->GetField(t);
1373            if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t));            if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
# Line 1421  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1434  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1434      if( Row ){      if( Row ){
1435        stringstream fname;        stringstream fname;
1436        fname.str("");        fname.str("");
1437        fname << Row->GetField(0) << "/" << Row->GetField(1);        fname << gSystem->ExpandPathName(Row->GetField(0)) << "/" << Row->GetField(1);
1438        rname << Row->GetField(1);        rname << Row->GetField(1);
1439        file = new TFile(fname.str().c_str(),"READ");        file = new TFile(fname.str().c_str(),"READ");
1440        idraw = (UInt_t)atoll(Row->GetField(2));        idraw = (UInt_t)atoll(Row->GetField(2));
# Line 1467  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr Line 1480  GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TStr
1480    //    //
1481    //    //
1482    stringstream oss;    stringstream oss;
1483      TString frn = rname.str().c_str();
1484      frn = frn.ReplaceAll(".root",5,".pam",4);
1485    oss.str("");    oss.str("");
1486    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 SPECIAL_FILE='"    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 SPECIAL_FILE='"
1487        << rname.str().c_str() << "';";        << frn.Data() << "';";
1488    if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return;  
1489    this->GetGLTABLES()->AddQ();    this->GetGLTABLES()->AddQ();
1490    pResult = dbc->Query(oss.str().c_str());    pResult = dbc->Query(oss.str().c_str());
# Line 1805  Int_t GL_TLE::DoQuery(TString myquery, T Line 1820  Int_t GL_TLE::DoQuery(TString myquery, T
1820    TSQLRow *row;    TSQLRow *row;
1821    
1822    // Set the right time_zone (otherwise horrible things will occur! :)    // Set the right time_zone (otherwise horrible things will occur! :)
1823      if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;  
1824    dbc->Query("SET time_zone = '+0:00'");    dbc->Query("SET time_zone = '+0:00'");
1825    
1826    // Do the query    // Do the query
   if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57;    
1827    this->GetGLTABLES()->AddQ();    this->GetGLTABLES()->AddQ();
1828    result = dbc->Query(myquery.Data());    result = dbc->Query(myquery.Data());
1829    if(! result->GetRowCount() ) {    if(! result->GetRowCount() ) {

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.23