1 | #ifndef FACT_FactGui
|
---|
2 | #define FACT_FactGui
|
---|
3 |
|
---|
4 | #include "MainWindow.h"
|
---|
5 |
|
---|
6 | #include <iomanip>
|
---|
7 | #include <valarray>
|
---|
8 |
|
---|
9 | #include <boost/bind.hpp>
|
---|
10 |
|
---|
11 | #include <QTimer>
|
---|
12 | #include <QStandardItemModel>
|
---|
13 |
|
---|
14 | #include "CheckBoxDelegate.h"
|
---|
15 |
|
---|
16 | #include "src/Dim.h"
|
---|
17 | #include "src/Converter.h"
|
---|
18 | #include "src/HeadersFTM.h"
|
---|
19 | #include "src/HeadersFAD.h"
|
---|
20 | #include "src/DimNetwork.h"
|
---|
21 | #include "src/tools.h"
|
---|
22 | #include "src/FAD.h"
|
---|
23 |
|
---|
24 |
|
---|
25 | #include "TROOT.h"
|
---|
26 | #include "TSystem.h"
|
---|
27 | #include "TGraph.h"
|
---|
28 | #include "TH1.h"
|
---|
29 | #include "TBox.h"
|
---|
30 | #include "TStyle.h"
|
---|
31 | #include "TMarker.h"
|
---|
32 | #include "TColor.h"
|
---|
33 |
|
---|
34 | using namespace std;
|
---|
35 |
|
---|
36 | // #########################################################################
|
---|
37 |
|
---|
38 | class Camera : public TObject
|
---|
39 | {
|
---|
40 | typedef pair<double,double> Position;
|
---|
41 | typedef vector<Position> Positions;
|
---|
42 |
|
---|
43 | Positions fGeom;
|
---|
44 |
|
---|
45 | void CreatePalette()
|
---|
46 | {
|
---|
47 | /*
|
---|
48 | double ss[5] = {0., 0.10, 0.45, 0.75, 1.00};
|
---|
49 | double rr[5] = {0., 0.35, 0.85, 1.00, 1.00};
|
---|
50 | double gg[5] = {0., 0.10, 0.20, 0.73, 1.00};
|
---|
51 | double bb[5] = {0., 0.03, 0.06, 0.00, 1.00};
|
---|
52 | */
|
---|
53 | double ss[5] = {0.00, 0.25, 0.50, 0.75, 1.00};
|
---|
54 | double rr[5] = {0.15, 0.00, 0.00, 1.00, 0.85};
|
---|
55 | double gg[5] = {0.15, 0.00, 1.00, 0.00, 0.85};
|
---|
56 | double bb[5] = {0.15, 1.00, 0.00, 0.00, 0.85};
|
---|
57 |
|
---|
58 | const Int_t nn = 1440;
|
---|
59 |
|
---|
60 | Int_t idx = TColor::CreateGradientColorTable(5, ss, rr, gg, bb, nn);
|
---|
61 | for (int i=0; i<nn; i++)
|
---|
62 | fPalette.push_back(idx++);
|
---|
63 | }
|
---|
64 |
|
---|
65 | void CreateGeometry()
|
---|
66 | {
|
---|
67 | const double gsSin60 = sqrt(3.)/2;
|
---|
68 |
|
---|
69 | const int rings = 23;
|
---|
70 |
|
---|
71 | // add the first pixel to the list
|
---|
72 |
|
---|
73 | fGeom.push_back(make_pair(0, -0.5));
|
---|
74 |
|
---|
75 | for (int ring=1; ring<=rings; ring++)
|
---|
76 | {
|
---|
77 | for (int s=0; s<6; s++)
|
---|
78 | {
|
---|
79 | for (int i=1; i<=ring; i++)
|
---|
80 | {
|
---|
81 | double xx, yy;
|
---|
82 | switch (s)
|
---|
83 | {
|
---|
84 | case 0: // Direction South East
|
---|
85 | xx = (ring+i)*0.5;
|
---|
86 | yy = (-ring+i)*gsSin60;
|
---|
87 | break;
|
---|
88 |
|
---|
89 | case 1: // Direction North East
|
---|
90 | xx = ring-i*0.5;
|
---|
91 | yy = i*gsSin60;
|
---|
92 | break;
|
---|
93 |
|
---|
94 | case 2: // Direction North
|
---|
95 | xx = ring*0.5-i;
|
---|
96 | yy = ring*gsSin60;
|
---|
97 | break;
|
---|
98 |
|
---|
99 | case 3: // Direction North West
|
---|
100 | xx = -(ring+i)*0.5;
|
---|
101 | yy = (ring-i)*gsSin60;
|
---|
102 | break;
|
---|
103 |
|
---|
104 | case 4: // Direction South West
|
---|
105 | xx = 0.5*i-ring;
|
---|
106 | yy = -i*gsSin60;
|
---|
107 | break;
|
---|
108 |
|
---|
109 | case 5: // Direction South
|
---|
110 | xx = i-ring*0.5;
|
---|
111 | yy = -ring*gsSin60;
|
---|
112 | break;
|
---|
113 | }
|
---|
114 |
|
---|
115 | if (xx*xx + yy*yy - xx > 395.75)
|
---|
116 | continue;
|
---|
117 |
|
---|
118 | fGeom.push_back(make_pair(yy, xx-0.5));
|
---|
119 | }
|
---|
120 | }
|
---|
121 | }
|
---|
122 | }
|
---|
123 |
|
---|
124 | valarray<double> fData;
|
---|
125 | vector<bool> fBold;
|
---|
126 | vector<bool> fEnable;
|
---|
127 |
|
---|
128 | int fWhite;
|
---|
129 |
|
---|
130 | int64_t fMin;
|
---|
131 | int64_t fMax;
|
---|
132 |
|
---|
133 | public:
|
---|
134 | Camera() : fData(1440), fBold(1440), fEnable(1440), fWhite(-1), fMin(-1), fMax(-1)
|
---|
135 | {
|
---|
136 | CreatePalette();
|
---|
137 | CreateGeometry();
|
---|
138 |
|
---|
139 | for (int i=0; i<1440; i++)
|
---|
140 | {
|
---|
141 | fData[i] = i;
|
---|
142 | fBold[i]=false;
|
---|
143 | fEnable[i]=true;
|
---|
144 | }
|
---|
145 | }
|
---|
146 |
|
---|
147 | void Reset() { fBold.assign(1440, false); }
|
---|
148 |
|
---|
149 | void SetBold(int idx) { fBold[idx]=true; }
|
---|
150 | void SetWhite(int idx) { fWhite=idx; }
|
---|
151 | void SetEnable(int idx, bool b) { fEnable[idx]=b; }
|
---|
152 | void Toggle(int idx) { fEnable[idx]=!fEnable[idx]; }
|
---|
153 | double GetData(int idx) const { return fData[idx]; }
|
---|
154 | void SetMin(int64_t min) { fMin=min; }
|
---|
155 | void SetMax(int64_t max) { fMax=max; }
|
---|
156 |
|
---|
157 | const char *GetName() const { return "Camera"; }
|
---|
158 |
|
---|
159 | vector<Int_t> fPalette;
|
---|
160 |
|
---|
161 | void Paint(const Position &p)
|
---|
162 | {
|
---|
163 | static const Double_t fgCos60 = 0.5; // TMath::Cos(60/TMath::RadToDeg());
|
---|
164 | static const Double_t fgSin60 = sqrt(3.)/2; // TMath::Sin(60/TMath::RadToDeg());
|
---|
165 |
|
---|
166 | static const Double_t fgDy[6] = { fgCos60, 0., -fgCos60, -fgCos60, 0., fgCos60 };
|
---|
167 | static const Double_t fgDx[6] = { fgSin60/3, fgSin60*2/3, fgSin60/3, -fgSin60/3, -fgSin60*2/3, -fgSin60/3 };
|
---|
168 |
|
---|
169 | //
|
---|
170 | // calculate the positions of the pixel corners
|
---|
171 | //
|
---|
172 | Double_t x[7], y[7];
|
---|
173 | for (Int_t i=0; i<7; i++)
|
---|
174 | {
|
---|
175 | x[i] = p.first + fgDx[i%6];
|
---|
176 | y[i] = p.second + fgDy[i%6];
|
---|
177 | }
|
---|
178 |
|
---|
179 | gPad->PaintFillArea(6, x, y);
|
---|
180 | gPad->PaintPolyLine(7, x, y);
|
---|
181 |
|
---|
182 | }
|
---|
183 |
|
---|
184 | int GetCol(double dmin, double val, double dmax, bool enable)
|
---|
185 | {
|
---|
186 | if (!enable)
|
---|
187 | return kWhite;
|
---|
188 |
|
---|
189 | if (val<dmin)
|
---|
190 | return kBlue+4;//kBlack;
|
---|
191 |
|
---|
192 | if (val>dmax)
|
---|
193 | return kRed+4;//kWhite;
|
---|
194 |
|
---|
195 | const double min = dmin;
|
---|
196 | const double scale = dmax==dmin ? 1 : dmax-dmin;
|
---|
197 |
|
---|
198 | const int col = (val-min)/scale*(fPalette.size()-1);
|
---|
199 |
|
---|
200 | return gStyle->GetColorPalette(col);
|
---|
201 | }
|
---|
202 |
|
---|
203 | void Paint(Option_t *)
|
---|
204 | {
|
---|
205 | gStyle->SetPalette(fPalette.size(), fPalette.data());
|
---|
206 |
|
---|
207 | const double r = double(gPad->GetWw())/gPad->GetWh();
|
---|
208 | const double max = 20.5; // 20.5 rings in x and y
|
---|
209 |
|
---|
210 | if (r>1)
|
---|
211 | gPad->Range(-r*max, -max, r*max, max);
|
---|
212 | else
|
---|
213 | gPad->Range(-max, -max/r, max, max/r);
|
---|
214 |
|
---|
215 | Double_t x1, x2, y1, y2;
|
---|
216 | gPad->GetRange(x1, x2, y1, y2);
|
---|
217 |
|
---|
218 | double dmin = fData[0];
|
---|
219 | double dmax = fData[0];
|
---|
220 |
|
---|
221 | for (unsigned int i=0; i<fData.size(); i++)
|
---|
222 | {
|
---|
223 | if (!fEnable[i])
|
---|
224 | continue;
|
---|
225 |
|
---|
226 | if (fData[i]>dmax)
|
---|
227 | dmax = fData[i];
|
---|
228 | if (fData[i]<dmin)
|
---|
229 | dmin = fData[i];
|
---|
230 | }
|
---|
231 |
|
---|
232 | if (fMin>=0)
|
---|
233 | dmin = fMin;
|
---|
234 | if (fMax>=0)
|
---|
235 | dmax = fMax;
|
---|
236 |
|
---|
237 | // const double min = dmin;
|
---|
238 | // const double scale = dmax==dmin ? 1 : dmax-dmin;
|
---|
239 |
|
---|
240 | TAttFill fill(0, 1001);
|
---|
241 | TAttLine line;
|
---|
242 |
|
---|
243 | int cnt=0;
|
---|
244 | for (Positions::iterator p=fGeom.begin(); p!=fGeom.end(); p++, cnt++)
|
---|
245 | {
|
---|
246 | if (fBold[cnt])
|
---|
247 | continue;
|
---|
248 |
|
---|
249 | const int col = GetCol(dmin, fData[cnt], dmax, fEnable[cnt]);
|
---|
250 |
|
---|
251 | fill.SetFillColor(col);
|
---|
252 | fill.Modify();
|
---|
253 |
|
---|
254 | Paint(*p);
|
---|
255 | }
|
---|
256 |
|
---|
257 | line.SetLineWidth(2);
|
---|
258 | line.Modify();
|
---|
259 |
|
---|
260 | cnt = 0;
|
---|
261 | for (Positions::iterator p=fGeom.begin(); p!=fGeom.end(); p++, cnt++)
|
---|
262 | {
|
---|
263 | if (!fBold[cnt])
|
---|
264 | continue;
|
---|
265 |
|
---|
266 | const int col = GetCol(dmin, fData[cnt], dmax, fEnable[cnt]);
|
---|
267 |
|
---|
268 | fill.SetFillColor(col);
|
---|
269 | fill.Modify();
|
---|
270 |
|
---|
271 | Paint(*p);
|
---|
272 | }
|
---|
273 |
|
---|
274 | TMarker m(0,0,kStar);
|
---|
275 | m.DrawMarker(0, 0);
|
---|
276 |
|
---|
277 | if (fWhite<0)
|
---|
278 | return;
|
---|
279 |
|
---|
280 | const Position &p = fGeom[fWhite];
|
---|
281 |
|
---|
282 | line.SetLineColor(kWhite);
|
---|
283 | line.Modify();
|
---|
284 |
|
---|
285 | const int col = GetCol(dmin, fData[fWhite], dmax, fEnable[fWhite]);
|
---|
286 |
|
---|
287 | fill.SetFillColor(col);
|
---|
288 | fill.Modify();
|
---|
289 |
|
---|
290 | Paint(p);
|
---|
291 | }
|
---|
292 |
|
---|
293 | int GetIdx(float px, float py) const
|
---|
294 | {
|
---|
295 | static const double sqrt3 = sqrt(3);
|
---|
296 |
|
---|
297 | int idx = 0;
|
---|
298 | for (Positions::const_iterator p=fGeom.begin(); p!=fGeom.end(); p++, idx++)
|
---|
299 | {
|
---|
300 | const Double_t dy = py - p->second;
|
---|
301 | if (fabs(dy)>0.5)
|
---|
302 | continue;
|
---|
303 |
|
---|
304 | const Double_t dx = px - p->first;
|
---|
305 |
|
---|
306 | if (TMath::Abs(dy + dx*sqrt3) > 1)
|
---|
307 | continue;
|
---|
308 |
|
---|
309 | if (TMath::Abs(dy - dx*sqrt3) > 1)
|
---|
310 | continue;
|
---|
311 |
|
---|
312 | return idx;
|
---|
313 | }
|
---|
314 | return -1;
|
---|
315 | }
|
---|
316 |
|
---|
317 | char *GetObjectInfo(Int_t px, Int_t py) const
|
---|
318 | {
|
---|
319 | static stringstream stream;
|
---|
320 | static string str;
|
---|
321 |
|
---|
322 | const float x = gPad->AbsPixeltoX(px);
|
---|
323 | const float y = gPad->AbsPixeltoY(py);
|
---|
324 |
|
---|
325 | const int idx = GetIdx(x, y);
|
---|
326 |
|
---|
327 | stream.seekp(0);
|
---|
328 | if (idx>=0)
|
---|
329 | {
|
---|
330 | stream << "Pixel=" << idx << " Data=" << fData[idx] << '\0';
|
---|
331 | }
|
---|
332 |
|
---|
333 | str = stream.str();
|
---|
334 | return const_cast<char*>(str.c_str());
|
---|
335 | }
|
---|
336 |
|
---|
337 | Int_t DistancetoPrimitive(Int_t px, Int_t py)
|
---|
338 | {
|
---|
339 | const float x = gPad->AbsPixeltoX(px);
|
---|
340 | const float y = gPad->AbsPixeltoY(py);
|
---|
341 |
|
---|
342 | return GetIdx(x, y)>=0 ? 0 : 99999;
|
---|
343 | }
|
---|
344 |
|
---|
345 | void SetData(const valarray<double> &data)
|
---|
346 | {
|
---|
347 | fData = data;
|
---|
348 | }
|
---|
349 |
|
---|
350 | void SetData(const float *data)
|
---|
351 | {
|
---|
352 | for (int i=0; i<1440; i++)
|
---|
353 | fData[i] = data[i];
|
---|
354 | }
|
---|
355 | };
|
---|
356 |
|
---|
357 | // #########################################################################
|
---|
358 |
|
---|
359 |
|
---|
360 | class FactGui : public MainWindow, public DimNetwork
|
---|
361 | {
|
---|
362 | private:
|
---|
363 | class FunctionEvent : public QEvent
|
---|
364 | {
|
---|
365 | public:
|
---|
366 | boost::function<void(const QEvent &)> fFunction;
|
---|
367 |
|
---|
368 | FunctionEvent(const boost::function<void(const QEvent &)> &f)
|
---|
369 | : QEvent((QEvent::Type)QEvent::registerEventType()),
|
---|
370 | fFunction(f) { }
|
---|
371 |
|
---|
372 | bool Exec() { fFunction(*this); return true; }
|
---|
373 | };
|
---|
374 |
|
---|
375 | valarray<int8_t> fFtuStatus;
|
---|
376 |
|
---|
377 | vector<int> fPixelMapHW; // Software -> Hardware
|
---|
378 | vector<int> fPatchMapHW; // Software -> Hardware
|
---|
379 | vector<int> fPatchHW; // Maps the software(!) pixel id to the hardware(!) patch id
|
---|
380 |
|
---|
381 | bool fInChoosePatch; // FIXME. Find a better solution
|
---|
382 |
|
---|
383 | DimStampedInfo fDimDNS;
|
---|
384 |
|
---|
385 | DimStampedInfo fDimLoggerStats;
|
---|
386 | DimStampedInfo fDimLoggerFilenameNight;
|
---|
387 | DimStampedInfo fDimLoggerFilenameRun;
|
---|
388 | DimStampedInfo fDimLoggerNumSubs;
|
---|
389 |
|
---|
390 | DimStampedInfo fDimFtmPassport;
|
---|
391 | DimStampedInfo fDimFtmTriggerRates;
|
---|
392 | DimStampedInfo fDimFtmError;
|
---|
393 | DimStampedInfo fDimFtmFtuList;
|
---|
394 | DimStampedInfo fDimFtmStaticData;
|
---|
395 | DimStampedInfo fDimFtmDynamicData;
|
---|
396 | DimStampedInfo fDimFtmCounter;
|
---|
397 |
|
---|
398 | DimStampedInfo fDimFadWriteStats;
|
---|
399 | DimStampedInfo fDimFadRuns;
|
---|
400 | DimStampedInfo fDimFadEvents;
|
---|
401 | DimStampedInfo fDimFadRawData;
|
---|
402 | DimStampedInfo fDimFadEventData;
|
---|
403 | DimStampedInfo fDimFadConnections;
|
---|
404 | DimStampedInfo fDimFadFwVersion;
|
---|
405 | DimStampedInfo fDimFadRunNumber;
|
---|
406 | DimStampedInfo fDimFadDNA;
|
---|
407 | DimStampedInfo fDimFadTemperature;
|
---|
408 | DimStampedInfo fDimFadPrescaler;
|
---|
409 | DimStampedInfo fDimFadRefClock;
|
---|
410 | DimStampedInfo fDimFadRoi;
|
---|
411 | DimStampedInfo fDimFadDac;
|
---|
412 | DimStampedInfo fDimFadDrsCalibration;
|
---|
413 | DimStampedInfo fDimFadStatus;
|
---|
414 | DimStampedInfo fDimFadStatistics1;
|
---|
415 | DimStampedInfo fDimFadStatistics2;
|
---|
416 |
|
---|
417 | map<string, DimInfo*> fServices;
|
---|
418 |
|
---|
419 | // ========================== LED Colors ================================
|
---|
420 |
|
---|
421 | enum LedColor_t
|
---|
422 | {
|
---|
423 | kLedRed,
|
---|
424 | kLedGreen,
|
---|
425 | kLedYellow,
|
---|
426 | kLedOrange,
|
---|
427 | kLedGray
|
---|
428 | };
|
---|
429 |
|
---|
430 | void SetLedColor(QPushButton *button, LedColor_t col, const Time &t)
|
---|
431 | {
|
---|
432 | switch (col)
|
---|
433 | {
|
---|
434 | case kLedRed:
|
---|
435 | button->setIcon(QIcon(":/Resources/icons/red circle 1.png"));
|
---|
436 | break;
|
---|
437 |
|
---|
438 | case kLedGreen:
|
---|
439 | button->setIcon(QIcon(":/Resources/icons/green circle 1.png"));
|
---|
440 | break;
|
---|
441 |
|
---|
442 | case kLedYellow:
|
---|
443 | button->setIcon(QIcon(":/Resources/icons/yellow circle 1.png"));
|
---|
444 | break;
|
---|
445 |
|
---|
446 | case kLedOrange:
|
---|
447 | button->setIcon(QIcon(":/Resources/icons/orange circle 1.png"));
|
---|
448 | break;
|
---|
449 |
|
---|
450 | case kLedGray:
|
---|
451 | button->setIcon(QIcon(":/Resources/icons/gray circle 1.png"));
|
---|
452 | break;
|
---|
453 | }
|
---|
454 |
|
---|
455 | //button->setToolTip("Last change: "+QDateTime::currentDateTimeUtc().toString()+" UTC");
|
---|
456 | button->setToolTip(("Last change: "+t.GetAsStr()+" (UTC)").c_str());
|
---|
457 | }
|
---|
458 |
|
---|
459 | // ===================== Services and Commands ==========================
|
---|
460 |
|
---|
461 | QStandardItem *AddServiceItem(const std::string &server, const std::string &service, bool iscmd)
|
---|
462 | {
|
---|
463 | QListView *servers = iscmd ? fDimCmdServers : fDimSvcServers;
|
---|
464 | QListView *services = iscmd ? fDimCmdCommands : fDimSvcServices;
|
---|
465 | QListView *description = iscmd ? fDimCmdDescription : fDimSvcDescription;
|
---|
466 |
|
---|
467 | QStandardItemModel *m = dynamic_cast<QStandardItemModel*>(servers->model());
|
---|
468 | if (!m)
|
---|
469 | {
|
---|
470 | m = new QStandardItemModel(this);
|
---|
471 | servers->setModel(m);
|
---|
472 | services->setModel(m);
|
---|
473 | description->setModel(m);
|
---|
474 | }
|
---|
475 |
|
---|
476 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
---|
477 |
|
---|
478 | if (l.size()>1)
|
---|
479 | {
|
---|
480 | cout << "hae" << endl;
|
---|
481 | return 0;
|
---|
482 | }
|
---|
483 |
|
---|
484 | QStandardItem *col = l.size()==0 ? NULL : l[0];
|
---|
485 |
|
---|
486 | if (!col)
|
---|
487 | {
|
---|
488 | col = new QStandardItem(server.c_str());
|
---|
489 | m->appendRow(col);
|
---|
490 |
|
---|
491 | if (!services->rootIndex().isValid())
|
---|
492 | {
|
---|
493 | services->setRootIndex(col->index());
|
---|
494 | servers->setCurrentIndex(col->index());
|
---|
495 | }
|
---|
496 | }
|
---|
497 |
|
---|
498 | QStandardItem *item = 0;
|
---|
499 | for (int i=0; i<col->rowCount(); i++)
|
---|
500 | {
|
---|
501 | QStandardItem *coli = col->child(i);
|
---|
502 | if (coli->text().toStdString()==service)
|
---|
503 | return coli;
|
---|
504 | }
|
---|
505 |
|
---|
506 | item = new QStandardItem(service.c_str());
|
---|
507 | col->appendRow(item);
|
---|
508 | col->sortChildren(0);
|
---|
509 |
|
---|
510 | if (!description->rootIndex().isValid())
|
---|
511 | {
|
---|
512 | description->setRootIndex(item->index());
|
---|
513 | services->setCurrentIndex(item->index());
|
---|
514 | }
|
---|
515 |
|
---|
516 | if (!iscmd)
|
---|
517 | item->setCheckable(true);
|
---|
518 |
|
---|
519 | return item;
|
---|
520 | }
|
---|
521 |
|
---|
522 | void AddDescription(QStandardItem *item, const vector<Description> &vec)
|
---|
523 | {
|
---|
524 | if (!item)
|
---|
525 | return;
|
---|
526 | if (vec.size()==0)
|
---|
527 | return;
|
---|
528 |
|
---|
529 | item->setToolTip(vec[0].comment.c_str());
|
---|
530 |
|
---|
531 | const string str = Description::GetHtmlDescription(vec);
|
---|
532 |
|
---|
533 | QStandardItem *desc = new QStandardItem(str.c_str());
|
---|
534 | desc->setSelectable(false);
|
---|
535 | item->setChild(0, 0, desc);
|
---|
536 | }
|
---|
537 |
|
---|
538 | void AddServer(const std::string &s)
|
---|
539 | {
|
---|
540 | DimNetwork::AddServer(s);
|
---|
541 |
|
---|
542 | QApplication::postEvent(this,
|
---|
543 | new FunctionEvent(boost::bind(&FactGui::handleAddServer, this, s)));
|
---|
544 | }
|
---|
545 |
|
---|
546 | void AddService(const std::string &server, const std::string &service, const std::string &fmt, bool iscmd)
|
---|
547 | {
|
---|
548 | QApplication::postEvent(this,
|
---|
549 | new FunctionEvent(boost::bind(&FactGui::handleAddService, this, server, service, fmt, iscmd)));
|
---|
550 | }
|
---|
551 |
|
---|
552 | void RemoveService(std::string server, std::string service, bool iscmd)
|
---|
553 | {
|
---|
554 | UnsubscribeService(server+'/'+service, true);
|
---|
555 |
|
---|
556 | QApplication::postEvent(this,
|
---|
557 | new FunctionEvent(boost::bind(&FactGui::handleRemoveService, this, server, service, iscmd)));
|
---|
558 | }
|
---|
559 |
|
---|
560 | void RemoveAllServices(const std::string &server)
|
---|
561 | {
|
---|
562 | UnsubscribeAllServices(server);
|
---|
563 |
|
---|
564 | QApplication::postEvent(this,
|
---|
565 | new FunctionEvent(boost::bind(&FactGui::handleRemoveAllServices, this, server)));
|
---|
566 | }
|
---|
567 |
|
---|
568 | void AddDescription(const std::string &server, const std::string &service, const vector<Description> &vec)
|
---|
569 | {
|
---|
570 | QApplication::postEvent(this,
|
---|
571 | new FunctionEvent(boost::bind(&FactGui::handleAddDescription, this, server, service, vec)));
|
---|
572 | }
|
---|
573 |
|
---|
574 | // ======================================================================
|
---|
575 |
|
---|
576 | void handleAddServer(const std::string &server)
|
---|
577 | {
|
---|
578 | const State s = GetState(server, GetCurrentState(server));
|
---|
579 | handleStateChanged(Time(), server, s);
|
---|
580 | }
|
---|
581 |
|
---|
582 | void handleAddService(const std::string &server, const std::string &service, const std::string &/*fmt*/, bool iscmd)
|
---|
583 | {
|
---|
584 | QStandardItem *item = AddServiceItem(server, service, iscmd);
|
---|
585 | const vector<Description> v = GetDescription(server, service);
|
---|
586 | AddDescription(item, v);
|
---|
587 | }
|
---|
588 |
|
---|
589 | void handleRemoveService(const std::string &server, const std::string &service, bool iscmd)
|
---|
590 | {
|
---|
591 | QListView *servers = iscmd ? fDimCmdServers : fDimSvcServers;
|
---|
592 |
|
---|
593 | QStandardItemModel *m = dynamic_cast<QStandardItemModel*>(servers->model());
|
---|
594 | if (!m)
|
---|
595 | return;
|
---|
596 |
|
---|
597 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
---|
598 | if (l.size()!=1)
|
---|
599 | return;
|
---|
600 |
|
---|
601 | for (int i=0; i<l[0]->rowCount(); i++)
|
---|
602 | {
|
---|
603 | QStandardItem *row = l[0]->child(i);
|
---|
604 | if (row->text().toStdString()==service)
|
---|
605 | {
|
---|
606 | l[0]->removeRow(row->index().row());
|
---|
607 | return;
|
---|
608 | }
|
---|
609 | }
|
---|
610 | }
|
---|
611 |
|
---|
612 | void handleRemoveAllServices(const std::string &server)
|
---|
613 | {
|
---|
614 | handleStateChanged(Time(), server, State(-2, "Offline", "No connection via DIM."));
|
---|
615 |
|
---|
616 | QStandardItemModel *m = 0;
|
---|
617 | if ((m=dynamic_cast<QStandardItemModel*>(fDimCmdServers->model())))
|
---|
618 | {
|
---|
619 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
---|
620 | if (l.size()==1)
|
---|
621 | m->removeRow(l[0]->index().row());
|
---|
622 | }
|
---|
623 |
|
---|
624 | if ((m = dynamic_cast<QStandardItemModel*>(fDimSvcServers->model())))
|
---|
625 | {
|
---|
626 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
---|
627 | if (l.size()==1)
|
---|
628 | m->removeRow(l[0]->index().row());
|
---|
629 | }
|
---|
630 | }
|
---|
631 |
|
---|
632 | void handleAddDescription(const std::string &server, const std::string &service, const vector<Description> &vec)
|
---|
633 | {
|
---|
634 | const bool iscmd = IsCommand(server, service)==true;
|
---|
635 |
|
---|
636 | QStandardItem *item = AddServiceItem(server, service, iscmd);
|
---|
637 | AddDescription(item, vec);
|
---|
638 | }
|
---|
639 |
|
---|
640 | // ======================================================================
|
---|
641 |
|
---|
642 | void SubscribeService(const string &service)
|
---|
643 | {
|
---|
644 | if (fServices.find(service)!=fServices.end())
|
---|
645 | {
|
---|
646 | cout << "ERROR - We are already subscribed to " << service << endl;
|
---|
647 | return;
|
---|
648 | }
|
---|
649 |
|
---|
650 | fServices[service] = new DimStampedInfo(service.c_str(), (void*)NULL, 0, this);
|
---|
651 | }
|
---|
652 |
|
---|
653 | void UnsubscribeService(const string &service, bool allow_unsubscribed=false)
|
---|
654 | {
|
---|
655 | const map<string,DimInfo*>::iterator i=fServices.find(service);
|
---|
656 |
|
---|
657 | if (i==fServices.end())
|
---|
658 | {
|
---|
659 | if (!allow_unsubscribed)
|
---|
660 | cout << "ERROR - We are not subscribed to " << service << endl;
|
---|
661 | return;
|
---|
662 | }
|
---|
663 |
|
---|
664 | delete i->second;
|
---|
665 |
|
---|
666 | fServices.erase(i);
|
---|
667 | }
|
---|
668 |
|
---|
669 | void UnsubscribeAllServices(const string &server)
|
---|
670 | {
|
---|
671 | for (map<string,DimInfo*>::iterator i=fServices.begin();
|
---|
672 | i!=fServices.end(); i++)
|
---|
673 | if (i->first.substr(0, server.length()+1)==server+'/')
|
---|
674 | {
|
---|
675 | delete i->second;
|
---|
676 | fServices.erase(i);
|
---|
677 | }
|
---|
678 | }
|
---|
679 |
|
---|
680 | // ======================================================================
|
---|
681 |
|
---|
682 | struct DimData
|
---|
683 | {
|
---|
684 | const int qos;
|
---|
685 | const string name;
|
---|
686 | const string format;
|
---|
687 | const vector<char> data;
|
---|
688 | const Time time;
|
---|
689 |
|
---|
690 | Time extract(DimInfo *inf) const
|
---|
691 | {
|
---|
692 | // Must be called in exactly this order!
|
---|
693 | const int tsec = inf->getTimestamp();
|
---|
694 | const int tms = inf->getTimestampMillisecs();
|
---|
695 |
|
---|
696 | return Time(tsec, tms*1000);
|
---|
697 | }
|
---|
698 |
|
---|
699 | // DimInfo *info; // this is ONLY for a fast check of the type of the DimData!!
|
---|
700 |
|
---|
701 | DimData(DimInfo *inf) :
|
---|
702 | qos(inf->getQuality()),
|
---|
703 | name(inf->getName()),
|
---|
704 | format(inf->getFormat()),
|
---|
705 | data(inf->getString(), inf->getString()+inf->getSize()),
|
---|
706 | time(extract(inf))/*,
|
---|
707 | info(inf)*/
|
---|
708 | {
|
---|
709 | }
|
---|
710 |
|
---|
711 | template<typename T>
|
---|
712 | T get(uint32_t offset=0) const { return *reinterpret_cast<const T*>(data.data()+offset); }
|
---|
713 |
|
---|
714 | template<typename T>
|
---|
715 | const T *ptr(uint32_t offset=0) const { return reinterpret_cast<const T*>(data.data()+offset); }
|
---|
716 |
|
---|
717 | template<typename T>
|
---|
718 | const T &ref(uint32_t offset=0) const { return *reinterpret_cast<const T*>(data.data()+offset); }
|
---|
719 |
|
---|
720 | // vector<char> vec(int b) const { return vector<char>(data.begin()+b, data.end()); }
|
---|
721 | // string str(unsigned int b) const { return b>=data.size()?string():string(data.data()+b, data.size()-b); }
|
---|
722 | const char *c_str() const { return (char*)data.data(); }
|
---|
723 | /*
|
---|
724 | vector<boost::any> any() const
|
---|
725 | {
|
---|
726 | const Converter conv(format);
|
---|
727 | conv.Print();
|
---|
728 | return conv.GetAny(data.data(), data.size());
|
---|
729 | }*/
|
---|
730 | size_t size() const { return data.size(); }
|
---|
731 | };
|
---|
732 |
|
---|
733 | // ======================= DNS ==========================================
|
---|
734 |
|
---|
735 | void handleDimDNS(const DimData &d)
|
---|
736 | {
|
---|
737 | const int version = d.size()!=4 ? 0 : d.get<uint32_t>();
|
---|
738 |
|
---|
739 | ostringstream str;
|
---|
740 | str << "V" << version/100 << 'r' << version%100;
|
---|
741 |
|
---|
742 | ostringstream dns;
|
---|
743 | dns << (version==0?"No connection":"Connection");
|
---|
744 | dns << " to DIM DNS (" << getenv("DIM_DNS_NODE") << ")";
|
---|
745 | dns << (version==0?".":" established.");
|
---|
746 |
|
---|
747 | fStatusDNSLabel->setText(version==0?"Offline":str.str().c_str());
|
---|
748 | fStatusDNSLabel->setToolTip(dns.str().c_str());
|
---|
749 |
|
---|
750 | SetLedColor(fStatusDNSLed, version==0 ? kLedRed : kLedGreen, Time());
|
---|
751 | }
|
---|
752 |
|
---|
753 |
|
---|
754 | // ======================= Logger =======================================
|
---|
755 |
|
---|
756 | void handleLoggerStats(const DimData &d)
|
---|
757 | {
|
---|
758 | const bool connected = d.size()!=0;
|
---|
759 |
|
---|
760 | fLoggerET->setEnabled(connected);
|
---|
761 | fLoggerRate->setEnabled(connected);
|
---|
762 | fLoggerWritten->setEnabled(connected);
|
---|
763 | fLoggerFreeSpace->setEnabled(connected);
|
---|
764 | fLoggerSpaceLeft->setEnabled(connected);
|
---|
765 |
|
---|
766 | if (!connected)
|
---|
767 | return;
|
---|
768 |
|
---|
769 | const uint64_t *vals = d.ptr<uint64_t>();
|
---|
770 |
|
---|
771 | const size_t space = vals[0];
|
---|
772 | const size_t written = vals[1];
|
---|
773 | const size_t rate = float(vals[2])/vals[3];
|
---|
774 |
|
---|
775 | fLoggerFreeSpace->setSuffix(" MB");
|
---|
776 | fLoggerFreeSpace->setDecimals(0);
|
---|
777 | fLoggerFreeSpace->setValue(space*1e-6);
|
---|
778 |
|
---|
779 | if (space> 1000000) // > 1GB
|
---|
780 | {
|
---|
781 | fLoggerFreeSpace->setSuffix(" GB");
|
---|
782 | fLoggerFreeSpace->setDecimals(2);
|
---|
783 | fLoggerFreeSpace->setValue(space*1e-9);
|
---|
784 | }
|
---|
785 | if (space>= 3000000) // >= 3GB
|
---|
786 | {
|
---|
787 | fLoggerFreeSpace->setSuffix(" GB");
|
---|
788 | fLoggerFreeSpace->setDecimals(1);
|
---|
789 | fLoggerFreeSpace->setValue(space*1e-9);
|
---|
790 | }
|
---|
791 | if (space>=100000000) // >= 100GB
|
---|
792 | {
|
---|
793 | fLoggerFreeSpace->setSuffix(" GB");
|
---|
794 | fLoggerFreeSpace->setDecimals(0);
|
---|
795 | fLoggerFreeSpace->setValue(space*1e-9);
|
---|
796 | }
|
---|
797 |
|
---|
798 | fLoggerET->setTime(QTime().addSecs(rate>0?space/rate:0));
|
---|
799 | fLoggerRate->setValue(rate*1e-3); // kB/s
|
---|
800 | fLoggerWritten->setValue(written*1e-6);
|
---|
801 |
|
---|
802 | fLoggerRate->setSuffix(" kB/s");
|
---|
803 | fLoggerRate->setDecimals(2);
|
---|
804 | fLoggerRate->setValue(rate);
|
---|
805 | if (rate> 2) // > 2kB/s
|
---|
806 | {
|
---|
807 | fLoggerRate->setSuffix(" kB/s");
|
---|
808 | fLoggerRate->setDecimals(1);
|
---|
809 | fLoggerRate->setValue(rate);
|
---|
810 | }
|
---|
811 | if (rate>=100) // >100kB/s
|
---|
812 | {
|
---|
813 | fLoggerRate->setSuffix(" kB/s");
|
---|
814 | fLoggerRate->setDecimals(0);
|
---|
815 | fLoggerRate->setValue(rate);
|
---|
816 | }
|
---|
817 | if (rate>=1000) // >100kB/s
|
---|
818 | {
|
---|
819 | fLoggerRate->setSuffix(" MB/s");
|
---|
820 | fLoggerRate->setDecimals(2);
|
---|
821 | fLoggerRate->setValue(rate*1e-3);
|
---|
822 | }
|
---|
823 | if (rate>=10000) // >1MB/s
|
---|
824 | {
|
---|
825 | fLoggerRate->setSuffix(" MB/s");
|
---|
826 | fLoggerRate->setDecimals(1);
|
---|
827 | fLoggerRate->setValue(rate*1e-3);
|
---|
828 | }
|
---|
829 | if (rate>=100000) // >10MB/s
|
---|
830 | {
|
---|
831 | fLoggerRate->setSuffix(" MB/s");
|
---|
832 | fLoggerRate->setDecimals(0);
|
---|
833 | fLoggerRate->setValue(rate*1e-3);
|
---|
834 | }
|
---|
835 |
|
---|
836 | if (space/1000000>static_cast<size_t>(fLoggerSpaceLeft->maximum()))
|
---|
837 | fLoggerSpaceLeft->setValue(fLoggerSpaceLeft->maximum()); // GB
|
---|
838 | else
|
---|
839 | fLoggerSpaceLeft->setValue(space/1000000); // MB
|
---|
840 | }
|
---|
841 |
|
---|
842 | void handleLoggerFilenameNight(const DimData &d)
|
---|
843 | {
|
---|
844 | const bool connected = d.size()!=0;
|
---|
845 |
|
---|
846 | fLoggerFilenameNight->setEnabled(connected);
|
---|
847 | if (!connected)
|
---|
848 | return;
|
---|
849 |
|
---|
850 | fLoggerFilenameNight->setText(d.c_str()+4);
|
---|
851 |
|
---|
852 | const uint32_t files = d.get<uint32_t>();
|
---|
853 |
|
---|
854 | SetLedColor(fLoggerLedLog, files&1 ? kLedGreen : kLedGray, d.time);
|
---|
855 | SetLedColor(fLoggerLedRep, files&2 ? kLedGreen : kLedGray, d.time);
|
---|
856 | SetLedColor(fLoggerLedFits, files&4 ? kLedGreen : kLedGray, d.time);
|
---|
857 | }
|
---|
858 |
|
---|
859 | void handleLoggerFilenameRun(const DimData &d)
|
---|
860 | {
|
---|
861 | const bool connected = d.size()!=0;
|
---|
862 |
|
---|
863 | fLoggerFilenameRun->setEnabled(connected);
|
---|
864 | if (!connected)
|
---|
865 | return;
|
---|
866 |
|
---|
867 | fLoggerFilenameRun->setText(d.c_str()+4);
|
---|
868 |
|
---|
869 | const uint32_t files = d.get<uint32_t>();
|
---|
870 |
|
---|
871 | SetLedColor(fLoggerLedLog, files&1 ? kLedGreen : kLedGray, d.time);
|
---|
872 | SetLedColor(fLoggerLedRep, files&2 ? kLedGreen : kLedGray, d.time);
|
---|
873 | SetLedColor(fLoggerLedFits, files&4 ? kLedGreen : kLedGray, d.time);
|
---|
874 | }
|
---|
875 |
|
---|
876 | void handleLoggerNumSubs(const DimData &d)
|
---|
877 | {
|
---|
878 | const bool connected = d.size()!=0;
|
---|
879 |
|
---|
880 | fLoggerSubscriptions->setEnabled(connected);
|
---|
881 | fLoggerOpenFiles->setEnabled(connected);
|
---|
882 | if (!connected)
|
---|
883 | return;
|
---|
884 |
|
---|
885 | const uint32_t *vals = d.ptr<uint32_t>();
|
---|
886 |
|
---|
887 | fLoggerSubscriptions->setValue(vals[0]);
|
---|
888 | fLoggerOpenFiles->setValue(vals[1]);
|
---|
889 | }
|
---|
890 |
|
---|
891 |
|
---|
892 | // ===================== All ============================================
|
---|
893 |
|
---|
894 | bool CheckSize(const DimData &d, size_t sz) const
|
---|
895 | {
|
---|
896 | if (d.size()==0)
|
---|
897 | return false;
|
---|
898 |
|
---|
899 | if (d.size()!=sz)
|
---|
900 | {
|
---|
901 | cout << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected=" << sz << endl;
|
---|
902 | return false;
|
---|
903 | }
|
---|
904 |
|
---|
905 | return true;
|
---|
906 | }
|
---|
907 |
|
---|
908 | // ===================== FAD ============================================
|
---|
909 |
|
---|
910 | void handleFadWriteStats(const DimData &d)
|
---|
911 | {
|
---|
912 | const bool connected = d.size()!=0;
|
---|
913 |
|
---|
914 | fEvtBuilderET->setEnabled(connected);
|
---|
915 | fEvtBuilderRate->setEnabled(connected);
|
---|
916 | fEvtBuilderWritten->setEnabled(connected);
|
---|
917 | fEvtBuilderFreeSpace->setEnabled(connected);
|
---|
918 | fEvtBuilderSpaceLeft->setEnabled(connected);
|
---|
919 |
|
---|
920 | if (!connected)
|
---|
921 | return;
|
---|
922 |
|
---|
923 | const uint64_t *vals = d.ptr<uint64_t>();
|
---|
924 |
|
---|
925 | const size_t space = vals[0];
|
---|
926 | const size_t written = vals[1];
|
---|
927 | const size_t rate = float(vals[2])/vals[3];
|
---|
928 |
|
---|
929 | fEvtBuilderFreeSpace->setSuffix(" MB");
|
---|
930 | fEvtBuilderFreeSpace->setDecimals(0);
|
---|
931 | fEvtBuilderFreeSpace->setValue(space*1e-6);
|
---|
932 |
|
---|
933 | if (space> 1000000) // > 1GB
|
---|
934 | {
|
---|
935 | fEvtBuilderFreeSpace->setSuffix(" GB");
|
---|
936 | fEvtBuilderFreeSpace->setDecimals(2);
|
---|
937 | fEvtBuilderFreeSpace->setValue(space*1e-9);
|
---|
938 | }
|
---|
939 | if (space>= 3000000) // >= 3GB
|
---|
940 | {
|
---|
941 | fEvtBuilderFreeSpace->setSuffix(" GB");
|
---|
942 | fEvtBuilderFreeSpace->setDecimals(1);
|
---|
943 | fEvtBuilderFreeSpace->setValue(space*1e-9);
|
---|
944 | }
|
---|
945 | if (space>=100000000) // >= 100GB
|
---|
946 | {
|
---|
947 | fEvtBuilderFreeSpace->setSuffix(" GB");
|
---|
948 | fEvtBuilderFreeSpace->setDecimals(0);
|
---|
949 | fEvtBuilderFreeSpace->setValue(space*1e-9);
|
---|
950 | }
|
---|
951 |
|
---|
952 | fEvtBuilderET->setTime(QTime().addSecs(rate>0?space/rate:0));
|
---|
953 | fEvtBuilderRate->setValue(rate*1e-3); // kB/s
|
---|
954 | fEvtBuilderWritten->setValue(written*1e-6);
|
---|
955 |
|
---|
956 | fEvtBuilderRate->setSuffix(" kB/s");
|
---|
957 | fEvtBuilderRate->setDecimals(2);
|
---|
958 | fEvtBuilderRate->setValue(rate);
|
---|
959 | if (rate> 2) // > 2kB/s
|
---|
960 | {
|
---|
961 | fEvtBuilderRate->setSuffix(" kB/s");
|
---|
962 | fEvtBuilderRate->setDecimals(1);
|
---|
963 | fEvtBuilderRate->setValue(rate);
|
---|
964 | }
|
---|
965 | if (rate>=100) // >100kB/s
|
---|
966 | {
|
---|
967 | fEvtBuilderRate->setSuffix(" kB/s");
|
---|
968 | fEvtBuilderRate->setDecimals(0);
|
---|
969 | fEvtBuilderRate->setValue(rate);
|
---|
970 | }
|
---|
971 | if (rate>=1000) // >100kB/s
|
---|
972 | {
|
---|
973 | fEvtBuilderRate->setSuffix(" MB/s");
|
---|
974 | fEvtBuilderRate->setDecimals(2);
|
---|
975 | fEvtBuilderRate->setValue(rate*1e-3);
|
---|
976 | }
|
---|
977 | if (rate>=10000) // >1MB/s
|
---|
978 | {
|
---|
979 | fEvtBuilderRate->setSuffix(" MB/s");
|
---|
980 | fEvtBuilderRate->setDecimals(1);
|
---|
981 | fEvtBuilderRate->setValue(rate*1e-3);
|
---|
982 | }
|
---|
983 | if (rate>=100000) // >10MB/s
|
---|
984 | {
|
---|
985 | fEvtBuilderRate->setSuffix(" MB/s");
|
---|
986 | fEvtBuilderRate->setDecimals(0);
|
---|
987 | fEvtBuilderRate->setValue(rate*1e-3);
|
---|
988 | }
|
---|
989 |
|
---|
990 | if (space/1000000>static_cast<size_t>(fEvtBuilderSpaceLeft->maximum()))
|
---|
991 | fEvtBuilderSpaceLeft->setValue(fEvtBuilderSpaceLeft->maximum()); // GB
|
---|
992 | else
|
---|
993 | fEvtBuilderSpaceLeft->setValue(space/1000000); // MB
|
---|
994 | }
|
---|
995 |
|
---|
996 | void handleFadRuns(const DimData &d)
|
---|
997 | {
|
---|
998 | if (d.size()==0)
|
---|
999 | return;
|
---|
1000 |
|
---|
1001 | if (d.size()<20)
|
---|
1002 | {
|
---|
1003 | cout << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected>=20" << endl;
|
---|
1004 | return;
|
---|
1005 | }
|
---|
1006 |
|
---|
1007 | const uint32_t *ptr = d.ptr<uint32_t>();
|
---|
1008 |
|
---|
1009 | fEvtBldOpenFiles->setValue(ptr[0]);
|
---|
1010 | fEvtBldOpenStreams->setValue(ptr[0]);
|
---|
1011 | fEvtBldRunNumberMin->setValue(ptr[1]);
|
---|
1012 | fEvtBldRunNumberMax->setValue(ptr[2]);
|
---|
1013 | fEvtBldLastOpened->setValue(ptr[3]);
|
---|
1014 | fEvtBldLastClosed->setValue(ptr[4]);
|
---|
1015 |
|
---|
1016 | if (d.size()>=20)
|
---|
1017 | fEvtBldFilename->setText(d.ptr<char>(20));
|
---|
1018 |
|
---|
1019 | if (ptr[0]==0)
|
---|
1020 | fEvtBldFilename->setText("");
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | void handleFadEvents(const DimData &d)
|
---|
1024 | {
|
---|
1025 | if (!CheckSize(d, 16))
|
---|
1026 | return;
|
---|
1027 |
|
---|
1028 | const uint32_t *ptr = d.ptr<uint32_t>();
|
---|
1029 |
|
---|
1030 | fEvtsSuccessCurRun->setValue(ptr[0]);
|
---|
1031 | fEvtsSuccessTotal->setValue(ptr[1]);
|
---|
1032 | fEvtBldEventId->setValue(ptr[2]);
|
---|
1033 | fEvtBldTriggerId->setValue(ptr[3]);
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 | void handleFadTemperature(const DimData &d)
|
---|
1037 | {
|
---|
1038 | if (d.size()==0)
|
---|
1039 | {
|
---|
1040 | fFadTempMin->setEnabled(false);
|
---|
1041 | fFadTempMax->setEnabled(false);
|
---|
1042 | SetLedColor(fFadLedTemp, kLedGray, d.time);
|
---|
1043 | return;
|
---|
1044 | }
|
---|
1045 |
|
---|
1046 | if (!CheckSize(d, 82*sizeof(float)))
|
---|
1047 | return;
|
---|
1048 |
|
---|
1049 | const float *ptr = d.ptr<float>();
|
---|
1050 |
|
---|
1051 | fFadTempMin->setEnabled(true);
|
---|
1052 | fFadTempMax->setEnabled(true);
|
---|
1053 |
|
---|
1054 | fFadTempMin->setValue(ptr[0]);
|
---|
1055 | fFadTempMax->setValue(ptr[41]);
|
---|
1056 |
|
---|
1057 | handleFadToolTip(d.time, fFadTempMin, ptr+1);
|
---|
1058 | handleFadToolTip(d.time, fFadTempMax, ptr+42);
|
---|
1059 | }
|
---|
1060 |
|
---|
1061 | void handleFadRefClock(const DimData &d)
|
---|
1062 | {
|
---|
1063 | if (d.size()==0)
|
---|
1064 | {
|
---|
1065 | fFadRefClockMin->setEnabled(false);
|
---|
1066 | fFadRefClockMax->setEnabled(false);
|
---|
1067 | SetLedColor(fFadLedRefClock, kLedGray, d.time);
|
---|
1068 | return;
|
---|
1069 | }
|
---|
1070 |
|
---|
1071 | if (!CheckSize(d, 42*sizeof(uint32_t)))
|
---|
1072 | return;
|
---|
1073 |
|
---|
1074 | const uint32_t *ptr = d.ptr<uint32_t>();
|
---|
1075 |
|
---|
1076 | fFadRefClockMin->setEnabled(true);
|
---|
1077 | fFadRefClockMax->setEnabled(true);
|
---|
1078 |
|
---|
1079 | fFadRefClockMin->setValue(ptr[40]*2.048);
|
---|
1080 | fFadRefClockMax->setValue(ptr[41]*2.048);
|
---|
1081 |
|
---|
1082 | const int64_t diff = int64_t(ptr[41]) - int64_t(ptr[40]);
|
---|
1083 |
|
---|
1084 | SetLedColor(fFadLedRefClock, abs(diff)>3?kLedRed:kLedGreen, d.time);
|
---|
1085 |
|
---|
1086 | handleFadToolTip(d.time, fFadLedRefClock, ptr);
|
---|
1087 | }
|
---|
1088 |
|
---|
1089 | void handleFadRoi(const DimData &d)
|
---|
1090 | {
|
---|
1091 | if (d.size()==0)
|
---|
1092 | {
|
---|
1093 | fFadRoi->setEnabled(false);
|
---|
1094 | fFadRoiCh9->setEnabled(false);
|
---|
1095 | SetLedColor(fFadLedRoi, kLedGray, d.time);
|
---|
1096 | return;
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | if (!CheckSize(d, 2*sizeof(uint16_t)))
|
---|
1100 | return;
|
---|
1101 |
|
---|
1102 | const uint16_t *ptr = d.ptr<uint16_t>();
|
---|
1103 |
|
---|
1104 | fFadRoi->setEnabled(true);
|
---|
1105 | fFadRoiCh9->setEnabled(true);
|
---|
1106 |
|
---|
1107 | fFadRoi->setValue(ptr[0]);
|
---|
1108 | fFadRoiCh9->setValue(ptr[1]);
|
---|
1109 |
|
---|
1110 | SetLedColor(fFadLedRoi, kLedGray, d.time);
|
---|
1111 | }
|
---|
1112 |
|
---|
1113 | void handleDac(QPushButton *led, QSpinBox *box, const DimData &d, int idx)
|
---|
1114 | {
|
---|
1115 | if (d.size()==0)
|
---|
1116 | {
|
---|
1117 | box->setEnabled(false);
|
---|
1118 | SetLedColor(led, kLedGray, d.time);
|
---|
1119 | return;
|
---|
1120 | }
|
---|
1121 |
|
---|
1122 | const uint16_t *ptr = d.ptr<uint16_t>()+idx*42;
|
---|
1123 |
|
---|
1124 | box->setEnabled(true);
|
---|
1125 | box->setValue(ptr[40]==ptr[41]?ptr[40]:0);
|
---|
1126 |
|
---|
1127 | SetLedColor(led, ptr[40]==ptr[41]?kLedGreen:kLedOrange, d.time);
|
---|
1128 | handleFadToolTip(d.time, led, ptr);
|
---|
1129 | }
|
---|
1130 |
|
---|
1131 | void handleFadDac(const DimData &d)
|
---|
1132 | {
|
---|
1133 | if (!CheckSize(d, 8*42*sizeof(uint16_t)) && !d.size()==0)
|
---|
1134 | return;
|
---|
1135 |
|
---|
1136 | handleDac(fFadLedDac0, fFadDac0, d, 0);
|
---|
1137 | handleDac(fFadLedDac1, fFadDac1, d, 1);
|
---|
1138 | handleDac(fFadLedDac2, fFadDac2, d, 2);
|
---|
1139 | handleDac(fFadLedDac3, fFadDac3, d, 3);
|
---|
1140 | handleDac(fFadLedDac4, fFadDac4, d, 4);
|
---|
1141 | handleDac(fFadLedDac5, fFadDac5, d, 5);
|
---|
1142 | handleDac(fFadLedDac6, fFadDac6, d, 6);
|
---|
1143 | handleDac(fFadLedDac7, fFadDac7, d, 7);
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 | EVENT *fEventData;
|
---|
1147 |
|
---|
1148 | void DrawHorizontal(TH1 *hf, double xmax, TH1 &h, double scale)
|
---|
1149 | {
|
---|
1150 | for (Int_t i=1;i<=h.GetNbinsX();i++)
|
---|
1151 | {
|
---|
1152 | if (h.GetBinContent(i)<0.5 || h.GetBinContent(i)>h.GetEntries()-0.5)
|
---|
1153 | continue;
|
---|
1154 |
|
---|
1155 | TBox * box=new TBox(xmax, h.GetBinLowEdge(i),
|
---|
1156 | xmax+h.GetBinContent(i)*scale,
|
---|
1157 | h.GetBinLowEdge(i+1));
|
---|
1158 |
|
---|
1159 | box->SetFillStyle(0);
|
---|
1160 | box->SetLineColor(h.GetLineColor());
|
---|
1161 | box->SetLineStyle(kSolid);
|
---|
1162 | box->SetBit(kCannotPick|kNoContextMenu);
|
---|
1163 | //box->Draw();
|
---|
1164 |
|
---|
1165 | hf->GetListOfFunctions()->Add(box);
|
---|
1166 | }
|
---|
1167 | }
|
---|
1168 |
|
---|
1169 | void DisplayEventData()
|
---|
1170 | {
|
---|
1171 | if (!fEventData)
|
---|
1172 | return;
|
---|
1173 |
|
---|
1174 | #ifdef HAVE_ROOT
|
---|
1175 | TCanvas *c = fAdcDataCanv->GetCanvas();
|
---|
1176 |
|
---|
1177 | TH1 *hf = dynamic_cast<TH1*>(c->FindObject("Frame"));
|
---|
1178 | TH1 *h = dynamic_cast<TH1*>(c->FindObject("EventData"));
|
---|
1179 | TH1 *d0 = dynamic_cast<TH1*>(c->FindObject("DrsCalib0"));
|
---|
1180 | TH1 *d1 = dynamic_cast<TH1*>(c->FindObject("DrsCalib1"));
|
---|
1181 | TH1 *d2 = dynamic_cast<TH1*>(c->FindObject("DrsCalib2"));
|
---|
1182 |
|
---|
1183 | if (hf && hf->GetNbinsX()!=fEventData->Roi)
|
---|
1184 | {
|
---|
1185 | delete hf;
|
---|
1186 | delete h;
|
---|
1187 | delete d0;
|
---|
1188 | delete d1;
|
---|
1189 | delete d2;
|
---|
1190 | hf = 0;
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | if (!hf)
|
---|
1194 | {
|
---|
1195 | c->cd();
|
---|
1196 |
|
---|
1197 | const int roi = fEventData->Roi>0 ? fEventData->Roi : 1;
|
---|
1198 |
|
---|
1199 | hf = new TH1F("Frame", "", roi, -0.5, roi-0.5);
|
---|
1200 | hf->SetDirectory(0);
|
---|
1201 | hf->SetBit(kCanDelete);
|
---|
1202 | hf->SetStats(kFALSE);
|
---|
1203 | hf->SetYTitle("Voltage [mV]");
|
---|
1204 | hf->GetXaxis()->CenterTitle();
|
---|
1205 | hf->GetYaxis()->CenterTitle();
|
---|
1206 | hf->SetMinimum(-1026);
|
---|
1207 | hf->SetMaximum(1025);
|
---|
1208 |
|
---|
1209 | h = new TH1F("EventData", "", roi, -0.5, roi-0.5);
|
---|
1210 | h->SetDirectory(0);
|
---|
1211 | h->SetBit(kCanDelete);
|
---|
1212 | h->SetMarkerStyle(kFullDotMedium);
|
---|
1213 | h->SetMarkerColor(kBlue);
|
---|
1214 |
|
---|
1215 | d0 = new TH1F("DrsCalib0", "", roi, -0.5, roi-0.5);
|
---|
1216 | d0->SetDirectory(0);
|
---|
1217 | d0->SetBit(kCanDelete);
|
---|
1218 | d0->SetMarkerStyle(kFullDotSmall);
|
---|
1219 | d0->SetMarkerColor(kRed);
|
---|
1220 | d0->SetLineColor(kRed);
|
---|
1221 |
|
---|
1222 | d1 = new TH1F("DrsCalib1", "", roi, -0.5, roi-0.5);
|
---|
1223 | d1->SetDirectory(0);
|
---|
1224 | d1->SetBit(kCanDelete);
|
---|
1225 | d1->SetMarkerStyle(kFullDotSmall);
|
---|
1226 | d1->SetMarkerColor(kMagenta);
|
---|
1227 | d1->SetLineColor(kMagenta);
|
---|
1228 |
|
---|
1229 | d2 = new TH1F("DrsCalib2", "", roi, -0.5, roi-0.5);
|
---|
1230 | d2->SetDirectory(0);
|
---|
1231 | d2->SetBit(kCanDelete);
|
---|
1232 | d2->SetMarkerStyle(kFullDotSmall);
|
---|
1233 | d2->SetMarkerColor(kGreen);
|
---|
1234 | d2->SetLineColor(kGreen);
|
---|
1235 |
|
---|
1236 | hf->Draw("");
|
---|
1237 | d0->Draw("PEX0same");
|
---|
1238 | d1->Draw("PEX0same");
|
---|
1239 | d2->Draw("PEX0same");
|
---|
1240 | h->Draw("PLsame");
|
---|
1241 |
|
---|
1242 | gPad = NULL;
|
---|
1243 | }
|
---|
1244 |
|
---|
1245 | // -----------------------------------------------------------
|
---|
1246 |
|
---|
1247 | const uint32_t p =
|
---|
1248 | fAdcChannel->value() +
|
---|
1249 | fAdcChip->value() * 9+
|
---|
1250 | fAdcBoard->value() * 36+
|
---|
1251 | fAdcCrate->value() *360;
|
---|
1252 |
|
---|
1253 | ostringstream str;
|
---|
1254 | str << "EventNum = " << fEventData->EventNum;
|
---|
1255 | str << " TriggerNum = " << fEventData->TriggerNum;
|
---|
1256 | str << " TriggerType = " << fEventData->TriggerType;
|
---|
1257 | str << " BoardTime = " << fEventData->BoardTime[fAdcBoard->value()+fAdcCrate->value()*10];
|
---|
1258 | str << " (" << Time(fEventData->PCTime, fEventData->PCUsec) << ")";
|
---|
1259 | hf->SetTitle(str.str().c_str());
|
---|
1260 | str.str("");
|
---|
1261 | str << "ADC Pipeline (start cell: " << fEventData->StartPix[p] << ")";
|
---|
1262 | hf->SetXTitle(str.str().c_str());
|
---|
1263 |
|
---|
1264 | // -----------------------------------------------------------
|
---|
1265 |
|
---|
1266 | const int16_t start = fEventData->StartPix[p];
|
---|
1267 | if (fDrsRuns[0]==0 || start<0)
|
---|
1268 | d0->Reset();
|
---|
1269 | if (fDrsRuns[1]==0 || start<0)
|
---|
1270 | d1->Reset();
|
---|
1271 | if (fDrsRuns[2]==0 || start<0)
|
---|
1272 | d2->Reset();
|
---|
1273 |
|
---|
1274 | h->SetEntries(0);
|
---|
1275 | d0->SetEntries(0);
|
---|
1276 | d1->SetEntries(0);
|
---|
1277 | d2->SetEntries(0);
|
---|
1278 |
|
---|
1279 | for (int i=0; i<fEventData->Roi; i++)
|
---|
1280 | {
|
---|
1281 | h->SetBinContent(i+1, reinterpret_cast<float*>(fEventData->Adc_Data)[p*fEventData->Roi+i]);
|
---|
1282 | if (start<0)
|
---|
1283 | continue;
|
---|
1284 |
|
---|
1285 | if (fDrsRuns[0]>0)
|
---|
1286 | {
|
---|
1287 | d0->SetBinContent(i+1, fDrsCalibration[1440*1024*0 + p*1024+(start+i)%1024]);
|
---|
1288 | d0->SetBinError(i+1, fDrsCalibration[1440*1024*1 + p*1024+(start+i)%1024]);
|
---|
1289 |
|
---|
1290 | }
|
---|
1291 | if (fDrsRuns[1]>0)
|
---|
1292 | {
|
---|
1293 | d1->SetBinContent(i+1, fDrsCalibration[1440*1024*2 + p*1024+(start+i)%1024]);
|
---|
1294 | d1->SetBinError(i+1, fDrsCalibration[1440*1024*3 + p*1024+(start+i)%1024]);
|
---|
1295 | }
|
---|
1296 | if (fDrsRuns[2]>0)
|
---|
1297 | {
|
---|
1298 | d2->SetBinContent(i+1, fDrsCalibration[1440*1024*4 + p*1024 + i]);
|
---|
1299 | d2->SetBinError(i+1, fDrsCalibration[1440*1024*5 + p*1024 + i]);
|
---|
1300 | }
|
---|
1301 | }
|
---|
1302 |
|
---|
1303 | // -----------------------------------------------------------
|
---|
1304 |
|
---|
1305 | if (fAdcDynamicScale->isChecked())
|
---|
1306 | {
|
---|
1307 | h->SetMinimum();
|
---|
1308 | h->SetMaximum();
|
---|
1309 |
|
---|
1310 | hf->SetMinimum(h->GetMinimum());
|
---|
1311 | hf->SetMaximum(h->GetMaximum());
|
---|
1312 | }
|
---|
1313 | if (fAdcManualScale->isChecked())
|
---|
1314 | {
|
---|
1315 | if (h->GetMinimumStored()==-1111)
|
---|
1316 | {
|
---|
1317 | h->SetMinimum(-1150);//-1026);
|
---|
1318 | hf->SetMinimum(-1150);//-1026);
|
---|
1319 | }
|
---|
1320 | if (h->GetMaximumStored()==-1111)
|
---|
1321 | {
|
---|
1322 | h->SetMaximum(2550);//1025);
|
---|
1323 | hf->SetMaximum(2550);//1025);
|
---|
1324 | }
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 | if (fAdcAutoScale->isChecked())
|
---|
1328 | {
|
---|
1329 | h->SetMinimum();
|
---|
1330 | h->SetMaximum();
|
---|
1331 |
|
---|
1332 | if (h->GetMinimum()<hf->GetMinimum())
|
---|
1333 | hf->SetMinimum(h->GetMinimum());
|
---|
1334 | if (h->GetMaximum()>hf->GetMaximum())
|
---|
1335 | hf->SetMaximum(h->GetMaximum());
|
---|
1336 | }
|
---|
1337 |
|
---|
1338 | // -----------------------------------------------------------
|
---|
1339 |
|
---|
1340 | const int imin = ceil(hf->GetMinimum());
|
---|
1341 | const int imax = floor(hf->GetMaximum());
|
---|
1342 |
|
---|
1343 | TH1S hd("", "", imax-imin+1, imin-0.5, imax+0.5);
|
---|
1344 | TH1S h0("", "", imax-imin+1, imin-0.5, imax+0.5);
|
---|
1345 | TH1S h1("", "", imax-imin+1, imin-0.5, imax+0.5);
|
---|
1346 | TH1S h2("", "", imax-imin+1, imin-0.5, imax+0.5);
|
---|
1347 | hd.SetDirectory(0);
|
---|
1348 | h0.SetDirectory(0);
|
---|
1349 | h1.SetDirectory(0);
|
---|
1350 | h2.SetDirectory(0);
|
---|
1351 | hd.SetLineColor(h->GetLineColor());
|
---|
1352 | h0.SetLineColor(d0->GetLineColor());
|
---|
1353 | h1.SetLineColor(d1->GetLineColor());
|
---|
1354 | h2.SetLineColor(d2->GetLineColor());
|
---|
1355 |
|
---|
1356 | for (int i=0; i<fEventData->Roi; i++)
|
---|
1357 | {
|
---|
1358 | hd.Fill(h->GetBinContent(i+1));
|
---|
1359 | h0.Fill(d0->GetBinContent(i+1));
|
---|
1360 | h1.Fill(d1->GetBinContent(i+1));
|
---|
1361 | h2.Fill(d2->GetBinContent(i+1));
|
---|
1362 | }
|
---|
1363 |
|
---|
1364 | double mm = hd.GetMaximum(hd.GetEntries());
|
---|
1365 | if (h0.GetMaximum(h0.GetEntries())>mm)
|
---|
1366 | mm = h0.GetMaximum();
|
---|
1367 | if (h1.GetMaximum(h1.GetEntries())>mm)
|
---|
1368 | mm = h1.GetMaximum();
|
---|
1369 | if (h2.GetMaximum(h2.GetEntries())>mm)
|
---|
1370 | mm = h2.GetMaximum();
|
---|
1371 |
|
---|
1372 | TIter Next(hf->GetListOfFunctions());
|
---|
1373 | TObject *obj = 0;
|
---|
1374 | while ((obj=Next()))
|
---|
1375 | if (dynamic_cast<TBox*>(obj))
|
---|
1376 | delete hf->GetListOfFunctions()->Remove(obj);
|
---|
1377 |
|
---|
1378 | const double l = h->GetBinLowEdge(h->GetXaxis()->GetLast()+1);
|
---|
1379 | const double m = c->GetX2();
|
---|
1380 |
|
---|
1381 | const double scale = 0.9*(m-l)/mm;
|
---|
1382 |
|
---|
1383 | c->cd();
|
---|
1384 |
|
---|
1385 | DrawHorizontal(hf, l, h2, scale);
|
---|
1386 | DrawHorizontal(hf, l, h1, scale);
|
---|
1387 | DrawHorizontal(hf, l, h0, scale);
|
---|
1388 | DrawHorizontal(hf, l, hd, scale);
|
---|
1389 |
|
---|
1390 | // -----------------------------------------------------------
|
---|
1391 |
|
---|
1392 | c->Modified();
|
---|
1393 | c->Update();
|
---|
1394 | #endif
|
---|
1395 | }
|
---|
1396 |
|
---|
1397 | void handleFadRawData(const DimData &d)
|
---|
1398 | {
|
---|
1399 | if (d.size()==0)
|
---|
1400 | return;
|
---|
1401 |
|
---|
1402 | if (fAdcStop->isChecked())
|
---|
1403 | return;
|
---|
1404 |
|
---|
1405 | const EVENT &dat = d.ref<EVENT>();
|
---|
1406 |
|
---|
1407 | if (d.size()<sizeof(EVENT))
|
---|
1408 | {
|
---|
1409 | cout << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected>=" << sizeof(EVENT) << endl;
|
---|
1410 | return;
|
---|
1411 | }
|
---|
1412 |
|
---|
1413 | if (d.size()!=sizeof(EVENT)+dat.Roi*4*1440)
|
---|
1414 | {
|
---|
1415 | cout << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected=" << dat.Roi*4*1440+sizeof(EVENT) << " [roi=" << dat.Roi << "]" << endl;
|
---|
1416 | return;
|
---|
1417 | }
|
---|
1418 |
|
---|
1419 | delete fEventData;
|
---|
1420 | fEventData = reinterpret_cast<EVENT*>(new char[d.size()]);
|
---|
1421 | memcpy(fEventData, d.ptr<void>(), d.size());
|
---|
1422 |
|
---|
1423 | DisplayEventData();
|
---|
1424 | }
|
---|
1425 |
|
---|
1426 | void handleFadEventData(const DimData &d)
|
---|
1427 | {
|
---|
1428 | if (!CheckSize(d, 4*1440*sizeof(float)))
|
---|
1429 | return;
|
---|
1430 |
|
---|
1431 | // static int cnt=0;
|
---|
1432 | // if (cnt++%10>0)
|
---|
1433 | // return;
|
---|
1434 |
|
---|
1435 | const float *ptr = d.ptr<float>();
|
---|
1436 |
|
---|
1437 | TCanvas *c = fEventCanv->GetCanvas();
|
---|
1438 | Camera *cam1 = (Camera*)c->GetPad(1)->FindObject("Camera");
|
---|
1439 | Camera *cam2 = (Camera*)c->GetPad(2)->FindObject("Camera");
|
---|
1440 | Camera *cam3 = (Camera*)c->GetPad(3)->FindObject("Camera");
|
---|
1441 | Camera *cam4 = (Camera*)c->GetPad(4)->FindObject("Camera");
|
---|
1442 |
|
---|
1443 | valarray<double> arr1(1440);
|
---|
1444 | valarray<double> arr2(1440);
|
---|
1445 | valarray<double> arr3(1440);
|
---|
1446 | valarray<double> arr4(1440);
|
---|
1447 |
|
---|
1448 | for (int i=0; i<1440; i++)
|
---|
1449 | {
|
---|
1450 | arr1[i] = ptr[0*1440+fPixelMapHW[i]];
|
---|
1451 | arr2[i] = ptr[1*1440+fPixelMapHW[i]];
|
---|
1452 | arr3[i] = ptr[2*1440+fPixelMapHW[i]];
|
---|
1453 | arr4[i] = ptr[3*1440+fPixelMapHW[i]];
|
---|
1454 | }
|
---|
1455 |
|
---|
1456 | cam1->SetData(arr1);
|
---|
1457 | cam2->SetData(arr2);
|
---|
1458 | cam3->SetData(arr3);
|
---|
1459 | cam4->SetData(arr4);
|
---|
1460 |
|
---|
1461 | c->GetPad(1)->Modified();
|
---|
1462 | c->GetPad(2)->Modified();
|
---|
1463 | c->GetPad(3)->Modified();
|
---|
1464 | c->GetPad(4)->Modified();
|
---|
1465 |
|
---|
1466 | c->Update();
|
---|
1467 | }
|
---|
1468 |
|
---|
1469 | uint32_t fDrsRuns[3];
|
---|
1470 | vector<float> fDrsCalibration;
|
---|
1471 |
|
---|
1472 | void handleFadDrsCalibration(const DimData &d)
|
---|
1473 | {
|
---|
1474 | if (d.size()==0)
|
---|
1475 | {
|
---|
1476 | fDrsRuns[0] = 0;
|
---|
1477 | fDrsRuns[1] = 0;
|
---|
1478 | fDrsRuns[2] = 0;
|
---|
1479 | fDrsCalibration.assign(1024*1440*6, 0);
|
---|
1480 | DisplayEventData();
|
---|
1481 | return;
|
---|
1482 | }
|
---|
1483 |
|
---|
1484 | if (!CheckSize(d, 1024*1440*6*sizeof(float)+3*sizeof(uint32_t)))
|
---|
1485 | // Do WHAT?
|
---|
1486 | return;
|
---|
1487 |
|
---|
1488 | const uint32_t *run = d.ptr<uint32_t>();
|
---|
1489 | fDrsRuns[0] = run[0];
|
---|
1490 | fDrsRuns[1] = run[1];
|
---|
1491 | fDrsRuns[2] = run[2];
|
---|
1492 |
|
---|
1493 | const float *dat = d.ptr<float>(sizeof(uint32_t)*3);
|
---|
1494 | fDrsCalibration.assign(dat, dat+1024*1440*6);
|
---|
1495 |
|
---|
1496 | DisplayEventData();
|
---|
1497 | }
|
---|
1498 |
|
---|
1499 | // vector<uint8_t> fFadConnections;
|
---|
1500 |
|
---|
1501 | void handleFadConnections(const DimData &d)
|
---|
1502 | {
|
---|
1503 | if (!CheckSize(d, 41))
|
---|
1504 | {
|
---|
1505 | fStatusEventBuilderLabel->setText("Offline");
|
---|
1506 | fStatusEventBuilderLabel->setToolTip("FADs or fadctrl seems to be offline.");
|
---|
1507 | fEvtBldWidget->setEnabled(false);
|
---|
1508 |
|
---|
1509 | SetLedColor(fStatusEventBuilderLed, kLedGray, d.time);
|
---|
1510 | return;
|
---|
1511 | }
|
---|
1512 |
|
---|
1513 | const uint8_t *ptr = d.ptr<uint8_t>();
|
---|
1514 |
|
---|
1515 | for (int i=0; i<40; i++)
|
---|
1516 | {
|
---|
1517 | const uint8_t stat1 = ptr[i]&3;
|
---|
1518 | const uint8_t stat2 = ptr[i]>>3;
|
---|
1519 |
|
---|
1520 | if (stat1==0 && stat2==0)
|
---|
1521 | {
|
---|
1522 | SetLedColor(fFadLED[i], kLedGray, d.time);
|
---|
1523 | continue;
|
---|
1524 | }
|
---|
1525 | if (stat1==2 && stat2==8)
|
---|
1526 | {
|
---|
1527 | SetLedColor(fFadLED[i], kLedGreen, d.time);
|
---|
1528 | continue;
|
---|
1529 | }
|
---|
1530 |
|
---|
1531 | if (stat1==1 && stat2==1)
|
---|
1532 | SetLedColor(fFadLED[i], kLedRed, d.time);
|
---|
1533 | else
|
---|
1534 | SetLedColor(fFadLED[i], kLedOrange, d.time);
|
---|
1535 | }
|
---|
1536 |
|
---|
1537 |
|
---|
1538 | const bool runs = ptr[40]!=0;
|
---|
1539 |
|
---|
1540 | fStatusEventBuilderLabel->setText(runs?"Running":"Not running");
|
---|
1541 | fStatusEventBuilderLabel->setToolTip(runs?"Event builder thread running.":"Event builder thread stopped.");
|
---|
1542 | fEvtBldWidget->setEnabled(runs);
|
---|
1543 |
|
---|
1544 | SetLedColor(fStatusEventBuilderLed, runs?kLedGreen:kLedRed, d.time);
|
---|
1545 |
|
---|
1546 | // fFadConnections.assign(ptr, ptr+40);
|
---|
1547 | }
|
---|
1548 |
|
---|
1549 | template<typename T>
|
---|
1550 | void handleFadToolTip(const Time &time, QWidget *w, T *ptr)
|
---|
1551 | {
|
---|
1552 | ostringstream tip;
|
---|
1553 | tip << "<table border='1'><tr><th colspan='11'>" << time.GetAsStr() << " (UTC)</th></tr><tr><th></th>";
|
---|
1554 | for (int b=0; b<10; b++)
|
---|
1555 | tip << "<th>" << b << "</th>";
|
---|
1556 | tip << "</tr>";
|
---|
1557 |
|
---|
1558 | for (int c=0; c<4; c++)
|
---|
1559 | {
|
---|
1560 | tip << "<tr><th>" << c << "</th>";
|
---|
1561 | for (int b=0; b<10; b++)
|
---|
1562 | tip << "<td>" << ptr[c*10+b] << "</td>";
|
---|
1563 | tip << "</tr>";
|
---|
1564 | }
|
---|
1565 | tip << "</table>";
|
---|
1566 |
|
---|
1567 | w->setToolTip(tip.str().c_str());
|
---|
1568 | }
|
---|
1569 |
|
---|
1570 | template<typename T, class S>
|
---|
1571 | void handleFadMinMax(const DimData &d, QPushButton *led, S *wmin, S *wmax=0)
|
---|
1572 | {
|
---|
1573 | if (!CheckSize(d, 42*sizeof(T)))
|
---|
1574 | return;
|
---|
1575 |
|
---|
1576 | const T *ptr = d.ptr<T>();
|
---|
1577 | const T min = ptr[40];
|
---|
1578 | const T max = ptr[41];
|
---|
1579 |
|
---|
1580 | if (max==0 && min>max)
|
---|
1581 | SetLedColor(led, kLedGray, d.time);
|
---|
1582 | else
|
---|
1583 | SetLedColor(led, min==max?kLedGreen: kLedOrange, d.time);
|
---|
1584 |
|
---|
1585 | if (!wmax && max!=min)
|
---|
1586 | wmin->setValue(0);
|
---|
1587 | else
|
---|
1588 | wmin->setValue(min);
|
---|
1589 |
|
---|
1590 | if (wmax)
|
---|
1591 | wmax->setValue(max);
|
---|
1592 |
|
---|
1593 | handleFadToolTip(d.time, led, ptr);
|
---|
1594 | }
|
---|
1595 |
|
---|
1596 | void handleFadFwVersion(const DimData &d)
|
---|
1597 | {
|
---|
1598 | handleFadMinMax<float, QDoubleSpinBox>(d, fFadLedFwVersion, fFadFwVersion);
|
---|
1599 | }
|
---|
1600 |
|
---|
1601 | void handleFadRunNumber(const DimData &d)
|
---|
1602 | {
|
---|
1603 | handleFadMinMax<uint32_t, QSpinBox>(d, fFadLedRunNumber, fFadRunNumber);
|
---|
1604 | }
|
---|
1605 |
|
---|
1606 | void handleFadPrescaler(const DimData &d)
|
---|
1607 | {
|
---|
1608 | handleFadMinMax<uint16_t, QSpinBox>(d, fFadLedPrescaler, fFadPrescaler);
|
---|
1609 | }
|
---|
1610 |
|
---|
1611 | void handleFadDNA(const DimData &d)
|
---|
1612 | {
|
---|
1613 | if (!CheckSize(d, 40*sizeof(uint64_t)))
|
---|
1614 | return;
|
---|
1615 |
|
---|
1616 | const uint64_t *ptr = d.ptr<uint64_t>();
|
---|
1617 |
|
---|
1618 | ostringstream tip;
|
---|
1619 | tip << "<table width='100%'>";
|
---|
1620 | tip << "<tr><th>Crate</th><td></td><th>Board</th><td></td><th>DNA</th></tr>";
|
---|
1621 |
|
---|
1622 | for (int i=0; i<40; i++)
|
---|
1623 | {
|
---|
1624 | tip << dec;
|
---|
1625 | tip << "<tr>";
|
---|
1626 | tip << "<td align='center'>" << i/10 << "</td><td>:</td>";
|
---|
1627 | tip << "<td align='center'>" << i%10 << "</td><td>:</td>";
|
---|
1628 | tip << hex;
|
---|
1629 | tip << "<td>0x" << setfill('0') << setw(16) << ptr[i] << "</td>";
|
---|
1630 | tip << "</tr>";
|
---|
1631 | }
|
---|
1632 | tip << "</table>";
|
---|
1633 |
|
---|
1634 | fFadDNA->setText(tip.str().c_str());
|
---|
1635 | }
|
---|
1636 |
|
---|
1637 | void SetFadLed(QPushButton *led, const DimData &d, uint16_t bitmask, bool invert=false)
|
---|
1638 | {
|
---|
1639 | if (d.size()==0)
|
---|
1640 | {
|
---|
1641 | SetLedColor(led, kLedGray, d.time);
|
---|
1642 | return;
|
---|
1643 | }
|
---|
1644 |
|
---|
1645 | const bool quality = d.ptr<uint16_t>()[0]&bitmask;
|
---|
1646 | const bool value = d.ptr<uint16_t>()[1]&bitmask;
|
---|
1647 | const uint16_t *ptr = d.ptr<uint16_t>()+2;
|
---|
1648 |
|
---|
1649 | SetLedColor(led, quality?kLedOrange:(value^invert?kLedGreen:kLedRed), d.time);
|
---|
1650 |
|
---|
1651 | ostringstream tip;
|
---|
1652 | tip << "<table border='1'><tr><th colspan='11'>" << d.time.GetAsStr() << " (UTC)</th></tr><tr><th></th>";
|
---|
1653 | for (int b=0; b<10; b++)
|
---|
1654 | tip << "<th>" << b << "</th>";
|
---|
1655 | tip << "</tr>";
|
---|
1656 |
|
---|
1657 | /*
|
---|
1658 | tip << "<tr>" << hex;
|
---|
1659 | tip << "<th>" << d.ptr<uint16_t>()[0] << " " << (d.ptr<uint16_t>()[0]&bitmask) << "</th>";
|
---|
1660 | tip << "<th>" << d.ptr<uint16_t>()[1] << " " << (d.ptr<uint16_t>()[1]&bitmask) << "</th>";
|
---|
1661 | tip << "</tr>";
|
---|
1662 | */
|
---|
1663 |
|
---|
1664 | for (int c=0; c<4; c++)
|
---|
1665 | {
|
---|
1666 | tip << "<tr><th>" << dec << c << "</th>" << hex;
|
---|
1667 | for (int b=0; b<10; b++)
|
---|
1668 | {
|
---|
1669 | tip << "<td>"
|
---|
1670 | << (ptr[c*10+b]&bitmask)
|
---|
1671 | << "</td>";
|
---|
1672 | }
|
---|
1673 | tip << "</tr>";
|
---|
1674 | }
|
---|
1675 | tip << "</table>";
|
---|
1676 |
|
---|
1677 | led->setToolTip(tip.str().c_str());
|
---|
1678 | }
|
---|
1679 |
|
---|
1680 | void handleFadStatus(const DimData &d)
|
---|
1681 | {
|
---|
1682 | if (d.size()!=0 && !CheckSize(d, 42*sizeof(uint16_t)))
|
---|
1683 | return;
|
---|
1684 |
|
---|
1685 | SetFadLed(fFadLedDrsEnabled, d, FAD::EventHeader::kDenable);
|
---|
1686 | SetFadLed(fFadLedDrsWrite, d, FAD::EventHeader::kDwrite);
|
---|
1687 | SetFadLed(fFadLedDcmLocked, d, FAD::EventHeader::kDcmLocked);
|
---|
1688 | SetFadLed(fFadLedDcmReady, d, FAD::EventHeader::kDcmReady);
|
---|
1689 | SetFadLed(fFadLedSpiSclk, d, FAD::EventHeader::kSpiSclk);
|
---|
1690 | SetFadLed(fFadLedRefClockTooLow, d, FAD::EventHeader::kRefClkTooLow, true);
|
---|
1691 | SetFadLed(fFadLedBusyOn, d, FAD::EventHeader::kBusyOn);
|
---|
1692 | SetFadLed(fFadLedBusyOff, d, FAD::EventHeader::kBusyOff);
|
---|
1693 | SetFadLed(fFadLedTriggerLine, d, FAD::EventHeader::kTriggerLine);
|
---|
1694 | SetFadLed(fFadLedContTrigger, d, FAD::EventHeader::kContTrigger);
|
---|
1695 | SetFadLed(fFadLedSocket, d, FAD::EventHeader::kSock17);
|
---|
1696 | SetFadLed(fFadLedPllLock, d, 0xf000);
|
---|
1697 | }
|
---|
1698 |
|
---|
1699 | void handleFadStatistics1(const DimData &d)
|
---|
1700 | {
|
---|
1701 | if (!CheckSize(d, sizeof(GUI_STAT)))
|
---|
1702 | return;
|
---|
1703 |
|
---|
1704 | const GUI_STAT &stat = d.ref<GUI_STAT>();
|
---|
1705 |
|
---|
1706 | /*
|
---|
1707 | //info about status of the main threads
|
---|
1708 | int32_t readStat ; //read thread
|
---|
1709 | int32_t procStat ; //processing thread(s)
|
---|
1710 | int32_t writStat ; //write thread
|
---|
1711 | */
|
---|
1712 |
|
---|
1713 | fFadBufferMax->setValue(stat.totMem/1000000);
|
---|
1714 | fFadBuffer->setMaximum(stat.totMem/100);
|
---|
1715 | fFadBuffer->setValue((stat.maxMem>stat.totMem?stat.totMem:stat.maxMem)/100); // Max mem used in last second
|
---|
1716 |
|
---|
1717 | uint32_t sum = 0;
|
---|
1718 | int32_t min = 0x7fffff;
|
---|
1719 | int32_t max = 0;
|
---|
1720 |
|
---|
1721 | int cnt = 0;
|
---|
1722 | int err = 0;
|
---|
1723 |
|
---|
1724 | for (int i=0; i<40; i++)
|
---|
1725 | {
|
---|
1726 | if (stat.numConn[i]!=7)
|
---|
1727 | continue;
|
---|
1728 |
|
---|
1729 | cnt++;
|
---|
1730 |
|
---|
1731 | sum += stat.rateBytes[i];
|
---|
1732 | err += stat.errConn[i];
|
---|
1733 |
|
---|
1734 | if (stat.rateBytes[i]<min)
|
---|
1735 | min = stat.rateBytes[i];
|
---|
1736 | if (stat.rateBytes[i]>max)
|
---|
1737 | max = stat.rateBytes[i];
|
---|
1738 | }
|
---|
1739 |
|
---|
1740 | fFadEvtConn->setValue(cnt);
|
---|
1741 | fFadEvtConnErr->setValue(err);
|
---|
1742 |
|
---|
1743 | fFadEvtBufNew->setValue(stat.bufNew); // Incomplete in buffer
|
---|
1744 | fFadEvtBufEvt->setValue(stat.bufEvt); // Complete in buffer
|
---|
1745 | fFadEvtBufMax->setValue(stat.maxEvt); // Complete in buffer
|
---|
1746 | fFadEvtWrite->setValue(stat.evtWrite-stat.evtSkip-stat.evtErr);
|
---|
1747 | fFadEvtSkip->setValue(stat.evtSkip);
|
---|
1748 | fFadEvtErr->setValue(stat.evtErr);
|
---|
1749 |
|
---|
1750 | if (stat.deltaT==0)
|
---|
1751 | return;
|
---|
1752 |
|
---|
1753 | fFadEthernetRateMin->setValue(min/stat.deltaT);
|
---|
1754 | fFadEthernetRateMax->setValue(max/stat.deltaT);
|
---|
1755 | fFadEthernetRateTot->setValue(sum/stat.deltaT);
|
---|
1756 | fFadEthernetRateAvg->setValue(cnt==0 ? 0 : sum/cnt/stat.deltaT);
|
---|
1757 | fFadEvtRateNew->setValue(1000*stat.rateNew/stat.deltaT);
|
---|
1758 | fFadEvtRateWrite->setValue(1000*stat.rateWrite/stat.deltaT);
|
---|
1759 | }
|
---|
1760 |
|
---|
1761 | void handleFadStatistics2(const DimData &d)
|
---|
1762 | {
|
---|
1763 | if (!CheckSize(d, sizeof(EVT_STAT)))
|
---|
1764 | return;
|
---|
1765 |
|
---|
1766 | //const EVT_STAT &stat = d.ref<EVT_STAT>();
|
---|
1767 |
|
---|
1768 | /*
|
---|
1769 | //some info about what happened since start of program (or last 'reset')
|
---|
1770 | uint32_t reset ; //#if increased, reset all counters
|
---|
1771 | uint32_t numRead[MAX_SOCK] ; //how often succesfull read from N sockets per loop
|
---|
1772 |
|
---|
1773 | uint64_t gotByte[NBOARDS] ; //#Bytes read per Board
|
---|
1774 | uint32_t gotErr[NBOARDS] ; //#Communication Errors per Board
|
---|
1775 |
|
---|
1776 | uint32_t evtGet; //#new Start of Events read
|
---|
1777 | uint32_t evtTot; //#complete Events read
|
---|
1778 |
|
---|
1779 | uint32_t evtErr; //#Events with Errors
|
---|
1780 | uint32_t evtSkp; //#Events incomplete (timeout)
|
---|
1781 |
|
---|
1782 |
|
---|
1783 | uint32_t procTot; //#Events processed
|
---|
1784 | uint32_t procErr; //#Events showed problem in processing
|
---|
1785 | uint32_t procTrg; //#Events accepted by SW trigger
|
---|
1786 | uint32_t procSkp; //#Events rejected by SW trigger
|
---|
1787 |
|
---|
1788 | uint32_t feedTot; //#Events used for feedBack system
|
---|
1789 | uint32_t feedErr; //#Events rejected by feedBack
|
---|
1790 |
|
---|
1791 | uint32_t wrtTot; //#Events written to disk
|
---|
1792 | uint32_t wrtErr; //#Events with write-error
|
---|
1793 |
|
---|
1794 | uint32_t runOpen; //#Runs opened
|
---|
1795 | uint32_t runClose; //#Runs closed
|
---|
1796 | uint32_t runErr; //#Runs with open/close errors
|
---|
1797 |
|
---|
1798 |
|
---|
1799 | //info about current connection status
|
---|
1800 | uint8_t numConn[NBOARDS] ; //#Sockets succesfully open per board
|
---|
1801 | */
|
---|
1802 | }
|
---|
1803 |
|
---|
1804 | // ===================== FTM ============================================
|
---|
1805 |
|
---|
1806 | void UpdateTriggerRate(const FTM::DimTriggerRates &sdata)
|
---|
1807 | {
|
---|
1808 | #ifdef HAVE_ROOT
|
---|
1809 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
---|
1810 |
|
---|
1811 | TH1 *h = (TH1*)c->FindObject("TimeFrame");
|
---|
1812 |
|
---|
1813 | if (sdata.fTriggerRate<0)
|
---|
1814 | {
|
---|
1815 | fGraphFtmRate.Set(0);
|
---|
1816 |
|
---|
1817 | const double tm = Time().RootTime();
|
---|
1818 |
|
---|
1819 | h->SetBins(1, tm, tm+60);
|
---|
1820 | h->GetXaxis()->SetTimeFormat("%M'%S\"");
|
---|
1821 | h->GetXaxis()->SetTitle("Time");
|
---|
1822 |
|
---|
1823 | c->Modified();
|
---|
1824 | c->Update();
|
---|
1825 | return;
|
---|
1826 | }
|
---|
1827 |
|
---|
1828 | const double t1 = h->GetXaxis()->GetXmax();
|
---|
1829 | const double t0 = h->GetXaxis()->GetXmin();
|
---|
1830 |
|
---|
1831 | const double now = t0+sdata.fTimeStamp/1000000.;
|
---|
1832 |
|
---|
1833 | h->SetBins(h->GetNbinsX()+1, t0, now+1);
|
---|
1834 | fGraphFtmRate.SetPoint(fGraphFtmRate.GetN(), now, sdata.fTriggerRate);
|
---|
1835 |
|
---|
1836 | if (t1-t0>60)
|
---|
1837 | {
|
---|
1838 | h->GetXaxis()->SetTimeFormat("%Hh%M'");
|
---|
1839 | h->GetXaxis()->SetTitle("Time");
|
---|
1840 | }
|
---|
1841 |
|
---|
1842 | h->SetMinimum(0);
|
---|
1843 |
|
---|
1844 | c->Modified();
|
---|
1845 | c->Update();
|
---|
1846 | #endif
|
---|
1847 | }
|
---|
1848 |
|
---|
1849 | void UpdateRatesCam(const FTM::DimTriggerRates &sdata)
|
---|
1850 | {
|
---|
1851 | #ifdef HAVE_ROOT
|
---|
1852 | if (fThresholdIdx->value()>=0)
|
---|
1853 | {
|
---|
1854 | const int isw = fThresholdIdx->value();
|
---|
1855 | const int ihw = fPatchMapHW[isw];
|
---|
1856 | fPatchRate->setValue(sdata.fPatchRate[ihw]);
|
---|
1857 | }
|
---|
1858 |
|
---|
1859 | valarray<double> dat(0., 1440);
|
---|
1860 |
|
---|
1861 | // fPatch converts from software id to software patch id
|
---|
1862 | for (int i=0; i<1440; i++)
|
---|
1863 | {
|
---|
1864 | const int ihw = fPatchHW[i];
|
---|
1865 | // const int isw = fPatch[i];
|
---|
1866 | // const int ihw = fPatchMapHW[isw];
|
---|
1867 | dat[i] = sdata.fPatchRate[ihw];
|
---|
1868 | }
|
---|
1869 |
|
---|
1870 | TCanvas *c = fRatesCanv->GetCanvas();
|
---|
1871 | Camera *cam = (Camera*)c->FindObject("Camera");
|
---|
1872 |
|
---|
1873 | cam->SetData(dat);
|
---|
1874 |
|
---|
1875 | c->Modified();
|
---|
1876 | c->Update();
|
---|
1877 | #endif
|
---|
1878 | }
|
---|
1879 |
|
---|
1880 | int64_t fTimeStamp0;
|
---|
1881 |
|
---|
1882 | void UpdateRatesGraphs(const FTM::DimTriggerRates &sdata)
|
---|
1883 | {
|
---|
1884 | #ifdef HAVE_ROOT
|
---|
1885 | if (fTimeStamp0<0)
|
---|
1886 | {
|
---|
1887 | fTimeStamp0 = sdata.fTimeStamp;
|
---|
1888 | return;
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
---|
1892 |
|
---|
1893 | TH1 *h = (TH1*)c->FindObject("TimeFrame");
|
---|
1894 |
|
---|
1895 | const double tdiff = sdata.fTimeStamp-fTimeStamp0;
|
---|
1896 | fTimeStamp0 = sdata.fTimeStamp;
|
---|
1897 |
|
---|
1898 | if (tdiff<0)
|
---|
1899 | {
|
---|
1900 | for (int i=0; i<160; i++)
|
---|
1901 | fGraphPatchRate[i].Set(0);
|
---|
1902 | for (int i=0; i<40; i++)
|
---|
1903 | fGraphBoardRate[i].Set(0);
|
---|
1904 |
|
---|
1905 | return;
|
---|
1906 | }
|
---|
1907 |
|
---|
1908 | //const double t1 = h->GetXaxis()->GetXmax();
|
---|
1909 | const double t0 = h->GetXaxis()->GetXmin();
|
---|
1910 |
|
---|
1911 | for (int i=0; i<160; i++)
|
---|
1912 | fGraphPatchRate[i].SetPoint(fGraphPatchRate[i].GetN(),
|
---|
1913 | t0+sdata.fTimeStamp/1000000., sdata.fPatchRate[i]);
|
---|
1914 | for (int i=0; i<40; i++)
|
---|
1915 | fGraphBoardRate[i].SetPoint(fGraphBoardRate[i].GetN(),
|
---|
1916 | t0+sdata.fTimeStamp/1000000., sdata.fBoardRate[i]);
|
---|
1917 |
|
---|
1918 | c->Modified();
|
---|
1919 | c->Update();
|
---|
1920 | #endif
|
---|
1921 | }
|
---|
1922 |
|
---|
1923 | void handleFtmTriggerRates(const DimData &d)
|
---|
1924 | {
|
---|
1925 | if (!CheckSize(d, sizeof(FTM::DimTriggerRates)))
|
---|
1926 | return;
|
---|
1927 |
|
---|
1928 | const FTM::DimTriggerRates &sdata = d.ref<FTM::DimTriggerRates>();
|
---|
1929 |
|
---|
1930 | fFtmTime->setText(QString::number(sdata.fTimeStamp/1000000., 'f', 6)+ " s");
|
---|
1931 | fTriggerCounter->setText(QString::number(sdata.fTriggerCounter));
|
---|
1932 |
|
---|
1933 | if (sdata.fTimeStamp>0)
|
---|
1934 | fTriggerCounterRate->setValue(1000000.*sdata.fTriggerCounter/sdata.fTimeStamp);
|
---|
1935 | else
|
---|
1936 | fTriggerCounterRate->setValue(0);
|
---|
1937 |
|
---|
1938 | // ----------------------------------------------
|
---|
1939 |
|
---|
1940 | fOnTime->setText(QString::number(sdata.fOnTimeCounter/1000000., 'f', 6)+" s");
|
---|
1941 |
|
---|
1942 | if (sdata.fTimeStamp>0)
|
---|
1943 | fOnTimeRel->setValue(100.*sdata.fOnTimeCounter/sdata.fTimeStamp);
|
---|
1944 | else
|
---|
1945 | fOnTimeRel->setValue(0);
|
---|
1946 |
|
---|
1947 | // ----------------------------------------------
|
---|
1948 |
|
---|
1949 | UpdateTriggerRate(sdata);
|
---|
1950 | UpdateRatesGraphs(sdata);
|
---|
1951 | UpdateRatesCam(sdata);
|
---|
1952 | }
|
---|
1953 |
|
---|
1954 | void handleFtmCounter(const DimData &d)
|
---|
1955 | {
|
---|
1956 | if (!CheckSize(d, sizeof(uint32_t)*6))
|
---|
1957 | return;
|
---|
1958 |
|
---|
1959 | const uint32_t *sdata = d.ptr<uint32_t>();
|
---|
1960 |
|
---|
1961 | fFtmCounterH->setValue(sdata[0]);
|
---|
1962 | fFtmCounterS->setValue(sdata[1]);
|
---|
1963 | fFtmCounterD->setValue(sdata[2]);
|
---|
1964 | fFtmCounterF->setValue(sdata[3]);
|
---|
1965 | fFtmCounterE->setValue(sdata[4]);
|
---|
1966 | fFtmCounterR->setValue(sdata[5]);
|
---|
1967 | }
|
---|
1968 |
|
---|
1969 | void handleFtmDynamicData(const DimData &d)
|
---|
1970 | {
|
---|
1971 | if (!CheckSize(d, sizeof(FTM::DimDynamicData)))
|
---|
1972 | return;
|
---|
1973 |
|
---|
1974 | const FTM::DimDynamicData &sdata = d.ref<FTM::DimDynamicData>();
|
---|
1975 |
|
---|
1976 | fFtmTemp0->setValue(sdata.fTempSensor[0]*0.1);
|
---|
1977 | fFtmTemp1->setValue(sdata.fTempSensor[1]*0.1);
|
---|
1978 | fFtmTemp2->setValue(sdata.fTempSensor[2]*0.1);
|
---|
1979 | fFtmTemp3->setValue(sdata.fTempSensor[3]*0.1);
|
---|
1980 |
|
---|
1981 | SetLedColor(fClockCondLed, sdata.fState&FTM::kFtmLocked ? kLedGreen : kLedRed, d.time);
|
---|
1982 | }
|
---|
1983 |
|
---|
1984 | void DisplayRates()
|
---|
1985 | {
|
---|
1986 | #ifdef HAVE_ROOT
|
---|
1987 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
---|
1988 |
|
---|
1989 | while (c->FindObject("PatchRate"))
|
---|
1990 | c->GetListOfPrimitives()->Remove(c->FindObject("PatchRate"));
|
---|
1991 |
|
---|
1992 | while (c->FindObject("BoardRate"))
|
---|
1993 | c->GetListOfPrimitives()->Remove(c->FindObject("BoardRate"));
|
---|
1994 |
|
---|
1995 | c->cd();
|
---|
1996 |
|
---|
1997 | if (fRatePatch1->value()>=0)
|
---|
1998 | {
|
---|
1999 | fGraphPatchRate[fRatePatch1->value()].SetLineColor(kRed);
|
---|
2000 | fGraphPatchRate[fRatePatch1->value()].SetMarkerColor(kRed);
|
---|
2001 | fGraphPatchRate[fRatePatch1->value()].Draw("PL");
|
---|
2002 | }
|
---|
2003 | if (fRatePatch2->value()>=0)
|
---|
2004 | {
|
---|
2005 | fGraphPatchRate[fRatePatch2->value()].SetLineColor(kGreen);
|
---|
2006 | fGraphPatchRate[fRatePatch2->value()].SetMarkerColor(kGreen);
|
---|
2007 | fGraphPatchRate[fRatePatch2->value()].Draw("PL");
|
---|
2008 | }
|
---|
2009 | if (fRateBoard1->value()>=0)
|
---|
2010 | {
|
---|
2011 | fGraphBoardRate[fRateBoard1->value()].SetLineColor(kMagenta);
|
---|
2012 | fGraphBoardRate[fRateBoard1->value()].SetMarkerColor(kMagenta);
|
---|
2013 | fGraphBoardRate[fRateBoard1->value()].Draw("PL");
|
---|
2014 | }
|
---|
2015 | if (fRateBoard2->value()>=0)
|
---|
2016 | {
|
---|
2017 | fGraphBoardRate[fRateBoard2->value()].SetLineColor(kCyan);
|
---|
2018 | fGraphBoardRate[fRateBoard2->value()].SetMarkerColor(kCyan);
|
---|
2019 | fGraphBoardRate[fRateBoard2->value()].Draw("PL");
|
---|
2020 | }
|
---|
2021 | #endif
|
---|
2022 | }
|
---|
2023 |
|
---|
2024 | void on_fRatePatch1_valueChanged(int)
|
---|
2025 | {
|
---|
2026 | DisplayRates();
|
---|
2027 | }
|
---|
2028 |
|
---|
2029 | void on_fRatePatch2_valueChanged(int)
|
---|
2030 | {
|
---|
2031 | DisplayRates();
|
---|
2032 | }
|
---|
2033 |
|
---|
2034 | void on_fRateBoard1_valueChanged(int)
|
---|
2035 | {
|
---|
2036 | DisplayRates();
|
---|
2037 | }
|
---|
2038 |
|
---|
2039 | void on_fRateBoard2_valueChanged(int)
|
---|
2040 | {
|
---|
2041 | DisplayRates();
|
---|
2042 | }
|
---|
2043 |
|
---|
2044 | FTM::DimStaticData fFtmStaticData;
|
---|
2045 |
|
---|
2046 | void SetFtuLed(int idx, int counter, const Time &t)
|
---|
2047 | {
|
---|
2048 | if (counter==0 || counter>3)
|
---|
2049 | counter = 3;
|
---|
2050 |
|
---|
2051 | if (counter<0)
|
---|
2052 | counter = 0;
|
---|
2053 |
|
---|
2054 | const LedColor_t col[4] = { kLedGray, kLedGreen, kLedOrange, kLedRed };
|
---|
2055 |
|
---|
2056 | SetLedColor(fFtuLED[idx], col[counter], t);
|
---|
2057 |
|
---|
2058 | fFtuStatus[idx] = counter;
|
---|
2059 | }
|
---|
2060 |
|
---|
2061 | void SetFtuStatusLed(const Time &t)
|
---|
2062 | {
|
---|
2063 | const int max = fFtuStatus.max();
|
---|
2064 |
|
---|
2065 | switch (max)
|
---|
2066 | {
|
---|
2067 | case 0:
|
---|
2068 | SetLedColor(fStatusFTULed, kLedGray, t);
|
---|
2069 | fStatusFTULabel->setText("All disabled");
|
---|
2070 | fStatusFTULabel->setToolTip("All FTUs are disabled");
|
---|
2071 | break;
|
---|
2072 |
|
---|
2073 | case 1:
|
---|
2074 | SetLedColor(fStatusFTULed, kLedGreen, t);
|
---|
2075 | fStatusFTULabel->setToolTip("Communication with FTU is smooth.");
|
---|
2076 | fStatusFTULabel->setText("ok");
|
---|
2077 | break;
|
---|
2078 |
|
---|
2079 | case 2:
|
---|
2080 | SetLedColor(fStatusFTULed, kLedOrange, t);
|
---|
2081 | fStatusFTULabel->setText("Warning");
|
---|
2082 | fStatusFTULabel->setToolTip("At least one FTU didn't answer immediately");
|
---|
2083 | break;
|
---|
2084 |
|
---|
2085 | case 3:
|
---|
2086 | SetLedColor(fStatusFTULed, kLedRed, t);
|
---|
2087 | fStatusFTULabel->setToolTip("At least one FTU didn't answer!");
|
---|
2088 | fStatusFTULabel->setText("ERROR");
|
---|
2089 | break;
|
---|
2090 | }
|
---|
2091 |
|
---|
2092 | const int cnt = count(&fFtuStatus[0], &fFtuStatus[40], 0);
|
---|
2093 | fFtuAllOn->setEnabled(cnt!=0);
|
---|
2094 | fFtuAllOff->setEnabled(cnt!=40);
|
---|
2095 | }
|
---|
2096 |
|
---|
2097 | void handleFtmStaticData(const DimData &d)
|
---|
2098 | {
|
---|
2099 | if (!CheckSize(d, sizeof(FTM::DimStaticData)))
|
---|
2100 | return;
|
---|
2101 |
|
---|
2102 | const FTM::DimStaticData &sdata = d.ref<FTM::DimStaticData>();
|
---|
2103 |
|
---|
2104 | fTriggerInterval->setValue(sdata.fTriggerInterval);
|
---|
2105 | fPhysicsCoincidence->setValue(sdata.fMultiplicityPhysics);
|
---|
2106 | fCalibCoincidence->setValue(sdata.fMultiplicityCalib);
|
---|
2107 | fPhysicsWindow->setValue(sdata.fWindowPhysics);
|
---|
2108 | fCalibWindow->setValue(sdata.fWindowCalib);
|
---|
2109 |
|
---|
2110 | fTriggerDelay->setValue(sdata.fDelayTrigger);
|
---|
2111 | fTimeMarkerDelay->setValue(sdata.fDelayTimeMarker);
|
---|
2112 | fDeadTime->setValue(sdata.fDeadTime);
|
---|
2113 |
|
---|
2114 | fClockCondR0->setValue(sdata.fClockConditioner[0]);
|
---|
2115 | fClockCondR1->setValue(sdata.fClockConditioner[1]);
|
---|
2116 | fClockCondR8->setValue(sdata.fClockConditioner[2]);
|
---|
2117 | fClockCondR9->setValue(sdata.fClockConditioner[3]);
|
---|
2118 | fClockCondR11->setValue(sdata.fClockConditioner[4]);
|
---|
2119 | fClockCondR13->setValue(sdata.fClockConditioner[5]);
|
---|
2120 | fClockCondR14->setValue(sdata.fClockConditioner[6]);
|
---|
2121 | fClockCondR15->setValue(sdata.fClockConditioner[7]);
|
---|
2122 |
|
---|
2123 | const uint32_t R0 = sdata.fClockConditioner[0];
|
---|
2124 | const uint32_t R14 = sdata.fClockConditioner[6];
|
---|
2125 | const uint32_t R15 = sdata.fClockConditioner[7];
|
---|
2126 |
|
---|
2127 | const uint32_t Ndiv = (R15&0x1ffff00)<<2;
|
---|
2128 | const uint32_t Rdiv = (R14&0x007ff00)>>8;
|
---|
2129 | const uint32_t Cdiv = (R0 &0x000ff00)>>8;
|
---|
2130 |
|
---|
2131 | double freq = 40.*Ndiv/(Rdiv*Cdiv);
|
---|
2132 |
|
---|
2133 | fClockCondFreqRes->setValue(freq);
|
---|
2134 |
|
---|
2135 | //fClockCondFreq->setEditText("");
|
---|
2136 | fClockCondFreq->setCurrentIndex(0);
|
---|
2137 |
|
---|
2138 | fTriggerSeqPed->setValue(sdata.fTriggerSeqPed);
|
---|
2139 | fTriggerSeqLPint->setValue(sdata.fTriggerSeqLPint);
|
---|
2140 | fTriggerSeqLPext->setValue(sdata.fTriggerSeqLPext);
|
---|
2141 |
|
---|
2142 | fLpIntIntensity->setValue(sdata.fIntensityLPint);
|
---|
2143 | fLpExtIntensity->setValue(sdata.fIntensityLPext);
|
---|
2144 |
|
---|
2145 | fLpIntGroup1->setChecked(sdata.HasLPintG1());
|
---|
2146 | fLpIntGroup2->setChecked(sdata.HasLPintG2());
|
---|
2147 | fLpExtGroup1->setChecked(sdata.HasLPextG1());
|
---|
2148 | fLpExtGroup2->setChecked(sdata.HasLPextG2());
|
---|
2149 |
|
---|
2150 | fEnableTrigger->setChecked(sdata.HasTrigger());
|
---|
2151 | fEnableVeto->setChecked(sdata.HasVeto());
|
---|
2152 | fEnableExt1->setChecked(sdata.HasExt1());
|
---|
2153 | fEnableExt2->setChecked(sdata.HasExt2());
|
---|
2154 | fEnableClockCond->setChecked(sdata.HasClockConditioner());
|
---|
2155 |
|
---|
2156 | for (int i=0; i<40; i++)
|
---|
2157 | {
|
---|
2158 | if (!sdata.IsActive(i))
|
---|
2159 | SetFtuLed(i, -1, d.time);
|
---|
2160 | else
|
---|
2161 | {
|
---|
2162 | if (fFtuStatus[i]==0)
|
---|
2163 | SetFtuLed(i, 1, d.time);
|
---|
2164 | }
|
---|
2165 | fFtuLED[i]->setChecked(false);
|
---|
2166 | }
|
---|
2167 | SetFtuStatusLed(d.time);
|
---|
2168 |
|
---|
2169 | #ifdef HAVE_ROOT
|
---|
2170 | Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
|
---|
2171 | for (int isw=0; isw<1440; isw++)
|
---|
2172 | {
|
---|
2173 | const int ihw = fPixelMapHW[isw];
|
---|
2174 | cam->SetEnable(isw, sdata.IsEnabled(ihw));
|
---|
2175 | }
|
---|
2176 |
|
---|
2177 | fRatesCanv->GetCanvas()->Modified();
|
---|
2178 | fRatesCanv->GetCanvas()->Update();
|
---|
2179 | #endif
|
---|
2180 |
|
---|
2181 | {
|
---|
2182 | const int isw = fPixelIdx->value();
|
---|
2183 | const int ihw = fPixelMapHW[isw];
|
---|
2184 | const bool on = sdata.IsEnabled(ihw);
|
---|
2185 | fPixelEnable->setChecked(on);
|
---|
2186 | }
|
---|
2187 |
|
---|
2188 | if (fThresholdIdx->value()>=0)
|
---|
2189 | {
|
---|
2190 | const int isw = fThresholdIdx->value();
|
---|
2191 | const int ihw = fPatchMapHW[isw];
|
---|
2192 | fThresholdVal->setValue(sdata.fThreshold[ihw]);
|
---|
2193 | }
|
---|
2194 |
|
---|
2195 | fPrescalingVal->setValue(sdata.fPrescaling[0]);
|
---|
2196 |
|
---|
2197 | fFtmStaticData = sdata;
|
---|
2198 | }
|
---|
2199 |
|
---|
2200 | void handleFtmPassport(const DimData &d)
|
---|
2201 | {
|
---|
2202 | if (!CheckSize(d, sizeof(FTM::DimPassport)))
|
---|
2203 | return;
|
---|
2204 |
|
---|
2205 | const FTM::DimPassport &sdata = d.ref<FTM::DimPassport>();
|
---|
2206 |
|
---|
2207 | stringstream str1, str2;
|
---|
2208 | str1 << hex << "0x" << setfill('0') << setw(16) << sdata.fBoardId;
|
---|
2209 | str2 << sdata.fFirmwareId;
|
---|
2210 |
|
---|
2211 | fFtmBoardId->setText(str1.str().c_str());
|
---|
2212 | fFtmFirmwareId->setText(str2.str().c_str());
|
---|
2213 | }
|
---|
2214 |
|
---|
2215 | void handleFtmFtuList(const DimData &d)
|
---|
2216 | {
|
---|
2217 | if (!CheckSize(d, sizeof(FTM::DimFtuList)))
|
---|
2218 | return;
|
---|
2219 |
|
---|
2220 | fFtuPing->setChecked(false);
|
---|
2221 |
|
---|
2222 | const FTM::DimFtuList &sdata = d.ref<FTM::DimFtuList>();
|
---|
2223 |
|
---|
2224 | stringstream str;
|
---|
2225 | str << "<table width='100%'>" << setfill('0');
|
---|
2226 | str << "<tr><th>Num</th><th></th><th>Addr</th><th></th><th>DNA</th></tr>";
|
---|
2227 | for (int i=0; i<40; i++)
|
---|
2228 | {
|
---|
2229 | str << "<tr>";
|
---|
2230 | str << "<td align='center'>" << dec << i << hex << "</td>";
|
---|
2231 | str << "<td align='center'>:</td>";
|
---|
2232 | str << "<td align='center'>0x" << setw(2) << (int)sdata.fAddr[i] << "</td>";
|
---|
2233 | str << "<td align='center'>:</td>";
|
---|
2234 | str << "<td align='center'>0x" << setw(16) << sdata.fDNA[i] << "</td>";
|
---|
2235 | str << "</tr>";
|
---|
2236 | }
|
---|
2237 | str << "</table>";
|
---|
2238 |
|
---|
2239 | fFtuDNA->setText(str.str().c_str());
|
---|
2240 |
|
---|
2241 | fFtuAnswersTotal->setValue(sdata.fNumBoards);
|
---|
2242 | fFtuAnswersCrate0->setValue(sdata.fNumBoardsCrate[0]);
|
---|
2243 | fFtuAnswersCrate1->setValue(sdata.fNumBoardsCrate[1]);
|
---|
2244 | fFtuAnswersCrate2->setValue(sdata.fNumBoardsCrate[2]);
|
---|
2245 | fFtuAnswersCrate3->setValue(sdata.fNumBoardsCrate[3]);
|
---|
2246 |
|
---|
2247 | for (int i=0; i<40; i++)
|
---|
2248 | SetFtuLed(i, sdata.IsActive(i) ? sdata.fPing[i] : -1, d.time);
|
---|
2249 |
|
---|
2250 | SetFtuStatusLed(d.time);
|
---|
2251 | }
|
---|
2252 |
|
---|
2253 | void handleFtmError(const DimData &d)
|
---|
2254 | {
|
---|
2255 | if (!CheckSize(d, sizeof(FTM::DimError)))
|
---|
2256 | return;
|
---|
2257 |
|
---|
2258 | const FTM::DimError &sdata = d.ref<FTM::DimError>();
|
---|
2259 |
|
---|
2260 | SetFtuLed(sdata.fError.fDestAddress, sdata.fError.fNumCalls, d.time);
|
---|
2261 | SetFtuStatusLed(d.time);
|
---|
2262 |
|
---|
2263 | // FIXME: Write to special window!
|
---|
2264 | //Out() << "Error:" << endl;
|
---|
2265 | //Out() << sdata.fError << endl;
|
---|
2266 | }
|
---|
2267 |
|
---|
2268 | // ====================== MessageImp ====================================
|
---|
2269 |
|
---|
2270 | bool fChatOnline;
|
---|
2271 |
|
---|
2272 | void handleStateChanged(const Time &time, const std::string &server,
|
---|
2273 | const State &s)
|
---|
2274 | {
|
---|
2275 | // FIXME: Prefix tooltip with time
|
---|
2276 | if (server=="FTM_CONTROL")
|
---|
2277 | {
|
---|
2278 | // FIXME: Enable FTU page!!!
|
---|
2279 | fStatusFTMLabel->setText(s.name.c_str());
|
---|
2280 | fStatusFTMLabel->setToolTip(s.comment.c_str());
|
---|
2281 |
|
---|
2282 | bool enable = false;
|
---|
2283 |
|
---|
2284 | if (s.index<FTM::StateMachine::kDisconnected) // No Dim connection
|
---|
2285 | SetLedColor(fStatusFTMLed, kLedGray, time);
|
---|
2286 | if (s.index==FTM::StateMachine::kDisconnected) // Dim connection / FTM disconnected
|
---|
2287 | SetLedColor(fStatusFTMLed, kLedYellow, time);
|
---|
2288 | if (s.index==FTM::StateMachine::kConnected ||
|
---|
2289 | s.index==FTM::StateMachine::kIdle ||
|
---|
2290 | s.index==FTM::StateMachine::kConfiguring1 ||
|
---|
2291 | s.index==FTM::StateMachine::kConfiguring2 ||
|
---|
2292 | s.index==FTM::StateMachine::kConfigured ||
|
---|
2293 | s.index==FTM::StateMachine::kTakingData) // Dim connection / FTM connected
|
---|
2294 | SetLedColor(fStatusFTMLed, kLedGreen, time);
|
---|
2295 |
|
---|
2296 | if (s.index==FTM::StateMachine::kConnected ||
|
---|
2297 | s.index==FTM::StateMachine::kIdle) // Dim connection / FTM connected
|
---|
2298 | enable = true;
|
---|
2299 |
|
---|
2300 | fTriggerWidget->setEnabled(enable);
|
---|
2301 | fFtuGroupEnable->setEnabled(enable);
|
---|
2302 | fRatesControls->setEnabled(enable);
|
---|
2303 | fFtuWidget->setEnabled(s.index>FTM::StateMachine::kDisconnected);
|
---|
2304 |
|
---|
2305 | if (s.index>=FTM::StateMachine::kConnected)
|
---|
2306 | SetFtuStatusLed(time);
|
---|
2307 | else
|
---|
2308 | {
|
---|
2309 | SetLedColor(fStatusFTULed, kLedGray, time);
|
---|
2310 | fStatusFTULabel->setText("Offline");
|
---|
2311 | fStatusFTULabel->setToolTip("FTM is not online.");
|
---|
2312 | }
|
---|
2313 | }
|
---|
2314 |
|
---|
2315 | if (server=="FAD_CONTROL")
|
---|
2316 | {
|
---|
2317 | fStatusFADLabel->setText(s.name.c_str());
|
---|
2318 | fStatusFADLabel->setToolTip(s.comment.c_str());
|
---|
2319 |
|
---|
2320 | bool enable = false;
|
---|
2321 |
|
---|
2322 | if (s.index<FAD::kOffline) // No Dim connection
|
---|
2323 | {
|
---|
2324 | SetLedColor(fStatusFADLed, kLedGray, time);
|
---|
2325 |
|
---|
2326 | // Timing problem - sometimes they stay gray :(
|
---|
2327 | //for (int i=0; i<40; i++)
|
---|
2328 | // SetLedColor(fFadLED[i], kLedGray, time);
|
---|
2329 |
|
---|
2330 | /*
|
---|
2331 | fStatusEventBuilderLabel->setText("Offline");
|
---|
2332 | fStatusEventBuilderLabel->setToolTip("No connection to fadctrl.");
|
---|
2333 | fEvtBldWidget->setEnabled(false);
|
---|
2334 |
|
---|
2335 | SetLedColor(fStatusEventBuilderLed, kLedGray, time);
|
---|
2336 | */
|
---|
2337 | }
|
---|
2338 | if (s.index==FAD::kOffline) // Dim connection / FTM disconnected
|
---|
2339 | SetLedColor(fStatusFADLed, kLedRed, time);
|
---|
2340 | if (s.index==FAD::kDisconnected) // Dim connection / FTM disconnected
|
---|
2341 | SetLedColor(fStatusFADLed, kLedOrange, time);
|
---|
2342 | if (s.index==FAD::kConnecting) // Dim connection / FTM disconnected
|
---|
2343 | {
|
---|
2344 | SetLedColor(fStatusFADLed, kLedYellow, time);
|
---|
2345 | // FIXME FIXME FIXME: The LEDs are not displayed when disabled!
|
---|
2346 | enable = true;
|
---|
2347 | }
|
---|
2348 | if (s.index>=FAD::kConnected) // Dim connection / FTM connected
|
---|
2349 | {
|
---|
2350 | SetLedColor(fStatusFADLed, kLedGreen, time);
|
---|
2351 | enable = true;
|
---|
2352 | }
|
---|
2353 |
|
---|
2354 | fFadWidget->setEnabled(enable);
|
---|
2355 | }
|
---|
2356 |
|
---|
2357 | if (server=="FSC_CONTROL")
|
---|
2358 | {
|
---|
2359 | fStatusFSCLabel->setText(s.name.c_str());
|
---|
2360 | fStatusFSCLabel->setToolTip(s.comment.c_str());
|
---|
2361 |
|
---|
2362 | bool enable = false;
|
---|
2363 |
|
---|
2364 | if (s.index<1) // No Dim connection
|
---|
2365 | SetLedColor(fStatusFSCLed, kLedGray, time);
|
---|
2366 | if (s.index==1) // Dim connection / FTM disconnected
|
---|
2367 | SetLedColor(fStatusFSCLed, kLedRed, time);
|
---|
2368 | if (s.index>=2) // Dim connection / FTM disconnected
|
---|
2369 | {
|
---|
2370 | SetLedColor(fStatusFSCLed, kLedGreen, time);
|
---|
2371 | enable = true;
|
---|
2372 | }
|
---|
2373 |
|
---|
2374 | //fFscWidget->setEnabled(enable);
|
---|
2375 | }
|
---|
2376 |
|
---|
2377 | if (server=="DATA_LOGGER")
|
---|
2378 | {
|
---|
2379 | fStatusLoggerLabel->setText(s.name.c_str());
|
---|
2380 | fStatusLoggerLabel->setToolTip(s.comment.c_str());
|
---|
2381 |
|
---|
2382 | bool enable = true;
|
---|
2383 |
|
---|
2384 | if (s.index<=30) // Ready/Waiting
|
---|
2385 | SetLedColor(fStatusLoggerLed, kLedYellow, time);
|
---|
2386 | if (s.index<-1) // Offline
|
---|
2387 | {
|
---|
2388 | SetLedColor(fStatusLoggerLed, kLedGray, time);
|
---|
2389 | enable = false;
|
---|
2390 | }
|
---|
2391 | if (s.index>=0x100) // Error
|
---|
2392 | SetLedColor(fStatusLoggerLed, kLedRed, time);
|
---|
2393 | if (s.index==40) // Logging
|
---|
2394 | SetLedColor(fStatusLoggerLed, kLedGreen, time);
|
---|
2395 |
|
---|
2396 | fLoggerWidget->setEnabled(enable);
|
---|
2397 | }
|
---|
2398 |
|
---|
2399 | if (server=="CHAT")
|
---|
2400 | {
|
---|
2401 | fStatusChatLabel->setText(s.name.c_str());
|
---|
2402 |
|
---|
2403 | fChatOnline = s.index==0;
|
---|
2404 |
|
---|
2405 | SetLedColor(fStatusChatLed, fChatOnline ? kLedGreen : kLedGray, time);
|
---|
2406 |
|
---|
2407 | fChatSend->setEnabled(fChatOnline);
|
---|
2408 | fChatMessage->setEnabled(fChatOnline);
|
---|
2409 | }
|
---|
2410 |
|
---|
2411 | if (server=="SCHEDULER")
|
---|
2412 | {
|
---|
2413 | fStatusSchedulerLabel->setText(s.name.c_str());
|
---|
2414 |
|
---|
2415 | SetLedColor(fStatusSchedulerLed, s.index>=0 ? kLedGreen : kLedRed, time);
|
---|
2416 | }
|
---|
2417 | }
|
---|
2418 |
|
---|
2419 | void on_fTabWidget_currentChanged(int which)
|
---|
2420 | {
|
---|
2421 | if (fTabWidget->tabText(which)=="Chat")
|
---|
2422 | fTabWidget->setTabIcon(which, QIcon());
|
---|
2423 | }
|
---|
2424 |
|
---|
2425 | void handleWrite(const Time &time, const string &text, int qos)
|
---|
2426 | {
|
---|
2427 | stringstream out;
|
---|
2428 |
|
---|
2429 | if (text.substr(0, 6)=="CHAT: ")
|
---|
2430 | {
|
---|
2431 | if (qos==MessageImp::kDebug)
|
---|
2432 | return;
|
---|
2433 |
|
---|
2434 | out << "<font size='-1' color='navy'>[<B>";
|
---|
2435 | out << time.GetAsStr("%H:%M:%S");
|
---|
2436 | out << "</B>]</FONT> " << text.substr(6);
|
---|
2437 | fChatText->append(out.str().c_str());
|
---|
2438 |
|
---|
2439 | if (fTabWidget->tabText(fTabWidget->currentIndex())=="Chat")
|
---|
2440 | return;
|
---|
2441 |
|
---|
2442 | static int num = 0;
|
---|
2443 | if (num++<2)
|
---|
2444 | return;
|
---|
2445 |
|
---|
2446 | for (int i=0; i<fTabWidget->count(); i++)
|
---|
2447 | if (fTabWidget->tabText(i)=="Chat")
|
---|
2448 | {
|
---|
2449 | fTabWidget->setTabIcon(i, QIcon(":/Resources/icons/warning 3.png"));
|
---|
2450 | break;
|
---|
2451 | }
|
---|
2452 |
|
---|
2453 | return;
|
---|
2454 | }
|
---|
2455 |
|
---|
2456 |
|
---|
2457 | out << "<font style='font-family:monospace' color='";
|
---|
2458 |
|
---|
2459 | switch (qos)
|
---|
2460 | {
|
---|
2461 | case kMessage: out << "black"; break;
|
---|
2462 | case kInfo: out << "green"; break;
|
---|
2463 | case kWarn: out << "#FF6600"; break;
|
---|
2464 | case kError: out << "maroon"; break;
|
---|
2465 | case kFatal: out << "maroon"; break;
|
---|
2466 | case kDebug: out << "navy"; break;
|
---|
2467 | default: out << "navy"; break;
|
---|
2468 | }
|
---|
2469 | out << "'>";
|
---|
2470 | out << time.GetAsStr("%H:%M:%S.%f").substr(0,12);
|
---|
2471 | out << " - " << text << "</font>";
|
---|
2472 |
|
---|
2473 | fLogText->append(out.str().c_str());
|
---|
2474 |
|
---|
2475 | if (qos>=kWarn && qos!=kDebug)
|
---|
2476 | fTextEdit->append(out.str().c_str());
|
---|
2477 | }
|
---|
2478 |
|
---|
2479 | void IndicateStateChange(const Time &time, const std::string &server)
|
---|
2480 | {
|
---|
2481 | const State s = GetState(server, GetCurrentState(server));
|
---|
2482 |
|
---|
2483 | QApplication::postEvent(this,
|
---|
2484 | new FunctionEvent(boost::bind(&FactGui::handleStateChanged, this, time, server, s)));
|
---|
2485 | }
|
---|
2486 |
|
---|
2487 | int Write(const Time &time, const string &txt, int qos)
|
---|
2488 | {
|
---|
2489 | QApplication::postEvent(this,
|
---|
2490 | new FunctionEvent(boost::bind(&FactGui::handleWrite, this, time, txt, qos)));
|
---|
2491 |
|
---|
2492 | return 0;
|
---|
2493 | }
|
---|
2494 |
|
---|
2495 | // ====================== Dim infoHandler================================
|
---|
2496 |
|
---|
2497 | void handleDimService(const string &txt)
|
---|
2498 | {
|
---|
2499 | fDimSvcText->append(txt.c_str());
|
---|
2500 | }
|
---|
2501 |
|
---|
2502 | void infoHandlerService(DimInfo &info)
|
---|
2503 | {
|
---|
2504 | const string fmt = string(info.getFormat()).empty() ? "C" : info.getFormat();
|
---|
2505 |
|
---|
2506 | stringstream dummy;
|
---|
2507 | const Converter conv(dummy, fmt, false);
|
---|
2508 |
|
---|
2509 | const Time tm(info.getTimestamp(), info.getTimestampMillisecs()*1000);
|
---|
2510 |
|
---|
2511 | stringstream out;
|
---|
2512 | out << "<font size'-1' color='navy'>[";
|
---|
2513 | out << tm.GetAsStr("%H:%M:%S.%f").substr(0,12);
|
---|
2514 | out << "]</font> <B>" << info.getName() << "</B> - ";
|
---|
2515 |
|
---|
2516 | bool iserr = true;
|
---|
2517 | if (!conv)
|
---|
2518 | {
|
---|
2519 | out << "Compilation of format string '" << fmt << "' failed!";
|
---|
2520 | }
|
---|
2521 | else
|
---|
2522 | {
|
---|
2523 | try
|
---|
2524 | {
|
---|
2525 | const string dat = conv.GetString(info.getData(), info.getSize());
|
---|
2526 | out << dat;
|
---|
2527 | iserr = false;
|
---|
2528 | }
|
---|
2529 | catch (const runtime_error &e)
|
---|
2530 | {
|
---|
2531 | out << "Conversion to string failed!<pre>" << e.what() << "</pre>";
|
---|
2532 | }
|
---|
2533 | }
|
---|
2534 |
|
---|
2535 | // srand(hash<string>()(string(info.getName())));
|
---|
2536 | // int bg = rand()&0xffffff;
|
---|
2537 |
|
---|
2538 | int bg = hash<string>()(string(info.getName()));
|
---|
2539 |
|
---|
2540 | // allow only light colors
|
---|
2541 | bg = ~(bg&0x1f1f1f)&0xffffff;
|
---|
2542 |
|
---|
2543 | if (iserr)
|
---|
2544 | bg = 0xffffff;
|
---|
2545 |
|
---|
2546 | stringstream bgcol;
|
---|
2547 | bgcol << hex << setfill('0') << setw(6) << bg;
|
---|
2548 |
|
---|
2549 | const string col = iserr ? "red" : "black";
|
---|
2550 | const string str = "<table width='100%' bgcolor=#"+bgcol.str()+"><tr><td><font color='"+col+"'>"+out.str()+"</font></td></tr></table>";
|
---|
2551 |
|
---|
2552 | QApplication::postEvent(this,
|
---|
2553 | new FunctionEvent(boost::bind(&FactGui::handleDimService, this, str)));
|
---|
2554 | }
|
---|
2555 |
|
---|
2556 | void CallInfoHandler(void (FactGui::*handler)(const DimData&), const DimData &d)
|
---|
2557 | {
|
---|
2558 | fInHandler = true;
|
---|
2559 | (this->*handler)(d);
|
---|
2560 | fInHandler = false;
|
---|
2561 | }
|
---|
2562 |
|
---|
2563 | /*
|
---|
2564 | void CallInfoHandler(const boost::function<void()> &func)
|
---|
2565 | {
|
---|
2566 | // This ensures that newly received values are not sent back to the emitter
|
---|
2567 | // because changing the value emits the valueChanged signal (or similar)
|
---|
2568 | fInHandler = true;
|
---|
2569 | func();
|
---|
2570 | fInHandler = false;
|
---|
2571 | }*/
|
---|
2572 |
|
---|
2573 | void PostInfoHandler(void (FactGui::*handler)(const DimData&))
|
---|
2574 | {
|
---|
2575 | //const boost::function<void()> f = boost::bind(handler, this, DimData(getInfo()));
|
---|
2576 |
|
---|
2577 | FunctionEvent *evt = new FunctionEvent(boost::bind(&FactGui::CallInfoHandler, this, handler, DimData(getInfo())));
|
---|
2578 | // FunctionEvent *evt = new FunctionEvent(boost::bind(&FactGui::CallInfoHandler, this, f));
|
---|
2579 | // FunctionEvent *evt = new FunctionEvent(boost::bind(handler, this, DimData(getInfo()))));
|
---|
2580 |
|
---|
2581 | QApplication::postEvent(this, evt);
|
---|
2582 | }
|
---|
2583 |
|
---|
2584 | void infoHandler()
|
---|
2585 | {
|
---|
2586 | // Initialize the time-stamp (what a weird workaround...)
|
---|
2587 | if (getInfo())
|
---|
2588 | getInfo()->getTimestamp();
|
---|
2589 |
|
---|
2590 | if (getInfo()==&fDimDNS)
|
---|
2591 | return PostInfoHandler(&FactGui::handleDimDNS);
|
---|
2592 | #ifdef DEBUG_DIM
|
---|
2593 | cout << "HandleDimInfo " << getInfo()->getName() << endl;
|
---|
2594 | #endif
|
---|
2595 | if (getInfo()==&fDimLoggerStats)
|
---|
2596 | return PostInfoHandler(&FactGui::handleLoggerStats);
|
---|
2597 |
|
---|
2598 | // if (getInfo()==&fDimFadFiles)
|
---|
2599 | // return PostInfoHandler(&FactGui::handleFadFiles);
|
---|
2600 |
|
---|
2601 | if (getInfo()==&fDimFadWriteStats)
|
---|
2602 | return PostInfoHandler(&FactGui::handleFadWriteStats);
|
---|
2603 |
|
---|
2604 | if (getInfo()==&fDimFadConnections)
|
---|
2605 | return PostInfoHandler(&FactGui::handleFadConnections);
|
---|
2606 |
|
---|
2607 | if (getInfo()==&fDimFadFwVersion)
|
---|
2608 | return PostInfoHandler(&FactGui::handleFadFwVersion);
|
---|
2609 |
|
---|
2610 | if (getInfo()==&fDimFadRunNumber)
|
---|
2611 | return PostInfoHandler(&FactGui::handleFadRunNumber);
|
---|
2612 |
|
---|
2613 | if (getInfo()==&fDimFadDNA)
|
---|
2614 | return PostInfoHandler(&FactGui::handleFadDNA);
|
---|
2615 |
|
---|
2616 | if (getInfo()==&fDimFadTemperature)
|
---|
2617 | return PostInfoHandler(&FactGui::handleFadTemperature);
|
---|
2618 |
|
---|
2619 | if (getInfo()==&fDimFadRefClock)
|
---|
2620 | return PostInfoHandler(&FactGui::handleFadRefClock);
|
---|
2621 |
|
---|
2622 | if (getInfo()==&fDimFadRoi)
|
---|
2623 | return PostInfoHandler(&FactGui::handleFadRoi);
|
---|
2624 |
|
---|
2625 | if (getInfo()==&fDimFadDac)
|
---|
2626 | return PostInfoHandler(&FactGui::handleFadDac);
|
---|
2627 |
|
---|
2628 | if (getInfo()==&fDimFadDrsCalibration)
|
---|
2629 | return PostInfoHandler(&FactGui::handleFadDrsCalibration);
|
---|
2630 |
|
---|
2631 | if (getInfo()==&fDimFadPrescaler)
|
---|
2632 | return PostInfoHandler(&FactGui::handleFadPrescaler);
|
---|
2633 |
|
---|
2634 | if (getInfo()==&fDimFadStatus)
|
---|
2635 | return PostInfoHandler(&FactGui::handleFadStatus);
|
---|
2636 |
|
---|
2637 | if (getInfo()==&fDimFadStatistics1)
|
---|
2638 | return PostInfoHandler(&FactGui::handleFadStatistics1);
|
---|
2639 |
|
---|
2640 | if (getInfo()==&fDimFadStatistics2)
|
---|
2641 | return PostInfoHandler(&FactGui::handleFadStatistics2);
|
---|
2642 |
|
---|
2643 | if (getInfo()==&fDimFadEvents)
|
---|
2644 | return PostInfoHandler(&FactGui::handleFadEvents);
|
---|
2645 |
|
---|
2646 | if (getInfo()==&fDimFadRuns)
|
---|
2647 | return PostInfoHandler(&FactGui::handleFadRuns);
|
---|
2648 |
|
---|
2649 | if (getInfo()==&fDimFadRawData)
|
---|
2650 | return PostInfoHandler(&FactGui::handleFadRawData);
|
---|
2651 |
|
---|
2652 | if (getInfo()==&fDimFadEventData)
|
---|
2653 | return PostInfoHandler(&FactGui::handleFadEventData);
|
---|
2654 |
|
---|
2655 | /*
|
---|
2656 | if (getInfo()==&fDimFadSetup)
|
---|
2657 | return PostInfoHandler(&FactGui::handleFadSetup);
|
---|
2658 | */
|
---|
2659 | if (getInfo()==&fDimLoggerFilenameNight)
|
---|
2660 | return PostInfoHandler(&FactGui::handleLoggerFilenameNight);
|
---|
2661 |
|
---|
2662 | if (getInfo()==&fDimLoggerNumSubs)
|
---|
2663 | return PostInfoHandler(&FactGui::handleLoggerNumSubs);
|
---|
2664 |
|
---|
2665 | if (getInfo()==&fDimLoggerFilenameRun)
|
---|
2666 | return PostInfoHandler(&FactGui::handleLoggerFilenameRun);
|
---|
2667 |
|
---|
2668 | if (getInfo()==&fDimFtmTriggerRates)
|
---|
2669 | return PostInfoHandler(&FactGui::handleFtmTriggerRates);
|
---|
2670 |
|
---|
2671 | if (getInfo()==&fDimFtmCounter)
|
---|
2672 | return PostInfoHandler(&FactGui::handleFtmCounter);
|
---|
2673 |
|
---|
2674 | if (getInfo()==&fDimFtmDynamicData)
|
---|
2675 | return PostInfoHandler(&FactGui::handleFtmDynamicData);
|
---|
2676 |
|
---|
2677 | if (getInfo()==&fDimFtmPassport)
|
---|
2678 | return PostInfoHandler(&FactGui::handleFtmPassport);
|
---|
2679 |
|
---|
2680 | if (getInfo()==&fDimFtmFtuList)
|
---|
2681 | return PostInfoHandler(&FactGui::handleFtmFtuList);
|
---|
2682 |
|
---|
2683 | if (getInfo()==&fDimFtmStaticData)
|
---|
2684 | return PostInfoHandler(&FactGui::handleFtmStaticData);
|
---|
2685 |
|
---|
2686 | if (getInfo()==&fDimFtmError)
|
---|
2687 | return PostInfoHandler(&FactGui::handleFtmError);
|
---|
2688 |
|
---|
2689 | // if (getInfo()==&fDimFadFiles)
|
---|
2690 | // return PostInfoHandler(&FactGui::handleFadFiles);
|
---|
2691 |
|
---|
2692 | for (map<string,DimInfo*>::iterator i=fServices.begin(); i!=fServices.end(); i++)
|
---|
2693 | if (i->second==getInfo())
|
---|
2694 | {
|
---|
2695 | infoHandlerService(*i->second);
|
---|
2696 | return;
|
---|
2697 | }
|
---|
2698 |
|
---|
2699 | DimNetwork::infoHandler();
|
---|
2700 | }
|
---|
2701 |
|
---|
2702 |
|
---|
2703 | // ======================================================================
|
---|
2704 |
|
---|
2705 | bool event(QEvent *evt)
|
---|
2706 | {
|
---|
2707 | if (dynamic_cast<FunctionEvent*>(evt))
|
---|
2708 | return static_cast<FunctionEvent*>(evt)->Exec();
|
---|
2709 |
|
---|
2710 | if (dynamic_cast<CheckBoxEvent*>(evt))
|
---|
2711 | {
|
---|
2712 | const QStandardItem &item = static_cast<CheckBoxEvent*>(evt)->item;
|
---|
2713 | const QStandardItem *par = item.parent();
|
---|
2714 | if (par)
|
---|
2715 | {
|
---|
2716 | const QString server = par->text();
|
---|
2717 | const QString service = item.text();
|
---|
2718 |
|
---|
2719 | const string s = (server+'/'+service).toStdString();
|
---|
2720 |
|
---|
2721 | if (item.checkState()==Qt::Checked)
|
---|
2722 | SubscribeService(s);
|
---|
2723 | else
|
---|
2724 | UnsubscribeService(s);
|
---|
2725 | }
|
---|
2726 | }
|
---|
2727 |
|
---|
2728 | return MainWindow::event(evt); // unrecognized
|
---|
2729 | }
|
---|
2730 |
|
---|
2731 | void on_fDimCmdSend_clicked()
|
---|
2732 | {
|
---|
2733 | const QString server = fDimCmdServers->currentIndex().data().toString();
|
---|
2734 | const QString command = fDimCmdCommands->currentIndex().data().toString();
|
---|
2735 | const QString arguments = fDimCmdLineEdit->displayText();
|
---|
2736 |
|
---|
2737 | // FIXME: Sending a command exactly when the info Handler changes
|
---|
2738 | // the list it might lead to confusion.
|
---|
2739 | try
|
---|
2740 | {
|
---|
2741 | SendDimCommand(server.toStdString(), command.toStdString()+" "+arguments.toStdString());
|
---|
2742 | fTextEdit->append("<font color='green'>Command '"+server+'/'+command+"' successfully emitted.</font>");
|
---|
2743 | fDimCmdLineEdit->clear();
|
---|
2744 | }
|
---|
2745 | catch (const runtime_error &e)
|
---|
2746 | {
|
---|
2747 | stringstream txt;
|
---|
2748 | txt << e.what();
|
---|
2749 |
|
---|
2750 | string buffer;
|
---|
2751 | while (getline(txt, buffer, '\n'))
|
---|
2752 | fTextEdit->append(("<font color='red'><pre>"+buffer+"</pre></font>").c_str());
|
---|
2753 | }
|
---|
2754 | }
|
---|
2755 |
|
---|
2756 | #ifdef HAVE_ROOT
|
---|
2757 | void slot_RootEventProcessed(TObject *obj, unsigned int evt, TCanvas *canv)
|
---|
2758 | {
|
---|
2759 | // kMousePressEvent // TCanvas processed QEvent mousePressEvent
|
---|
2760 | // kMouseMoveEvent // TCanvas processed QEvent mouseMoveEvent
|
---|
2761 | // kMouseReleaseEvent // TCanvas processed QEvent mouseReleaseEvent
|
---|
2762 | // kMouseDoubleClickEvent // TCanvas processed QEvent mouseDoubleClickEvent
|
---|
2763 | // kKeyPressEvent // TCanvas processed QEvent keyPressEvent
|
---|
2764 | // kEnterEvent // TCanvas processed QEvent enterEvent
|
---|
2765 | // kLeaveEvent // TCanvas processed QEvent leaveEvent
|
---|
2766 | if (dynamic_cast<TCanvas*>(obj))
|
---|
2767 | return;
|
---|
2768 |
|
---|
2769 | TQtWidget *tipped = static_cast<TQtWidget*>(sender());
|
---|
2770 |
|
---|
2771 | if (evt==11/*kMouseReleaseEvent*/)
|
---|
2772 | {
|
---|
2773 | if (dynamic_cast<Camera*>(obj))
|
---|
2774 | {
|
---|
2775 | const float xx = canv->AbsPixeltoX(tipped->GetEventX());
|
---|
2776 | const float yy = canv->AbsPixeltoY(tipped->GetEventY());
|
---|
2777 |
|
---|
2778 | Camera *cam = static_cast<Camera*>(obj);
|
---|
2779 | const int isw = cam->GetIdx(xx, yy);
|
---|
2780 |
|
---|
2781 | fPixelIdx->setValue(isw);
|
---|
2782 | ChoosePixel(*cam, isw);
|
---|
2783 | }
|
---|
2784 | return;
|
---|
2785 | }
|
---|
2786 |
|
---|
2787 | if (evt==61/*kMouseDoubleClickEvent*/)
|
---|
2788 | {
|
---|
2789 | if (dynamic_cast<Camera*>(obj) && fRatesControls->isEnabled())
|
---|
2790 | {
|
---|
2791 | const float xx = canv->AbsPixeltoX(tipped->GetEventX());
|
---|
2792 | const float yy = canv->AbsPixeltoY(tipped->GetEventY());
|
---|
2793 |
|
---|
2794 | Camera *cam = static_cast<Camera*>(obj);
|
---|
2795 | const int isw = cam->GetIdx(xx, yy);
|
---|
2796 |
|
---|
2797 | ChoosePixel(*cam, isw);
|
---|
2798 |
|
---|
2799 | fPixelIdx->setValue(isw);
|
---|
2800 |
|
---|
2801 | const uint16_t ihw = fPixelMapHW[isw];
|
---|
2802 |
|
---|
2803 | Dim::SendCommand("FTM_CONTROL/TOGGLE_PIXEL", ihw);
|
---|
2804 | }
|
---|
2805 |
|
---|
2806 | if (dynamic_cast<TAxis*>(obj))
|
---|
2807 | static_cast<TAxis*>(obj)->UnZoom();
|
---|
2808 |
|
---|
2809 | return;
|
---|
2810 | }
|
---|
2811 |
|
---|
2812 | if (obj)
|
---|
2813 | {
|
---|
2814 | // Find the object which will get picked by the GetObjectInfo
|
---|
2815 | // due to buffer overflows in many root-versions
|
---|
2816 | // in TH1 and TProfile we have to work around and implement
|
---|
2817 | // our own GetObjectInfo which make everything a bit more
|
---|
2818 | // complicated.
|
---|
2819 | canv->cd();
|
---|
2820 | #if ROOT_VERSION_CODE > ROOT_VERSION(5,22,00)
|
---|
2821 | const char *objectInfo =
|
---|
2822 | obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());
|
---|
2823 | #else
|
---|
2824 | const char *objectInfo = dynamic_cast<TH1*>(obj) ?
|
---|
2825 | "" : obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());
|
---|
2826 | #endif
|
---|
2827 |
|
---|
2828 | QString tipText;
|
---|
2829 | tipText += obj->GetName();
|
---|
2830 | tipText += " [";
|
---|
2831 | tipText += obj->ClassName();
|
---|
2832 | tipText += "]: ";
|
---|
2833 | tipText += objectInfo;
|
---|
2834 |
|
---|
2835 | if (dynamic_cast<Camera*>(obj))
|
---|
2836 | {
|
---|
2837 | const float xx = canv->AbsPixeltoX(tipped->GetEventX());
|
---|
2838 | const float yy = canv->AbsPixeltoY(tipped->GetEventY());
|
---|
2839 |
|
---|
2840 | Camera *cam = static_cast<Camera*>(obj);
|
---|
2841 |
|
---|
2842 | const int isw = cam->GetIdx(xx, yy);
|
---|
2843 | const int ihw = fPixelMapHW[isw];
|
---|
2844 |
|
---|
2845 | const int idx = fPatchHW[isw];
|
---|
2846 |
|
---|
2847 | int ii = 0;
|
---|
2848 | for (; ii<160; ii++)
|
---|
2849 | if (idx==fPatchMapHW[ii])
|
---|
2850 | break;
|
---|
2851 |
|
---|
2852 |
|
---|
2853 | const int patch = ihw%4;
|
---|
2854 | const int board = (ihw/4)%10;
|
---|
2855 | const int crate = (ihw/4)/10;
|
---|
2856 |
|
---|
2857 | ostringstream str;
|
---|
2858 | str << " (hw=" << ihw << ") Patch=" << ii << " (hw=" << fPatchMapHW[idx] << "; Crate=" << crate << " Board=" << board << " Patch=" << patch << ")";
|
---|
2859 |
|
---|
2860 | tipText += str.str().c_str();
|
---|
2861 | }
|
---|
2862 | fStatusBar->showMessage(tipText, 3000);
|
---|
2863 | }
|
---|
2864 |
|
---|
2865 | gSystem->DispatchOneEvent(kFALSE);
|
---|
2866 | //gSystem->ProcessEvents();
|
---|
2867 | //QWhatsThis::display(tipText)
|
---|
2868 | }
|
---|
2869 |
|
---|
2870 | void slot_RootUpdate()
|
---|
2871 | {
|
---|
2872 | gSystem->DispatchOneEvent(kFALSE);
|
---|
2873 | //gSystem->ProcessEvents();
|
---|
2874 | QTimer::singleShot(10, this, SLOT(slot_RootUpdate()));
|
---|
2875 | }
|
---|
2876 |
|
---|
2877 | void ChoosePatch(Camera &cam, int isw)
|
---|
2878 | {
|
---|
2879 | cam.Reset();
|
---|
2880 |
|
---|
2881 | fThresholdIdx->setValue(isw);
|
---|
2882 |
|
---|
2883 | const int ihw = isw<0 ? 0 : fPatchMapHW[isw];
|
---|
2884 |
|
---|
2885 | fPatchRate->setEnabled(isw>=0);
|
---|
2886 | fThresholdCrate->setEnabled(isw>=0);
|
---|
2887 | fThresholdBoard->setEnabled(isw>=0);
|
---|
2888 | fThresholdPatch->setEnabled(isw>=0);
|
---|
2889 |
|
---|
2890 | if (isw<0)
|
---|
2891 | return;
|
---|
2892 |
|
---|
2893 | const int patch = ihw%4;
|
---|
2894 | const int board = (ihw/4)%10;
|
---|
2895 | const int crate = (ihw/4)/10;
|
---|
2896 |
|
---|
2897 | fInChoosePatch = true;
|
---|
2898 |
|
---|
2899 | fThresholdCrate->setValue(crate);
|
---|
2900 | fThresholdBoard->setValue(board);
|
---|
2901 | fThresholdPatch->setValue(patch);
|
---|
2902 |
|
---|
2903 | fInChoosePatch = false;
|
---|
2904 |
|
---|
2905 | fThresholdVal->setValue(fFtmStaticData.fThreshold[ihw]);
|
---|
2906 | fPatchRate->setValue(cam.GetData(isw));
|
---|
2907 |
|
---|
2908 | // Loop over the software idx of all pixels
|
---|
2909 | for (unsigned int i=0; i<1440; i++)
|
---|
2910 | if (fPatchHW[i]==ihw)
|
---|
2911 | cam.SetBold(i);
|
---|
2912 | }
|
---|
2913 |
|
---|
2914 | void ChoosePixel(Camera &cam, int isw)
|
---|
2915 | {
|
---|
2916 | const int ihw = fPixelMapHW[isw];
|
---|
2917 |
|
---|
2918 | int ii = 0;
|
---|
2919 | for (; ii<160; ii++)
|
---|
2920 | if (fPatchHW[isw]==fPatchMapHW[ii])
|
---|
2921 | break;
|
---|
2922 |
|
---|
2923 | cam.SetWhite(isw);
|
---|
2924 | ChoosePatch(cam, ii);
|
---|
2925 |
|
---|
2926 | const bool on = fFtmStaticData.IsEnabled(ihw);
|
---|
2927 | fPixelEnable->setChecked(on);
|
---|
2928 | }
|
---|
2929 |
|
---|
2930 | void UpdatePatch(int isw)
|
---|
2931 | {
|
---|
2932 | Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
|
---|
2933 | ChoosePatch(*cam, isw);
|
---|
2934 | }
|
---|
2935 |
|
---|
2936 | void on_fThresholdIdx_valueChanged(int isw)
|
---|
2937 | {
|
---|
2938 | UpdatePatch(isw);
|
---|
2939 |
|
---|
2940 | fRatesCanv->GetCanvas()->Modified();
|
---|
2941 | fRatesCanv->GetCanvas()->Update();
|
---|
2942 | }
|
---|
2943 |
|
---|
2944 | void UpdateThresholdIdx()
|
---|
2945 | {
|
---|
2946 | if (fInChoosePatch)
|
---|
2947 | return;
|
---|
2948 |
|
---|
2949 | const int crate = fThresholdCrate->value();
|
---|
2950 | const int board = fThresholdBoard->value();
|
---|
2951 | const int patch = fThresholdPatch->value();
|
---|
2952 |
|
---|
2953 | const int ihw = patch + board*4 + crate*40;
|
---|
2954 |
|
---|
2955 | int isw = 0;
|
---|
2956 | for (; isw<160; isw++)
|
---|
2957 | if (ihw==fPatchMapHW[isw])
|
---|
2958 | break;
|
---|
2959 |
|
---|
2960 | UpdatePatch(isw);
|
---|
2961 | }
|
---|
2962 |
|
---|
2963 | void on_fThresholdPatch_valueChanged(int)
|
---|
2964 | {
|
---|
2965 | UpdateThresholdIdx();
|
---|
2966 | }
|
---|
2967 | void on_fThresholdBoard_valueChanged(int)
|
---|
2968 | {
|
---|
2969 | UpdateThresholdIdx();
|
---|
2970 | }
|
---|
2971 | void on_fThresholdCrate_valueChanged(int)
|
---|
2972 | {
|
---|
2973 | UpdateThresholdIdx();
|
---|
2974 | }
|
---|
2975 |
|
---|
2976 | void on_fPixelIdx_valueChanged(int isw)
|
---|
2977 | {
|
---|
2978 | Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
|
---|
2979 | ChoosePixel(*cam, isw);
|
---|
2980 |
|
---|
2981 | fRatesCanv->GetCanvas()->Modified();
|
---|
2982 | fRatesCanv->GetCanvas()->Update();
|
---|
2983 | }
|
---|
2984 |
|
---|
2985 | void on_fRatesMin_valueChanged(int min)
|
---|
2986 | {
|
---|
2987 | Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
|
---|
2988 | cam->SetMin(min);
|
---|
2989 |
|
---|
2990 | fRatesCanv->GetCanvas()->Modified();
|
---|
2991 | fRatesCanv->GetCanvas()->Update();
|
---|
2992 | }
|
---|
2993 |
|
---|
2994 | void on_fRatesMax_valueChanged(int max)
|
---|
2995 | {
|
---|
2996 | Camera *cam = (Camera*)fRatesCanv->GetCanvas()->FindObject("Camera");
|
---|
2997 | cam->SetMax(max);
|
---|
2998 |
|
---|
2999 | fRatesCanv->GetCanvas()->Modified();
|
---|
3000 | fRatesCanv->GetCanvas()->Update();
|
---|
3001 | }
|
---|
3002 |
|
---|
3003 | #endif
|
---|
3004 |
|
---|
3005 | void on_fPixelEnable_stateChanged(int b)
|
---|
3006 | {
|
---|
3007 | if (fInHandler)
|
---|
3008 | return;
|
---|
3009 |
|
---|
3010 | const uint16_t isw = fPixelIdx->value();
|
---|
3011 | const uint16_t ihw = fPixelMapHW[isw];
|
---|
3012 |
|
---|
3013 | Dim::SendCommand(b==Qt::Unchecked ?
|
---|
3014 | "FTM_CONTROL/DISABLE_PIXEL" : "FTM_CONTROL/ENABLE_PIXEL",
|
---|
3015 | ihw);
|
---|
3016 | }
|
---|
3017 |
|
---|
3018 | void on_fPixelDisableOthers_clicked()
|
---|
3019 | {
|
---|
3020 | const uint16_t isw = fPixelIdx->value();
|
---|
3021 | const uint16_t ihw = fPixelMapHW[isw];
|
---|
3022 |
|
---|
3023 | Dim::SendCommand("FTM_CONTROL/DISABLE_ALL_PIXELS_EXCEPT", ihw);
|
---|
3024 | }
|
---|
3025 |
|
---|
3026 | void on_fThresholdDisableOthers_clicked()
|
---|
3027 | {
|
---|
3028 | const int16_t isw = fThresholdIdx->value();
|
---|
3029 | const int16_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
|
---|
3030 |
|
---|
3031 | Dim::SendCommand("FTM_CONTROL/DISABLE_ALL_PATCHES_EXCEPT", ihw);
|
---|
3032 | }
|
---|
3033 |
|
---|
3034 | void on_fThresholdVal_valueChanged(int v)
|
---|
3035 | {
|
---|
3036 | fThresholdVolt->setValue(2500./4095*v);
|
---|
3037 |
|
---|
3038 | const int32_t isw = fThresholdIdx->value();
|
---|
3039 | const int32_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
|
---|
3040 |
|
---|
3041 | const int32_t d[2] = { ihw, v };
|
---|
3042 |
|
---|
3043 | if (!fInHandler)
|
---|
3044 | Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", d);
|
---|
3045 | }
|
---|
3046 |
|
---|
3047 | TGraph fGraphFtmTemp[4];
|
---|
3048 | TGraph fGraphFtmRate;
|
---|
3049 | TGraph fGraphPatchRate[160];
|
---|
3050 | TGraph fGraphBoardRate[40];
|
---|
3051 |
|
---|
3052 | #ifdef HAVE_ROOT
|
---|
3053 | TH1 *DrawTimeFrame(const char *ytitle)
|
---|
3054 | {
|
---|
3055 | const double tm = Time().RootTime();
|
---|
3056 |
|
---|
3057 | TH1F *h=new TH1F("TimeFrame", "", 1, tm, tm+60);//Time().RootTime()-1./24/60/60, Time().RootTime());
|
---|
3058 | h->SetDirectory(0);
|
---|
3059 | h->SetBit(kCanDelete);
|
---|
3060 | h->SetStats(kFALSE);
|
---|
3061 | // h.SetMinimum(0);
|
---|
3062 | // h.SetMaximum(1);
|
---|
3063 | h->SetXTitle("Time");
|
---|
3064 | h->SetYTitle(ytitle);
|
---|
3065 | h->GetXaxis()->CenterTitle();
|
---|
3066 | h->GetYaxis()->CenterTitle();
|
---|
3067 | h->GetXaxis()->SetTimeDisplay(true);
|
---|
3068 | h->GetXaxis()->SetTimeFormat("%Mh%S'");
|
---|
3069 | h->GetXaxis()->SetLabelSize(0.025);
|
---|
3070 | h->GetYaxis()->SetLabelSize(0.025);
|
---|
3071 | h->GetYaxis()->SetTitleOffset(1.2);
|
---|
3072 | // h.GetYaxis()->SetTitleSize(1.2);
|
---|
3073 | h->Draw();
|
---|
3074 |
|
---|
3075 | return h;
|
---|
3076 | }
|
---|
3077 | #endif
|
---|
3078 |
|
---|
3079 | public:
|
---|
3080 | FactGui() :
|
---|
3081 | fFtuStatus(40),
|
---|
3082 | fPixelMapHW(1440), fPatchMapHW(160), fPatchHW(1440),
|
---|
3083 | fInChoosePatch(false),
|
---|
3084 | fDimDNS("DIS_DNS/VERSION_NUMBER", 1, int(0), this),
|
---|
3085 | //-
|
---|
3086 | fDimLoggerStats ("DATA_LOGGER/STATS", (void*)NULL, 0, this),
|
---|
3087 | fDimLoggerFilenameNight("DATA_LOGGER/FILENAME_NIGHTLY", (void*)NULL, 0, this),
|
---|
3088 | fDimLoggerFilenameRun ("DATA_LOGGER/FILENAME_RUN", (void*)NULL, 0, this),
|
---|
3089 | fDimLoggerNumSubs ("DATA_LOGGER/NUM_SUBS", (void*)NULL, 0, this),
|
---|
3090 | //-
|
---|
3091 | fDimFtmPassport ("FTM_CONTROL/PASSPORT", (void*)NULL, 0, this),
|
---|
3092 | fDimFtmTriggerRates ("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, this),
|
---|
3093 | fDimFtmError ("FTM_CONTROL/ERROR", (void*)NULL, 0, this),
|
---|
3094 | fDimFtmFtuList ("FTM_CONTROL/FTU_LIST", (void*)NULL, 0, this),
|
---|
3095 | fDimFtmStaticData ("FTM_CONTROL/STATIC_DATA", (void*)NULL, 0, this),
|
---|
3096 | fDimFtmDynamicData ("FTM_CONTROL/DYNAMIC_DATA", (void*)NULL, 0, this),
|
---|
3097 | fDimFtmCounter ("FTM_CONTROL/COUNTER", (void*)NULL, 0, this),
|
---|
3098 | //-
|
---|
3099 | fDimFadWriteStats ("FAD_CONTROL/STATS", (void*)NULL, 0, this),
|
---|
3100 | fDimFadRuns ("FAD_CONTROL/RUNS", (void*)NULL, 0, this),
|
---|
3101 | fDimFadEvents ("FAD_CONTROL/EVENTS", (void*)NULL, 0, this),
|
---|
3102 | fDimFadRawData ("FAD_CONTROL/RAW_DATA", (void*)NULL, 0, this),
|
---|
3103 | fDimFadEventData ("FAD_CONTROL/EVENT_DATA", (void*)NULL, 0, this),
|
---|
3104 | fDimFadConnections ("FAD_CONTROL/CONNECTIONS", (void*)NULL, 0, this),
|
---|
3105 | fDimFadFwVersion ("FAD_CONTROL/FIRMWARE_VERSION", (void*)NULL, 0, this),
|
---|
3106 | fDimFadRunNumber ("FAD_CONTROL/RUN_NUMBER", (void*)NULL, 0, this),
|
---|
3107 | fDimFadDNA ("FAD_CONTROL/DNA", (void*)NULL, 0, this),
|
---|
3108 | fDimFadTemperature ("FAD_CONTROL/TEMPERATURE", (void*)NULL, 0, this),
|
---|
3109 | fDimFadPrescaler ("FAD_CONTROL/PRESCALER", (void*)NULL, 0, this),
|
---|
3110 | fDimFadRefClock ("FAD_CONTROL/REFERENCE_CLOCK", (void*)NULL, 0, this),
|
---|
3111 | fDimFadRoi ("FAD_CONTROL/REGION_OF_INTEREST", (void*)NULL, 0, this),
|
---|
3112 | fDimFadDac ("FAD_CONTROL/DAC", (void*)NULL, 0, this),
|
---|
3113 | fDimFadDrsCalibration ("FAD_CONTROL/DRS_CALIBRATION", (void*)NULL, 0, this),
|
---|
3114 | fDimFadStatus ("FAD_CONTROL/STATUS", (void*)NULL, 0, this),
|
---|
3115 | fDimFadStatistics1 ("FAD_CONTROL/STATISTICS1", (void*)NULL, 0, this),
|
---|
3116 | fDimFadStatistics2 ("FAD_CONTROL/STATISTICS2", (void*)NULL, 0, this),
|
---|
3117 | //-
|
---|
3118 | fEventData(0), fDrsCalibration(1440*1024*6),
|
---|
3119 | fTimeStamp0(0)
|
---|
3120 |
|
---|
3121 | {
|
---|
3122 | fClockCondFreq->addItem("--- Hz", QVariant(-1));
|
---|
3123 | fClockCondFreq->addItem("800 MHz", QVariant(800));
|
---|
3124 | fClockCondFreq->addItem("1 GHz", QVariant(1000));
|
---|
3125 | fClockCondFreq->addItem("2 GHz", QVariant(2000));
|
---|
3126 | fClockCondFreq->addItem("3 GHz", QVariant(3000));
|
---|
3127 | fClockCondFreq->addItem("4 GHz", QVariant(4000));
|
---|
3128 | fClockCondFreq->addItem("5 GHz", QVariant(5000));
|
---|
3129 |
|
---|
3130 | fMcpNumEvents->addItem("unlimited", QVariant(0));
|
---|
3131 | fMcpNumEvents->addItem("100", QVariant(100));
|
---|
3132 | fMcpNumEvents->addItem("300", QVariant(300));
|
---|
3133 | fMcpNumEvents->addItem("1000", QVariant(1000));
|
---|
3134 | fMcpNumEvents->addItem("3000", QVariant(3000));
|
---|
3135 | fMcpNumEvents->addItem("10000", QVariant(10000));
|
---|
3136 | fMcpNumEvents->addItem("30000", QVariant(30000));
|
---|
3137 |
|
---|
3138 | fMcpTime->addItem("unlimited", QVariant(0));
|
---|
3139 | fMcpTime->addItem("00:30", QVariant(30));
|
---|
3140 | fMcpTime->addItem("01:00", QVariant(60));
|
---|
3141 | fMcpTime->addItem("02:30", QVariant(150));
|
---|
3142 | fMcpTime->addItem("05:00", QVariant(300));
|
---|
3143 | fMcpTime->addItem("10:00", QVariant(600));
|
---|
3144 | fMcpTime->addItem("15:00", QVariant(900));
|
---|
3145 | fMcpTime->addItem("20:00", QVariant(1200));
|
---|
3146 | fMcpTime->addItem("30:00", QVariant(1800));
|
---|
3147 | fMcpTime->addItem("60:00", QVariant(3600));
|
---|
3148 |
|
---|
3149 | fMcpRunType->addItem("Data", QVariant("data"));
|
---|
3150 | fMcpRunType->addItem("Pedestal", QVariant("pedestal"));
|
---|
3151 | fMcpRunType->addItem("DRS Calib", QVariant("drs-calib"));
|
---|
3152 |
|
---|
3153 | fTriggerWidget->setEnabled(false);
|
---|
3154 | fFtuWidget->setEnabled(false);
|
---|
3155 | fFtuGroupEnable->setEnabled(false);
|
---|
3156 | fRatesControls->setEnabled(false);
|
---|
3157 | fFadWidget->setEnabled(false);
|
---|
3158 | fEvtBldWidget->setEnabled(false);
|
---|
3159 | fLoggerWidget->setEnabled(false);
|
---|
3160 |
|
---|
3161 | fChatSend->setEnabled(false);
|
---|
3162 | fChatMessage->setEnabled(false);
|
---|
3163 |
|
---|
3164 | DimClient::sendCommand("CHAT/MSG", "GUI online.");
|
---|
3165 | // + MessageDimRX
|
---|
3166 |
|
---|
3167 | // --------------------------------------------------------------------------
|
---|
3168 |
|
---|
3169 | ifstream fin1("Trigger-Patches.txt");
|
---|
3170 |
|
---|
3171 | int l = 0;
|
---|
3172 |
|
---|
3173 | string buf;
|
---|
3174 | while (getline(fin1, buf, '\n'))
|
---|
3175 | {
|
---|
3176 | buf = Tools::Trim(buf);
|
---|
3177 | if (buf[0]=='#')
|
---|
3178 | continue;
|
---|
3179 |
|
---|
3180 | stringstream str(buf);
|
---|
3181 | for (int i=0; i<9; i++)
|
---|
3182 | {
|
---|
3183 | unsigned int n;
|
---|
3184 | str >> n;
|
---|
3185 |
|
---|
3186 | if (n>=fPatchHW.size())
|
---|
3187 | continue;
|
---|
3188 |
|
---|
3189 | fPatchHW[n] = l;
|
---|
3190 | }
|
---|
3191 | l++;
|
---|
3192 | }
|
---|
3193 |
|
---|
3194 | if (l!=160)
|
---|
3195 | cerr << "WARNING - Problems reading Trigger-Patches.txt" << endl;
|
---|
3196 |
|
---|
3197 | // --------------------------------------------------------------------------
|
---|
3198 |
|
---|
3199 | ifstream fin2("MasterList-v3.txt");
|
---|
3200 |
|
---|
3201 | l = 0;
|
---|
3202 |
|
---|
3203 | while (getline(fin2, buf, '\n'))
|
---|
3204 | {
|
---|
3205 | buf = Tools::Trim(buf);
|
---|
3206 | if (buf[0]=='#')
|
---|
3207 | continue;
|
---|
3208 |
|
---|
3209 | unsigned int softid, hardid, dummy;
|
---|
3210 |
|
---|
3211 | stringstream str(buf);
|
---|
3212 |
|
---|
3213 | str >> softid;
|
---|
3214 | str >> dummy;
|
---|
3215 | str >> hardid;
|
---|
3216 |
|
---|
3217 | if (softid>=fPixelMapHW.size())
|
---|
3218 | continue;
|
---|
3219 |
|
---|
3220 | fPixelMapHW[softid] = hardid;
|
---|
3221 |
|
---|
3222 | l++;
|
---|
3223 | }
|
---|
3224 |
|
---|
3225 | if (l!=1440)
|
---|
3226 | cerr << "WARNING - Problems reading MasterList-v3.txt" << endl;
|
---|
3227 |
|
---|
3228 | // --------------------------------------------------------------------------
|
---|
3229 |
|
---|
3230 | ifstream fin3("PatchList.txt");
|
---|
3231 |
|
---|
3232 | l = 0;
|
---|
3233 |
|
---|
3234 | while (getline(fin3, buf, '\n'))
|
---|
3235 | {
|
---|
3236 | buf = Tools::Trim(buf);
|
---|
3237 | if (buf[0]=='#')
|
---|
3238 | continue;
|
---|
3239 |
|
---|
3240 | unsigned int softid, hardid;
|
---|
3241 |
|
---|
3242 | stringstream str(buf);
|
---|
3243 |
|
---|
3244 | str >> softid;
|
---|
3245 | str >> hardid;
|
---|
3246 |
|
---|
3247 | if (softid>=fPatchMapHW.size())
|
---|
3248 | continue;
|
---|
3249 |
|
---|
3250 | fPatchMapHW[softid] = hardid-1;
|
---|
3251 |
|
---|
3252 | l++;
|
---|
3253 | }
|
---|
3254 |
|
---|
3255 | if (l!=160)
|
---|
3256 | cerr << "WARNING - Problems reading PatchList.txt" << endl;
|
---|
3257 |
|
---|
3258 | // --------------------------------------------------------------------------
|
---|
3259 | #ifdef HAVE_ROOT
|
---|
3260 |
|
---|
3261 | fGraphFtmRate.SetLineColor(kBlue);
|
---|
3262 | fGraphFtmRate.SetMarkerColor(kBlue);
|
---|
3263 | fGraphFtmRate.SetMarkerStyle(kFullDotMedium);
|
---|
3264 |
|
---|
3265 | for (int i=0; i<160; i++)
|
---|
3266 | {
|
---|
3267 | fGraphPatchRate[i].SetName("PatchRate");
|
---|
3268 | //fGraphPatchRate[i].SetLineColor(kBlue);
|
---|
3269 | //fGraphPatchRate[i].SetMarkerColor(kBlue);
|
---|
3270 | fGraphPatchRate[i].SetMarkerStyle(kFullDotMedium);
|
---|
3271 | }
|
---|
3272 | for (int i=0; i<40; i++)
|
---|
3273 | {
|
---|
3274 | fGraphBoardRate[i].SetName("BoardRate");
|
---|
3275 | //fGraphBoardRate[i].SetLineColor(kBlue);
|
---|
3276 | //fGraphBoardRate[i].SetMarkerColor(kBlue);
|
---|
3277 | fGraphBoardRate[i].SetMarkerStyle(kFullDotMedium);
|
---|
3278 | }
|
---|
3279 | /*
|
---|
3280 | TCanvas *c = fFtmTempCanv->GetCanvas();
|
---|
3281 | c->SetBit(TCanvas::kNoContextMenu);
|
---|
3282 | c->SetBorderMode(0);
|
---|
3283 | c->SetFrameBorderMode(0);
|
---|
3284 | c->SetFillColor(kWhite);
|
---|
3285 | c->SetRightMargin(0.03);
|
---|
3286 | c->SetTopMargin(0.03);
|
---|
3287 | c->cd();
|
---|
3288 | */
|
---|
3289 | //CreateTimeFrame("Temperature / °C");
|
---|
3290 |
|
---|
3291 | fGraphFtmTemp[0].SetMarkerStyle(kFullDotSmall);
|
---|
3292 | fGraphFtmTemp[1].SetMarkerStyle(kFullDotSmall);
|
---|
3293 | fGraphFtmTemp[2].SetMarkerStyle(kFullDotSmall);
|
---|
3294 | fGraphFtmTemp[3].SetMarkerStyle(kFullDotSmall);
|
---|
3295 |
|
---|
3296 | fGraphFtmTemp[1].SetLineColor(kBlue);
|
---|
3297 | fGraphFtmTemp[2].SetLineColor(kRed);
|
---|
3298 | fGraphFtmTemp[3].SetLineColor(kGreen);
|
---|
3299 |
|
---|
3300 | fGraphFtmTemp[1].SetMarkerColor(kBlue);
|
---|
3301 | fGraphFtmTemp[2].SetMarkerColor(kRed);
|
---|
3302 | fGraphFtmTemp[3].SetMarkerColor(kGreen);
|
---|
3303 |
|
---|
3304 | //fGraphFtmTemp[0].Draw("LP");
|
---|
3305 | //fGraphFtmTemp[1].Draw("LP");
|
---|
3306 | //fGraphFtmTemp[2].Draw("LP");
|
---|
3307 | //fGraphFtmTemp[3].Draw("LP");
|
---|
3308 |
|
---|
3309 | // --------------------------------------------------------------------------
|
---|
3310 |
|
---|
3311 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
---|
3312 | //c->SetBit(TCanvas::kNoContextMenu);
|
---|
3313 | c->SetBorderMode(0);
|
---|
3314 | c->SetFrameBorderMode(0);
|
---|
3315 | c->SetFillColor(kWhite);
|
---|
3316 | c->SetRightMargin(0.03);
|
---|
3317 | c->SetTopMargin(0.03);
|
---|
3318 | c->SetGrid();
|
---|
3319 | c->cd();
|
---|
3320 |
|
---|
3321 | TH1 *hf = DrawTimeFrame("Trigger rate [Hz]");
|
---|
3322 | hf->GetYaxis()->SetRangeUser(0, 1010);
|
---|
3323 |
|
---|
3324 | fGraphFtmRate.SetMarkerStyle(kFullDotSmall);
|
---|
3325 | fGraphFtmRate.Draw("LP");
|
---|
3326 |
|
---|
3327 | // --------------------------------------------------------------------------
|
---|
3328 |
|
---|
3329 | c = fRatesCanv->GetCanvas();
|
---|
3330 | //c->SetBit(TCanvas::kNoContextMenu);
|
---|
3331 | c->SetBorderMode(0);
|
---|
3332 | c->SetFrameBorderMode(0);
|
---|
3333 | c->SetFillColor(kWhite);
|
---|
3334 | c->cd();
|
---|
3335 |
|
---|
3336 | Camera *cam = new Camera;
|
---|
3337 | cam->SetBit(kCanDelete);
|
---|
3338 | cam->SetMin(fRatesMin->value());
|
---|
3339 | cam->SetMax(fRatesMax->value());
|
---|
3340 | cam->Draw();
|
---|
3341 |
|
---|
3342 | ChoosePixel(*cam, 0);
|
---|
3343 |
|
---|
3344 | // --------------------------------------------------------------------------
|
---|
3345 |
|
---|
3346 | c = fAdcDataCanv->GetCanvas();
|
---|
3347 | //c->SetBit(TCanvas::kNoContextMenu);
|
---|
3348 | c->SetBorderMode(0);
|
---|
3349 | c->SetFrameBorderMode(0);
|
---|
3350 | c->SetFillColor(kWhite);
|
---|
3351 | c->SetRightMargin(0.10);
|
---|
3352 | c->SetGrid();
|
---|
3353 | c->cd();
|
---|
3354 |
|
---|
3355 | // --------------------------------------------------------------------------
|
---|
3356 |
|
---|
3357 | c = fEventCanv->GetCanvas();
|
---|
3358 | c->SetBit(TCanvas::kNoContextMenu);
|
---|
3359 | c->SetBorderMode(0);
|
---|
3360 | c->SetFrameBorderMode(0);
|
---|
3361 | c->SetFillColor(kWhite);
|
---|
3362 | c->Divide(2,2);
|
---|
3363 | c->cd(1);
|
---|
3364 | gPad->SetBorderMode(0);
|
---|
3365 | gPad->SetFrameBorderMode(0);
|
---|
3366 | gPad->SetFillColor(kWhite);
|
---|
3367 | Camera *cam1 = new Camera;
|
---|
3368 | cam1->SetBit(kCanDelete);
|
---|
3369 | cam1->Draw();
|
---|
3370 | c->cd(2);
|
---|
3371 | gPad->SetBorderMode(0);
|
---|
3372 | gPad->SetFrameBorderMode(0);
|
---|
3373 | gPad->SetFillColor(kWhite);
|
---|
3374 | Camera *cam2 = new Camera;
|
---|
3375 | cam2->SetBit(kCanDelete);
|
---|
3376 | cam2->Draw();
|
---|
3377 | c->cd(3);
|
---|
3378 | gPad->SetBorderMode(0);
|
---|
3379 | gPad->SetFrameBorderMode(0);
|
---|
3380 | gPad->SetFillColor(kWhite);
|
---|
3381 | Camera *cam3 = new Camera;
|
---|
3382 | cam3->SetBit(kCanDelete);
|
---|
3383 | cam3->Draw();
|
---|
3384 | c->cd(4);
|
---|
3385 | gPad->SetBorderMode(0);
|
---|
3386 | gPad->SetFrameBorderMode(0);
|
---|
3387 | gPad->SetFillColor(kWhite);
|
---|
3388 | Camera *cam4 = new Camera;
|
---|
3389 | cam4->SetBit(kCanDelete);
|
---|
3390 | cam4->Draw();
|
---|
3391 |
|
---|
3392 |
|
---|
3393 |
|
---|
3394 | // Create histogram?
|
---|
3395 |
|
---|
3396 | // --------------------------------------------------------------------------
|
---|
3397 |
|
---|
3398 | QTimer::singleShot(1000, this, SLOT(slot_RootUpdate()));
|
---|
3399 |
|
---|
3400 | //widget->setMouseTracking(true);
|
---|
3401 | //widget->EnableSignalEvents(kMouseMoveEvent);
|
---|
3402 |
|
---|
3403 | fFtmRateCanv->setMouseTracking(true);
|
---|
3404 | fFtmRateCanv->EnableSignalEvents(kMouseMoveEvent);
|
---|
3405 |
|
---|
3406 | fAdcDataCanv->setMouseTracking(true);
|
---|
3407 | fAdcDataCanv->EnableSignalEvents(kMouseMoveEvent);
|
---|
3408 |
|
---|
3409 | fRatesCanv->setMouseTracking(true);
|
---|
3410 | fRatesCanv->EnableSignalEvents(kMouseMoveEvent|kMouseReleaseEvent|kMouseDoubleClickEvent);
|
---|
3411 |
|
---|
3412 | connect(fRatesCanv, SIGNAL( RootEventProcessed(TObject*, unsigned int, TCanvas*)),
|
---|
3413 | this, SLOT (slot_RootEventProcessed(TObject*, unsigned int, TCanvas*)));
|
---|
3414 | connect(fFtmRateCanv, SIGNAL( RootEventProcessed(TObject*, unsigned int, TCanvas*)),
|
---|
3415 | this, SLOT (slot_RootEventProcessed(TObject*, unsigned int, TCanvas*)));
|
---|
3416 | connect(fAdcDataCanv, SIGNAL( RootEventProcessed(TObject*, unsigned int, TCanvas*)),
|
---|
3417 | this, SLOT (slot_RootEventProcessed(TObject*, unsigned int, TCanvas*)));
|
---|
3418 | #endif
|
---|
3419 | }
|
---|
3420 |
|
---|
3421 | ~FactGui()
|
---|
3422 | {
|
---|
3423 | // Unsubscribe all services
|
---|
3424 | for (map<string,DimInfo*>::iterator i=fServices.begin();
|
---|
3425 | i!=fServices.end(); i++)
|
---|
3426 | delete i->second;
|
---|
3427 |
|
---|
3428 | delete fEventData;
|
---|
3429 | }
|
---|
3430 | };
|
---|
3431 |
|
---|
3432 | #endif
|
---|