Updated buffer handling with mutex and faster response
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHLTEventManagerHomer.cxx
CommitLineData
30e7579c 1// Author: 2010 Svein Lindal <slindal@fys.uio.no> *
2// for The ALICE HLT Project. *
3
4#include "AliHLTEveHLT.h"
5#include "AliHLTEvePhos.h"
6#include "AliHLTEveEmcal.h"
7
8
9#include "AliESDEvent.h"
10#include "AliEveHLTEventManager.h"
11#include "AliEveEventBufferOffline.h"
12#include "AliEveHLTEventManagerHomer.h"
13#include "TList.h"
14#include "AliEveHOMERManager.h"
15#include "TEveManager.h"
55f78c0d 16#include "TTimer.h"
17#include "TGLOverlayButton.h"
30e7579c 18
19ClassImp(AliEveHLTEventManagerHomer)
20
21AliEveHLTEventManagerHomer::AliEveHLTEventManagerHomer() :
22 AliEveHLTEventManager(),
55f78c0d 23 fEventBuffer(NULL),
24 fNextEventTimer(NULL),
25 fInfoButton(NULL)
30e7579c 26{
27 // see header file for class documentation
55f78c0d 28
30e7579c 29 fEventBuffer = new AliEveEventBufferHomer();
11757805 30 fEventBuffer->StartBufferMonitor();
55f78c0d 31
32 fNextEventTimer = new TTimer();
33 fNextEventTimer->Connect("Timeout()", "AliEveHLTEventManagerHomer", this, "TryNextEvent()" );
34
30e7579c 35
36
37}
38
39
40AliEveHLTEventManagerHomer::~AliEveHLTEventManagerHomer() {
41
42 //DestroyElements();
43 //DestroyDetectorElements();
44 if(fEventBuffer)
45 delete fEventBuffer;
46 fEventBuffer = NULL;
47
48}
49
0ddb492b 50///________________________________________________________________________________
51void AliEveHLTEventManagerHomer::ProcessList(TList * blockList) {
52
53 ProcessEvent(blockList);
54 UpdateDisplay();
55
56}
55f78c0d 57void AliEveHLTEventManagerHomer::NextEvent() {
58 fNextEventTimer->Start(1000);
59}
30e7579c 60
61///________________________________________________________________________________
55f78c0d 62void AliEveHLTEventManagerHomer::TryNextEvent() {
30e7579c 63 //See header file for documentation
55f78c0d 64
65 if ( fEventBuffer->LockMutex() ) {
66 cout << "try again in 1 sec"<<endl;
d63d227e 67 return;
55f78c0d 68 }
69
70 fNextEventTimer->Stop();
71
72 cout << "Mutex is freeee!!"<<endl;
cc87822c 73 TList * aSyncEvent = fEventBuffer->GetASyncEvent();
74 TList * event = static_cast<TList*>(fEventBuffer->NextEvent());
75 if(event) {
76 cout << "Got the event, reset the display " <<endl;
77 ResetDisplay();
78 cout << "Process event"<<endl;
79 ProcessEvent(event);
80 if(aSyncEvent) {
81 cout << "Process asynchroneous event" << endl;
82 ProcessEvent(aSyncEvent);
83 } else {
84 cout << "Could not get async event"<<endl;
85 }
86
87 cout << "Upate the display"<<endl;
88 UpdateDisplay();
89
30e7579c 90 } else {
0ddb492b 91 cout << "couldn't get the sync event"<<endl;
30e7579c 92 }
d5180d24 93
765675f2 94
95 fEventBuffer->UnLockMutex();
30e7579c 96}
97
98
99///____________________________________________________________________________________
100void AliEveHLTEventManagerHomer::NavigateFwd() {
101 //See header file for documentation
102 TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Fwd());
103 if(fEvent) {
0ddb492b 104 ResetDisplay();
30e7579c 105 ProcessEvent(fEvent);
0ddb492b 106 UpdateDisplay();
30e7579c 107 } else {
108 cout << "couldn't get the fwd event"<<endl;
109 }
110}
111
112
113///______________________________________________________________________________________
114void AliEveHLTEventManagerHomer::NavigateBack() {
115 //See header file for documentation
116 TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Back());
117 if(fEvent) {
0ddb492b 118 ResetDisplay();
30e7579c 119 ProcessEvent(fEvent);
0ddb492b 120 UpdateDisplay();
30e7579c 121 } else {
122 cout << "couldn't get the back event"<<endl;
123 }
124}
125