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

Contents of /yoda/techmodel/TrkAlarmReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4.5 - (show annotations) (download)
Mon Aug 29 09:33:40 2005 UTC (19 years, 3 months ago) by kusanagi
Branch: MAIN
Changes since 4.4: +38 -0 lines
Update: fully implemented the data reading

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

  ViewVC Help
Powered by ViewVC 1.1.23