]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveHLT/AliEveHLTEventManagerHomer.cxx
Coverity
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveHLTEventManagerHomer.cxx
index f8ed314ec0a00ad594f31224dee54d2b9cd30d60..515073aff3d7b9306ce470cbd118b7368c22ba9c 100644 (file)
 #include "TList.h"
 #include "AliEveHOMERManager.h"
 #include "TEveManager.h"
+#include "TTimer.h"
+#include "TGLOverlayButton.h"
+#include "TGLViewer.h"
 
 ClassImp(AliEveHLTEventManagerHomer)
 
 AliEveHLTEventManagerHomer::AliEveHLTEventManagerHomer() : 
   AliEveHLTEventManager(),
-  fEventBuffer(NULL)
+  fEventBuffer(NULL), 
+  fNextEventTimer(NULL),
+  fInfoButton(NULL)
 {
   // see header file for class documentation
-  // or
-  // refer to README to build package
-  // or
-  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
   fEventBuffer = new AliEveEventBufferHomer();
-  //AliEveHOMERManager * hm = fEventBuffer->GetHomerManager();
-  //if(hm) GetEveManager()->AddToListTree(hm, kTRUE);
+  fEventBuffer->StartBufferMonitor();
+    
+  fNextEventTimer = new TTimer();
+  fNextEventTimer->Connect("Timeout()", "AliEveHLTEventManagerHomer", this, "TryNextEvent()" );
+   
+  fInfoButton = new TGLOverlayButton(dynamic_cast<TGLViewerBase*>(gEve->GetDefaultGLViewer()),  "", 0, 540, 210, 25);
+    fInfoButton->SetAlphaValues(0.0, 0.8);
+  
   
 
 }
@@ -43,36 +51,67 @@ AliEveHLTEventManagerHomer::~AliEveHLTEventManagerHomer() {
 
 }
 
-
 ///________________________________________________________________________________
+void AliEveHLTEventManagerHomer::ProcessList(TList * blockList) {
+
+  ProcessEvent(blockList);
+  UpdateDisplay();
+
+}
 void AliEveHLTEventManagerHomer::NextEvent() {
+  fNextEventTimer->Start(1000);
+}
+
+///________________________________________________________________________________
+void AliEveHLTEventManagerHomer::TryNextEvent() {
   //See header file for documentation
-  if(fEventBuffer->GetBusy() ) {
-    cout << "event buffer already busy"<<endl;
+    
+  if ( fEventBuffer->LockMutex() ) {
+    fInfoButton->SetAlphaValues(0.8, 0.8);
+    fInfoButton->SetText("Waiting for buffer...");
+    gEve->Redraw3D(kFALSE);
+    cout << "try again in 1 sec"<<endl;
     return;
-  }else {
-    fEventBuffer->SetBusy(kTRUE);
   }
+  fInfoButton->SetAlphaValues(0.8, 0.8);
+
+  fNextEventTimer->Stop();
+    
+  cout << "Mutex is freeee!!"<<endl;
+  TList * aSyncEvent = fEventBuffer->GetASyncEvent();
+  TList * event = static_cast<TList*>(fEventBuffer->NextEvent());
+  if(event) {
+    cout << "Got the event, reset the display " <<endl;
+    fInfoButton->SetText("Reset display..");
+    ResetDisplay();
+    cout << "Process event"<<endl;
+    fInfoButton->SetText("Processing event..");
+    ProcessEvent(event);
+    if(aSyncEvent) {
+      cout  << "Process asynchroneous event" << endl;
+      ProcessEvent(aSyncEvent);
+    }  else {
+      cout << "Could not get async event"<<endl;
+    }
+    
+    cout << "Upate the display"<<endl;
+    fInfoButton->SetText("Updating display...");
+    UpdateDisplay();
   
-  TList * fEvent = static_cast<TList*>(fEventBuffer->NextEvent());
-  if(fEvent) {
-    cout << "Got the event " <<endl;
-    ProcessEvent(fEvent);
-
   } else {
-    cout << "could't get the sync event"<<endl;
+    cout << "couldn't get the sync event"<<endl;
+    fInfoButton->SetAlphaValues(0.8, 0.8);
+    fInfoButton->SetText("Waiting for buffer...");
+    fEventBuffer->UnLockMutex();
+    fEventBuffer->CreateBufferThread();
+    fNextEventTimer->Start(3000);
+    return;
   }
   
- //  cout  << "doint async block"<<endl;
- //  TList * async = static_cast<TList*>(fEventBuffer->GetAList());
- //  if(async) {
- //    ProcessEvent(async);
- //   }  else {
- //     cout << "No async bloc"<<endl;
- // }
-
+  fInfoButton->SetAlphaValues(0.0, 0.0);
+  fInfoButton->SetText("Done..");
+  fEventBuffer->UnLockMutex();
 
-fEventBuffer->SetBusy(kFALSE);
 }
 
 
@@ -81,7 +120,9 @@ void AliEveHLTEventManagerHomer::NavigateFwd() {
   //See header file for documentation
   TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Fwd());
   if(fEvent) {
+    ResetDisplay();
     ProcessEvent(fEvent);
+    UpdateDisplay();
   } else {
     cout << "couldn't get the fwd event"<<endl;
   }
@@ -93,7 +134,9 @@ void AliEveHLTEventManagerHomer::NavigateBack() {
   //See header file for documentation
   TList * fEvent = dynamic_cast<TList*>(fEventBuffer->Back());
   if(fEvent) {
+    ResetDisplay();
     ProcessEvent(fEvent);
+    UpdateDisplay();
   } else {
     cout << "couldn't get the back event"<<endl;
   }