AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliStorageAdministratorPanelSetStorageParams.cxx
Go to the documentation of this file.
2 #include "AliStorageTypes.h"
3 
4 #include <iostream>
5 
6 #include <TGFrame.h>
7 #include <TGButton.h>
8 
9 using namespace std;
10 
12 
14 
15 #define WINDOWS_WIDTH 200
16 #define WINDOWS_HEIGHT 200
17 
18 enum BUTTON{
21 };
22 
23 enum ENTRY{
28 };
29 
31  TGMainFrame(gClient->GetRoot(), 400, 400),
32  fStatusLabel(0),
33  fMaxStorageSizeEntry(0),
34  fMaxOccupationEntry(0),
35  fRemoveEventsEntry(0),
36  fEventsInChunkEntry(0),
37  fClientSocket(CLIENT_COMMUNICATION_REQ),
38  fEventManager(0)
39 {
41  InitWindow();
42 }
43 
45 
47 {
49  return fInstance;
50 }
51 
52 void AliStorageAdministratorPanelSetStorageParams::Setup(storageSockets socket, int maxStorageSize, int maxOccupation, int removeEvents, int eventsInChunk)
53 {
54  fClientSocket = socket;
55  fMaxStorageSizeEntry->SetIntNumber(maxStorageSize);
56  fMaxOccupationEntry->SetIntNumber(maxOccupation);
57  fRemoveEventsEntry->SetIntNumber(removeEvents);
58  fEventsInChunkEntry->SetIntNumber(eventsInChunk);
59 }
60 
62 {
63  SetCleanup(kDeepCleanup);
64 
65  // max storage size
66  AddFrame(new TGLabel(this,"Max storage size (MB):"),new TGLayoutHints(kLHintsLeft));
67 
68  fMaxStorageSizeEntry = new TGNumberEntry(this,
69  0,
70  6,
72  TGNumberFormat::kNESInteger,
73  TGNumberFormat::kNEAPositive,
74  TGNumberFormat::kNELNoLimits);
75  AddFrame(fMaxStorageSizeEntry,new TGLayoutHints(kLHintsLeft));
76 
77  // max occupation
78  AddFrame(new TGLabel(this,"Max occupation percent (%):"),new TGLayoutHints(kLHintsLeft));
79 
80  fMaxOccupationEntry = new TGNumberEntry(this,
81  0,
82  6,
84  TGNumberFormat::kNESInteger,
85  TGNumberFormat::kNEAPositive,
86  TGNumberFormat::kNELNoLimits);
87  AddFrame(fMaxOccupationEntry,new TGLayoutHints(kLHintsLeft));
88 
89  // remove events percantage
90  AddFrame(new TGLabel(this,"Remove events percentage (%):"),new TGLayoutHints(kLHintsLeft));
91 
92  fRemoveEventsEntry = new TGNumberEntry(this,
93  0,
94  6,
96  TGNumberFormat::kNESInteger,
97  TGNumberFormat::kNEAPositive,
98  TGNumberFormat::kNELNoLimits);
99  AddFrame(fRemoveEventsEntry,new TGLayoutHints(kLHintsLeft));
100 
101  // events in chunk
102  AddFrame(new TGLabel(this,"Number of events in file:"),new TGLayoutHints(kLHintsLeft));
103 
104  fEventsInChunkEntry = new TGNumberEntry(this,
105  0,
106  6,
108  TGNumberFormat::kNESInteger,
109  TGNumberFormat::kNEAPositive,
110  TGNumberFormat::kNELNoLimits);
111  AddFrame(fEventsInChunkEntry,new TGLayoutHints(kLHintsLeft));
112 
113  // status label
114  fStatusLabel = new TGLabel(this,"");
115  AddFrame(fStatusLabel,new TGLayoutHints(kLHintsExpandX | kLHintsLeft));
116 
117  AddFrame(new TGTextButton(this,"Close",BUTTON_CLOSE),
118  new TGLayoutHints(kLHintsLeft));
119 
120  AddFrame(new TGTextButton(this,"Set parameters",BUTTON_SET),
121  new TGLayoutHints(kLHintsRight));
122 
123 
124  SetWindowName("Set Storage Parameters");
125  MapSubwindows();
127  MapWindow();
128 }
129 
130 
131 
132 
134 {
135 
136  struct clientRequestStruct *requestMessage = new struct clientRequestStruct;
137  //get run and event number from TGNumberEntries
138  requestMessage->messageType = REQUEST_SET_PARAMS;
139  requestMessage->maxStorageSize = fMaxStorageSizeEntry->GetIntNumber()*1000000;
140  requestMessage->maxOccupation = fMaxOccupationEntry->GetIntNumber();
141  requestMessage->removeEvents = fRemoveEventsEntry->GetIntNumber();
142  requestMessage->eventsInChunk = fEventsInChunkEntry->GetIntNumber();
143 
144  fEventManager->Send(requestMessage,fClientSocket);
145  bool response;
146  fEventManager->Get(&response,fClientSocket);
147 
148  if(response)
149  {
150  fStatusLabel->SetText("Params set");
151  cout<<"ADMIN PANEL -- Params set succesfully"<<endl;
152  }
153  else
154  {
155  fStatusLabel->SetText("Couldn't set params");
156  cout<<"ADMIN PANEL -- Couldn't set params"<<endl;
157  }
158 }
159 
162 
164 {
165  cout<<"Quiting set storage params";
166  if(fInstance){delete fInstance;fInstance=0;}
167  cout<<" -- OK"<<endl;
168 }
169 
170 Bool_t AliStorageAdministratorPanelSetStorageParams::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
171 {
172  switch (GET_MSG(msg))
173  {
174  case kC_COMMAND:
175  switch (GET_SUBMSG(msg))
176  {
177  case kCM_BUTTON:
178  switch(parm1)
179  {
180  case BUTTON_CLOSE:onCloseButton();break;
181  case BUTTON_SET:onSetParamsButton();break;
182  default:break;
183  }
184  break;
185  default:break;
186  }
187  break;
188  default:break;
189  }
190 
191  return false;
192 }
void Setup(storageSockets socket, int maxStorageSize, int maxOccupation, int removeEvents, int eventsInChunk)
static AliZMQManager * GetInstance()
static AliStorageAdministratorPanelSetStorageParams * GetInstance()
bool Send(std::vector< serverListStruct > list, storageSockets socket)
ClassImp(AliStorageAdministratorPanelSetStorageParams)
static AliStorageAdministratorPanelSetStorageParams * fInstance
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t)
bool Get(std::vector< serverListStruct > *&result, storageSockets socket)