X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MONITOR%2Falionlinemonitor.cxx;h=1c7c5118e51d4067fff7c0c9137bf57c3e651851;hb=f12dabf047497f243db3d7b57775f2f2b639d2ae;hp=34a38bc560f2ff97533cfd8bcc099773db67a32b;hpb=c6d78c69939da49a77987e98cd062f7c55c25571;p=u%2Fmrichter%2FAliRoot.git diff --git a/MONITOR/alionlinemonitor.cxx b/MONITOR/alionlinemonitor.cxx index 34a38bc560f..1c7c5118e51 100644 --- a/MONITOR/alionlinemonitor.cxx +++ b/MONITOR/alionlinemonitor.cxx @@ -3,6 +3,12 @@ #include +#include +#include +#include + +#include + int main(int argc, char **argv) { AliDimIntNotifier::SetMainThreadId(); @@ -14,17 +20,99 @@ int main(int argc, char **argv) AliOnlineReco *win = new AliOnlineReco; win->MapWindow(); + TString autoRun(gSystem->Getenv("ONLINERECO_AUTORUN")); + if (autoRun == "1" || autoRun.CompareTo("true", TString::kIgnoreCase) == 0) + { + win->SetAutoRunMode(kTRUE); + } + if (test) { win->SetTestMode(); - win->GetSOR()->infoHandlerTest(2214); - win->GetSOR()->infoHandlerTest(2215); - win->GetSOR()->infoHandlerTest(2224); - win->GetSOR()->infoHandlerTest(2244); + win->GetSOR(0)->infoHandlerTest(2214); + win->GetSOR(0)->infoHandlerTest(2215); + win->GetSOR(0)->infoHandlerTest(2224); + win->GetSOR(0)->infoHandlerTest(2244); printf("win = (AliOnlineReco*) 0x%lx\n", (unsigned long)win); } + else + { + TString baseDir = gSystem->Getenv("ONLINERECO_BASE_DIR"); + if (baseDir.IsNull()) + { + printf("ERROR: ONLINERECO_BASE_DIR is not set. Exiting..."); + return 0; + } + + TString dbHost = gSystem->Getenv("ONLINERECO_DB_HOST"); + if (dbHost.IsNull()) + { + printf("ERROR: ONLINERECO_DB_HOST is not set. Exiting..."); + return 0; + } + + TString dbPort = gSystem->Getenv("ONLINERECO_DB_PORT"); + if (dbPort.IsNull()) + { + printf("ERROR: ONLINERECO_DB_PORT is not set. Exiting..."); + return 0; + } + + TString dbName = gSystem->Getenv("ONLINERECO_DB_NAME"); + if (dbName.IsNull()) + { + printf("ERROR: ONLINERECO_DB_NAME is not set. Exiting..."); + return 0; + } + + TString user = gSystem->Getenv("ONLINERECO_DB_USER"); + if (user.IsNull()) + { + printf("ERROR: ONLINERECO_DB_USER is not set. Exiting..."); + return 0; + } + + TString password = gSystem->Getenv("ONLINERECO_DB_PASSWORD"); + if (password.IsNull()) + { + printf("ERROR: ONLINERECO_DB_PASSWORD is not set. Exiting..."); + return 0; + } + + TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%s/%s", dbHost.Data(), dbPort.Data(), dbName.Data()), user.Data(), password.Data()); + if (!server) { + printf("ERROR: Could not connect to DAQ Logbook"); + return 0; + } + TString sqlQuery; + TTimeStamp ts; + sqlQuery.Form("SELECT run FROM logbook WHERE DAQ_time_start > %u AND DAQ_time_end IS NULL AND partition REGEXP 'PHYSICS.*'", + (UInt_t)ts.GetSec()-86400); + TSQLResult* result = server->Query(sqlQuery); + if (!result) + { + printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); + return 0; + } + if (result->GetRowCount() == 0) + { + printf("No active physics runs found"); + } + else + { + for (Int_t iRow = 0; iRow < result->GetRowCount(); iRow++) + { + TSQLRow* row = result->Next(); + TString runStr = row->GetField(0); + if (runStr.IsDigit()) + win->StartOfRun(runStr.Atoi()); + delete row; + } + } + delete result; + } app.Run(kTRUE); return 0;