New version (B.Yordanov)
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttleTrigger.h
1 #ifndef ALI_SHUTTLE_TRIGGER_H
2 #define ALI_SHUTTLE_TRIGGER_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               */
6
7 /* $Id$ */
8
9 //
10 // This class is to deal with DAQ LogBook and DAQ end run notification.
11 // It executes AliShuttle for retrieval of conditions data.
12 //
13
14 #include <TObject.h>
15 #include <TSysEvtHandler.h>
16 #include <TMutex.h>
17 #include <TCondition.h>
18
19
20 class AliCDBStorage;
21 class AliShuttle;
22 class AliShuttleConfig;
23
24 class AliShuttleTrigger;
25 class DATENotifier;
26
27 class TerminateSignalHandler: public TSignalHandler {
28         
29         AliShuttleTrigger* fTrigger;
30 public:
31         TerminateSignalHandler(AliShuttleTrigger* trigger, ESignals signal):
32                 TSignalHandler(signal, kFALSE), fTrigger(trigger) {}
33
34         virtual Bool_t Notify();
35
36         ClassDef(TerminateSignalHandler, 0)
37 };
38
39 class AliShuttleTrigger: public TObject {
40 public:
41         AliShuttleTrigger(const AliShuttleConfig* config,
42                         AliCDBStorage* storage, UInt_t timeout = 5000,
43                         Int_t retries = 5);
44         ~AliShuttleTrigger();
45
46         AliShuttle* GetShuttle() {return fShuttle;}
47
48         Bool_t Collect(Int_t run);
49         Bool_t CollectNew();
50         Bool_t CollectAll();
51         
52         virtual Bool_t Notify();
53         void Terminate();
54
55         void Run();
56
57 private:
58
59         class DATEEntry: public TObject {
60                 Int_t fRun;
61                 UInt_t fStartTime;
62                 UInt_t fEndTime;
63         public:
64                 DATEEntry(Int_t run, UInt_t startTime, UInt_t endTime):
65                         fRun(run), fStartTime(startTime), fEndTime(endTime) {}
66
67                 Int_t GetRun() {return fRun;}
68                 UInt_t GetStartTime() {return fStartTime;}
69                 UInt_t GetEndTime() {return fEndTime;}
70
71                 ClassDef(DATEEntry, 0)
72         };
73
74         Bool_t RetrieveDATEEntries(const char* whereClause, TObjArray& entries,
75                         Int_t& lastRun);
76         Bool_t RetrieveConditionsData(const TObjArray& dateEntries);
77
78         const AliShuttleConfig* fConfig;
79         AliCDBStorage* fStorage;
80
81         AliShuttle* fShuttle;
82
83         Bool_t fNotified;
84         Bool_t fTerminate;
85
86         TMutex fMutex;
87         TCondition fCondition;
88
89         TerminateSignalHandler fQuitSignalHandler;
90         TerminateSignalHandler fInterruptSignalHandler;
91
92
93         ClassDef(AliShuttleTrigger, 0)
94 };
95
96 #endif