1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 #include "AliOnlineRecoTrigger.h"
22 #include "SORNotifier.h"
25 ClassImp(TerminateSignalHandler)
26 ClassImp(AliOnlineRecoTrigger)
28 //______________________________________________________________________________________________
29 Bool_t TerminateSignalHandler::Notify()
31 // Sentd terminate command to the Shuttle trigger
33 AliInfo("Terminate signal received ...");
34 fTrigger->Terminate();
39 //______________________________________________________________________________________________
40 AliOnlineRecoTrigger::AliOnlineRecoTrigger():
41 fNotified(kFALSE), fTerminate(kFALSE),
42 fMutex(), fCondition(&fMutex),
43 fQuitSignalHandler(0),
44 fInterruptSignalHandler(0)
46 // Default constructor
49 fQuitSignalHandler = new TerminateSignalHandler(this, kSigQuit);
50 fInterruptSignalHandler = new TerminateSignalHandler(this, kSigInterrupt);
52 gSystem->AddSignalHandler(fQuitSignalHandler);
53 gSystem->AddSignalHandler(fInterruptSignalHandler);
56 //______________________________________________________________________________________________
57 AliOnlineRecoTrigger::~AliOnlineRecoTrigger()
61 gSystem->RemoveSignalHandler(fQuitSignalHandler);
62 gSystem->RemoveSignalHandler(fInterruptSignalHandler);
64 delete fQuitSignalHandler;
65 fQuitSignalHandler = 0;
67 delete fInterruptSignalHandler;
68 fInterruptSignalHandler = 0;
71 //______________________________________________________________________________________________
72 Bool_t AliOnlineRecoTrigger::Notify() {
74 // The method is called automaticly by SORNotifier on "start of run"
75 // notification event from ECS
88 //______________________________________________________________________________________________
89 void AliOnlineRecoTrigger::Terminate() {
91 // Stop triggers listen mode and exist from Run()
92 // Usually called automaticly by TerminateSignalHandler.
99 //______________________________________________________________________________________________
100 Int_t AliOnlineRecoTrigger::Run() {
102 // AliOnlineRecoTrigger main loop for asynchronized (listen) mode.
103 // It spawns DIM service listener and waits for DAQ "start of run"
110 SORNotifier* notifier = new SORNotifier(this);
114 AliInfo("Listening for ECS SOR trigger");
118 while (!(fNotified || fTerminate)) {
119 received=fCondition.TimedWaitRelative(1000*86400); //wait 24h
120 if (received==1) break; // 1 = timeout
129 run = notifier->GetRun();
134 AliInfo("Terminated.");
140 AliInfo("Trigger from ECS received!");
142 AliError("Invalid run number received!");
146 } else if (received == 1) {
147 AliWarning("Timeout waiting for trigger!");
150 AliError("Error receiving trigger from ECS!");