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

Diff of /YodaProfiler/src/PamelaDBOperations.cpp

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

revision 1.28 by mocchiut, Wed Feb 14 10:55:00 2007 UTC revision 1.30 by mocchiut, Mon Apr 30 08:09:50 2007 UTC
# Line 56  string getTleDatetime(cTle*); Line 56  string getTleDatetime(cTle*);
56   * @param debug        debug flag.   * @param debug        debug flag.
57   * @param tlefilename  ascii file with TLE 3 line elements.   * @param tlefilename  ascii file with TLE 3 line elements.
58   */   */
59  PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput){  PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput, Bool_t staticp){
60    //    //
61      STATIC=false;
62      if ( staticp ) STATIC=true;
63    //    //
64    SetConnection(host,user,password);    SetConnection(host,user,password);
65    //    //
# Line 261  void PamelaDBOperations::SetTLEPath(TStr Line 263  void PamelaDBOperations::SetTLEPath(TStr
263    tlefilename = str;    tlefilename = str;
264  };  };
265    
266    TString PamelaDBOperations::GetRawPath(){
267      if ( STATIC ){
268        return((TString)gSystem->DirName(filerawname.Data())+'/');
269      } else {
270        return((TString)gSystem->ExpandPathName("$PAM_RAW")+'/');
271      };
272    };
273    
274    TString PamelaDBOperations::GetRootPath(){
275      if ( STATIC ){
276        return((TString)gSystem->DirName(filerootname.Data())+'/');
277      } else {
278        return((TString)gSystem->ExpandPathName("$PAM_L0")+'/');
279      };
280    };
281    
282  /**  /**
283   * Store the olderthan variable   * Store the olderthan variable
284   * @param olderthan   * @param olderthan
# Line 277  Bool_t PamelaDBOperations::SetID_RAW(){ Line 295  Bool_t PamelaDBOperations::SetID_RAW(){
295    TSQLResult *result = 0;    TSQLResult *result = 0;
296    TSQLRow    *row    = 0;    TSQLRow    *row    = 0;
297    oss.str("");    oss.str("");
298    oss << "SELECT ID FROM GL_RAW WHERE "    if ( STATIC ){
299        << " PATH = '" << this->GetRawPath().Data() << "' AND "      oss << "SELECT ID FROM GL_RAW WHERE "
300        << " NAME = '" << this->GetRawFile().Data() << "' ";          << " PATH = '" << this->GetRawPath().Data() << "' AND "
301            << " NAME = '" << this->GetRawFile().Data() << "' ";  
302      } else {
303        oss << "SELECT ID FROM GL_RAW WHERE "
304            << " PATH = '$PAM_RAW' AND "
305            << " NAME = '" << this->GetRawFile().Data() << "' ";  
306      }
307    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
308    if ( result == NULL ) throw -4;    if ( result == NULL ) throw -4;
309    row = result->Next();    row = result->Next();
# Line 859  Long64_t PamelaDBOperations::PKT(UInt_t Line 882  Long64_t PamelaDBOperations::PKT(UInt_t
882   */   */
883  Long64_t PamelaDBOperations::OBT(UInt_t obt){    Long64_t PamelaDBOperations::OBT(UInt_t obt){  
884    //    //
885      if ( IsDebug() ) printf(" obt conversion: ob is %u obtfirst is %u  (numeric_limits<UInt_t>::max()/2) is %u  \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2));
886      //
887    if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max()));    if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max()));
888    //    //
889    if ( obt > (pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){    if ( obt > (pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){
# Line 980  Int_t PamelaDBOperations::insertPamelaRa Line 1005  Int_t PamelaDBOperations::insertPamelaRa
1005    if ( idr ) return(1);    if ( idr ) return(1);
1006    //    //
1007    oss.str("");    oss.str("");
1008    oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('"    if ( STATIC ){
1009        << this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')";      oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('"
1010            << this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')";
1011      } else {
1012        oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')";
1013      };
1014    if ( conn->Query(oss.str().c_str()) == 0 ) throw -4;    if ( conn->Query(oss.str().c_str()) == 0 ) throw -4;
1015    //    //
1016    idr =  this->SetID_RAW();    idr =  this->SetID_RAW();
# Line 1262  Int_t PamelaDBOperations::insertPamelaRo Line 1291  Int_t PamelaDBOperations::insertPamelaRo
1291    UInt_t idtimesync = 0;    UInt_t idtimesync = 0;
1292    //    //
1293    oss.str("");    oss.str("");
1294    oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW "    if ( STATIC ){
1295        << " LEFT JOIN GL_ROOT "      oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW "
1296        << " ON GL_RAW.ID = GL_ROOT.ID_RAW "          << " LEFT JOIN GL_ROOT "
1297        << " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND "          << " ON GL_RAW.ID = GL_ROOT.ID_RAW "
1298        << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID ";          << " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND "
1299            << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID ";
1300      } else {
1301        oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW "
1302            << " LEFT JOIN GL_ROOT "
1303            << " ON GL_RAW.ID = GL_ROOT.ID_RAW "
1304            << " WHERE GL_RAW.PATH = '$PAM_RAW' AND "
1305            << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID ";
1306      };
1307    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
1308    //    //
1309    if ( !result ) throw -12;    if ( !result ) throw -12;
# Line 1293  Int_t PamelaDBOperations::insertPamelaRo Line 1330  Int_t PamelaDBOperations::insertPamelaRo
1330    idtimesync = (UInt_t)atoll(row->GetField(0));    idtimesync = (UInt_t)atoll(row->GetField(0));
1331    //    //
1332    oss.str("");    oss.str("");
1333    oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('"    if ( STATIC ){
1334        << this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')";      oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('"
1335            << this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')";
1336      } else {
1337        oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('"
1338            << this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')";
1339      };
1340    //    //
1341    if (conn->Query(oss.str().c_str()) == 0) throw -4;    if (conn->Query(oss.str().c_str()) == 0) throw -4;
1342    //    //
# Line 1321  Int_t PamelaDBOperations::assignBOOT_NUM Line 1363  Int_t PamelaDBOperations::assignBOOT_NUM
1363    TSQLResult *result = 0;    TSQLResult *result = 0;
1364    TSQLRow    *row    = 0;    TSQLRow    *row    = 0;
1365    oss.str("");    oss.str("");
1366    oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE "    if ( STATIC ){
1367        << " PATH = '" << this->GetRawPath().Data() << "' AND "      oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE "
1368        << " NAME = '" << this->GetRawFile().Data() << "' ";          << " PATH = '" << this->GetRawPath().Data() << "' AND "
1369            << " NAME = '" << this->GetRawFile().Data() << "' ";
1370      } else {
1371        oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE "
1372            << " PATH = '$PAM_RAW' AND "
1373            << " NAME = '" << this->GetRawFile().Data() << "' ";
1374      };
1375    result = conn->Query(oss.str().c_str());    result = conn->Query(oss.str().c_str());
1376    //    //
1377    if ( !result ) throw -4;;    if ( !result ) throw -4;;

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

  ViewVC Help
Powered by ViewVC 1.1.23