1 |
|
2 |
// Implementation of the TrkAlarmReader class. |
3 |
|
4 |
#include "ReaderAlgorithms.h" |
5 |
using namespace pamela::techmodel; |
6 |
|
7 |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.TrkAlarmReader")); |
8 |
|
9 |
/** |
10 |
* Constructor. |
11 |
*/ |
12 |
TrkAlarmReader::TrkAlarmReader(void): |
13 |
TechmodelAlgorithm(PacketType::TrkAlarm, "TechmodelTrkAlarmReader") { |
14 |
logger->debug(_T("Constructor")); |
15 |
trkAlarm = new TrkAlarmEvent(); |
16 |
} |
17 |
|
18 |
/** |
19 |
* Get a string with the version info of the algorithm. |
20 |
*/ |
21 |
std::string TrkAlarmReader::GetVersionInfo(void) const { |
22 |
return |
23 |
"$Trailer: /home/cvsmanager/yoda/techmodel/TrkAlarmReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 Maurizio Nagni Exp $\n"; |
24 |
} |
25 |
|
26 |
/** |
27 |
* Initialize the algorithm with a special run. This will initialize the |
28 |
* event reader routines for all packet types. |
29 |
*/ |
30 |
void TrkAlarmReader::Init(PamelaRun *run) { |
31 |
SetInputStream(run); |
32 |
run->WriteSubPacket(this, &trkAlarm, trkAlarm->Class()); |
33 |
logger->debug(_T("Initialize")); |
34 |
} |
35 |
|
36 |
/** |
37 |
* Unpack the TrkAlarm event from an input file. |
38 |
*/ |
39 |
void TrkAlarmReader::RunEvent(int EventNumber, long int length) throw (WrongCRCException){ |
40 |
|
41 |
char subData[length]; |
42 |
memset(subData, 0, length*sizeof(char)); |
43 |
InputFile->read(subData, sizeof(subData)); |
44 |
|
45 |
trkAlarm->TrigMask = (subData[0]&0xc0) >> 6; |
46 |
trkAlarm->DSPMask = (subData[0]&0x3f); |
47 |
|
48 |
|
49 |
trkAlarm->FlashShutdown = (subData[1]&0x80) >> 7; |
50 |
trkAlarm->FlashOn = (subData[1]&0x40) >> 6; |
51 |
trkAlarm->DSPBusy = (subData[1]&0x3f); |
52 |
|
53 |
trkAlarm->FlashUpset = (subData[2]&0x80) >> 7; |
54 |
trkAlarm->FlashData = (subData[2]&0x40) >> 6; |
55 |
trkAlarm->DSPSoft = (subData[2]&0x3f); |
56 |
|
57 |
trkAlarm->InterCheck = (subData[3]&0x80) >> 7; |
58 |
trkAlarm->FinalCheck = (subData[3]&0x40) >> 6; |
59 |
trkAlarm->CmdIDMA = (subData[3]&0x3f); |
60 |
|
61 |
trkAlarm->UnknownCmd = (subData[4]&0x80) >> 7; |
62 |
trkAlarm->CmdDuringTrig = (subData[4]&0x40) >> 6; |
63 |
trkAlarm->TrigIDMA = (subData[4]&0x3f); |
64 |
|
65 |
trkAlarm->PNum = (subData[5]&0xf0) >> 4; |
66 |
trkAlarm->CmdNum = (subData[5]&0x0f); |
67 |
|
68 |
for(int i=0 ; i<4 ; i++){ |
69 |
trkAlarm->BID[i] = (subData[6]&(0x03<<i*2)) >> i*2; |
70 |
}; |
71 |
|
72 |
for(int i=1 ; i<4 ; i++){ |
73 |
trkAlarm->BID[3+i] = (subData[7]&(0x03<<i*2)) >> i*2; |
74 |
}; |
75 |
|
76 |
trkAlarm->ALARM[0] = (subData[7]&0x02) >> 1; |
77 |
trkAlarm->ALARM[1] = (subData[7]&0x01); |
78 |
|
79 |
trkAlarm->Aswr = (subData[8]&0xff) << 8; |
80 |
trkAlarm->Aswr = trkAlarm->Aswr | (subData[9]&0xff); |
81 |
} |
82 |
|