-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathORHexDumpAllProc.cc
71 lines (61 loc) · 2.31 KB
/
ORHexDumpAllProc.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// ORHexDumpAllProc.cc
#include "ORHexDumpAllProc.hh"
#include "ORLogger.hh"
#include "ORRunContext.hh"
#include "ORBasicDataDecoder.hh"
#include <map>
#include <string>
using namespace std;
ORHexDumpAllProc::ORHexDumpAllProc() : ORDataProcessor(NULL)
{
fDataDecoder = new ORBasicDataDecoder;
fCheckLimits=false;
fBegin=0;
fEnd=0;
}
ORHexDumpAllProc::~ORHexDumpAllProc()
{
delete fDataDecoder;
}
ORHexDumpAllProc::EReturnCode ORHexDumpAllProc::ProcessDataRecord(UInt_t* record)
{
if (!fDoProcess || !fDoProcessRun || !fRunContext) return kFailure;
if (fCheckLimits && ((fRunContext->GetPacketNumber() < fBegin) || (fEnd>=0 && fRunContext->GetPacketNumber() > fEnd))) return kSuccess;
if(fRunContext->MustSwap() && !fRunContext->IsRecordSwapped()) {
/* Swapping the record. This only must be done once! */
fDataDecoder->Swap(record);
fRunContext->SetRecordSwapped();
}
static map<int, string> deviceNames = MakeIDMap();
if(deviceNames.size() == 0) return kAlarm;
UInt_t dataID = fDataDecoder->DataIdOf(record);
ORLog(kRoutine) << "Packet Number: " << fRunContext->GetPacketNumber() << endl;
ORLog(kRoutine) << deviceNames[dataID] << " (dataID = " << dataID << "):" << endl;
fDataDecoder->DumpHex(record);
return kSuccess;
}
map<int, string> ORHexDumpAllProc::MakeIDMap()
{
map<int, string> deviceNames;
ORDictionary* dataDescDict = (ORDictionary*) fRunContext->GetHeader()->LookUp("dataDescription");
if(dataDescDict == NULL) {
ORLog(kError) << "no dataDescDescription?" << endl;
return deviceNames;
}
ORDictionary::DictMap dataDescMap = dataDescDict->GetDictMap();
for(ORDictionary::DictMap::iterator i = dataDescMap.begin(); i != dataDescMap.end(); i++) {
string deviceName = i->first;
ORDictionary* deviceDict = (ORDictionary*) i->second;
ORDictionary::DictMap deviceDictMap = deviceDict->GetDictMap();
for(ORDictionary::DictMap::iterator j = deviceDictMap.begin(); j != deviceDictMap.end(); j++) {
ORDictValueI* dataIDDVI = (ORDictValueI*) ((ORDictionary*) j->second)->LookUp("dataId");
if(dataIDDVI == NULL) {
ORLog(kError) << "no dataId for " << deviceName << ":" << j->first << endl;
deviceName.clear();
return deviceNames;
}
deviceNames[dataIDDVI->GetI()] = deviceName + ":" + j->first;
}
}
return deviceNames;
}