/[PAMELA software]/chewbacca/PamOffLineSW/PamOffLineSW_Main.cpp
ViewVC logotype

Diff of /chewbacca/PamOffLineSW/PamOffLineSW_Main.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by mocchiut, Tue Sep 23 07:20:14 2008 UTC revision 1.5 by mocchiut, Thu Dec 18 14:47:02 2008 UTC
# Line 1  Line 1 
1  //============================================================================  //============================================================================
2  // $Id: PamOffLineSW_Main.cpp,v 1.51 2008-09-05 14:33:48 messineo Exp $  // $Id: PamOffLineSW_Main.cpp,v 1.4 2008/12/18 12:58:37 mocchiut Exp $
3  // Description : Pamela Off-Line Software  // Description : Pamela Off-Line Software
4  //============================================================================  //============================================================================
5    
# Line 42  short int CRC_Cadre_Check(char dataVRL[] Line 42  short int CRC_Cadre_Check(char dataVRL[]
42    
43  //global variables  //global variables
44  bool simulated_data = false;  bool simulated_data = false;
45  bool do_vrl_check = false;  //bool do_vrl_check = false; //EMI
46    bool do_vrl_check = true; //EMI
47    
48  char*  db_host = "";  char*  db_host = "";
49  int        db_port = 0;  int        db_port = 0;
50  char*  db_name = "";  char*  db_name = "";
51  char conn[100]="";  char conn[100]="";
 //char* connection = NULL;        
 //char*  db_user = "yoda_user";  
 //char*  db_pwd  = "yoda_pwd";  
