Merging STORAGE-dev to master
[u/mrichter/AliRoot.git] / MONITOR / alistoragemanager / AliStorageAdministratorPanelListEvents.cxx
CommitLineData
5eb34a26 1#include "AliStorageAdministratorPanelListEvents.h"
2
3#include <iostream>
4#include <sstream>
5#include <vector>
6
7#include <TG3DLine.h>
8#include <TGButton.h>
9#include <TGFrame.h>
10
5eb34a26 11using namespace std;
5eb34a26 12
13AliStorageAdministratorPanelListEvents *AliStorageAdministratorPanelListEvents::fInstance=0;
14
15ClassImp(AliStorageAdministratorPanelListEvents);
16
17#define WINDOWS_WIDTH 400
18#define WINDOWS_HEIGHT 500
19
20enum BUTTON{
21 BUTTON_CLOSE=1,
22 BUTTON_GET_LIST,
23 BUTTON_CHECK_PP,
24 BUTTON_CHECK_PBPB,
25 BUTTON_CHECK_TEMP,
26 BUTTON_CHECK_PERM,
164d3d29 27 BUTTON_MARK_EVENT,
28 BUTTON_LOAD_EVENT
5eb34a26 29};
30
31enum TEXTENTRY{
32 TEXTENTRY_RUN_MIN=1,
33 TEXTENTRY_RUN_MAX,
34 TEXTENTRY_EVENT_MIN,
35 TEXTENTRY_EVENT_MAX,
36 TEXTENTRY_MULTIPLICITY_MIN,
37 TEXTENTRY_MULTIPLICITY_MAX
38};
39
40AliStorageAdministratorPanelListEvents::AliStorageAdministratorPanelListEvents() :
41 TGMainFrame(gClient->GetRoot(),400,400),
42 fStatusLabel(0),
43 fRunNumberMinEntry(0),
44 fRunNumberMaxEntry(0),
45 fEventNumberMinEntry(0),
46 fEventNumberMaxEntry(0),
47 fMultiplicityMinEntry(0),
48 fMultiplicityMaxEntry(0),
49 fProtonProtonCheckButton(0),
50 fLeadLeadCheckButton(0),
51 fTempCheckButton(0),
52 fPermCheckButton(0),
53 fEventsList(0),
54 fEventsListVector(0),
164d3d29 55 fServerSocket(SERVER_COMMUNICATION_REQ),
5eb34a26 56 fEventManager(0)
57{
164d3d29 58 fEventManager = AliStorageEventManager::GetEventManagerInstance();
59 fEventManager->CreateSocket(fServerSocket);
5eb34a26 60 InitWindow();
61}
62
63AliStorageAdministratorPanelListEvents::~AliStorageAdministratorPanelListEvents()
64{
65 cout<<"ADMIN PANEL -- List events descructor called";
5eb34a26 66 cout<<" --- OK"<<endl;
67}
68
69AliStorageAdministratorPanelListEvents* AliStorageAdministratorPanelListEvents::GetInstance()
70{
71 if(!fInstance){fInstance = new AliStorageAdministratorPanelListEvents();}
72 return fInstance;
73}
74
164d3d29 75
76void AliStorageAdministratorPanelListEvents::SelectedEvent()
5eb34a26 77{
164d3d29 78 Emit("SelectedEvent()");
5eb34a26 79}
80
81void AliStorageAdministratorPanelListEvents::InitWindow()
82{
83 SetCleanup(kDeepCleanup);
84
85 //min run number
86 AddFrame(new TGLabel(this,"Minimum run number:"),new TGLayoutHints(kLHintsLeft));
87
88 fRunNumberMinEntry = new TGNumberEntry(this,
89 0,
90 6,
91 TEXTENTRY_RUN_MIN,
92 TGNumberFormat::kNESInteger,
93 TGNumberFormat::kNEAPositive,
94 TGNumberFormat::kNELNoLimits);
95 AddFrame(fRunNumberMinEntry,new TGLayoutHints(kLHintsLeft));
96
97 //max run number
98 AddFrame(new TGLabel(this,"Maximum run number:"),new TGLayoutHints(kLHintsLeft));
99
100 fRunNumberMaxEntry = new TGNumberEntry(this,
101 999999,
102 6,
103 TEXTENTRY_RUN_MAX,
104 TGNumberFormat::kNESInteger,
105 TGNumberFormat::kNEAPositive,
106 TGNumberFormat::kNELNoLimits);
107 AddFrame(fRunNumberMaxEntry,new TGLayoutHints(kLHintsLeft));
108
109 //min event number
110 AddFrame(new TGLabel(this,"Minimum event number:"),new TGLayoutHints(kLHintsLeft));
111
112 fEventNumberMinEntry = new TGNumberEntry(this,
113 0,
114 6,
115 TEXTENTRY_EVENT_MIN,
116 TGNumberFormat::kNESInteger,
117 TGNumberFormat::kNEAPositive,
118 TGNumberFormat::kNELNoLimits);
119 AddFrame(fEventNumberMinEntry,new TGLayoutHints(kLHintsLeft));
120
121 //max event number
122 AddFrame(new TGLabel(this,"Maximum event number:"),new TGLayoutHints(kLHintsLeft));
123
124 fEventNumberMaxEntry = new TGNumberEntry(this,
125 99999,
126 6,
127 TEXTENTRY_EVENT_MAX,
128 TGNumberFormat::kNESInteger,
129 TGNumberFormat::kNEAPositive,
130 TGNumberFormat::kNELNoLimits);
131 AddFrame(fEventNumberMaxEntry,new TGLayoutHints(kLHintsLeft));
132
133 //min multiplicity
134 AddFrame(new TGLabel(this,"Minimum multiplicity:"),new TGLayoutHints(kLHintsLeft));
135
136 fMultiplicityMinEntry = new TGNumberEntry(this,
137 0,
138 6,
139 TEXTENTRY_MULTIPLICITY_MIN,
140 TGNumberFormat::kNESInteger,
141 TGNumberFormat::kNEAPositive,
142 TGNumberFormat::kNELNoLimits);
143 AddFrame(fMultiplicityMinEntry,new TGLayoutHints(kLHintsLeft));
144
145 //max multiplicity
146 AddFrame(new TGLabel(this,"Maximum multiplicity:"),new TGLayoutHints(kLHintsLeft));
147
148 fMultiplicityMaxEntry = new TGNumberEntry(this,
149 9999,
150 6,
151 TEXTENTRY_MULTIPLICITY_MAX,
152 TGNumberFormat::kNESInteger,
153 TGNumberFormat::kNEAPositive,
154 TGNumberFormat::kNELNoLimits);
155 AddFrame(fMultiplicityMaxEntry,new TGLayoutHints(kLHintsLeft));
156
157 //p-p check button
158 AddFrame(new TGLabel(this,"System:"),new TGLayoutHints(kLHintsLeft));
159 fProtonProtonCheckButton = new TGCheckButton(this,"p-p",BUTTON_CHECK_PP);
160 fProtonProtonCheckButton->SetOn();
161 AddFrame(fProtonProtonCheckButton,new TGLayoutHints(kLHintsLeft));
162
163 //Pb-Pb check button
164 fLeadLeadCheckButton = new TGCheckButton(this,"Pb-Pb",BUTTON_CHECK_PBPB);
165 fLeadLeadCheckButton->SetOn();
166 AddFrame(fLeadLeadCheckButton,new TGLayoutHints(kLHintsLeft));
167
168 //temp check button
169 AddFrame(new TGLabel(this,"Storage type:"),new TGLayoutHints(kLHintsLeft));
170 fTempCheckButton = new TGCheckButton(this,"Temporary",BUTTON_CHECK_TEMP);
171 fTempCheckButton->SetOn();
172 AddFrame(fTempCheckButton,new TGLayoutHints(kLHintsLeft));
173
174 //perm check button
175 fPermCheckButton = new TGCheckButton(this,"Permanent",BUTTON_CHECK_PERM);
176 fPermCheckButton->SetOn();
177 AddFrame(fPermCheckButton,new TGLayoutHints(kLHintsLeft));
178
179 // status label
180 fStatusLabel = new TGLabel(this,"");
181 AddFrame(fStatusLabel,new TGLayoutHints(kLHintsExpandX | kLHintsLeft));
182
183 //buttons
184 AddFrame(new TGTextButton(this,"Close",BUTTON_CLOSE),
185 new TGLayoutHints(kLHintsLeft));
186
187 AddFrame(new TGTextButton(this,"Get event's list",BUTTON_GET_LIST),
188 new TGLayoutHints(kLHintsRight));
189
190 AddFrame(new TGTextButton(this,"Mark selected event",BUTTON_MARK_EVENT),
191 new TGLayoutHints(kLHintsRight));
192
164d3d29 193 AddFrame(new TGTextButton(this,"Load event",BUTTON_LOAD_EVENT),
194 new TGLayoutHints(kLHintsRight));
195
5eb34a26 196
197 //event's list
198 fEventsList = new TGListBox(this,0);
199 fEventsList->AddEntry(new TGString("Run Event System Mult Marked"),0);
200 AddFrame(fEventsList,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
201
202 SetWindowName("List Events");
203 MapSubwindows();
204 Resize(WINDOWS_WIDTH,WINDOWS_HEIGHT);
205 MapWindow();
206}
207
208
209
210
211void AliStorageAdministratorPanelListEvents::onGetListButton()
212{
213//prepare and send request message
214 struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
215 struct listRequestStruct list;
216
217 //get listing parameters from somwhere
218 list.runNumber[0]=fRunNumberMinEntry->GetIntNumber();
219 list.runNumber[1]=fRunNumberMaxEntry->GetIntNumber();
220 list.eventNumber[0]=fEventNumberMinEntry->GetIntNumber();
221 list.eventNumber[1]=fEventNumberMaxEntry->GetIntNumber();
222 if(fTempCheckButton->GetState()==1)
223 {
224 list.marked[0]=0;
225 }
226 else
227 {
228 list.marked[0]=-1;
229 }
230 if(fPermCheckButton->GetState()==1)
231 {
232 list.marked[1]=1;
233 }
234 else
235 {
236 list.marked[1]=-1;
237 }
238 list.multiplicity[0]=fMultiplicityMinEntry->GetIntNumber();
239 list.multiplicity[1]=fMultiplicityMaxEntry->GetIntNumber();
240 if(fProtonProtonCheckButton->GetState()==1)
241 {
242 strcpy(list.system[0],"p-p");
243 }
244 else
245 {
246 strcpy(list.system[0],"");
247 }
248 if(fLeadLeadCheckButton->GetState()==1)
249 {
250 strcpy(list.system[1],"Pb-Pb");
251 }
252 else
253 {
254 strcpy(list.system[1],"");
255 }
256
257 requestMessage->messageType = REQUEST_LIST_EVENTS;
258 requestMessage->list = list;
259
260 fEventManager->Send(requestMessage,fServerSocket);
261
262 fEventsList->RemoveAll();
263 fEventsList->AddEntry(new TGString("Run Event System Mult Marked"),0);
264
265 vector<serverListStruct> receivedList = fEventManager->GetServerListVector(fServerSocket);
266
267 cout<<"PANEL:"<<receivedList[0].runNumber<<endl;
268 cout<<"VECTOR SIZE:"<<receivedList.size()<<endl;
269
270//do something with list of maching events
271 cout<<"Received list of perm events"<<endl;
272
273 for(unsigned int i=0;i<receivedList.size();i++)
274 {
275 fEventsList->InsertEntry(Form("%d %d %s %d %d ",
276 receivedList[i].runNumber,
277 receivedList[i].eventNumber,
278 receivedList[i].system,
279 receivedList[i].multiplicity,
280 receivedList[i].marked),i+1,i);
281
282 cout<<receivedList[i].runNumber<<receivedList[i].eventNumber<<endl;
283
284 }
285
286 fEventsListVector = receivedList;
287
288 gClient->HandleInput();
289 gClient->NeedRedraw(fEventsList, kTRUE);
290 gClient->HandleInput();
291 MapSubwindows();
292 MapWindow();
293 Layout();
294}
295
296
297void AliStorageAdministratorPanelListEvents::onMarkButton()
298{
299 int runNumber;
300 int eventNumber;
301
302 //get run and event number from selected row
303 int selectedEventNumber = fEventsList->GetSelected()-1;
304
305 cout<<"SELECTED:"<<selectedEventNumber<<endl;
306
307 if(selectedEventNumber<0)return;
308
309 runNumber=fEventsListVector[selectedEventNumber].runNumber;
310 eventNumber=fEventsListVector[selectedEventNumber].eventNumber;
311
312 struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
313 struct eventStruct mark;
314 mark.runNumber = runNumber;
315 mark.eventNumber = eventNumber;
316 requestMessage->messageType = REQUEST_MARK_EVENT;
317 requestMessage->event = mark;
318
319 fEventManager->Send(requestMessage,fServerSocket);
320
164d3d29 321 bool response = fEventManager->GetBool(fServerSocket);
322
323 if(response)
5eb34a26 324 {
325 fStatusLabel->SetText("Event marked");
326 cout<<"ADMIN PANEL -- Event marked succesfully"<<endl;
327 }
328 else
329 {
330 fStatusLabel->SetText("Couldn't mark this event");
331 cout<<"ADMIN PANEL -- Could not matk event"<<endl;
332 }
333}
334
164d3d29 335void AliStorageAdministratorPanelListEvents::onLoadButton()
336{
337 int selectedEventNumber = fEventsList->GetSelected()-1;
338 int runNumber=fEventsListVector[selectedEventNumber].runNumber;
339 int eventNumber=fEventsListVector[selectedEventNumber].eventNumber;
340
341
342 struct serverRequestStruct *requestMessage = new struct serverRequestStruct;
343 struct eventStruct eventToLoad;
344 eventToLoad.runNumber = runNumber;
345 eventToLoad.eventNumber = eventNumber;
346 requestMessage->messageType = REQUEST_GET_EVENT;
347 requestMessage->event = eventToLoad;
348
349 fEventManager->Send(requestMessage,fServerSocket);
350 AliESDEvent *resultEvent = fEventManager->GetEvent(fServerSocket);
351
352 if(resultEvent)
353 {
354 cout<<"ADMIN -- received event"<<endl;
355 fCurrentEvent = resultEvent;
356 }
357 else
358 {
359 cout<<"ADMIN -- received no event"<<endl;
360 }
361
362 SelectedEvent();
363}
364
5eb34a26 365void AliStorageAdministratorPanelListEvents::onCloseButton(){onExit();}
366void AliStorageAdministratorPanelListEvents::CloseWindow(){onExit();}
367
368void AliStorageAdministratorPanelListEvents::onExit()
369{
370 cout<<"Quiting list events";
371 if(fInstance){delete fInstance;fInstance=0;}
372 cout<<" -- OK"<<endl;
373}
374
375Bool_t AliStorageAdministratorPanelListEvents::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
376{
377 switch (GET_MSG(msg))
378 {
379 case kC_COMMAND:
380 switch (GET_SUBMSG(msg))
381 {
382 case kCM_BUTTON:
383 switch(parm1)
384 {
385 case BUTTON_CLOSE:onCloseButton();break;
386 case BUTTON_GET_LIST:onGetListButton();break;
387 case BUTTON_MARK_EVENT:onMarkButton();break;
164d3d29 388 case BUTTON_LOAD_EVENT:onLoadButton();break;
5eb34a26 389 default:break;
390 }
391 break;
392 default:break;
393 }
394 break;
395 default:break;
396 }
397
398 return false;
399}