/[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 2.7 by kusanagi, Wed Dec 22 11:38:35 2004 UTC revision 2.9.2.1 by kusanagi, Fri Mar 4 10:34:27 2005 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Author: kusanagi $   * $Author: kusanagi $
3   * $Date: 2004/12/16 17:32:57 $   * $Date: 2005/01/13 08:20:26 $
4   * $Revision: 2.6 $   * $Revision: 2.9 $
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.
# Line 81  EventReader::EventReader(int packetsLimi Line 81  EventReader::EventReader(int packetsLimi
81    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgAlarm,        new TrgAlarmReader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgAlarm,        new TrgAlarmReader));
82    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofAlarm,        new TofAlarmReader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofAlarm,        new TofAlarmReader));
83    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::S4Alarm,         new S4AlarmReader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::S4Alarm,         new S4AlarmReader));
84      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TsbT,            new TsbTReader));
85      TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TsbB,            new TsbBReader));
86  }  }
87    
88  /**  /**
# Line 88  EventReader::EventReader(int packetsLimi Line 90  EventReader::EventReader(int packetsLimi
90   */   */
91  std::string EventReader::GetVersionInfo(void) const {  std::string EventReader::GetVersionInfo(void) const {
92    return    return
93      "$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 2.6 2004/12/16 17:32:57 kusanagi Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 2.9 2005/01/13 08:20:26 kusanagi Exp $\n";
94  }  }
95    
96  /**  /**
# Line 143  void EventReader::RunEvent(int EventNumb Line 145  void EventReader::RunEvent(int EventNumb
145                  Header->GetCounter()->Increment(type);                  Header->GetCounter()->Increment(type);
146                  logger->info(Header->GetPscuHeader()->Print());                  logger->info(Header->GetPscuHeader()->Print());
147              } else {              } else {
148                  throw NotExistingAlgorithmException(type->GetName().c_str()); //to exctract to an higher level and delete the logger!                  oss.str("");
149                    oss << "\n No way to read events of type  " << type->GetName().c_str() << Header->GetPscuHeader()->Print();
150                    throw NotExistingAlgorithmException(oss.str().c_str()); //to exctract to an higher level and delete the logger!
151              }              }
152        }        }
153      // In case of exception have to save the packet in a specific root file??      // In case of exception have to save the packet in a specific root file??
# Line 153  void EventReader::RunEvent(int EventNumb Line 157  void EventReader::RunEvent(int EventNumb
157        logger->error(oss.str().c_str());        logger->error(oss.str().c_str());
158      } catch (WrongCRCHeaderException exc) {      } catch (WrongCRCHeaderException exc) {
159        oss.str("");        oss.str("");
160        oss << exc.print() << " " << Header->GetPscuHeader()->Print();        oss << exc.print();
161        logger->error(oss.str().c_str());        logger->error(oss.str().c_str());
162      } catch (WrongCRCException exc) {      } catch (WrongCRCException exc) {
163        oss.str("");        oss.str("");
# Line 188  static void SkipToNextHeader(ifstream* T Line 192  static void SkipToNextHeader(ifstream* T
192  /**  /**
193   * Unpack the PSCU header from a file into the structure.   * Unpack the PSCU header from a file into the structure.
194   */   */
195  void EventReader::UnpackPscuHeader(void) throw (WrongCRCException, LengthException) {  void EventReader::UnpackPscuHeader(void) throw (WrongCRCHeaderException, LengthException) {
196    stringstream oss;    stringstream oss;
197    int response = false;    int response = false;
198    char buff[16];    char buff[16];
# Line 238  void EventReader::UnpackPscuHeader(void) Line 242  void EventReader::UnpackPscuHeader(void)
242              }              }
243          if (finalPos > 0 && finalPos < 64) {          if (finalPos > 0 && finalPos < 64) {
244              oss.str("");              oss.str("");
245              oss << " Correct packet length: Padded of " << finalPos << " bytes";              oss << "\n Correct packet length: Padded of " << finalPos << " bytes";
246              logger->debug(oss.str().c_str());              logger->debug(oss.str().c_str());
247          }          }
248          if (finalPos > 64){          if (finalPos > 64){
249              oss.str("");              oss.str("");
250              oss << " The begin of the next packet is far more than 64 byte from the end of the previous."              oss << "\n The begin of the next packet is far more than 64 byte from the end of the previous."
251                  << Header->GetPscuHeader()->Print();                  << Header->GetPscuHeader()->Print();
252              logger->error(oss.str().c_str());              logger->error(oss.str().c_str());
253              //throw LengthException("The begin of the next packet is far more than 64 byte from the end of the previous.");              //throw LengthException("The begin of the next packet is far more than 64 byte from the end of the previous.");
# Line 255  void EventReader::UnpackPscuHeader(void) Line 259  void EventReader::UnpackPscuHeader(void)
259                    
260          InputFile->seekg(initPos, std::ios::beg);          InputFile->seekg(initPos, std::ios::beg);
261    } else {    } else {
262         /*Here i should extract the block of Data for later analysis */
263      InputFile->seekg(-(13), std::ios::cur);      InputFile->seekg(-(13), std::ios::cur);
264      throw WrongCRCHeaderException();      oss.str("");
265        oss << "CRC Header Error on packet:" << PscuHeader::Print(buff);
266        throw WrongCRCHeaderException(oss.str().c_str());
267    }    }
268    
269  /*    char tmpId1[4];  /*    char tmpId1[4];

Legend:
Removed from v.2.7  
changed lines
  Added in v.2.9.2.1

  ViewVC Help
Powered by ViewVC 1.1.23