6 |
*/ |
*/ |
7 |
// |
// |
8 |
#include <sstream> |
#include <sstream> |
9 |
|
#include <iostream> |
10 |
// |
// |
11 |
#include <TFile.h> |
#include <TFile.h> |
12 |
#include <TTree.h> |
#include <TTree.h> |
14 |
#include <PscuHeader.h> |
#include <PscuHeader.h> |
15 |
// |
// |
16 |
#include <GLTables.h> |
#include <GLTables.h> |
17 |
|
#include <cTle.h> |
18 |
// |
// |
19 |
ClassImp(GL_TRK_CALIB); |
ClassImp(GL_TRK_CALIB); |
20 |
ClassImp(GL_RUN); |
ClassImp(GL_RUN); |
23 |
ClassImp(GL_S4_CALIB); |
ClassImp(GL_S4_CALIB); |
24 |
ClassImp(GL_CALO_CALIB); |
ClassImp(GL_CALO_CALIB); |
25 |
ClassImp(GL_TIMESYNC); |
ClassImp(GL_TIMESYNC); |
26 |
|
ClassImp(GL_TLE); |
27 |
// |
// |
28 |
using namespace std; |
using namespace std; |
29 |
|
|
61 |
VALIDATION = 0; |
VALIDATION = 0; |
62 |
} |
} |
63 |
|
|
64 |
|
|
65 |
void GL_RUN::Clear() { |
void GL_RUN::Clear() { |
66 |
ID = 0; |
ID = 0; |
67 |
ID_RUN_FRAG = 0; |
ID_RUN_FRAG = 0; |
126 |
OBT2 = 0; |
OBT2 = 0; |
127 |
PKT1 = 0; |
PKT1 = 0; |
128 |
PKT2 = 0; |
PKT2 = 0; |
129 |
|
BOOT_NUMBER = 0; |
130 |
|
VALIDATION = 0; |
131 |
} |
} |
132 |
|
|
133 |
GL_CALO_CALIB::GL_CALO_CALIB(){ |
GL_CALO_CALIB::GL_CALO_CALIB(){ |
158 |
OBT0 = 0; |
OBT0 = 0; |
159 |
TIMESYNC = 0; |
TIMESYNC = 0; |
160 |
TYPE = 0; |
TYPE = 0; |
161 |
}// **************************************************** |
} |
162 |
|
|
163 |
|
GL_TLE::GL_TLE(){ |
164 |
|
} |
165 |
|
|
166 |
|
// **************************************************** |
167 |
|
|
168 |
void GL_RUN::SetEV_FROM(UInt_t evfrom){ |
void GL_RUN::SetEV_FROM(UInt_t evfrom){ |
169 |
EV_FROM = evfrom; |
EV_FROM = evfrom; |
337 |
CAL_DSP_MASK = 0; |
CAL_DSP_MASK = 0; |
338 |
}; |
}; |
339 |
|
|
340 |
|
void GL_RUN::Set_GL_RUN(TSQLRow *Row){ |
341 |
|
for( Int_t t = 0; t < 30; t++){ |
342 |
|
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
343 |
|
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
344 |
|
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
345 |
|
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
346 |
|
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
347 |
|
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
348 |
|
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
349 |
|
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
350 |
|
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
351 |
|
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
352 |
|
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
353 |
|
if (t==11) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
354 |
|
if (t==12) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
355 |
|
if (t==13) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
356 |
|
if (t==14) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
357 |
|
if (t==15) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
358 |
|
if (t==16) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
359 |
|
if (t==17) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
360 |
|
if (t==18) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
361 |
|
if (t==19) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
362 |
|
if (t==20) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
363 |
|
if (t==21) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
364 |
|
if (t==22) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
365 |
|
if (t==23) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
366 |
|
if (t==24) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
367 |
|
if (t==25) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
368 |
|
if (t==26) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
369 |
|
if (t==27) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
370 |
|
if (t==28) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
371 |
|
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
372 |
|
}; |
373 |
|
|
374 |
|
} |
375 |
|
|
376 |
|
|
377 |
/** |
/** |
378 |
* Function to fill the GL_RUN table of the DB. |
* Function to fill the GL_RUN table of the DB. |
593 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
594 |
Row = pResult->Next(); |
Row = pResult->Next(); |
595 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
596 |
|
// Set_GL_RUN(Row); |
597 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
598 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
599 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
600 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
601 |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
602 |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
603 |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
604 |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
605 |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
606 |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
607 |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
608 |
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
609 |
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
610 |
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
611 |
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
612 |
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
613 |
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
614 |
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
615 |
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
616 |
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
617 |
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
618 |
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
619 |
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
620 |
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
621 |
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
622 |
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
623 |
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
624 |
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
625 |
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
626 |
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
627 |
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
628 |
}; |
}; |
629 |
}; |
}; |
630 |
// delete pResult; |
// delete pResult; |
768 |
* Function to query the GL_TRK_CALIB table of the DB. |
* Function to query the GL_TRK_CALIB table of the DB. |
769 |
* |
* |
770 |
* \param run starting time |
* \param run starting time |
771 |
|
* \param dbc DB server |
772 |
* \return struct of type GL_TRK_CALIB_data, which stores the query result |
* \return struct of type GL_TRK_CALIB_data, which stores the query result |
773 |
*/ |
*/ |
774 |
Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ |
Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ |
780 |
stringstream myquery; |
stringstream myquery; |
781 |
// ---------------- |
// ---------------- |
782 |
myquery.str(""); |
myquery.str(""); |
783 |
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; |
784 |
myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
785 |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
786 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
792 |
stringstream row; |
stringstream row; |
793 |
row.str(""); |
row.str(""); |
794 |
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 |
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 |
795 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
796 |
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
797 |
if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str()); |
if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str()); |
798 |
if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str()); |
if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str()); |
799 |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
800 |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
801 |
// |
// |
802 |
if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); |
if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); |
803 |
if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); |
if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); |
804 |
if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); |
if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); |
805 |
if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); |
if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); |
806 |
}; |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
807 |
|
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
808 |
|
}; |
809 |
}; |
}; |
810 |
delete pResult; |
delete pResult; |
811 |
|
// |
812 |
|
// if ( TO_TIME < time ) return(51); |
813 |
// |
// |
|
if(TO_TIME < time)return(51); |
|
814 |
if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING! |
if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING! |
815 |
// |
// |
816 |
return 0; |
return 0; |
823 |
* \param run starting time |
* \param run starting time |
824 |
* \return struct of type GL_CALO_CALIB_data, which stores the query result |
* \return struct of type GL_CALO_CALIB_data, which stores the query result |
825 |
*/ |
*/ |
826 |
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){ |
827 |
// MySQL variables |
// MySQL variables |
828 |
TSQLResult *pResult; |
TSQLResult *pResult; |
829 |
TSQLRow *Row; |
TSQLRow *Row; |
830 |
int t; |
int t; |
831 |
stringstream myquery; |
stringstream myquery; |
832 |
|
uptime = 0; |
833 |
// |
// |
834 |
// select the correct calibration |
// select the correct calibration |
835 |
// |
// |
837 |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
838 |
myquery << " and FROM_TIME <= " << time; |
myquery << " and FROM_TIME <= " << time; |
839 |
myquery << " and TO_TIME > " << time; |
myquery << " and TO_TIME > " << time; |
840 |
myquery << " and VALIDATION=1;"; |
myquery << " ;"; |
841 |
|
//myquery << " and VALIDATION=1;"; |
842 |
// |
// |
843 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
844 |
|
// printf(" mysquery is %s\n",myquery.str().c_str()); |
845 |
|
// |
846 |
|
if( !pResult->GetRowCount() ) return(-54); |
847 |
|
Row = pResult->Next(); |
848 |
|
if( Row == NULL ) return (-54); |
849 |
|
// |
850 |
|
uptime = (UInt_t)atoll(Row->GetField(2)); |
851 |
// |
// |
852 |
// if it is corrupted validation is 0 and we have no results from the query... |
// if it is corrupted validation is 0 and we have no results from the query... |
853 |
// |
// |
854 |
if( !pResult->GetRowCount() ){ |
if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 |
|
// pResult->Delete(); |
|
855 |
// |
// |
856 |
// in this case take relax the conditions and take the valid calibration that preceed the correct one |
// in this case take relax the conditions and take the valid calibration that preceed the correct one |
857 |
// |
// |
860 |
myquery << " and FROM_TIME <= " << time; |
myquery << " and FROM_TIME <= " << time; |
861 |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
862 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
863 |
|
// printf(" mysquery is %s\n",myquery.str().c_str()); |
864 |
// |
// |
865 |
// if no results yet quit with error |
// if no results yet quit with error |
866 |
// |
// |
867 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ) return (-54); |
868 |
|
// |
869 |
|
Row = pResult->Next(); |
870 |
|
// |
871 |
}; |
}; |
872 |
// |
// |
873 |
// store infos and exit |
// store infos and exit |
874 |
// |
// |
|
Row = pResult->Next(); |
|
875 |
if( Row == NULL ) return (-54); |
if( Row == NULL ) return (-54); |
876 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
877 |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1121 |
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
1122 |
* |
* |
1123 |
*/ |
*/ |
1124 |
TString GL_TIMESYNC::ConvertTime(TString tzone, UInt_t dbt){ |
TString GL_TIMESYNC::ConvertTime(TString &tzone, UInt_t dbt){ |
1125 |
// |
// |
1126 |
TDatime *time = new TDatime(); |
TDatime *time = new TDatime(); |
1127 |
TString rtime; |
TString rtime; |
1128 |
|
Bool_t found = false; |
1129 |
// |
// |
1130 |
time->Set(dbt,false); // MSK = Moscow Winter Time |
time->Set(dbt,false); // UTC (Coordinated Universal Time) |
1131 |
// |
// |
1132 |
if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){ |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
1133 |
// |
// |
1134 |
UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3 hs |
UInt_t timeMSK = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time |
1135 |
time->Set(timeUTC,false); |
time->Set(timeMSK,false); |
1136 |
|
found = true; |
1137 |
// |
// |
1138 |
}; |
}; |
1139 |
// |
// |
1140 |
if ( !strcmp(tzone.Data(),"CET") ){ |
if ( !strcmp(tzone.Data(),"CET") ){ |
1141 |
// |
// |
1142 |
UInt_t timeCET = time->Convert() - 60*60*2; // CET (Central European Time) = Moscow Winter Time - 2 hs |
UInt_t timeCET = time->Convert() + 60*60*1; // CET (Central European Time) = UTC + 1 hs |
1143 |
time->Set(timeCET,false); |
time->Set(timeCET,false); |
1144 |
|
found = true; |
1145 |
// |
// |
1146 |
}; |
}; |
1147 |
// |
// |
1148 |
if ( !strcmp(tzone.Data(),"CEST") ){ |
if ( !strcmp(tzone.Data(),"CEST") ){ |
1149 |
// |
// |
1150 |
UInt_t timeCEST = time->Convert() - 60*60*1; // CEST (Central European Summer Time) = Moscow Winter Time - 1 h |
UInt_t timeCEST = time->Convert() + 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h |
1151 |
time->Set(timeCEST,false); |
time->Set(timeCEST,false); |
1152 |
|
found = true; |
1153 |
// |
// |
1154 |
}; |
}; |
1155 |
// |
// |
1156 |
if ( !strcmp(tzone.Data(),"MSD") ){ |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST")){ |
1157 |
// |
// |
1158 |
UInt_t timeMSD = time->Convert() + 60*60*1; // MSD (Moscow Summer Time) = Moscow Winter Time + 1 h |
UInt_t timeMSD = time->Convert() + 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h |
1159 |
time->Set(timeMSD,false); |
time->Set(timeMSD,false); |
1160 |
|
found = true; |
1161 |
// |
// |
1162 |
}; |
}; |
1163 |
// |
// |
1164 |
|
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
1165 |
|
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
1166 |
|
tzone = "UTC"; |
1167 |
|
}; |
1168 |
|
// |
1169 |
rtime = time->AsSQLString(); |
rtime = time->AsSQLString(); |
1170 |
// |
// |
1171 |
return(rtime); |
return(rtime); |
1179 |
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
1180 |
* |
* |
1181 |
*/ |
*/ |
1182 |
TString GL_TIMESYNC::UnConvertTime(TString tzone, UInt_t dbt){ |
TString GL_TIMESYNC::UnConvertTime(TString &tzone, UInt_t dbt){ |
1183 |
// |
// |
1184 |
TDatime *time = new TDatime(); |
TDatime *time = new TDatime(); |
1185 |
TString rtime; |
TString rtime; |
1186 |
// |
// |
1187 |
time->Set(dbt,false); // MSK = Moscow Winter Time |
Bool_t found = false; |
1188 |
|
// |
1189 |
|
time->Set(dbt,false); // tzone |
1190 |
// |
// |
1191 |
if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){ |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
1192 |
// |
// |
1193 |
UInt_t timeUTC = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) +3 hs = Moscow Winter Time |
UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs |
1194 |
time->Set(timeUTC,false); |
time->Set(timeUTC,false); |
1195 |
|
found = true; |
1196 |
// |
// |
1197 |
}; |
}; |
1198 |
// |
// |
1199 |
if ( !strcmp(tzone.Data(),"CET") ){ |
if ( !strcmp(tzone.Data(),"CET") ){ |
1200 |
// |
// |
1201 |
UInt_t timeCET = time->Convert() + 60*60*2; // CET (Central European Time) + 2 hs = Moscow Winter Time |
UInt_t timeCET = time->Convert() - 60*60*1; // CET (Central European Time) - 1 hs = UTC |
1202 |
time->Set(timeCET,false); |
time->Set(timeCET,false); |
1203 |
|
found = true; |
1204 |
// |
// |
1205 |
}; |
}; |
1206 |
// |
// |
1207 |
if ( !strcmp(tzone.Data(),"CEST") ){ |
if ( !strcmp(tzone.Data(),"CEST") ){ |
1208 |
// |
// |
1209 |
UInt_t timeCEST = time->Convert() + 60*60*1; // CEST (Central European Summer Time) + 1 h = Moscow Winter Time |
UInt_t timeCEST = time->Convert() - 60*60*2; // CEST (Central European Summer Time) - 2 h = UTC |
1210 |
time->Set(timeCEST,false); |
time->Set(timeCEST,false); |
1211 |
|
found = true; |
1212 |
// |
// |
1213 |
}; |
}; |
1214 |
// |
// |
1215 |
if ( !strcmp(tzone.Data(),"MSD") ){ |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){ |
1216 |
// |
// |
1217 |
UInt_t timeMSD = time->Convert() - 60*60*1; // MSD (Moscow Summer Time) - 1 h = Moscow Winter Time |
UInt_t timeMSD = time->Convert() - 60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC |
1218 |
time->Set(timeMSD,false); |
time->Set(timeMSD,false); |
1219 |
|
found = true; |
1220 |
// |
// |
1221 |
}; |
}; |
1222 |
// |
// |
1223 |
|
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
1224 |
|
// |
1225 |
|
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
1226 |
|
tzone = "UTC"; |
1227 |
|
}; |
1228 |
|
// |
1229 |
rtime = time->AsSQLString(); |
rtime = time->AsSQLString(); |
1230 |
// |
// |
1231 |
return(rtime); |
return(rtime); |
1232 |
} |
} |
1233 |
|
|
1234 |
|
|
1235 |
|
// **************************************************** |
1236 |
|
/** |
1237 |
|
* Function to query the GL_TLE table of the DB. |
1238 |
|
* |
1239 |
|
* time is the unix time for which a good tle is requested. |
1240 |
|
* |
1241 |
|
* Return the pointer to a cTle object that has the closest and |
1242 |
|
* previous date compared with time. |
1243 |
|
* |
1244 |
|
* If errors occurs it returns NULL. |
1245 |
|
*/ |
1246 |
|
cTle* GL_TLE::Query_GL_TLE(UInt_t time, TSQLServer *dbc){ |
1247 |
|
stringstream myquery; |
1248 |
|
myquery.str(""); |
1249 |
|
|
1250 |
|
myquery << "SELECT TLE1, TLE2, TLE3 FROM GL_TLE " |
1251 |
|
<< "WHERE FROM_TIME < FROM_UNIXTIME(" << time << ") ORDER BY FROM_TIME DESC LIMIT 1;"; |
1252 |
|
|
1253 |
|
|
1254 |
|
return Query_GL_TLE_go(myquery.str(), dbc); |
1255 |
|
} |
1256 |
|
|
1257 |
|
|
1258 |
|
// **************************************************** |
1259 |
|
/** |
1260 |
|
* Function to query the GL_TLE table of the DB. |
1261 |
|
* |
1262 |
|
* date is a datetime format YYYY-MM-DD hh:mm:ss for which a good tle |
1263 |
|
* is requested. |
1264 |
|
* |
1265 |
|
* Return the pointer to a cTle object that has the closest and |
1266 |
|
* previous date compared with time. |
1267 |
|
* |
1268 |
|
* If errors occurs it returns NULL. |
1269 |
|
*/ |
1270 |
|
cTle* GL_TLE::Query_GL_TLE(TString date, TSQLServer *dbc){ |
1271 |
|
stringstream myquery; |
1272 |
|
myquery.str(""); |
1273 |
|
|
1274 |
|
myquery << "SELECT TLE1, TLE2, TLE3 FROM GL_TLE " |
1275 |
|
<< "WHERE FROM_TIME < '" << date.Data() << "' ORDER BY FROM_TIME DESC LIMIT 1;"; |
1276 |
|
|
1277 |
|
|
1278 |
|
return Query_GL_TLE_go(myquery.str(), dbc); |
1279 |
|
} |
1280 |
|
|
1281 |
|
|
1282 |
|
// **************************************************** |
1283 |
|
/** |
1284 |
|
* Private function used by Query_GL_TLE methods. |
1285 |
|
* |
1286 |
|
* myquery is the query string. |
1287 |
|
* |
1288 |
|
* Return the pointer to a cTle object that has the closest and |
1289 |
|
* previous date compared with time. |
1290 |
|
* |
1291 |
|
* If errors occurs it returns NULL. |
1292 |
|
*/ |
1293 |
|
cTle* GL_TLE::Query_GL_TLE_go(TString myquery, TSQLServer *dbc){ |
1294 |
|
cTle *tle; |
1295 |
|
string tle1, tle2, tle3; |
1296 |
|
|
1297 |
|
// MySQL variables |
1298 |
|
TSQLResult *result; |
1299 |
|
TSQLRow *row; |
1300 |
|
|
1301 |
|
result = dbc->Query(myquery.Data()); |
1302 |
|
if(! result->GetRowCount() ) return NULL; |
1303 |
|
|
1304 |
|
row = result->Next(); |
1305 |
|
tle1 = row->GetField(0); |
1306 |
|
tle2 = row->GetField(1); |
1307 |
|
tle3 = row->GetField(2); |
1308 |
|
|
1309 |
|
tle = new cTle(tle1, tle2, tle3); |
1310 |
|
|
1311 |
|
delete result; |
1312 |
|
delete row; |
1313 |
|
|
1314 |
|
return tle; |
1315 |
|
} |