/[PAMELA software]/yoda/techmodel/EventReader.cpp
ViewVC logotype

Diff of /yoda/techmodel/EventReader.cpp

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

revision 1.1.1.1 by kusanagi, Tue Jul 6 12:20:23 2004 UTC revision 2.2 by kusanagi, Fri Sep 24 11:57:49 2004 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Author: nagni $   * $Author: kusanagi $
3   * $Date: 2004/06/09 23:18:20 $   * $Date: 2004/09/22 13:14:03 $
4   * $Revision: 1.12 $   * $Revision: 2.1 $
5   *   *
6   * Implementation of the functions of a sample Algorithm class.   * Implementation of the functions of a sample Algorithm class.
7   * This file can be used as a templace to develop your own algorithm.   * This file can be used as a templace to develop your own algorithm.
8   */   */
9    
10  #include <log4cpp/Category.hh>  #include <log4cxx/logger.h>
11  #include <fstream>  #include <fstream>
12  #include "TechmodelAlgorithm.h"  #include "TechmodelAlgorithm.h"
13  #include "EventReader.h"  #include "EventReader.h"
# Line 23  extern "C" { Line 23  extern "C" {
23  using namespace pamela;  using namespace pamela;
24  using namespace pamela::techmodel;  using namespace pamela::techmodel;
25    
26  static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.EventReader");  static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.EventReader"));
27  static unsigned int prevPckCounter = 0;  
28  static unsigned int prevPckOBT     = 0;  unsigned int EventReader::maxPackets     = 0;
29    unsigned int EventReader::prevPckCounter = 0;
30    unsigned int EventReader::prevPckOBT     = 0;
31    
32    
33  /**  /**
34   * Constructor.   * Constructor.
35   */   */
36  EventReader::EventReader(void):  EventReader::EventReader(int packetsLimit = -1):
37    TechmodelAlgorithm(0, "TechmodelEventReader") {    TechmodelAlgorithm(0, "TechmodelEventReader"){
38    cat <<  log4cpp::Priority::DEBUG  //EventReader::EventReader(void):
39        <<  "Constructor "  //  TechmodelAlgorithm(0, "TechmodelEventReader") {
40        <<  "\n " << log4cpp::CategoryStream::ENDLINE;    EventReader::maxPackets = packetsLimit;
41      logger->debug(_T("Constructor"));
42    Header = new EventHeader();    Header = new EventHeader();
43    /*  
44        TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::PhysEndRun,      new PhysEndRunReader()));
45        TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse1,  new CalibCalPulse1Reader()));
46    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Alarm,    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse2,  new CalibCalPulse2Reader()));
47                                                    new AlarmReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Physics,         new PhysicsReader()));
48    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Khb,    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrkBoth,    new CalibTrkBothReader()));
49                                                    new KhbReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk1,       new CalibTrk1Reader()));
50   */    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk2,       new CalibTrk2Reader()));
51    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Physics,    new PhysicsReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrd,        new CalibTrdReader()));
52    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ForcedPkt,  new ForcedPktReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTof,        new CalibTofReader()));
53    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunHeader,  new RunHeaderReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibS4,         new CalibS4Reader()));
54    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunTrailer, new RunTrailerReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPed,     new CalibCalPedReader()));
55    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Log,      new LogReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibAc,         new CalibAcReader()));
56    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::VarDump,  new VarDumpReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunHeader,       new RunHeaderReader()));
57    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ArrDump,  new ArrDumpReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunTrailer,      new RunTrailerReader()));
58    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TabDump,  new TabDumpReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibHeader,     new CalibHeaderReader()));
59    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Tmtc,     new TmtcReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrailer,    new CalibTrailerReader()));
60    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Mcmd,     new McmdReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::InitHeader,      new InitHeaderReader()));
61    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCal, new CalibCalReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::InitTrailer,     new InitTrailerReader()));
62    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk, new CalibTrkReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::EventTrk,        new EventTrkReader()));
63    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrg, new CalibTrgReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TestTrk,         new TestTrkReader()));
64    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrd, new CalibTrdReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TestTof,         new TestTofReader()));
65    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTof, new CalibTofReader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Log,             new LogReader()));
66    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibS4,  new CalibS4Reader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::VarDump,         new VarDumpReader()));
67    /*    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ArrDump,         new ArrDumpReader()));
68    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::HA_Header_E5,    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TabDump,         new TabDumpReader()));
69                                                    new E5Reader()));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Tmtc,            new TmtcReader()));
70  */    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Mcmd,            new McmdReader()));
71      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ForcedFECmd,     new ForcedFECmdReader()));
72      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::AcInit,          new AcInitReader()));
73      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalInit,         new CalInitReader()));
74      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkInit,         new TrkInitReader()));
75      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofInit,         new TofInitReader()));
76      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgInit,         new TrgInitReader()));
77      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgInit,         new NdInitReader()));
78      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalAlarm,        new CalAlarmReader()));
79      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::AcAlarm,         new AcAlarmReader()));
80      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkAlarm,        new TrkAlarmReader()));
81      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgAlarm,        new TrgAlarmReader()));
82      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofAlarm,        new TofAlarmReader()));
83  }  }
84    
85  /**  /**
# Line 70  EventReader::EventReader(void): Line 87  EventReader::EventReader(void):
87   */   */
88  std::string EventReader::GetVersionInfo(void) const {  std::string EventReader::GetVersionInfo(void) const {
89    return    return
90      "$Header: /home/cvspamela/yoda/techmodel/EventReader.cpp,v 1.12 2004/06/09 23:18:20 nagni Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 2.1 2004/09/22 13:14:03 kusanagi Exp $\n";
91  }  }
92    
93  /**  /**
# Line 78  std::string EventReader::GetVersionInfo( Line 95  std::string EventReader::GetVersionInfo(
95   * event reader routines for all packet types.   * event reader routines for all packet types.
96   */   */
97  void EventReader::Init(PamelaRun *run) {  void EventReader::Init(PamelaRun *run) {
98        std::stringstream oss;
99        logger->debug(_T("Initialize"));
100      SetInputStream(run);      SetInputStream(run);
101            
102      //Create the structure of directories and create xxx.Header.root files      //Create the structure of directories and create xxx.Header.root files
# Line 86  void EventReader::Init(PamelaRun *run) { Line 105  void EventReader::Init(PamelaRun *run) {
105      //Create the xxx.root in it's specific directory      //Create the xxx.root in it's specific directory
106      for (AlgorithmMap::iterator i = TechmodelAlgorithmMap.begin();      for (AlgorithmMap::iterator i = TechmodelAlgorithmMap.begin();
107         i != TechmodelAlgorithmMap.end(); i++) {         i != TechmodelAlgorithmMap.end(); i++) {
108         cat  <<  log4cpp::Priority::DEBUG         oss.flush();
109              <<  " Initializing algo " << i->second->GetAlgorithmName()         oss << "Initializing algo " << i->second->GetAlgorithmName();
110              <<  "\n " << log4cpp::CategoryStream::ENDLINE;         //cout << "Initializing algo " << i->second->GetAlgorithmName();
111           logger->debug(oss.str().c_str());
112         i->second->Init(run);         i->second->Init(run);
113      }      }
114      Run = dynamic_cast<TechmodelPamelaRun*>(run);      Run = dynamic_cast<TechmodelPamelaRun*>(run);
# Line 107  static void SkipToNextHeader(ifstream *) Line 127  static void SkipToNextHeader(ifstream *)
127  // EventAlgorithm->RunEvent(....) directly the data inside the packet.... will see later....  // EventAlgorithm->RunEvent(....) directly the data inside the packet.... will see later....
128  // 15 June 2004 ---note------------------  // 15 June 2004 ---note------------------
129  void EventReader::RunEvent(int EventNumber) {  void EventReader::RunEvent(int EventNumber) {
     
   cat <<  log4cpp::Priority::ERROR <<  "Start Unpacking........"  
       <<  "\n " << log4cpp::CategoryStream::ENDLINE;  
130    //for now i'll suppose that the raw file starts immediately with the right bytes    //for now i'll suppose that the raw file starts immediately with the right bytes
131    //to insert a GetPacketStart()    //to insert a GetPacketStart()
132    while (!InputFile->eof()){    stringstream oss;
133      int step = 0;
134      while (!InputFile->eof() && ((step++ < maxPackets) || (maxPackets == 0))){
135      try {      try {
136        if (FindStart()) {        if (FindStart()) {
137          if(UnpackPscuHeader()){          if(UnpackPscuHeader()){
# Line 124  void EventReader::RunEvent(int EventNumb Line 143  void EventReader::RunEvent(int EventNumb
143                  Run->FillTrees(type);                  Run->FillTrees(type);
144                  Header->GetCounter()->Increment(type);                  Header->GetCounter()->Increment(type);
145              } else {              } else {
146              cat <<  log4cpp::Priority::ERROR                  oss.flush();
147                  <<  "No way to read events of type" << type->GetName()                  oss << "No way to read events of type" << type->GetName();
148                  <<  "\n " << log4cpp::CategoryStream::ENDLINE;                  logger->info(oss.str().c_str());
149              throw Exception("No way to read events of type " + type->GetName());              throw Exception("No way to read events of type " + type->GetName());
150          }          }
151        } //else {        } //else {
152          //**TO BE DONE**   <<WRONG CRC l --- LOST PACKET>>//          //**TO BE DONE**   <<WRONG CRC l --- LOST PACKET>>//
153          //Have to be defined a "WrongCRC" packet::Type?          //Have to be defined a "WrongCRC" packet::Type?
154          //}          //}
155       }       }
156      } catch (...) {      } catch (...) {
157        //This have to be more detailed. More exceptions type are needed.        //This have to be more detailed. More exceptions type are needed.
158        cat <<  log4cpp::Priority::ERROR <<  "Couldn't read the event. Skipping to the next header."        logger->error("Couldn't read the event. Skipping to the next header.");
           <<  "\n " << log4cpp::CategoryStream::ENDLINE;  
159      }      }
160        if ((step%1000) == 0) std::cout << step/1000 << "K \n";
161    }    }
162    Header->GetCounter()->PrintCounters();      Header->GetCounter()->PrintCounters();
163  }  }
164    
165  static void SkipToNextHeader(ifstream* TechmodelFile) {  static void SkipToNextHeader(ifstream* TechmodelFile) {
# Line 153  static void SkipToNextHeader(ifstream* T Line 172  static void SkipToNextHeader(ifstream* T
172   * Unpack the PSCU header from a file into the structure.   * Unpack the PSCU header from a file into the structure.
173   */   */
174  int EventReader::UnpackPscuHeader(void) throw (std::exception) {  int EventReader::UnpackPscuHeader(void) throw (std::exception) {
175      stringstream oss;
176    int response;    int response;
177    char buff[16];    char buff[16];
178    InputFile->read(buff, sizeof(buff));    InputFile->read(buff, sizeof(buff));
179        
   prevPckCounter = 0;  
   prevPckOBT     = 0;  
180        
181    unsigned char PacketId1    = buff[3];    unsigned char PacketId1    = buff[3];
182    unsigned char PacketId2    = buff[4];    unsigned char PacketId2    = buff[4];
# Line 166  int EventReader::UnpackPscuHeader(void) Line 184  int EventReader::UnpackPscuHeader(void)
184    unsigned int  OrbitalTime  = (((UINT32)buff[8]<<24)&0xFF000000) + (((UINT32)buff[9]<<16)&0x00FF0000) +  (((UINT32)buff[10]<<8)&0x0000FF00) + (((UINT32)buff[11])&0x000000FF);    unsigned int  OrbitalTime  = (((UINT32)buff[8]<<24)&0xFF000000) + (((UINT32)buff[9]<<16)&0x00FF0000) +  (((UINT32)buff[10]<<8)&0x0000FF00) + (((UINT32)buff[11])&0x000000FF);
185    unsigned int  PacketLenght = (((UINT32)buff[12]<<16)&0x00FF0000) +  (((UINT32)buff[13]<<8)&0x0000FF00) + (((UINT32)buff[14])&0x000000FF);    unsigned int  PacketLenght = (((UINT32)buff[12]<<16)&0x00FF0000) +  (((UINT32)buff[13]<<8)&0x0000FF00) + (((UINT32)buff[14])&0x000000FF);
186    unsigned char CRC          = buff[15];    unsigned char CRC          = buff[15];
187      unsigned char FileOffset   = buff[15];
188    
189    if (Counter < prevPckCounter){    if (Counter < prevPckCounter){
190      cat <<  log4cpp::Priority::ERROR      oss.flush();
191          <<  " Packet counter is less than before of " << (prevPckCounter - Counter)      oss << "Packet counter is less than before of " << (prevPckCounter - Counter);
192          <<  "\n " << log4cpp::CategoryStream::ENDLINE;      logger->info(oss.str().c_str());
193    }    }
194    
195    if (OrbitalTime < prevPckOBT){    if (OrbitalTime < prevPckOBT){
196        cat <<  log4cpp::Priority::WARN      oss.flush();
197            <<  " Orbital Time is less than before of " << (prevPckOBT - OrbitalTime)      oss << " Orbital Time is less than before of " << (prevPckOBT - OrbitalTime);
198            <<  "\n " << log4cpp::CategoryStream::ENDLINE;      logger->info(oss.str().c_str());
199    }    }
200    
201    
202    if ((BYTE)CM_Compute_CRC16(0, (BYTE*)&buff, 15) == (BYTE)buff[15]){    if (((BYTE)CM_Compute_CRC16(0, (BYTE*)&buff, 15) == (BYTE)buff[15]) && (PacketId1 == PacketId2)){
203        prevPckCounter = Counter;
204        prevPckOBT     = OrbitalTime;
205      long int initPos = InputFile->tellg();      long int initPos = InputFile->tellg();
206      long int finalPos;      long int finalPos;
207      Header->GetPscuHeader()->SetPacketId(PacketId1, PacketId2);      Header->GetPscuHeader()->SetPacketId(PacketId1, PacketId2);
# Line 190  int EventReader::UnpackPscuHeader(void) Line 211  int EventReader::UnpackPscuHeader(void)
211      //plus the CRC legth (which varies for each type of packet)      //plus the CRC legth (which varies for each type of packet)
212      Header->GetPscuHeader()->SetPacketLenght(PacketLenght);      Header->GetPscuHeader()->SetPacketLenght(PacketLenght);
213      Header->GetPscuHeader()->SetCRC(CRC);      Header->GetPscuHeader()->SetCRC(CRC);
214        Header->GetPscuHeader()->SetFileOffset(((long int)(InputFile->tellg()) - 16));
215            
216      //commented out because of the above test code      //commented out because of the above test code
217      InputFile->seekg(Header->GetPscuHeader()->GetPacketLenght(), std::ios::cur);      InputFile->seekg(Header->GetPscuHeader()->GetPacketLenght(), std::ios::cur);
218      FindStart();      FindStart();
219      finalPos =  (long int)InputFile->tellg() - (1 + initPos + (long int)(Header->GetPscuHeader()->GetPacketLenght()));      finalPos =  (long int)InputFile->tellg() - (1 + initPos + (long int)(Header->GetPscuHeader()->GetPacketLenght()));
220          if(finalPos == 0){          if(finalPos == 0){
221              cat <<  log4cpp::Priority::INFO <<  " Correct packet length \n"              logger->debug(_T("Correct packet length"));
                 <<  "\n " << log4cpp::CategoryStream::ENDLINE;  
222              }              }
223          if (finalPos > 0 && finalPos < 64) {          if (finalPos > 0 && finalPos < 64) {
224              cat <<  log4cpp::Priority::WARN              oss.flush();
225                  <<  " Correct packet length: Padded of " << finalPos << " bytes \n"              oss << " Correct packet length: Padded of " << finalPos << " bytes";
226                  <<  "\n " << log4cpp::CategoryStream::ENDLINE;              logger->warn(oss.str().c_str());
227          }          }
228          if (finalPos > 64){          if (finalPos > 64){
229              cat <<  log4cpp::Priority::ERROR <<  " Wrong packet length? (because of wrong padding?) \n"              logger->warn(_T(" Wrong packet length? (because of wrong padding?)"));
                 <<  "\n " << log4cpp::CategoryStream::ENDLINE;  
230          }          }
231          InputFile->seekg(initPos, std::ios::beg);          InputFile->seekg(initPos, std::ios::beg);
232          response =  true;          response =  true;
233    } else {    } else {
234      cat <<  log4cpp::Priority::ERROR <<  " WRONG CRC FOR HEADER "      logger->warn(_T(" WRONG CRC FOR HEADER "));
235          <<  "\n " << log4cpp::CategoryStream::ENDLINE;      InputFile->seekg(-(13), std::ios::cur);
236      response =  false;      response =  false;
237    }    }
   
238      char tmpId1[4];      char tmpId1[4];
239      char tmpId2[4];      char tmpId2[4];
240      char tmpLength[12];      char tmpLength[12];
# Line 223  int EventReader::UnpackPscuHeader(void) Line 242  int EventReader::UnpackPscuHeader(void)
242      char tmpCRC[4];      char tmpCRC[4];
243      sprintf(tmpId1, "%02X", PacketId1);      sprintf(tmpId1, "%02X", PacketId1);
244      sprintf(tmpId2, "%02X", PacketId2);      sprintf(tmpId2, "%02X", PacketId2);
245      sprintf(tmpLength, "%06X", PacketLenght);      sprintf(tmpLength, "%06X", Header->GetPscuHeader()->GetPacketLenght());
246      sprintf(tmpStart, "%X", ((long int)(InputFile->tellg()) - 16));      sprintf(tmpStart, "%X", Header->GetPscuHeader()->GetFileOffset());
247      sprintf(tmpCRC, "%02X", CRC);      sprintf(tmpCRC, "%02X", CRC);
248      cat <<  log4cpp::Priority::INFO        oss.flush();
249          <<  "\n Packet Counter (decimal) : "  <<  Counter      oss << "\n Packet Counter (decimal) : "  <<  Counter
250          <<  "\n Id1 - Id2                : "  <<  tmpId1 <<  " - " <<  tmpId2          <<  "\n Id1 - Id2                : "  <<  tmpId1 <<  " - " <<  tmpId2
251          <<  "\n Orbital Time (decimal)   : "  <<  OrbitalTime          <<  "\n Orbital Time (decimal)   : "  <<  OrbitalTime
252          <<  "\n Lenght                   : "  <<  tmpLength          <<  "\n Lenght                   : "  <<  tmpLength
253          <<  "\n CRC                      : "  <<  tmpCRC          <<  "\n CRC                      : "  <<  tmpCRC
254          <<  "\n Header Start Position    : "  <<  tmpStart          <<  "\n Header Start Position    : "  <<  tmpStart;
255          <<  "\n " << log4cpp::CategoryStream::ENDLINE;      logger->info(oss.str().c_str());
256    return response;    return response;
257  }  }
258    
# Line 260  int EventReader::FindStart(void) throw ( Line 279  int EventReader::FindStart(void) throw (
279  //------------------------------------------  //------------------------------------------
280    int subIndex = 0;    int subIndex = 0;
281    char dataByte;    char dataByte;
282    /*InputFile->read(fileByte, 1);  
283      if ( *fileByte ==  *(subSign+subIndex)){    int  buffSize = 100;
284         if (subIndex++ == (subSignDim-1)) {    int  index = 0;
285          InputFile->seekg(-(subIndex), std::ios::cur);    int  loop = 0;
286          return 1;    char buffer[buffSize];
287        }  
288        }*/    /* original version
289    while (!InputFile->eof()) {    while (!InputFile->eof()) {
290      InputFile->get(dataByte);      InputFile->get(dataByte);
291      if (dataByte == (char)(*(subSign+subIndex))){      if (dataByte == (char)(*(subSign+subIndex))){
# Line 278  int EventReader::FindStart(void) throw ( Line 297  int EventReader::FindStart(void) throw (
297        if (InputFile->eof()) {        if (InputFile->eof()) {
298          throw Exception("Extra bytes over the last packets");          throw Exception("Extra bytes over the last packets");
299        } else {        } else {
300          return 0;          subIndex = 0;
301        }        }
       //InputFile->seekg(-(subIndex+1), std::ios::cur);  
       //subIndex = 0;  
302      }      }
303    }    } */
304      while (!InputFile->eof()) {
305        InputFile->read(buffer, sizeof(buffer));
306        index = 0;
307        ++loop;
308        while (index < buffSize){
309            dataByte = buffer[index++];
310            if (dataByte == (char)(*(subSign+subIndex))){
311                if (subIndex++ == (subSignDim-1)) {
312                    InputFile->seekg( (index - subIndex - (buffSize*loop)), std::ios::cur);
313                return 1;
314                }
315            } else {
316                subIndex = 0;
317            }
318        }
319      }
320    return 0;    return 0;
321  }  }
322    

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.2.2

  ViewVC Help
Powered by ViewVC 1.1.23