1 |
//============================================================================ |
//============================================================================ |
2 |
// $Id: PacketUser.cpp,v 1.8 2009/08/05 18:48:42 pam-fi Exp $ |
// $Id: PacketUser.cpp,v 1.9 2009/10/01 08:55:42 mocchiut Exp $ |
3 |
// Description : |
// Description : |
4 |
//============================================================================ |
//============================================================================ |
5 |
#include "PacketUser.h" |
#include "PacketUser.h" |
6 |
#include <sys/time.h> |
#include <sys/time.h> |
7 |
|
#include <iostream> |
8 |
|
|
9 |
namespace PamOffLineSW { |
namespace PamOffLineSW { |
10 |
extern LogUtil* mainLogUtil; |
extern LogUtil* mainLogUtil; |
21 |
extern unsigned int orbit_number; |
extern unsigned int orbit_number; |
22 |
extern unsigned long int time_Offset; |
extern unsigned long int time_Offset; |
23 |
extern bool tryMerge; |
extern bool tryMerge; |
24 |
|
extern bool candelete; // EM |
25 |
//marco_new_01 |
//marco_new_01 |
26 |
extern bool single_connection; |
extern bool single_connection; |
27 |
|
|
66 |
last_time_sync_info_prevvalue = 0; |
last_time_sync_info_prevvalue = 0; |
67 |
time_is_estimated = false; |
time_is_estimated = false; |
68 |
|
|
69 |
|
//EM |
70 |
|
recoverlimit = 400; |
71 |
|
idtorecover = new TArrayI(100); |
72 |
|
arsize = 0; |
73 |
|
|
74 |
real_time_init = 0; |
real_time_init = 0; |
75 |
real_time_last = 0; |
real_time_last = 0; |
76 |
bad_pkt = 0; |
bad_pkt = 0; |
257 |
//good_pkt_Calib=0; |
//good_pkt_Calib=0; |
258 |
|
|
259 |
//marco_NB: |
//marco_NB: |
260 |
//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 discontinuita` resetto come se mi trovassi in un nuovo download oppure uso i vecchi valori se esistono? |
261 |
|
|
262 |
obt_time_sync_prevvalue = obt_time_sync; |
if ( obt_time_sync ) obt_time_sync_prevvalue = obt_time_sync; // save the last NOT NULL obt_time_sync! EM |
263 |
last_time_sync_info_prevvalue = last_time_sync_info; |
if ( last_time_sync_info ) last_time_sync_info_prevvalue = last_time_sync_info; // save the last NOT NULL last_time_sync |
264 |
time_is_estimated = false; |
time_is_estimated = false; |
265 |
obt_time_sync = 0; |
obt_time_sync = 0; |
266 |
last_time_sync_info = 0; |
last_time_sync_info = 0; |
340 |
} |
} |
341 |
|
|
342 |
//I don't need to retrieve them again if they are good |
//I don't need to retrieve them again if they are good |
343 |
if ((obt_time_sync) || (last_time_sync_info)) |
// if ((obt_time_sync) || (last_time_sync_info)) |
344 |
return; |
// return; |
345 |
|
// no, do it, since there is a (small indeed) time drift due to different clock of PAMELA CPU and RESURS CPU... |
346 |
|
|
347 |
obt_time_sync = (((UINT32) packet[5 + offset] << 24) & 0xFF000000) + (((UINT32) packet[6 + offset] << 16) |
obt_time_sync = (((UINT32) packet[5 + offset] << 24) & 0xFF000000) + (((UINT32) packet[6 + offset] << 16) |
348 |
& 0x00FF0000) + (((UINT32) packet[7 + offset] << 8) & 0x0000FF00) + (((UINT32) packet[8 + offset]) & 0x000000FF); |
& 0x00FF0000) + (((UINT32) packet[7 + offset] << 8) & 0x0000FF00) + (((UINT32) packet[8 + offset]) & 0x000000FF); |
395 |
//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 |
396 |
void PacketUser::setReal_Time() { |
void PacketUser::setReal_Time() { |
397 |
|
|
398 |
if (!obt_time_sync && !last_time_sync_info && numPKTSaved > 1000) { |
if (!obt_time_sync && !last_time_sync_info && numPKTSaved > recoverlimit) { |
399 |
time_is_estimated = true; |
time_is_estimated = true; |
400 |
obt_time_sync = obt_time_sync_prevvalue; |
obt_time_sync = obt_time_sync_prevvalue; |
401 |
last_time_sync_info = last_time_sync_info_prevvalue; |
last_time_sync_info = last_time_sync_info_prevvalue; |
420 |
} |
} |
421 |
} |
} |
422 |
|
|
423 |
|
void PacketUser::setReal_TimeRECOVERY( |
424 |
|
unsigned long int & _real_time_init, |
425 |
|
unsigned long int & _real_time_last, |
426 |
|
unsigned long int _obt_init, |
427 |
|
unsigned long int _obt_last |
428 |
|
) { |
429 |
|
|
430 |
|
if (obt_time_sync || last_time_sync_info) { |
431 |
|
_real_time_init = (_obt_init / 1000 - obt_time_sync) + last_time_sync_info; |
432 |
|
//se obt si e' resettato |
433 |
|
if (_obt_last < _obt_init) { |
434 |
|
_real_time_last = (max_pkt_obt / 1000 + _obt_last / 1000 - obt_time_sync) + last_time_sync_info; |
435 |
|
stringstream oss; |
436 |
|
oss.str() = ""; |
437 |
|
oss << "obt_last(" << obt_last << ") < obt_init(" << obt_init |
438 |
|
<< "). It is due to Pamela Reset. Adding max_pkt_obt(" << max_pkt_obt |
439 |
|
<< ") to obt_last in order to compute real_time_last"; |
440 |
|
string msg = oss.str(); |
441 |
|
mainLogUtil->logWarning(msg); |
442 |
|
} |
443 |
|
else |
444 |
|
_real_time_last = (_obt_last / 1000 - obt_time_sync) + last_time_sync_info; |
445 |
|
_real_time_init += timeOffset; |
446 |
|
_real_time_last += timeOffset; |
447 |
|
} |
448 |
|
} |
449 |
|
|
450 |
|
|
451 |
//timeOffset |
//timeOffset |
452 |
//retrieve from table Table_GL_RESURS_OFFSET timeOffset |
//retrieve from table Table_GL_RESURS_OFFSET timeOffset |
453 |
unsigned long int PacketUser::retrieveTimeOffset(const char * table) { |
unsigned long int PacketUser::retrieveTimeOffset(const char * table) { |
532 |
setReal_Time(); |
setReal_Time(); |
533 |
FinishGroup(rootfilename); |
FinishGroup(rootfilename); |
534 |
mainLogUtil->logAll("######################### Closed the last group ############################"); |
mainLogUtil->logAll("######################### Closed the last group ############################"); |
535 |
|
// |
536 |
if (single_connection) { |
if (single_connection) { |
537 |
CloseDBConnection(); |
CloseDBConnection(); |
538 |
} |
} |
541 |
//Finish the old root file |
//Finish the old root file |
542 |
void PacketUser::FinishGroup(char * filename) { |
void PacketUser::FinishGroup(char * filename) { |
543 |
if (pRun) { |
if (pRun) { |
544 |
pRun->WriteFiles(); |
if ( !( !real_time_init && !real_time_last && numPKTSaved <= recoverlimit ) && candelete ) pRun->WriteFiles(); |
545 |
delete pRun; |
delete pRun; |
546 |
pRun = NULL; |
pRun = NULL; |
547 |
stringstream close; |
stringstream close; |
548 |
close.str() = ""; |
close.str() = ""; |
549 |
string msg; |
string msg; |
550 |
|
|
551 |
close << "######################### Close group in file: " << rootfilename << " ############################"; |
close << "TAG XX ######################### Close group in file: " << rootfilename << " ############################"; |
552 |
msg = close.str(); |
msg = close.str(); |
553 |
mainLogUtil->logInfo(msg); |
mainLogUtil->logInfo(msg); |
554 |
|
|
567 |
err << "NO PACKET SAVED in file: " << rootfilename << " The group is empty: you can remove this file."; |
err << "NO PACKET SAVED in file: " << rootfilename << " The group is empty: you can remove this file."; |
568 |
msg = err.str(); |
msg = err.str(); |
569 |
mainLogUtil->logError(msg); |
mainLogUtil->logError(msg); |
570 |
return; |
// return; |
571 |
} |
} |
572 |
|
|
573 |
//se non ho salvato nessun pacchetto buono |
//se non ho salvato nessun pacchetto buono |
585 |
OpenDBConnection(NULL);//Nota qui ho deciso di lockare tutte le tabelle |
OpenDBConnection(NULL);//Nota qui ho deciso di lockare tutte le tabelle |
586 |
} |
} |
587 |
|
|
588 |
|
|
589 |
//don't save in Table_ROOT_Good and don't search for ROOT files in the same temporal range |
//don't save in Table_ROOT_Good and don't search for ROOT files in the same temporal range |
590 |
if ((!real_time_init) && (!real_time_last)) { |
if ((!real_time_init) && (!real_time_last)) { |
591 |
//saved in another table for future study |
//saved in another table for future study |
607 |
mainLogUtil->logError(msg); |
mainLogUtil->logError(msg); |
608 |
} |
} |
609 |
|
|
|
if (!single_connection) { |
|
|
CloseDBConnection(); |
|
|
} |
|
610 |
|
|
611 |
return; |
|
612 |
|
if ( numPKTSaved > recoverlimit){ // EM |
613 |
|
// |
614 |
|
if ( obt_time_sync && last_time_sync_info ){ |
615 |
|
stringstream err; |
616 |
|
err.str() = ""; |
617 |
|
err << "(EM): -- RECOVERING WHEN NUMPACKET > "<< recoverlimit <<"!! -- file=<" << filename << ">. We have a previous time sync, immediate recovery!\n"; |
618 |
|
msg = err.str(); |
619 |
|
mainLogUtil->logInfo(msg); |
620 |
|
// |
621 |
|
setReal_TimeRECOVERY( |
622 |
|
real_time_init, |
623 |
|
real_time_last, |
624 |
|
obt_init, |
625 |
|
obt_last |
626 |
|
); |
627 |
|
// |
628 |
|
} else { |
629 |
|
stringstream err; |
630 |
|
err.str() = ""; |
631 |
|
err << "TAG(tassa): -- RECOVERING WHEN NUMPACKET > "<< recoverlimit <<"!! -- file=<" << filename << ">. Saving in a queue to try alfer to recover it!\n"; |
632 |
|
msg = err.str(); |
633 |
|
mainLogUtil->logInfo(msg); |
634 |
|
|
635 |
|
TString qu = Form("select ID_N from ROOT_TABLE_BAD order by INSERT_TIME desc limit 1;"); |
636 |
|
TSQLResult *result = sqlServer->Query(qu.Data()); |
637 |
|
TSQLRow *row = result->Next(); |
638 |
|
Int_t eid = -1; |
639 |
|
if ( row ) eid = (Int_t)atoi(row->GetField(0)); |
640 |
|
idtorecover->AddAt(eid,arsize); |
641 |
|
arsize++; |
642 |
|
if ( arsize > 100 ) idtorecover->Set(arsize); |
643 |
|
// dbinfo *app = new dbinfo( outDir, |
644 |
|
// filename, pkt_number_init, pkt_number_last, obt_init, obt_last, boot_number, timeOffset, bad_pkt, bad_pkt_EventReader, bad_pkt_CalibReader, |
645 |
|
// numPKTSaved, fni, time_is_estimated); |
646 |
|
// m_dbinfos.push_back(app); |
647 |
|
} |
648 |
|
|
649 |
|
CleanDisk(); |
650 |
|
if (!single_connection) { |
651 |
|
CloseDBConnection(); |
652 |
|
} |
653 |
|
return; |
654 |
|
|
655 |
|
}; |
656 |
} |
} |
657 |
|
|
658 |
//saves info in DB in table Table_ROOT_Good |
if ( real_time_init || real_time_last) { |
659 |
|
//saves info in DB in table Table_ROOT |
660 |
if (boot_number == 0) |
if (boot_number == 0) |
661 |
boot_number = boot_number_prevvalue; |
boot_number = boot_number_prevvalue; |
662 |
|
|
663 |
if (saveROOT_DB( |
if (saveROOT_DB( |
664 |
Table_ROOT_Good, |
Table_ROOT_Good, |
665 |
outDir, // here outDir is good, no expand EMI |
outDir, // here outDir is good, no expand EMI |
666 |
filename, pkt_number_init, pkt_number_last, obt_init, obt_last, obt_time_sync, last_time_sync_info, |
filename, pkt_number_init, pkt_number_last, obt_init, obt_last, obt_time_sync, last_time_sync_info, |
667 |
real_time_init, real_time_last, boot_number, timeOffset, bad_pkt, bad_pkt_EventReader, bad_pkt_CalibReader, |
real_time_init, real_time_last, boot_number, timeOffset, bad_pkt, bad_pkt_EventReader, bad_pkt_CalibReader, |
668 |
numPKTSaved, fni, time_is_estimated) == true) { |
numPKTSaved, fni, time_is_estimated) == true) { |
669 |
|
oss.str() = ""; |
670 |
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; |
671 |
msg = oss.str(); |
msg = oss.str(); |
672 |
mainLogUtil->logInfo(msg); |
mainLogUtil->logInfo(msg); |
673 |
|
|
674 |
if (tryMerge) { |
if (tryMerge) { |
675 |
merge_ROOTfiles(); |
merge_ROOTfiles(); |
676 |
} |
} |
677 |
} |
} else { |
678 |
else { |
oss.str() = ""; |
679 |
oss << "Problem storing information in DB regarding file: " << filename; |
oss << "Problem storing information in DB regarding file: " << filename; |
680 |
msg = oss.str(); |
msg = oss.str(); |
681 |
mainLogUtil->logError(msg); |
mainLogUtil->logError(msg); |
682 |
} |
} |
683 |
|
}; |
684 |
|
|
685 |
|
// if dbinfo is not empty than |
686 |
|
if ( obt_time_sync && last_time_sync_info && arsize > 0 ){ |
687 |
|
|
688 |
|
|
689 |
|
// if(!m_dbinfos.empty()){ |
690 |
|
// while(!m_dbinfos.empty()){ |
691 |
|
// dbinfo *app = m_dbinfos.back(); |
692 |
|
// m_dbinfos.pop_back(); |
693 |
|
Int_t ez=0; |
694 |
|
while ( ez < arsize ){ |
695 |
|
Int_t eid = idtorecover->At(ez); |
696 |
|
if ( eid > -1 ){ |
697 |
|
|
698 |
|
TString qu = Form("select FOLDER_NAME,FILE_NAME,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL,BOOT_NUMBER,TIME_OFFSET,BAD_PKT,BAD_PKT_READ,BAD_PKT_CALREAD,NUM_PKT_SAVED,INPUT_NAME,TIME_IS_ESTIMATED from ROOT_TABLE_BAD where ID_N=%i;",eid); |
699 |
|
TSQLResult *result = sqlServer->Query(qu.Data()); |
700 |
|
TSQLRow *row = result->Next(); |
701 |
|
|
702 |
|
TString efolder_name=""; |
703 |
|
TString efile_name=""; |
704 |
|
unsigned long int epkt_number_in=0ULL; |
705 |
|
unsigned long int epkt_number_fin=0ULL; |
706 |
|
unsigned long int eobt_in=0ULL; |
707 |
|
unsigned long int eobt_fin=0ULL; |
708 |
|
unsigned long int emboot_num=0ULL; |
709 |
|
unsigned long int etime_offset=0ULL; |
710 |
|
int ebad_pkt=0; |
711 |
|
int ebad_pkt_read=0; |
712 |
|
int ebad_pkt_CalRead=0; |
713 |
|
int enum_PKT_Saved=0; |
714 |
|
TString enome_input=""; |
715 |
|
bool e_time_is_estimated=false; |
716 |
|
|
717 |
|
if ( row ){ |
718 |
|
efolder_name = (TString)row->GetField(0); |
719 |
|
efile_name = (TString)row->GetField(1); |
720 |
|
epkt_number_in = (unsigned long int)atoll(row->GetField(2)); |
721 |
|
epkt_number_fin = (unsigned long int)atoll(row->GetField(3)); |
722 |
|
eobt_in = (unsigned long int)atoll(row->GetField(4)); |
723 |
|
eobt_fin = (unsigned long int)atoll(row->GetField(5)); |
724 |
|
emboot_num = (unsigned long int)atoll(row->GetField(6)); |
725 |
|
etime_offset = (unsigned long int)atoll(row->GetField(7)); |
726 |
|
ebad_pkt = (int)atoi(row->GetField(8)); |
727 |
|
ebad_pkt_read = (int)atoi(row->GetField(9)); |
728 |
|
ebad_pkt_CalRead = (int)atoi(row->GetField(10)); |
729 |
|
enum_PKT_Saved = (int)atoi(row->GetField(11)); |
730 |
|
enome_input = (TString)row->GetField(12); |
731 |
|
e_time_is_estimated = (bool)atoi(row->GetField(13)); |
732 |
|
}; |
733 |
|
delete result; |
734 |
|
|
735 |
|
setReal_TimeRECOVERY( |
736 |
|
real_time_init, |
737 |
|
real_time_last, |
738 |
|
eobt_in, |
739 |
|
eobt_fin |
740 |
|
); |
741 |
|
// |
742 |
|
|
743 |
|
if (saveROOT_DB( |
744 |
|
Table_ROOT_Good, |
745 |
|
efolder_name.Data(), |
746 |
|
efile_name.Data(), |
747 |
|
epkt_number_in, |
748 |
|
epkt_number_fin, eobt_in, eobt_fin, obt_time_sync, last_time_sync_info, |
749 |
|
real_time_init, real_time_last, emboot_num, etime_offset, ebad_pkt, ebad_pkt_read, ebad_pkt_CalRead, |
750 |
|
enum_PKT_Saved, enome_input.Data(), e_time_is_estimated) == true) { |
751 |
|
oss.str() = ""; |
752 |
|
oss << "\nTAG(tassa): RECOVERED!!!! Saved information regarding file: " << efile_name << " in table " << Table_ROOT_Good << " id= " << my_id; |
753 |
|
msg = oss.str(); |
754 |
|
mainLogUtil->logInfo(msg); |
755 |
|
/*merging we use global variable. we haveto set with current value*/ |
756 |
|
|
757 |
|
strcpy(outDir,efolder_name.Data() ); |
758 |
|
// outDir=efolder_name.Data(); |
759 |
|
strcpy(filename,efile_name.Data() ); |
760 |
|
// filename=efile_name.Data(); |
761 |
|
pkt_number_init=epkt_number_in; |
762 |
|
pkt_number_last=epkt_number_fin; |
763 |
|
obt_init=eobt_in; |
764 |
|
obt_last=eobt_fin; |
765 |
|
boot_number=emboot_num; |
766 |
|
timeOffset=etime_offset; |
767 |
|
bad_pkt=ebad_pkt; |
768 |
|
bad_pkt_EventReader=ebad_pkt_read; |
769 |
|
bad_pkt_CalibReader=ebad_pkt_CalRead; |
770 |
|
numPKTSaved=enum_PKT_Saved; |
771 |
|
strcpy(fni,enome_input.Data() ); |
772 |
|
// fni=enome_input.Data(); |
773 |
|
time_is_estimated=e_time_is_estimated; |
774 |
|
|
775 |
|
if (tryMerge) { |
776 |
|
merge_ROOTfiles(); |
777 |
|
} |
778 |
|
|
779 |
|
TString qu2 = Form("update ROOT_TABLE_BAD set ON_DISK='MVD' where ID_N=%i;",eid); |
780 |
|
sqlServer->Query(qu2.Data()); |
781 |
|
|
782 |
|
|
783 |
|
} |
784 |
|
else { |
785 |
|
oss.str() = ""; |
786 |
|
oss << "Problem storing information in DB regarding file: " << filename; |
787 |
|
msg = oss.str(); |
788 |
|
mainLogUtil->logError(msg); |
789 |
|
} |
790 |
|
|
791 |
|
|
792 |
|
}; |
793 |
|
ez++; |
794 |
|
} |
795 |
|
// |
796 |
|
idtorecover->Reset(); |
797 |
|
delete idtorecover; |
798 |
|
idtorecover = new TArrayI(100); |
799 |
|
arsize = 0; |
800 |
|
// delete app; |
801 |
|
} |
802 |
|
|
803 |
|
CleanDisk(); |
804 |
if (!single_connection) { |
if (!single_connection) { |
805 |
CloseDBConnection(); |
CloseDBConnection(); |
806 |
} |
} |
808 |
}//pRun |
}//pRun |
809 |
} |
} |
810 |
|
|
811 |
|
|
812 |
|
void PacketUser::CleanDisk(){ |
813 |
|
if ( !candelete ) return; |
814 |
|
// |
815 |
|
// delete small files present in root_table_bad from disk: |
816 |
|
// |
817 |
|
TString qu = Form("select FOLDER_NAME,FILE_NAME from ROOT_TABLE_BAD where NUM_PKT_SAVED<=%i and INSERTED_BY='%s' and ON_DISK='YES';",recoverlimit,tag_value); |
818 |
|
TSQLResult *result = sqlServer->Query(qu.Data()); |
819 |
|
TSQLRow *row = result->Next(); |
820 |
|
while ( row ){ |
821 |
|
TString tbdel = (TString)gSystem->ExpandPathName(row->GetField(0))+"/"+ (TString)row->GetField(1); |
822 |
|
stringstream err; |
823 |
|
string msg; |
824 |
|
err.str() = ""; |
825 |
|
err << " Deleting file " << tbdel.Data() << " from disk! "; |
826 |
|
msg = err.str(); |
827 |
|
mainLogUtil->logInfo(msg); |
828 |
|
gSystem->Unlink(tbdel.Data()); |
829 |
|
// printf("ciccio %s \n",tbdel.Data()); |
830 |
|
TString q2u = Form("UPDATE ROOT_TABLE_BAD set ON_DISK='NO' where FOLDER_NAME='%s' and FILE_NAME='%s' and NUM_PKT_SAVED<=%i and INSERTED_BY='%s';",row->GetField(0),row->GetField(1),recoverlimit,tag_value); |
831 |
|
// printf("pluto %s \n",q2u.Data()); |
832 |
|
sqlServer->Query(q2u.Data()); |
833 |
|
// printf("paperoga \n"); |
834 |
|
row=result->Next(); |
835 |
|
// |
836 |
|
}; |
837 |
|
|
838 |
|
} |
839 |
|
|
840 |
//save in Table_ROOT_Good or in Table_ROOT_Bad |
//save in Table_ROOT_Good or in Table_ROOT_Bad |
841 |
bool PacketUser::saveROOT_DB(const char* table_name, char* folder_name, char* file_name, |
bool PacketUser::saveROOT_DB(const char* table_name, const char* folder_name, const char* file_name, |
842 |
unsigned long int pkt_number_in, unsigned long int pkt_number_fin, unsigned long int obt_in, |
unsigned long int pkt_number_in, unsigned long int pkt_number_fin, unsigned long int obt_in, |
843 |
unsigned long int obt_fin, unsigned long int oT_sync, unsigned long int lT_sync_info, unsigned long int mtime_init, |
unsigned long int obt_fin, unsigned long int oT_sync, unsigned long int lT_sync_info, unsigned long int mtime_init, |
844 |
unsigned long int mtime_last, unsigned long int mboot_num, unsigned long int time_offset, int bad_pkt, |
unsigned long int mtime_last, unsigned long int mboot_num, unsigned long int time_offset, int bad_pkt, |
845 |
int bad_pkt_read, int bad_pkt_CalRead, int num_PKT_Saved, char* nome_input, bool _time_is_estimated) { |
int bad_pkt_read, int bad_pkt_CalRead, int num_PKT_Saved, const char* nome_input, bool _time_is_estimated) { |
846 |
//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? |
847 |
stringstream oss; |
stringstream oss; |
848 |
oss.str(""); |
oss.str(""); |
849 |
oss << "INSERT INTO " << table_name |
oss << "INSERT INTO " << table_name |
850 |
<< " (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)" |
<< " (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,INSERTED_BY)" |
851 |
<< " VALUES ('" << 0 << "','" << folder_name << "','" << file_name << "','" << pkt_number_in << "','" |
<< " VALUES ('" << 0 << "','" << folder_name << "','" << file_name << "','" << pkt_number_in << "','" |
852 |
<< pkt_number_fin << "','" << obt_in << "','" << obt_fin << "','" << oT_sync << "','" << lT_sync_info << "','" |
<< pkt_number_fin << "','" << obt_in << "','" << obt_fin << "','" << oT_sync << "','" << lT_sync_info << "','" |
853 |
<< mtime_init << "','" << mtime_last << "','" << mboot_num << "','" << time_offset << "','" << bad_pkt << "','" |
<< mtime_init << "','" << mtime_last << "','" << mboot_num << "','" << time_offset << "','" << bad_pkt << "','" |
854 |
<< bad_pkt_read << "','" << bad_pkt_CalRead << "','" << num_PKT_Saved << "','" << nome_input << "'," << "NULL," |
<< bad_pkt_read << "','" << bad_pkt_CalRead << "','" << num_PKT_Saved << "','" << nome_input << "'," << "NULL," |
855 |
<< _time_is_estimated << ");"; |
<< _time_is_estimated << ",'" << tag_value << "'" << ");"; |
856 |
string msg = oss.str(); |
string msg = oss.str(); |
857 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |
858 |
|
|
876 |
return false; |
return false; |
877 |
} |
} |
878 |
|
|
879 |
//the ID of the current ROOT file in table Table_ROOT_Good |
|
880 |
my_id = select_maxIDN_DB(table_name); |
if(!strcmp(table_name,Table_ROOT_Good)) { |
881 |
if (!boot_number) { |
//the ID of the current ROOT file in table Table_ROOT_Good |
882 |
if (id_to_recover_index < 1000) |
my_id = select_maxIDN_DB(table_name); |
883 |
id_to_recover[id_to_recover_index++] = my_id; |
if (!boot_number) { |
884 |
} |
if (id_to_recover_index < 1000) |
885 |
else if (boot_number && id_to_recover_index && !is_new_route) { |
id_to_recover[id_to_recover_index++] = my_id; |
886 |
recover_boot_number(); |
} |
887 |
|
else if (boot_number && id_to_recover_index && !is_new_route) { |
888 |
|
recover_boot_number(); |
889 |
|
} |
890 |
} |
} |
891 |
// cout<<"DBG: my_id = "<<my_id<<endl; |
// cout<<"DBG: my_id = "<<my_id<<endl; |
892 |
if (res) { |
if (res) { |
1251 |
<< " (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)" |
<< " (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)" |
1252 |
<< " VALUES ('" << 0 << "','" << root_id << "','" << pkt_number_in << "','" << pkt_number_fin << "','" << obt_in |
<< " VALUES ('" << 0 << "','" << root_id << "','" << pkt_number_in << "','" << pkt_number_fin << "','" << obt_in |
1253 |
<< "','" << obt_fin << "','" << mtime_init << "','" << mtime_last << "','" << mboot_num << "','" << percentage |
<< "','" << obt_fin << "','" << mtime_init << "','" << mtime_last << "','" << mboot_num << "','" << percentage |
1254 |
<< "'," << "NULL" << ",'" << tag_value << "'" << ")"; |
<< "'," << "NULL" << ",'" << tag_value << "'" << ");"; |
1255 |
|
|
1256 |
string msg = oss.str(); |
string msg = oss.str(); |
1257 |
mainLogUtil->logAll(msg); |
mainLogUtil->logAll(msg); |