]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MONITOR/alionlinemonitor.cxx
Useful macros for the shifter
[u/mrichter/AliRoot.git] / MONITOR / alionlinemonitor.cxx
CommitLineData
c6d78c69 1#include "AliDimIntNotifier.h"
2#include "AliOnlineReco.h"
3
4#include <TRint.h>
5
fb25eab0 6#include <TSQLServer.h>
7#include <TSQLResult.h>
8#include <TSQLRow.h>
9
10#include <TTimeStamp.h>
11
c6d78c69 12int main(int argc, char **argv)
13{
14 AliDimIntNotifier::SetMainThreadId();
15
16 Bool_t test = argc > 1 && strcmp("-test", argv[1]) == 0;
17
18 TRint app("App", &argc, argv);
19
20 AliOnlineReco *win = new AliOnlineReco;
21 win->MapWindow();
22
dc836d53 23 TString autoRun(gSystem->Getenv("ONLINERECO_AUTORUN"));
24 if (autoRun == "1" || autoRun.CompareTo("true", TString::kIgnoreCase) == 0)
25 {
26 win->SetAutoRunMode(kTRUE);
27 }
28
c6d78c69 29 if (test)
30 {
31 win->SetTestMode();
32
e35c7687 33 win->GetSOR(0)->infoHandlerTest(2214);
34 win->GetSOR(0)->infoHandlerTest(2215);
35 win->GetSOR(0)->infoHandlerTest(2224);
36 win->GetSOR(0)->infoHandlerTest(2244);
c6d78c69 37
38 printf("win = (AliOnlineReco*) 0x%lx\n", (unsigned long)win);
39 }
dc836d53 40 else
41 {
a15a9f84 42 TString baseDir = gSystem->Getenv("ONLINERECO_BASE_DIR");
dc836d53 43 if (baseDir.IsNull())
44 {
a15a9f84 45 printf("ERROR: ONLINERECO_BASE_DIR is not set. Exiting...");
46 return 0;
47 }
48
fb25eab0 49 const char *dbHost = "aldaqdb";
50 Int_t dbPort = 3306;
51 const char *dbName = "LOGBOOK";
52 const char *user = "logbook";
53 const char *password = "alice";
54
55 TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password);
56 if (!server) {
57 printf("ERROR: Could not connect to DAQ Logbook");
58 return 0;
59 }
60 TString sqlQuery;
61 TTimeStamp ts;
82142d1d 62 sqlQuery.Form("SELECT run FROM logbook WHERE DAQ_time_start > %u AND DAQ_time_end IS NULL AND partition REGEXP 'PHYSICS.*'",
63 ts.GetSec()-86400);
fb25eab0 64 TSQLResult* result = server->Query(sqlQuery);
dc836d53 65 if (!result)
66 {
fb25eab0 67 printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
68 return 0;
69 }
dc836d53 70 if (result->GetRowCount() == 0)
71 {
fb25eab0 72 printf("No active physics runs found");
73 }
dc836d53 74 else
75 {
76 for (Int_t iRow = 0; iRow < result->GetRowCount(); iRow++)
77 {
fb25eab0 78 TSQLRow* row = result->Next();
79 TString runStr = row->GetField(0);
80 if (runStr.IsDigit())
81 win->StartOfRun(runStr.Atoi());
82 delete row;
83 }
84 }
85 delete result;
86 }
c6d78c69 87
88 app.Run(kTRUE);
89 return 0;
90}