/[PAMELA software]/rawreader/src/Verify.cpp
ViewVC logotype

Diff of /rawreader/src/Verify.cpp

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

revision 1.4 by cafagna, Sun Dec 10 13:06:00 2006 UTC revision 1.5 by cafagna, Sun Jan 28 10:55:50 2007 UTC
# Line 81  void verify(char fni[], char inf[], char Line 81  void verify(char fni[], char inf[], char
81   unsigned long int time_p[3];      /*Packet time*/   unsigned long int time_p[3];      /*Packet time*/
82   unsigned long int time_max=0;   unsigned long int time_max=0;
83   unsigned long int time_min=0;   unsigned long int time_min=0;
84     int CLN2_END=0;
85   long int pack_length=0;           /*PAMELA packet length*/   long int pack_length=0;           /*PAMELA packet length*/
86   long long int adr_first[3];       /*Start displacement from file begin*/   long long int adr_first[3];       /*Start displacement from file begin*/
87   long long int adr_last[3];        /*Finish displacement from file begin*/   long long int adr_last[3];        /*Finish displacement from file begin*/
# Line 387  void verify(char fni[], char inf[], char Line 388  void verify(char fni[], char inf[], char
388      fo_work<<"CRC error : PAMELA packet="<<numP[2]<<" : real CRC="<<bitset<8>(CRC_Header[2])<<"("<<CRC_Header[2]<<      fo_work<<"CRC error : PAMELA packet="<<numP[2]<<" : real CRC="<<bitset<8>(CRC_Header[2])<<"("<<CRC_Header[2]<<
389               ") : calculated CRC="<<bitset<8>(CalcCheckSum)<<"("<<CalcCheckSum<<")\n";               ") : calculated CRC="<<bitset<8>(CalcCheckSum)<<"("<<CalcCheckSum<<")\n";
390     }     }
391     if ((time_max<time_p[2])&&(flag_CRC_H[2]!=1)) time_max=time_p[2];  // TIme in the last new packet  
392       if ((time_max<=time_p[2])&&(flag_CRC_H[2]!=1))
393       {time_max=time_p[2];}
394       else if ((time_max>time_p[2])&&(flag_CRC_H[2]!=1)&&(CLN2_FLAG==2))
395       {fin.seekg(0,ios::end); CLN2_END=1; goto END;}
396  /*********packet counter error analysis****************************/  /*********packet counter error analysis****************************/
397     if ((numP[2]!=(numP[1]+1))&&(N1!=1)&&(flag_len[1]==0)&&(CRC_bad_pack[2]==numP[2]))     if ((numP[2]!=(numP[1]+1))&&(N1!=1)&&(flag_len[1]==0)&&(CRC_bad_pack[2]==numP[2]))
398     {     {
# Line 570  void verify(char fni[], char inf[], char Line 575  void verify(char fni[], char inf[], char
575  /******************************************************************/  /******************************************************************/
576  /********************MAIN READING CYCLE END************************/  /********************MAIN READING CYCLE END************************/
577  /******************************************************************/  /******************************************************************/
578    END:
579     if (CLN2_END==0)
580     {
581  /*************PAMELA LAST PACKET END DISPLACEMENT******************/  /*************PAMELA LAST PACKET END DISPLACEMENT******************/
582    if ((icount-adr_first[2]+1-LenP[2]-16)<=Limit) {adr_last[2]=icount;}                   //end byte for previous packet    if ((icount-adr_first[2]+1-LenP[2]-16)<=Limit) {adr_last[2]=icount;}                   //end byte for previous packet
583    else if ((icount-adr_first[2]+1-LenP[2]-16)>Limit) {adr_last[2]=adr_first[2]+Limit;}   //end byte for previous packet    else if ((icount-adr_first[2]+1-LenP[2]-16)>Limit) {adr_last[2]=adr_first[2]+Limit;}   //end byte for previous packet
# Line 594  void verify(char fni[], char inf[], char Line 601  void verify(char fni[], char inf[], char
601       (int)(temp[1]/(long int)(pow(256.,3-i)));}}         (int)(temp[1]/(long int)(pow(256.,3-i)));}}  
602    
603  //Write last packet end displacement in log file  //Write last packet end displacement in log file
604   for (i=0;i<4;i++) fprintf(fo_log,"%1c",char(Byte_adr2[i]));    for (i=0;i<4;i++) fprintf(fo_log,"%1c",char(Byte_adr2[i]));
605    
606  //Write error number in log and work.dat files  //Write error number in log and work.dat files
607   flags=(short int)(pow((float)(2*flag_CRC_H[2]),1)+    flags=(short int)(pow((float)(2*flag_CRC_H[2]),1)+
608                     pow((float)(2*flag_len[2]),2)+                     pow((float)(2*flag_len[2]),2)+
609                     pow((float)(2*flag_pack[2]),3)+                     pow((float)(2*flag_pack[2]),3)+
610                     pow((float)(2*flag_name[2]),4)+                     pow((float)(2*flag_name[2]),4)+
611                     pow((float)(2*flag_type[2]),5)+                     pow((float)(2*flag_type[2]),5)+
612                     pow((float)(2*flag_time[2]),6)+                     pow((float)(2*flag_time[2]),6)+
613                                     pow((float)(2*flag_CRC_cor[2]),7));                                     pow((float)(2*flag_CRC_cor[2]),7));
614   if ((flags!=0)&&(N1>0)) er_pack_count+=1;    if ((flags!=0)&&(N1>0)) er_pack_count+=1;
615   fprintf(fo_log,"%1c",char(flags));    fprintf(fo_log,"%1c",char(flags));
616  //Write error number in work.dat file  //Write error number in work.dat file
617   if (flags!=0) fo_work<<"PAMELA packet="<<numP[2]<<" : error flag="<<flags<<"\n";    if (flags!=0) fo_work<<"PAMELA packet="<<numP[2]<<" : error flag="<<flags<<"\n";
618     }
619    
620  //Write inf file  //Write inf file
621   fprintf(fo_inf,"%lli bytes in initial file %s\n", icount_total, name_in);   fprintf(fo_inf,"%lli bytes in initial file %s\n", icount_total, name_in);
622   icount_int = (int)(icount_total/1024);   icount_int = (int)(icount_total/1024);
# Line 634  void verify(char fni[], char inf[], char Line 642  void verify(char fni[], char inf[], char
642    fprintf(fo_inf,"Type %x  number of PAMELA packets= %i\n",    fprintf(fo_inf,"Type %x  number of PAMELA packets= %i\n",
643                       packet_type[i-1], packet_counter[i]);                       packet_type[i-1], packet_counter[i]);
644   }   }
645    
646     if (CLN2_END==0)
647     {
648  //Write data in file "nnnnn_mmm_xxx_cln2.pam"  //Write data in file "nnnnn_mmm_xxx_cln2.pam"
649   for (i=0;i<adr_last[2]-adr_first[2]+1;i++)    for (i=0;i<adr_last[2]-adr_first[2]+1;i++)
650   {fo_pam<<buffer[i];}    {fo_pam<<buffer[i];}
651     }
652    
653   time(&seconds);   time(&seconds);
654   timeinfo=localtime(&seconds);   timeinfo=localtime(&seconds);

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

  ViewVC Help
Powered by ViewVC 1.1.23