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 cout<<"AliDIMListenerThread -- destructor called...";
56 if(fDimSORListener){delete fDimSORListener;fDimSORListener = 0;}
57 if(fDimEORListener){delete fDimEORListener;fDimEORListener = 0;}
59 // kill all running reconstructions (to be changed later)
60 gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str()));
63 for (int i = 0; i < 5; ++i){
64 if(fDimSORListener[i]) delete fDimSORListener[i];
65 if(fDimEORListener[i]) delete fDimEORListener[i];
67 fDimSORListener[i] = 0;
68 fDimEORListener[i] = 0;
73 void AliDIMListenerThread::InitDIMListeners()
78 for (int i = 0; i < 5; ++i)
83 fDimSORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS");
84 fDimEORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS");
88 fDimSORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_%d", i));
89 fDimEORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_%d", i));
91 fDimSORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
92 fDimEORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
95 fDimSORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_1");
96 fDimEORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_1");
97 fDimSORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
98 fDimEORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
102 void AliDIMListenerThread::StartOfRun(int run)
104 cout<<"AliDIMListenerThread -- SOR signal received for run:"<<run<<endl;
106 // Kill reconstruction and start new one
107 gSystem->Exec(Form("ssh -n -f %s@%s \". ~/EventServerTesting/setEnv.sh;killall alionlinereco;alionlinereco %d\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str(),run));
110 void AliDIMListenerThread::EndOfRun(int run)
112 cout<<"AliDIMListenerThread -- EOR signal received for run:"<<run<<endl;
114 // kill all running reconstructions (to be changed later)
115 gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str()));