| 1 |
/** @file |
/** @file |
| 2 |
* $Source: /home/cvsmanager/yoda/techmodel/CalibAcReader.cpp,v $ |
* $Source: /home/cvsmanager/yoda/techmodel/CalibAcReader.cpp,v $ |
| 3 |
* $Id: CalibAcReader.cpp,v 1.3 2004/08/24 16:01:57 kusanagi Exp $ |
* $Id: CalibAcReader.cpp,v 2.0 2004/09/21 20:50:54 kusanagi Exp $ |
| 4 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
| 5 |
* |
* |
| 6 |
* Implementation of the ArrDumpReader class. |
* Implementation of the ArrDumpReader class. |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
#include <string> |
#include <string> |
| 10 |
#include <log4cpp/Category.hh> |
#include <log4cxx/logger.h> |
| 11 |
#include <fstream> |
#include <fstream> |
| 12 |
#include "stdio.h" |
#include "stdio.h" |
| 13 |
extern "C" { |
extern "C" { |
| 14 |
#include "CRC.h" |
#include "CRC.h" |
| 15 |
#include "forroutines/anticounter/ACcalib.h" |
#include "forroutines/anticounter/AC.h" |
| 16 |
extern int ACcalib(int length, unsigned short* datapointer, struct datastruct* calibpointer); |
extern int ACcalib(int length, unsigned char* calibpointer, struct calibstruct* calibpointer); |
| 17 |
} |
} |
| 18 |
|
|
| 19 |
#include "ReaderAlgorithms.h" |
#include "ReaderAlgorithms.h" |
| 21 |
using namespace pamela; |
using namespace pamela; |
| 22 |
using namespace pamela::techmodel; |
using namespace pamela::techmodel; |
| 23 |
|
|
| 24 |
|
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibAcReader")); |
|
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibAcReader"); |
|
| 25 |
|
|
| 26 |
/** |
/** |
| 27 |
* Constructor. |
* Constructor. |
| 28 |
*/ |
*/ |
| 29 |
CalibAcReader::CalibAcReader(void): |
CalibAcReader::CalibAcReader(void): |
| 30 |
TechmodelAlgorithm(PacketType::CalibAc, "TechmodelCalibAc") { |
TechmodelAlgorithm(PacketType::CalibAc, "TechmodelCalibAc") { |
| 31 |
|
logger->debug(_T("Constructor")); |
| 32 |
CalibAc = new CalibAcEvent(); |
CalibAc = new CalibAcEvent(); |
| 33 |
} |
} |
| 34 |
|
|
| 36 |
* Get a string with the version info of the algorithm. |
* Get a string with the version info of the algorithm. |
| 37 |
*/ |
*/ |
| 38 |
std::string CalibAcReader::GetVersionInfo(void) const { |
std::string CalibAcReader::GetVersionInfo(void) const { |
| 39 |
return "$Header: /home/cvsmanager/yoda/techmodel/CalibAcReader.cpp,v 1.3 2004/08/24 16:01:57 kusanagi Exp $\n"; |
return "$Header: /home/cvsmanager/yoda/techmodel/CalibAcReader.cpp,v 2.0 2004/09/21 20:50:54 kusanagi Exp $\n"; |
| 40 |
} |
} |
| 41 |
|
|
| 42 |
/** |
/** |
| 44 |
* event reader routines for all packet types. |
* event reader routines for all packet types. |
| 45 |
*/ |
*/ |
| 46 |
void CalibAcReader::Init(PamelaRun *run) { |
void CalibAcReader::Init(PamelaRun *run) { |
| 47 |
|
logger->debug(_T("Initialize")); |
| 48 |
SetInputStream(run); |
SetInputStream(run); |
| 49 |
run->WriteSubPacket(this, &CalibAc, CalibAc->Class()); |
run->WriteSubPacket(this, &CalibAc, CalibAc->Class()); |
| 50 |
} |
} |
| 53 |
* Unpack the CalibAc event from an input file. |
* Unpack the CalibAc event from an input file. |
| 54 |
*/ |
*/ |
| 55 |
void CalibAcReader::RunEvent(int EventNumber, long int length) { |
void CalibAcReader::RunEvent(int EventNumber, long int length) { |
|
|
|
| 56 |
char *subData; |
char *subData; |
| 57 |
char eventCRC[2]; |
char eventCRC[2]; |
| 58 |
UINT16 subCRC; //CRC of the data |
UINT16 subCRC; //CRC of the data |
| 71 |
readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF); |
readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF); |
| 72 |
|
|
| 73 |
if (subCRC == readCRC){ |
if (subCRC == readCRC){ |
| 74 |
datastruct output; |
calibstruct output; |
| 75 |
int ERROR; |
int ERROR; |
| 76 |
ERROR = ACcalib(dataLength, (unsigned short*)subData, &output); |
ERROR = ACcalib(dataLength, (unsigned char*)subData, &output); |
| 77 |
|
|
| 78 |
CalibAc->header = output.header; |
CalibAc->header = output.header; |
| 79 |
memcpy(CalibAc->status, output.status, sizeof(CalibAc->status)); |
memcpy(CalibAc->status, output.status, sizeof(CalibAc->status)); |
| 90 |
CalibAc->tail = output.tail; |
CalibAc->tail = output.tail; |
| 91 |
CalibAc->CRC = output.CRC; |
CalibAc->CRC = output.CRC; |
| 92 |
} else { |
} else { |
| 93 |
cat << log4cpp::Priority::ERROR |
logger->warn(_T("Wrong CRC on Subpacket in ArrDump Packet ")); |
|
<< "Wrong CRC on Subpacket in ArrDump Packet " |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
| 94 |
} |
} |
| 95 |
delete [] subData; |
delete [] subData; |
| 96 |
} |
} |