1 #include "AliDIMListenerThread.h"
2 #include "AliStorageTypes.h"
10 AliDIMListenerThread::AliDIMListenerThread() :
13 fOnlineReconstructionHostname(""),
14 fOnlineReconstructionUsername("")
16 ifstream configFile (GetConfigFilePath());
18 if (configFile.is_open())
22 while(configFile.good())
24 getline(configFile,line);
25 from = line.find("\"")+1;
26 to = line.find_last_of("\"");
27 if(line.find("EVENT_SERVER=")==0){fOnlineReconstructionHostname=line.substr(from,to-from);}
28 else if(line.find("EVENT_SERVER_USER=")==0){fOnlineReconstructionUsername=line.substr(from,to-from);}
30 if(configFile.eof()){configFile.clear();}
33 else{cout<<"AliDIMListenerThread -- Unable to open config file"<<endl;}
38 // check if there is a run in partition PHYSICS_1
39 DimCurrentInfo SORrunNumber("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_1",-1);
40 DimCurrentInfo EORrunNumber("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_1",-1);
42 if(SORrunNumber.getData() && EORrunNumber.getData())
44 cout<<"DIM Listener -- current SOR signal:"<<SORrunNumber.getInt()<<endl;
45 cout<<"DIM Listener -- current EOR signal:"<<EORrunNumber.getInt()<<endl;
47 if(SORrunNumber.getInt() != EORrunNumber.getInt()){StartOfRun(SORrunNumber.getInt());}
49 else{cout<<"AliDIMListenerThread -- no data received from dim server"<<endl;}
53 AliDIMListenerThread::~AliDIMListenerThread()
55 if(fDimSORListener){delete fDimSORListener;fDimSORListener = 0;}
56 if(fDimEORListener){delete fDimEORListener;fDimEORListener = 0;}
59 for (int i = 0; i < 5; ++i){
60 if(fDimSORListener[i]) delete fDimSORListener[i];
61 if(fDimEORListener[i]) delete fDimEORListener[i];
63 fDimSORListener[i] = 0;
64 fDimEORListener[i] = 0;
68 void AliDIMListenerThread::InitDIMListeners()
73 for (int i = 0; i < 5; ++i)
78 fDimSORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS");
79 fDimEORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS");
83 fDimSORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_%d", i));
84 fDimEORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_%d", i));
86 fDimSORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
87 fDimEORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
90 fDimSORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_1");
91 fDimEORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_1");
92 fDimSORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
93 fDimEORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
97 void AliDIMListenerThread::StartOfRun(int run)
99 cout<<"AliDIMListenerThread -- SOR signal received for run:"<<run<<endl;
101 // Kill reconstruction and start new one
102 gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco;alionlinereco %d\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str(),run));
105 void AliDIMListenerThread::EndOfRun(int run)
107 cout<<"AliDIMListenerThread -- EOR signal received for run:"<<run<<endl;
109 // kill all running reconstructions (to be changed later)
110 gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str()));