52    
53  LogUtil::logLevel loglevel=LogUtil::LOGERROR;  LogUtil::logLevel loglevel=LogUtil::LOGERROR;
54  char* logfilename = "pamofflinesw.log";  char* logfilename = "chewbacca.log";
55  //current route  //current route
56  int route = 999;  int route = 999;
57  //previous route  //previous route
# Line 79  namespace PamOffLineSW Line 77  namespace PamOffLineSW
77  //      char *outDir = ".";  //      char *outDir = ".";
78          char *outDir = "";          char *outDir = "";
79    
80          char * nome_output="yoda";    //    char * nome_output="chewbacca"; //EMI
81      bool multiFile = 0;          char * nome_output="L0PAM";//EMI
82          unsigned long int step_pkt_number=0;          bool multiFile = 0;    
83          unsigned long int step_pkt_obt=0;    //    unsigned long int step_pkt_number=0; // EMI
84            unsigned long int step_pkt_number=3000;
85      //    unsigned long int step_pkt_obt=0; // EMI
86            unsigned long int step_pkt_obt=7200000; // EMI
87          LogUtil* mainLogUtil = NULL;          LogUtil* mainLogUtil = NULL;
88          TSQLServer* sqlServer = NULL;          TSQLServer* sqlServer = NULL;
89          unsigned long int max_pkt_number =   16777215;//biggest value before reset          unsigned long int max_pkt_number =   16777215;//biggest value before reset
90          unsigned long int max_pkt_obt    = 4294967295u;//biggest value before reset          unsigned long int max_pkt_obt    = 4294967295u;//biggest value before reset
91    
92          bool is_new_route = false;          //    bool is_new_route = false;      // EMI
93            bool is_new_route = true;       // EMI ??????????? VA BENE? SECONDO ME SI`
94          unsigned int download = 0;          unsigned int download = 0;
95          unsigned int orbit_number=0;          unsigned int orbit_number=0;
96          unsigned int mmm_number = 0;//session_number          unsigned int mmm_number = 0;//session_number
97          unsigned long int time_Offset=0;          unsigned long int time_Offset=0;
98          bool tryMerge = false;    //    bool tryMerge = false;
99            bool tryMerge = true;
100                                    
101          bool do_cont_check=true;//if do_cont_check is false do not use a DB ...          bool do_cont_check=true;//if do_cont_check is false do not use a DB ...
102    
103          //TODO: now it is unused          //TODO: now it is unused
104          unsigned long int delta_Time=0;//in seconds          unsigned long int delta_Time=0;//in seconds
105    #define TAGVALUELEN 4
106      char tag_value[TAGVALUELEN];
107  }  }
108    
109  // main:  // main:
# Line 161  void readOptions(int argc, char *argv[]) Line 166  void readOptions(int argc, char *argv[])
166          cout << "\t  (-help | --help | -h) print this help and exit \n";          cout << "\t  (-help | --help | -h) print this help and exit \n";
167          cout << "\t -simu       if the input file contains simulated data instead of real data\n";          cout << "\t -simu       if the input file contains simulated data instead of real data\n";
168          cout << "\t -vrl    if you want to perform the vrl check\n";          cout << "\t -vrl    if you want to perform the vrl check\n";
169          cout << "\t -filelog     set the log filename. [default: pamofflinesw.log]\n";          cout << "\t -filelog     set the log filename. [default: chewbacca.log]\n";
170          cout << "\t -loglevel     set the log level. Values: [0,3] (error,warning,info,all) [default:0]\n";          cout << "\t -loglevel     set the log level. Values: [0,3] (error,warning,info,all) [default:0]\n";
171          cout << "\t -c      set the compression level for the generated ROOT file(s). Values: [0,9] [default = 3]\n";          cout << "\t -c      set the compression level for the generated ROOT file(s). Values: [0,9] [default = 3]\n";
172          cout << "\t -root_name      set the root-name for the generated ROOT file(s). [default = yoda]\n";          cout << "\t -root_name      set the root-name for the generated ROOT file(s). [default = chewbacca]\n";
173          cout << "\t -outDir      set the output directory for the generated root file(s). [default = .]\n";          cout << "\t -outDir      set the output directory for the generated root file(s). [default = .]\n";
174          cout << "\t -delta_counter     set the allowed difference in the Packet Counter between two continuos packets. If 0 all packets are considered continuos.  [default = 0]\n";          cout << "\t -delta_counter     set the allowed difference in the Packet Counter between two continuos packets. If 0 all packets are considered continuos.  [default = 0]\n";
175          cout << "\t -delta_obt     set the allowed difference (ms) in the Packet Orbital Time between two continuos packets. If 0 all packets are considered continuos.  [default = 0]\n";          cout << "\t -delta_obt     set the allowed difference (ms) in the Packet Orbital Time between two continuos packets. If 0 all packets are considered continuos.  [default = 0]\n";
176          cout << "\t -db_host   set the host-name of the DataBase.  [default = localhost]\n";          cout << "\t -db_host   set the host-name of the DataBase.  [default = localhost]\n";
177          cout << "\t -db_port  set the port of the DataBase.  [default = 3306]\n";          cout << "\t -db_port  set the port of the DataBase.  [default = 3306]\n";
178          cout << "\t -db_name  set the name of the DataBase.  [default = yoda_db]\n";          cout << "\t -db_name  set the name of the DataBase.  [default = chewbacca_db]\n";
179          cout << "\t -db_user  set the user of the DataBase.  [default = yoda_user]\n";          cout << "\t -db_user  set the user of the DataBase.  [default = chewbacca_user]\n";
180          cout << "\t -db_pwd  set the user of the DataBase.  [default = yoda_pwd]\n";          cout << "\t -db_pwd  set the user of the DataBase.  [default = chewbacca_pwd]\n";
181          cout << "\t -max_pkt_number  Maximum value for  Packet Counter, after this value it is resetted.  [default = 2^24 - 1]\n";          cout << "\t -max_pkt_number  Maximum value for  Packet Counter, after this value it is resetted.  [default = 2^24 - 1]\n";
182          cout << "\t -max_pkt_obt  Maximum value for  Packet OBT, after this value it is resetted.  [default = 2^32 - 1]\n";                cout << "\t -max_pkt_obt  Maximum value for  Packet OBT, after this value it is resetted.  [default = 2^32 - 1]\n";      
183          cout << "\t -orbit_number  Value of the orbital number. If 0 this is retrieved from the input file name.  [default = 0]\n";                  cout << "\t -orbit_number  Value of the orbital number. If 0 this is retrieved from the input file name.  [default = 0]\n";        
184          cout << "\t -session_number  Value of the session number. If 0 this is retrieved from the input file name.  [default = 0]\n";                          cout << "\t -session_number  Value of the session number. If 0 this is retrieved from the input file name.  [default = 0]\n";                
185          cout << "\t -time_Offset  Value of the timeOffset. If 0 this is retrieved using the orbital number.  [default = 0]\n";          cout << "\t -time_Offset  Value of the timeOffset. If 0 this is retrieved using the orbital number.  [default = 0]\n";
186          cout << "\t -tryMerge if you want to try to Merge ROOT files\n";          cout << "\t -tryMerge if you want to try to Merge ROOT files\n";
187                  //marco_new_01          cout << "\t -dontMerge if you don not want to try to Merge ROOT files\n";
188            //marco_new_01
189          cout << "\t -single_connection if you want to open only one connection to DB.\n";          cout << "\t -single_connection if you want to open only one connection to DB.\n";
190                          //       cout << "\t -delta_Time  set the allowed difference (seconds) in the Real Time between two root file. [default = 0]\n";          cout << "\t -tag if you want add the 'The owner of the file' - the tag lenght is 4 char\n";
191            //       cout << "\t -delta_Time  set the allowed difference (seconds) in the Real Time between two root file. [default = 0]\n";
192          //cout << "\t -multi  generate multiple root files \n";          //cout << "\t -multi  generate multiple root files \n";
193          exit(1);          exit(1);
194    }    }
# Line 216  void readOptions(int argc, char *argv[]) Line 222  void readOptions(int argc, char *argv[])
222                          tryMerge = true;                          tryMerge = true;
223                  continue;                  continue;
224              }              }
225    
226              if (!strcmp(argv[i], "-dontMerge")) // EMI
227                {
228                            tryMerge = false;
229                    continue;
230                }
231                        
232            if (!strcmp(argv[i], "-time_Offset")){            if (!strcmp(argv[i], "-time_Offset")){
233                          if (++i >= argc){                          if (++i >= argc){
# Line 304  void readOptions(int argc, char *argv[]) Line 316  void readOptions(int argc, char *argv[])
316            continue;            continue;
317        }        }
318                
319          if (!strcmp(argv[i], "-no-vrl")) //EMI
320            {
321              do_vrl_check = false;
322          }
323        if (!strcmp(argv[i], "-vrl"))        if (!strcmp(argv[i], "-vrl"))
324        {        {
325            do_vrl_check = true;            do_vrl_check = true;
# Line 367  void readOptions(int argc, char *argv[]) Line 383  void readOptions(int argc, char *argv[])
383                   exit(1);                   exit(1);
384               }               }
385               DIR* tempdir;               DIR* tempdir;
386               if ((tempdir = opendir(argv[i])) != 0) {               if ((tempdir = opendir(gSystem->ExpandPathName(argv[i]))) != 0) { // EMI
387                   outDir = argv[i];                   outDir = argv[i];
388                   closedir(tempdir);                   closedir(tempdir);
389               } else {               } else {
# Line 491  void readOptions(int argc, char *argv[]) Line 507  void readOptions(int argc, char *argv[])
507                               db_pwd = argv[i];                               db_pwd = argv[i];
508                                continue;                                continue;
509                            }                            }
510                   if (!strcmp(argv[i], "-tag")){
511                                  if (++i >= argc){
512                                      cerr << "-tag needs arguments. \n";
513                                      cout << "Try '-help' for more information. \n";
514                                      exit(1);
515                                  }
516                                  int len=strlen(argv[i])>TAGVALUELEN?TAGVALUELEN:strlen(argv[i]);
517                                  strncpy(tag_value,argv[i],len);
518                                  tag_value[len]=0;
519                                  continue;
520                              }
521                      
522                  //TODO: check that multiFile is always 0                  //TODO: check that multiFile is always 0
523         //       if (!strcmp(argv[i], "-multi")){multiFile = 1; cout<<"debug: multi= "<<multiFile<<endl;}                 //       if (!strcmp(argv[i], "-multi")){multiFile = 1; cout<<"debug: multi= "<<multiFile<<endl;}        
524     }     }
# Line 590  void DB_config() Line 617  void DB_config()
617                                                    
618                          if (!strcmp(db_name,""))                          if (!strcmp(db_name,""))
619                          {                          {
620                                  db_name="yoda_db";                                                db_name="chewbacca_db";        
621                          }                                                                                        }                                                              
622                          sprintf(conn,"mysql://%s:%d/%s",db_host,db_port,db_name);                                sprintf(conn,"mysql://%s:%d/%s",db_host,db_port,db_name);      
623                          connection=conn;                                                  connection=conn;                        
# Line 610  void DB_config() Line 637  void DB_config()
637                  }                  }
638                  else                  else
639                  {                  {
640                          db_user="yoda_user";                          db_user="chewbacca_user";
641                  }                  }
642                    
643          }          }
# Line 624  void DB_config() Line 651  void DB_config()
651                  }                  }
652                  else                  else
653                  {                  {
654                          db_pwd="yoda_pwd";                          db_pwd="chewbacca_pwd";
655                  }                        }      
656          }          }
657                    
# Line 637  void firstLog(){ Line 664  void firstLog(){
664          string msg = "Input file: " + (string)fni;          string msg = "Input file: " + (string)fni;
665          mainLogUtil->logAlways(msg);          mainLogUtil->logAlways(msg);
666    
667          msg = "Output directory for the generated root file(s): " + (string)outDir;          msg = "Output directory for the generated root file(s): " + (string)outDir;
668          mainLogUtil->logAlways(msg);              mainLogUtil->logAlways(msg);    
669            msg = "Output directory for the generated root file(s) expanded: " + (string)gSystem->ExpandPathName(outDir); // EMI
670            mainLogUtil->logAlways(msg);    //EMI
671    
672          msg = "Output root name for the generated root file(s): " + (string)nome_output;          msg = "Output root name for the generated root file(s): " + (string)nome_output;
673          mainLogUtil->logAlways(msg);              mainLogUtil->logAlways(msg);    
# Line 818  void mainRead_RealData(char fni[]) Line 847  void mainRead_RealData(char fni[])
847                          if(do_vrl_check){isCadreGood=false;}                          if(do_vrl_check){isCadreGood=false;}
848                          break;                                                            break;                                  
849                  }                  }
850                            skip_cadre = false;
851                  //check of the VRL header e setta route number                  //check of the VRL header e setta route number
852                  if(!VRL_Header_Check(ccHeader_VRL,LENGTH_HEADER_VRL))                            if(!VRL_Header_Check(ccHeader_VRL,LENGTH_HEADER_VRL))          
853                  {                                                {                              
# Line 897  void mainRead_RealData(char fni[]) Line 926  void mainRead_RealData(char fni[])
926                                  string msg = oss.str();                                  string msg = oss.str();
927                                  mainLogUtil->logError(msg);                                  mainLogUtil->logError(msg);
928                                                                    
929                                  //non mi fido del contatore del route                                  //non mi fido del contatore del route                                  
                                           
930                                  stringstream oss1;                                  stringstream oss1;
931                                  oss1<<"Route number unused = "<<route<<" Resetting ROUTE to old value = "<<old_route<<" (download="<<download<<")";                                  oss1<<"Route number unused = "<<route<<" Resetting ROUTE to old value = "<<old_route<<" (download="<<download<<")";
932                                  msg = oss1.str();                                  msg = oss1.str();
# Line 921  void mainRead_RealData(char fni[]) Line 949  void mainRead_RealData(char fni[])
949                                  mainLogUtil->logAll(msg);                                  mainLogUtil->logAll(msg);
950                          }                          }
951                          // is_new_route will be reset to false in PacketUser after the packet is used and stored                          // is_new_route will be reset to false in PacketUser after the packet is used and stored
952                                    
953                            
954                          //main processing of the data, searching for Pamela Packets                          //main processing of the data, searching for Pamela Packets
955                          for(int i=0; i<LENGTH_DATA_CADRE; i++)                          for(int i=0; i<LENGTH_DATA_CADRE; i++)
956                          {                                                {                      
957                                  StateManager::getInstance().getCurrentState()->readInput(ccData[i]);                            StateManager::getInstance().getCurrentState()->readInput(ccData[i]);
958                                  iByte_tot++;                            iByte_tot++;
959                                  if(exitdbg==true){cout<<"**** DBG EXIT FOR****"<<endl; break;}                            if(exitdbg==true){cout<<"**** DBG EXIT FOR****"<<endl; break;}
960                  }                          }
961                  }                  }
962                  else{                  else{
963                          iByte_tot+=LENGTH_DATA_CADRE;                          iByte_tot+=LENGTH_DATA_CADRE;
# Line 967  void mainRead_RealData(char fni[]) Line 996  void mainRead_RealData(char fni[])
996  //function that check the header VRL  //function that check the header VRL
997  bool VRL_Header_Check(char* headVRL, int length)  bool VRL_Header_Check(char* headVRL, int length)
998  {        {      
999                            
           
1000  /*      stringstream oss;                                                /*      stringstream oss;                                              
1001          oss<<"Pippooooooo: at byte+ "<<iByte_tot<<" cadre ... route number = "<<(int)headVRL[3];          oss<<"Pippooooooo: at byte+ "<<iByte_tot<<" cadre ... route number = "<<(int)headVRL[3];
1002          string msg = oss.str();          string msg = oss.str();

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23