]>
Commit | Line | Data |
---|---|---|
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 | 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 | ||
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 | ||
d6087125 | 49 | TString dbHost = gSystem->Getenv("ONLINERECO_DB_HOST"); |
50 | if (dbHost.IsNull()) | |
51 | { | |
52 | printf("ERROR: ONLINERECO_DB_HOST is not set. Exiting..."); | |
53 | return 0; | |
54 | } | |
55 | ||
56 | TString dbPort = gSystem->Getenv("ONLINERECO_DB_PORT"); | |
57 | if (dbPort.IsNull()) | |
58 | { | |
59 | printf("ERROR: ONLINERECO_DB_PORT is not set. Exiting..."); | |
60 | return 0; | |
61 | } | |
62 | ||
63 | TString dbName = gSystem->Getenv("ONLINERECO_DB_NAME"); | |
64 | if (dbName.IsNull()) | |
65 | { | |
66 | printf("ERROR: ONLINERECO_DB_NAME is not set. Exiting..."); | |
67 | return 0; | |
68 | } | |
69 | ||
70 | TString user = gSystem->Getenv("ONLINERECO_DB_USER"); | |
71 | if (user.IsNull()) | |
72 | { | |
73 | printf("ERROR: ONLINERECO_DB_USER is not set. Exiting..."); | |
74 | return 0; | |
75 | } | |
76 | ||
77 | TString password = gSystem->Getenv("ONLINERECO_DB_PASSWORD"); | |
78 | if (password.IsNull()) | |
79 | { | |
80 | printf("ERROR: ONLINERECO_DB_PASSWORD is not set. Exiting..."); | |
81 | return 0; | |
82 | } | |
fb25eab0 | 83 | |
d6087125 | 84 | TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%s/%s", dbHost.Data(), dbPort.Data(), dbName.Data()), user.Data(), password.Data()); |
fb25eab0 | 85 | if (!server) { |
86 | printf("ERROR: Could not connect to DAQ Logbook"); | |
87 | return 0; | |
88 | } | |
89 | TString sqlQuery; | |
90 | TTimeStamp ts; | |
82142d1d | 91 | sqlQuery.Form("SELECT run FROM logbook WHERE DAQ_time_start > %u AND DAQ_time_end IS NULL AND partition REGEXP 'PHYSICS.*'", |
e849dadd | 92 | (UInt_t)ts.GetSec()-86400); |
fb25eab0 | 93 | TSQLResult* result = server->Query(sqlQuery); |
dc836d53 | 94 | if (!result) |
95 | { | |
fb25eab0 | 96 | printf("ERROR: Can't execute query <%s>!", sqlQuery.Data()); |
97 | return 0; | |
98 | } | |
dc836d53 | 99 | if (result->GetRowCount() == 0) |
100 | { | |
fb25eab0 | 101 | printf("No active physics runs found"); |
102 | } | |
dc836d53 | 103 | else |
104 | { | |
105 | for (Int_t iRow = 0; iRow < result->GetRowCount(); iRow++) | |
106 | { | |
e849dadd | 107 | TSQLRow* row = result->Next(); |
108 | TString runStr = row->GetField(0); | |
109 | if (runStr.IsDigit()) | |
110 | win->StartOfRun(runStr.Atoi()); | |
111 | delete row; | |
fb25eab0 | 112 | } |
113 | } | |
114 | delete result; | |
115 | } | |
c6d78c69 | 116 | |
117 | app.Run(kTRUE); | |
e849dadd | 118 | |
c6d78c69 | 119 | return 0; |
120 | } |