|
|
|
1 |
//============================================================================ |
//============================================================================ |
2 |
// $Id: PacketUser.cpp,v 1.69 2008-10-27 10:41:27 messineo Exp $ |
// $Id: PacketUser.cpp,v 1.5 2008/12/22 16:50:10 mocchiut Exp $ |
3 |
// Description : |
// Description : |
4 |
//============================================================================ |
//============================================================================ |
5 |
#include "PacketUser.h" |
#include "PacketUser.h" |
35 |
//per tenere conto reset obt |
//per tenere conto reset obt |
36 |
extern unsigned long int max_pkt_obt; |
extern unsigned long int max_pkt_obt; |
37 |
|
|
38 |
|
#define TAGVALUELEN 4 |
39 |
|
extern char tag_value[TAGVALUELEN]; |
40 |
|
|
41 |
PacketUser PacketUser::instance; |
PacketUser PacketUser::instance; |
42 |
|
|
61 |
obt_last=0; |
obt_last=0; |
62 |
obt_time_sync=0; |
obt_time_sync=0; |
63 |
last_time_sync_info=0; |
last_time_sync_info=0; |
64 |
|
|
65 |
|
//(tassa) |
66 |
|
obt_time_sync_prevvalue=0; |
67 |
|
last_time_sync_info_prevvalue=0; |
68 |
|
time_is_estimated=false; |
69 |
|
|
70 |
|
|
71 |
real_time_init=0; |
real_time_init=0; |
72 |
real_time_last=0; |
real_time_last=0; |
73 |
bad_pkt=0; |
bad_pkt=0; |
83 |
// good_pkt_Calib=0; |
// good_pkt_Calib=0; |
84 |
my_id=0; |
my_id=0; |
85 |
boot_number=0; |
boot_number=0; |
86 |
|
//(tassa) |
87 |
|
boot_number_prevvalue=0; |
88 |
|
|
89 |
|
//(tassa) |
90 |
|
id_to_recover[1000]; |
91 |
|
id_to_recover_index=0; |
92 |
} |
} |
93 |
|
|
94 |
PacketUser::~PacketUser() |
PacketUser::~PacketUser() |
103 |
obt_last=0; |
obt_last=0; |
104 |
obt_time_sync = 0; |
obt_time_sync = 0; |
105 |
last_time_sync_info = 0; |
last_time_sync_info = 0; |
106 |
|
obt_time_sync_prevvalue=0; |
107 |
|
last_time_sync_info_prevvalue=0; |
108 |
|
time_is_estimated=false; |
109 |
|
|
110 |
real_time_init=0; |
real_time_init=0; |
111 |
real_time_last=0; |
real_time_last=0; |
112 |
bad_pkt=0; |
bad_pkt=0; |
115 |
// good_pkt_Calib=0; |
// good_pkt_Calib=0; |
116 |
my_id=0; |
my_id=0; |
117 |
boot_number=0; |
boot_number=0; |
118 |
|
boot_number_prevvalue=0; |
119 |
} |
} |
120 |
|
|
121 |
|
|
228 |
|
|
229 |
//marco_NB: |
//marco_NB: |
230 |
//ogni volta che trovo una discontinuit� resetto come se mi trovassi in un nuovo download oppure uso i vecchi valori se esistono? |
//ogni volta che trovo una discontinuit� resetto come se mi trovassi in un nuovo download oppure uso i vecchi valori se esistono? |
231 |
obt_time_sync=0; last_time_sync_info=0; boot_number=0; |
|
232 |
|
obt_time_sync_prevvalue=obt_time_sync; |
233 |
|
last_time_sync_info_prevvalue=last_time_sync_info; |
234 |
|
time_is_estimated=false; |
235 |
|
obt_time_sync=0; last_time_sync_info=0; |
236 |
|
boot_number_prevvalue=boot_number; |
237 |
|
boot_number=0; |
238 |
|
|
239 |
// NB: se ho discontinuita in genere non so a che download appartiene potrebbe proprio essere sbagliato tenere i vecchi valori |
// NB: se ho discontinuita in genere non so a che download appartiene potrebbe proprio essere sbagliato tenere i vecchi valori |
240 |
|
|
241 |
} |
} |
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; |
280 |
{ |
{ |
281 |
//reset |
//reset |
282 |
is_new_route=false; |
is_new_route=false; |
283 |
|
//(tassa) ci ho ripensato se stiamo in un secondo download non prendiamo i bootnumber e timesync del precedente! |
284 |
|
obt_time_sync_prevvalue=0;//obt_time_sync; |
285 |
|
last_time_sync_info_prevvalue=0;//last_time_sync_info; |
286 |
|
|
287 |
obt_time_sync=0; last_time_sync_info=0; |
obt_time_sync=0; last_time_sync_info=0; |
288 |
|
boot_number_prevvalue=0;//boot_number; |
289 |
boot_number=0; |
boot_number=0; |
290 |
|
time_is_estimated=false; |
291 |
if(time_Offset) |
if(time_Offset) |
292 |
timeOffset=time_Offset; |
timeOffset=time_Offset; |
293 |
else |
else |
365 |
//set the real time of the first packet and the last packet oif a group of packet if possible |
//set the real time of the first packet and the last packet oif a group of packet if possible |
366 |
void PacketUser::setReal_Time() |
void PacketUser::setReal_Time() |
367 |
{ |
{ |
368 |
if((obt_time_sync)||(last_time_sync_info)) |
|
369 |
|
if(!obt_time_sync && !last_time_sync_info && numPKTSaved > 1000 ) |
370 |
{ |
{ |
371 |
|
time_is_estimated=true; |
372 |
real_time_init=(obt_init/1000-obt_time_sync)+last_time_sync_info; |
obt_time_sync=obt_time_sync_prevvalue; |
373 |
|
last_time_sync_info=last_time_sync_info_prevvalue; |
374 |
|
} |
375 |
|
if(obt_time_sync || last_time_sync_info) |
376 |
|
{ |
377 |
|
real_time_init=(obt_init/1000-obt_time_sync)+last_time_sync_info; |
378 |
//se obt si e' resettato |
//se obt si e' resettato |
379 |
if(obt_last<obt_init) |
if(obt_last<obt_init) |
380 |
{ |
{ |
389 |
real_time_last=(obt_last/1000-obt_time_sync)+last_time_sync_info; |
real_time_last=(obt_last/1000-obt_time_sync)+last_time_sync_info; |
390 |
real_time_init+=timeOffset; |
real_time_init+=timeOffset; |
391 |
real_time_last+=timeOffset; |
real_time_last+=timeOffset; |
|
|
|
|
|
|
392 |
} |
} |
393 |
} |
} |
394 |
|
|
429 |
|
|
430 |
oss.str(""); |
oss.str(""); |
431 |
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 < " |
432 |
<< orbit_number << " order by FROM_ORBIT desc limit 1;"; |
<< orbit_number << " AND SPECIAL_FILE='' order by FROM_ORBIT desc limit 1;"; |
433 |
|
|
434 |
string msg2 = oss.str(); |
string msg2 = oss.str(); |
435 |
mainLogUtil->logAll(msg2); |
mainLogUtil->logAll(msg2); |
524 |
if((!real_time_init)&&(!real_time_last)) |
if((!real_time_init)&&(!real_time_last)) |
525 |
{ |
{ |
526 |
//saved in another table for future study |
//saved in another table for future study |
527 |
if(saveROOT_DB(Table_ROOT_Bad, outDir, |
if(saveROOT_DB(Table_ROOT_Bad, outDir,// here outDir is good, no expand EMI |
528 |
filename, |
filename, |
529 |
pkt_number_init, pkt_number_last, |
pkt_number_init, pkt_number_last, |
530 |
obt_init, obt_last, |
obt_init, obt_last, |
533 |
boot_number, |
boot_number, |
534 |
timeOffset, |
timeOffset, |
535 |
bad_pkt, bad_pkt_EventReader, bad_pkt_CalibReader, numPKTSaved, |
bad_pkt, bad_pkt_EventReader, bad_pkt_CalibReader, numPKTSaved, |
536 |
fni)==true) |
fni,time_is_estimated)==true) |
537 |
{ |
{ |
538 |
oss.str()=""; |
oss.str()=""; |
539 |
oss<<"Saved information regarding file: "<<filename<<" in table "<<Table_ROOT_Bad; |
oss<<"Saved information regarding file: "<<filename<<" in table "<<Table_ROOT_Bad; |
556 |
} |
} |
557 |
|
|
558 |
//saves info in DB in table Table_ROOT_Good |
//saves info in DB in table Table_ROOT_Good |
559 |
if(saveROOT_DB(Table_ROOT_Good, outDir, |
if(boot_number==0) |
560 |
|
boot_number=boot_number_prevvalue; |
561 |
|
|
562 |
|
if(saveROOT_DB(Table_ROOT_Good, outDir, // here outDir is good, no expand EMI |
563 |
filename, |
filename, |
564 |
pkt_number_init, pkt_number_last, |
pkt_number_init, pkt_number_last, |
565 |
obt_init, obt_last, |
obt_init, obt_last, |
568 |
boot_number, |
boot_number, |
569 |
timeOffset, |
timeOffset, |
570 |
bad_pkt, bad_pkt_EventReader, bad_pkt_CalibReader, numPKTSaved, |
bad_pkt, bad_pkt_EventReader, bad_pkt_CalibReader, numPKTSaved, |
571 |
fni)==true) |
fni,time_is_estimated)==true) |
572 |
{ |
{ |
573 |
oss<<"Saved information regarding file: "<<filename<<" in table "<<Table_ROOT_Good<< " id= "<<my_id; |
oss<<"Saved information regarding file: "<<filename<<" in table "<<Table_ROOT_Good<< " id= "<<my_id; |
574 |
msg = oss.str(); |
msg = oss.str(); |
601 |
unsigned long int mboot_num, |
unsigned long int mboot_num, |
602 |
unsigned long int time_offset, |
unsigned long int time_offset, |
603 |
int bad_pkt, int bad_pkt_read, int bad_pkt_CalRead, int num_PKT_Saved, |
int bad_pkt, int bad_pkt_read, int bad_pkt_CalRead, int num_PKT_Saved, |
604 |
char* nome_input){ |
char* nome_input, bool _time_is_estimated){ |
605 |
//TODO: forse far ritornare ID della cosa appena inserita se e' andatato tutto ok invece che true false? |
//TODO: forse far ritornare ID della cosa appena inserita se e' andatato tutto ok invece che true false? |
606 |
stringstream oss; |
stringstream oss; |
607 |
oss.str(""); |
oss.str(""); |
608 |
oss << "INSERT INTO "<< table_name <<" (ID_N, FOLDER_NAME, FILE_NAME, PKT_NUMBER_INIT, PKT_NUMBER_FINAL, PKT_OBT_INIT, PKT_OBT_FINAL, OBT_TIME_SYNC, LAST_TIME_SYNC_INFO, REAL_TIME_INIT, REAL_TIME_LAST, BOOT_NUMBER, TIME_OFFSET,BAD_PKT,BAD_PKT_READ,BAD_PKT_CALREAD,NUM_PKT_SAVED,INPUT_NAME,INSERT_TIME)" |
oss << "INSERT INTO "<< table_name <<" (ID_N, FOLDER_NAME, FILE_NAME, PKT_NUMBER_INIT, PKT_NUMBER_FINAL, PKT_OBT_INIT, PKT_OBT_FINAL, OBT_TIME_SYNC, LAST_TIME_SYNC_INFO, REAL_TIME_INIT, REAL_TIME_LAST, BOOT_NUMBER, TIME_OFFSET,BAD_PKT,BAD_PKT_READ,BAD_PKT_CALREAD,NUM_PKT_SAVED,INPUT_NAME,INSERT_TIME,TIME_IS_ESTIMATED)" |
609 |
<< " VALUES ('"<<0<< "','" <<folder_name<<"','" <<file_name<< "','" << pkt_number_in <<"','"<< pkt_number_fin << "','"<< obt_in <<"','"<< obt_fin<< "','" |
<< " VALUES ('"<<0<< "','" <<folder_name<<"','" <<file_name<< "','" << pkt_number_in <<"','"<< pkt_number_fin << "','"<< obt_in <<"','"<< obt_fin<< "','" |
610 |
<< oT_sync << "','" << lT_sync_info << "','" |
<< oT_sync << "','" << lT_sync_info << "','" |
611 |
<< mtime_init << "','" << mtime_last << "','" |
<< mtime_init << "','" << mtime_last << "','" |
613 |
<< time_offset << "','" |
<< time_offset << "','" |
614 |
<< bad_pkt <<"','" << bad_pkt_read <<"','"<< bad_pkt_CalRead <<"','"<< num_PKT_Saved<<"','" |
<< bad_pkt <<"','" << bad_pkt_read <<"','"<< bad_pkt_CalRead <<"','"<< num_PKT_Saved<<"','" |
615 |
<< nome_input <<"'," |
<< nome_input <<"'," |
616 |
<<"NULL"<< |
<<"NULL,"<<_time_is_estimated<< |
617 |
")"; |
");"; |
618 |
string msg = oss.str(); |
string msg = oss.str(); |
619 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
620 |
|
|
621 |
stringstream oss1; |
stringstream oss1; |
622 |
oss1.str()=""; |
oss1.str()=""; |
623 |
string msg1; |
string msg1; |
624 |
|
string query; |
625 |
|
|
626 |
TSQLResult* res=NULL; |
TSQLResult* res=NULL; |
627 |
res= sqlServer->Query(oss.str().c_str()); |
|
628 |
|
query=oss.str(); |
629 |
|
msg1="SaveROOT_DB query: "; |
630 |
|
msg1 += query; |
631 |
|
mainLogUtil->logInfo(msg1); |
632 |
|
|
633 |
|
res= sqlServer->Query(query.c_str()); |
634 |
if(!res) |
if(!res) |
635 |
{ |
{ |
636 |
oss1<<"DBError UNABLE to: "<<oss.str().c_str()<<endl; |
oss1<<"DBError UNABLE to: "<<oss.str().c_str()<<endl; |
641 |
|
|
642 |
//the ID of the current ROOT file in table Table_ROOT_Good |
//the ID of the current ROOT file in table Table_ROOT_Good |
643 |
my_id = select_maxIDN_DB(table_name); |
my_id = select_maxIDN_DB(table_name); |
644 |
|
if(!boot_number){ |
645 |
|
if(id_to_recover_index<1000) |
646 |
|
id_to_recover[id_to_recover_index++]=my_id; |
647 |
|
}else if (boot_number && id_to_recover_index && !is_new_route){ |
648 |
|
recover_boot_number(); |
649 |
|
} |
650 |
// cout<<"DBG: my_id = "<<my_id<<endl; |
// cout<<"DBG: my_id = "<<my_id<<endl; |
651 |
if(res){delete res; res = NULL;} |
if(res){delete res; res = NULL;} |
652 |
return true; |
return true; |
653 |
} |
} |
654 |
|
|
655 |
|
|
656 |
|
void PacketUser::recover_boot_number(){ |
657 |
|
string msg1; |
658 |
|
stringstream oss1; |
659 |
|
stringstream oss; |
660 |
|
oss.str(""); |
661 |
|
string query=""; |
662 |
|
TSQLResult* res=NULL; |
663 |
|
if(!boot_number || !id_to_recover_index) |
664 |
|
return; |
665 |
|
|
666 |
|
for (int i = 0; i<id_to_recover_index;i++){ |
667 |
|
oss.str(""); |
668 |
|
oss << "UPDATE "<< Table_ROOT_Good << " SET BOOT_NUMBER=" << boot_number << " WHERE ID_N=" << id_to_recover[i] << ";"; |
669 |
|
query = oss.str(); |
670 |
|
res= sqlServer->Query(query.c_str()); |
671 |
|
if(!res) |
672 |
|
{ |
673 |
|
oss1<<"DBError UNABLE to: "<<query.c_str()<<endl; |
674 |
|
msg1=oss1.str(); |
675 |
|
mainLogUtil->logError(msg1); |
676 |
|
return ; |
677 |
|
} |
678 |
|
} |
679 |
|
|
680 |
|
for (int i = 0; i<id_to_recover_index;i++){ |
681 |
|
oss.str(""); |
682 |
|
oss << "UPDATE " << Table_ROOT_Merging << " SET BOOT_NUMBER=" << boot_number << " WHERE ROOT_ID_N=" << id_to_recover[i] << ";"; |
683 |
|
query=oss.str(); |
684 |
|
res= sqlServer->Query(query.c_str()); |
685 |
|
if(!res) |
686 |
|
{ |
687 |
|
oss1<<"DBError UNABLE to: "<<query.c_str()<<endl; |
688 |
|
msg1=oss1.str(); |
689 |
|
mainLogUtil->logError(msg1); |
690 |
|
return ; |
691 |
|
} |
692 |
|
} |
693 |
|
|
694 |
|
id_to_recover_index=0; |
695 |
|
} |
696 |
|
|
697 |
|
|
698 |
|
|
699 |
/**********************************************************************************************/ |
/**********************************************************************************************/ |
700 |
/*###########################################################################################################*/ |
/*###########################################################################################################*/ |
701 |
/********************************** MERGING *************************************************/ |
/********************************** MERGING *************************************************/ |
702 |
/*###########################################################################################################*/ |
/*###########################################################################################################*/ |
703 |
// Merge ROOT files: find other ROOT files in the same temporal ranges |
// Merge ROT files: find other ROOT files in the same temporal ranges |
704 |
// it finds ROOT files that covers particular temporal range of interest and save this info in DB |
// it finds ROOT files that covers particular temporal range of interest and save this info in DB |
705 |
/**********************************************************************************************/ |
/**********************************************************************************************/ |
706 |
//try to merge current ROOT file with files in DB |
//try to merge current ROOT file with files in DB |
814 |
if(relaz == AFTER) |
if(relaz == AFTER) |
815 |
{ |
{ |
816 |
mainLogUtil->logInfo("Relaz:AFTER = Changing Init values of the Current ROOT file"); |
mainLogUtil->logInfo("Relaz:AFTER = Changing Init values of the Current ROOT file"); |
817 |
pkt_number_init = pkt_num_fin_db; |
pkt_number_init = (pkt_num_fin_db+1); |
818 |
obt_init = pkt_obt_fin_db; |
obt_init = pkt_obt_fin_db; |
819 |
real_time_init = time_fin_db; |
real_time_init = time_fin_db; |
820 |
log.str(""); |
log.str(""); |
826 |
else if(relaz == BEFORE) |
else if(relaz == BEFORE) |
827 |
{ |
{ |
828 |
mainLogUtil->logInfo("Relaz:BEFORE = Changing Last values of the Current ROOT file"); |
mainLogUtil->logInfo("Relaz:BEFORE = Changing Last values of the Current ROOT file"); |
829 |
pkt_number_last = pkt_num_in_db; |
pkt_number_last = (pkt_num_in_db-1); |
830 |
obt_last = pkt_obt_in_db; |
obt_last = pkt_obt_in_db; |
831 |
real_time_last = time_in_db; |
real_time_last = time_in_db; |
832 |
|
|
849 |
{ |
{ |
850 |
mainLogUtil->logInfo("Relaz:BIGGER = (1st part) Saving the first part of the Current ROOT file"); |
mainLogUtil->logInfo("Relaz:BIGGER = (1st part) Saving the first part of the Current ROOT file"); |
851 |
saveMergeROOT_DB(Table_ROOT_Merging, my_id, |
saveMergeROOT_DB(Table_ROOT_Merging, my_id, |
852 |
pkt_number_init, pkt_num_in_db, |
pkt_number_init, (pkt_num_in_db-1), |
853 |
obt_init, pkt_obt_in_db, |
obt_init, pkt_obt_in_db, |
854 |
real_time_init, time_in_db, |
real_time_init, time_in_db, |
855 |
boot_number, |
boot_number, |
856 |
percentage); |
percentage); |
857 |
|
|
858 |
mainLogUtil->logInfo("Relaz:BIGGER = (2nd part)Changing Init values of the Current ROOT file"); |
mainLogUtil->logInfo("Relaz:BIGGER = (2nd part)Changing Init values of the Current ROOT file"); |
859 |
pkt_number_init = pkt_num_fin_db; |
pkt_number_init = (pkt_num_fin_db+1); |
860 |
obt_init= pkt_obt_fin_db; |
obt_init= pkt_obt_fin_db; |
861 |
real_time_init= time_fin_db; |
real_time_init= time_fin_db; |
862 |
|
|
905 |
mainLogUtil->logInfo("Relaz:AFTER = Updating Last values of the DB ROOT file"); |
mainLogUtil->logInfo("Relaz:AFTER = Updating Last values of the DB ROOT file"); |
906 |
//marco_new:tolti tutti gli apici che qui non devono essere |
//marco_new:tolti tutti gli apici che qui non devono essere |
907 |
oss << "UPDATE "<< table_name |
oss << "UPDATE "<< table_name |
908 |
<< " SET PKT_NUMBER_FINAL ="<< pkt_number_init |
<< " SET PKT_NUMBER_FINAL ="<< (pkt_number_init - 1) |
909 |
<<", PKT_OBT_FINAL ="<< obt_init |
<<", PKT_OBT_FINAL ="<< obt_init |
910 |
<<", REAL_TIME_LAST ="<< real_time_init<<" WHERE ID_N ="<< ID_record <<";"; |
<<", REAL_TIME_LAST ="<< real_time_init<<" WHERE ID_N ="<< ID_record <<";"; |
911 |
|
|
913 |
else if(type_rel == BEFORE){ |
else if(type_rel == BEFORE){ |
914 |
mainLogUtil->logInfo("Relaz:BEFORE = Updating Init values of the DB ROOT file"); |
mainLogUtil->logInfo("Relaz:BEFORE = Updating Init values of the DB ROOT file"); |
915 |
oss << "UPDATE "<< table_name |
oss << "UPDATE "<< table_name |
916 |
<< " SET PKT_NUMBER_INIT ="<< pkt_number_last |
<< " SET PKT_NUMBER_INIT ="<< (pkt_number_last+1) |
917 |
<<", PKT_OBT_INIT ="<< obt_last |
<<", PKT_OBT_INIT ="<< obt_last |
918 |
<<", REAL_TIME_INIT ="<< real_time_last<<" WHERE ID_N ="<< ID_record<<";"; |
<<", REAL_TIME_INIT ="<< real_time_last<<" WHERE ID_N ="<< ID_record<<";"; |
919 |
} |
} |
922 |
mainLogUtil->logInfo("Relaz:SMALLER = (1st part) Updating Last values of the DB ROOT file"); |
mainLogUtil->logInfo("Relaz:SMALLER = (1st part) Updating Last values of the DB ROOT file"); |
923 |
|
|
924 |
oss << "UPDATE "<< table_name |
oss << "UPDATE "<< table_name |
925 |
<< " SET PKT_NUMBER_FINAL="<< pkt_number_init |
<< " SET PKT_NUMBER_FINAL="<< (pkt_number_init-1) |
926 |
<<", PKT_OBT_FINAL ="<< obt_init |
<<", PKT_OBT_FINAL ="<< obt_init |
927 |
<<", REAL_TIME_LAST ="<< real_time_init<<" WHERE ID_N ="<< ID_record<<";"; |
<<", REAL_TIME_LAST ="<< real_time_init<<" WHERE ID_N ="<< ID_record<<";"; |
928 |
|
|
929 |
mainLogUtil->logInfo("Relaz:SMALLER = (2nd part) Saving the second part of the DB ROOT file"); |
mainLogUtil->logInfo("Relaz:SMALLER = (2nd part) Saving the second part of the DB ROOT file"); |
930 |
|
|
931 |
saveMergeROOT_DB(table_name, root_id, |
saveMergeROOT_DB(table_name, root_id, |
932 |
pkt_number_last, pkt_number_fin, |
(pkt_number_last+1), pkt_number_fin, |
933 |
obt_last, obt_fin, |
obt_last, obt_fin, |
934 |
real_time_last, mtime_last, |
real_time_last, mtime_last, |
935 |
mboot_num, |
mboot_num, |
937 |
} |
} |
938 |
else if(type_rel == BIGGER){ |
else if(type_rel == BIGGER){ |
939 |
//marco_new: ok anche se coincidenti etc |
//marco_new: ok anche se coincidenti etc |
940 |
oss << "DELETE FROM "<< table_name <<" WHERE ID_N ="<< ID_record<<";"; |
// oss << "DELETE FROM "<< table_name <<" WHERE ID_N ="<< ID_record<<";"; // EMILIANO |
941 |
|
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 |
942 |
mainLogUtil->logInfo("Record deleted from merging table"); |
mainLogUtil->logInfo("Record deleted from merging table"); |
943 |
} |
} |
944 |
else |
else |
975 |
query.str(""); |
query.str(""); |
976 |
|
|
977 |
if(type_rel == AFTER) |
if(type_rel == AFTER) |
978 |
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 |
979 |
else if(type_rel == BEFORE) |
else if(type_rel == BEFORE) |
980 |
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 |
981 |
else if(type_rel == SMALLER) |
else if(type_rel == SMALLER) |
982 |
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 |
983 |
else if(type_rel == BIGGER) |
else if(type_rel == BIGGER) |
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 |
else |
986 |
return 0; |
return 0; |
987 |
|
|
1015 |
|
|
1016 |
stringstream oss; |
stringstream oss; |
1017 |
oss.str(""); |
oss.str(""); |
1018 |
oss << "INSERT INTO "<< table_name <<" (ID_N, ROOT_ID_N, PKT_NUMBER_INIT, PKT_NUMBER_FINAL, PKT_OBT_INIT, PKT_OBT_FINAL, REAL_TIME_INIT, REAL_TIME_LAST, BOOT_NUMBER, BAD_PKT_PERCENTAGE, INSERT_TIME)" |
oss << "INSERT INTO "<< table_name <<" (ID_N, ROOT_ID_N, PKT_NUMBER_INIT, PKT_NUMBER_FINAL, PKT_OBT_INIT, PKT_OBT_FINAL, REAL_TIME_INIT, REAL_TIME_LAST, BOOT_NUMBER, BAD_PKT_PERCENTAGE, INSERT_TIME, INSERTED_BY)" |
1019 |
<< " VALUES ('"<<0<< "','" <<root_id<<"','"<< pkt_number_in <<"','"<< pkt_number_fin << "','"<< obt_in <<"','"<< obt_fin<< "','" |
<< " VALUES ('"<<0<< "','" <<root_id<<"','"<< pkt_number_in <<"','"<< pkt_number_fin << "','"<< obt_in <<"','"<< obt_fin<< "','" |
1020 |
<< mtime_init << "','" << mtime_last << "','" |
<< mtime_init << "','" << mtime_last << "','" |
1021 |
<< mboot_num <<"','" |
<< mboot_num <<"','" |
1022 |
<< percentage <<"'," |
<< percentage <<"'," |
1023 |
<<"NULL"<< |
<<"NULL"<<",'" |
1024 |
")"; |
<< tag_value<<"'" |
1025 |
|
<< ")"; |
1026 |
|
|
1027 |
string msg = oss.str(); |
string msg = oss.str(); |
1028 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
1029 |
|
|
|
|
|
1030 |
//marco_new: controlla |
//marco_new: controlla |
1031 |
//marco_new: esci se sono arrivato a zero |
//marco_new: esci se sono arrivato a zero |
1032 |
// if(real_time_last==real_time_init){ |
// if(real_time_last==real_time_init){ |
1235 |
{ |
{ |
1236 |
char fno[80]=""; |
char fno[80]=""; |
1237 |
ofstream fout; |
ofstream fout; |
1238 |
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 |
1239 |
|
|
1240 |
if(append==true) |
if(append==true) |
1241 |
fout.open(fno, ios::binary | ios::app); |
fout.open(fno, ios::binary | ios::app); |
1255 |
ofstream fout; |
ofstream fout; |
1256 |
if(append==true) |
if(append==true) |
1257 |
{ |
{ |
1258 |
sprintf(fno,"%s/packets.pkt", outDir); |
sprintf(fno,"%s/packets.pkt", gSystem->ExpandPathName(outDir)); // EMI |
1259 |
fout.open(fno, ios::binary | ios::app); |
fout.open(fno, ios::binary | ios::app); |
1260 |
} |
} |
1261 |
else{ |
else{ |
1262 |
sprintf(fno,"%s/packet%d.pkt", outDir, numPKT ); |
sprintf(fno,"%s/packet%d.pkt", gSystem->ExpandPathName(outDir), numPKT ); // EMI |
1263 |
fout.open(fno, ios::binary); |
fout.open(fno, ios::binary); |
1264 |
} |
} |
1265 |
|
|