-
Notifications
You must be signed in to change notification settings - Fork 3
/
ORMotionNodeDecoder.hh
93 lines (74 loc) · 2.94 KB
/
ORMotionNodeDecoder.hh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// ORMotionNodeDecoder.hh
#ifndef _ORMotionNodeDecoder_hh_
#define _ORMotionNodeDecoder_hh_
#include "ORVDigitizerDecoder.hh"
/*----------------------------------------------
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
^^^^ ^^^^ ^^^^ ^^-----------------------data id
^^ ^^^^ ^^^^ ^^^^ ^^^^-length in longs
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
^^---------------------traceid (0=x,1=y,2=z)
^^^^ ^^^^ ^^^^-device
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx Unix Time
the trace follows and fills out the record length (floats encoded as longs)
------------------------------------------------*/
class ORMotionNodeDecoder: public ORVDigitizerDecoder
{
public:
ORMotionNodeDecoder();
virtual ~ORMotionNodeDecoder() {}
enum EMotionNodeConsts {kBufHeadLen = 3};
virtual std::string GetDataObjectPath() { return "ORMotionNodeModel:XYZTrace"; }
virtual std::string GetDictionaryObjectPath() { return "ORMotionNodeModel"; }
virtual bool SetDataRecord(UInt_t* record);
//Functions that return data from buffer header:
virtual inline UShort_t GetChannelNum();
virtual inline UInt_t GetTimeStamp();
virtual inline UShort_t Device();
// Waveform Functions
virtual inline UInt_t GetRecordOffset();
virtual inline size_t GetWaveformLength();
virtual inline UInt_t* GetWaveformDataPointer();
virtual size_t CopyWaveformData(UInt_t* waveform, size_t len);
//Error checking:
virtual bool IsValid();
virtual void DumpBufferHeader();
//debugging:
void Dump(UInt_t* dataRecord);
/* Adhering to ORVDigitizerDecoder interface. */
virtual double GetSamplingFrequency();
virtual UShort_t GetBitResolution() {return 32;}
virtual size_t GetNumberOfEvents() {return 1;}
virtual ULong64_t GetEventTime(size_t /*event*/) { return GetTimeStamp(); }
virtual UInt_t GetEventEnergy(size_t /*event*/) { return 0; }
virtual UShort_t GetEventChannel(size_t /*event*/) { return GetChannelNum();}
virtual size_t GetEventWaveformLength(size_t /*event*/) { return GetWaveformLength(); }
virtual UInt_t GetEventWaveformPoint( size_t /*event*/,
size_t waveformPoint );
};
//inline functions: ************************************************************************
inline UInt_t ORMotionNodeDecoder::GetRecordOffset()
{
return (UShort_t) (kBufHeadLen);
}
inline UShort_t ORMotionNodeDecoder::Device()
{
return (UShort_t) (fDataRecord[1] & 0x0000ffff);
}
inline UShort_t ORMotionNodeDecoder::GetChannelNum()
{
return (UShort_t) ((fDataRecord[1] & 0x00030000) >> 16);
}
inline UInt_t ORMotionNodeDecoder::GetTimeStamp()
{
return (fDataRecord[2]);
}
inline size_t ORMotionNodeDecoder::GetWaveformLength()
{
return (LengthOf(fDataRecord) - kBufHeadLen); //in longs
}
inline UInt_t* ORMotionNodeDecoder::GetWaveformDataPointer()
{
return (UInt_t*)(fDataRecord + kBufHeadLen);
}
#endif