--- YodaProfiler/src/GLTables.cpp 2006/10/31 15:36:04 1.15 +++ YodaProfiler/src/GLTables.cpp 2006/11/09 12:02:54 1.17 @@ -10,6 +10,7 @@ // #include #include +#include #include #include // @@ -153,8 +154,8 @@ obtfirst = 0; pktfirst = 0; toffset = 0; - ID = 0; - ID_RAW = 0; + // ID = 0; + // ID_RAW = 0; OBT0 = 0; TIMESYNC = 0; TYPE = 0; @@ -861,36 +862,36 @@ 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; @@ -1303,7 +1304,7 @@ // // look for Resurs offset // - UInt_t t0 = 0; + T0 = 0; // // stringstream oss; @@ -1346,34 +1347,25 @@ }; }; // - t0 = (UInt_t)TDatime(Row->GetField(0)).Convert(); - // - // myquery.str(""); - // myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= " - // << idraw << " AND TO_ID_RAW >= " - // << idraw << ";"; - // pResult = dbc->Query(myquery.str().c_str()); - // if ( pResult ){ - // Row = pResult->Next(); - // if ( Row ){ - // // - // t0 = (UInt_t)TDatime(Row->GetField(0)).Convert(); - // // - // }; - // }; - // + // + TDatime ti = TDatime(Row->GetField(0)); + TTimeStamp tu = TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0); + T0 = (UInt_t)tu.GetSec(); // // look for the correct timesync entry // myquery.str(""); - myquery << " SELECT OBT0,TIMESYNC FROM GL_TIMESYNC " + myquery << " SELECT OBT0,TIMESYNC,TYPE FROM GL_TIMESYNC " << " WHERE ID_RAW = " << idraw << ";"; pResult = dbc->Query(myquery.str().c_str()); if ( pResult ){ Row = pResult->Next(); if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){ - toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + t0; + OBT0 = (UInt_t)atoll(Row->GetField(0)); + TIMESYNC = (UInt_t)atoll(Row->GetField(1)); + TYPE = (UInt_t)atoll(Row->GetField(2)); + toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + T0; }; }; // @@ -1392,6 +1384,17 @@ // }; +/** + * + * Returns the Resurs time given the OBT needed to process inclination and orbital infos + * + */ +UInt_t GL_TIMESYNC::ResursTime(UInt_t OBT){ + // + return(((UInt_t)((this->DBobt(OBT)-this->DBobt(OBT0))/1000)+TIMESYNC)); + // +}; + ULong64_t GL_TIMESYNC::DBobt(UInt_t obt){ // @@ -1435,40 +1438,34 @@ */ TString GL_TIMESYNC::ConvertTime(TString &tzone, UInt_t dbt){ // - TDatime *time = new TDatime(); + Int_t offset = 0; TString rtime; Bool_t found = false; // - time->Set(dbt,false); // UTC (Coordinated Universal Time) - // if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ // - UInt_t timeMSK = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time - time->Set(timeMSK,false); + offset = 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time found = true; // }; // if ( !strcmp(tzone.Data(),"CET") ){ // - UInt_t timeCET = time->Convert() + 60*60*1; // CET (Central European Time) = UTC + 1 hs - time->Set(timeCET,false); + offset = 60*60*1; // CET (Central European Time) = UTC + 1 hs found = true; // }; // if ( !strcmp(tzone.Data(),"CEST") ){ // - UInt_t timeCEST = time->Convert() + 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h - time->Set(timeCEST,false); + offset = 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h found = true; // }; // if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST")){ // - UInt_t timeMSD = time->Convert() + 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h - time->Set(timeMSD,false); + offset = 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h found = true; // }; @@ -1478,14 +1475,20 @@ tzone = "UTC"; }; // - rtime = time->AsSQLString(); + dbt += offset; + // + TTimeStamp *time = new TTimeStamp((time_t)dbt,0); + // + rtime = time->AsString("s"); + // + delete time; // return(rtime); } /* * - * Convert the time in the DB from UInt_t to a string + * Convert the time from TZONE to UTC * * @param dbt time in the DB * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK @@ -1493,52 +1496,50 @@ */ TString GL_TIMESYNC::UnConvertTime(TString &tzone, UInt_t dbt){ // - TDatime *time = new TDatime(); + Int_t offset = 0; TString rtime; // Bool_t found = false; // - time->Set(dbt,false); // tzone - // if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ // - UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs - time->Set(timeUTC,false); + offset = -60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs found = true; // }; // if ( !strcmp(tzone.Data(),"CET") ){ // - UInt_t timeCET = time->Convert() - 60*60*1; // CET (Central European Time) - 1 hs = UTC - time->Set(timeCET,false); + offset = -60*60*1; // CET (Central European Time) - 1 hs = UTC found = true; // }; // if ( !strcmp(tzone.Data(),"CEST") ){ // - UInt_t timeCEST = time->Convert() - 60*60*2; // CEST (Central European Summer Time) - 2 h = UTC - time->Set(timeCEST,false); + offset = -60*60*2; // CEST (Central European Summer Time) - 2 h = UTC found = true; // }; // if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){ // - UInt_t timeMSD = time->Convert() - 60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC - time->Set(timeMSD,false); + offset = -60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC found = true; // }; // if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ // + offset = 0; printf("\n Unknown time zone %s using UTC \n",tzone.Data()); tzone = "UTC"; }; // - rtime = time->AsSQLString(); + dbt += offset; + TTimeStamp *time = new TTimeStamp((time_t)dbt,0); + // + rtime = time->AsString("s"); // return(rtime); }