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

Annotation of /yoda/techmodel/CalibAcReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2.1 - (hide annotations) (download)
Sun Oct 17 12:28:38 2004 UTC (20 years, 2 months ago) by kusanagi
Branch: MAIN
Changes since 2.0: +6 -6 lines
*** empty log message ***

1 kusanagi 1.1 /** @file
2 kusanagi 1.2 * $Source: /home/cvsmanager/yoda/techmodel/CalibAcReader.cpp,v $
3 kusanagi 2.1 * $Id: CalibAcReader.cpp,v 2.0 2004/09/21 20:50:54 kusanagi Exp $
4 kusanagi 1.1 * $Author: kusanagi $
5     *
6     * Implementation of the ArrDumpReader class.
7     */
8    
9     #include <string>
10 kusanagi 1.5 #include <log4cxx/logger.h>
11 kusanagi 1.1 #include <fstream>
12     #include "stdio.h"
13     extern "C" {
14     #include "CRC.h"
15 kusanagi 2.1 #include "forroutines/anticounter/AC.h"
16     extern int ACcalib(int length, unsigned char* calibpointer, struct calibstruct* calibpointer);
17 kusanagi 1.1 }
18    
19     #include "ReaderAlgorithms.h"
20    
21     using namespace pamela;
22     using namespace pamela::techmodel;
23    
24 kusanagi 1.5 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibAcReader"));
25 kusanagi 1.1
26     /**
27     * Constructor.
28     */
29     CalibAcReader::CalibAcReader(void):
30     TechmodelAlgorithm(PacketType::CalibAc, "TechmodelCalibAc") {
31 kusanagi 1.5 logger->debug(_T("Constructor"));
32 kusanagi 1.1 CalibAc = new CalibAcEvent();
33     }
34    
35     /**
36     * Get a string with the version info of the algorithm.
37     */
38     std::string CalibAcReader::GetVersionInfo(void) const {
39 kusanagi 2.1 return "$Header: /home/cvsmanager/yoda/techmodel/CalibAcReader.cpp,v 2.0 2004/09/21 20:50:54 kusanagi Exp $\n";
40 kusanagi 1.1 }
41    
42     /**
43     * Initialize the algorithm with a special run. This will initialize the
44     * event reader routines for all packet types.
45     */
46     void CalibAcReader::Init(PamelaRun *run) {
47 kusanagi 1.5 logger->debug(_T("Initialize"));
48 kusanagi 1.1 SetInputStream(run);
49     run->WriteSubPacket(this, &CalibAc, CalibAc->Class());
50     }
51    
52     /**
53     * Unpack the CalibAc event from an input file.
54     */
55     void CalibAcReader::RunEvent(int EventNumber, long int length) {
56     char *subData;
57     char eventCRC[2];
58     UINT16 subCRC; //CRC of the data
59     UINT16 readCRC; //CRC read from the end of the subpacket
60     long int dataLength;
61    
62     //the 2 bytes subtracted belong to the final event CRC bytes
63     dataLength = length - (long int)2;
64    
65     subData = new char[dataLength];
66     InputFile->read(subData, sizeof(unsigned char)*dataLength);
67     subCRC = CM_Compute_CRC16(0, (BYTE*)subData, dataLength);
68    
69     //took the final CRC to compare it with the previous calculated CRC of the data
70     InputFile->read(eventCRC, sizeof(eventCRC));
71     readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF);
72    
73     if (subCRC == readCRC){
74 kusanagi 2.1 calibstruct output;
75 kusanagi 1.2 int ERROR;
76 kusanagi 2.1 ERROR = ACcalib(dataLength, (unsigned char*)subData, &output);
77 kusanagi 1.1
78 kusanagi 1.2 CalibAc->header = output.header;
79     memcpy(CalibAc->status, output.status, sizeof(CalibAc->status));
80 kusanagi 1.4 memcpy(CalibAc->temp, output.temp, sizeof(CalibAc->temp));
81     memcpy(CalibAc->DAC1, output.DAC1, sizeof(CalibAc->DAC1));
82     memcpy(CalibAc->DAC2, output.DAC2, sizeof(CalibAc->DAC2));
83 kusanagi 1.2 memcpy(CalibAc->regist, output.regist, sizeof(CalibAc->regist));
84     memcpy(CalibAc->time, output.time, sizeof(CalibAc->time));
85     CalibAc->n_tr = output.n_tr;
86     memcpy(CalibAc->hitmap_tr, output.hitmap_tr, sizeof(CalibAc->hitmap_tr));
87     memcpy(CalibAc->curve1, output.curve1, sizeof(CalibAc->curve1));
88     memcpy(CalibAc->curve2, output.curve2, sizeof(CalibAc->curve2));
89     CalibAc->iCRC = output.iCRC;
90     CalibAc->tail = output.tail;
91     CalibAc->CRC = output.CRC;
92 kusanagi 1.1 } else {
93 kusanagi 1.5 logger->warn(_T("Wrong CRC on Subpacket in ArrDump Packet "));
94 kusanagi 1.1 }
95 kusanagi 1.3 delete [] subData;
96 kusanagi 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.23