]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTHOMERManager.h
* Updated HOMERManager for AMORE functionality
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERManager.h
1 //-*- Mode: C++ -*-
2
3 // $Id: AliHLTHOMERManager.h $
4
5 #ifndef ALIEVEHOMERMANGER_H
6 #define ALIEVEHOMERMANGER_H
7
8 /* This file is property of and copyright by the ALICE HLT Project        * 
9  * ALICE Experiment at CERN, All rights reserved.                         *
10  * See cxx source for full Copyright notice     
11  */
12
13 /** @file   AliHLTHOMERManager.h
14     @author Jochen Thaeder
15     @date
16     @brief  Manager for HOMER in aliroot
17 */
18
19
20 #include "TString.h"
21 #include "TList.h"
22
23 #include "AliHLTHOMERSourceDesc.h"
24 #include "AliHLTHOMERBlockDesc.h"
25 #include "AliHLTHOMERReader.h"
26 #include "AliHLTHOMERProxyHandler.h"
27
28 #include "AliHLTLogging.h"
29
30 class AliHLTHOMERLibManager;
31
32 /**
33  * @class AliHLTHOMERManager
34  * This Class should handle the communication
35  * from the HLT to aliroot. The HLT sends data via 
36  * the HOMER interface on several TCP ports of nodes 
37  * in the CERN GPN and DCS network.
38  * All this communication is hidden from the user.
39  * 
40  * Right now, a xml file ( SCC1 ) is used to get the
41  * configuration, this will/ has to change to a proxy
42  * running on dedicated nodes.
43  *
44  * @ingroup alihlt_homer
45  */
46
47 class AliHLTHOMERManager : public TObject, public AliHLTLogging {
48 public:
49   
50   /*
51    * ---------------------------------------------------------------------------------
52    *                            Constructor / Destructor
53    * ---------------------------------------------------------------------------------
54    */
55
56   /** default constructor */
57   AliHLTHOMERManager();
58
59   /** destructor */
60   virtual ~AliHLTHOMERManager();
61
62   /** Initialize 
63    *  @return 0 on success, <0 for failure
64    */
65   Int_t Initialize();
66
67   /*
68    * ---------------------------------------------------------------------------------
69    *                            Source Handling - public
70    * ---------------------------------------------------------------------------------
71    */
72
73   /** Create Sources List from HOMER-Proxy 
74    *  @return 0 on success, <0 for failure
75    */
76   virtual Int_t CreateSourcesList();
77
78   /** Set state of a source 
79    *  @param source      Pointer to AliHLTHOMERSourceDesc object.
80    *  @param state       New (selected/not selected) state.
81    */
82   void   SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
83
84   /** Get pointer to source List */
85   TList* GetSourceList() { return fSourceList; }
86
87   /*
88    * ---------------------------------------------------------------------------------
89    *                            Connection Handling - public
90    * ---------------------------------------------------------------------------------
91    */
92
93   /** Connect to HOMER sources, of a certain detector.
94    *  which gets created when state has changed 
95    *  @param detector    Detector to be connected to
96    *  @return            0 on success, <0 for failure
97    */
98   Int_t ConnectHOMER( TString detector );
99
100   /** Disconnect from HOMER sources */
101   void  DisconnectHOMER();
102
103   /** Reconnect from HOMER sources 
104    *  @param detector    Detector to be connected to
105    *  @return            0 on success, <0 for failure
106    */
107   Int_t ReconnectHOMER( TString detector);
108
109   /*
110    * ---------------------------------------------------------------------------------
111    *                            Event Handling - public
112    * ---------------------------------------------------------------------------------
113    */
114
115   /** Loads the next Event, after being connected 
116    *  @return 0 on success, <0 for failure
117    */
118   virtual Int_t NextEvent();
119
120   /** Loads the next Cycle, after being connected 
121    *  @return 0 on success, <0 for failure
122    */
123   virtual Int_t NextCycle() { return NextEvent(); }
124
125   /** Get event ID */
126   ULong_t GetEventID() { return fEventID; }    // Get event ID
127
128   /** Get pointer to block List */
129   TList* GetBlockList() { return fBlockList; } // Get pointer to block List
130   
131   ///////////////////////////////////////////////////////////////////////////////////
132
133 protected:
134
135   /** Dynamic loader manager for the HOMER library */
136   AliHLTHOMERLibManager* fLibManager;             //! transient
137
138   ///////////////////////////////////////////////////////////////////////////////////
139
140 private:
141
142   /** copy constructor prohibited */
143   AliHLTHOMERManager(const AliHLTHOMERManager&);
144
145   /** assignment operator prohibited */
146   AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
147
148   /*
149    * ---------------------------------------------------------------------------------
150    *                            Connection Handling - private
151    * ---------------------------------------------------------------------------------
152    */
153
154   /** Create a readout list for Hostname and ports 
155    *  @param socurceHostnames   Array of selected hostnames
156    *  @param socurcePorts       Array of selected ports
157    *  @param socurceCount       Number of selected hostname:port
158    *  @param detector           detector to be selected
159    */
160   void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts, 
161                           UInt_t &sourceCount, TString detector );
162
163   /** Checks if already connected to HOMER sources */
164   Bool_t IsConnected() { return fConnected; }  
165   
166   /* ---------------------------------------------------------------------------------
167    *                            Event Handling - private
168    * ---------------------------------------------------------------------------------
169    */
170
171   /** Create a TList of blocks, which have been readout */
172   void CreateBlockList();
173
174   /*
175    * ---------------------------------------------------------------------------------
176    *                            Block Handling - private
177    * ---------------------------------------------------------------------------------
178    */
179
180   /** Get Number of blocks in current event */
181   ULong_t GetNBlks() { return fNBlks; }
182
183   // ----------------------------------------------------
184
185   /** Get pointer to block ndx in current event 
186    *  @param ndx        Block index
187    *  @return           returns pointer to blk, NULL if no block present
188    */
189   void* GetBlk( Int_t ndx );
190
191   /** Get pointer to current block in current event */
192   void* GetBlk() { return GetBlk(fCurrentBlk); }
193
194   /** Get first block in current event */
195   void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
196
197   /** Get next block in current event */
198   void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
199
200   // ----------------------------------------------------
201
202   /** Get size of block ndx 
203    *  @param ndx        Block index
204    *  @return           returns size blk, 0 otherwise
205    */
206   ULong_t GetBlkSize( Int_t ndx );
207
208   /** Get size of current block */ 
209   ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
210
211   // ---------------------------------------------------- 
212
213   /** Get origin of block ndx 
214    *  @param ndx        Block index
215    *  @return           origin of block
216    */
217   TString GetBlkOrigin( Int_t ndx );
218
219   /** Get origin of current block */
220   TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
221
222   // ----------------------------------------------------
223
224   /** Get type of block ndx 
225    *  @param ndx        Block index
226    *  @return           type of block
227    */
228   TString GetBlkType( Int_t ndx ); 
229
230   /** Get type of current block */
231   TString GetBlkType() { return GetBlkType( fCurrentBlk ); } 
232   
233   // ----------------------------------------------------
234   
235   /** Get specification of block ndx 
236    *  @param ndx        Block index
237    *  @return           specification of block
238    */
239   ULong_t GetBlkSpecification( Int_t ndx );
240
241   /** Get specification of current block */
242   ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); } 
243
244   // ----------------------------------------------------
245
246   /** Checks if current Block should was requested 
247    *  @return           returns kTRUE, if block should was requested
248    */
249   Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
250
251   /*
252    * ---------------------------------------------------------------------------------
253    *                            Members - private
254    * ---------------------------------------------------------------------------------
255    */
256
257   /** Proxy Handler to get the list of sources */
258   AliHLTHOMERProxyHandler *fProxyHandler;            //! transient 
259
260   // == connection ==
261
262   /** Pointer to HOMER reader */
263   AliHLTHOMERReader* fReader;                        //! transient 
264
265   // == sources ==
266
267   /** List to HOMER sources */
268   TList    *fSourceList;                             //! transient
269   
270   // == blocks ==
271
272   /** List to HOMER blocks */
273   TList    *fBlockList;                              //! transient
274
275   // == events ==
276
277   /** Number of blockes in current event */
278   ULong_t   fNBlks;                                  //  see above
279
280   /** EventID of current event */
281   ULong64_t fEventID;                                //  see above
282
283   /** Current block in current event */
284   ULong_t   fCurrentBlk;                             //  see above
285
286   // == states ==
287   
288   /** Shows connection status */
289   Bool_t    fConnected;                              //  see above
290
291   /** Indicates, if a sources have changes, 
292    *  so that one has to reconnect. */
293   Bool_t    fStateHasChanged;                        //  see above
294
295   ClassDef(AliHLTHOMERManager, 0); // Manage connections to HLT data-sources.
296 };
297
298 #endif