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 *
10 /** @file AliHLTAltroEncoder.h
11 @author Matthias Richter
13 @brief Encoder class for 10/40bit Altro Data format
16 #include "AliHLTDataTypes.h"
17 #include "AliHLTLogging.h"
20 #define AliHLTUInt16MAX 0xffff
23 * @class AliHLTAltroEncoder
24 * Encoder of the RCU/Altro data format.
25 * The class allows to encodes data sets of channel, timebin and signal
26 * value into the 10bit/40bit Altro format. It works on a provided buffer.
28 * Signal values can be added by using the AddSignal(AliHLTUInt16_t, AliHLTUInt16_t)
29 * function. It functions works on a 'current channel'. If data is supposed to go into
30 * a new channel, SetChannel(AliHLTUInt16_t) has to be used.
33 * AliHLTAltroEncoder encoder;
34 * encoder.SetBuffer(pBuffer, size);
37 * int channelAddress=...;
39 * for (int bunch=0; bunch<nofBunches; bunch++) {
40 * int bunchLength=...;
43 * for (; time<startTime+bunchLength; time++) {
44 * iResult=encoder.AddSignal(signal, time);
48 * encoder.SetChannel(channelAddress);
54 class AliHLTAltroEncoder : AliHLTLogging {
56 /** default constructor */
59 AliHLTAltroEncoder(AliHLTUInt8_t* pBuffer, int iSize);
61 virtual ~AliHLTAltroEncoder();
64 * Set the target buffer.
66 int SetBuffer(AliHLTUInt8_t* pBuffer, int iSize);
70 * If the timebin is a consecutive timebin, the signal is added to the
71 * current bunch. If not, the previous bunch is terminated and a new
74 * The first timebins decide whether the order is ascending or descending.
75 * @param signal 10bit signal value
76 * @param timebin 10bot time bin value
78 int AddSignal(AliHLTUInt16_t signal, AliHLTUInt16_t timebin);
81 * Set and terminate the current channel.
83 * @param hwaddress Hardware address of the channel
85 int SetChannel(AliHLTUInt16_t hwaddress);
89 * The function is a combination of ::AddSignal and ::SetChannel.
90 * All signal of the same channel are added and if a new channel is detected,
91 * the current one is terminated and a new one created.
93 * @param signal 10bit signal value
94 * @param timebin 10bot time bin value
95 * @param hwaddress Hardware address of the channel
96 * @return number of 10bit words added
98 int AddChannelSignal(AliHLTUInt16_t signal, AliHLTUInt16_t timebin, AliHLTUInt16_t hwaddress);
101 * Get total number of 40bit Altro words
103 int GetTotal40bitWords();
114 /** copy constructor prohibited */
115 AliHLTAltroEncoder(const AliHLTAltroEncoder&);
116 /** assignment operator prohibited */
117 AliHLTAltroEncoder& operator=(const AliHLTAltroEncoder&);
120 * Add 10bit value to the buffer
122 int Add10BitValue(AliHLTUInt16_t value);
125 * Fill with 0x2aa paddings to reach complete 40bit word
130 * Finalize the current bunch
134 /// external data buffer
135 AliHLTUInt8_t* fpBuffer; //!transient
137 /// size of the data buffer
138 int fBufferSize; //!transient
140 /// the previous time bin
141 AliHLTUInt16_t fPrevTimebin; //!transient
143 /// length of the current bunch
144 AliHLTUInt16_t fBunchLength; //!transient
146 /// start of the current channel in 10bit word count
147 AliHLTUInt16_t fChannelStart; //!transient
149 /// the current channel
150 AliHLTUInt16_t fChannel; //!transient
152 /// list of already finished channels
153 vector<AliHLTUInt16_t> fChannels; //!transient
155 /// current byte offset
156 int fOffset; //!transient
158 /// current 10bit word count
159 int f10bitWords; //!transient
162 int fOrder; //!transient
164 ClassDef(AliHLTAltroEncoder, 0);