1 | /* ============================================================
|
---|
2 |
|
---|
3 | Edd - Evidence Data Display
|
---|
4 |
|
---|
5 | Qt-based graphical user interface for the Evidence contron system
|
---|
6 |
|
---|
7 | EddLineDisplay changes its background colour in case it display
|
---|
8 | a DIM status service
|
---|
9 |
|
---|
10 | Note: Currently no limit to number of points in plot, can result in out of memory condition.
|
---|
11 |
|
---|
12 | ============================================================ */
|
---|
13 |
|
---|
14 | #include "Edd.h"
|
---|
15 |
|
---|
16 | QString DRSBoard = "FADctrl";
|
---|
17 | std::string PixelMapText;
|
---|
18 |
|
---|
19 | extern class EddDim *Handler;
|
---|
20 |
|
---|
21 | ////////////////////////
|
---|
22 | // Event oscilloscope //
|
---|
23 | ////////////////////////
|
---|
24 |
|
---|
25 | // Constructor
|
---|
26 | EventScope::EventScope(class TP_DAQ *Page, QWidget *P): EddBasePlot(P), PixelMap(PixelMapText, false) {
|
---|
27 |
|
---|
28 | // Initalise
|
---|
29 | LastPath = ".";
|
---|
30 | Name = DRSBoard+"/EventData";
|
---|
31 | DAQPage = Page;
|
---|
32 | Active = false;
|
---|
33 |
|
---|
34 | // Open temporary files
|
---|
35 | Tmpfile = tmpfile();
|
---|
36 | if(Tmpfile==NULL || !File.open()) {
|
---|
37 | QMessageBox::warning(this, "Edd Message", "Could not open temporary file.", QMessageBox::Ok);
|
---|
38 | return;
|
---|
39 | }
|
---|
40 |
|
---|
41 | // Open file with RawDataCTX
|
---|
42 | RD = new RawDataCTX(true);
|
---|
43 | ErrCode = CTX_NOTOPEN;
|
---|
44 |
|
---|
45 | // Context menu
|
---|
46 | PhysPipeAction = new QAction("Physical pipeline", this);
|
---|
47 | PhysPipeAction->setCheckable(true);
|
---|
48 | connect(PhysPipeAction, SIGNAL(triggered()), SLOT(PlotTraces()));
|
---|
49 | Menu->insertAction(StripAction, PhysPipeAction);
|
---|
50 |
|
---|
51 | PersistanceAction = new QAction("Persistance", this);
|
---|
52 | PersistanceAction->setCheckable(true);
|
---|
53 | Menu->insertAction(StripAction, PersistanceAction);
|
---|
54 | Menu->removeAction(StripAction);
|
---|
55 |
|
---|
56 | // Initial trace
|
---|
57 | AddTrace(0,0,0);
|
---|
58 |
|
---|
59 | // Update interval
|
---|
60 | Timer->setInterval(100);
|
---|
61 | SetActive(true);
|
---|
62 | }
|
---|
63 |
|
---|
64 | // Destructor (items with parent widget are automatically deleted)
|
---|
65 | EventScope::~EventScope() {
|
---|
66 |
|
---|
67 | SetActive(false);
|
---|
68 | while (!List.isEmpty()) DeleteCurve(List.last().Signal);
|
---|
69 | delete RD;
|
---|
70 | if (Tmpfile != NULL) fclose(Tmpfile);
|
---|
71 | }
|
---|
72 |
|
---|
73 | // Add trace
|
---|
74 | void EventScope::AddTrace(int Board, int Chip, int Channel) {
|
---|
75 |
|
---|
76 | struct ItemDetails N;
|
---|
77 |
|
---|
78 | N.Signal = NewCurve(QString::number(Board)+","+QString::number(Chip)+","+ QString::number(Channel)+ " (" + ToPixel(0, Board, Chip, Channel) + ")");
|
---|
79 | N.Board = Board;
|
---|
80 | N.Chip = Chip;
|
---|
81 | N.Channel = Channel;
|
---|
82 | N.Trigger = new QwtPlotMarker();
|
---|
83 | N.Trigger->setSymbol(QwtSymbol(QwtSymbol::Diamond, QBrush(N.Signal->pen().color()), N.Signal->pen(), QSize(10,10)));
|
---|
84 | N.Trigger->attach(this);
|
---|
85 |
|
---|
86 | if (List.isEmpty()) {
|
---|
87 | QPen Pen = N.Signal->pen();
|
---|
88 | Pen.setWidth(2);
|
---|
89 | N.Signal->setPen(Pen);
|
---|
90 | }
|
---|
91 | List.append(N);
|
---|
92 |
|
---|
93 | PlotTraces();
|
---|
94 | }
|
---|
95 |
|
---|
96 | // Update last trace (to reflect current setting of spin boxes in DAQ page)
|
---|
97 | void EventScope::UpdateFirst(int Board, int Chip, int Channel) {
|
---|
98 |
|
---|
99 | if (List.isEmpty()) return;
|
---|
100 |
|
---|
101 | // Clear in case persistance was activated
|
---|
102 | ClearCurve(0);
|
---|
103 |
|
---|
104 | List.first().Signal->setTitle(QString::number(Board)+","+QString::number(Chip)+","+ QString::number(Channel) + " (" + ToPixel(0, Board, Chip, Channel) + ")");
|
---|
105 | List.first().Board = Board;
|
---|
106 | List.first().Chip = Chip;
|
---|
107 | List.first().Channel = Channel;
|
---|
108 |
|
---|
109 | PlotTraces();
|
---|
110 | }
|
---|
111 |
|
---|
112 | // Update event buffer
|
---|
113 | void EventScope::Update(const QString &, int Time, const QByteArray &Data, const QString &Format, const QString &, int) {
|
---|
114 |
|
---|
115 | // Check if service available
|
---|
116 | if (!SetStatus(this, Name, Time, Format)) return;
|
---|
117 | if (Data.size() < (int) sizeof(RunHeader)) return;
|
---|
118 |
|
---|
119 | // Ignore further data while processing this one
|
---|
120 | Handler->Ignore(Name, true);
|
---|
121 |
|
---|
122 | // Clear temporary file and write event data to this file
|
---|
123 | File.resize(0);
|
---|
124 | if (File.write(Data) == -1) {
|
---|
125 | QMessageBox::warning(this, "Edd Message","Could not write data to temporary file.",QMessageBox::Ok);
|
---|
126 | return;
|
---|
127 | }
|
---|
128 | File.flush();
|
---|
129 |
|
---|
130 | // Open temporary raw data file
|
---|
131 | OpenRawFile(File.fileName());
|
---|
132 |
|
---|
133 |
|
---|
134 | // Process all pending events, then allow data again
|
---|
135 | QApplication::processEvents();
|
---|
136 | Handler->Ignore(Name, false);
|
---|
137 | }
|
---|
138 |
|
---|
139 |
|
---|
140 | // New event number selected in raw data browser
|
---|
141 | void EventScope::OpenRawFile(QString Filename) {
|
---|
142 |
|
---|
143 | // Request filename to open if none given
|
---|
144 | if (Filename.isEmpty()) {
|
---|
145 | Filename = QFileDialog::getOpenFileName(this, "Open raw file", LastPath, "Raw data files (*.raw);; All files (*)");
|
---|
146 | if (Filename == NULL) return;
|
---|
147 | }
|
---|
148 |
|
---|
149 | DAQPage->FilenameBox->setText(Filename);
|
---|
150 | LastPath = QFileInfo(Filename).absolutePath();
|
---|
151 |
|
---|
152 | // Prepare temporary file for run header
|
---|
153 | ftruncate(fileno(Tmpfile), 0);
|
---|
154 | rewind(Tmpfile);
|
---|
155 |
|
---|
156 | // Write run header to temporary file
|
---|
157 | switch (ErrCode = RD->OpenDataFile(Filename.toAscii().data(), Tmpfile)) {
|
---|
158 | case CTX_FOPEN: QMessageBox::warning(this, "Edd Message","Could not open file.",QMessageBox::Ok);
|
---|
159 | return;
|
---|
160 | case CTX_RHEADER: QMessageBox::warning(this, "Edd Message","Could not read run header.",QMessageBox::Ok);
|
---|
161 | return;
|
---|
162 | case CTX_BSTRUCT: QMessageBox::warning(this, "Edd Message","Could not read board structures.",QMessageBox::Ok);
|
---|
163 | return;
|
---|
164 | default: break;
|
---|
165 | }
|
---|
166 | RunHeader *R = RD->RHeader;
|
---|
167 |
|
---|
168 | // Magic number warnings not for online display
|
---|
169 | if (Filename != File.fileName()) {
|
---|
170 | if (R->MagicNum == MAGICNUM_OPEN) {
|
---|
171 | QMessageBox::warning(this, "Edd Message","Magic number in run header indicates that the file has not been closed properly.",QMessageBox::Ok);
|
---|
172 | }
|
---|
173 | if (R->MagicNum == MAGICNUM_ERROR) {
|
---|
174 | QMessageBox::warning(this, "Edd Message","Magic number in run header indicates that an error occurred while writing the file.",QMessageBox::Ok);
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | // Print run header to display
|
---|
179 | rewind(Tmpfile);
|
---|
180 | QTextStream in(Tmpfile);
|
---|
181 | QString text = in.readAll();
|
---|
182 | DAQPage->RunHeaderDisplay->setPlainText(text);
|
---|
183 |
|
---|
184 | // Update spin box ranges on DAQ page
|
---|
185 | DAQPage->Event->setRange(0, R->Events-1);
|
---|
186 | DAQPage->Event->setEnabled(true);
|
---|
187 |
|
---|
188 | DAQPage->Channel->setRange(0, R->NChannels-1);
|
---|
189 | DAQPage->Chip->setRange(0, R->NChips-1);
|
---|
190 | DAQPage->Board->setRange(0, R->NBoards-1);
|
---|
191 |
|
---|
192 | // Display first event
|
---|
193 | NewEventNum(DAQPage->Channel->value());
|
---|
194 | }
|
---|
195 |
|
---|
196 | // New event number selected in raw data browser
|
---|
197 | void EventScope::NewEventNum(int Event) {
|
---|
198 |
|
---|
199 | // Prepare temporary file for event header
|
---|
200 | ftruncate(fileno(Tmpfile), 0);
|
---|
201 | rewind(Tmpfile);
|
---|
202 |
|
---|
203 | // Read event
|
---|
204 | if (RD->ReadEvent(Event, Tmpfile) != CTX_OK) {
|
---|
205 | QMessageBox::warning(this, "Edd Message","Could not read event.",QMessageBox::Ok);
|
---|
206 | DAQPage->EventHeaderDisplay->clear();
|
---|
207 | return;
|
---|
208 | }
|
---|
209 |
|
---|
210 | // Plot traces for event
|
---|
211 | PlotTraces();
|
---|
212 | }
|
---|
213 |
|
---|
214 | // Update curves
|
---|
215 | void EventScope::PlotTraces() {
|
---|
216 |
|
---|
217 | double x,y;
|
---|
218 | unsigned int Cell, Trig;
|
---|
219 | static int Last = 0;
|
---|
220 |
|
---|
221 | // Only process if valid data in RawDataCTX class
|
---|
222 | if (ErrCode != CTX_OK) return;
|
---|
223 |
|
---|
224 | // Print event header and trigger cell information from event data
|
---|
225 | rewind(Tmpfile);
|
---|
226 | QTextStream in(Tmpfile);
|
---|
227 | QString text = in.readAll();
|
---|
228 |
|
---|
229 | text.append("\nTrigger cells: ");
|
---|
230 | for (unsigned int i=0; i<RD->RHeader->NBoards*RD->RHeader->NChips; i++) {
|
---|
231 | QString a;
|
---|
232 | text.append(a.sprintf("%d ", *((int *)RD->Data + i)));
|
---|
233 | }
|
---|
234 | DAQPage->EventHeaderDisplay->setPlainText(text);
|
---|
235 |
|
---|
236 | // Set x axis title
|
---|
237 | if (PhysPipeAction->isChecked()) setAxisTitle(QwtPlot::xBottom, "Time from start of pipeline (ns)");
|
---|
238 | else setAxisTitle(QwtPlot::xBottom, "Time from trigger minus one revolution (ns)");
|
---|
239 |
|
---|
240 | // Loop through event data to update event scope
|
---|
241 | RunHeader *R = RD->RHeader;
|
---|
242 | for (int i=0; i<List.size(); i++) {
|
---|
243 |
|
---|
244 | if (PersistanceAction->isChecked()) List[i].Signal->setStyle(QwtPlotCurve::Dots);
|
---|
245 | else {
|
---|
246 | ClearCurve(i);
|
---|
247 | List[i].Signal->setStyle(QwtPlotCurve::Lines);
|
---|
248 | }
|
---|
249 |
|
---|
250 | // Check if current event contains requested trace
|
---|
251 | if (List[i].Board>=R->NBoards || List[i].Chip>=R->NChips || List[i].Channel>=R->NChannels) continue;
|
---|
252 |
|
---|
253 | // Set trigger marker visibility
|
---|
254 | List[i].Trigger->setVisible(PhysPipeAction->isChecked());
|
---|
255 |
|
---|
256 | // Determine trigger cell
|
---|
257 | Trig = *((int *) RD->Data + List[i].Board*R->NChips + List[i].Chip);
|
---|
258 |
|
---|
259 | // Calulate point of curve
|
---|
260 | for (unsigned int j=0; j<R->Samples; j++) {
|
---|
261 |
|
---|
262 | if (PhysPipeAction->isChecked()) Cell = (j - Trig) % 1024;
|
---|
263 | else Cell = j;
|
---|
264 |
|
---|
265 | x = j / RD->BStruct[List[i].Board].NomFreq;
|
---|
266 | y = *((short *) (RD->Data + R->NBoards*R->NChips*sizeof(int)) +
|
---|
267 | List[i].Board*R->NChips*R->NChannels*R->Samples + List[i].Chip*R->NChannels*R->Samples +
|
---|
268 | List[i].Channel*R->Samples + Cell) * RD->BStruct[List[i].Board].ScaleFactor;
|
---|
269 |
|
---|
270 | AddPoint(i, x, y);
|
---|
271 |
|
---|
272 | // Set trigger point indicator
|
---|
273 | if (Trig == j) List[i].Trigger->setValue(x, y);
|
---|
274 | }
|
---|
275 | }
|
---|
276 |
|
---|
277 | // Limit update rate in persistance mode
|
---|
278 | if (!PersistanceAction->isChecked() || time(NULL) > Last) {
|
---|
279 | UpdatePlot();
|
---|
280 | Last = time(NULL);
|
---|
281 | }
|
---|
282 |
|
---|
283 |
|
---|
284 | // Loop through event data for pixel display
|
---|
285 | QVector<double> Pixel(R->NBoards*R->NChips*R->NChannels);
|
---|
286 | int Count = 0;
|
---|
287 |
|
---|
288 | for (unsigned int Board=0; Board<R->NBoards; Board++) {
|
---|
289 | for (unsigned int Chip=0; Chip<R->NChips; Chip++) {
|
---|
290 | for (unsigned int Channel=0; Channel<R->NChannels; Channel++) {
|
---|
291 | Pixel[Count] = DBL_MIN;
|
---|
292 |
|
---|
293 | for (unsigned int i=0; i<R->Samples; i++) {
|
---|
294 | y = *((short *) (RD->Data + R->NBoards*R->NChips*sizeof(int)) +
|
---|
295 | Board*R->NChips*R->NChannels*R->Samples + Chip*R->NChannels*R->Samples +
|
---|
296 | Channel*R->Samples + i) * RD->BStruct[Board].ScaleFactor;
|
---|
297 |
|
---|
298 | if (y > Pixel[Count]) Pixel[Count] = y;
|
---|
299 | }
|
---|
300 | Count++;
|
---|
301 | }}}
|
---|
302 |
|
---|
303 | emit(PixelData(Pixel));
|
---|
304 | }
|
---|
305 |
|
---|
306 | // Remove list entry
|
---|
307 | void EventScope::DeleteCurve(QwtPlotCurve *Curve) {
|
---|
308 |
|
---|
309 | for (int i=0; i<List.size(); i++) if (List[i].Signal == Curve) {
|
---|
310 | delete List[i].Trigger;
|
---|
311 | List.removeAt(i);
|
---|
312 | }
|
---|
313 | }
|
---|
314 |
|
---|
315 | // Set display active (if inactive, disconnect from server)
|
---|
316 | void EventScope::SetActive(bool State) {
|
---|
317 |
|
---|
318 | if (State && !Active) Handler->Subscribe(DRSBoard+"/EventData", this, -1);
|
---|
319 | if (!State && Active) Handler->Unsubscribe(DRSBoard+"/EventData", this);
|
---|
320 |
|
---|
321 | Active = State;
|
---|
322 | }
|
---|
323 |
|
---|
324 | // Translate FPA ID to Pixel ID (use '-' instead of PM_ERROR_CODE)
|
---|
325 | QString EventScope::ToPixel(unsigned int Crate, unsigned int Board, unsigned int Patch, unsigned int Pixel) {
|
---|
326 |
|
---|
327 | if (FPA_to_Pixel(Crate, Board, Patch, Pixel) == PM_ERROR_CODE) return "-";
|
---|
328 | else return QString::number(FPA_to_Pixel(Crate, Board, Patch, Pixel));
|
---|
329 | }
|
---|
330 |
|
---|
331 | //------------------------------------------------------------------
|
---|
332 | //**************************** Tab pages ***************************
|
---|
333 | //------------------------------------------------------------------
|
---|
334 |
|
---|
335 | //
|
---|
336 | // Environment page (For M0, server was called ARDUINO)
|
---|
337 | //
|
---|
338 | TP_Environment::TP_Environment() {
|
---|
339 |
|
---|
340 | QGridLayout *Layout = new QGridLayout(this);
|
---|
341 | setAttribute(Qt::WA_DeleteOnClose);
|
---|
342 |
|
---|
343 | // Status display
|
---|
344 | EddLineDisplay *Line = new EddLineDisplay("FSCctrl/Message");
|
---|
345 | Line->setMaximumWidth(300);
|
---|
346 | Layout->addWidget(Line, 0, 0, 1, 4);
|
---|
347 |
|
---|
348 | Line = new EddLineDisplay("FSCctrl/Time");
|
---|
349 | Layout->addWidget(Line, 0, 5, 1, 2);
|
---|
350 |
|
---|
351 | // Temperatures
|
---|
352 | EddPlot *Plot = new EddPlot();
|
---|
353 | for (int i=0; i<64; i++) {
|
---|
354 | Line = new EddLineDisplay("FSCctrl/Temperature", i);
|
---|
355 | Line->setMaximumWidth(50);
|
---|
356 | Layout->addWidget(Line, i/8+1, i%8);
|
---|
357 | Plot->AddService("FSCctrl/Temperature", i);
|
---|
358 | }
|
---|
359 | Layout->addWidget(Plot, 0, 10, 22, 15);
|
---|
360 |
|
---|
361 | // Voltages and currents
|
---|
362 | for (int i=0; i<40; i++) {
|
---|
363 | Line = new EddLineDisplay("FSCctrl/Voltage", i);
|
---|
364 | Line->setMaximumWidth(50);
|
---|
365 | Layout->addWidget(Line, i/8+10, i%8);
|
---|
366 |
|
---|
367 | Line = new EddLineDisplay("FSCctrl/Current", i);
|
---|
368 | Line->setMaximumWidth(50);
|
---|
369 | Layout->addWidget(Line, i/8+16, i%8);
|
---|
370 | }
|
---|
371 |
|
---|
372 | // Night sky monitor
|
---|
373 | Line = new EddLineDisplay("SQM/Message");
|
---|
374 | Line->setMaximumWidth(300);
|
---|
375 | Layout->addWidget(Line, 22, 0, 1, 4);
|
---|
376 |
|
---|
377 | Line = new EddLineDisplay("SQM/NSB");
|
---|
378 | Layout->addWidget(Line, 22, 5, 1, 2);
|
---|
379 | }
|
---|
380 |
|
---|
381 | //
|
---|
382 | // Bias page
|
---|
383 | //
|
---|
384 | TP_Bias::TP_Bias() {
|
---|
385 |
|
---|
386 | QGridLayout *Layout = new QGridLayout(this);
|
---|
387 | setAttribute(Qt::WA_DeleteOnClose);
|
---|
388 | EddLineDisplay *Line;
|
---|
389 |
|
---|
390 | EddPlot *Plot = new EddPlot();
|
---|
391 | Plot->setMinimumWidth(400);
|
---|
392 | for (int i=0; i<18; i++) {
|
---|
393 | Line = new EddLineDisplay("Bias/VOLT/ID00", i+64);
|
---|
394 | Layout->addWidget(Line, i%9+1, 0+i/9, 1, 1);
|
---|
395 | Plot->AddService("Bias/VOLT/ID00", i+64);
|
---|
396 |
|
---|
397 | Line = new EddLineDisplay("Bias/VOLT/ID00", i+96);
|
---|
398 | Layout->addWidget(Line, i%9+1, 2+i/9, 1, 1);
|
---|
399 | Plot->AddService("Bias/VOLT/ID00",i+96);
|
---|
400 | }
|
---|
401 |
|
---|
402 | Layout->addWidget(Plot, 0, 4, 12, 3);
|
---|
403 | Line = new EddLineDisplay("Bias/Message");
|
---|
404 | Line->setMaximumWidth(200);
|
---|
405 | Layout->addWidget(Line, 0, 0, 1, 3);
|
---|
406 |
|
---|
407 | EddCommand *Command = new EddCommand("Bias/Command");
|
---|
408 | Layout->addWidget(Command, 10, 0, 1, 4);
|
---|
409 |
|
---|
410 | EddText *Text = new EddText("Bias/ConsoleOut", true);
|
---|
411 | Text->setFixedWidth(400);
|
---|
412 | Layout->addWidget(Text, 11, 0, 4, 4);
|
---|
413 |
|
---|
414 | // Current page
|
---|
415 | EddWindow *Button = new EddWindow("Currents", "Edd - Edd - Bias currents");
|
---|
416 | Layout->addWidget(Button, 13, 4, 1, 1);
|
---|
417 |
|
---|
418 | Plot = new EddPlot();
|
---|
419 |
|
---|
420 | for (int i=0; i<36; i++) {
|
---|
421 | Line = new EddLineDisplay("Bias/MICROAMP/ID00", i+64);
|
---|
422 | Line->setMaximumWidth(60);
|
---|
423 | Button->Layout()->addWidget(Line, i%9, 0+i/9, 1, 1);
|
---|
424 | Plot->AddService("Bias/MICROAMP/ID00", i+64);
|
---|
425 | }
|
---|
426 | Button->Layout()->addWidget(Plot, 0, 4, 30, 12);
|
---|
427 | }
|
---|
428 |
|
---|
429 | //
|
---|
430 | // Feedback page
|
---|
431 | //
|
---|
432 | TP_Feedback::TP_Feedback() {
|
---|
433 |
|
---|
434 | setAttribute(Qt::WA_DeleteOnClose);
|
---|
435 | QGridLayout *Layout = new QGridLayout(this);
|
---|
436 | EddLineDisplay *Line;
|
---|
437 |
|
---|
438 | EddPlot *Plot = new EddPlot();
|
---|
439 | for (int i=0; i<36; i++) {
|
---|
440 | Line = new EddLineDisplay("Feedback/Average", i);
|
---|
441 | Line->setMaximumWidth(60);
|
---|
442 | Layout->addWidget(Line, i%9+2, 0+i/9, 1, 1);
|
---|
443 | Plot->AddService("Feedback/Average", i);
|
---|
444 | }
|
---|
445 | Layout->addWidget(Plot, 0, 4, 12, 10);
|
---|
446 |
|
---|
447 | Line = new EddLineDisplay("Feedback/Message");
|
---|
448 | Line->setMaximumWidth(200);
|
---|
449 | Layout->addWidget(Line, 0, 0, 1, 2);
|
---|
450 |
|
---|
451 | Line = new EddLineDisplay("Feedback/State");
|
---|
452 | Line->setMaximumWidth(150);
|
---|
453 | Layout->addWidget(Line, 1, 0, 1, 2);
|
---|
454 | Line = new EddLineDisplay("Feedback/Count");
|
---|
455 | Line->setMaximumWidth(60);
|
---|
456 | Layout->addWidget(Line, 1, 2);
|
---|
457 |
|
---|
458 | // Details page
|
---|
459 | EddWindow *Button = new EddWindow("Details", "Edd - Feedback Details");
|
---|
460 | Layout->addWidget(Button, 12, 0, 1, 1);
|
---|
461 |
|
---|
462 | Plot = new EddPlot();
|
---|
463 |
|
---|
464 | for (int i=0; i<36; i++) {
|
---|
465 | Line = new EddLineDisplay("Feedback/Sigma", i);
|
---|
466 | Line->setMaximumWidth(60);
|
---|
467 | Button->Layout()->addWidget(Line, i%9, 0+i/9, 1, 1);
|
---|
468 | Plot->AddService("Feedback/Sigma", i);
|
---|
469 |
|
---|
470 | Line = new EddLineDisplay("Feedback/Target", i);
|
---|
471 | Line->setMaximumWidth(60);
|
---|
472 | Button->Layout()->addWidget(Line, i%9+10, 0+i/9, 1, 1);
|
---|
473 |
|
---|
474 | Line = new EddLineDisplay("Feedback/Response", i);
|
---|
475 | Line->setMaximumWidth(60);
|
---|
476 | Button->Layout()->addWidget(Line, i%9+20, 0+i/9, 1, 1);
|
---|
477 | }
|
---|
478 | Button->Layout()->addWidget(Plot, 0, 4, 30, 12);
|
---|
479 | }
|
---|
480 |
|
---|
481 |
|
---|
482 | //
|
---|
483 | // FADctrl page
|
---|
484 | //
|
---|
485 | TP_FADctrl::TP_FADctrl() {
|
---|
486 |
|
---|
487 | QString Board;
|
---|
488 |
|
---|
489 | QScrollArea *scrollArea = new QScrollArea;
|
---|
490 | scrollArea->setBackgroundRole(QPalette::Dark);
|
---|
491 | scrollArea->setWidget(this);
|
---|
492 | setMinimumSize(QSize(0,0));
|
---|
493 |
|
---|
494 | QGridLayout *Layout = new QGridLayout(this);
|
---|
495 | setAttribute(Qt::WA_DeleteOnClose);
|
---|
496 | EddLineDisplay *Line;
|
---|
497 |
|
---|
498 | Line = new EddLineDisplay("FADctrl/Message");
|
---|
499 | Line->setMaximumWidth(200);
|
---|
500 | Layout->addWidget(Line, 0, 0, 1, 3);
|
---|
501 |
|
---|
502 | EddCommand *Command = new EddCommand("FADctrl/Command");
|
---|
503 | Layout->addWidget(Command, 1, 0, 1, 3);
|
---|
504 |
|
---|
505 | EddText *Text = new EddText("FADctrl/ConsoleOut", true);
|
---|
506 | Text->setFixedWidth(400);
|
---|
507 | Layout->addWidget(Text, 2, 0, 4, 4);
|
---|
508 |
|
---|
509 | EddPlot *Plot = new EddPlot();
|
---|
510 | Layout->addWidget(Plot, 2, 4, 4, 4);
|
---|
511 |
|
---|
512 | // Details page
|
---|
513 | EddWindow *Button[2];
|
---|
514 | Button[0] = new EddWindow("Boards 0-19", "Edd - FADctrl - Board 0 to 19");
|
---|
515 | Button[1] = new EddWindow("Boards 20-39", "Edd - FADctrl - Board 20 to 39");
|
---|
516 | Layout->addWidget(Button[0], 7, 0, 1, 1);
|
---|
517 | Layout->addWidget(Button[1], 7, 1, 1, 1);
|
---|
518 |
|
---|
519 | for (int i=0; i<40; i++) {
|
---|
520 | Board = Board.sprintf("FADctrl/Board%.2d/", i);
|
---|
521 | Line = new EddLineDisplay(Board+"Server");
|
---|
522 | Line->setMinimumWidth(90);
|
---|
523 | Button[i/20]->Layout()->addWidget(Line, i+7, 0, 1, 1);
|
---|
524 |
|
---|
525 | Line = new EddLineDisplay(Board+"BoardID");
|
---|
526 | Line->setMaximumWidth(30);
|
---|
527 | Button[i/20]->Layout()->addWidget(Line, i+7, 1, 1, 1);
|
---|
528 |
|
---|
529 | Line = new EddLineDisplay(Board+"Frequency");
|
---|
530 | Line->setMaximumWidth(40);
|
---|
531 | Button[i/20]->Layout()->addWidget(Line, i+7, 2, 1, 1);
|
---|
532 |
|
---|
533 | for (int j=0; j<4; j++) {
|
---|
534 | Line = new EddLineDisplay(Board+"Lock", j);
|
---|
535 | Line->setMaximumWidth(20);
|
---|
536 | Button[i/20]->Layout()->addWidget(Line, i+7, 3+j, 1, 1);
|
---|
537 | }
|
---|
538 |
|
---|
539 | for (int j=0; j<4; j++) {
|
---|
540 | Plot->AddService(Board+"Temperature", j);
|
---|
541 |
|
---|
542 | Line = new EddLineDisplay(Board+"Temperature", j);
|
---|
543 | Line->setMinimumWidth(40);
|
---|
544 | Button[i/20]->Layout()->addWidget(Line, i+7, 7+j, 1, 1);
|
---|
545 | }
|
---|
546 |
|
---|
547 | Line = new EddLineDisplay(Board+"TriggerNum");
|
---|
548 | Line->setMinimumWidth(40);
|
---|
549 | Button[i/20]->Layout()->addWidget(Line, i+7, 11, 1, 1);
|
---|
550 |
|
---|
551 | Line = new EddLineDisplay(Board+"RateHz");
|
---|
552 | Line->setMinimumWidth(50);
|
---|
553 | Button[i/20]->Layout()->addWidget(Line, i+7, 19, 1, 1);
|
---|
554 |
|
---|
555 | Line = new EddLineDisplay(Board+"Status");
|
---|
556 | Line->setMaximumWidth(150);
|
---|
557 | Button[i/20]->Layout()->addWidget(Line, i+7, 20, 1, 1);
|
---|
558 | }
|
---|
559 | }
|
---|
560 |
|
---|
561 | //
|
---|
562 | // Event scope page
|
---|
563 | //
|
---|
564 | TP_DAQ::TP_DAQ(bool IsBrowser) {
|
---|
565 |
|
---|
566 | EddLineDisplay *Line;
|
---|
567 |
|
---|
568 | setAttribute(Qt::WA_DeleteOnClose);
|
---|
569 | QGridLayout *Layout = new QGridLayout(this);
|
---|
570 |
|
---|
571 | // Event scope
|
---|
572 | Scope = new EventScope(this);
|
---|
573 | Scope->setMinimumWidth(700);
|
---|
574 |
|
---|
575 | if (IsBrowser) Scope->SetActive(false);
|
---|
576 |
|
---|
577 | // FilenameBox must exist also for online browser (but not added to layout)
|
---|
578 | FilenameBox = new QLineEdit();
|
---|
579 |
|
---|
580 | if (!IsBrowser) {
|
---|
581 | // Message service
|
---|
582 | Line = new EddLineDisplay(DRSBoard+"/Message");
|
---|
583 | Line->setMinimumWidth(500);
|
---|
584 | Layout->addWidget(Line, 0, 1, 1, 6);
|
---|
585 |
|
---|
586 | // Run-related information
|
---|
587 | Line = new EddLineDisplay(DRSBoard+"/EventNumber");
|
---|
588 | Line->setMaximumWidth(100);
|
---|
589 | Layout->addWidget(Line, 0, 8, 1, 1);
|
---|
590 | Line = new EddLineDisplay(DRSBoard+"/FileSizeMB");
|
---|
591 | Line->setMaximumWidth(100);
|
---|
592 | Layout->addWidget(Line, 0, 9, 1, 1);
|
---|
593 | }
|
---|
594 | else {
|
---|
595 | // Filename box
|
---|
596 | Layout->addWidget(FilenameBox, 0, 1, 1, 6);
|
---|
597 | connect(FilenameBox, SIGNAL(returnPressed()), SLOT(OpenDataFile()));
|
---|
598 | FilenameBox->setToolTip("Raw data file name");
|
---|
599 |
|
---|
600 | // Browse botton
|
---|
601 | QToolButton *LoadButton = new QToolButton();
|
---|
602 | LoadButton->setToolButtonStyle (Qt::ToolButtonTextOnly);
|
---|
603 | LoadButton->setText("...");
|
---|
604 | Layout->addWidget(LoadButton, 0, 7, 1, 1);
|
---|
605 | connect(LoadButton, SIGNAL(clicked()), Scope, SLOT(OpenRawFile()));
|
---|
606 | LoadButton->setToolTip("Open file dialog to select raw data file");
|
---|
607 | }
|
---|
608 |
|
---|
609 | // Text boxes for run and event header
|
---|
610 | RunHeaderDisplay = new QPlainTextEdit();
|
---|
611 | EventHeaderDisplay = new QPlainTextEdit();
|
---|
612 | RunHeaderDisplay->setReadOnly(true);
|
---|
613 | EventHeaderDisplay->setReadOnly(true);
|
---|
614 |
|
---|
615 | // Tab widget
|
---|
616 | QTabWidget *TabWidget = new QTabWidget();
|
---|
617 | TabWidget->addTab(Scope, "&Signals");
|
---|
618 | TabWidget->addTab(RunHeaderDisplay, "&Run Header");
|
---|
619 | TabWidget->addTab(EventHeaderDisplay, "&Event Header");
|
---|
620 | Layout->addWidget(TabWidget, 1, 1, 7, 12);
|
---|
621 |
|
---|
622 | // Channel number
|
---|
623 | Channel = new QSpinBox;
|
---|
624 | connect(Channel, SIGNAL(valueChanged(int)), SLOT(UpdateScope(int)));
|
---|
625 | Channel->setToolTip("Channel number");
|
---|
626 |
|
---|
627 | // Chip number
|
---|
628 | Chip = new QSpinBox;
|
---|
629 | connect(Chip, SIGNAL(valueChanged(int)), SLOT(UpdateScope(int)));
|
---|
630 | Chip->setToolTip("Chip number");
|
---|
631 |
|
---|
632 | // Board number
|
---|
633 | Board = new QSpinBox;
|
---|
634 | connect(Board, SIGNAL(valueChanged(int)), SLOT(UpdateScope(int)));
|
---|
635 | Board->setToolTip("Board number");
|
---|
636 |
|
---|
637 | // Pixel ID
|
---|
638 | PixelID = new QSpinBox;
|
---|
639 | PixelID->setMaximumWidth(60);
|
---|
640 | PixelID->setRange(-1, 9999);
|
---|
641 | PixelID->setSpecialValueText("n/a");
|
---|
642 | connect(PixelID, SIGNAL(valueChanged(int)), SLOT(TranslatePixelID(int)));
|
---|
643 | PixelID->setToolTip("Pixel identification");
|
---|
644 |
|
---|
645 | // Add trace permanently
|
---|
646 | QPushButton *Button = new QPushButton("Keep trace");
|
---|
647 | Button->setToolTip("Keep trace in display");
|
---|
648 | Button->setMaximumWidth(80);
|
---|
649 | connect(Button, SIGNAL(clicked()), SLOT(KeepCurrent()));
|
---|
650 |
|
---|
651 | // Layout of pixel addressing widgets
|
---|
652 | QFormLayout *FormLayout = new QFormLayout();
|
---|
653 | FormLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
---|
654 | FormLayout->addRow("Board", Board);
|
---|
655 | FormLayout->addRow("Chip", Chip);
|
---|
656 | FormLayout->addRow("Channel", Channel);
|
---|
657 | FormLayout->addRow("Pixel ID", PixelID);
|
---|
658 | FormLayout->addRow("", Button);
|
---|
659 | Layout->addLayout(FormLayout, 0, 0, 4, 1);
|
---|
660 |
|
---|
661 | // Spin box for event number
|
---|
662 | Event = new QSpinBox;
|
---|
663 | Event->setToolTip("Event number");
|
---|
664 | Event->setEnabled (false);
|
---|
665 |
|
---|
666 | // Stop/start button
|
---|
667 | StartStopButton = new QPushButton("Stop");
|
---|
668 | StartStopButton->setToolTip("Start/stop display");
|
---|
669 | StartStopButton->setMaximumWidth(80);
|
---|
670 | StartStopButton->setCheckable(true);
|
---|
671 | QPalette Palette = StartStopButton->palette();
|
---|
672 | Palette.setColor(QPalette::ButtonText, Qt::blue);
|
---|
673 | Palette.setColor(QPalette::Button, Qt::green);
|
---|
674 | StartStopButton->setPalette(Palette);
|
---|
675 | StartStopButton->setFont(QFont("Times", 10, QFont::Bold));
|
---|
676 |
|
---|
677 | if (IsBrowser) {
|
---|
678 | FormLayout = new QFormLayout();
|
---|
679 | FormLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
---|
680 | FormLayout->addRow("Event Num", Event);
|
---|
681 | Layout->addLayout(FormLayout, 6, 0);
|
---|
682 | connect(Event, SIGNAL(valueChanged(int)), Scope, SLOT(NewEventNum(int)));
|
---|
683 | }
|
---|
684 | else {
|
---|
685 | Layout->addWidget(StartStopButton, 6, 0);
|
---|
686 | connect(StartStopButton, SIGNAL(toggled(bool)), SLOT(StartStop(bool)));
|
---|
687 | }
|
---|
688 |
|
---|
689 | // Event display page
|
---|
690 | EddWindow *New = new EddWindow("Pixel display", "Edd - Event display");
|
---|
691 | New->setFont(QFont("Times", 10, QFont::Bold));
|
---|
692 | New->setMaximumWidth(80);
|
---|
693 | New->setToolTip("Show event display window");
|
---|
694 | Layout->addWidget(New, 7, 0);
|
---|
695 |
|
---|
696 | Pixel = new QPushButton *[MAXPIXEL];
|
---|
697 | int Count = 0;
|
---|
698 | double x,y;
|
---|
699 |
|
---|
700 | for (int ix=-22; ix<=22; ix++) for (int iy=-19; iy<=20; iy++) {
|
---|
701 | if (Count == MAXPIXEL) break;
|
---|
702 |
|
---|
703 | x = ix*0.866;
|
---|
704 | y = iy - (ix%2==0 ? 0.5:0);
|
---|
705 | if ((pow(x,2)+pow(y,2) >= 395) && !(abs(ix)==22 && iy==7)) continue;
|
---|
706 |
|
---|
707 | //Pixel[Count] = new QPushButton(Display);
|
---|
708 | Pixel[Count] = new QPushButton(New->Window());
|
---|
709 | Pixel[Count]->setAutoFillBackground(true);
|
---|
710 | Pixel[Count]->setGeometry((int) (x*12.5 + 250), (int) (y*12.5 + 250), 10, 10);
|
---|
711 | Pixel[Count]->show();
|
---|
712 | Count++;
|
---|
713 | }
|
---|
714 |
|
---|
715 | // Connect slots for updating displays
|
---|
716 | if (!IsBrowser) StartStop(false);
|
---|
717 | connect(Scope, SIGNAL(PixelData(QVector<double>)), SLOT(SetPixelData(QVector<double>)));
|
---|
718 |
|
---|
719 | // Call to get initial pixel ID correct
|
---|
720 | UpdateScope(0);
|
---|
721 | }
|
---|
722 |
|
---|
723 | TP_DAQ::~TP_DAQ() {
|
---|
724 |
|
---|
725 | delete[] Pixel;
|
---|
726 | }
|
---|
727 |
|
---|
728 | // Translate pixel ID to board, chip, channel
|
---|
729 | void TP_DAQ::TranslatePixelID(int ID) {
|
---|
730 |
|
---|
731 | // setValue() below will call UpdateScope() through signal, therefore need to store numbers here
|
---|
732 | unsigned int BoardNo = Scope->Pixel_to_FPAboard(ID);
|
---|
733 | unsigned int PatchNo = Scope->Pixel_to_FPApatch(ID);
|
---|
734 | unsigned int PixelNo = Scope->Pixel_to_FPApixel(ID);
|
---|
735 |
|
---|
736 | if (BoardNo == Scope->PM_ERROR_CODE) PixelID->setValue(-1);
|
---|
737 | else {
|
---|
738 | Board->setValue(BoardNo);
|
---|
739 | Chip->setValue(PatchNo);
|
---|
740 | Channel->setValue(PixelNo);
|
---|
741 | }
|
---|
742 | }
|
---|
743 |
|
---|
744 | // Keep current trace
|
---|
745 | void TP_DAQ::KeepCurrent() {
|
---|
746 |
|
---|
747 | Scope->AddTrace(Board->value(), Chip->value(), Channel->value());
|
---|
748 | }
|
---|
749 |
|
---|
750 | // Start/stop event acquisition
|
---|
751 | void TP_DAQ::StartStop(bool State) {
|
---|
752 |
|
---|
753 | Scope->SetActive(!State);
|
---|
754 | StartStopButton->setText(State ? "Start" : "Stop");
|
---|
755 | }
|
---|
756 |
|
---|
757 | // Open raw data file
|
---|
758 | void TP_DAQ::OpenDataFile() {
|
---|
759 |
|
---|
760 | Scope->OpenRawFile(FilenameBox->text());
|
---|
761 | }
|
---|
762 |
|
---|
763 | // Update event scope
|
---|
764 | void TP_DAQ::UpdateScope(int) {
|
---|
765 |
|
---|
766 | // Update pixel ID
|
---|
767 | PixelID->setValue(Scope->FPA_to_Pixel(0, Board->value(), Chip->value(), Channel->value()));
|
---|
768 | if (PixelID->value() == (int) Scope->PM_ERROR_CODE) PixelID->setValue(-1);
|
---|
769 |
|
---|
770 | // Update first trace
|
---|
771 | Scope->UpdateFirst(Board->value(), Chip->value(), Channel->value());
|
---|
772 | }
|
---|
773 |
|
---|
774 | // Show/hide pixel display
|
---|
775 | void TP_DAQ::ShowPixelDisplay() {
|
---|
776 |
|
---|
777 | Display->show();
|
---|
778 | Display->raise();
|
---|
779 | }
|
---|
780 |
|
---|
781 | void TP_DAQ::SetPixelData(QVector<double> Data) {
|
---|
782 |
|
---|
783 | QwtLinearColorMap Map;
|
---|
784 |
|
---|
785 | for (int i=0; i<Data.size(); i++) {
|
---|
786 | Pixel[i]->setPalette(QPalette(Map.color(QwtDoubleInterval(300, 400), Data[i])));
|
---|
787 | }
|
---|
788 | }
|
---|
789 |
|
---|
790 |
|
---|
791 | //
|
---|
792 | // Evidence page
|
---|
793 | //
|
---|
794 | TP_Evidence::TP_Evidence() {
|
---|
795 |
|
---|
796 | setAttribute(Qt::WA_DeleteOnClose);
|
---|
797 | QGridLayout *Layout = new QGridLayout(this);
|
---|
798 | EddLineDisplay *Line;
|
---|
799 | EddText *Text;
|
---|
800 |
|
---|
801 | Line = new EddLineDisplay("Alarm/Message");
|
---|
802 | Line->setMaximumWidth(200);
|
---|
803 | Layout->addWidget(Line, 0, 0, 1, 2);
|
---|
804 |
|
---|
805 | QPushButton *Button = new QPushButton();
|
---|
806 | Button->setText("ON/OFF");
|
---|
807 | Button->setCheckable(true);
|
---|
808 | connect(Button, SIGNAL(toggled(bool)), SLOT(ToggleAlarm(bool)));
|
---|
809 | Layout->addWidget(Button, 0, 3, 1, 1);
|
---|
810 |
|
---|
811 | Line = new EddLineDisplay("Alarm/MasterAlarm");
|
---|
812 | Layout->addWidget(Line, 0, 1, 1, 1);
|
---|
813 |
|
---|
814 | Text = new EddText("Alarm/Summary", true);
|
---|
815 | Text->Accumulate = false;
|
---|
816 | Text->setMaximumWidth(200);
|
---|
817 | Text->setMaximumHeight(150);
|
---|
818 | Layout->addWidget(Text, 1, 0, 1, 2);
|
---|
819 |
|
---|
820 | Line = new EddLineDisplay("DColl/Message");
|
---|
821 | Line->setMaximumWidth(200);
|
---|
822 | Layout->addWidget(Line, 3, 0, 1, 2);
|
---|
823 |
|
---|
824 | Line = new EddLineDisplay("DColl/DataSizeMB");
|
---|
825 | Layout->addWidget(Line, 4, 0, 1, 1);
|
---|
826 |
|
---|
827 | Line = new EddLineDisplay("DColl/LogSizeMB");
|
---|
828 | Layout->addWidget(Line, 4, 1, 1, 1);
|
---|
829 |
|
---|
830 | Line = new EddLineDisplay("DColl/CurrentFile");
|
---|
831 | Line->setMaximumWidth(400);
|
---|
832 | Layout->addWidget(Line, 5, 0, 1, 3);
|
---|
833 |
|
---|
834 | Line = new EddLineDisplay("Config/Message");
|
---|
835 | Line->setMaximumWidth(200);
|
---|
836 | Layout->addWidget(Line, 6, 0, 1, 2);
|
---|
837 |
|
---|
838 | Line = new EddLineDisplay("Config/ModifyTime");
|
---|
839 | Line->setMaximumWidth(200);
|
---|
840 | Line->ShowAsTime = true;
|
---|
841 | Layout->addWidget(Line, 7, 0, 1, 1);
|
---|
842 |
|
---|
843 | Button = new QPushButton();
|
---|
844 | Button->setText("eLogBook");
|
---|
845 | connect(Button, SIGNAL(released()), SLOT(StartELog()));
|
---|
846 | Layout->addWidget(Button, 6, 1, 1, 1);
|
---|
847 |
|
---|
848 | Button = new QPushButton();
|
---|
849 | Button->setText("DIM browser");
|
---|
850 | connect(Button, SIGNAL(released()), SLOT(StartDIMBrowser()));
|
---|
851 | Layout->addWidget(Button, 7, 1, 1, 1);
|
---|
852 |
|
---|
853 | Line = new EddLineDisplay("Edd/Rate_kBSec");
|
---|
854 | Layout->addWidget(Line, 8, 0, 1, 1);
|
---|
855 | }
|
---|
856 |
|
---|
857 | // Toggle state of Alarm server
|
---|
858 | void TP_Evidence::ToggleAlarm(bool State) {
|
---|
859 |
|
---|
860 | if (State) DimClient::sendCommandNB((char *) "Alarm/Switch", (char *) "off");
|
---|
861 | else DimClient::sendCommandNB((char *) "Alarm/Switch", (char *) "on");
|
---|
862 | }
|
---|
863 |
|
---|
864 | // Start DIM Browser
|
---|
865 | void TP_Evidence::StartDIMBrowser() {
|
---|
866 |
|
---|
867 | QProcess::startDetached("did", QStringList(), QString(getenv("DIMDIR"))+"/linux/");
|
---|
868 | }
|
---|
869 |
|
---|
870 | // Start eLogBook
|
---|
871 | void TP_Evidence::StartELog() {
|
---|
872 |
|
---|
873 | QProcess::startDetached("firefox http://fact.ethz.ch/FACTelog/index.jsp");
|
---|
874 | }
|
---|
875 |
|
---|
876 |
|
---|
877 | //--------------------------------------------------------------------
|
---|
878 | //*************************** Main GUI *******************************
|
---|
879 | //--------------------------------------------------------------------
|
---|
880 | //
|
---|
881 | // All widgets have ultimately Central as parent.
|
---|
882 | //
|
---|
883 | GUI::GUI() {
|
---|
884 |
|
---|
885 | Handler = new EddDim;
|
---|
886 |
|
---|
887 | // Arrangement in tabs
|
---|
888 | TabWidget = new QTabWidget(this);
|
---|
889 | TabWidget->setTabsClosable(true);
|
---|
890 | connect(TabWidget, SIGNAL(tabCloseRequested(int)), SLOT(DetachTab(int)));
|
---|
891 | TabWidget->addTab(new TP_DAQ(false), "Event scope");
|
---|
892 | TabWidget->addTab(new TP_FADctrl, "FADctrl");
|
---|
893 | TabWidget->addTab(new TP_Bias, "Bias");
|
---|
894 | TabWidget->addTab(new TP_Feedback, "Feedback");
|
---|
895 | TabWidget->addTab(new TP_Environment, "FSC/SQM");
|
---|
896 | TabWidget->addTab(new TP_Evidence, "Evidence");
|
---|
897 |
|
---|
898 | // Set features of main window
|
---|
899 | setStatusBar(new QStatusBar(this));
|
---|
900 | setWindowTitle("Edd - Evidence Data Display - Node: " + QString(DimServer::getDnsNode()) + ":" + QString::number(DimServer::getDnsPort()));
|
---|
901 | setCentralWidget(TabWidget);
|
---|
902 |
|
---|
903 | // Menu bar
|
---|
904 | QMenu* Menu = menuBar()->addMenu("&Menu");
|
---|
905 | Menu->addAction("Open history plot", this, SLOT(MenuNewHistory()));
|
---|
906 | Menu->addAction("Send command", this, SLOT(MenuCommand()));
|
---|
907 | Menu->addAction("Raw data browser", this, SLOT(MenuRawDataBrowser()));
|
---|
908 | Menu->addSeparator();
|
---|
909 | Menu->addAction("About", this, SLOT(MenuAbout()));
|
---|
910 | Menu->addSeparator();
|
---|
911 | QAction* QuitAction = Menu->addAction("Quit", qApp, SLOT(quit()));
|
---|
912 | QuitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
|
---|
913 |
|
---|
914 | // Size and show main window
|
---|
915 | QSize Size = TabWidget->sizeHint()*1.1;
|
---|
916 | Size = Size.boundedTo(QApplication::desktop()->screenGeometry(this).size()*0.6);
|
---|
917 | //setMaximumSize(QApplication::desktop()->screenGeometry(this).size()*0.9);
|
---|
918 | TabWidget->resize(Size);
|
---|
919 | TabWidget->setMaximumSize(QApplication::desktop()->screenGeometry(this).size()*0.9);
|
---|
920 | show();
|
---|
921 |
|
---|
922 | // Set timer to regularly check the master alarm
|
---|
923 | QTimer *Timer = new QTimer(this);
|
---|
924 | connect(Timer, SIGNAL(timeout()), this, SLOT(CheckAlarm()));
|
---|
925 | Timer->start(5000);
|
---|
926 | }
|
---|
927 |
|
---|
928 |
|
---|
929 | void GUI::MenuAbout() {
|
---|
930 | QString Rev(SVN_REVISION);
|
---|
931 | Rev.remove(0,1).chop(2);
|
---|
932 |
|
---|
933 | QMessageBox::about(this, "About Edd","Evidence Data Display\n\n"
|
---|
934 | "Written by Oliver Grimm, IPP, ETH Zurich\n"
|
---|
935 | "This version compiled "__DATE__" ("+Rev+")\n\n"
|
---|
936 | "Graphical user interface implemented with Qt and Qwt.\n"
|
---|
937 | "Evidence control system based on DIM (http://dim.web.cern.ch).\n\n"
|
---|
938 | "Comments to oliver.grimm@phys.ethz.ch.");
|
---|
939 | }
|
---|
940 |
|
---|
941 | // Open new history plot
|
---|
942 | void GUI::MenuNewHistory() {
|
---|
943 |
|
---|
944 | QStringList List;
|
---|
945 | char *Name, *Format;
|
---|
946 | int Type;
|
---|
947 | bool OK;
|
---|
948 |
|
---|
949 | // Find all DIM services and sort
|
---|
950 | getServices("*");
|
---|
951 | while ((Type = getNextService(Name, Format)) != 0) {
|
---|
952 | if (Type==DimSERVICE) List.append(Name);
|
---|
953 | }
|
---|
954 | List.sort();
|
---|
955 |
|
---|
956 | // Open dialog and open history window
|
---|
957 | QString Result = QInputDialog::getItem(this, "Edd Request",
|
---|
958 | "Enter or choose DIM service name (add index separated by colon)", List, 0, true, &OK);
|
---|
959 |
|
---|
960 | // Check if cancelled or empty data
|
---|
961 | List = Result.trimmed().split(":", QString::SkipEmptyParts);
|
---|
962 | if (!OK || List.isEmpty()) return;
|
---|
963 |
|
---|
964 | if (List.size() == 1) OpenHistory(List[0].toAscii().data(), 0);
|
---|
965 | else OpenHistory(List[0].toAscii().data(), atoi(List[1].toAscii().data()));
|
---|
966 | }
|
---|
967 |
|
---|
968 | // Send command selected from list
|
---|
969 | void GUI::MenuCommand() {
|
---|
970 |
|
---|
971 | QStringList List;
|
---|
972 | char *Name, *Format;
|
---|
973 | int Type;
|
---|
974 | bool OK;
|
---|
975 |
|
---|
976 | // Find all DIM commands and sort
|
---|
977 | getServices("*");
|
---|
978 | while ((Type = getNextService(Name, Format)) != 0) {
|
---|
979 | if (Type==DimCOMMAND) List.append(Name);
|
---|
980 | }
|
---|
981 | List.sort();
|
---|
982 |
|
---|
983 | // Open dialog and open window for entering command
|
---|
984 | QString Result = QInputDialog::getItem(this, "Edd Request",
|
---|
985 | "Enter or choose DIM command name", List, 0, true, &OK);
|
---|
986 | if (OK && !Result.isEmpty()) {
|
---|
987 | Result = Result.trimmed();
|
---|
988 |
|
---|
989 | QMainWindow *M = new QMainWindow;
|
---|
990 | M->setCentralWidget(new QWidget(M));
|
---|
991 | M->setStatusBar(new QStatusBar(M));
|
---|
992 | M->setAttribute(Qt::WA_DeleteOnClose);
|
---|
993 | QWidget *W = new EddCommand(Result.toAscii().data());
|
---|
994 | QFormLayout *FormLayout = new QFormLayout(M->centralWidget());
|
---|
995 | FormLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
---|
996 | FormLayout->addRow("Enter argument for " + Result, W);
|
---|
997 | M->show();
|
---|
998 | }
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | // Raw data browser
|
---|
1002 | void GUI::MenuRawDataBrowser() {
|
---|
1003 |
|
---|
1004 | DetachTab(0, true);
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | // Open tab as separate window
|
---|
1008 | void GUI::DetachTab(int Tab, bool IsDAQBrowser) {
|
---|
1009 |
|
---|
1010 | QWidget *W = NULL;
|
---|
1011 | QMainWindow *M = new QMainWindow;
|
---|
1012 |
|
---|
1013 | M->setCentralWidget(new QWidget(M));
|
---|
1014 | M->setStatusBar(new QStatusBar(M));
|
---|
1015 |
|
---|
1016 | switch(Tab) {
|
---|
1017 | case 0: W = new TP_DAQ(IsDAQBrowser); break;
|
---|
1018 | case 1: W = new TP_FADctrl; break;
|
---|
1019 | case 2: W = new TP_Bias; break;
|
---|
1020 | case 3: W = new TP_Feedback; break;
|
---|
1021 | case 4: W = new TP_Environment; break;
|
---|
1022 | case 5: W = new TP_Evidence; break;
|
---|
1023 | default: break;
|
---|
1024 | }
|
---|
1025 |
|
---|
1026 | if (W == NULL) {
|
---|
1027 | delete M->centralWidget();
|
---|
1028 | delete M;
|
---|
1029 | return;
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 | W->setParent(M);
|
---|
1033 | W->resize(size());
|
---|
1034 | M->resize(size());
|
---|
1035 | if (!IsDAQBrowser) M->setWindowTitle("Edd - " + TabWidget->tabText(Tab));
|
---|
1036 | else M->setWindowTitle("Edd - Raw Data Browser");
|
---|
1037 | M->show();
|
---|
1038 |
|
---|
1039 | return;
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 | // Check alarm level and if Alarm server is alive
|
---|
1043 | void GUI::CheckAlarm() {
|
---|
1044 |
|
---|
1045 | static int WarnedLevel = 0;
|
---|
1046 | static bool AlarmServerWarned = false;
|
---|
1047 |
|
---|
1048 | // === Check service Alarm/MasterAlarm ===
|
---|
1049 | DimCurrentInfo MasterAlarm("Alarm/MasterAlarm", -1);
|
---|
1050 |
|
---|
1051 | if (MasterAlarm.getInt() > WarnedLevel) {
|
---|
1052 | QSound::play(QApplication::applicationDirPath() + "/Error.wav");
|
---|
1053 |
|
---|
1054 | // Construct warning message box
|
---|
1055 | QMessageBox Box;
|
---|
1056 | Box.setWindowTitle("Edd Alarm");
|
---|
1057 | Box.setText("Service 'Alarm/MasterAlarm' is at " + QString::number(MasterAlarm.getInt()));
|
---|
1058 | Box.setInformativeText("Warn again for the same alarm level?");
|
---|
1059 | Box.setIcon(QMessageBox::Warning);
|
---|
1060 | Box.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
---|
1061 | Box.setDefaultButton(QMessageBox::No);
|
---|
1062 |
|
---|
1063 | // Check if user wants to reset warned level
|
---|
1064 | if (Box.exec() == QMessageBox::Yes) WarnedLevel = 0;
|
---|
1065 | else WarnedLevel = MasterAlarm.getInt();
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 | // If MasterAlam decreased, lower also warned level
|
---|
1069 | if (MasterAlarm.getInt() < WarnedLevel && MasterAlarm.getInt() >=0 ) WarnedLevel = MasterAlarm.getInt();
|
---|
1070 |
|
---|
1071 | // === Check Alarm server ===
|
---|
1072 | DimCurrentInfo ServerList("DIS_DNS/SERVER_LIST", NO_LINK);
|
---|
1073 | std::string Result = EvidenceServer::ToString((char *) "C", ServerList.getData(), ServerList.getSize());
|
---|
1074 |
|
---|
1075 | // Warn if SERVER_LIST does not contain alarm server
|
---|
1076 | if (Result.find("Alarm@") == std::string::npos && !AlarmServerWarned) {
|
---|
1077 | QMessageBox Box;
|
---|
1078 | Box.setWindowTitle("Edd Alarm");
|
---|
1079 | Box.setText("Alarm server is unavailable or in error");
|
---|
1080 | Box.setIcon(QMessageBox::Critical);
|
---|
1081 | Box.setStandardButtons(QMessageBox::Ok);
|
---|
1082 | Box.setDefaultButton(QMessageBox::Ok);
|
---|
1083 | Box.exec();
|
---|
1084 |
|
---|
1085 | AlarmServerWarned = true;
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 | if (Result.find("Alarm@") != std::string::npos) AlarmServerWarned = false;
|
---|
1089 | }
|
---|
1090 |
|
---|
1091 | // Quit application when clicking close button on window
|
---|
1092 | void GUI::closeEvent(QCloseEvent *) {
|
---|
1093 |
|
---|
1094 | qApp->quit();
|
---|
1095 | }
|
---|
1096 |
|
---|
1097 |
|
---|
1098 | //
|
---|
1099 | //**************************** Main program ***************************
|
---|
1100 | //
|
---|
1101 | int main(int argc, char *argv[]) {
|
---|
1102 |
|
---|
1103 | if (argc>1 && strcmp(argv[1],"drsdaq")==0) DRSBoard = "drsdaq";
|
---|
1104 |
|
---|
1105 | // Make RPC to get pixelmap
|
---|
1106 | DimRpcInfo RPC((char *) "ConfigRequest", (char *) "");
|
---|
1107 | RPC.setData((char *) "Misc PixelMap");
|
---|
1108 | PixelMapText = std::string(RPC.getString(), RPC.getSize());
|
---|
1109 |
|
---|
1110 | QApplication app(argc, argv);
|
---|
1111 | GUI MainWindow;
|
---|
1112 |
|
---|
1113 | return app.exec();
|
---|
1114 | }
|
---|