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

Annotation of /yoda/techmodel/CalibS4Reader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.1 - (hide annotations) (download)
Tue May 30 19:10:01 2006 UTC (18 years, 6 months ago) by kusanagi
Branch: MAIN
Changes since 6.0: +3 -14 lines
Major update.
All the packet officially produced by PAMELA are implemented and unpacked.
The RegistryEvent Packet has been removed and put into another library.
New version, releasd by D.Campana, of tofunpack.

1 kusanagi 1.1 /** @file
2 kusanagi 1.2 * $Source: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v $
3 kusanagi 6.1 * $Id: CalibS4Reader.cpp,v 6.0 2006/02/07 17:11:09 kusanagi Exp $
4 kusanagi 6.0 * $Author: kusanagi $
5 kusanagi 1.1 *
6     * Implementation of the LogReader class.
7     * ToBeDone:
8     * Control the CRC for the entire data Packet not just for single records
9     */
10    
11 kusanagi 6.1
12 kusanagi 1.1 extern "C" {
13     #include "CRC.h"
14     }
15     #include "ReaderAlgorithms.h"
16    
17     using namespace pamela::techmodel;
18    
19 kusanagi 1.3 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibS4Reader"));
20 kusanagi 1.1
21     /**
22     * Constructor.
23     */
24     CalibS4Reader::CalibS4Reader(void):
25     TechmodelAlgorithm(PacketType::Log, "TechmodelCalibS4Reader") {
26 kusanagi 1.3 logger->debug(_T("Constructor"));
27 kusanagi 2.3 calibS4 = new CalibS4Event();
28 kusanagi 1.1 }
29    
30     /**
31     * Get a string with the version info of the algorithm.
32     */
33     std::string CalibS4Reader::GetVersionInfo(void) const {
34     return
35 kusanagi 6.1 "$Header: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v 6.0 2006/02/07 17:11:09 kusanagi Exp $\n";
36 kusanagi 1.1 }
37    
38     /**
39     * Initialize the algorithm with a special run. This will initialize the
40     * event reader routines for all packet types.
41     */
42     void CalibS4Reader::Init(PamelaRun *run) {
43 kusanagi 1.3 logger->debug(_T("Initialize"));
44 kusanagi 1.1 SetInputStream(run);
45 kusanagi 2.3 run->WriteSubPacket(this, &calibS4, calibS4->Class());
46 kusanagi 1.1 }
47    
48     /**
49     * Unpack the CalibS4 event from an input file.
50     */
51 kusanagi 2.4 void CalibS4Reader::RunEvent(int EventNumber, long int length) throw (WrongCRCException){
52 kusanagi 2.3
53     int offset;
54 kusanagi 2.5 char subData[length]; //impulse*(11 + 10 + 01 + 00)*eventLength + CRC = 128*4*6 + UINT16
55 kusanagi 2.4 UINT16 subCRC; //CRC of the data
56     UINT16 readCRC; //CRC read from the end of the subpacket
57    
58     int numRecords = ((length - 2)/6);
59 kusanagi 2.3
60     S4::S4Event* rec;
61     calibS4->Records->Clear();
62     TClonesArray &recs = *(calibS4->Records);
63    
64 kusanagi 2.4 InputFile->read(subData, sizeof(unsigned char)*length);
65     subCRC = CM_Compute_CRC16(0, (BYTE*)subData, length - 2);
66 kusanagi 2.5 readCRC = (((UINT16)(subData[length - 2]<<8))&0xFF00) + (((UINT16)subData[length - 1])&0x00FF);
67 kusanagi 2.4
68     if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for CalibS4 Packet ");
69 kusanagi 2.3
70     for(int i = 0; i < numRecords; i++) {
71     offset = i*6;
72     rec = new(recs[i]) S4::S4Event(); //add a new S4Event
73     rec->S4_REG_STATUS = (((UINT8)subData[offset])&0xF0);
74     rec->S4_DATA = ((((UINT16)subData[offset]<<8)&0x0FFF) + (((UINT16)subData[offset+1])&0x00FF));
75     rec->S4_CMD_NUM = (((UINT8)subData[offset+2])&0xFF);
76     rec->S4_RESP_LENGHT = ((((UINT16)subData[offset+3]<<8)&0xFF00) + (((UINT16)subData[offset+4])&0x00FF));
77     rec->S4_OVERALL_CHKCODE = (((UINT8)subData[offset+5])&0xFF);
78 kusanagi 2.4 }
79 kusanagi 1.1 }
80    

  ViewVC Help
Powered by ViewVC 1.1.23