68 |
return NULL; |
return NULL; |
69 |
}; |
}; |
70 |
// |
// |
71 |
|
if (Row) |
72 |
|
delete Row; |
73 |
pResult = dbc->Query(query.Data()); |
pResult = dbc->Query(query.Data()); |
74 |
// |
// |
75 |
Row = pResult->Next(); |
Row = pResult->Next(); |
99 |
if ( f2 < minf2 ) minf2 = f2; |
if ( f2 < minf2 ) minf2 = f2; |
100 |
|
|
101 |
}; |
}; |
102 |
|
if (Row) |
103 |
|
delete Row; |
104 |
Row = pResult->Next(); |
Row = pResult->Next(); |
105 |
}; |
}; |
106 |
pResult->Delete(); |
pResult->Delete(); |
140 |
// |
// |
141 |
pResult = dbc->Query(query.Data()); |
pResult = dbc->Query(query.Data()); |
142 |
// |
// |
143 |
|
if (Row) |
144 |
|
delete Row; |
145 |
Row = pResult->Next(); |
Row = pResult->Next(); |
146 |
// |
// |
147 |
Int_t r = 0; |
Int_t r = 0; |
157 |
h2->Fill(f1,f2); |
h2->Fill(f1,f2); |
158 |
}; |
}; |
159 |
r++; |
r++; |
160 |
|
if (Row) |
161 |
|
delete Row; |
162 |
Row = pResult->Next(); |
Row = pResult->Next(); |
163 |
}; |
}; |
164 |
// |
// |
172 |
if ( dim == 1 ) h1->Draw(); |
if ( dim == 1 ) h1->Draw(); |
173 |
if ( dim == 2 ) h2->Draw(); |
if ( dim == 2 ) h2->Draw(); |
174 |
// |
// |
175 |
|
if (Row) |
176 |
|
delete Row; |
177 |
pResult->Delete(); |
pResult->Delete(); |
178 |
if ( dim == 1 ) return h1; |
if ( dim == 1 ) return h1; |
179 |
if ( dim == 2 ) return h2; |
if ( dim == 2 ) return h2; |
223 |
myquery << "show databases;"; |
myquery << "show databases;"; |
224 |
if ( dbc ){ |
if ( dbc ){ |
225 |
if ( dbc->IsConnected() ){ |
if ( dbc->IsConnected() ){ |
226 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
227 |
fNquery++; |
fNquery++; |
228 |
if ( !(dbc->GetErrorCode()) ){ |
if ( !(dbc->GetErrorCode()) ){ |
229 |
// printf("ok\n"); |
// printf("ok\n"); |
247 |
if ( dbc ){ |
if ( dbc ){ |
248 |
dbc->Close(); |
dbc->Close(); |
249 |
delete dbc; |
delete dbc; |
250 |
|
dbc = 0; |
251 |
}; |
}; |
252 |
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
253 |
// |
// |
254 |
myquery.str(""); |
myquery.str(""); |
255 |
myquery << "show databases;"; |
myquery << "show databases;"; |
256 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
257 |
fNquery++; |
fNquery++; |
258 |
// if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
// if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
259 |
if ( !(dbc->GetErrorCode()) ){ |
if ( !(dbc->GetErrorCode()) ){ |
262 |
// |
// |
263 |
myquery.str(""); |
myquery.str(""); |
264 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00'"; |
265 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
266 |
fNquery++; |
fNquery++; |
267 |
myquery.str(""); |
myquery.str(""); |
268 |
myquery << "SET wait_timeout=173000;"; |
myquery << "SET wait_timeout=173000;"; |
269 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
270 |
fNquery++; |
fNquery++; |
271 |
return true; |
return true; |
272 |
}; |
}; |
685 |
Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ |
Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ |
686 |
// MySQL variables |
// MySQL variables |
687 |
TSQLResult *pResult; |
TSQLResult *pResult; |
688 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
689 |
stringstream myquery; |
stringstream myquery; |
690 |
// |
// |
691 |
if ( !IDRUN ) IDRUN = ID; |
if ( !IDRUN ) IDRUN = ID; |
735 |
// |
// |
736 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
737 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
738 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
739 |
// |
// |
740 |
// retrieve this ID_TRASH |
// retrieve this ID_TRASH |
741 |
// |
// |
749 |
UInt_t idl0 = 0; |
UInt_t idl0 = 0; |
750 |
UInt_t idl2 = 0; |
UInt_t idl2 = 0; |
751 |
// |
// |
752 |
|
if (Row) |
753 |
|
delete Row; |
754 |
Row = pResult->Next(); |
Row = pResult->Next(); |
755 |
if( Row != NULL ){ |
if( Row != NULL ){ |
756 |
idtrash = (UInt_t)atoll(Row->GetField(0)); |
idtrash = (UInt_t)atoll(Row->GetField(0)); |
766 |
// |
// |
767 |
// printf("2myquery is %s \n",myquery.str().c_str()); |
// printf("2myquery is %s \n",myquery.str().c_str()); |
768 |
// |
// |
769 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
770 |
|
if (pResult) |
771 |
|
delete pResult; |
772 |
|
if (Row) |
773 |
|
delete Row; |
774 |
|
return -57; |
775 |
|
} |
776 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
777 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
778 |
// |
// |
779 |
|
if (Row) |
780 |
|
delete Row; |
781 |
Row = pResult->Next(); |
Row = pResult->Next(); |
782 |
if( Row != NULL ){ |
if( Row != NULL ){ |
783 |
fileL0 = (TString)Row->GetField(0); |
fileL0 = (TString)Row->GetField(0); |
791 |
// |
// |
792 |
// printf("3myquery is %s \n",myquery.str().c_str()); |
// printf("3myquery is %s \n",myquery.str().c_str()); |
793 |
// |
// |
794 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
795 |
|
if (pResult) |
796 |
|
delete pResult; |
797 |
|
if (Row) |
798 |
|
delete Row; |
799 |
|
return -57; |
800 |
|
} |
801 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
802 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
803 |
// |
// |
804 |
|
if (Row) |
805 |
|
delete Row; |
806 |
Row = pResult->Next(); |
Row = pResult->Next(); |
807 |
if( Row != NULL ){ |
if( Row != NULL ){ |
808 |
fileL2 = (TString)Row->GetField(0); |
fileL2 = (TString)Row->GetField(0); |
809 |
}; |
} |
810 |
|
delete pResult; |
811 |
|
pResult = NULL; |
812 |
|
if (Row){ |
813 |
|
delete Row; |
814 |
|
Row = NULL; // This variable is not used below |
815 |
|
} |
816 |
// |
// |
817 |
// |
// |
818 |
// |
// |
825 |
// |
// |
826 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
827 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
828 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
829 |
// |
// |
830 |
myquery.str(""); |
myquery.str(""); |
831 |
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='"; |
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='"; |
836 |
// |
// |
837 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
838 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
839 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
840 |
// |
// |
841 |
myquery.str(""); |
myquery.str(""); |
842 |
myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='"; |
myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='"; |
848 |
// |
// |
849 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
850 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
851 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
852 |
// |
// |
853 |
myquery.str(""); |
myquery.str(""); |
854 |
myquery << " DELETE FROM "; |
myquery << " DELETE FROM "; |
860 |
// |
// |
861 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
862 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
863 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
864 |
// |
// |
865 |
return 0; |
return 0; |
866 |
}; |
}; |
876 |
// insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11; |
// insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11; |
877 |
//insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11; |
//insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11; |
878 |
// MySQL variables |
// MySQL variables |
879 |
TSQLResult *pResult; |
TSQLResult *pResult = NULL; |
880 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
881 |
stringstream myquery; |
stringstream myquery; |
882 |
// |
// |
883 |
if ( !IDRUN ) IDRUN = ID; |
if ( !IDRUN ) IDRUN = ID; |
899 |
if( Row != NULL ){ |
if( Row != NULL ){ |
900 |
ToTable = (TString)Row->GetField(0); |
ToTable = (TString)Row->GetField(0); |
901 |
} else { |
} else { |
902 |
|
delete pResult; |
903 |
return 1; |
return 1; |
904 |
}; |
}; |
905 |
}; |
}; |
906 |
|
|
907 |
|
if (pResult) |
908 |
|
delete pResult; |
909 |
|
if (Row) |
910 |
|
delete Row; |
911 |
// ---------------- |
// ---------------- |
912 |
myquery.str(""); |
myquery.str(""); |
913 |
myquery << " INSERT INTO "; |
myquery << " INSERT INTO "; |
988 |
// |
// |
989 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
990 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
991 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
992 |
// |
// |
993 |
// |
// |
994 |
myquery.str(""); |
myquery.str(""); |
997 |
// |
// |
998 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
999 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1000 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
1001 |
// |
// |
1002 |
return 0; |
return 0; |
1003 |
}; |
}; |
1085 |
// |
// |
1086 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1087 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1088 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
1089 |
// |
// |
1090 |
return 0; |
return 0; |
1091 |
|
|
1167 |
// |
// |
1168 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1169 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1170 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
1171 |
// |
// |
1172 |
return 0; |
return 0; |
1173 |
|
|
1184 |
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
1185 |
// MySQL variables |
// MySQL variables |
1186 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1187 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
|
int t; |
|
1188 |
int r; |
int r; |
1189 |
stringstream myquery; |
stringstream myquery; |
1190 |
// ---------------- |
// ---------------- |
1231 |
// |
// |
1232 |
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
1233 |
// |
// |
1234 |
if( !pResult->GetRowCount() ) return(-50); |
if( !pResult->GetRowCount() ){ |
1235 |
|
delete pResult; |
1236 |
|
if (Row) |
1237 |
|
delete Row; |
1238 |
|
return(-50); |
1239 |
|
} |
1240 |
// |
// |
1241 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1242 |
|
if (Row) |
1243 |
|
delete Row; |
1244 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1245 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1246 |
// Set_GL_RUN(Row); |
// Set_GL_RUN(Row); |
1247 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( int t = 0; t < pResult->GetFieldCount(); t++){ |
1248 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
1249 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
1250 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1278 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1279 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1280 |
}; |
}; |
1281 |
}; |
} |
1282 |
// delete pResult; |
|
1283 |
|
if (Row) |
1284 |
|
delete Row; |
1285 |
|
delete pResult; |
1286 |
return(0); |
return(0); |
1287 |
}; |
}; |
1288 |
|
|
1296 |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
1297 |
// MySQL variables |
// MySQL variables |
1298 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1299 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1300 |
int t; |
int t; |
1301 |
int r; |
int r; |
1302 |
stringstream myquery; |
stringstream myquery; |
1342 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1343 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1344 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1345 |
if(!pResult->GetRowCount())return(-50); |
if(!pResult->GetRowCount()){ |
1346 |
|
delete pResult; |
1347 |
|
if (Row) |
1348 |
|
delete Row; |
1349 |
|
return(-50); |
1350 |
|
} |
1351 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1352 |
|
if (Row) |
1353 |
|
delete Row; |
1354 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1355 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1356 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1387 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1388 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1389 |
}; |
}; |
1390 |
}; |
} |
1391 |
// delete pResult; |
|
1392 |
|
if (Row) |
1393 |
|
delete Row; |
1394 |
|
delete pResult; |
1395 |
return(0); |
return(0); |
1396 |
};// **************************************************** |
};// **************************************************** |
1397 |
|
|
1404 |
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
1405 |
// MySQL variables |
// MySQL variables |
1406 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1407 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1408 |
int t; |
int t; |
1409 |
int r; |
int r; |
1410 |
stringstream myquery; |
stringstream myquery; |
1421 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1422 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1423 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1424 |
if(!pResult->GetRowCount())return (-51); |
if(!pResult->GetRowCount()){ |
1425 |
|
delete pResult; |
1426 |
|
if (Row) |
1427 |
|
delete Row; |
1428 |
|
return (-51); |
1429 |
|
} |
1430 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1431 |
|
if (Row) |
1432 |
|
delete Row; |
1433 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1434 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1435 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1436 |
if(t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
if(t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1437 |
if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t)); |
if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t)); |
1438 |
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1439 |
if(t==3) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/'; |
if(t==3){ |
1440 |
|
PATH = TString(Row->GetField(t)) + '/'; |
1441 |
|
gSystem->ExpandPathName(PATH); |
1442 |
|
} |
1443 |
if(t==4) NAME = Row->GetField(t); |
if(t==4) NAME = Row->GetField(t); |
1444 |
}; |
} |
1445 |
}; |
} |
1446 |
|
if (Row) |
1447 |
|
delete Row; |
1448 |
delete pResult; |
delete pResult; |
1449 |
return 0; |
return 0; |
1450 |
}; |
}; |
1459 |
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){ |
1460 |
// MySQL variables |
// MySQL variables |
1461 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1462 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1463 |
int t; |
int t; |
1464 |
int r; |
int r; |
1465 |
stringstream myquery; |
stringstream myquery; |
1473 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1474 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1475 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1476 |
if(!pResult->GetRowCount())return (-53); |
if(!pResult->GetRowCount()){ |
1477 |
|
delete pResult; |
1478 |
|
return (-53); |
1479 |
|
} |
1480 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1481 |
|
if (Row) |
1482 |
|
delete Row; |
1483 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1484 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1485 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1500 |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1501 |
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1502 |
}; |
}; |
1503 |
}; |
} |
1504 |
|
if (Row) |
1505 |
|
delete Row; |
1506 |
delete pResult; |
delete pResult; |
1507 |
// |
// |
1508 |
// if ( TO_TIME < time ) return(51); |
// if ( TO_TIME < time ) return(51); |
1522 |
Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, 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){ |
1523 |
// MySQL variables |
// MySQL variables |
1524 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1525 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1526 |
int t; |
int t; |
1527 |
stringstream myquery; |
stringstream myquery; |
1528 |
uptime = 0; |
uptime = 0; |
1541 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1542 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1543 |
// |
// |
1544 |
if( !pResult->GetRowCount() ) return(-54); |
if (Row) |
1545 |
|
delete Row; |
1546 |
|
if( !pResult->GetRowCount() ){ |
1547 |
|
delete pResult; |
1548 |
|
return(-54); |
1549 |
|
} |
1550 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1551 |
if( Row == NULL ) return (-54); |
if( Row == NULL ){ |
1552 |
|
delete pResult; |
1553 |
|
return (-54); |
1554 |
|
} |
1555 |
// |
// |
1556 |
uptime = (UInt_t)atoll(Row->GetField(2)); |
uptime = (UInt_t)atoll(Row->GetField(2)); |
1557 |
// |
// |
1568 |
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; |
1569 |
myquery << " and FROM_TIME <= " << time; |
myquery << " and FROM_TIME <= " << time; |
1570 |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
1571 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1572 |
|
if(pResult) |
1573 |
|
delete pResult; |
1574 |
|
if(Row) |
1575 |
|
delete Row; |
1576 |
|
return -57; |
1577 |
|
} |
1578 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1579 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1580 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1581 |
// |
// |
1582 |
// if no results yet quit with error |
// if no results yet quit with error |
1583 |
// |
// |
1584 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ){ |
1585 |
|
delete pResult; |
1586 |
|
if(Row) |
1587 |
|
delete Row; |
1588 |
|
return (-54); |
1589 |
|
} |
1590 |
// |
// |
1591 |
|
if (Row) |
1592 |
|
delete Row; |
1593 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1594 |
// |
// |
1595 |
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
1603 |
myquery.str(""); |
myquery.str(""); |
1604 |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALO_CALIB where SECTION=" << section; |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALO_CALIB where SECTION=" << section; |
1605 |
myquery << " and VALIDATION=1 ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;"; |
myquery << " and VALIDATION=1 ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;"; |
1606 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1607 |
|
if(pResult) |
1608 |
|
delete pResult; |
1609 |
|
if(Row) |
1610 |
|
delete Row; |
1611 |
|
return -57; |
1612 |
|
} |
1613 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1614 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1615 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1616 |
// |
// |
1617 |
// if no results yet quit with error |
// if no results yet quit with error |
1618 |
// |
// |
1619 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ){ |
1620 |
|
if (Row) |
1621 |
|
delete Row; |
1622 |
|
delete pResult; |
1623 |
|
return (-54); |
1624 |
|
} |
1625 |
// |
// |
1626 |
|
if (Row) |
1627 |
|
delete Row; |
1628 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1629 |
// |
// |
1630 |
}; |
}; |
1631 |
// |
// |
1632 |
// store infos and exit |
// store infos and exit |
1633 |
// |
// |
1634 |
if( Row == NULL ) return (-54); |
if( Row == NULL ){ |
1635 |
|
delete pResult; |
1636 |
|
return (-54); |
1637 |
|
} |
1638 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1639 |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1640 |
if (t==1) FROM_TIME = myfromtime; |
if (t==1) FROM_TIME = myfromtime; |
1641 |
if (t==2) TO_TIME = mytotime; |
if (t==2) TO_TIME = mytotime; |
1642 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1643 |
}; |
} |
1644 |
pResult->Delete(); |
if (Row) |
1645 |
|
delete Row; |
1646 |
|
delete pResult; |
1647 |
return 0; |
return 0; |
1648 |
}; |
}; |
1649 |
|
|
1658 |
Int_t GL_CALOPULSE_CALIB::Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc){ |
Int_t GL_CALOPULSE_CALIB::Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc){ |
1659 |
// MySQL variables |
// MySQL variables |
1660 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1661 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1662 |
int t; |
int t; |
1663 |
stringstream myquery; |
stringstream myquery; |
1664 |
// |
// |
1676 |
// |
// |
1677 |
if( !pResult ) return(-54); |
if( !pResult ) return(-54); |
1678 |
// |
// |
1679 |
|
if (Row) |
1680 |
|
delete Row; |
1681 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1682 |
// |
// |
1683 |
if( !Row ) return (-54); |
if( !Row ){ |
1684 |
|
delete pResult; |
1685 |
|
return (-54); |
1686 |
|
} |
1687 |
// |
// |
1688 |
// store infos and exit |
// store infos and exit |
1689 |
// |
// |
1693 |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1694 |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1695 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1696 |
}; |
} |
1697 |
|
if (Row) |
1698 |
|
delete Row; |
1699 |
pResult->Delete(); |
pResult->Delete(); |
1700 |
return 0; |
return 0; |
1701 |
}; |
}; |
1711 |
Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){ |
Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){ |
1712 |
// MySQL variables |
// MySQL variables |
1713 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1714 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1715 |
int t; |
int t; |
1716 |
int r; |
int r; |
1717 |
stringstream myquery; |
stringstream myquery; |
1723 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1724 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1725 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1726 |
if(!pResult->GetRowCount())return (-55);//throw -55; |
if(!pResult->GetRowCount()){ |
1727 |
|
delete pResult; |
1728 |
|
return (-55);//throw -55; |
1729 |
|
} |
1730 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1731 |
|
if (Row) |
1732 |
|
delete Row; |
1733 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1734 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1735 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1739 |
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1740 |
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1741 |
}; |
}; |
1742 |
}; |
} |
1743 |
|
if (Row) |
1744 |
|
delete Row; |
1745 |
delete pResult; |
delete pResult; |
1746 |
// |
// |
1747 |
if(TO_TIME < time)return(51); |
if(TO_TIME < time)return(51); |
1760 |
// Bool_t debug = 1; |
// Bool_t debug = 1; |
1761 |
// MySQL variables |
// MySQL variables |
1762 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1763 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1764 |
int t; |
int t; |
1765 |
int r; |
int r; |
1766 |
stringstream myquery; |
stringstream myquery; |
1776 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1777 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1778 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1779 |
if(!pResult->GetRowCount())return (-52); |
if(!pResult->GetRowCount()){ |
1780 |
|
delete pResult; |
1781 |
|
return (-52); |
1782 |
|
} |
1783 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1784 |
|
if (Row) |
1785 |
|
delete Row; |
1786 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1787 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1788 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1789 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1790 |
if (t==1) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/';// put in fpath the path to that file |
if (t==1) { |
1791 |
if (t==2) NAME = Row->GetField(t); |
PATH = TString(Row->GetField(t)) + "/";// put in fpath the path to that file |
1792 |
if (t==3) DESCR = Row->GetField(t); |
gSystem->ExpandPathName(PATH); |
1793 |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
} |
1794 |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==2) NAME = Row->GetField(t); |
1795 |
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) DESCR = Row->GetField(t); |
1796 |
|
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1797 |
|
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1798 |
|
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
1799 |
}; |
}; |
1800 |
}; |
} |
1801 |
|
if (Row) |
1802 |
|
delete Row; |
1803 |
delete pResult; |
delete pResult; |
1804 |
// |
// |
1805 |
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
1835 |
UInt_t idtsy = 0; |
UInt_t idtsy = 0; |
1836 |
// |
// |
1837 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1838 |
TSQLRow *Row = 0; |
TSQLRow *Row = NULL; |
1839 |
stringstream myquery; |
stringstream myquery; |
1840 |
stringstream rname; |
stringstream rname; |
1841 |
// pcksList packetsNames; |
// pcksList packetsNames; |
1855 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1856 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1857 |
if( pResult->GetRowCount() ){ |
if( pResult->GetRowCount() ){ |
1858 |
|
if (Row) |
1859 |
|
delete Row; |
1860 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1861 |
if( Row ){ |
if( Row ){ |
1862 |
stringstream fname; |
stringstream fname; |
1863 |
fname.str(""); |
fname.str(""); |
1864 |
fname << gSystem->ExpandPathName(Row->GetField(0)) << "/" << Row->GetField(1); |
TString auxStr(Row->GetField(0)); |
1865 |
|
gSystem->ExpandPathName(auxStr); |
1866 |
|
fname << auxStr << "/" << Row->GetField(1); |
1867 |
rname << Row->GetField(1); |
rname << Row->GetField(1); |
1868 |
file = new TFile(fname.str().c_str(),"READ"); |
file = new TFile(fname.str().c_str(),"READ"); |
1869 |
idtsy = (UInt_t)atoll(Row->GetField(2)); |
idtsy = (UInt_t)atoll(Row->GetField(2)); |
1890 |
stringstream oss; |
stringstream oss; |
1891 |
// |
// |
1892 |
TString name=rname.str().c_str(); |
TString name=rname.str().c_str(); |
1893 |
UInt_t dworbit = 0; |
// UInt_t dworbit = 0; |
1894 |
// Int_t nlength = name.Length(); |
// Int_t nlength = name.Length(); |
1895 |
delete pResult; |
delete pResult; |
1896 |
|
if (Row){ |
1897 |
|
delete Row; |
1898 |
|
Row = NULL; |
1899 |
|
} |
1900 |
// |
// |
1901 |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
1902 |
// |
// |
1907 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
1908 |
Bool_t fndit = false; |
Bool_t fndit = false; |
1909 |
if ( pResult ){ |
if ( pResult ){ |
1910 |
|
if (Row) |
1911 |
|
delete Row; |
1912 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1913 |
if ( Row ){ |
if ( Row ){ |
1914 |
// |
// |
1920 |
oss.str(""); |
oss.str(""); |
1921 |
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 ID=" |
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 ID=" |
1922 |
<< Row->GetField(3) << ";"; |
<< Row->GetField(3) << ";"; |
1923 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1924 |
|
delete pResult; |
1925 |
|
delete Row; |
1926 |
|
return; |
1927 |
|
} |
1928 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1929 |
delete pResult; |
delete pResult; |
1930 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
1931 |
if ( pResult ){ |
if (pResult){ |
1932 |
Row = pResult->Next(); |
if (Row) |
1933 |
if ( Row ){ |
delete Row; |
1934 |
// printf(" GREAT! the DB structure is the new one! \n"); |
Row = pResult->Next(); |
1935 |
fndit = true; |
if ( Row ){ |
1936 |
dworbit = 1; |
// printf(" GREAT! the DB structure is the new one! \n"); |
1937 |
}; |
fndit = true; |
1938 |
|
// dworbit = 1; |
1939 |
|
}; |
1940 |
}; |
}; |
1941 |
}; |
}; |
1942 |
}; |
}; |
1955 |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
1956 |
// |
// |
1957 |
if ( file ) file->Close(); |
if ( file ) file->Close(); |
1958 |
|
if (Row) |
1959 |
|
delete Row; |
1960 |
delete pResult; |
delete pResult; |
1961 |
}; |
}; |
1962 |
|
|
1966 |
UInt_t idtsy = 0; |
UInt_t idtsy = 0; |
1967 |
// |
// |
1968 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1969 |
TSQLRow *Row = 0; |
TSQLRow *Row = NULL; |
1970 |
stringstream myquery; |
stringstream myquery; |
1971 |
stringstream rname; |
stringstream rname; |
1972 |
// pcksList packetsNames; |
// pcksList packetsNames; |
1986 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1987 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1988 |
if( pResult->GetRowCount() ){ |
if( pResult->GetRowCount() ){ |
1989 |
|
if (Row) |
1990 |
|
delete Row; |
1991 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1992 |
if( Row ){ |
if( Row ){ |
1993 |
stringstream fname; |
stringstream fname; |
1994 |
fname.str(""); |
fname.str(""); |
1995 |
fname << gSystem->ExpandPathName(Row->GetField(0)) << "/" << Row->GetField(1); |
TString auxString(Row->GetField(0)); |
1996 |
|
gSystem->ExpandPathName(auxString); |
1997 |
|
fname << auxString << "/" << Row->GetField(1); |
1998 |
rname << Row->GetField(1); |
rname << Row->GetField(1); |
1999 |
if ( usel0file ) file = new TFile(fname.str().c_str(),"READ"); |
if ( usel0file ) file = new TFile(fname.str().c_str(),"READ"); |
2000 |
idtsy = (UInt_t)atoll(Row->GetField(2)); |
idtsy = (UInt_t)atoll(Row->GetField(2)); |
2022 |
stringstream oss; |
stringstream oss; |
2023 |
// |
// |
2024 |
TString name=rname.str().c_str(); |
TString name=rname.str().c_str(); |
2025 |
UInt_t dworbit = 0; |
// UInt_t dworbit = 0; |
2026 |
// Int_t nlength = name.Length(); |
// Int_t nlength = name.Length(); |
2027 |
delete pResult; |
delete pResult; |
2028 |
|
if (Row){ |
2029 |
|
delete Row; |
2030 |
|
Row = NULL; |
2031 |
|
} |
2032 |
// |
// |
2033 |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
2034 |
// |
// |
2039 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
2040 |
Bool_t fndit = false; |
Bool_t fndit = false; |
2041 |
if ( pResult ){ |
if ( pResult ){ |
2042 |
|
if (Row) |
2043 |
|
delete Row; |
2044 |
Row = pResult->Next(); |
Row = pResult->Next(); |
2045 |
if ( Row ){ |
if ( Row ){ |
2046 |
// |
// |
2052 |
oss.str(""); |
oss.str(""); |
2053 |
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 ID=" |
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 ID=" |
2054 |
<< Row->GetField(3) << ";"; |
<< Row->GetField(3) << ";"; |
2055 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
2056 |
|
delete pResult; |
2057 |
|
delete Row; |
2058 |
|
return; |
2059 |
|
} |
2060 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
2061 |
delete pResult; |
delete pResult; |
2062 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
2063 |
if ( pResult ){ |
if (pResult){ |
2064 |
Row = pResult->Next(); |
if (Row) |
2065 |
if ( Row ){ |
delete Row; |
2066 |
// printf(" GREAT! the DB structure is the new one! \n"); |
Row = pResult->Next(); |
2067 |
fndit = true; |
if (Row){ |
2068 |
dworbit = 1; |
// printf(" GREAT! the DB structure is the new one! \n"); |
2069 |
}; |
fndit = true; |
2070 |
|
// dworbit = 1; |
2071 |
|
}; |
2072 |
}; |
}; |
2073 |
}; |
}; |
2074 |
}; |
}; |
2087 |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
2088 |
// |
// |
2089 |
if ( file ) file->Close(); |
if ( file ) file->Close(); |
2090 |
|
if (Row) |
2091 |
|
delete Row; |
2092 |
delete pResult; |
delete pResult; |
2093 |
}; |
}; |
2094 |
|
|
2359 |
// |
// |
2360 |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
2361 |
TSQLResult *result; |
TSQLResult *result; |
2362 |
TSQLRow *row; |
TSQLRow *row = NULL; |
2363 |
|
|
2364 |
// Set the right time_zone (otherwise horrible things will occur! :) |
// Set the right time_zone (otherwise horrible things will occur! :) |
2365 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
2366 |
dbc->Query("SET time_zone = '+0:00'"); |
delete dbc->Query("SET time_zone = '+0:00'"); |
2367 |
|
|
2368 |
// Do the query |
// Do the query |
2369 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
2370 |
result = dbc->Query(myquery.Data()); |
result = dbc->Query(myquery.Data()); |
2371 |
if(! result->GetRowCount() ) { |
if(! result->GetRowCount() ) { |
2372 |
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
2373 |
|
delete result; |
2374 |
return 1; |
return 1; |
2375 |
} |
} |
2376 |
|
|
2379 |
tle = GiveTle(row); |
tle = GiveTle(row); |
2380 |
|
|
2381 |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
2382 |
|
if (row) |
2383 |
|
delete row; |
2384 |
row = result->Next(); // second tle row |
row = result->Next(); // second tle row |
2385 |
if(row) |
if(row) |
2386 |
tleToTime = strtol(row->GetField(4), NULL, 10); |
tleToTime = strtol(row->GetField(4), NULL, 10); |
2389 |
tleToTime = UINT_MAX; |
tleToTime = UINT_MAX; |
2390 |
} |
} |
2391 |
|
|
2392 |
delete row; |
if (row) |
2393 |
|
delete row; |
2394 |
delete result; |
delete result; |
2395 |
|
|
2396 |
return 0; |
return 0; |