]>
Commit | Line | Data |
---|---|---|
768be5c3 | 1 | //-*- Mode: C++ -*- |
2 | // $Id$ | |
3 | ||
4 | #ifndef ALIHLTALTROENCODER_H | |
5 | #define ALIHLTALTROENCODER_H | |
6 | //* This file is property of and copyright by the ALICE HLT Project * | |
7 | //* ALICE Experiment at CERN, All rights reserved. * | |
8 | //* See cxx source for full Copyright notice * | |
9 | ||
10 | /** @file AliHLTAltroEncoder.h | |
11 | @author Matthias Richter | |
12 | @date | |
13 | @brief Encoder class for 10/40bit Altro Data format | |
14 | */ | |
15 | ||
16 | // see below for class documentation | |
17 | // or | |
18 | // refer to README to build package | |
19 | // or | |
20 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
21 | ||
22 | #include "AliHLTDataTypes.h" | |
23 | #include "AliHLTLogging.h" | |
24 | #include <vector> | |
25 | ||
26 | #define AliHLTUInt16MAX 0xffff | |
27 | ||
28 | /** | |
29 | * @class AliHLTAltroEncoder | |
30 | * Encoder of the RCU/Altro data format. | |
31 | * The class allows to encodes data sets of channel, timebin and signal | |
32 | * value into the 10bit/40bit Altro format. It works on a provided buffer. | |
33 | * | |
34 | * Signal values can be added by using the ::AddSignal function. This | |
35 | * functions works on a 'current channel'. If data is supposed to go into | |
36 | * a new channel, the ::SetChannel function has to be used. | |
37 | */ | |
38 | class AliHLTAltroEncoder : AliHLTLogging { | |
39 | public: | |
40 | /** default constructor */ | |
41 | AliHLTAltroEncoder(); | |
42 | /** constructor */ | |
43 | AliHLTAltroEncoder(AliHLTUInt8_t* pBuffer, int iSize); | |
44 | /** destructor */ | |
45 | virtual ~AliHLTAltroEncoder(); | |
46 | ||
47 | /** | |
48 | * Set the target buffer. | |
49 | */ | |
50 | int SetBuffer(AliHLTUInt8_t* pBuffer, int iSize); | |
51 | ||
52 | /** | |
53 | * Add a signal value. | |
54 | * If the timebin is a consecutive timebin, the signal is added to the | |
55 | * current bunch. If not, the previous bunch is terminated and a new | |
56 | * one opened. | |
57 | * | |
58 | * The first timebins decide whether the order is ascending or descending. | |
59 | * @param signal 10bit signal value | |
60 | * @param timebin 10bot time bin value | |
61 | */ | |
62 | int AddSignal(AliHLTUInt16_t signal, AliHLTUInt16_t timebin); | |
63 | ||
64 | /** | |
65 | * Set and terminate the current channel. | |
66 | * | |
67 | * @param hwaddress Hardware address of the channel | |
68 | */ | |
69 | int SetChannel(AliHLTUInt16_t hwaddress); | |
70 | ||
71 | /** | |
72 | * Add a signal value. | |
73 | * The function is a combination of ::AddSignal and ::SetChannel. | |
74 | * All signal of the same channel are added and if a new channel is detected, | |
75 | * the current one is terminated and a new one created. | |
76 | * | |
77 | * @param signal 10bit signal value | |
78 | * @param timebin 10bot time bin value | |
79 | * @param hwaddress Hardware address of the channel | |
80 | * @return number of 10bit words added | |
81 | */ | |
82 | int AddChannelSignal(AliHLTUInt16_t signal, AliHLTUInt16_t timebin, AliHLTUInt16_t hwaddress); | |
83 | ||
84 | /** | |
85 | * Get total number of 40bit Altro words | |
86 | */ | |
87 | int GetTotal40bitWords(); | |
88 | ||
89 | enum { | |
90 | kUnknownOrder = 0, | |
91 | kAscending, | |
92 | kDescending | |
93 | }; | |
94 | ||
95 | protected: | |
96 | ||
97 | private: | |
98 | /** copy constructor prohibited */ | |
99 | AliHLTAltroEncoder(const AliHLTAltroEncoder&); | |
100 | /** assignment operator prohibited */ | |
101 | AliHLTAltroEncoder& operator=(const AliHLTAltroEncoder&); | |
102 | ||
103 | /** | |
104 | * Add 10bit value to the buffer | |
105 | */ | |
106 | int Add10BitValue(AliHLTUInt16_t value); | |
107 | ||
108 | /** | |
109 | * Fill with 0x2aa paddings to reach complete 40bit word | |
110 | */ | |
111 | int Pad40Bit(); | |
112 | ||
113 | /** | |
114 | * Finalize the current bunch | |
115 | */ | |
116 | int SetBunch(); | |
117 | ||
118 | /// external data buffer | |
119 | AliHLTUInt8_t* fpBuffer; //!transient | |
120 | ||
121 | /// size of the data buffer | |
122 | int fBufferSize; //!transient | |
123 | ||
124 | /// the previous time bin | |
125 | AliHLTUInt16_t fPrevTimebin; //!transient | |
126 | ||
127 | /// length of the current bunch | |
128 | AliHLTUInt16_t fBunchLength; //!transient | |
129 | ||
130 | /// start of the current channel in 10bit word count | |
131 | AliHLTUInt16_t fChannelStart; //!transient | |
132 | ||
133 | /// the current channel | |
134 | AliHLTUInt16_t fChannel; //!transient | |
135 | ||
136 | /// list of already finished channels | |
137 | vector<AliHLTUInt16_t> fChannels; //!transient | |
138 | ||
139 | /// current byte offset | |
140 | int fOffset; //!transient | |
141 | ||
142 | /// current 10bit word count | |
143 | int f10bitWords; //!transient | |
144 | ||
145 | /// time bin order | |
146 | int fOrder; //!transient | |
147 | ||
148 | ClassDef(AliHLTAltroEncoder, 0); | |
149 | }; | |
150 | ||
151 | #endif |