]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/alionlinemonitor.cxx
Correct path to the AMORE OCDB snapshot. To be defined as env variable after discussi...
[u/mrichter/AliRoot.git] / MONITOR / alionlinemonitor.cxx
1 #include "AliDimIntNotifier.h"
2 #include "AliOnlineReco.h"
3
4 #include <TRint.h>
5
6 #include <TSQLServer.h>
7 #include <TSQLResult.h>
8 #include <TSQLRow.h>
9
10 #include <TTimeStamp.h>
11
12 int 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
23   if (test)
24   {
25     win->SetTestMode();
26
27     win->GetSOR()->infoHandlerTest(2214);
28     win->GetSOR()->infoHandlerTest(2215);
29     win->GetSOR()->infoHandlerTest(2224);
30     win->GetSOR()->infoHandlerTest(2244);
31
32     printf("win = (AliOnlineReco*) 0x%lx\n", (unsigned long)win);
33   }
34   else {
35
36     const char *dbHost = "aldaqdb";
37     Int_t dbPort = 3306;
38     const char *dbName = "LOGBOOK";
39     const char *user = "logbook";
40     const char *password = "alice";
41
42     TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password);
43     if (!server) {
44       printf("ERROR: Could not connect to DAQ Logbook");
45       return 0;
46     }
47     TString sqlQuery;
48     TTimeStamp ts;
49     sqlQuery.Form("SELECT run FROM logbook WHERE DAQ_time_start > %u AND DAQ_time_end IS NULL AND partition = 'PHYSICS'",
50                   ts.GetSec()-86400);
51     TSQLResult* result = server->Query(sqlQuery);
52     if (!result) {
53       printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
54       return 0;
55     }
56     if (result->GetRowCount() == 0) {
57       printf("No active physics runs found");
58     }
59     else {
60       for (Int_t iRow = 0; iRow < result->GetRowCount(); iRow++) {
61         TSQLRow* row = result->Next();
62         TString runStr = row->GetField(0);
63         if (runStr.IsDigit())
64           win->StartOfRun(runStr.Atoi());
65         delete row;
66       }
67     }
68     delete result;
69   }
70
71   app.Run(kTRUE);
72   return 0;
73 }