| 1 |
/** @file |
/** @file |
| 2 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
| 3 |
* $Date: 2004/12/03 22:08:00 $ |
* $Date: 2004/12/16 17:32:57 $ |
| 4 |
* $Revision: 2.4 $ |
* $Revision: 2.6 $ |
| 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. |
| 47 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTof, new CalibTofReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTof, new CalibTofReader)); |
| 48 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibS4, new CalibS4Reader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibS4, new CalibS4Reader)); |
| 49 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPed, new CalibCalPedReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPed, new CalibCalPedReader)); |
| 50 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibAc, new CalibAcReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Calib1_Ac1, new Calib1_Ac1Reader)); |
| 51 |
|
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Calib2_Ac1, new Calib2_Ac1Reader)); |
| 52 |
|
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Calib1_Ac2, new Calib1_Ac2Reader)); |
| 53 |
|
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Calib2_Ac2, new Calib2_Ac2Reader)); |
| 54 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunHeader, new RunHeaderReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunHeader, new RunHeaderReader)); |
| 55 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunTrailer, new RunTrailerReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::RunTrailer, new RunTrailerReader)); |
| 56 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibHeader, new CalibHeaderReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibHeader, new CalibHeaderReader)); |
| 67 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Tmtc, new TmtcReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Tmtc, new TmtcReader)); |
| 68 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Mcmd, new McmdReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Mcmd, new McmdReader)); |
| 69 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ForcedFECmd, new ForcedFECmdReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::ForcedFECmd, new ForcedFECmdReader)); |
| 70 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::AcInit, new AcInitReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Ac1Init, new Ac1InitReader)); |
| 71 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalInit, new CalInitReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalInit, new CalInitReader)); |
| 72 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkInit, new TrkInitReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkInit, new TrkInitReader)); |
| 73 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofInit, new TofInitReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TofInit, new TofInitReader)); |
| 74 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgInit, new TrgInitReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrgInit, new TrgInitReader)); |
| 75 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::NdInit, new NdInitReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::NdInit, new NdInitReader)); |
| 76 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::S4Init, new S4InitReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::S4Init, new S4InitReader)); |
| 77 |
|
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Ac2Init, new Ac2InitReader)); |
| 78 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalAlarm, new CalAlarmReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalAlarm, new CalAlarmReader)); |
| 79 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::AcAlarm, new AcAlarmReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::AcAlarm, new AcAlarmReader)); |
| 80 |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkAlarm, new TrkAlarmReader)); |
TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::TrkAlarm, new TrkAlarmReader)); |
| 88 |
*/ |
*/ |
| 89 |
std::string EventReader::GetVersionInfo(void) const { |
std::string EventReader::GetVersionInfo(void) const { |
| 90 |
return |
return |
| 91 |
"$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 2.4 2004/12/03 22:08:00 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 2.6 2004/12/16 17:32:57 kusanagi Exp $\n"; |
| 92 |
} |
} |
| 93 |
|
|
| 94 |
/** |
/** |
| 231 |
|
|
| 232 |
//commented out because of the above test code |
//commented out because of the above test code |
| 233 |
InputFile->seekg(Header->GetPscuHeader()->GetPacketLenght(), std::ios::cur); |
InputFile->seekg(Header->GetPscuHeader()->GetPacketLenght(), std::ios::cur); |
| 234 |
FindStart(); |
if (FindStart()) { |
| 235 |
finalPos = (long int)InputFile->tellg() - (1 + initPos + (long int)(Header->GetPscuHeader()->GetPacketLenght())); |
finalPos = (long int)InputFile->tellg() - (initPos + (long int)(Header->GetPscuHeader()->GetPacketLenght())); |
| 236 |
if(finalPos == 0){ |
if(finalPos == 0){ |
| 237 |
logger->debug(_T("Correct packet length")); |
logger->debug(_T(" Correct packet length")); |
| 238 |
} |
} |
| 239 |
if (finalPos > 0 && finalPos < 64) { |
if (finalPos > 0 && finalPos < 64) { |
| 240 |
oss.str(""); |
oss.str(""); |
| 243 |
} |
} |
| 244 |
if (finalPos > 64){ |
if (finalPos > 64){ |
| 245 |
oss.str(""); |
oss.str(""); |
| 246 |
oss << "The begin of the next packet is far more than 64 byte from the end of the previous." |
oss << " The begin of the next packet is far more than 64 byte from the end of the previous." |
| 247 |
<< Header->GetPscuHeader()->Print(); |
<< Header->GetPscuHeader()->Print(); |
| 248 |
logger->error(oss.str().c_str()); |
logger->error(oss.str().c_str()); |
| 249 |
//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."); |
| 250 |
} |
} |
| 251 |
|
} |
| 252 |
|
else { |
| 253 |
|
logger->debug(_T(" END OF FILE")); |
| 254 |
|
} |
| 255 |
|
|
| 256 |
InputFile->seekg(initPos, std::ios::beg); |
InputFile->seekg(initPos, std::ios::beg); |
| 257 |
} else { |
} else { |
| 258 |
InputFile->seekg(-(13), std::ios::cur); |
InputFile->seekg(-(13), std::ios::cur); |
| 290 |
/** |
/** |
| 291 |
* Find the next starting poin for the PSCU event looking for a {0xFA, 0xFE, 0xDE} sequence |
* Find the next starting poin for the PSCU event looking for a {0xFA, 0xFE, 0xDE} sequence |
| 292 |
*/ |
*/ |
| 293 |
int EventReader::FindStart(void) throw (std::exception) { |
bool EventReader::FindStart(void) throw (std::exception) { |
| 294 |
//search an hexadecimal sequence in a file |
//search an hexadecimal sequence in a file |
| 295 |
//subSign ------> pointer to the sequence buffer |
//subSign ------> pointer to the sequence buffer |
| 296 |
//subSignDim ------> dimension of the buffer |
//subSignDim ------> dimension of the buffer |
| 318 |
if (dataByte == (char)(*(subSign+subIndex))){ |
if (dataByte == (char)(*(subSign+subIndex))){ |
| 319 |
if (subIndex++ == (subSignDim-1)) { |
if (subIndex++ == (subSignDim-1)) { |
| 320 |
InputFile->seekg( (index - (subIndex + buffSize)), std::ios::cur); |
InputFile->seekg( (index - (subIndex + buffSize)), std::ios::cur); |
| 321 |
return 1; |
return true; |
| 322 |
} |
} |
| 323 |
} else { |
} else { |
| 324 |
index = index - (subIndex); |
index = index - (subIndex); |
| 327 |
} |
} |
| 328 |
//Needs to guarantee the overap of the buffer(s) in several loop |
//Needs to guarantee the overap of the buffer(s) in several loop |
| 329 |
InputFile->seekg( (-1)*(subSignDim + 1) , std::ios::cur); |
InputFile->seekg( (-1)*(subSignDim + 1) , std::ios::cur); |
| 330 |
} |
} |
| 331 |
return 0; |
return false; |
| 332 |
} |
} |
| 333 |
|
|
| 334 |
ClassImp(EventReader) |
ClassImp(EventReader) |