| 1 |
/** @file |
/** @file |
| 2 |
* $Source: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v $ |
* $Source: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v $ |
| 3 |
* $Id: CalibS4Reader.cpp,v 1.2 2004/07/17 20:03:38 kusanagi Exp $ |
* $Id: CalibS4Reader.cpp,v 2.1 2004/10/17 12:28:38 kusanagi Exp $ |
| 4 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
| 5 |
* |
* |
| 6 |
* Implementation of the LogReader class. |
* Implementation of the LogReader class. |
| 42 |
*/ |
*/ |
| 43 |
std::string CalibS4Reader::GetVersionInfo(void) const { |
std::string CalibS4Reader::GetVersionInfo(void) const { |
| 44 |
return |
return |
| 45 |
"$Header: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v 1.2 2004/07/17 20:03:38 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v 2.1 2004/10/17 12:28:38 kusanagi Exp $\n"; |
| 46 |
} |
} |
| 47 |
|
|
| 48 |
/** |
/** |
| 58 |
/** |
/** |
| 59 |
* Unpack the CalibS4 event from an input file. |
* Unpack the CalibS4 event from an input file. |
| 60 |
*/ |
*/ |
| 61 |
void CalibS4Reader::RunEvent(int EventNumber, long int length) { |
void CalibS4Reader::RunEvent(int EventNumber, long int dataLength) throw (Exception){ |
| 62 |
char *subData; |
char subData[dataLength]; |
|
char eventCRC[2]; |
|
|
UINT16 subCRC; //CRC of the data |
|
|
UINT16 readCRC; //CRC read from the end of the subpacket |
|
|
long int dataLength; |
|
|
|
|
|
//the 2 bytes subtracted belong to the final event CRC bytes |
|
|
dataLength = length - (long int)2; |
|
|
|
|
|
subData = new char[dataLength]; |
|
| 63 |
InputFile->read(subData, sizeof(unsigned char)*dataLength); |
InputFile->read(subData, sizeof(unsigned char)*dataLength); |
|
subCRC = CM_Compute_CRC16(0, (BYTE*)subData, dataLength); |
|
| 64 |
|
|
| 65 |
//took the final CRC to compare it with the previous calculated CRC of the data |
for (int i = 0; i < 384; i++){ |
| 66 |
InputFile->read(eventCRC, sizeof(eventCRC)); |
CalibS4->S4register[i] = ((UINT16)subData[i*6] + (UINT16)subData[(i*6)+1])&0x0FFF; |
| 67 |
readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF); |
CalibS4->S4command[i] = (BYTE)subData[(i*6)+2]; |
| 68 |
|
CalibS4->S4length[i] = ((UINT16)subData[(i*6)+3])&0xFF00 + ((UINT16)subData[(i*6)+4])&0x00FF; |
| 69 |
if (subCRC == readCRC){ |
CalibS4->S4crc[i] = (BYTE)subData[(i*6)+5]; |
|
//put here the reader |
|
|
} else { |
|
|
logger->warn(_T("Wrong CRC for CalibS4 Packet ")); |
|
| 70 |
} |
} |
| 71 |
|
|
| 72 |
} |
} |
| 73 |
|
|