Client Thread of Storage Manager split into smaller classes. Preparation for moving...
[u/mrichter/AliRoot.git] / MONITOR / alistoragemanager / AliDIMListenerThread.cxx
1 #include "AliDIMListenerThread.h"
2
3 #include <iostream>
4
5 using namespace std;
6
7 AliDIMListenerThread::AliDIMListenerThread()
8 {
9     InitDIMListeners();
10     
11 #ifdef ALI_DATE
12     DimCurrentInfo SORrunNumber("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_1",-1);
13     DimCurrentInfo EORrunNumber("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_1",-1);
14
15     if(SORrunNumber.getData() && EORrunNumber.getData())
16     {
17         cout<<"DIM Listener -- current SOR signal:"<<SORrunNumber.getInt()<<endl;
18         cout<<"DIM Listener -- current EOR signal:"<<EORrunNumber.getInt()<<endl;
19         
20         if(SORrunNumber.getInt() != EORrunNumber.getInt()){StartOfRun(SORrunNumber.getInt());}
21     }
22     else{cout<<"DIM Listener -- no data received from dim server"<<endl;}
23 #endif
24 }
25
26 AliDIMListenerThread::~AliDIMListenerThread()
27 {
28     for (int i = 0; i < 5; ++i){
29         if(fDimSORListener[i]) delete fDimSORListener[i];
30         if(fDimEORListener[i]) delete fDimEORListener[i];
31         
32         fDimSORListener[i] = 0;
33         fDimEORListener[i] = 0;
34     }
35 }
36
37 void AliDIMListenerThread::InitDIMListeners()
38 {
39     for (int i = 0; i < 5; ++i)
40     {
41 #ifdef ALI_DATE
42         if (i == 0)
43         {
44             fDimSORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS");
45             fDimEORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS");
46         }
47         else
48         {
49             fDimSORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_%d", i));
50             fDimEORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_%d", i));
51         }
52         
53         fDimSORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
54         fDimEORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
55 #else
56         fDimSORListener[i]=0x0;
57         fDimEORListener[i]=0x0;
58 #endif
59     }
60     
61 }
62
63 void AliDIMListenerThread::StartOfRun(int run)
64 {
65     cout<<"DIM Listener -- SOR signal received for run:"<<run<<endl;
66 }
67
68 void AliDIMListenerThread::EndOfRun(int run)
69 {
70     cout<<"DIM Listener -- EOR signal received for run:"<<run<<endl;
71 }