1 |
//============================================================================ |
//============================================================================ |
2 |
// $Id: PacketUser.cpp,v 1.69 2008-10-27 10:41:27 messineo Exp $ |
// $Id: PacketUser.cpp,v 1.6 2008/12/23 20:43:08 mocchiut Exp $ |
3 |
// Description : |
// Description : |
4 |
//============================================================================ |
//============================================================================ |
5 |
#include "PacketUser.h" |
#include "PacketUser.h" |
87 |
boot_number_prevvalue=0; |
boot_number_prevvalue=0; |
88 |
|
|
89 |
//(tassa) |
//(tassa) |
90 |
id_to_recover[1000]; |
// id_to_recover[1000]; // Emiliano: che si vuole fare con questa riga? cosi` non fa nulla... |
91 |
id_to_recover_index=0; |
id_to_recover_index=0; |
92 |
} |
} |
93 |
|
|
243 |
//starts a new root file |
//starts a new root file |
244 |
void PacketUser::StartGroup() |
void PacketUser::StartGroup() |
245 |
{ |
{ |
246 |
pRun = new PamelaRun(rootfilename, outDir, multiFile, compression); |
pRun = new PamelaRun(rootfilename, gSystem->ExpandPathName(outDir), multiFile, compression); // EMI |
247 |
strcat(rootfilename,".root"); |
strcat(rootfilename,".root"); |
248 |
reader->Init(pRun); |
reader->Init(pRun); |
249 |
stringstream oss; |
stringstream oss; |
325 |
|
|
326 |
stringstream oss; |
stringstream oss; |
327 |
oss.str()=""; |
oss.str()=""; |
328 |
oss<<"In download: "<<download<<" timeOffset: "<<timeOffset<<" obt_time_sync: "<<obt_time_sync<<" last_time_sync_info: "<<last_time_sync_info<<" using Packet Type: "<<type->GetName().c_str(); |
oss<<"In download: "<<download<<" timeOffset: "<<timeOffset<<" obt_time_sync: "<<obt_time_sync<<" last_time_sync_info: "<<last_time_sync_info<<" using Packet Type: "<<type->GetName(); |
329 |
|
// oss<<"In download: "<<download<<" timeOffset: "<<timeOffset<<" obt_time_sync: "<<obt_time_sync<<" last_time_sync_info: "<<last_time_sync_info<<" using Packet Type: "<<type->GetName().c_str(); |
330 |
string msg = oss.str(); |
string msg = oss.str(); |
331 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
332 |
} |
} |
352 |
*/ |
*/ |
353 |
stringstream oss; |
stringstream oss; |
354 |
oss.str()=""; |
oss.str()=""; |
355 |
oss<<"In download: "<<download<<" boot_number: "<<boot_number<<" using Packet Type: "<<type->GetName().c_str(); |
// oss<<"In download: "<<download<<" boot_number: "<<boot_number<<" using Packet Type: "<<type->GetName().c_str(); |
356 |
|
oss<<"In download: "<<download<<" boot_number: "<<boot_number<<" using Packet Type: "<<type->GetName(); |
357 |
string msg = oss.str(); |
string msg = oss.str(); |
358 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
359 |
return; |
return; |
431 |
|
|
432 |
oss.str(""); |
oss.str(""); |
433 |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE),ID FROM "<< table <<" WHERE FROM_ORBIT < " |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE),ID FROM "<< table <<" WHERE FROM_ORBIT < " |
434 |
<< orbit_number << " order by FROM_ORBIT desc limit 1;"; |
<< orbit_number << " AND SPECIAL_FILE='' order by FROM_ORBIT desc limit 1;"; |
435 |
|
|
436 |
string msg2 = oss.str(); |
string msg2 = oss.str(); |
437 |
mainLogUtil->logAll(msg2); |
mainLogUtil->logAll(msg2); |
526 |
if((!real_time_init)&&(!real_time_last)) |
if((!real_time_init)&&(!real_time_last)) |
527 |
{ |
{ |
528 |
//saved in another table for future study |
//saved in another table for future study |
529 |
if(saveROOT_DB(Table_ROOT_Bad, outDir, |
if(saveROOT_DB(Table_ROOT_Bad, outDir,// here outDir is good, no expand EMI |
530 |
filename, |
filename, |
531 |
pkt_number_init, pkt_number_last, |
pkt_number_init, pkt_number_last, |
532 |
obt_init, obt_last, |
obt_init, obt_last, |
561 |
if(boot_number==0) |
if(boot_number==0) |
562 |
boot_number=boot_number_prevvalue; |
boot_number=boot_number_prevvalue; |
563 |
|
|
564 |
if(saveROOT_DB(Table_ROOT_Good, outDir, |
if(saveROOT_DB(Table_ROOT_Good, outDir, // here outDir is good, no expand EMI |
565 |
filename, |
filename, |
566 |
pkt_number_init, pkt_number_last, |
pkt_number_init, pkt_number_last, |
567 |
obt_init, obt_last, |
obt_init, obt_last, |
616 |
<< bad_pkt <<"','" << bad_pkt_read <<"','"<< bad_pkt_CalRead <<"','"<< num_PKT_Saved<<"','" |
<< bad_pkt <<"','" << bad_pkt_read <<"','"<< bad_pkt_CalRead <<"','"<< num_PKT_Saved<<"','" |
617 |
<< nome_input <<"'," |
<< nome_input <<"'," |
618 |
<<"NULL,"<<_time_is_estimated<< |
<<"NULL,"<<_time_is_estimated<< |
619 |
")"; |
");"; |
620 |
string msg = oss.str(); |
string msg = oss.str(); |
621 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
622 |
|
|
666 |
return; |
return; |
667 |
|
|
668 |
for (int i = 0; i<id_to_recover_index;i++){ |
for (int i = 0; i<id_to_recover_index;i++){ |
669 |
oss << "UPDATE "<< Table_ROOT_Good << " SET BOOT_NUMBER=" << boot_number << " WHERE ID_N=" << id_to_recover[i]; |
oss.str(""); |
670 |
|
oss << "UPDATE "<< Table_ROOT_Good << " SET BOOT_NUMBER=" << boot_number << " WHERE ID_N=" << id_to_recover[i] << ";"; |
671 |
query = oss.str(); |
query = oss.str(); |
672 |
res= sqlServer->Query(query.c_str()); |
res= sqlServer->Query(query.c_str()); |
673 |
if(!res) |
if(!res) |
679 |
} |
} |
680 |
} |
} |
681 |
|
|
682 |
for (int i = 0; i<id_to_recover_index;i++){ |
for (int i = 0; i<id_to_recover_index;i++){ |
683 |
oss << "UPDATE " << Table_ROOT_Merging << " SET BOOT_NUMBER=" << boot_number << " WHERE ROOT_ID_N=" << id_to_recover[i]; |
oss.str(""); |
684 |
query=oss.str(); |
oss << "UPDATE " << Table_ROOT_Merging << " SET BOOT_NUMBER=" << boot_number << " WHERE ROOT_ID_N=" << id_to_recover[i] << ";"; |
685 |
res= sqlServer->Query(query.c_str()); |
query=oss.str(); |
686 |
if(!res) |
res= sqlServer->Query(query.c_str()); |
687 |
{ |
if(!res) |
688 |
|
{ |
689 |
oss1<<"DBError UNABLE to: "<<query.c_str()<<endl; |
oss1<<"DBError UNABLE to: "<<query.c_str()<<endl; |
690 |
msg1=oss1.str(); |
msg1=oss1.str(); |
691 |
mainLogUtil->logError(msg1); |
mainLogUtil->logError(msg1); |
939 |
} |
} |
940 |
else if(type_rel == BIGGER){ |
else if(type_rel == BIGGER){ |
941 |
//marco_new: ok anche se coincidenti etc |
//marco_new: ok anche se coincidenti etc |
942 |
oss << "DELETE FROM "<< table_name <<" WHERE ID_N ="<< ID_record<<";"; |
// oss << "DELETE FROM "<< table_name <<" WHERE ID_N ="<< ID_record<<";"; // EMILIANO |
943 |
|
oss << "UPDATE "<< table_name <<" SET GOOD=0 WHERE ID_N ="<< ID_record<<";"; // EMILIANO DO NOT DELETE FROM ROOT_TABLE_MERGING JUST SET GOOD FLAG TO ZERO |
944 |
mainLogUtil->logInfo("Record deleted from merging table"); |
mainLogUtil->logInfo("Record deleted from merging table"); |
945 |
} |
} |
946 |
else |
else |
977 |
query.str(""); |
query.str(""); |
978 |
|
|
979 |
if(type_rel == AFTER) |
if(type_rel == AFTER) |
980 |
query<<"select * from "<<table_name<<" where REAL_TIME_LAST > "<< mtime_init <<" and REAL_TIME_LAST <= "<< mtime_last <<" and REAL_TIME_INIT < "<< mtime_init; |
query<<"select * from "<<table_name<<" where GOOD=1 and REAL_TIME_LAST > "<< mtime_init <<" and REAL_TIME_LAST <= "<< mtime_last <<" and REAL_TIME_INIT < "<< mtime_init; // EMI |
981 |
else if(type_rel == BEFORE) |
else if(type_rel == BEFORE) |
982 |
query<<"select * from "<<table_name<<" where REAL_TIME_INIT >= "<< mtime_init <<" and REAL_TIME_INIT < "<< mtime_last <<" and REAL_TIME_LAST > "<< mtime_last; |
query<<"select * from "<<table_name<<" where GOOD=1 and REAL_TIME_INIT >= "<< mtime_init <<" and REAL_TIME_INIT < "<< mtime_last <<" and REAL_TIME_LAST > "<< mtime_last; // EMI |
983 |
else if(type_rel == SMALLER) |
else if(type_rel == SMALLER) |
984 |
query<<"select * from "<<table_name<<" where REAL_TIME_INIT < "<< mtime_init <<" and REAL_TIME_LAST > "<< mtime_last; |
query<<"select * from "<<table_name<<" where GOOD=1 and REAL_TIME_INIT < "<< mtime_init <<" and REAL_TIME_LAST > "<< mtime_last; // EMI |
985 |
else if(type_rel == BIGGER) |
else if(type_rel == BIGGER) |
986 |
query<<"select * from "<<table_name<<" where REAL_TIME_INIT >= "<< mtime_init <<" and REAL_TIME_LAST <= "<< mtime_last; |
query<<"select * from "<<table_name<<" where GOOD=1 and REAL_TIME_INIT >= "<< mtime_init <<" and REAL_TIME_LAST <= "<< mtime_last; // EMI |
987 |
else |
else |
988 |
return 0; |
return 0; |
989 |
|
|
1237 |
{ |
{ |
1238 |
char fno[80]=""; |
char fno[80]=""; |
1239 |
ofstream fout; |
ofstream fout; |
1240 |
sprintf(fno,"%s/pkt%d_of_%s.pkt", outDir, numPKTSaved, nomefile); |
sprintf(fno,"%s/pkt%d_of_%s.pkt", gSystem->ExpandPathName(outDir), numPKTSaved, nomefile); // EMI |
1241 |
|
|
1242 |
if(append==true) |
if(append==true) |
1243 |
fout.open(fno, ios::binary | ios::app); |
fout.open(fno, ios::binary | ios::app); |
1257 |
ofstream fout; |
ofstream fout; |
1258 |
if(append==true) |
if(append==true) |
1259 |
{ |
{ |
1260 |
sprintf(fno,"%s/packets.pkt", outDir); |
sprintf(fno,"%s/packets.pkt", gSystem->ExpandPathName(outDir)); // EMI |
1261 |
fout.open(fno, ios::binary | ios::app); |
fout.open(fno, ios::binary | ios::app); |
1262 |
} |
} |
1263 |
else{ |
else{ |
1264 |
sprintf(fno,"%s/packet%d.pkt", outDir, numPKT ); |
sprintf(fno,"%s/packet%d.pkt", gSystem->ExpandPathName(outDir), numPKT ); // EMI |
1265 |
fout.open(fno, ios::binary); |
fout.open(fno, ios::binary); |
1266 |
} |
} |
1267 |
|
|