--- YodaProfiler/src/GLTables.cpp 2006/08/30 11:18:13 1.1 +++ YodaProfiler/src/GLTables.cpp 2006/09/08 14:42:48 1.9 @@ -58,6 +58,7 @@ VALIDATION = 0; } + void GL_RUN::Clear() { ID = 0; ID_RUN_FRAG = 0; @@ -122,6 +123,8 @@ OBT2 = 0; PKT1 = 0; PKT2 = 0; + BOOT_NUMBER = 0; + VALIDATION = 0; } GL_CALO_CALIB::GL_CALO_CALIB(){ @@ -327,6 +330,42 @@ CAL_DSP_MASK = 0; }; +void GL_RUN::Set_GL_RUN(TSQLRow *Row){ + for( Int_t t = 0; t < 30; t++){ + if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); + if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); + if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); + if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); + if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); + if (t==11) EV_FROM = (UInt_t)atoll(Row->GetField(t)); + if (t==12) EV_TO = (UInt_t)atoll(Row->GetField(t)); + if (t==13) NEVENTS = (UInt_t)atoll(Row->GetField(t)); + if (t==14) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==15) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==16) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); + if (t==17) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==18) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==19) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); + if (t==20) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); + if (t==21) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==22) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==23) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); + if (t==24) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); + if (t==25) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); + if (t==26) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); + if (t==27) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==28) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); + }; + +} + /** * Function to fill the GL_RUN table of the DB. @@ -403,7 +442,7 @@ myquery << (UInt_t)BOOT_NUMBER << "','"; myquery << (UInt_t)VALIDATION << "');"; // - //printf("myquery is %s \n",myquery.str().c_str()); + // printf("myquery is %s \n",myquery.str().c_str()); // dbc->Query(myquery.str().c_str()); // @@ -537,48 +576,52 @@ myquery << ",VALIDATION"; myquery << " from GL_RUN where ID=" << run << ";"; // + // printf(" myquery is %s \n",myquery.str().c_str()); pResult = dbc->Query(myquery.str().c_str()); - if(!pResult->GetRowCount())return(-50); + // + // printf(" getrowcount %i \n",pResult->GetRowCount()); + // + if( !pResult->GetRowCount() ) return(-50); + // for( r=0; r < 1000; r++){ Row = pResult->Next(); if( Row == NULL ) break; +// Set_GL_RUN(Row); for( t = 0; t < pResult->GetFieldCount(); t++){ - if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); - if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); - if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); - if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); - if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); - if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); - if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); - if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); - if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); - if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); - if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); - if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); - if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); - if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); - if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); - if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); - if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); - if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); - if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); - if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); - if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); - if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); - if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); - if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); - if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); - if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); - if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); - if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); + if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); + if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); + if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); + if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); + if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); + if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); + if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); + if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); + if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); + if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); + if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); + if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); + if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); + if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); + if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); + if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); }; }; - delete pResult; - - return 0; - + // delete pResult; + return(0); }; /** @@ -589,7 +632,6 @@ * */ Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ - // Bool_t debug = 1; // MySQL variables TSQLResult *pResult; TSQLRow *Row; @@ -597,12 +639,12 @@ int r; stringstream myquery; // ---------------- - // NB! unsigned long long integers: when set to a number use ULL to store the correct number myquery.str(""); myquery << " select "; - // myquery << " * "; myquery << "ID"; + myquery << ",ID_RUN_FRAG"; myquery << ",ID_ROOT_L0"; + myquery << ",ID_ROOT_L2"; myquery << ",RUNHEADER_TIME"; myquery << ",RUNTRAILER_TIME"; myquery << ",RUNHEADER_OBT"; @@ -628,48 +670,53 @@ myquery << ",TRK_CALIB_USED"; myquery << ",CAL_DSP_MASK"; myquery << ",BOOT_NUMBER"; + myquery << ",VALIDATION"; myquery << " from GL_RUN_FRAGMENTS where " << where.Data() << ";"; // + // printf(" query is %s \n",myquery.str().c_str()); + // pResult = dbc->Query(myquery.str().c_str()); if(!pResult->GetRowCount())return(-50); for( r=0; r < 1000; r++){ - Row = pResult->Next(); - if( Row == NULL ) break; - for( t = 0; t < pResult->GetFieldCount(); t++){ - if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); - if (t== 1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); - if (t== 2) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t== 3) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t== 4) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); - if (t== 5) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); - if (t== 6) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); - if (t== 7) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); - if (t== 8) EV_FROM = (UInt_t)atoll(Row->GetField(t)); - if (t== 9) EV_TO = (UInt_t)atoll(Row->GetField(t)); - if (t==10) NEVENTS = (UInt_t)atoll(Row->GetField(t)); - if (t==11) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); - if (t==12) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); - if (t==13) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); - if (t==14) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); - if (t==15) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); - if (t==16) PRH_VAR_TRG_MODE_A = (UInt_t)atoll(Row->GetField(t)); - if (t==17) PRH_VAR_TRG_MODE_B = (UInt_t)atoll(Row->GetField(t)); - if (t==18) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); - if (t==19) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); - if (t==20) RM_ACQ_AFTER_CALIB = (UInt_t)atoll(Row->GetField(t)); - if (t==21) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); - if (t==22) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); - if (t==23) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); - if (t==24) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); - if (t==25) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); - if (t==26) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); - }; + Row = pResult->Next(); + if( Row == NULL ) break; + for( t = 0; t < pResult->GetFieldCount(); t++){ + if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); + if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); + if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); + if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); + if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); + if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); + if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); + if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); + if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); + if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); + if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); + if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); + if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); + if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); + if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); + if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); + if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); + if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); + if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); + if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); + if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); + if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); + }; }; - delete pResult; - - return 0; - + // delete pResult; + return(0); };// **************************************************** + /** * Function to query the GL_ROOT table of the DB. * @@ -714,6 +761,7 @@ * Function to query the GL_TRK_CALIB table of the DB. * * \param run starting time + * \param dbc DB server * \return struct of type GL_TRK_CALIB_data, which stores the query result */ Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ @@ -725,7 +773,7 @@ stringstream myquery; // ---------------- myquery.str(""); - myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2 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; myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; // myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; pResult = dbc->Query(myquery.str().c_str()); @@ -734,22 +782,28 @@ Row = pResult->Next(); if( Row == NULL ) break; for( t = 0; t < pResult->GetFieldCount(); t++){ - if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); - if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); - if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(Row->GetField(t)); - if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(Row->GetField(t)); - if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); - if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); + stringstream row; + row.str(""); + row << "0" << Row->GetField(t); // add leading 0 since we have two fields that could be "null" and we want to avoid crashes due to atoll + if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); + if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); + if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str()); + if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str()); + if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); + if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); // - if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); - if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); - if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); - if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); - }; + if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); + if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); + if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); + if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); + if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); + if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); + }; }; - delete pResult; + delete pResult; + // +// if ( TO_TIME < time ) return(51); // - if(TO_TIME < time)return(51); if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING! // return 0; @@ -762,12 +816,13 @@ * \param run starting time * \return struct of type GL_CALO_CALIB_data, which stores the query result */ -Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t section, TSQLServer *dbc){ +Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){ // MySQL variables TSQLResult *pResult; TSQLRow *Row; int t; stringstream myquery; + uptime = 0; // // select the correct calibration // @@ -775,14 +830,21 @@ myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; myquery << " and FROM_TIME <= " << time; myquery << " and TO_TIME > " << time; - myquery << " and VALIDATION=1;"; + myquery << " ;"; + //myquery << " and VALIDATION=1;"; // pResult = dbc->Query(myquery.str().c_str()); + // printf(" mysquery is %s\n",myquery.str().c_str()); + // + if( !pResult->GetRowCount() ) return(-54); + Row = pResult->Next(); + if( Row == NULL ) return (-54); + // + uptime = (UInt_t)atoll(Row->GetField(2)); // // if it is corrupted validation is 0 and we have no results from the query... // - if( !pResult->GetRowCount() ){ - // pResult->Delete(); + if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 // // in this case take relax the conditions and take the valid calibration that preceed the correct one // @@ -791,15 +853,18 @@ myquery << " and FROM_TIME <= " << time; myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; pResult = dbc->Query(myquery.str().c_str()); + // printf(" mysquery is %s\n",myquery.str().c_str()); // // if no results yet quit with error // if( !pResult->GetRowCount() ) return (-54); + // + Row = pResult->Next(); + // }; // // store infos and exit // - Row = pResult->Next(); if( Row == NULL ) return (-54); for( t = 0; t < pResult->GetFieldCount(); t++){ if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); @@ -827,7 +892,7 @@ // ---------------- myquery.str(""); myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time; - myquery << " AND VALIDATION = 1 ORDER BY FROM_TIME DESC LIMIT 1;"; + myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; // myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; pResult = dbc->Query(myquery.str().c_str()); if(!pResult->GetRowCount())return (-55);//throw -55; @@ -992,6 +1057,8 @@ toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + t0; }; }; + // + file->Close(); delete pResult; }; @@ -1038,3 +1105,99 @@ return(pkt_num); // }; + +/* + * + * Convert the time in the DB from UInt_t to a string + * + * @param dbt time in the DB + * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK + * + */ +TString GL_TIMESYNC::ConvertTime(TString tzone, UInt_t dbt){ + // + TDatime *time = new TDatime(); + TString rtime; + // + time->Set(dbt,false); // MSK = Moscow Winter Time + // + if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){ + // + UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3 hs + time->Set(timeUTC,false); + // + }; + // + if ( !strcmp(tzone.Data(),"CET") ){ + // + UInt_t timeCET = time->Convert() - 60*60*2; // CET (Central European Time) = Moscow Winter Time - 2 hs + time->Set(timeCET,false); + // + }; + // + if ( !strcmp(tzone.Data(),"CEST") ){ + // + UInt_t timeCEST = time->Convert() - 60*60*1; // CEST (Central European Summer Time) = Moscow Winter Time - 1 h + time->Set(timeCEST,false); + // + }; + // + if ( !strcmp(tzone.Data(),"MSD") ){ + // + UInt_t timeMSD = time->Convert() + 60*60*1; // MSD (Moscow Summer Time) = Moscow Winter Time + 1 h + time->Set(timeMSD,false); + // + }; + // + rtime = time->AsSQLString(); + // + return(rtime); +} + +/* + * + * Convert the time in the DB from UInt_t to a string + * + * @param dbt time in the DB + * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK + * + */ +TString GL_TIMESYNC::UnConvertTime(TString tzone, UInt_t dbt){ + // + TDatime *time = new TDatime(); + TString rtime; + // + time->Set(dbt,false); // MSK = Moscow Winter Time + // + if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){ + // + UInt_t timeUTC = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) +3 hs = Moscow Winter Time + time->Set(timeUTC,false); + // + }; + // + if ( !strcmp(tzone.Data(),"CET") ){ + // + UInt_t timeCET = time->Convert() + 60*60*2; // CET (Central European Time) + 2 hs = Moscow Winter Time + time->Set(timeCET,false); + // + }; + // + if ( !strcmp(tzone.Data(),"CEST") ){ + // + UInt_t timeCEST = time->Convert() + 60*60*1; // CEST (Central European Summer Time) + 1 h = Moscow Winter Time + time->Set(timeCEST,false); + // + }; + // + if ( !strcmp(tzone.Data(),"MSD") ){ + // + UInt_t timeMSD = time->Convert() - 60*60*1; // MSD (Moscow Summer Time) - 1 h = Moscow Winter Time + time->Set(timeMSD,false); + // + }; + // + rtime = time->AsSQLString(); + // + return(rtime); +}