]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/AliShuttleTrigger.cxx
make the buffer size check a bit less strict in order to workaround a bug/feature...
[u/mrichter/AliRoot.git] / SHUTTLE / AliShuttleTrigger.cxx
index 1716fd9f6009b67d8fdfdcc72fe0ff619c4d2855..18730e00f19b69b8a92cc9432bdd27163ecb55d8 100644 (file)
 
 /*
  $Log$
+ Revision 1.15  2007/12/10 18:29:23  acolla
+ Some log added to the listen mode
+
+ Revision 1.14  2007/12/07 19:14:36  acolla
+ in AliShuttleTrigger:
+
+ Added automatic collection of new runs on a regular time basis (settable from the configuration)
+
+ in AliShuttleConfig: new members
+
+ - triggerWait: time to wait for DIM trigger (s) before starting automatic collection of new runs
+ - mode: run mode (test, prod) -> used to build log folder (logs or logs_PROD)
+
+ in AliShuttle:
+
+ - logs now stored in logs/#RUN/DET_#RUN.log
+
+ Revision 1.13  2006/11/16 16:16:48  jgrosseo
+ introducing strict run ordering flag
+ removed giving preprocessor name to preprocessor, they have to know their name themselves ;-)
+
+ Revision 1.12  2006/10/20 15:22:59  jgrosseo
+ o) Adding time out to the execution of the preprocessors: The Shuttle forks and the parent process monitors the child
+ o) Merging Collect, CollectAll, CollectNew function
+ o) Removing implementation of empty copy constructors (declaration still there!)
+
  Revision 1.11  2006/10/02 16:38:39  jgrosseo
  update (alberto):
  fixed memory leaks
@@ -103,8 +129,7 @@ Bool_t TerminateSignalHandler::Notify()
 }
 
 //______________________________________________________________________________________________
-AliShuttleTrigger::AliShuttleTrigger(const AliShuttleConfig* config,
-               UInt_t timeout, Int_t retries):
+AliShuttleTrigger::AliShuttleTrigger(const AliShuttleConfig* config):
        fConfig(config), fShuttle(NULL),
        fNotified(kFALSE), fTerminate(kFALSE),
        fMutex(), fCondition(&fMutex),
@@ -118,10 +143,13 @@ AliShuttleTrigger::AliShuttleTrigger(const AliShuttleConfig* config,
        // localStorage (local) CDB storage to be used if mainStorage is unavailable
        //
 
+       if (!fConfig->IsValid()) AliFatal("********** !!!!! Invalid configuration !!!!! **********");
+       UInt_t timeout = fConfig->GetDCSTimeOut();
+       Int_t retries = fConfig->GetDCSRetries();
        fShuttle = new AliShuttle(config, timeout, retries);
 
-  TerminateSignalHandler* fQuitSignalHandler = new TerminateSignalHandler(this, kSigQuit);
-  TerminateSignalHandler* fInterruptSignalHandler = new TerminateSignalHandler(this, kSigInterrupt);
+       fQuitSignalHandler = new TerminateSignalHandler(this, kSigQuit);
+       fInterruptSignalHandler = new TerminateSignalHandler(this, kSigInterrupt);
 
        gSystem->AddSignalHandler(fQuitSignalHandler);
        gSystem->AddSignalHandler(fInterruptSignalHandler);
@@ -184,14 +212,21 @@ void AliShuttleTrigger::Run() {
 
        fTerminate = kFALSE;
 
-       DATENotifier* notifier = new DATENotifier(this, "/DATE/LOGBOOK/UPDATE");
+       DATENotifier* notifier = new DATENotifier(this, "/LOGBOOK/SUBSCRIBE/ECS_EOR");
 
+       Int_t nTry=0; 
+       Int_t nMaxTry = fConfig->GetMaxRetries()+1;
+       Int_t received=0;
+       
+       AliInfo("Listening for ECS trigger");
+       
        while (1) {
        
                fMutex.Lock();
 
                while (!(fNotified || fTerminate)) {
-                       fCondition.Wait();
+                       received=fCondition.TimedWaitRelative(1000*fConfig->GetTriggerWait());
+                       if (received==1) break; // 1 = timeout
                }
 
                fNotified = kFALSE;
@@ -202,6 +237,31 @@ void AliShuttleTrigger::Run() {
                        AliInfo("Terminated.");
                        break;          
                }
+               
+               if (received == 0)
+               {
+                       AliInfo("Trigger from ECS received!");
+               } else if (received == 1) {
+                       AliInfo(Form("Timeout (%d s) waiting for trigger. "
+                               "Starting collection of new runs!", 
+                                       fConfig->GetTriggerWait()));
+               } else {
+                       AliInfo("Error receiving trigger from ECS!");
+                       break;
+               }
+               
+               nTry++;
+               AliInfo(Form("Received %d triggers so far", nTry));
+               
+               if (fConfig->GetRunMode() == AliShuttleConfig::kTest)
+               {
+                       if(nTry>=nMaxTry)
+                       {
+                               AliInfo(Form("Collect() ran more than %d times -> Exiting!", 
+                                               nMaxTry));
+                               break;
+                       }
+               }
        
                Collect();
        }