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/Configuration.h"
|
---|
19 | #include "src/HeadersFTM.h"
|
---|
20 | #include "src/HeadersFAD.h"
|
---|
21 | #include "src/HeadersBIAS.h"
|
---|
22 | #include "src/DimNetwork.h"
|
---|
23 | #include "src/tools.h"
|
---|
24 | #include "src/FAD.h"
|
---|
25 | #include "src/PixelMap.h"
|
---|
26 |
|
---|
27 |
|
---|
28 | #include "TROOT.h"
|
---|
29 | #include "TSystem.h"
|
---|
30 | #include "TGraph.h"
|
---|
31 | #include "TGraphErrors.h"
|
---|
32 | #include "TH2.h"
|
---|
33 | #include "TBox.h"
|
---|
34 | #include "TStyle.h"
|
---|
35 | #include "TMarker.h"
|
---|
36 | #include "TColor.h"
|
---|
37 |
|
---|
38 | #include "QCameraWidget.h"
|
---|
39 |
|
---|
40 | using namespace std;
|
---|
41 |
|
---|
42 | // #########################################################################
|
---|
43 |
|
---|
44 | /*
|
---|
45 | class Camera : public TObject
|
---|
46 | {
|
---|
47 | typedef pair<double,double> Position;
|
---|
48 | typedef vector<Position> Positions;
|
---|
49 |
|
---|
50 | Positions fGeom;
|
---|
51 |
|
---|
52 | void CreatePalette()
|
---|
53 | {
|
---|
54 |
|
---|
55 | double ss[5] = {0.00, 0.25, 0.50, 0.75, 1.00};
|
---|
56 | double rr[5] = {0.15, 0.00, 0.00, 1.00, 0.85};
|
---|
57 | double gg[5] = {0.15, 0.00, 1.00, 0.00, 0.85};
|
---|
58 | double bb[5] = {0.15, 1.00, 0.00, 0.00, 0.85};
|
---|
59 |
|
---|
60 | const Int_t nn = 1440;
|
---|
61 |
|
---|
62 | Int_t idx = TColor::CreateGradientColorTable(5, ss, rr, gg, bb, nn);
|
---|
63 | for (int i=0; i<nn; i++)
|
---|
64 | fPalette.push_back(idx++);
|
---|
65 | }
|
---|
66 |
|
---|
67 | void CreateGeometry()
|
---|
68 | {
|
---|
69 | const double gsSin60 = sqrt(3.)/2;
|
---|
70 |
|
---|
71 | const int rings = 23;
|
---|
72 |
|
---|
73 | // add the first pixel to the list
|
---|
74 |
|
---|
75 | fGeom.push_back(make_pair(0, -0.5));
|
---|
76 |
|
---|
77 | for (int ring=1; ring<=rings; ring++)
|
---|
78 | {
|
---|
79 | for (int s=0; s<6; s++)
|
---|
80 | {
|
---|
81 | for (int i=1; i<=ring; i++)
|
---|
82 | {
|
---|
83 | double xx, yy;
|
---|
84 | switch (s)
|
---|
85 | {
|
---|
86 | case 0: // Direction South East
|
---|
87 | xx = (ring+i)*0.5;
|
---|
88 | yy = (-ring+i)*gsSin60;
|
---|
89 | break;
|
---|
90 |
|
---|
91 | case 1: // Direction North East
|
---|
92 | xx = ring-i*0.5;
|
---|
93 | yy = i*gsSin60;
|
---|
94 | break;
|
---|
95 |
|
---|
96 | case 2: // Direction North
|
---|
97 | xx = ring*0.5-i;
|
---|
98 | yy = ring*gsSin60;
|
---|
99 | break;
|
---|
100 |
|
---|
101 | case 3: // Direction North West
|
---|
102 | xx = -(ring+i)*0.5;
|
---|
103 | yy = (ring-i)*gsSin60;
|
---|
104 | break;
|
---|
105 |
|
---|
106 | case 4: // Direction South West
|
---|
107 | xx = 0.5*i-ring;
|
---|
108 | yy = -i*gsSin60;
|
---|
109 | break;
|
---|
110 |
|
---|
111 | case 5: // Direction South
|
---|
112 | xx = i-ring*0.5;
|
---|
113 | yy = -ring*gsSin60;
|
---|
114 | break;
|
---|
115 | }
|
---|
116 |
|
---|
117 | if (xx*xx + yy*yy - xx > 395.75)
|
---|
118 | continue;
|
---|
119 |
|
---|
120 | fGeom.push_back(make_pair(yy, xx-0.5));
|
---|
121 | }
|
---|
122 | }
|
---|
123 | }
|
---|
124 | }
|
---|
125 |
|
---|
126 | valarray<double> fData;
|
---|
127 | vector<bool> fBold;
|
---|
128 | vector<bool> fEnable;
|
---|
129 |
|
---|
130 | int fWhite;
|
---|
131 |
|
---|
132 | int64_t fMin;
|
---|
133 | int64_t fMax;
|
---|
134 |
|
---|
135 | public:
|
---|
136 | Camera() : fData(1440), fBold(1440), fEnable(1440), fWhite(-1), fMin(-1), fMax(-1)
|
---|
137 | {
|
---|
138 | CreatePalette();
|
---|
139 | CreateGeometry();
|
---|
140 |
|
---|
141 | for (int i=0; i<1440; i++)
|
---|
142 | {
|
---|
143 | fData[i] = i;
|
---|
144 | fBold[i]=false;
|
---|
145 | fEnable[i]=true;
|
---|
146 | }
|
---|
147 | }
|
---|
148 |
|
---|
149 | void Reset() { fBold.assign(1440, false); }
|
---|
150 |
|
---|
151 | void SetBold(int idx) { fBold[idx]=true; }
|
---|
152 | void SetWhite(int idx) { fWhite=idx; }
|
---|
153 | void SetEnable(int idx, bool b) { fEnable[idx]=b; }
|
---|
154 | void Toggle(int idx) { fEnable[idx]=!fEnable[idx]; }
|
---|
155 | double GetData(int idx) const { return fData[idx]; }
|
---|
156 | void SetMin(int64_t min) { fMin=min; }
|
---|
157 | void SetMax(int64_t max) { fMax=max; }
|
---|
158 |
|
---|
159 | const char *GetName() const { return "Camera"; }
|
---|
160 |
|
---|
161 | vector<Int_t> fPalette;
|
---|
162 |
|
---|
163 | void Paint(const Position &p)
|
---|
164 | {
|
---|
165 | static const Double_t fgCos60 = 0.5; // TMath::Cos(60/TMath::RadToDeg());
|
---|
166 | static const Double_t fgSin60 = sqrt(3.)/2; // TMath::Sin(60/TMath::RadToDeg());
|
---|
167 |
|
---|
168 | static const Double_t fgDy[6] = { fgCos60, 0., -fgCos60, -fgCos60, 0., fgCos60 };
|
---|
169 | static const Double_t fgDx[6] = { fgSin60/3, fgSin60*2/3, fgSin60/3, -fgSin60/3, -fgSin60*2/3, -fgSin60/3 };
|
---|
170 |
|
---|
171 | //
|
---|
172 | // calculate the positions of the pixel corners
|
---|
173 | //
|
---|
174 | static Double_t x[7], y[7];
|
---|
175 | for (Int_t i=0; i<7; i++)
|
---|
176 | {
|
---|
177 | x[i] = p.first + fgDx[i%6];
|
---|
178 | y[i] = p.second + fgDy[i%6];
|
---|
179 | }
|
---|
180 |
|
---|
181 | gPad->PaintFillArea(6, x, y);
|
---|
182 | gPad->PaintPolyLine(7, x, y);
|
---|
183 | }
|
---|
184 |
|
---|
185 | int GetCol(double dmin, double val, double dmax, bool enable)
|
---|
186 | {
|
---|
187 | if (!enable)
|
---|
188 | return kWhite;
|
---|
189 |
|
---|
190 | if (val<dmin)
|
---|
191 | return kBlue+4;//kBlack;
|
---|
192 |
|
---|
193 | if (val>dmax)
|
---|
194 | return kRed+4;//kWhite;
|
---|
195 |
|
---|
196 | const double min = dmin;
|
---|
197 | const double scale = dmax==dmin ? 1 : dmax-dmin;
|
---|
198 |
|
---|
199 | const int col = (val-min)/scale*(fPalette.size()-1);
|
---|
200 |
|
---|
201 | return gStyle->GetColorPalette(col);
|
---|
202 | }
|
---|
203 |
|
---|
204 | void Paint(Option_t *)
|
---|
205 | {
|
---|
206 | gStyle->SetPalette(fPalette.size(), fPalette.data());
|
---|
207 |
|
---|
208 | const double r = double(gPad->GetWw())/gPad->GetWh();
|
---|
209 | const double max = 20.5; // 20.5 rings in x and y
|
---|
210 |
|
---|
211 | if (r>1)
|
---|
212 | gPad->Range(-r*max, -max, r*max, max);
|
---|
213 | else
|
---|
214 | gPad->Range(-max, -max/r, max, max/r);
|
---|
215 |
|
---|
216 | Double_t x1, x2, y1, y2;
|
---|
217 | gPad->GetRange(x1, x2, y1, y2);
|
---|
218 |
|
---|
219 | double dmin = fData[0];
|
---|
220 | double dmax = fData[0];
|
---|
221 |
|
---|
222 | for (unsigned int i=0; i<fData.size(); i++)
|
---|
223 | {
|
---|
224 | if (!fEnable[i])
|
---|
225 | continue;
|
---|
226 |
|
---|
227 | if (fData[i]>dmax)
|
---|
228 | dmax = fData[i];
|
---|
229 | if (fData[i]<dmin)
|
---|
230 | dmin = fData[i];
|
---|
231 | }
|
---|
232 |
|
---|
233 | if (fMin>=0)
|
---|
234 | dmin = fMin;
|
---|
235 | if (fMax>=0)
|
---|
236 | dmax = fMax;
|
---|
237 |
|
---|
238 | // const double min = dmin;
|
---|
239 | // const double scale = dmax==dmin ? 1 : dmax-dmin;
|
---|
240 |
|
---|
241 | TAttFill fill(0, 1001);
|
---|
242 | TAttLine line;
|
---|
243 |
|
---|
244 | int cnt=0;
|
---|
245 | for (Positions::iterator p=fGeom.begin(); p!=fGeom.end(); p++, cnt++)
|
---|
246 | {
|
---|
247 | if (fBold[cnt])
|
---|
248 | continue;
|
---|
249 |
|
---|
250 | const int col = GetCol(dmin, fData[cnt], dmax, fEnable[cnt]);
|
---|
251 |
|
---|
252 | fill.SetFillColor(col);
|
---|
253 | fill.Modify();
|
---|
254 |
|
---|
255 | Paint(*p);
|
---|
256 | }
|
---|
257 |
|
---|
258 | line.SetLineWidth(2);
|
---|
259 | line.Modify();
|
---|
260 |
|
---|
261 | cnt = 0;
|
---|
262 | for (Positions::iterator p=fGeom.begin(); p!=fGeom.end(); p++, cnt++)
|
---|
263 | {
|
---|
264 | if (!fBold[cnt])
|
---|
265 | continue;
|
---|
266 |
|
---|
267 | const int col = GetCol(dmin, fData[cnt], dmax, fEnable[cnt]);
|
---|
268 |
|
---|
269 | fill.SetFillColor(col);
|
---|
270 | fill.Modify();
|
---|
271 |
|
---|
272 | Paint(*p);
|
---|
273 | }
|
---|
274 |
|
---|
275 | TMarker m(0,0,kStar);
|
---|
276 | m.DrawMarker(0, 0);
|
---|
277 |
|
---|
278 | if (fWhite<0)
|
---|
279 | return;
|
---|
280 |
|
---|
281 | const Position &p = fGeom[fWhite];
|
---|
282 |
|
---|
283 | line.SetLineColor(kWhite);
|
---|
284 | line.Modify();
|
---|
285 |
|
---|
286 | const int col = GetCol(dmin, fData[fWhite], dmax, fEnable[fWhite]);
|
---|
287 |
|
---|
288 | fill.SetFillColor(col);
|
---|
289 | fill.Modify();
|
---|
290 |
|
---|
291 | Paint(p);
|
---|
292 | }
|
---|
293 |
|
---|
294 | int GetIdx(float px, float py) const
|
---|
295 | {
|
---|
296 | static const double sqrt3 = sqrt(3);
|
---|
297 |
|
---|
298 | int idx = 0;
|
---|
299 | for (Positions::const_iterator p=fGeom.begin(); p!=fGeom.end(); p++, idx++)
|
---|
300 | {
|
---|
301 | const Double_t dy = py - p->second;
|
---|
302 | if (fabs(dy)>0.5)
|
---|
303 | continue;
|
---|
304 |
|
---|
305 | const Double_t dx = px - p->first;
|
---|
306 |
|
---|
307 | if (TMath::Abs(dy + dx*sqrt3) > 1)
|
---|
308 | continue;
|
---|
309 |
|
---|
310 | if (TMath::Abs(dy - dx*sqrt3) > 1)
|
---|
311 | continue;
|
---|
312 |
|
---|
313 | return idx;
|
---|
314 | }
|
---|
315 | return -1;
|
---|
316 | }
|
---|
317 |
|
---|
318 | char *GetObjectInfo(Int_t px, Int_t py) const
|
---|
319 | {
|
---|
320 | static stringstream stream;
|
---|
321 | static string str;
|
---|
322 |
|
---|
323 | const float x = gPad->AbsPixeltoX(px);
|
---|
324 | const float y = gPad->AbsPixeltoY(py);
|
---|
325 |
|
---|
326 | const int idx = GetIdx(x, y);
|
---|
327 |
|
---|
328 | stream.seekp(0);
|
---|
329 | if (idx>=0)
|
---|
330 | {
|
---|
331 | stream << "Pixel=" << idx << " Data=" << fData[idx] << '\0';
|
---|
332 | }
|
---|
333 |
|
---|
334 | str = stream.str();
|
---|
335 | return const_cast<char*>(str.c_str());
|
---|
336 | }
|
---|
337 |
|
---|
338 | Int_t DistancetoPrimitive(Int_t px, Int_t py)
|
---|
339 | {
|
---|
340 | const float x = gPad->AbsPixeltoX(px);
|
---|
341 | const float y = gPad->AbsPixeltoY(py);
|
---|
342 |
|
---|
343 | return GetIdx(x, y)>=0 ? 0 : 99999;
|
---|
344 | }
|
---|
345 |
|
---|
346 | void SetData(const valarray<double> &data)
|
---|
347 | {
|
---|
348 | fData = data;
|
---|
349 | }
|
---|
350 |
|
---|
351 | void SetData(const float *data)
|
---|
352 | {
|
---|
353 | for (int i=0; i<1440; i++)
|
---|
354 | fData[i] = data[i];
|
---|
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 | PixelMap fPixelMap;
|
---|
378 |
|
---|
379 | //vector<int> fPixelMapHW; // Software -> Hardware
|
---|
380 | vector<int> fPatchMapHW; // Software -> Hardware
|
---|
381 |
|
---|
382 | bool fInChoosePatchTH; // FIXME. Find a better solution
|
---|
383 | bool fInChooseBiasHv; // FIXME. Find a better solution
|
---|
384 | bool fInChooseBiasCam; // FIXME. Find a better solution
|
---|
385 |
|
---|
386 | DimStampedInfo fDimDNS;
|
---|
387 |
|
---|
388 | DimStampedInfo fDimLoggerStats;
|
---|
389 | DimStampedInfo fDimLoggerFilenameNight;
|
---|
390 | DimStampedInfo fDimLoggerFilenameRun;
|
---|
391 | DimStampedInfo fDimLoggerNumSubs;
|
---|
392 |
|
---|
393 | DimStampedInfo fDimFtmPassport;
|
---|
394 | DimStampedInfo fDimFtmTriggerRates;
|
---|
395 | DimStampedInfo fDimFtmError;
|
---|
396 | DimStampedInfo fDimFtmFtuList;
|
---|
397 | DimStampedInfo fDimFtmStaticData;
|
---|
398 | DimStampedInfo fDimFtmDynamicData;
|
---|
399 | DimStampedInfo fDimFtmCounter;
|
---|
400 |
|
---|
401 | DimStampedInfo fDimFadWriteStats;
|
---|
402 | DimStampedInfo fDimFadStartRun;
|
---|
403 | DimStampedInfo fDimFadRuns;
|
---|
404 | DimStampedInfo fDimFadEvents;
|
---|
405 | DimStampedInfo fDimFadRawData;
|
---|
406 | DimStampedInfo fDimFadEventData;
|
---|
407 | DimStampedInfo fDimFadConnections;
|
---|
408 | DimStampedInfo fDimFadFwVersion;
|
---|
409 | DimStampedInfo fDimFadRunNumber;
|
---|
410 | DimStampedInfo fDimFadDNA;
|
---|
411 | DimStampedInfo fDimFadTemperature;
|
---|
412 | DimStampedInfo fDimFadPrescaler;
|
---|
413 | DimStampedInfo fDimFadRefClock;
|
---|
414 | DimStampedInfo fDimFadRoi;
|
---|
415 | DimStampedInfo fDimFadDac;
|
---|
416 | DimStampedInfo fDimFadDrsCalibration;
|
---|
417 | DimStampedInfo fDimFadStatus;
|
---|
418 | DimStampedInfo fDimFadStatistics1;
|
---|
419 | DimStampedInfo fDimFadStatistics2;
|
---|
420 | DimStampedInfo fDimFadFileFormat;
|
---|
421 |
|
---|
422 | DimStampedInfo fDimFscTemp;
|
---|
423 | DimStampedInfo fDimFscVolt;
|
---|
424 | DimStampedInfo fDimFscCurrent;
|
---|
425 | DimStampedInfo fDimFscHumidity;
|
---|
426 |
|
---|
427 | DimStampedInfo fDimFeedbackDeviation;
|
---|
428 | DimStampedInfo fDimFeedbackReference;
|
---|
429 | DimStampedInfo fDimFeedbackCalibration;
|
---|
430 |
|
---|
431 | DimStampedInfo fDimBiasVolt;
|
---|
432 | DimStampedInfo fDimBiasCurrent;
|
---|
433 |
|
---|
434 | DimStampedInfo fDimRateScan;
|
---|
435 |
|
---|
436 | map<string, DimInfo*> fServices;
|
---|
437 |
|
---|
438 | // ========================== LED Colors ================================
|
---|
439 |
|
---|
440 | enum LedColor_t
|
---|
441 | {
|
---|
442 | kLedRed,
|
---|
443 | kLedGreen,
|
---|
444 | kLedGreenWarn,
|
---|
445 | kLedGreenCheck,
|
---|
446 | kLedGreenBar,
|
---|
447 | kLedYellow,
|
---|
448 | kLedOrange,
|
---|
449 | kLedGray,
|
---|
450 | kLedWarnBorder,
|
---|
451 | kLedWarn,
|
---|
452 | kLedWarnTriangleBorder,
|
---|
453 | kLedWarnTriangle,
|
---|
454 | kLedInProgress,
|
---|
455 | };
|
---|
456 |
|
---|
457 | void SetLedColor(QPushButton *button, LedColor_t col, const Time &t)
|
---|
458 | {
|
---|
459 | switch (col)
|
---|
460 | {
|
---|
461 | case kLedRed:
|
---|
462 | button->setIcon(QIcon(":/Resources/icons/red circle 1.png"));
|
---|
463 | break;
|
---|
464 |
|
---|
465 | case kLedGreen:
|
---|
466 | button->setIcon(QIcon(":/Resources/icons/green circle 1.png"));
|
---|
467 | break;
|
---|
468 |
|
---|
469 | case kLedGreenBar:
|
---|
470 | button->setIcon(QIcon(":/Resources/icons/green bar.png"));
|
---|
471 | break;
|
---|
472 |
|
---|
473 | case kLedGreenWarn:
|
---|
474 | button->setIcon(QIcon(":/Resources/icons/green warn.png"));
|
---|
475 | break;
|
---|
476 |
|
---|
477 | case kLedGreenCheck:
|
---|
478 | button->setIcon(QIcon(":/Resources/icons/green check.png"));
|
---|
479 | break;
|
---|
480 |
|
---|
481 | case kLedYellow:
|
---|
482 | button->setIcon(QIcon(":/Resources/icons/yellow circle 1.png"));
|
---|
483 | break;
|
---|
484 |
|
---|
485 | case kLedOrange:
|
---|
486 | button->setIcon(QIcon(":/Resources/icons/orange circle 1.png"));
|
---|
487 | break;
|
---|
488 |
|
---|
489 | case kLedGray:
|
---|
490 | button->setIcon(QIcon(":/Resources/icons/gray circle 1.png"));
|
---|
491 | break;
|
---|
492 |
|
---|
493 | case kLedWarnBorder:
|
---|
494 | button->setIcon(QIcon(":/Resources/icons/warning 1.png"));
|
---|
495 | break;
|
---|
496 |
|
---|
497 | case kLedWarn:
|
---|
498 | button->setIcon(QIcon(":/Resources/icons/warning 2.png"));
|
---|
499 | break;
|
---|
500 |
|
---|
501 | case kLedWarnTriangle:
|
---|
502 | button->setIcon(QIcon(":/Resources/icons/warning 3.png"));
|
---|
503 | break;
|
---|
504 |
|
---|
505 | case kLedWarnTriangleBorder:
|
---|
506 | button->setIcon(QIcon(":/Resources/icons/warning 4.png"));
|
---|
507 | break;
|
---|
508 |
|
---|
509 | case kLedInProgress:
|
---|
510 | button->setIcon(QIcon(":/Resources/icons/in progress.png"));
|
---|
511 | break;
|
---|
512 |
|
---|
513 | }
|
---|
514 |
|
---|
515 | //button->setToolTip("Last change: "+QDateTime::currentDateTimeUtc().toString()+" UTC");
|
---|
516 | button->setToolTip(("Last change: "+t.GetAsStr()+" (UTC)").c_str());
|
---|
517 | }
|
---|
518 |
|
---|
519 | // ===================== Services and Commands ==========================
|
---|
520 |
|
---|
521 | QStandardItem *AddServiceItem(const std::string &server, const std::string &service, bool iscmd)
|
---|
522 | {
|
---|
523 | QListView *servers = iscmd ? fDimCmdServers : fDimSvcServers;
|
---|
524 | QListView *services = iscmd ? fDimCmdCommands : fDimSvcServices;
|
---|
525 | QListView *description = iscmd ? fDimCmdDescription : fDimSvcDescription;
|
---|
526 |
|
---|
527 | QStandardItemModel *m = dynamic_cast<QStandardItemModel*>(servers->model());
|
---|
528 | if (!m)
|
---|
529 | {
|
---|
530 | m = new QStandardItemModel(this);
|
---|
531 | servers->setModel(m);
|
---|
532 | services->setModel(m);
|
---|
533 | description->setModel(m);
|
---|
534 | }
|
---|
535 |
|
---|
536 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
---|
537 |
|
---|
538 | if (l.size()>1)
|
---|
539 | {
|
---|
540 | cout << "hae" << endl;
|
---|
541 | return 0;
|
---|
542 | }
|
---|
543 |
|
---|
544 | QStandardItem *col = l.size()==0 ? NULL : l[0];
|
---|
545 |
|
---|
546 | if (!col)
|
---|
547 | {
|
---|
548 | col = new QStandardItem(server.c_str());
|
---|
549 | m->appendRow(col);
|
---|
550 |
|
---|
551 | if (!services->rootIndex().isValid())
|
---|
552 | {
|
---|
553 | services->setRootIndex(col->index());
|
---|
554 | servers->setCurrentIndex(col->index());
|
---|
555 | }
|
---|
556 | }
|
---|
557 |
|
---|
558 | QStandardItem *item = 0;
|
---|
559 | for (int i=0; i<col->rowCount(); i++)
|
---|
560 | {
|
---|
561 | QStandardItem *coli = col->child(i);
|
---|
562 | if (coli->text().toStdString()==service)
|
---|
563 | return coli;
|
---|
564 | }
|
---|
565 |
|
---|
566 | item = new QStandardItem(service.c_str());
|
---|
567 | col->appendRow(item);
|
---|
568 | col->sortChildren(0);
|
---|
569 |
|
---|
570 | if (!description->rootIndex().isValid())
|
---|
571 | {
|
---|
572 | description->setRootIndex(item->index());
|
---|
573 | services->setCurrentIndex(item->index());
|
---|
574 | }
|
---|
575 |
|
---|
576 | if (!iscmd)
|
---|
577 | item->setCheckable(true);
|
---|
578 |
|
---|
579 | return item;
|
---|
580 | }
|
---|
581 |
|
---|
582 | void AddDescription(QStandardItem *item, const vector<Description> &vec)
|
---|
583 | {
|
---|
584 | if (!item)
|
---|
585 | return;
|
---|
586 | if (vec.size()==0)
|
---|
587 | return;
|
---|
588 |
|
---|
589 | item->setToolTip(vec[0].comment.c_str());
|
---|
590 |
|
---|
591 | const string str = Description::GetHtmlDescription(vec);
|
---|
592 |
|
---|
593 | QStandardItem *desc = new QStandardItem(str.c_str());
|
---|
594 | desc->setSelectable(false);
|
---|
595 | item->setChild(0, 0, desc);
|
---|
596 | }
|
---|
597 |
|
---|
598 | void AddServer(const std::string &s)
|
---|
599 | {
|
---|
600 | DimNetwork::AddServer(s);
|
---|
601 |
|
---|
602 | QApplication::postEvent(this,
|
---|
603 | new FunctionEvent(boost::bind(&FactGui::handleAddServer, this, s)));
|
---|
604 | }
|
---|
605 |
|
---|
606 | void AddService(const std::string &server, const std::string &service, const std::string &fmt, bool iscmd)
|
---|
607 | {
|
---|
608 | QApplication::postEvent(this,
|
---|
609 | new FunctionEvent(boost::bind(&FactGui::handleAddService, this, server, service, fmt, iscmd)));
|
---|
610 | }
|
---|
611 |
|
---|
612 | void RemoveService(std::string server, std::string service, bool iscmd)
|
---|
613 | {
|
---|
614 | UnsubscribeService(server+'/'+service, true);
|
---|
615 |
|
---|
616 | QApplication::postEvent(this,
|
---|
617 | new FunctionEvent(boost::bind(&FactGui::handleRemoveService, this, server, service, iscmd)));
|
---|
618 | }
|
---|
619 |
|
---|
620 | void RemoveAllServices(const std::string &server)
|
---|
621 | {
|
---|
622 | UnsubscribeAllServices(server);
|
---|
623 |
|
---|
624 | QApplication::postEvent(this,
|
---|
625 | new FunctionEvent(boost::bind(&FactGui::handleRemoveAllServices, this, server)));
|
---|
626 | }
|
---|
627 |
|
---|
628 | void AddDescription(const std::string &server, const std::string &service, const vector<Description> &vec)
|
---|
629 | {
|
---|
630 | QApplication::postEvent(this,
|
---|
631 | new FunctionEvent(boost::bind(&FactGui::handleAddDescription, this, server, service, vec)));
|
---|
632 | }
|
---|
633 |
|
---|
634 | // ======================================================================
|
---|
635 |
|
---|
636 | void handleAddServer(const std::string &server)
|
---|
637 | {
|
---|
638 | const State s = GetState(server, GetCurrentState(server));
|
---|
639 | handleStateChanged(Time(), server, s);
|
---|
640 | }
|
---|
641 |
|
---|
642 | void handleAddService(const std::string &server, const std::string &service, const std::string &/*fmt*/, bool iscmd)
|
---|
643 | {
|
---|
644 | QStandardItem *item = AddServiceItem(server, service, iscmd);
|
---|
645 | const vector<Description> v = GetDescription(server, service);
|
---|
646 | AddDescription(item, v);
|
---|
647 | }
|
---|
648 |
|
---|
649 | void handleRemoveService(const std::string &server, const std::string &service, bool iscmd)
|
---|
650 | {
|
---|
651 | QListView *servers = iscmd ? fDimCmdServers : fDimSvcServers;
|
---|
652 |
|
---|
653 | QStandardItemModel *m = dynamic_cast<QStandardItemModel*>(servers->model());
|
---|
654 | if (!m)
|
---|
655 | return;
|
---|
656 |
|
---|
657 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
---|
658 | if (l.size()!=1)
|
---|
659 | return;
|
---|
660 |
|
---|
661 | for (int i=0; i<l[0]->rowCount(); i++)
|
---|
662 | {
|
---|
663 | QStandardItem *row = l[0]->child(i);
|
---|
664 | if (row->text().toStdString()==service)
|
---|
665 | {
|
---|
666 | l[0]->removeRow(row->index().row());
|
---|
667 | return;
|
---|
668 | }
|
---|
669 | }
|
---|
670 | }
|
---|
671 |
|
---|
672 | void handleRemoveAllServices(const std::string &server)
|
---|
673 | {
|
---|
674 | handleStateChanged(Time(), server, State(-2, "Offline", "No connection via DIM."));
|
---|
675 |
|
---|
676 | QStandardItemModel *m = 0;
|
---|
677 | if ((m=dynamic_cast<QStandardItemModel*>(fDimCmdServers->model())))
|
---|
678 | {
|
---|
679 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
---|
680 | if (l.size()==1)
|
---|
681 | m->removeRow(l[0]->index().row());
|
---|
682 | }
|
---|
683 |
|
---|
684 | if ((m = dynamic_cast<QStandardItemModel*>(fDimSvcServers->model())))
|
---|
685 | {
|
---|
686 | QList<QStandardItem*> l = m->findItems(server.c_str());
|
---|
687 | if (l.size()==1)
|
---|
688 | m->removeRow(l[0]->index().row());
|
---|
689 | }
|
---|
690 | }
|
---|
691 |
|
---|
692 | void handleAddDescription(const std::string &server, const std::string &service, const vector<Description> &vec)
|
---|
693 | {
|
---|
694 | const bool iscmd = IsCommand(server, service)==true;
|
---|
695 |
|
---|
696 | QStandardItem *item = AddServiceItem(server, service, iscmd);
|
---|
697 | AddDescription(item, vec);
|
---|
698 | }
|
---|
699 |
|
---|
700 | // ======================================================================
|
---|
701 |
|
---|
702 | void SubscribeService(const string &service)
|
---|
703 | {
|
---|
704 | if (fServices.find(service)!=fServices.end())
|
---|
705 | {
|
---|
706 | cerr << "ERROR - We are already subscribed to " << service << endl;
|
---|
707 | return;
|
---|
708 | }
|
---|
709 |
|
---|
710 | fServices[service] = new DimStampedInfo(service.c_str(), (void*)NULL, 0, this);
|
---|
711 | }
|
---|
712 |
|
---|
713 | void UnsubscribeService(const string &service, bool allow_unsubscribed=false)
|
---|
714 | {
|
---|
715 | const map<string,DimInfo*>::iterator i=fServices.find(service);
|
---|
716 |
|
---|
717 | if (i==fServices.end())
|
---|
718 | {
|
---|
719 | if (!allow_unsubscribed)
|
---|
720 | cerr << "ERROR - We are not subscribed to " << service << endl;
|
---|
721 | return;
|
---|
722 | }
|
---|
723 |
|
---|
724 | delete i->second;
|
---|
725 |
|
---|
726 | fServices.erase(i);
|
---|
727 | }
|
---|
728 |
|
---|
729 | void UnsubscribeAllServices(const string &server)
|
---|
730 | {
|
---|
731 | for (map<string,DimInfo*>::iterator i=fServices.begin();
|
---|
732 | i!=fServices.end(); i++)
|
---|
733 | if (i->first.substr(0, server.length()+1)==server+'/')
|
---|
734 | {
|
---|
735 | delete i->second;
|
---|
736 | fServices.erase(i);
|
---|
737 | }
|
---|
738 | }
|
---|
739 |
|
---|
740 | // ======================================================================
|
---|
741 |
|
---|
742 | struct DimData
|
---|
743 | {
|
---|
744 | const int qos;
|
---|
745 | const string name;
|
---|
746 | const string format;
|
---|
747 | const vector<char> data;
|
---|
748 | const Time time;
|
---|
749 |
|
---|
750 | Time extract(DimInfo *inf) const
|
---|
751 | {
|
---|
752 | // Must be called in exactly this order!
|
---|
753 | const int tsec = inf->getTimestamp();
|
---|
754 | const int tms = inf->getTimestampMillisecs();
|
---|
755 |
|
---|
756 | return Time(tsec, tms*1000);
|
---|
757 | }
|
---|
758 |
|
---|
759 | // DimInfo *info; // this is ONLY for a fast check of the type of the DimData!!
|
---|
760 |
|
---|
761 | DimData(DimInfo *inf) :
|
---|
762 | qos(inf->getQuality()),
|
---|
763 | name(inf->getName()),
|
---|
764 | format(inf->getFormat()),
|
---|
765 | data(inf->getString(), inf->getString()+inf->getSize()),
|
---|
766 | time(extract(inf))/*,
|
---|
767 | info(inf)*/
|
---|
768 | {
|
---|
769 | }
|
---|
770 |
|
---|
771 | template<typename T>
|
---|
772 | T get(uint32_t offset=0) const { return *reinterpret_cast<const T*>(data.data()+offset); }
|
---|
773 |
|
---|
774 | template<typename T>
|
---|
775 | const T *ptr(uint32_t offset=0) const { return reinterpret_cast<const T*>(data.data()+offset); }
|
---|
776 |
|
---|
777 | template<typename T>
|
---|
778 | const T &ref(uint32_t offset=0) const { return *reinterpret_cast<const T*>(data.data()+offset); }
|
---|
779 |
|
---|
780 | // vector<char> vec(int b) const { return vector<char>(data.begin()+b, data.end()); }
|
---|
781 | // string str(unsigned int b) const { return b>=data.size()?string():string(data.data()+b, data.size()-b); }
|
---|
782 | const char *c_str() const { return (char*)data.data(); }
|
---|
783 | /*
|
---|
784 | vector<boost::any> any() const
|
---|
785 | {
|
---|
786 | const Converter conv(format);
|
---|
787 | conv.Print();
|
---|
788 | return conv.GetAny(data.data(), data.size());
|
---|
789 | }*/
|
---|
790 | size_t size() const { return data.size(); }
|
---|
791 | };
|
---|
792 |
|
---|
793 | // ======================= DNS ==========================================
|
---|
794 |
|
---|
795 | void handleDimDNS(const DimData &d)
|
---|
796 | {
|
---|
797 | const int version = d.size()!=4 ? 0 : d.get<uint32_t>();
|
---|
798 |
|
---|
799 | ostringstream str;
|
---|
800 | str << "V" << version/100 << 'r' << version%100;
|
---|
801 |
|
---|
802 | ostringstream dns;
|
---|
803 | dns << (version==0?"No connection":"Connection");
|
---|
804 | dns << " to DIM DNS (" << getenv("DIM_DNS_NODE") << ")";
|
---|
805 | dns << (version==0?".":" established.");
|
---|
806 |
|
---|
807 | fStatusDNSLabel->setText(version==0?"Offline":str.str().c_str());
|
---|
808 | fStatusDNSLabel->setToolTip(dns.str().c_str());
|
---|
809 |
|
---|
810 | SetLedColor(fStatusDNSLed, version==0 ? kLedRed : kLedGreen, Time());
|
---|
811 |
|
---|
812 | fShutdown->setEnabled(version!=0);
|
---|
813 | fShutdownAll->setEnabled(version!=0);
|
---|
814 | }
|
---|
815 |
|
---|
816 |
|
---|
817 | // ======================= Logger =======================================
|
---|
818 |
|
---|
819 | void handleLoggerStats(const DimData &d)
|
---|
820 | {
|
---|
821 | const bool connected = d.size()!=0;
|
---|
822 |
|
---|
823 | fLoggerET->setEnabled(connected);
|
---|
824 | fLoggerRate->setEnabled(connected);
|
---|
825 | fLoggerWritten->setEnabled(connected);
|
---|
826 | fLoggerFreeSpace->setEnabled(connected);
|
---|
827 | fLoggerSpaceLeft->setEnabled(connected);
|
---|
828 |
|
---|
829 | if (!connected)
|
---|
830 | return;
|
---|
831 |
|
---|
832 | const uint64_t *vals = d.ptr<uint64_t>();
|
---|
833 |
|
---|
834 | const size_t space = vals[0];
|
---|
835 | const size_t written = vals[1];
|
---|
836 | const size_t rate = float(vals[2])/vals[3];
|
---|
837 |
|
---|
838 | fLoggerFreeSpace->setSuffix(" MB");
|
---|
839 | fLoggerFreeSpace->setDecimals(0);
|
---|
840 | fLoggerFreeSpace->setValue(space*1e-6);
|
---|
841 |
|
---|
842 | if (space> 1000000) // > 1GB
|
---|
843 | {
|
---|
844 | fLoggerFreeSpace->setSuffix(" GB");
|
---|
845 | fLoggerFreeSpace->setDecimals(2);
|
---|
846 | fLoggerFreeSpace->setValue(space*1e-9);
|
---|
847 | }
|
---|
848 | if (space>= 3000000) // >= 3GB
|
---|
849 | {
|
---|
850 | fLoggerFreeSpace->setSuffix(" GB");
|
---|
851 | fLoggerFreeSpace->setDecimals(1);
|
---|
852 | fLoggerFreeSpace->setValue(space*1e-9);
|
---|
853 | }
|
---|
854 | if (space>=100000000) // >= 100GB
|
---|
855 | {
|
---|
856 | fLoggerFreeSpace->setSuffix(" GB");
|
---|
857 | fLoggerFreeSpace->setDecimals(0);
|
---|
858 | fLoggerFreeSpace->setValue(space*1e-9);
|
---|
859 | }
|
---|
860 |
|
---|
861 | fLoggerET->setTime(QTime().addSecs(rate>0?space/rate:0));
|
---|
862 | fLoggerRate->setValue(rate*1e-3); // kB/s
|
---|
863 | fLoggerWritten->setValue(written*1e-6);
|
---|
864 |
|
---|
865 | fLoggerRate->setSuffix(" kB/s");
|
---|
866 | fLoggerRate->setDecimals(2);
|
---|
867 | fLoggerRate->setValue(rate);
|
---|
868 | if (rate> 2) // > 2kB/s
|
---|
869 | {
|
---|
870 | fLoggerRate->setSuffix(" kB/s");
|
---|
871 | fLoggerRate->setDecimals(1);
|
---|
872 | fLoggerRate->setValue(rate);
|
---|
873 | }
|
---|
874 | if (rate>=100) // >100kB/s
|
---|
875 | {
|
---|
876 | fLoggerRate->setSuffix(" kB/s");
|
---|
877 | fLoggerRate->setDecimals(0);
|
---|
878 | fLoggerRate->setValue(rate);
|
---|
879 | }
|
---|
880 | if (rate>=1000) // >100kB/s
|
---|
881 | {
|
---|
882 | fLoggerRate->setSuffix(" MB/s");
|
---|
883 | fLoggerRate->setDecimals(2);
|
---|
884 | fLoggerRate->setValue(rate*1e-3);
|
---|
885 | }
|
---|
886 | if (rate>=10000) // >1MB/s
|
---|
887 | {
|
---|
888 | fLoggerRate->setSuffix(" MB/s");
|
---|
889 | fLoggerRate->setDecimals(1);
|
---|
890 | fLoggerRate->setValue(rate*1e-3);
|
---|
891 | }
|
---|
892 | if (rate>=100000) // >10MB/s
|
---|
893 | {
|
---|
894 | fLoggerRate->setSuffix(" MB/s");
|
---|
895 | fLoggerRate->setDecimals(0);
|
---|
896 | fLoggerRate->setValue(rate*1e-3);
|
---|
897 | }
|
---|
898 |
|
---|
899 | if (space/1000000>static_cast<size_t>(fLoggerSpaceLeft->maximum()))
|
---|
900 | fLoggerSpaceLeft->setValue(fLoggerSpaceLeft->maximum()); // GB
|
---|
901 | else
|
---|
902 | fLoggerSpaceLeft->setValue(space/1000000); // MB
|
---|
903 | }
|
---|
904 |
|
---|
905 | void handleLoggerFilenameNight(const DimData &d)
|
---|
906 | {
|
---|
907 | const bool connected = d.size()!=0;
|
---|
908 |
|
---|
909 | fLoggerFilenameNight->setEnabled(connected);
|
---|
910 | if (!connected)
|
---|
911 | return;
|
---|
912 |
|
---|
913 | fLoggerFilenameNight->setText(d.c_str()+4);
|
---|
914 |
|
---|
915 | const uint32_t files = d.get<uint32_t>();
|
---|
916 |
|
---|
917 | SetLedColor(fLoggerLedLog, files&1 ? kLedGreen : kLedGray, d.time);
|
---|
918 | SetLedColor(fLoggerLedRep, files&2 ? kLedGreen : kLedGray, d.time);
|
---|
919 | SetLedColor(fLoggerLedFits, files&4 ? kLedGreen : kLedGray, d.time);
|
---|
920 | }
|
---|
921 |
|
---|
922 | void handleLoggerFilenameRun(const DimData &d)
|
---|
923 | {
|
---|
924 | const bool connected = d.size()!=0;
|
---|
925 |
|
---|
926 | fLoggerFilenameRun->setEnabled(connected);
|
---|
927 | if (!connected)
|
---|
928 | return;
|
---|
929 |
|
---|
930 | fLoggerFilenameRun->setText(d.c_str()+4);
|
---|
931 |
|
---|
932 | const uint32_t files = d.get<uint32_t>();
|
---|
933 |
|
---|
934 | SetLedColor(fLoggerLedLog, files&1 ? kLedGreen : kLedGray, d.time);
|
---|
935 | SetLedColor(fLoggerLedRep, files&2 ? kLedGreen : kLedGray, d.time);
|
---|
936 | SetLedColor(fLoggerLedFits, files&4 ? kLedGreen : kLedGray, d.time);
|
---|
937 | }
|
---|
938 |
|
---|
939 | void handleLoggerNumSubs(const DimData &d)
|
---|
940 | {
|
---|
941 | const bool connected = d.size()!=0;
|
---|
942 |
|
---|
943 | fLoggerSubscriptions->setEnabled(connected);
|
---|
944 | fLoggerOpenFiles->setEnabled(connected);
|
---|
945 | if (!connected)
|
---|
946 | return;
|
---|
947 |
|
---|
948 | const uint32_t *vals = d.ptr<uint32_t>();
|
---|
949 |
|
---|
950 | fLoggerSubscriptions->setValue(vals[0]);
|
---|
951 | fLoggerOpenFiles->setValue(vals[1]);
|
---|
952 | }
|
---|
953 |
|
---|
954 |
|
---|
955 | // ===================== All ============================================
|
---|
956 |
|
---|
957 | bool CheckSize(const DimData &d, size_t sz, bool print=true) const
|
---|
958 | {
|
---|
959 | if (d.size()==0)
|
---|
960 | return false;
|
---|
961 |
|
---|
962 | if (d.size()!=sz)
|
---|
963 | {
|
---|
964 | if (print)
|
---|
965 | cerr << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected=" << sz << endl;
|
---|
966 | return false;
|
---|
967 | }
|
---|
968 |
|
---|
969 | return true;
|
---|
970 | }
|
---|
971 |
|
---|
972 | // ===================== FAD ============================================
|
---|
973 |
|
---|
974 | void handleFadWriteStats(const DimData &d)
|
---|
975 | {
|
---|
976 | const bool connected = d.size()!=0;
|
---|
977 |
|
---|
978 | fEvtBuilderET->setEnabled(connected);
|
---|
979 | fEvtBuilderRate->setEnabled(connected);
|
---|
980 | fEvtBuilderWritten->setEnabled(connected);
|
---|
981 | fEvtBuilderFreeSpace->setEnabled(connected);
|
---|
982 | fEvtBuilderSpaceLeft->setEnabled(connected);
|
---|
983 |
|
---|
984 | if (!connected)
|
---|
985 | return;
|
---|
986 |
|
---|
987 | const uint64_t *vals = d.ptr<uint64_t>();
|
---|
988 |
|
---|
989 | const size_t space = vals[0];
|
---|
990 | const size_t written = vals[1];
|
---|
991 | const size_t rate = float(vals[2])/vals[3];
|
---|
992 |
|
---|
993 | fEvtBuilderFreeSpace->setSuffix(" MB");
|
---|
994 | fEvtBuilderFreeSpace->setDecimals(0);
|
---|
995 | fEvtBuilderFreeSpace->setValue(space*1e-6);
|
---|
996 |
|
---|
997 | if (space> 1000000) // > 1GB
|
---|
998 | {
|
---|
999 | fEvtBuilderFreeSpace->setSuffix(" GB");
|
---|
1000 | fEvtBuilderFreeSpace->setDecimals(2);
|
---|
1001 | fEvtBuilderFreeSpace->setValue(space*1e-9);
|
---|
1002 | }
|
---|
1003 | if (space>= 3000000) // >= 3GB
|
---|
1004 | {
|
---|
1005 | fEvtBuilderFreeSpace->setSuffix(" GB");
|
---|
1006 | fEvtBuilderFreeSpace->setDecimals(1);
|
---|
1007 | fEvtBuilderFreeSpace->setValue(space*1e-9);
|
---|
1008 | }
|
---|
1009 | if (space>=100000000) // >= 100GB
|
---|
1010 | {
|
---|
1011 | fEvtBuilderFreeSpace->setSuffix(" GB");
|
---|
1012 | fEvtBuilderFreeSpace->setDecimals(0);
|
---|
1013 | fEvtBuilderFreeSpace->setValue(space*1e-9);
|
---|
1014 | }
|
---|
1015 |
|
---|
1016 | fEvtBuilderET->setTime(QTime().addSecs(rate>0?space/rate:0));
|
---|
1017 | fEvtBuilderRate->setValue(rate*1e-3); // kB/s
|
---|
1018 | fEvtBuilderWritten->setValue(written*1e-6);
|
---|
1019 |
|
---|
1020 | fEvtBuilderRate->setSuffix(" kB/s");
|
---|
1021 | fEvtBuilderRate->setDecimals(2);
|
---|
1022 | fEvtBuilderRate->setValue(rate);
|
---|
1023 | if (rate> 2) // > 2kB/s
|
---|
1024 | {
|
---|
1025 | fEvtBuilderRate->setSuffix(" kB/s");
|
---|
1026 | fEvtBuilderRate->setDecimals(1);
|
---|
1027 | fEvtBuilderRate->setValue(rate);
|
---|
1028 | }
|
---|
1029 | if (rate>=100) // >100kB/s
|
---|
1030 | {
|
---|
1031 | fEvtBuilderRate->setSuffix(" kB/s");
|
---|
1032 | fEvtBuilderRate->setDecimals(0);
|
---|
1033 | fEvtBuilderRate->setValue(rate);
|
---|
1034 | }
|
---|
1035 | if (rate>=1000) // >100kB/s
|
---|
1036 | {
|
---|
1037 | fEvtBuilderRate->setSuffix(" MB/s");
|
---|
1038 | fEvtBuilderRate->setDecimals(2);
|
---|
1039 | fEvtBuilderRate->setValue(rate*1e-3);
|
---|
1040 | }
|
---|
1041 | if (rate>=10000) // >1MB/s
|
---|
1042 | {
|
---|
1043 | fEvtBuilderRate->setSuffix(" MB/s");
|
---|
1044 | fEvtBuilderRate->setDecimals(1);
|
---|
1045 | fEvtBuilderRate->setValue(rate*1e-3);
|
---|
1046 | }
|
---|
1047 | if (rate>=100000) // >10MB/s
|
---|
1048 | {
|
---|
1049 | fEvtBuilderRate->setSuffix(" MB/s");
|
---|
1050 | fEvtBuilderRate->setDecimals(0);
|
---|
1051 | fEvtBuilderRate->setValue(rate*1e-3);
|
---|
1052 | }
|
---|
1053 |
|
---|
1054 | if (space/1000000>static_cast<size_t>(fEvtBuilderSpaceLeft->maximum()))
|
---|
1055 | fEvtBuilderSpaceLeft->setValue(fEvtBuilderSpaceLeft->maximum()); // GB
|
---|
1056 | else
|
---|
1057 | fEvtBuilderSpaceLeft->setValue(space/1000000); // MB
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 | void handleFadRuns(const DimData &d)
|
---|
1061 | {
|
---|
1062 | if (d.size()==0)
|
---|
1063 | return;
|
---|
1064 |
|
---|
1065 | if (d.size()<20)
|
---|
1066 | {
|
---|
1067 | cerr << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected>=20" << endl;
|
---|
1068 | return;
|
---|
1069 | }
|
---|
1070 |
|
---|
1071 | const uint32_t *ptr = d.ptr<uint32_t>();
|
---|
1072 |
|
---|
1073 | fEvtBldOpenFiles->setValue(ptr[0]);
|
---|
1074 | fEvtBldOpenStreams->setValue(ptr[0]);
|
---|
1075 | fEvtBldRunNumberMin->setValue(ptr[1]);
|
---|
1076 | fEvtBldRunNumberMax->setValue(ptr[2]);
|
---|
1077 | fEvtBldLastOpened->setValue(ptr[3]);
|
---|
1078 | fEvtBldLastClosed->setValue(ptr[4]);
|
---|
1079 |
|
---|
1080 | if (d.size()>=20)
|
---|
1081 | fEvtBldFilename->setText(d.ptr<char>(20));
|
---|
1082 |
|
---|
1083 | if (ptr[0]==0)
|
---|
1084 | fEvtBldFilename->setText("");
|
---|
1085 | }
|
---|
1086 |
|
---|
1087 | void handleFadStartRun(const DimData &d)
|
---|
1088 | {
|
---|
1089 | if (!CheckSize(d, 16))
|
---|
1090 | return;
|
---|
1091 |
|
---|
1092 | const int64_t *runs = d.ptr<int64_t>();
|
---|
1093 |
|
---|
1094 | fFadRunNoCur->setValue(runs[0]);
|
---|
1095 | fFadRunNoNext->setValue(runs[1]);
|
---|
1096 | fFadRunNoCur->setEnabled(runs[0]>=0);
|
---|
1097 | //fMcpStopRun->setEnabled(runs[0]>=0);
|
---|
1098 |
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 | void handleFadEvents(const DimData &d)
|
---|
1102 | {
|
---|
1103 | if (!CheckSize(d, 16))
|
---|
1104 | return;
|
---|
1105 |
|
---|
1106 | const uint32_t *ptr = d.ptr<uint32_t>();
|
---|
1107 |
|
---|
1108 | fEvtsSuccessCurRun->setValue(ptr[0]);
|
---|
1109 | fEvtsSuccessTotal->setValue(ptr[1]);
|
---|
1110 | fEvtBldEventId->setValue(ptr[2]);
|
---|
1111 | fFadEvtCounter->setValue(ptr[2]);
|
---|
1112 | fEvtBldTriggerId->setValue(ptr[3]);
|
---|
1113 | }
|
---|
1114 |
|
---|
1115 | void handleFadTemperature(const DimData &d)
|
---|
1116 | {
|
---|
1117 | if (d.size()==0)
|
---|
1118 | {
|
---|
1119 | fFadTempMin->setEnabled(false);
|
---|
1120 | fFadTempMax->setEnabled(false);
|
---|
1121 | SetLedColor(fFadLedTemp, kLedGray, d.time);
|
---|
1122 | return;
|
---|
1123 | }
|
---|
1124 |
|
---|
1125 | if (!CheckSize(d, 82*sizeof(float)))
|
---|
1126 | return;
|
---|
1127 |
|
---|
1128 | const float *ptr = d.ptr<float>();
|
---|
1129 |
|
---|
1130 | fFadTempMin->setEnabled(true);
|
---|
1131 | fFadTempMax->setEnabled(true);
|
---|
1132 |
|
---|
1133 | fFadTempMin->setValue(ptr[0]);
|
---|
1134 | fFadTempMax->setValue(ptr[41]);
|
---|
1135 |
|
---|
1136 | handleFadToolTip(d.time, fFadTempMin, ptr+1);
|
---|
1137 | handleFadToolTip(d.time, fFadTempMax, ptr+42);
|
---|
1138 | }
|
---|
1139 |
|
---|
1140 | void handleFadRefClock(const DimData &d)
|
---|
1141 | {
|
---|
1142 | if (d.size()==0)
|
---|
1143 | {
|
---|
1144 | fFadRefClockMin->setEnabled(false);
|
---|
1145 | fFadRefClockMax->setEnabled(false);
|
---|
1146 | SetLedColor(fFadLedRefClock, kLedGray, d.time);
|
---|
1147 | return;
|
---|
1148 | }
|
---|
1149 |
|
---|
1150 | if (!CheckSize(d, 42*sizeof(uint32_t)))
|
---|
1151 | return;
|
---|
1152 |
|
---|
1153 | const uint32_t *ptr = d.ptr<uint32_t>();
|
---|
1154 |
|
---|
1155 | fFadRefClockMin->setEnabled(true);
|
---|
1156 | fFadRefClockMax->setEnabled(true);
|
---|
1157 |
|
---|
1158 | fFadRefClockMin->setValue(ptr[40]*2.048);
|
---|
1159 | fFadRefClockMax->setValue(ptr[41]*2.048);
|
---|
1160 |
|
---|
1161 | const int64_t diff = int64_t(ptr[41]) - int64_t(ptr[40]);
|
---|
1162 |
|
---|
1163 | SetLedColor(fFadLedRefClock, abs(diff)>3?kLedRed:kLedGreen, d.time);
|
---|
1164 |
|
---|
1165 | handleFadToolTip(d.time, fFadLedRefClock, ptr);
|
---|
1166 | }
|
---|
1167 |
|
---|
1168 | void handleFadRoi(const DimData &d)
|
---|
1169 | {
|
---|
1170 | if (d.size()==0)
|
---|
1171 | {
|
---|
1172 | fFadRoi->setEnabled(false);
|
---|
1173 | fFadRoiCh9->setEnabled(false);
|
---|
1174 | //SetLedColor(fFadLedRoi, kLedGray, d.time);
|
---|
1175 | return;
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | if (!CheckSize(d, 2*sizeof(uint16_t)))
|
---|
1179 | return;
|
---|
1180 |
|
---|
1181 | const uint16_t *ptr = d.ptr<uint16_t>();
|
---|
1182 |
|
---|
1183 | fFadRoi->setEnabled(true);
|
---|
1184 | fFadRoiCh9->setEnabled(true);
|
---|
1185 |
|
---|
1186 | fFadRoi->setValue(ptr[0]);
|
---|
1187 | fFadRoiCh9->setValue(ptr[1]);
|
---|
1188 |
|
---|
1189 | //SetLedColor(fFadLedRoi, kLedGray, d.time);
|
---|
1190 | }
|
---|
1191 |
|
---|
1192 | void handleDac(QPushButton *led, QSpinBox *box, const DimData &d, int idx)
|
---|
1193 | {
|
---|
1194 | if (d.size()==0)
|
---|
1195 | {
|
---|
1196 | box->setEnabled(false);
|
---|
1197 | SetLedColor(led, kLedGray, d.time);
|
---|
1198 | return;
|
---|
1199 | }
|
---|
1200 |
|
---|
1201 | const uint16_t *ptr = d.ptr<uint16_t>()+idx*42;
|
---|
1202 |
|
---|
1203 | box->setEnabled(true);
|
---|
1204 | box->setValue(ptr[40]==ptr[41]?ptr[40]:0);
|
---|
1205 |
|
---|
1206 | SetLedColor(led, ptr[40]==ptr[41]?kLedGreen:kLedOrange, d.time);
|
---|
1207 | handleFadToolTip(d.time, led, ptr);
|
---|
1208 | }
|
---|
1209 |
|
---|
1210 | void handleFadDac(const DimData &d)
|
---|
1211 | {
|
---|
1212 | if (!CheckSize(d, 8*42*sizeof(uint16_t)) && !d.size()==0)
|
---|
1213 | return;
|
---|
1214 |
|
---|
1215 | handleDac(fFadLedDac0, fFadDac0, d, 0);
|
---|
1216 | handleDac(fFadLedDac1, fFadDac1, d, 1);
|
---|
1217 | handleDac(fFadLedDac2, fFadDac2, d, 2);
|
---|
1218 | handleDac(fFadLedDac3, fFadDac3, d, 3);
|
---|
1219 | handleDac(fFadLedDac4, fFadDac4, d, 4);
|
---|
1220 | handleDac(fFadLedDac5, fFadDac5, d, 5);
|
---|
1221 | handleDac(fFadLedDac6, fFadDac6, d, 6);
|
---|
1222 | handleDac(fFadLedDac7, fFadDac7, d, 7);
|
---|
1223 | }
|
---|
1224 |
|
---|
1225 | EVENT *fEventData;
|
---|
1226 |
|
---|
1227 | void DrawHorizontal(TH1 *hf, double xmax, TH1 &h, double scale)
|
---|
1228 | {
|
---|
1229 | for (Int_t i=1;i<=h.GetNbinsX();i++)
|
---|
1230 | {
|
---|
1231 | if (h.GetBinContent(i)<0.5 || h.GetBinContent(i)>h.GetEntries()-0.5)
|
---|
1232 | continue;
|
---|
1233 |
|
---|
1234 | TBox * box=new TBox(xmax, h.GetBinLowEdge(i),
|
---|
1235 | xmax+h.GetBinContent(i)*scale,
|
---|
1236 | h.GetBinLowEdge(i+1));
|
---|
1237 |
|
---|
1238 | box->SetFillStyle(0);
|
---|
1239 | box->SetLineColor(h.GetLineColor());
|
---|
1240 | box->SetLineStyle(kSolid);
|
---|
1241 | box->SetBit(kCannotPick|kNoContextMenu);
|
---|
1242 | //box->Draw();
|
---|
1243 |
|
---|
1244 | hf->GetListOfFunctions()->Add(box);
|
---|
1245 | }
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 | void DisplayEventData()
|
---|
1249 | {
|
---|
1250 | if (!fEventData)
|
---|
1251 | return;
|
---|
1252 |
|
---|
1253 | #ifdef HAVE_ROOT
|
---|
1254 | TCanvas *c = fAdcDataCanv->GetCanvas();
|
---|
1255 |
|
---|
1256 | TH1 *hf = dynamic_cast<TH1*>(c->FindObject("Frame"));
|
---|
1257 | TH1 *h = dynamic_cast<TH1*>(c->FindObject("EventData"));
|
---|
1258 | TH1 *d0 = dynamic_cast<TH1*>(c->FindObject("DrsCalib0"));
|
---|
1259 | TH1 *d1 = dynamic_cast<TH1*>(c->FindObject("DrsCalib1"));
|
---|
1260 | TH1 *d2 = dynamic_cast<TH1*>(c->FindObject("DrsCalib2"));
|
---|
1261 |
|
---|
1262 | const int roi = fAdcPhysical->isChecked() ? 1024 : (fEventData->Roi>0 ? fEventData->Roi : 1);
|
---|
1263 |
|
---|
1264 | if ((hf && hf->GetNbinsX()!=roi) ||
|
---|
1265 | (dynamic_cast<TH2*>(h) && !fAdcPersistent->isChecked()) ||
|
---|
1266 | (!dynamic_cast<TH2*>(h) && fAdcPersistent->isChecked()))
|
---|
1267 | {
|
---|
1268 | delete hf;
|
---|
1269 | delete h;
|
---|
1270 | delete d0;
|
---|
1271 | delete d1;
|
---|
1272 | delete d2;
|
---|
1273 | d0 = 0;
|
---|
1274 | d1 = 0;
|
---|
1275 | d2 = 0;
|
---|
1276 | hf = 0;
|
---|
1277 | }
|
---|
1278 |
|
---|
1279 | c->cd();
|
---|
1280 |
|
---|
1281 | if (!hf)
|
---|
1282 | {
|
---|
1283 | hf = new TH1F("Frame", "", roi, -0.5, roi-0.5);
|
---|
1284 | hf->SetDirectory(0);
|
---|
1285 | hf->SetBit(kCanDelete);
|
---|
1286 | hf->SetStats(kFALSE);
|
---|
1287 | hf->SetYTitle("Voltage [mV]");
|
---|
1288 | hf->GetXaxis()->CenterTitle();
|
---|
1289 | hf->GetYaxis()->CenterTitle();
|
---|
1290 | hf->SetMinimum(-1250);
|
---|
1291 | hf->SetMaximum(2150);
|
---|
1292 |
|
---|
1293 | if (!fAdcPersistent->isChecked())
|
---|
1294 | h = new TH1F("EventData", "", roi, -0.5, roi-0.5);
|
---|
1295 | else
|
---|
1296 | {
|
---|
1297 | h = new TH2F("EventData", "", roi, -0.5, roi-0.5, 6751, -2350.5*2000/4096, 4400.5*2000/4096);
|
---|
1298 | h->SetContour(50);
|
---|
1299 | gStyle->SetPalette(1, 0);
|
---|
1300 | }
|
---|
1301 |
|
---|
1302 | h->SetDirectory(0);
|
---|
1303 | h->SetBit(kCanDelete);
|
---|
1304 | h->SetMarkerStyle(kFullDotMedium);
|
---|
1305 | h->SetMarkerColor(kBlue);
|
---|
1306 |
|
---|
1307 | hf->Draw("");
|
---|
1308 |
|
---|
1309 | if (dynamic_cast<TH2*>(h))
|
---|
1310 | h->Draw("col same");
|
---|
1311 | }
|
---|
1312 |
|
---|
1313 | if (d0 && !(fDrsCalibBaselineOn->isChecked() && fDrsCalibBaseline->value()>0))
|
---|
1314 | {
|
---|
1315 | delete d0;
|
---|
1316 | d0 = 0;
|
---|
1317 | }
|
---|
1318 | if (d1 && !(fDrsCalibGainOn->isChecked() && fDrsCalibGain->value()>0))
|
---|
1319 | {
|
---|
1320 | delete d1;
|
---|
1321 | d1 = 0;
|
---|
1322 | }
|
---|
1323 | if (d2 && !(fDrsCalibTrgOffsetOn->isChecked() && fDrsCalibTrgOffset->value()>0))
|
---|
1324 | {
|
---|
1325 | delete d2;
|
---|
1326 | d2 = 0;
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 | if (!d0 && fDrsCalibBaselineOn->isChecked() && fDrsCalibBaseline->value()>0)
|
---|
1330 | {
|
---|
1331 | d0 = new TH1F("DrsCalib0", "", roi, -0.5, roi-0.5);
|
---|
1332 | d0->SetDirectory(0);
|
---|
1333 | d0->SetBit(kCanDelete);
|
---|
1334 | d0->SetMarkerStyle(kFullDotSmall);
|
---|
1335 | d0->SetMarkerColor(kRed);
|
---|
1336 | d0->SetLineColor(kRed);
|
---|
1337 | d0->Draw("PEX0same");
|
---|
1338 | }
|
---|
1339 |
|
---|
1340 | if (!d1 && fDrsCalibGainOn->isChecked() && fDrsCalibGain->value()>0)
|
---|
1341 | {
|
---|
1342 | d1 = new TH1F("DrsCalib1", "", roi, -0.5, roi-0.5);
|
---|
1343 | d1->SetDirectory(0);
|
---|
1344 | d1->SetBit(kCanDelete);
|
---|
1345 | d1->SetMarkerStyle(kFullDotSmall);
|
---|
1346 | d1->SetMarkerColor(kMagenta);
|
---|
1347 | d1->SetLineColor(kMagenta);
|
---|
1348 | d1->Draw("PEX0same");
|
---|
1349 | }
|
---|
1350 |
|
---|
1351 | if (!d2 && fDrsCalibTrgOffsetOn->isChecked() && fDrsCalibTrgOffset->value()>0)
|
---|
1352 | {
|
---|
1353 | d2 = new TH1F("DrsCalib2", "", roi, -0.5, roi-0.5);
|
---|
1354 | d2->SetDirectory(0);
|
---|
1355 | d2->SetBit(kCanDelete);
|
---|
1356 | d2->SetMarkerStyle(kFullDotSmall);
|
---|
1357 | d2->SetMarkerColor(kGreen);
|
---|
1358 | d2->SetLineColor(kGreen);
|
---|
1359 | d2->Draw("PEX0same");
|
---|
1360 | }
|
---|
1361 |
|
---|
1362 | if (!dynamic_cast<TH2*>(h) && !c->GetListOfPrimitives()->FindObject(h))
|
---|
1363 | h->Draw("PLsame");
|
---|
1364 |
|
---|
1365 | // -----------------------------------------------------------
|
---|
1366 |
|
---|
1367 | const uint32_t p =
|
---|
1368 | fAdcChannel->value() +
|
---|
1369 | fAdcChip->value() * 9+
|
---|
1370 | fAdcBoard->value() * 36+
|
---|
1371 | fAdcCrate->value() *360;
|
---|
1372 |
|
---|
1373 | ostringstream str;
|
---|
1374 | str << "CBPX = " << fAdcCrate->value() << '|' << fAdcBoard->value() << '|' << fAdcChip->value() << '|' << fAdcChannel->value() << " (" << p << ")";
|
---|
1375 | str << " EventNum = " << fEventData->EventNum;
|
---|
1376 | str << " TriggerNum = " << fEventData->TriggerNum;
|
---|
1377 | str << " TriggerType = " << fEventData->TriggerType;
|
---|
1378 | str << " BoardTime = " << fEventData->BoardTime[fAdcBoard->value()+fAdcCrate->value()*10];
|
---|
1379 | str << " (" << Time(fEventData->PCTime, fEventData->PCUsec) << ")";
|
---|
1380 | hf->SetTitle(str.str().c_str());
|
---|
1381 | str.str("");
|
---|
1382 | str << "ADC Pipeline (start cell: " << fEventData->StartPix[p] << ")";
|
---|
1383 | hf->SetXTitle(str.str().c_str());
|
---|
1384 |
|
---|
1385 | // -----------------------------------------------------------
|
---|
1386 |
|
---|
1387 | const int16_t start = fEventData->StartPix[p];
|
---|
1388 |
|
---|
1389 | fDrsCalibBaseline->setEnabled(fDrsCalibBaseline->value()>0);
|
---|
1390 | fDrsCalibGain->setEnabled(fDrsCalibGain->value()>0);
|
---|
1391 | fDrsCalibTrgOffset->setEnabled(fDrsCalibTrgOffset->value()>0);
|
---|
1392 | fDrsCalibROI->setEnabled(fDrsCalibROI->value()>0);
|
---|
1393 |
|
---|
1394 | fDrsCalibBaseline2->setEnabled(fDrsCalibBaseline->value()>0);
|
---|
1395 | fDrsCalibGain2->setEnabled(fDrsCalibGain->value()>0);
|
---|
1396 | fDrsCalibTrgOffset2->setEnabled(fDrsCalibTrgOffset->value()>0);
|
---|
1397 | fDrsCalibROI2->setEnabled(fDrsCalibROI->value()>0);
|
---|
1398 |
|
---|
1399 | SetLedColor(fFadLedDrsBaseline, fDrsCalibBaseline->value()>0 ?kLedGreen:kLedGray, Time());
|
---|
1400 | SetLedColor(fFadLedDrsGain, fDrsCalibGain->value()>0 ?kLedGreen:kLedGray, Time());
|
---|
1401 | SetLedColor(fFadLedDrsTrgOff, fDrsCalibTrgOffset->value()>0?kLedGreen:kLedGray, Time());
|
---|
1402 |
|
---|
1403 | if (d0)//fDrsCalibBaseline->value()==0 || start<0)
|
---|
1404 | d0->Reset();
|
---|
1405 | if (d1)//fDrsCalibGain->value()==0 || start<0)
|
---|
1406 | d1->Reset();
|
---|
1407 | if (d2)//fDrsCalibTrgOffset->value()==0 || start<0)
|
---|
1408 | d2->Reset();
|
---|
1409 |
|
---|
1410 | if (!dynamic_cast<TH2*>(h))
|
---|
1411 | h->Reset();
|
---|
1412 | if (d0)
|
---|
1413 | d0->SetEntries(0);
|
---|
1414 | if (d1)
|
---|
1415 | d1->SetEntries(0);
|
---|
1416 | if (d2)
|
---|
1417 | d2->SetEntries(0);
|
---|
1418 |
|
---|
1419 | for (int i=0; i<fEventData->Roi; i++)
|
---|
1420 | {
|
---|
1421 | // FIXME: physcial: i -> (i+start)%1024
|
---|
1422 | // FIXME: logical: i -> i
|
---|
1423 |
|
---|
1424 | const int ii = fAdcPhysical->isChecked() ? (i+start)%1024 : i;
|
---|
1425 |
|
---|
1426 | //if (dynamic_cast<TH2*>(h))
|
---|
1427 | h->Fill(ii, reinterpret_cast<float*>(fEventData->Adc_Data)[p*fEventData->Roi+i]);
|
---|
1428 | //else
|
---|
1429 | // h->SetBinContent(i+1, reinterpret_cast<float*>(fEventData->Adc_Data)[p*fEventData->Roi+i]);
|
---|
1430 | if (start<0)
|
---|
1431 | continue;
|
---|
1432 |
|
---|
1433 | if (d0)
|
---|
1434 | {
|
---|
1435 | d0->SetBinContent(ii+1, fDrsCalibration[1440*1024*0 + p*1024+(start+i)%1024]);
|
---|
1436 | d0->SetBinError(ii+1, fDrsCalibration[1440*1024*1 + p*1024+(start+i)%1024]);
|
---|
1437 |
|
---|
1438 | }
|
---|
1439 | if (d1)
|
---|
1440 | {
|
---|
1441 | d1->SetBinContent(ii+1, fDrsCalibration[1440*1024*2 + p*1024+(start+i)%1024]);
|
---|
1442 | d1->SetBinError(ii+1, fDrsCalibration[1440*1024*3 + p*1024+(start+i)%1024]);
|
---|
1443 | }
|
---|
1444 | if (d2)
|
---|
1445 | {
|
---|
1446 | d2->SetBinContent(ii+1, fDrsCalibration[1440*1024*4 + p*1024 + i]);
|
---|
1447 | d2->SetBinError(ii+1, fDrsCalibration[1440*1024*5 + p*1024 + i]);
|
---|
1448 | }
|
---|
1449 | }
|
---|
1450 |
|
---|
1451 | // -----------------------------------------------------------
|
---|
1452 | if (fAdcDynamicScale->isEnabled() && fAdcDynamicScale->isChecked())
|
---|
1453 | {
|
---|
1454 | h->SetMinimum();
|
---|
1455 | h->SetMaximum();
|
---|
1456 |
|
---|
1457 | hf->SetMinimum(h->GetMinimum());
|
---|
1458 | hf->SetMaximum(h->GetMaximum());
|
---|
1459 | }
|
---|
1460 | if (fAdcManualScale->isEnabled() && fAdcManualScale->isChecked())
|
---|
1461 | {
|
---|
1462 | if (h->GetMinimumStored()==-1111)
|
---|
1463 | {
|
---|
1464 | h->SetMinimum(-1150);//-1026);
|
---|
1465 | hf->SetMinimum(-1150);//-1026);
|
---|
1466 | }
|
---|
1467 | if (h->GetMaximumStored()==-1111)
|
---|
1468 | {
|
---|
1469 | h->SetMaximum(2150);//1025);
|
---|
1470 | hf->SetMaximum(2150);//1025);
|
---|
1471 | }
|
---|
1472 | }
|
---|
1473 |
|
---|
1474 | if (fAdcAutoScale->isEnabled() && fAdcAutoScale->isChecked())
|
---|
1475 | {
|
---|
1476 | h->SetMinimum();
|
---|
1477 | h->SetMaximum();
|
---|
1478 |
|
---|
1479 | if (h->GetMinimum()<hf->GetMinimum())
|
---|
1480 | hf->SetMinimum(h->GetMinimum());
|
---|
1481 | if (h->GetMaximum()>hf->GetMaximum())
|
---|
1482 | hf->SetMaximum(h->GetMaximum());
|
---|
1483 | }
|
---|
1484 |
|
---|
1485 | if (dynamic_cast<TH2*>(h))
|
---|
1486 | {
|
---|
1487 | h->SetMinimum();
|
---|
1488 | h->SetMaximum();
|
---|
1489 | }
|
---|
1490 |
|
---|
1491 | // -----------------------------------------------------------
|
---|
1492 |
|
---|
1493 | const int imin = ceil(hf->GetMinimum());
|
---|
1494 | const int imax = floor(hf->GetMaximum());
|
---|
1495 |
|
---|
1496 | TH1S hd("", "", imax-imin+1, imin-0.5, imax+0.5);
|
---|
1497 | hd.SetDirectory(0);
|
---|
1498 | TH1S h0("", "", imax-imin+1, imin-0.5, imax+0.5);
|
---|
1499 | h0.SetDirectory(0);
|
---|
1500 | TH1S h1("", "", imax-imin+1, imin-0.5, imax+0.5);
|
---|
1501 | h1.SetDirectory(0);
|
---|
1502 | TH1S h2("", "", imax-imin+1, imin-0.5, imax+0.5);
|
---|
1503 | h2.SetDirectory(0);
|
---|
1504 | hd.SetLineColor(h->GetLineColor());
|
---|
1505 | if (d0)
|
---|
1506 | h0.SetLineColor(d0->GetLineColor());
|
---|
1507 | if (d1)
|
---|
1508 | h1.SetLineColor(d1->GetLineColor());
|
---|
1509 | if (d2)
|
---|
1510 | h2.SetLineColor(d2->GetLineColor());
|
---|
1511 |
|
---|
1512 | for (int i=0; i<fEventData->Roi; i++)
|
---|
1513 | {
|
---|
1514 | if (!dynamic_cast<TH2*>(h))
|
---|
1515 | hd.Fill(h->GetBinContent(i+1));
|
---|
1516 | if (d0)
|
---|
1517 | h0.Fill(d0->GetBinContent(i+1));
|
---|
1518 | if (d1)
|
---|
1519 | h1.Fill(d1->GetBinContent(i+1));
|
---|
1520 | if (d2)
|
---|
1521 | h2.Fill(d2->GetBinContent(i+1));
|
---|
1522 | }
|
---|
1523 |
|
---|
1524 | double mm = hd.GetMaximum(hd.GetEntries());
|
---|
1525 | if (h0.GetMaximum(h0.GetEntries())>mm)
|
---|
1526 | mm = h0.GetMaximum();
|
---|
1527 | if (h1.GetMaximum(h1.GetEntries())>mm)
|
---|
1528 | mm = h1.GetMaximum();
|
---|
1529 | if (h2.GetMaximum(h2.GetEntries())>mm)
|
---|
1530 | mm = h2.GetMaximum();
|
---|
1531 |
|
---|
1532 | TIter Next(hf->GetListOfFunctions());
|
---|
1533 | TObject *obj = 0;
|
---|
1534 | while ((obj=Next()))
|
---|
1535 | if (dynamic_cast<TBox*>(obj))
|
---|
1536 | delete hf->GetListOfFunctions()->Remove(obj);
|
---|
1537 |
|
---|
1538 | const double l = h->GetBinLowEdge(h->GetXaxis()->GetLast()+1);
|
---|
1539 | const double m = c->GetX2();
|
---|
1540 |
|
---|
1541 | const double scale = 0.9*(m-l)/mm;
|
---|
1542 |
|
---|
1543 | c->cd();
|
---|
1544 |
|
---|
1545 | DrawHorizontal(hf, l, h2, scale);
|
---|
1546 | DrawHorizontal(hf, l, h1, scale);
|
---|
1547 | DrawHorizontal(hf, l, h0, scale);
|
---|
1548 | DrawHorizontal(hf, l, hd, scale);
|
---|
1549 |
|
---|
1550 | // -----------------------------------------------------------
|
---|
1551 |
|
---|
1552 | c->Modified();
|
---|
1553 | c->Update();
|
---|
1554 | #endif
|
---|
1555 | }
|
---|
1556 |
|
---|
1557 | void handleFadRawData(const DimData &d)
|
---|
1558 | {
|
---|
1559 | if (d.size()==0)
|
---|
1560 | return;
|
---|
1561 |
|
---|
1562 | if (fAdcStop->isChecked())
|
---|
1563 | return;
|
---|
1564 |
|
---|
1565 | const EVENT &dat = d.ref<EVENT>();
|
---|
1566 |
|
---|
1567 | if (d.size()<sizeof(EVENT))
|
---|
1568 | {
|
---|
1569 | cerr << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected>=" << sizeof(EVENT) << endl;
|
---|
1570 | return;
|
---|
1571 | }
|
---|
1572 |
|
---|
1573 | if (d.size()!=sizeof(EVENT)+dat.Roi*4*1440+dat.Roi*4*160)
|
---|
1574 | {
|
---|
1575 | cerr << "Size mismatch in " << d.name << ": Found=" << d.size() << " Expected=" << dat.Roi*4*1440+sizeof(EVENT) << " [roi=" << dat.Roi << "]" << endl;
|
---|
1576 | return;
|
---|
1577 | }
|
---|
1578 |
|
---|
1579 | delete fEventData;
|
---|
1580 | fEventData = reinterpret_cast<EVENT*>(new char[d.size()]);
|
---|
1581 | memcpy(fEventData, d.ptr<void>(), d.size());
|
---|
1582 |
|
---|
1583 | DisplayEventData();
|
---|
1584 | }
|
---|
1585 |
|
---|
1586 | void handleFadEventData(const DimData &d)
|
---|
1587 | {
|
---|
1588 | if (!CheckSize(d, 4*1440*sizeof(float)))
|
---|
1589 | return;
|
---|
1590 |
|
---|
1591 | if (fEventsStop->isChecked())
|
---|
1592 | return;
|
---|
1593 |
|
---|
1594 | const float *ptr = d.ptr<float>();
|
---|
1595 |
|
---|
1596 | valarray<double> arr1(1440);
|
---|
1597 | valarray<double> arr2(1440);
|
---|
1598 | valarray<double> arr3(1440);
|
---|
1599 | valarray<double> arr4(1440);
|
---|
1600 |
|
---|
1601 | for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
|
---|
1602 | {
|
---|
1603 | arr1[it->index] = ptr[0*1440+it->hw()];
|
---|
1604 | arr2[it->index] = ptr[1*1440+it->hw()];
|
---|
1605 | arr3[it->index] = ptr[2*1440+it->hw()];
|
---|
1606 | arr4[it->index] = ptr[3*1440+it->hw()];
|
---|
1607 | }
|
---|
1608 |
|
---|
1609 | fEventCanv1->SetData(arr1);
|
---|
1610 | fEventCanv2->SetData(arr2);
|
---|
1611 | fEventCanv3->SetData(arr3);
|
---|
1612 | fEventCanv4->SetData(arr4);
|
---|
1613 |
|
---|
1614 | fEventCanv1->updateCamera();
|
---|
1615 | fEventCanv2->updateCamera();
|
---|
1616 | fEventCanv3->updateCamera();
|
---|
1617 | fEventCanv4->updateCamera();
|
---|
1618 | }
|
---|
1619 |
|
---|
1620 | vector<float> fDrsCalibration;
|
---|
1621 |
|
---|
1622 | void handleFadDrsCalibration(const DimData &d)
|
---|
1623 | {
|
---|
1624 | const size_t sz = 1024*1440*6+1024*160*2;
|
---|
1625 |
|
---|
1626 | if (d.size()==0)
|
---|
1627 | {
|
---|
1628 | fDrsCalibBaseline->setValue(-1);
|
---|
1629 | fDrsCalibGain->setValue(-1);
|
---|
1630 | fDrsCalibTrgOffset->setValue(-1);
|
---|
1631 | fDrsCalibROI->setValue(-1);
|
---|
1632 |
|
---|
1633 | fDrsCalibBaseline2->setValue(-1);
|
---|
1634 | fDrsCalibGain2->setValue(-1);
|
---|
1635 | fDrsCalibTrgOffset2->setValue(-1);
|
---|
1636 | fDrsCalibROI2->setValue(-1);
|
---|
1637 |
|
---|
1638 | fDrsCalibration.assign(sz, 0);
|
---|
1639 | DisplayEventData();
|
---|
1640 | return;
|
---|
1641 | }
|
---|
1642 |
|
---|
1643 | if (!CheckSize(d, sz*sizeof(float)+4*sizeof(uint32_t)))
|
---|
1644 | // Do WHAT?
|
---|
1645 | return;
|
---|
1646 |
|
---|
1647 | const uint32_t *run = d.ptr<uint32_t>();
|
---|
1648 |
|
---|
1649 | fDrsCalibROI->setValue(run[0]);
|
---|
1650 | fDrsCalibBaseline->setValue(run[1]);
|
---|
1651 | fDrsCalibGain->setValue(run[2]);
|
---|
1652 | fDrsCalibTrgOffset->setValue(run[3]);
|
---|
1653 |
|
---|
1654 | fDrsCalibROI2->setValue(run[0]);
|
---|
1655 | fDrsCalibBaseline2->setValue(run[1]);
|
---|
1656 | fDrsCalibGain2->setValue(run[2]);
|
---|
1657 | fDrsCalibTrgOffset2->setValue(run[3]);
|
---|
1658 |
|
---|
1659 | const float *dat = d.ptr<float>(sizeof(uint32_t)*4);
|
---|
1660 | fDrsCalibration.assign(dat, dat+sz);
|
---|
1661 |
|
---|
1662 | DisplayEventData();
|
---|
1663 | }
|
---|
1664 |
|
---|
1665 | // vector<uint8_t> fFadConnections;
|
---|
1666 |
|
---|
1667 | void handleFadConnections(const DimData &d)
|
---|
1668 | {
|
---|
1669 | if (!CheckSize(d, 41))
|
---|
1670 | {
|
---|
1671 | fStatusEventBuilderLabel->setText("Offline");
|
---|
1672 | fStatusEventBuilderLabel->setToolTip("FADs or fadctrl seems to be offline.");
|
---|
1673 | fEvtBldWidget->setEnabled(false);
|
---|
1674 |
|
---|
1675 | SetLedColor(fStatusEventBuilderLed, kLedGray, d.time);
|
---|
1676 | return;
|
---|
1677 | }
|
---|
1678 |
|
---|
1679 | const uint8_t *ptr = d.ptr<uint8_t>();
|
---|
1680 |
|
---|
1681 | for (int i=0; i<40; i++)
|
---|
1682 | {
|
---|
1683 | const uint8_t stat1 = ptr[i]&3;
|
---|
1684 | const uint8_t stat2 = ptr[i]>>3;
|
---|
1685 |
|
---|
1686 | if (stat1==0 && stat2==0)
|
---|
1687 | {
|
---|
1688 | SetLedColor(fFadLED[i], kLedGray, d.time);
|
---|
1689 | continue;
|
---|
1690 | }
|
---|
1691 | if (stat1>=2 && stat2==8)
|
---|
1692 | {
|
---|
1693 | SetLedColor(fFadLED[i], stat1==2?kLedGreen:kLedGreenCheck, d.time);
|
---|
1694 | continue;
|
---|
1695 | }
|
---|
1696 |
|
---|
1697 | if (stat1==1 && stat2==1)
|
---|
1698 | SetLedColor(fFadLED[i], kLedRed, d.time);
|
---|
1699 | else
|
---|
1700 | SetLedColor(fFadLED[i], kLedOrange, d.time);
|
---|
1701 | }
|
---|
1702 |
|
---|
1703 |
|
---|
1704 | const bool runs = ptr[40]!=0;
|
---|
1705 |
|
---|
1706 | fStatusEventBuilderLabel->setText(runs?"Running":"Not running");
|
---|
1707 | fStatusEventBuilderLabel->setToolTip(runs?"Event builder thread running.":"Event builder thread stopped.");
|
---|
1708 | fEvtBldWidget->setEnabled(runs);
|
---|
1709 |
|
---|
1710 | SetLedColor(fStatusEventBuilderLed, runs?kLedGreen:kLedRed, d.time);
|
---|
1711 |
|
---|
1712 | // fFadConnections.assign(ptr, ptr+40);
|
---|
1713 | }
|
---|
1714 |
|
---|
1715 | template<typename T>
|
---|
1716 | void handleFadToolTip(const Time &time, QWidget *w, T *ptr)
|
---|
1717 | {
|
---|
1718 | ostringstream tip;
|
---|
1719 | tip << "<table border='1'><tr><th colspan='11'>" << time.GetAsStr() << " (UTC)</th></tr><tr><th></th>";
|
---|
1720 | for (int b=0; b<10; b++)
|
---|
1721 | tip << "<th>" << b << "</th>";
|
---|
1722 | tip << "</tr>";
|
---|
1723 |
|
---|
1724 | for (int c=0; c<4; c++)
|
---|
1725 | {
|
---|
1726 | tip << "<tr><th>" << c << "</th>";
|
---|
1727 | for (int b=0; b<10; b++)
|
---|
1728 | tip << "<td>" << ptr[c*10+b] << "</td>";
|
---|
1729 | tip << "</tr>";
|
---|
1730 | }
|
---|
1731 | tip << "</table>";
|
---|
1732 |
|
---|
1733 | w->setToolTip(tip.str().c_str());
|
---|
1734 | }
|
---|
1735 |
|
---|
1736 | template<typename T, class S>
|
---|
1737 | void handleFadMinMax(const DimData &d, QPushButton *led, S *wmin, S *wmax=0)
|
---|
1738 | {
|
---|
1739 | if (!CheckSize(d, 42*sizeof(T)))
|
---|
1740 | return;
|
---|
1741 |
|
---|
1742 | const T *ptr = d.ptr<T>();
|
---|
1743 | const T min = ptr[40];
|
---|
1744 | const T max = ptr[41];
|
---|
1745 |
|
---|
1746 | if (max==0 && min>max)
|
---|
1747 | SetLedColor(led, kLedGray, d.time);
|
---|
1748 | else
|
---|
1749 | SetLedColor(led, min==max?kLedGreen: kLedOrange, d.time);
|
---|
1750 |
|
---|
1751 | if (!wmax && max!=min)
|
---|
1752 | wmin->setValue(0);
|
---|
1753 | else
|
---|
1754 | wmin->setValue(min);
|
---|
1755 |
|
---|
1756 | if (wmax)
|
---|
1757 | wmax->setValue(max);
|
---|
1758 |
|
---|
1759 | handleFadToolTip(d.time, led, ptr);
|
---|
1760 | }
|
---|
1761 |
|
---|
1762 | void handleFadFwVersion(const DimData &d)
|
---|
1763 | {
|
---|
1764 | handleFadMinMax<float, QDoubleSpinBox>(d, fFadLedFwVersion, fFadFwVersion);
|
---|
1765 | }
|
---|
1766 |
|
---|
1767 | void handleFadRunNumber(const DimData &d)
|
---|
1768 | {
|
---|
1769 | handleFadMinMax<uint32_t, QSpinBox>(d, fFadLedRunNumber, fFadRunNumber);
|
---|
1770 | }
|
---|
1771 |
|
---|
1772 | void handleFadPrescaler(const DimData &d)
|
---|
1773 | {
|
---|
1774 | handleFadMinMax<uint16_t, QSpinBox>(d, fFadLedPrescaler, fFadPrescaler);
|
---|
1775 | }
|
---|
1776 |
|
---|
1777 | void handleFadDNA(const DimData &d)
|
---|
1778 | {
|
---|
1779 | if (!CheckSize(d, 40*sizeof(uint64_t)))
|
---|
1780 | return;
|
---|
1781 |
|
---|
1782 | const uint64_t *ptr = d.ptr<uint64_t>();
|
---|
1783 |
|
---|
1784 | ostringstream tip;
|
---|
1785 | tip << "<table width='100%'>";
|
---|
1786 | tip << "<tr><th>Crate</th><td></td><th>Board</th><td></td><th>DNA</th></tr>";
|
---|
1787 |
|
---|
1788 | for (int i=0; i<40; i++)
|
---|
1789 | {
|
---|
1790 | tip << dec;
|
---|
1791 | tip << "<tr>";
|
---|
1792 | tip << "<td align='center'>" << i/10 << "</td><td>:</td>";
|
---|
1793 | tip << "<td align='center'>" << i%10 << "</td><td>:</td>";
|
---|
1794 | tip << hex;
|
---|
1795 | tip << "<td>0x" << setfill('0') << setw(16) << ptr[i] << "</td>";
|
---|
1796 | tip << "</tr>";
|
---|
1797 | }
|
---|
1798 | tip << "</table>";
|
---|
1799 |
|
---|
1800 | fFadDNA->setText(tip.str().c_str());
|
---|
1801 | }
|
---|
1802 |
|
---|
1803 | void SetFadLed(QPushButton *led, const DimData &d, uint16_t bitmask, bool invert=false)
|
---|
1804 | {
|
---|
1805 | if (d.size()==0)
|
---|
1806 | {
|
---|
1807 | SetLedColor(led, kLedGray, d.time);
|
---|
1808 | return;
|
---|
1809 | }
|
---|
1810 |
|
---|
1811 | const bool quality = d.ptr<uint16_t>()[0]&bitmask;
|
---|
1812 | const bool value = d.ptr<uint16_t>()[1]&bitmask;
|
---|
1813 | const uint16_t *ptr = d.ptr<uint16_t>()+2;
|
---|
1814 |
|
---|
1815 | SetLedColor(led, quality?kLedOrange:(value^invert?kLedGreen:kLedGreenBar), d.time);
|
---|
1816 |
|
---|
1817 | ostringstream tip;
|
---|
1818 | tip << "<table border='1'><tr><th colspan='11'>" << d.time.GetAsStr() << " (UTC)</th></tr><tr><th></th>";
|
---|
1819 | for (int b=0; b<10; b++)
|
---|
1820 | tip << "<th>" << b << "</th>";
|
---|
1821 | tip << "</tr>";
|
---|
1822 |
|
---|
1823 | /*
|
---|
1824 | tip << "<tr>" << hex;
|
---|
1825 | tip << "<th>" << d.ptr<uint16_t>()[0] << " " << (d.ptr<uint16_t>()[0]&bitmask) << "</th>";
|
---|
1826 | tip << "<th>" << d.ptr<uint16_t>()[1] << " " << (d.ptr<uint16_t>()[1]&bitmask) << "</th>";
|
---|
1827 | tip << "</tr>";
|
---|
1828 | */
|
---|
1829 |
|
---|
1830 | for (int c=0; c<4; c++)
|
---|
1831 | {
|
---|
1832 | tip << "<tr><th>" << dec << c << "</th>" << hex;
|
---|
1833 | for (int b=0; b<10; b++)
|
---|
1834 | {
|
---|
1835 | tip << "<td>"
|
---|
1836 | << (ptr[c*10+b]&bitmask)
|
---|
1837 | << "</td>";
|
---|
1838 | }
|
---|
1839 | tip << "</tr>";
|
---|
1840 | }
|
---|
1841 | tip << "</table>";
|
---|
1842 |
|
---|
1843 | led->setToolTip(tip.str().c_str());
|
---|
1844 | }
|
---|
1845 |
|
---|
1846 | void handleFadStatus(const DimData &d)
|
---|
1847 | {
|
---|
1848 | if (d.size()!=0 && !CheckSize(d, 42*sizeof(uint16_t)))
|
---|
1849 | return;
|
---|
1850 |
|
---|
1851 | SetFadLed(fFadLedDrsEnabled, d, FAD::EventHeader::kDenable);
|
---|
1852 | SetFadLed(fFadLedDrsWrite, d, FAD::EventHeader::kDwrite);
|
---|
1853 | SetFadLed(fFadLedDcmLocked, d, FAD::EventHeader::kDcmLocked);
|
---|
1854 | SetFadLed(fFadLedDcmReady, d, FAD::EventHeader::kDcmReady);
|
---|
1855 | SetFadLed(fFadLedSpiSclk, d, FAD::EventHeader::kSpiSclk);
|
---|
1856 | SetFadLed(fFadLedRefClockTooLow, d, FAD::EventHeader::kRefClkTooLow, true);
|
---|
1857 | SetFadLed(fFadLedBusyOn, d, FAD::EventHeader::kBusyOn);
|
---|
1858 | SetFadLed(fFadLedBusyOff, d, FAD::EventHeader::kBusyOff);
|
---|
1859 | SetFadLed(fFadLedTriggerLine, d, FAD::EventHeader::kTriggerLine);
|
---|
1860 | SetFadLed(fFadLedContTrigger, d, FAD::EventHeader::kContTrigger);
|
---|
1861 | SetFadLed(fFadLedSocket, d, FAD::EventHeader::kSock17);
|
---|
1862 | SetFadLed(fFadLedPllLock, d, 0xf000);
|
---|
1863 | }
|
---|
1864 |
|
---|
1865 | void handleFadStatistics1(const DimData &d)
|
---|
1866 | {
|
---|
1867 | if (!CheckSize(d, sizeof(GUI_STAT)))
|
---|
1868 | return;
|
---|
1869 |
|
---|
1870 | const GUI_STAT &stat = d.ref<GUI_STAT>();
|
---|
1871 |
|
---|
1872 | /*
|
---|
1873 | //info about status of the main threads
|
---|
1874 | int32_t readStat ; //read thread
|
---|
1875 | int32_t procStat ; //processing thread(s)
|
---|
1876 | int32_t writStat ; //write thread
|
---|
1877 | */
|
---|
1878 |
|
---|
1879 | fFadBufferMax->setValue(stat.totMem/1000000);
|
---|
1880 | fFadBuffer->setMaximum(stat.totMem/100);
|
---|
1881 | fFadBuffer->setValue((stat.maxMem>stat.totMem?stat.totMem:stat.maxMem)/100); // Max mem used in last second
|
---|
1882 |
|
---|
1883 | uint32_t sum = 0;
|
---|
1884 | //int32_t min = 0x7fffff;
|
---|
1885 | //int32_t max = 0;
|
---|
1886 |
|
---|
1887 | int cnt = 0;
|
---|
1888 | int err = 0;
|
---|
1889 |
|
---|
1890 | for (int i=0; i<40; i++)
|
---|
1891 | {
|
---|
1892 | if (stat.numConn[i]!=1)
|
---|
1893 | continue;
|
---|
1894 |
|
---|
1895 | cnt++;
|
---|
1896 |
|
---|
1897 | sum += stat.rateBytes[i];
|
---|
1898 | err += stat.errConn[i];
|
---|
1899 |
|
---|
1900 | //if (stat.rateBytes[i]<min)
|
---|
1901 | // min = stat.rateBytes[i];
|
---|
1902 | //if (stat.rateBytes[i]>max)
|
---|
1903 | // max = stat.rateBytes[i];
|
---|
1904 | }
|
---|
1905 |
|
---|
1906 | fFadEvtConn->setValue(cnt);
|
---|
1907 | fFadEvtConnErr->setValue(err);
|
---|
1908 |
|
---|
1909 | fFadEvtBufNew->setValue(stat.bufNew); // Incomplete in buffer
|
---|
1910 | fFadEvtBufEvt->setValue(stat.bufEvt); // Complete in buffer
|
---|
1911 | fFadEvtBufMax->setValue(stat.maxEvt); // Complete in buffer
|
---|
1912 | fFadEvtWrite->setValue(stat.evtWrite-stat.evtSkip-stat.evtErr);
|
---|
1913 | fFadEvtSkip->setValue(stat.evtSkip);
|
---|
1914 | fFadEvtErr->setValue(stat.evtErr);
|
---|
1915 |
|
---|
1916 | if (stat.deltaT==0)
|
---|
1917 | return;
|
---|
1918 |
|
---|
1919 | //fFadEthernetRateMin->setValue(min/stat.deltaT);
|
---|
1920 | //fFadEthernetRateMax->setValue(max/stat.deltaT);
|
---|
1921 | fFadEthernetRateTot->setValue(sum/stat.deltaT);
|
---|
1922 | fFadEthernetRateAvg->setValue(cnt==0 ? 0 : sum/cnt/stat.deltaT);
|
---|
1923 |
|
---|
1924 | fFadTransmission->setValue(1000*stat.rateNew/stat.deltaT);
|
---|
1925 | fFadWriteRate->setValue(1000*stat.rateWrite/stat.deltaT);
|
---|
1926 | }
|
---|
1927 |
|
---|
1928 | void handleFadStatistics2(const DimData &d)
|
---|
1929 | {
|
---|
1930 | if (!CheckSize(d, sizeof(EVT_STAT)))
|
---|
1931 | return;
|
---|
1932 |
|
---|
1933 | //const EVT_STAT &stat = d.ref<EVT_STAT>();
|
---|
1934 |
|
---|
1935 | /*
|
---|
1936 | //some info about what happened since start of program (or last 'reset')
|
---|
1937 | uint32_t reset ; //#if increased, reset all counters
|
---|
1938 | uint32_t numRead[MAX_SOCK] ; //how often succesfull read from N sockets per loop
|
---|
1939 |
|
---|
1940 | uint64_t gotByte[NBOARDS] ; //#Bytes read per Board
|
---|
1941 | uint32_t gotErr[NBOARDS] ; //#Communication Errors per Board
|
---|
1942 |
|
---|
1943 | uint32_t evtGet; //#new Start of Events read
|
---|
1944 | uint32_t evtTot; //#complete Events read
|
---|
1945 |
|
---|
1946 | uint32_t evtErr; //#Events with Errors
|
---|
1947 | uint32_t evtSkp; //#Events incomplete (timeout)
|
---|
1948 |
|
---|
1949 |
|
---|
1950 | uint32_t procTot; //#Events processed
|
---|
1951 | uint32_t procErr; //#Events showed problem in processing
|
---|
1952 | uint32_t procTrg; //#Events accepted by SW trigger
|
---|
1953 | uint32_t procSkp; //#Events rejected by SW trigger
|
---|
1954 |
|
---|
1955 | uint32_t feedTot; //#Events used for feedBack system
|
---|
1956 | uint32_t feedErr; //#Events rejected by feedBack
|
---|
1957 |
|
---|
1958 | uint32_t wrtTot; //#Events written to disk
|
---|
1959 | uint32_t wrtErr; //#Events with write-error
|
---|
1960 |
|
---|
1961 | uint32_t runOpen; //#Runs opened
|
---|
1962 | uint32_t runClose; //#Runs closed
|
---|
1963 | uint32_t runErr; //#Runs with open/close errors
|
---|
1964 |
|
---|
1965 |
|
---|
1966 | //info about current connection status
|
---|
1967 | uint8_t numConn[NBOARDS] ; //#Sockets succesfully open per board
|
---|
1968 | */
|
---|
1969 | }
|
---|
1970 |
|
---|
1971 | void handleFadFileFormat(const DimData &d)
|
---|
1972 | {
|
---|
1973 | if (!CheckSize(d, sizeof(uint16_t)))
|
---|
1974 | return;
|
---|
1975 |
|
---|
1976 | const uint16_t &fmt = d.get<uint16_t>();
|
---|
1977 |
|
---|
1978 | SetLedColor(fFadLedFileFormatNone, fmt==FAD::kNone ?kLedGreen:kLedGray, d.time);
|
---|
1979 | SetLedColor(fFadLedFileFormatDebug, fmt==FAD::kDebug?kLedGreen:kLedGray, d.time);
|
---|
1980 | SetLedColor(fFadLedFileFormatRaw, fmt==FAD::kRaw ?kLedGreen:kLedGray, d.time);
|
---|
1981 | SetLedColor(fFadLedFileFormatFits, fmt==FAD::kFits ?kLedGreen:kLedGray, d.time);
|
---|
1982 | SetLedColor(fFadLedFileFormatCalib, fmt==FAD::kCalib?kLedGreen:kLedGray, d.time);
|
---|
1983 | }
|
---|
1984 |
|
---|
1985 | // ===================== FTM ============================================
|
---|
1986 |
|
---|
1987 | FTM::DimTriggerRates fTriggerRates;
|
---|
1988 |
|
---|
1989 | void UpdateTriggerRate(const FTM::DimTriggerRates &sdata)
|
---|
1990 | {
|
---|
1991 | #ifdef HAVE_ROOT
|
---|
1992 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
---|
1993 |
|
---|
1994 | TH1 *h = (TH1*)c->FindObject("TimeFrame");
|
---|
1995 |
|
---|
1996 | if (sdata.fTriggerRate<0)
|
---|
1997 | {
|
---|
1998 | fGraphFtmRate.Set(0);
|
---|
1999 |
|
---|
2000 | const double tm = Time().RootTime();
|
---|
2001 |
|
---|
2002 | h->SetBins(1, tm, tm+60);
|
---|
2003 | h->GetXaxis()->SetTimeFormat("%M'%S\"");
|
---|
2004 | h->GetXaxis()->SetTitle("Time");
|
---|
2005 |
|
---|
2006 | c->Modified();
|
---|
2007 | c->Update();
|
---|
2008 | return;
|
---|
2009 | }
|
---|
2010 |
|
---|
2011 | const double t1 = h->GetXaxis()->GetXmax();
|
---|
2012 | const double t0 = h->GetXaxis()->GetXmin();
|
---|
2013 |
|
---|
2014 | const double now = t0+sdata.fTimeStamp/1000000.;
|
---|
2015 |
|
---|
2016 | h->SetBins(h->GetNbinsX()+1, t0, now+1);
|
---|
2017 | fGraphFtmRate.SetPoint(fGraphFtmRate.GetN(), now, sdata.fTriggerRate);
|
---|
2018 |
|
---|
2019 | if (t1-t0>300)
|
---|
2020 | {
|
---|
2021 | h->GetXaxis()->SetTimeFormat("%Hh%M'");
|
---|
2022 | h->GetXaxis()->SetTitle("Time");
|
---|
2023 | }
|
---|
2024 |
|
---|
2025 | h->SetMinimum(0);
|
---|
2026 |
|
---|
2027 | c->Modified();
|
---|
2028 | c->Update();
|
---|
2029 | #endif
|
---|
2030 | }
|
---|
2031 |
|
---|
2032 | void UpdateRatesCam(const FTM::DimTriggerRates &sdata)
|
---|
2033 | {
|
---|
2034 | if (fThresholdIdx->value()>=0)
|
---|
2035 | {
|
---|
2036 | const int isw = fThresholdIdx->value();
|
---|
2037 | const int ihw = fPatchMapHW[isw];
|
---|
2038 | fPatchRate->setValue(sdata.fPatchRate[ihw]);
|
---|
2039 | fBoardRate->setValue(sdata.fBoardRate[ihw/4]);
|
---|
2040 | }
|
---|
2041 |
|
---|
2042 | const bool b = fBoardRatesEnabled->isChecked();
|
---|
2043 |
|
---|
2044 | valarray<double> dat(0., 1440);
|
---|
2045 |
|
---|
2046 | // fPatch converts from software id to software patch id
|
---|
2047 | for (int i=0; i<1440; i++)
|
---|
2048 | {
|
---|
2049 | const int ihw = fPixelMap.index(i).hw()/9;
|
---|
2050 | dat[i] = b ? sdata.fBoardRate[ihw/4] : sdata.fPatchRate[ihw];
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 | fRatesCanv->SetData(dat);
|
---|
2054 | fRatesCanv->updateCamera();
|
---|
2055 | }
|
---|
2056 |
|
---|
2057 | int64_t fTimeStamp0;
|
---|
2058 |
|
---|
2059 | void on_fBoardRatesEnabled_toggled(bool)
|
---|
2060 | {
|
---|
2061 | UpdateRatesCam(fTriggerRates);
|
---|
2062 | }
|
---|
2063 |
|
---|
2064 | void UpdateRatesGraphs(const FTM::DimTriggerRates &sdata)
|
---|
2065 | {
|
---|
2066 | #ifdef HAVE_ROOT
|
---|
2067 | if (fTimeStamp0<0)
|
---|
2068 | {
|
---|
2069 | fTimeStamp0 = sdata.fTimeStamp;
|
---|
2070 | return;
|
---|
2071 | }
|
---|
2072 |
|
---|
2073 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
---|
2074 |
|
---|
2075 | TH1 *h = (TH1*)c->FindObject("TimeFrame");
|
---|
2076 |
|
---|
2077 | const double tdiff = sdata.fTimeStamp-fTimeStamp0;
|
---|
2078 | fTimeStamp0 = sdata.fTimeStamp;
|
---|
2079 |
|
---|
2080 | if (tdiff<0)
|
---|
2081 | {
|
---|
2082 | for (int i=0; i<160; i++)
|
---|
2083 | fGraphPatchRate[i].Set(0);
|
---|
2084 | for (int i=0; i<40; i++)
|
---|
2085 | fGraphBoardRate[i].Set(0);
|
---|
2086 |
|
---|
2087 | return;
|
---|
2088 | }
|
---|
2089 |
|
---|
2090 | //const double t1 = h->GetXaxis()->GetXmax();
|
---|
2091 | const double t0 = h->GetXaxis()->GetXmin();
|
---|
2092 |
|
---|
2093 | for (int i=0; i<160; i++)
|
---|
2094 | if (fFtuStatus[i/4]>0)
|
---|
2095 | fGraphPatchRate[i].SetPoint(fGraphPatchRate[i].GetN(),
|
---|
2096 | t0+sdata.fTimeStamp/1000000., sdata.fPatchRate[i]);
|
---|
2097 | for (int i=0; i<40; i++)
|
---|
2098 | if (fFtuStatus[i]>0)
|
---|
2099 | fGraphBoardRate[i].SetPoint(fGraphBoardRate[i].GetN(),
|
---|
2100 | t0+sdata.fTimeStamp/1000000., sdata.fBoardRate[i]);
|
---|
2101 |
|
---|
2102 | c->Modified();
|
---|
2103 | c->Update();
|
---|
2104 | #endif
|
---|
2105 | }
|
---|
2106 |
|
---|
2107 | void handleFtmTriggerRates(const DimData &d)
|
---|
2108 | {
|
---|
2109 | if (!CheckSize(d, sizeof(FTM::DimTriggerRates)))
|
---|
2110 | return;
|
---|
2111 |
|
---|
2112 | const FTM::DimTriggerRates &sdata = d.ref<FTM::DimTriggerRates>();
|
---|
2113 |
|
---|
2114 | fFtmTime->setText(QString::number(sdata.fTimeStamp/1000000., 'f', 6)+ " s");
|
---|
2115 | fTriggerCounter->setText(QString::number(sdata.fTriggerCounter));
|
---|
2116 |
|
---|
2117 | if (sdata.fTimeStamp>0)
|
---|
2118 | fTriggerCounterRate->setValue(1000000.*sdata.fTriggerCounter/sdata.fTimeStamp);
|
---|
2119 | else
|
---|
2120 | fTriggerCounterRate->setValue(0);
|
---|
2121 |
|
---|
2122 | // ----------------------------------------------
|
---|
2123 |
|
---|
2124 | fOnTime->setText(QString::number(sdata.fOnTimeCounter/1000000., 'f', 6)+" s");
|
---|
2125 |
|
---|
2126 | if (sdata.fTimeStamp>0)
|
---|
2127 | fOnTimeRel->setValue(100.*sdata.fOnTimeCounter/sdata.fTimeStamp);
|
---|
2128 | else
|
---|
2129 | fOnTimeRel->setValue(0);
|
---|
2130 |
|
---|
2131 | // ----------------------------------------------
|
---|
2132 |
|
---|
2133 | UpdateTriggerRate(sdata);
|
---|
2134 | UpdateRatesGraphs(sdata);
|
---|
2135 | UpdateRatesCam(sdata);
|
---|
2136 |
|
---|
2137 | fTriggerRates = sdata;
|
---|
2138 | }
|
---|
2139 |
|
---|
2140 | void handleFtmCounter(const DimData &d)
|
---|
2141 | {
|
---|
2142 | if (!CheckSize(d, sizeof(uint32_t)*6))
|
---|
2143 | return;
|
---|
2144 |
|
---|
2145 | const uint32_t *sdata = d.ptr<uint32_t>();
|
---|
2146 |
|
---|
2147 | fFtmCounterH->setValue(sdata[0]);
|
---|
2148 | fFtmCounterS->setValue(sdata[1]);
|
---|
2149 | fFtmCounterD->setValue(sdata[2]);
|
---|
2150 | fFtmCounterF->setValue(sdata[3]);
|
---|
2151 | fFtmCounterE->setValue(sdata[4]);
|
---|
2152 | fFtmCounterR->setValue(sdata[5]);
|
---|
2153 | }
|
---|
2154 |
|
---|
2155 | void handleFtmDynamicData(const DimData &d)
|
---|
2156 | {
|
---|
2157 | if (!CheckSize(d, sizeof(FTM::DimDynamicData)))
|
---|
2158 | return;
|
---|
2159 |
|
---|
2160 | const FTM::DimDynamicData &sdata = d.ref<FTM::DimDynamicData>();
|
---|
2161 |
|
---|
2162 | fFtmTemp0->setValue(sdata.fTempSensor[0]*0.1);
|
---|
2163 | fFtmTemp1->setValue(sdata.fTempSensor[1]*0.1);
|
---|
2164 | fFtmTemp2->setValue(sdata.fTempSensor[2]*0.1);
|
---|
2165 | fFtmTemp3->setValue(sdata.fTempSensor[3]*0.1);
|
---|
2166 |
|
---|
2167 | SetLedColor(fClockCondLed, sdata.fState&FTM::kFtmLocked ? kLedGreen : kLedRed, d.time);
|
---|
2168 | }
|
---|
2169 |
|
---|
2170 | void DisplayRates()
|
---|
2171 | {
|
---|
2172 | #ifdef HAVE_ROOT
|
---|
2173 | TCanvas *c = fFtmRateCanv->GetCanvas();
|
---|
2174 |
|
---|
2175 | while (c->FindObject("PatchRate"))
|
---|
2176 | c->GetListOfPrimitives()->Remove(c->FindObject("PatchRate"));
|
---|
2177 |
|
---|
2178 | while (c->FindObject("BoardRate"))
|
---|
2179 | c->GetListOfPrimitives()->Remove(c->FindObject("BoardRate"));
|
---|
2180 |
|
---|
2181 | c->cd();
|
---|
2182 |
|
---|
2183 | if (fRatePatch1->value()>=0)
|
---|
2184 | {
|
---|
2185 | fGraphPatchRate[fRatePatch1->value()].SetLineColor(kRed);
|
---|
2186 | fGraphPatchRate[fRatePatch1->value()].SetMarkerColor(kRed);
|
---|
2187 | fGraphPatchRate[fRatePatch1->value()].Draw("PL");
|
---|
2188 | }
|
---|
2189 | if (fRatePatch2->value()>=0)
|
---|
2190 | {
|
---|
2191 | fGraphPatchRate[fRatePatch2->value()].SetLineColor(kGreen);
|
---|
2192 | fGraphPatchRate[fRatePatch2->value()].SetMarkerColor(kGreen);
|
---|
2193 | fGraphPatchRate[fRatePatch2->value()].Draw("PL");
|
---|
2194 | }
|
---|
2195 | if (fRateBoard1->value()>=0)
|
---|
2196 | {
|
---|
2197 | fGraphBoardRate[fRateBoard1->value()].SetLineColor(kMagenta);
|
---|
2198 | fGraphBoardRate[fRateBoard1->value()].SetMarkerColor(kMagenta);
|
---|
2199 | fGraphBoardRate[fRateBoard1->value()].Draw("PL");
|
---|
2200 | }
|
---|
2201 | if (fRateBoard2->value()>=0)
|
---|
2202 | {
|
---|
2203 | fGraphBoardRate[fRateBoard2->value()].SetLineColor(kCyan);
|
---|
2204 | fGraphBoardRate[fRateBoard2->value()].SetMarkerColor(kCyan);
|
---|
2205 | fGraphBoardRate[fRateBoard2->value()].Draw("PL");
|
---|
2206 | }
|
---|
2207 |
|
---|
2208 | c->Modified();
|
---|
2209 | c->Update();
|
---|
2210 | #endif
|
---|
2211 | }
|
---|
2212 |
|
---|
2213 | FTM::DimStaticData fFtmStaticData;
|
---|
2214 |
|
---|
2215 | void SetFtuLed(int idx, int counter, const Time &t)
|
---|
2216 | {
|
---|
2217 | if (counter==0 || counter>3)
|
---|
2218 | counter = 3;
|
---|
2219 |
|
---|
2220 | if (counter<0)
|
---|
2221 | counter = 0;
|
---|
2222 |
|
---|
2223 | const LedColor_t col[4] = { kLedGray, kLedGreen, kLedOrange, kLedRed };
|
---|
2224 |
|
---|
2225 | SetLedColor(fFtuLED[idx], col[counter], t);
|
---|
2226 |
|
---|
2227 | fFtuStatus[idx] = counter;
|
---|
2228 | }
|
---|
2229 |
|
---|
2230 | void SetFtuStatusLed(const Time &t)
|
---|
2231 | {
|
---|
2232 | const int max = fFtuStatus.max();
|
---|
2233 |
|
---|
2234 | switch (max)
|
---|
2235 | {
|
---|
2236 | case 0:
|
---|
2237 | SetLedColor(fStatusFTULed, kLedGray, t);
|
---|
2238 | fStatusFTULabel->setText("All disabled");
|
---|
2239 | fStatusFTULabel->setToolTip("All FTUs are disabled");
|
---|
2240 | break;
|
---|
2241 |
|
---|
2242 | case 1:
|
---|
2243 | SetLedColor(fStatusFTULed, kLedGreen, t);
|
---|
2244 | fStatusFTULabel->setToolTip("Communication with FTU is smooth.");
|
---|
2245 | fStatusFTULabel->setText("ok");
|
---|
2246 | break;
|
---|
2247 |
|
---|
2248 | case 2:
|
---|
2249 | SetLedColor(fStatusFTULed, kLedOrange, t);
|
---|
2250 | fStatusFTULabel->setText("Warning");
|
---|
2251 | fStatusFTULabel->setToolTip("At least one FTU didn't answer immediately");
|
---|
2252 | break;
|
---|
2253 |
|
---|
2254 | case 3:
|
---|
2255 | SetLedColor(fStatusFTULed, kLedRed, t);
|
---|
2256 | fStatusFTULabel->setToolTip("At least one FTU didn't answer!");
|
---|
2257 | fStatusFTULabel->setText("ERROR");
|
---|
2258 | break;
|
---|
2259 | }
|
---|
2260 |
|
---|
2261 | const int cnt = count(&fFtuStatus[0], &fFtuStatus[40], 0);
|
---|
2262 | fFtuAllOn->setEnabled(cnt!=0);
|
---|
2263 | fFtuAllOff->setEnabled(cnt!=40);
|
---|
2264 | }
|
---|
2265 |
|
---|
2266 | void handleFtmStaticData(const DimData &d)
|
---|
2267 | {
|
---|
2268 | if (!CheckSize(d, sizeof(FTM::DimStaticData)))
|
---|
2269 | return;
|
---|
2270 |
|
---|
2271 | const FTM::DimStaticData &sdata = d.ref<FTM::DimStaticData>();
|
---|
2272 |
|
---|
2273 | fTriggerInterval->setValue(sdata.fTriggerInterval);
|
---|
2274 | fPhysicsCoincidence->setValue(sdata.fMultiplicityPhysics);
|
---|
2275 | fCalibCoincidence->setValue(sdata.fMultiplicityCalib);
|
---|
2276 | fPhysicsWindow->setValue(sdata.fWindowPhysics);
|
---|
2277 | fCalibWindow->setValue(sdata.fWindowCalib);
|
---|
2278 |
|
---|
2279 | fTriggerDelay->setValue(sdata.fDelayTrigger);
|
---|
2280 | fTimeMarkerDelay->setValue(sdata.fDelayTimeMarker);
|
---|
2281 | fDeadTime->setValue(sdata.fDeadTime);
|
---|
2282 |
|
---|
2283 | fClockCondR0->setValue(sdata.fClockConditioner[0]);
|
---|
2284 | fClockCondR1->setValue(sdata.fClockConditioner[1]);
|
---|
2285 | fClockCondR8->setValue(sdata.fClockConditioner[2]);
|
---|
2286 | fClockCondR9->setValue(sdata.fClockConditioner[3]);
|
---|
2287 | fClockCondR11->setValue(sdata.fClockConditioner[4]);
|
---|
2288 | fClockCondR13->setValue(sdata.fClockConditioner[5]);
|
---|
2289 | fClockCondR14->setValue(sdata.fClockConditioner[6]);
|
---|
2290 | fClockCondR15->setValue(sdata.fClockConditioner[7]);
|
---|
2291 |
|
---|
2292 | const uint32_t R0 = sdata.fClockConditioner[0];
|
---|
2293 | const uint32_t R14 = sdata.fClockConditioner[6];
|
---|
2294 | const uint32_t R15 = sdata.fClockConditioner[7];
|
---|
2295 |
|
---|
2296 | const uint32_t Ndiv = (R15&0x1ffff00)<<2;
|
---|
2297 | const uint32_t Rdiv = (R14&0x007ff00)>>8;
|
---|
2298 | const uint32_t Cdiv = (R0 &0x000ff00)>>8;
|
---|
2299 |
|
---|
2300 | double freq = 40.*Ndiv/(Rdiv*Cdiv);
|
---|
2301 |
|
---|
2302 | fClockCondFreqRes->setValue(freq);
|
---|
2303 |
|
---|
2304 | //fClockCondFreq->setEditText("");
|
---|
2305 | fClockCondFreq->setCurrentIndex(0);
|
---|
2306 |
|
---|
2307 | fTriggerSeqPed->setValue(sdata.fTriggerSeqPed);
|
---|
2308 | fTriggerSeqLPint->setValue(sdata.fTriggerSeqLPint);
|
---|
2309 | fTriggerSeqLPext->setValue(sdata.fTriggerSeqLPext);
|
---|
2310 |
|
---|
2311 | fLpIntIntensity->setValue(sdata.fIntensityLPint);
|
---|
2312 | fLpExtIntensity->setValue(sdata.fIntensityLPext);
|
---|
2313 |
|
---|
2314 | fLpIntGroup1->setChecked(sdata.HasLPintG1());
|
---|
2315 | fLpIntGroup2->setChecked(sdata.HasLPintG2());
|
---|
2316 | fLpExtGroup1->setChecked(sdata.HasLPextG1());
|
---|
2317 | fLpExtGroup2->setChecked(sdata.HasLPextG2());
|
---|
2318 |
|
---|
2319 | fEnableTrigger->setChecked(sdata.HasTrigger());
|
---|
2320 | fEnableVeto->setChecked(sdata.HasVeto());
|
---|
2321 | fEnableExt1->setChecked(sdata.HasExt1());
|
---|
2322 | fEnableExt2->setChecked(sdata.HasExt2());
|
---|
2323 | fEnableClockCond->setChecked(sdata.HasClockConditioner());
|
---|
2324 |
|
---|
2325 | uint16_t multiplicity = sdata.fMultiplicity[0];
|
---|
2326 |
|
---|
2327 | for (int i=0; i<40; i++)
|
---|
2328 | {
|
---|
2329 | if (!sdata.IsActive(i))
|
---|
2330 | SetFtuLed(i, -1, d.time);
|
---|
2331 | else
|
---|
2332 | {
|
---|
2333 | if (fFtuStatus[i]==0)
|
---|
2334 | SetFtuLed(i, 1, d.time);
|
---|
2335 | }
|
---|
2336 | fFtuLED[i]->setChecked(false);
|
---|
2337 |
|
---|
2338 | if (sdata.fMultiplicity[i]!=multiplicity)
|
---|
2339 | multiplicity = -1;
|
---|
2340 |
|
---|
2341 | }
|
---|
2342 | SetFtuStatusLed(d.time);
|
---|
2343 |
|
---|
2344 | fNoutof4Val->setValue(multiplicity);
|
---|
2345 |
|
---|
2346 | for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
|
---|
2347 | fRatesCanv->SetEnable(it->index, sdata.IsEnabled(it->hw()));
|
---|
2348 |
|
---|
2349 | const PixelMapEntry &entry = fPixelMap.index(fPixelIdx->value());
|
---|
2350 | fPixelEnable->setChecked(sdata.IsEnabled(entry.hw()));
|
---|
2351 |
|
---|
2352 | if (fThresholdIdx->value()>=0)
|
---|
2353 | {
|
---|
2354 | const int isw = fThresholdIdx->value();
|
---|
2355 | const int ihw = fPatchMapHW[isw];
|
---|
2356 | fThresholdVal->setValue(sdata.fThreshold[ihw]);
|
---|
2357 | }
|
---|
2358 |
|
---|
2359 | fPrescalingVal->setValue(sdata.fPrescaling[0]);
|
---|
2360 |
|
---|
2361 | fFtmStaticData = sdata;
|
---|
2362 | }
|
---|
2363 |
|
---|
2364 | void handleFtmPassport(const DimData &d)
|
---|
2365 | {
|
---|
2366 | if (!CheckSize(d, sizeof(FTM::DimPassport)))
|
---|
2367 | return;
|
---|
2368 |
|
---|
2369 | const FTM::DimPassport &sdata = d.ref<FTM::DimPassport>();
|
---|
2370 |
|
---|
2371 | stringstream str1, str2;
|
---|
2372 | str1 << hex << "0x" << setfill('0') << setw(16) << sdata.fBoardId;
|
---|
2373 | str2 << sdata.fFirmwareId;
|
---|
2374 |
|
---|
2375 | fFtmBoardId->setText(str1.str().c_str());
|
---|
2376 | fFtmFirmwareId->setText(str2.str().c_str());
|
---|
2377 | }
|
---|
2378 |
|
---|
2379 | void handleFtmFtuList(const DimData &d)
|
---|
2380 | {
|
---|
2381 | if (!CheckSize(d, sizeof(FTM::DimFtuList)))
|
---|
2382 | return;
|
---|
2383 |
|
---|
2384 | fFtuPing->setChecked(false);
|
---|
2385 |
|
---|
2386 | const FTM::DimFtuList &sdata = d.ref<FTM::DimFtuList>();
|
---|
2387 |
|
---|
2388 | stringstream str;
|
---|
2389 | str << "<table width='100%'>" << setfill('0');
|
---|
2390 | str << "<tr><th>Num</th><th></th><th>Addr</th><th></th><th>DNA</th></tr>";
|
---|
2391 | for (int i=0; i<40; i++)
|
---|
2392 | {
|
---|
2393 | str << "<tr>";
|
---|
2394 | str << "<td align='center'>" << dec << i << hex << "</td>";
|
---|
2395 | str << "<td align='center'>:</td>";
|
---|
2396 | str << "<td align='center'>0x" << setw(2) << (int)sdata.fAddr[i] << "</td>";
|
---|
2397 | str << "<td align='center'>:</td>";
|
---|
2398 | str << "<td align='center'>0x" << setw(16) << sdata.fDNA[i] << "</td>";
|
---|
2399 | str << "</tr>";
|
---|
2400 | }
|
---|
2401 | str << "</table>";
|
---|
2402 |
|
---|
2403 | fFtuDNA->setText(str.str().c_str());
|
---|
2404 |
|
---|
2405 | fFtuAnswersTotal->setValue(sdata.fNumBoards);
|
---|
2406 | fFtuAnswersCrate0->setValue(sdata.fNumBoardsCrate[0]);
|
---|
2407 | fFtuAnswersCrate1->setValue(sdata.fNumBoardsCrate[1]);
|
---|
2408 | fFtuAnswersCrate2->setValue(sdata.fNumBoardsCrate[2]);
|
---|
2409 | fFtuAnswersCrate3->setValue(sdata.fNumBoardsCrate[3]);
|
---|
2410 |
|
---|
2411 | for (int i=0; i<40; i++)
|
---|
2412 | SetFtuLed(i, sdata.IsActive(i) ? sdata.fPing[i] : -1, d.time);
|
---|
2413 |
|
---|
2414 | SetFtuStatusLed(d.time);
|
---|
2415 | }
|
---|
2416 |
|
---|
2417 | void handleFtmError(const DimData &d)
|
---|
2418 | {
|
---|
2419 | if (!CheckSize(d, sizeof(FTM::DimError)))
|
---|
2420 | return;
|
---|
2421 |
|
---|
2422 | const FTM::DimError &sdata = d.ref<FTM::DimError>();
|
---|
2423 |
|
---|
2424 | SetFtuLed(sdata.fError.fDestAddress, sdata.fError.fNumCalls, d.time);
|
---|
2425 | SetFtuStatusLed(d.time);
|
---|
2426 |
|
---|
2427 | // FIXME: Write to special window!
|
---|
2428 | //Out() << "Error:" << endl;
|
---|
2429 | //Out() << sdata.fError << endl;
|
---|
2430 | }
|
---|
2431 |
|
---|
2432 | // ========================== FSC =======================================
|
---|
2433 |
|
---|
2434 | void SetFscValue(QDoubleSpinBox *box, const DimData &d, int idx, bool enable)
|
---|
2435 | {
|
---|
2436 | //box->setEnabled(enable);
|
---|
2437 | if (!enable)
|
---|
2438 | {
|
---|
2439 | box->setToolTip(d.time.GetAsStr().c_str());
|
---|
2440 | return;
|
---|
2441 | }
|
---|
2442 |
|
---|
2443 | ostringstream str;
|
---|
2444 | str << d.time << " -- " << d.get<float>() << "s";
|
---|
2445 |
|
---|
2446 | box->setToolTip(str.str().c_str());
|
---|
2447 | box->setValue(d.get<float>(idx*4+4));
|
---|
2448 | }
|
---|
2449 |
|
---|
2450 |
|
---|
2451 | void handleFscTemp(const DimData &d)
|
---|
2452 | {
|
---|
2453 | const bool enable = d.size()>0 && CheckSize(d, 60*sizeof(float));
|
---|
2454 | if (!enable)
|
---|
2455 | return;
|
---|
2456 |
|
---|
2457 | QDoubleSpinBox *boxes[] = {
|
---|
2458 | fTempCam00, fTempCam01,
|
---|
2459 | fTempCam10, fTempCam11, fTempCam12, fTempCam13, fTempCam14,
|
---|
2460 | fTempCam20, fTempCam21, fTempCam22, fTempCam23, fTempCam24, fTempCam25,
|
---|
2461 | fTempCam30, fTempCam31, fTempCam32, fTempCam33, fTempCam34,
|
---|
2462 | fTempCam40, fTempCam41, fTempCam42, fTempCam43, fTempCam44, fTempCam45,
|
---|
2463 | fTempCam50, fTempCam51, fTempCam52, fTempCam53, fTempCam54,
|
---|
2464 | fTempCam60, fTempCam61,
|
---|
2465 | // 0:b/f 1:b/f 2:b/f 3:b/f
|
---|
2466 | fTempCrate0back, fTempCrate0front,
|
---|
2467 | fTempCrate1back, fTempCrate1front,
|
---|
2468 | fTempCrate2back, fTempCrate2front,
|
---|
2469 | fTempCrate3back, fTempCrate3front,
|
---|
2470 | // 0:b/f 1:b/f 2:b/f 3:b/f
|
---|
2471 | fTempPS0back, fTempPS0front,
|
---|
2472 | fTempPS1back, fTempPS1front,
|
---|
2473 | fTempPS2back, fTempPS2front,
|
---|
2474 | fTempPS3back, fTempPS3front,
|
---|
2475 | // AUX PS: FTM t/b; FSC t/b
|
---|
2476 | fTempAuxFTMtop, fTempAuxFTMbottom,
|
---|
2477 | fTempAuxFSCtop, fTempAuxFSCbottom,
|
---|
2478 | // Backpanel: FTM t/b; FSC t/b
|
---|
2479 | fTempBackpanelFTMtop, fTempBackpanelFTMbottom,
|
---|
2480 | fTempBackpanelFSCtop, fTempBackpanelFSCbottom,
|
---|
2481 | // top front/back; bottom front/back
|
---|
2482 | fTempSwitchboxTopFront, fTempSwitchboxTopBack,
|
---|
2483 | fTempSwitchboxBottomFront, fTempSwitchboxBottomBack,
|
---|
2484 | };
|
---|
2485 |
|
---|
2486 | for (int i=0; i<59; i++)
|
---|
2487 | SetFscValue(boxes[i], d, i, enable);
|
---|
2488 |
|
---|
2489 | if (!enable)
|
---|
2490 | return;
|
---|
2491 |
|
---|
2492 | const float *ptr = d.ptr<float>();
|
---|
2493 |
|
---|
2494 | double avg = 0;
|
---|
2495 | int num = 0;
|
---|
2496 | for (int i=1; i<32; i++)
|
---|
2497 | if (ptr[i]!=0)
|
---|
2498 | {
|
---|
2499 | avg += ptr[i];
|
---|
2500 | num ++;
|
---|
2501 | }
|
---|
2502 |
|
---|
2503 | fTempCamAvg->setValue(num?avg/num:0);
|
---|
2504 | }
|
---|
2505 |
|
---|
2506 | void handleFscVolt(const DimData &d)
|
---|
2507 | {
|
---|
2508 | const bool enable = d.size()>0 && CheckSize(d, 31*sizeof(float));
|
---|
2509 | if (!enable)
|
---|
2510 | return;
|
---|
2511 |
|
---|
2512 | QDoubleSpinBox *boxes[] = {
|
---|
2513 | fVoltFad00, fVoltFad10, fVoltFad20, fVoltFad30,
|
---|
2514 | fVoltFad01, fVoltFad11, fVoltFad21, fVoltFad31,
|
---|
2515 | fVoltFad02, fVoltFad12, fVoltFad22, fVoltFad32,
|
---|
2516 | fVoltFPA00, fVoltFPA10, fVoltFPA20, fVoltFPA30,
|
---|
2517 | fVoltFPA01, fVoltFPA11, fVoltFPA21, fVoltFPA31,
|
---|
2518 | fVoltFPA02, fVoltFPA12, fVoltFPA22, fVoltFPA32,
|
---|
2519 | fVoltETH0, fVoltETH1,
|
---|
2520 | fVoltFTM0, fVoltFTM1,
|
---|
2521 | fVoltFFC, fVoltFLP,
|
---|
2522 | };
|
---|
2523 |
|
---|
2524 | for (int i=0; i<30; i++)
|
---|
2525 | SetFscValue(boxes[i], d, i, enable);
|
---|
2526 | }
|
---|
2527 |
|
---|
2528 | void handleFscCurrent(const DimData &d)
|
---|
2529 | {
|
---|
2530 | const bool enable = d.size()>0 && CheckSize(d, 31*sizeof(float));
|
---|
2531 | if (!enable)
|
---|
2532 | return;
|
---|
2533 |
|
---|
2534 | QDoubleSpinBox *boxes[] = {
|
---|
2535 | fAmpFad00, fAmpFad10, fAmpFad20, fAmpFad30,
|
---|
2536 | fAmpFad01, fAmpFad11, fAmpFad21, fAmpFad31,
|
---|
2537 | fAmpFad02, fAmpFad12, fAmpFad22, fAmpFad32,
|
---|
2538 | fAmpFPA00, fAmpFPA10, fAmpFPA20, fAmpFPA30,
|
---|
2539 | fAmpFPA01, fAmpFPA11, fAmpFPA21, fAmpFPA31,
|
---|
2540 | fAmpFPA02, fAmpFPA12, fAmpFPA22, fAmpFPA32,
|
---|
2541 | fAmpETH0, fAmpETH1,
|
---|
2542 | fAmpFTM0, fAmpFTM1,
|
---|
2543 | fAmpFFC, fAmpFLP,
|
---|
2544 | };
|
---|
2545 |
|
---|
2546 | for (int i=0; i<30; i++)
|
---|
2547 | SetFscValue(boxes[i], d, i, enable);
|
---|
2548 | }
|
---|
2549 |
|
---|
2550 | void handleFscHumidity(const DimData &d)
|
---|
2551 | {
|
---|
2552 | const bool enable = d.size()>0 && CheckSize(d, 5*sizeof(float));
|
---|
2553 |
|
---|
2554 | SetFscValue(fHumidity1, d, 0, enable);
|
---|
2555 | SetFscValue(fHumidity2, d, 1, enable);
|
---|
2556 | SetFscValue(fHumidity3, d, 2, enable);
|
---|
2557 | SetFscValue(fHumidity4, d, 3, enable);
|
---|
2558 | }
|
---|
2559 |
|
---|
2560 | // ========================== Feedback ==================================
|
---|
2561 |
|
---|
2562 | #ifdef HAVE_ROOT
|
---|
2563 | TGraphErrors fGraphFeedbackDev;
|
---|
2564 | TGraphErrors fGraphFeedbackCmd;
|
---|
2565 |
|
---|
2566 | void UpdateFeedback(TQtWidget &rwidget, const Time &time, TGraphErrors &graph, double avg, double rms)
|
---|
2567 | {
|
---|
2568 | TCanvas *c = rwidget.GetCanvas();
|
---|
2569 |
|
---|
2570 | TH1 *h = (TH1*)c->FindObject("TimeFrame");
|
---|
2571 |
|
---|
2572 | while (graph.GetN()>500)
|
---|
2573 | graph.RemovePoint(0);
|
---|
2574 |
|
---|
2575 | const double now = time.RootTime();
|
---|
2576 |
|
---|
2577 | while (graph.GetN()>0 && now-graph.GetX()[0]>3600)
|
---|
2578 | graph.RemovePoint(0);
|
---|
2579 |
|
---|
2580 | const int n = graph.GetN();
|
---|
2581 |
|
---|
2582 | const double xmin = n>0 ? graph.GetX()[0] : now;
|
---|
2583 |
|
---|
2584 | h->SetBins(n+1, xmin-1, now+1);
|
---|
2585 | graph.SetPoint(n, now, avg);
|
---|
2586 | graph.SetPointError(n, 0, rms);
|
---|
2587 |
|
---|
2588 | h->GetXaxis()->SetTimeFormat(now-xmin>300 ? "%Hh%M'" : "%M'%S\"");
|
---|
2589 |
|
---|
2590 | c->Modified();
|
---|
2591 | c->Update();
|
---|
2592 | }
|
---|
2593 | #endif
|
---|
2594 |
|
---|
2595 | void handleFeedbackDeviation(const DimData &d)
|
---|
2596 | {
|
---|
2597 | if (!CheckSize(d, 2*416*sizeof(float)))
|
---|
2598 | return;
|
---|
2599 |
|
---|
2600 | const float *ptr = d.ptr<float>();
|
---|
2601 |
|
---|
2602 | valarray<float> dev(1440);
|
---|
2603 | valarray<float> cmd(1440);
|
---|
2604 |
|
---|
2605 | double avgdev = 0;
|
---|
2606 | double avgcmd = 0;
|
---|
2607 |
|
---|
2608 | double rmsdev = 0;
|
---|
2609 | double rmscmd = 0;
|
---|
2610 |
|
---|
2611 | for (int i=0; i<1440; i++)
|
---|
2612 | {
|
---|
2613 | const PixelMapEntry &entry = fPixelMap.index(i);
|
---|
2614 |
|
---|
2615 | dev[i] = /*1000*/ptr[entry.hv()];
|
---|
2616 | cmd[i] = 1000*ptr[entry.hv()+416];
|
---|
2617 |
|
---|
2618 | avgdev += dev[i];
|
---|
2619 | avgcmd += cmd[i];
|
---|
2620 |
|
---|
2621 | rmsdev += dev[i]*dev[i];
|
---|
2622 | rmscmd += cmd[i]*cmd[i];
|
---|
2623 | }
|
---|
2624 |
|
---|
2625 | avgdev /= 1440;
|
---|
2626 | avgcmd /= 1440;
|
---|
2627 |
|
---|
2628 | rmsdev = sqrt(rmsdev/1440 - avgdev*avgdev);
|
---|
2629 | rmscmd = sqrt(rmscmd/1440 - avgcmd*avgcmd);
|
---|
2630 |
|
---|
2631 | fFeedbackDevCam->SetData(dev);
|
---|
2632 | fFeedbackCmdCam->SetData(cmd);
|
---|
2633 |
|
---|
2634 | fFeedbackDevCam->updateCamera();
|
---|
2635 | fFeedbackCmdCam->updateCamera();
|
---|
2636 |
|
---|
2637 | #ifdef HAVE_ROOT
|
---|
2638 | UpdateFeedback(*fFeedbackDev, d.time, fGraphFeedbackDev, avgdev, rmsdev);
|
---|
2639 | UpdateFeedback(*fFeedbackCmd, d.time, fGraphFeedbackCmd, avgcmd, rmscmd);
|
---|
2640 | #endif
|
---|
2641 | }
|
---|
2642 |
|
---|
2643 | void handleFeedbackReference(const DimData &d)
|
---|
2644 | {
|
---|
2645 | if (!CheckSize(d, 416*sizeof(float)))
|
---|
2646 | return;
|
---|
2647 |
|
---|
2648 | const float *ptr = d.ptr<float>();
|
---|
2649 |
|
---|
2650 | // fFeedbackRefCam->SetData(valarray<float>(ptr, 416));
|
---|
2651 | // fFeedbackRefCam->updateCamera();
|
---|
2652 | }
|
---|
2653 |
|
---|
2654 | vector<float> fBiasOffsets;
|
---|
2655 |
|
---|
2656 | void handleFeedbackCalibration(const DimData &d)
|
---|
2657 | {
|
---|
2658 | if (!CheckSize(d, 2*416*sizeof(float)))
|
---|
2659 | return;
|
---|
2660 |
|
---|
2661 | const float *ptr = d.ptr<float>();
|
---|
2662 | fBiasOffsets.assign(ptr, ptr+416);
|
---|
2663 | }
|
---|
2664 |
|
---|
2665 | // ======================= Rate Scan ====================================
|
---|
2666 |
|
---|
2667 | TGraph fGraphRateScan[201];
|
---|
2668 |
|
---|
2669 | void UpdateRateScan(uint32_t th, const float *rates)
|
---|
2670 | {
|
---|
2671 | #ifdef HAVE_ROOT
|
---|
2672 | TCanvas *c = fRateScanCanv->GetCanvas();
|
---|
2673 |
|
---|
2674 | TH1 *h = (TH1*)c->FindObject("Frame");
|
---|
2675 |
|
---|
2676 | if (fGraphRateScan[0].GetN()==0 || th<fGraphRateScan[0].GetX()[fGraphRateScan[0].GetN()-1])
|
---|
2677 | {
|
---|
2678 | h->SetBins(1, th<10 ? 0 : th-10, th+10);
|
---|
2679 | h->SetMinimum(1);
|
---|
2680 | h->SetMaximum(rates[0]*2);
|
---|
2681 |
|
---|
2682 | for (int i=0; i<201; i++)
|
---|
2683 | {
|
---|
2684 | fGraphRateScan[i].Set(0);
|
---|
2685 | fGraphRateScan[i].SetPoint(fGraphRateScan[i].GetN(), th, rates[i]);
|
---|
2686 | }
|
---|
2687 |
|
---|
2688 | c->SetGrid();
|
---|
2689 | c->SetLogy();
|
---|
2690 |
|
---|
2691 | c->Modified();
|
---|
2692 | c->Update();
|
---|
2693 | return;
|
---|
2694 | }
|
---|
2695 |
|
---|
2696 | const double dac = h->GetXaxis()->GetXmin();
|
---|
2697 | h->SetBins(h->GetNbinsX()+1, dac, th+10);
|
---|
2698 |
|
---|
2699 | for (int i=0; i<201; i++)
|
---|
2700 | fGraphRateScan[i].SetPoint(fGraphRateScan[i].GetN(), th, rates[i]);
|
---|
2701 |
|
---|
2702 | c->Modified();
|
---|
2703 | c->Update();
|
---|
2704 | #endif
|
---|
2705 | }
|
---|
2706 |
|
---|
2707 | void DisplayRateScan()
|
---|
2708 | {
|
---|
2709 | #ifdef HAVE_ROOT
|
---|
2710 | TCanvas *c = fRateScanCanv->GetCanvas();
|
---|
2711 |
|
---|
2712 | while (c->FindObject("PatchRate"))
|
---|
2713 | c->GetListOfPrimitives()->Remove(c->FindObject("PatchRate"));
|
---|
2714 |
|
---|
2715 | while (c->FindObject("BoardRate"))
|
---|
2716 | c->GetListOfPrimitives()->Remove(c->FindObject("BoardRate"));
|
---|
2717 |
|
---|
2718 | c->cd();
|
---|
2719 |
|
---|
2720 | if (fRateScanPatch1->value()>=0)
|
---|
2721 | {
|
---|
2722 | fGraphRateScan[fRateScanPatch1->value()+41].SetLineColor(kRed);
|
---|
2723 | fGraphRateScan[fRateScanPatch1->value()+41].SetMarkerColor(kRed);
|
---|
2724 | fGraphRateScan[fRateScanPatch1->value()+41].Draw("PL");
|
---|
2725 | }
|
---|
2726 | if (fRateScanPatch2->value()>=0)
|
---|
2727 | {
|
---|
2728 | fGraphRateScan[fRateScanPatch2->value()+41].SetLineColor(kGreen);
|
---|
2729 | fGraphRateScan[fRateScanPatch2->value()+41].SetMarkerColor(kGreen);
|
---|
2730 | fGraphRateScan[fRateScanPatch2->value()+41].Draw("PL");
|
---|
2731 | }
|
---|
2732 | if (fRateScanBoard1->value()>=0)
|
---|
2733 | {
|
---|
2734 | fGraphRateScan[fRateScanBoard1->value()+1].SetLineColor(kMagenta);
|
---|
2735 | fGraphRateScan[fRateScanBoard1->value()+1].SetMarkerColor(kMagenta);
|
---|
2736 | fGraphRateScan[fRateScanBoard1->value()+1].Draw("PL");
|
---|
2737 | }
|
---|
2738 | if (fRateScanBoard2->value()>=0)
|
---|
2739 | {
|
---|
2740 | fGraphRateScan[fRateScanBoard2->value()+1].SetLineColor(kCyan);
|
---|
2741 | fGraphRateScan[fRateScanBoard2->value()+1].SetMarkerColor(kCyan);
|
---|
2742 | fGraphRateScan[fRateScanBoard2->value()+1].Draw("PL");
|
---|
2743 | }
|
---|
2744 |
|
---|
2745 | c->Modified();
|
---|
2746 | c->Update();
|
---|
2747 | #endif
|
---|
2748 | }
|
---|
2749 |
|
---|
2750 | void handleRateScan(const DimData &d)
|
---|
2751 | {
|
---|
2752 | if (!CheckSize(d, 204*sizeof(float)))
|
---|
2753 | return;
|
---|
2754 |
|
---|
2755 | UpdateRateScan(d.get<uint32_t>(), d.ptr<float>(12));
|
---|
2756 | }
|
---|
2757 |
|
---|
2758 | // ========================== FSC =======================================
|
---|
2759 |
|
---|
2760 | vector<int16_t> fVecBiasVolt;
|
---|
2761 | vector<int16_t> fVecBiasCurrent;
|
---|
2762 |
|
---|
2763 | void handleBiasVolt(const DimData &d)
|
---|
2764 | {
|
---|
2765 | if (!CheckSize(d, 2*416*sizeof(int16_t)))
|
---|
2766 | return;
|
---|
2767 |
|
---|
2768 | const int16_t *ptr = d.ptr<int16_t>();
|
---|
2769 |
|
---|
2770 | fVecBiasVolt.assign(ptr, ptr+2*416);
|
---|
2771 |
|
---|
2772 | on_fBiasDispRefVolt_stateChanged();
|
---|
2773 | UpdateBiasValues();
|
---|
2774 | }
|
---|
2775 |
|
---|
2776 | void handleBiasCurrent(const DimData &d)
|
---|
2777 | {
|
---|
2778 | if (!CheckSize(d, 416*sizeof(int16_t)))
|
---|
2779 | return;
|
---|
2780 |
|
---|
2781 | const int16_t *ptr = d.ptr<int16_t>();
|
---|
2782 |
|
---|
2783 | fVecBiasCurrent.assign(ptr, ptr+416);
|
---|
2784 |
|
---|
2785 | valarray<double> dat(0., 1440);
|
---|
2786 |
|
---|
2787 | // fPatch converts from software id to software patch id
|
---|
2788 | for (int i=0; i<1440; i++)
|
---|
2789 | {
|
---|
2790 | const PixelMapEntry &entry = fPixelMap.index(i);
|
---|
2791 |
|
---|
2792 | // FIXME: Display Overcurrent
|
---|
2793 | /*
|
---|
2794 | dat[i] = fVecBiasVolt[entry.hv()]*90./4096;
|
---|
2795 | double amp = abs(ptr[entry.hv()]);
|
---|
2796 | if (fBiasOffsets.size()>0)
|
---|
2797 | amp -= fBiasOffsets[entry.hv()];
|
---|
2798 | amp *= 5000./4096;
|
---|
2799 | amp *= 5200 *1e-6;
|
---|
2800 | dat[i] -= amp;
|
---|
2801 | */
|
---|
2802 |
|
---|
2803 | dat[i] = abs(ptr[entry.hv()]);
|
---|
2804 | if (fBiasOffsets.size()>0)
|
---|
2805 | dat[i] -= fBiasOffsets[entry.hv()];
|
---|
2806 | dat[i] *= 5000./4096;
|
---|
2807 |
|
---|
2808 | if (entry.group()==1)
|
---|
2809 | dat[i] *= 0.92;
|
---|
2810 |
|
---|
2811 | fBiasCamA->SetEnable(i, uint16_t(ptr[entry.hv()])!=0x8000);
|
---|
2812 | fBiasCamA->highlightPixel(i, ptr[entry.hv()]<0);
|
---|
2813 | }
|
---|
2814 |
|
---|
2815 | fBiasCamA->SetData(dat);
|
---|
2816 | fBiasCamA->updateCamera();
|
---|
2817 |
|
---|
2818 | UpdateBiasValues();
|
---|
2819 | }
|
---|
2820 |
|
---|
2821 | // ====================== MessageImp ====================================
|
---|
2822 |
|
---|
2823 | bool fChatOnline;
|
---|
2824 |
|
---|
2825 | void handleStateChanged(const Time &time, const std::string &server,
|
---|
2826 | const State &s)
|
---|
2827 | {
|
---|
2828 | // FIXME: Prefix tooltip with time
|
---|
2829 | if (server=="MCP")
|
---|
2830 | {
|
---|
2831 | // FIXME: Enable FTU page!!!
|
---|
2832 | fStatusMCPLabel->setText(s.name.c_str());
|
---|
2833 | fStatusMCPLabel->setToolTip(s.comment.c_str());
|
---|
2834 |
|
---|
2835 | if (s.index<2) // No Dim connection
|
---|
2836 | SetLedColor(fStatusMCPLed, kLedGray, time);
|
---|
2837 | if (s.index==2) // Disconnected
|
---|
2838 | SetLedColor(fStatusMCPLed, kLedRed, time);
|
---|
2839 | if (s.index==3) // Connecting
|
---|
2840 | SetLedColor(fStatusMCPLed, kLedOrange, time);
|
---|
2841 | if (s.index==4) // Connected
|
---|
2842 | SetLedColor(fStatusMCPLed, kLedYellow, time);
|
---|
2843 | if (s.index==5 || s.index==10) // Idle
|
---|
2844 | SetLedColor(fStatusMCPLed, kLedGreen, time);
|
---|
2845 |
|
---|
2846 | if (s.index>=7 && s.index<=9)
|
---|
2847 | SetLedColor(fStatusMCPLed, kLedGreenBar, time);
|
---|
2848 |
|
---|
2849 | fMcpStartRun->setEnabled(s.index>=5);
|
---|
2850 | fMcpStopRun->setEnabled(s.index>=5);
|
---|
2851 | fMcpReset->setEnabled(s.index==5||(s.index>=7 && s.index<=10));
|
---|
2852 | }
|
---|
2853 |
|
---|
2854 | if (server=="FTM_CONTROL")
|
---|
2855 | {
|
---|
2856 | // FIXME: Enable FTU page!!!
|
---|
2857 | fStatusFTMLabel->setText(s.name.c_str());
|
---|
2858 | fStatusFTMLabel->setToolTip(s.comment.c_str());
|
---|
2859 |
|
---|
2860 | bool enable = false;
|
---|
2861 | const bool configuring =
|
---|
2862 | s.index==FTM::StateMachine::kConfiguring1 ||
|
---|
2863 | s.index==FTM::StateMachine::kConfiguring2 ||
|
---|
2864 | s.index==FTM::StateMachine::kConfigured;
|
---|
2865 |
|
---|
2866 | if (s.index<FTM::StateMachine::kDisconnected) // No Dim connection
|
---|
2867 | SetLedColor(fStatusFTMLed, kLedGray, time);
|
---|
2868 | if (s.index==FTM::StateMachine::kDisconnected) // Dim connection / FTM disconnected
|
---|
2869 | SetLedColor(fStatusFTMLed, kLedYellow, time);
|
---|
2870 | if (s.index==FTM::StateMachine::kConnected ||
|
---|
2871 | s.index==FTM::StateMachine::kIdle ||
|
---|
2872 | configuring) // Dim connection / FTM connected
|
---|
2873 | SetLedColor(fStatusFTMLed, kLedGreen, time);
|
---|
2874 | if (s.index==FTM::StateMachine::kTriggerOn) // Dim connection / FTM connected
|
---|
2875 | SetLedColor(fStatusFTMLed, kLedGreenCheck, time);
|
---|
2876 | if (s.index==FTM::StateMachine::kConnected ||
|
---|
2877 | s.index==FTM::StateMachine::kIdle) // Dim connection / FTM connected
|
---|
2878 | enable = true;
|
---|
2879 |
|
---|
2880 | fFtmStartRun->setEnabled(!configuring && enable);
|
---|
2881 | fFtmStopRun->setEnabled(!configuring && (enable || s.index==FTM::StateMachine::kTriggerOn));
|
---|
2882 |
|
---|
2883 | fTriggerWidget->setEnabled(enable);
|
---|
2884 | fFtuGroupEnable->setEnabled(enable);
|
---|
2885 | fRatesControls->setEnabled(enable);
|
---|
2886 | fFtuWidget->setEnabled(s.index>FTM::StateMachine::kDisconnected);
|
---|
2887 |
|
---|
2888 | if (s.index>=FTM::StateMachine::kConnected)
|
---|
2889 | SetFtuStatusLed(time);
|
---|
2890 | else
|
---|
2891 | {
|
---|
2892 | SetLedColor(fStatusFTULed, kLedGray, time);
|
---|
2893 | fStatusFTULabel->setText("Offline");
|
---|
2894 | fStatusFTULabel->setToolTip("FTM is not online.");
|
---|
2895 | }
|
---|
2896 | }
|
---|
2897 |
|
---|
2898 | if (server=="FAD_CONTROL")
|
---|
2899 | {
|
---|
2900 | fStatusFADLabel->setText(s.name.c_str());
|
---|
2901 | fStatusFADLabel->setToolTip(s.comment.c_str());
|
---|
2902 |
|
---|
2903 | bool enable = false;
|
---|
2904 |
|
---|
2905 | if (s.index<FAD::kOffline) // No Dim connection
|
---|
2906 | {
|
---|
2907 | SetLedColor(fStatusFADLed, kLedGray, time);
|
---|
2908 |
|
---|
2909 | // Timing problem - sometimes they stay gray :(
|
---|
2910 | //for (int i=0; i<40; i++)
|
---|
2911 | // SetLedColor(fFadLED[i], kLedGray, time);
|
---|
2912 |
|
---|
2913 | /*
|
---|
2914 | fStatusEventBuilderLabel->setText("Offline");
|
---|
2915 | fStatusEventBuilderLabel->setToolTip("No connection to fadctrl.");
|
---|
2916 | fEvtBldWidget->setEnabled(false);
|
---|
2917 |
|
---|
2918 | SetLedColor(fStatusEventBuilderLed, kLedGray, time);
|
---|
2919 | */
|
---|
2920 | }
|
---|
2921 | if (s.index==FAD::kOffline) // Dim connection / FTM disconnected
|
---|
2922 | SetLedColor(fStatusFADLed, kLedRed, time);
|
---|
2923 | if (s.index==FAD::kDisconnected) // Dim connection / FTM disconnected
|
---|
2924 | SetLedColor(fStatusFADLed, kLedOrange, time);
|
---|
2925 | if (s.index==FAD::kConnecting) // Dim connection / FTM disconnected
|
---|
2926 | {
|
---|
2927 | SetLedColor(fStatusFADLed, kLedYellow, time);
|
---|
2928 | // FIXME FIXME FIXME: The LEDs are not displayed when disabled!
|
---|
2929 | enable = true;
|
---|
2930 | }
|
---|
2931 | if (s.index>=FAD::kConnected) // Dim connection / FTM connected
|
---|
2932 | {
|
---|
2933 | SetLedColor(fStatusFADLed, kLedGreen, time);
|
---|
2934 | enable = true;
|
---|
2935 | }
|
---|
2936 |
|
---|
2937 | fFadWidget->setEnabled(enable);
|
---|
2938 |
|
---|
2939 | fFadStart->setEnabled(s.index==FAD::kOffline);
|
---|
2940 | fFadStop->setEnabled(s.index>FAD::kOffline);
|
---|
2941 | fFadAbort->setEnabled(s.index>FAD::kOffline);
|
---|
2942 | fFadSoftReset->setEnabled(s.index>FAD::kOffline);
|
---|
2943 | fFadHardReset->setEnabled(s.index>FAD::kOffline);
|
---|
2944 | }
|
---|
2945 |
|
---|
2946 | if (server=="FSC_CONTROL")
|
---|
2947 | {
|
---|
2948 | fStatusFSCLabel->setText(s.name.c_str());
|
---|
2949 | fStatusFSCLabel->setToolTip(s.comment.c_str());
|
---|
2950 |
|
---|
2951 | bool enable = false;
|
---|
2952 |
|
---|
2953 | if (s.index<1) // No Dim connection
|
---|
2954 | SetLedColor(fStatusFSCLed, kLedGray, time);
|
---|
2955 | if (s.index==1) // Dim connection / FTM disconnected
|
---|
2956 | SetLedColor(fStatusFSCLed, kLedRed, time);
|
---|
2957 | if (s.index>=2) // Dim connection / FTM disconnected
|
---|
2958 | {
|
---|
2959 | SetLedColor(fStatusFSCLed, kLedGreen, time);
|
---|
2960 | enable = true;
|
---|
2961 | }
|
---|
2962 |
|
---|
2963 | fAuxWidget->setEnabled(enable);
|
---|
2964 | }
|
---|
2965 |
|
---|
2966 | if (server=="DRIVE_CONTROL")
|
---|
2967 | {
|
---|
2968 | fStatusDriveLabel->setText(s.name.c_str());
|
---|
2969 | fStatusDriveLabel->setToolTip(s.comment.c_str());
|
---|
2970 |
|
---|
2971 | if (s.index<1) // No Dim connection
|
---|
2972 | SetLedColor(fStatusDriveLed, kLedGray, time);
|
---|
2973 | if (s.index==1) // Dim connection / No connection to cosy
|
---|
2974 | SetLedColor(fStatusDriveLed, kLedRed, time);
|
---|
2975 | if (s.index==2 || s.index==3) // Not Ready
|
---|
2976 | SetLedColor(fStatusDriveLed, kLedGreenBar, time);
|
---|
2977 | if (s.index==4 || s.index==5) // Connected / Armed
|
---|
2978 | SetLedColor(fStatusDriveLed, kLedGreen, time);
|
---|
2979 | if (s.index==6) // Moving
|
---|
2980 | SetLedColor(fStatusDriveLed, kLedInProgress, time);
|
---|
2981 | if (s.index==7) // Tracking
|
---|
2982 | SetLedColor(fStatusDriveLed, kLedGreenCheck, time);
|
---|
2983 | if (s.index==99) // Error
|
---|
2984 | SetLedColor(fStatusDriveLed, kLedGreenWarn, time);
|
---|
2985 | }
|
---|
2986 |
|
---|
2987 | if (server=="BIAS_CONTROL")
|
---|
2988 | {
|
---|
2989 | fStatusBiasLabel->setText(s.name.c_str());
|
---|
2990 | fStatusBiasLabel->setToolTip(s.comment.c_str());
|
---|
2991 |
|
---|
2992 | if (s.index<1) // No Dim connection
|
---|
2993 | SetLedColor(fStatusBiasLed, kLedGray, time);
|
---|
2994 | if (s.index==BIAS::kDisconnected) // Dim connection / FTM disconnected
|
---|
2995 | SetLedColor(fStatusBiasLed, kLedRed, time);
|
---|
2996 | if (s.index==BIAS::kConnecting || s.index==BIAS::kInitializing) // Connecting / Initializing
|
---|
2997 | SetLedColor(fStatusBiasLed, kLedOrange, time);
|
---|
2998 | if (s.index==BIAS::kVoltageOff) // At reference
|
---|
2999 | SetLedColor(fStatusBiasLed, kLedGreenBar, time);
|
---|
3000 | if (s.index==BIAS::kNotReferenced) // At reference
|
---|
3001 | SetLedColor(fStatusBiasLed, kLedGreenWarn, time);
|
---|
3002 | if (s.index==BIAS::kRamping) // Ramping
|
---|
3003 | SetLedColor(fStatusBiasLed, kLedInProgress, time);
|
---|
3004 | if (s.index==BIAS::kVoltageOn) // At reference
|
---|
3005 | SetLedColor(fStatusBiasLed, kLedGreenCheck, time);
|
---|
3006 | if (s.index==BIAS::kOverCurrent) // Over current
|
---|
3007 | SetLedColor(fStatusBiasLed, kLedWarnBorder, time);
|
---|
3008 | if (s.index==BIAS::kExpertMode) // ExpertMode
|
---|
3009 | SetLedColor(fStatusBiasLed, kLedWarnTriangleBorder, time);
|
---|
3010 |
|
---|
3011 | fBiasWidget->setEnabled(s.index>=3);
|
---|
3012 | }
|
---|
3013 |
|
---|
3014 | if (server=="FEEDBACK")
|
---|
3015 | {
|
---|
3016 | fStatusFeedbackLabel->setText(s.name.c_str());
|
---|
3017 | fStatusFeedbackLabel->setToolTip(s.comment.c_str());
|
---|
3018 |
|
---|
3019 | if (s.index>6) // Running
|
---|
3020 | SetLedColor(fStatusFeedbackLed, kLedGreenCheck, time);
|
---|
3021 | if (s.index==5 || s.index==6) // Idle
|
---|
3022 | SetLedColor(fStatusFeedbackLed, kLedGreen, time);
|
---|
3023 | if (s.index==4) // Connected
|
---|
3024 | SetLedColor(fStatusFeedbackLed, kLedYellow, time);
|
---|
3025 | if (s.index==3) // Connecting
|
---|
3026 | SetLedColor(fStatusFeedbackLed, kLedOrange, time);
|
---|
3027 | if (s.index<3) // NoDim / Disconnected
|
---|
3028 | SetLedColor(fStatusFeedbackLed, kLedRed, time);
|
---|
3029 | if (s.index<1) // No Dim connection
|
---|
3030 | SetLedColor(fStatusFeedbackLed, kLedGray, time);
|
---|
3031 |
|
---|
3032 | fFeedbackWidget->setEnabled(s.index>=3);
|
---|
3033 | fFeedbackCalibrate->setEnabled(s.index==4);
|
---|
3034 | fFeedbackStop->setEnabled(s.index>4);
|
---|
3035 | fFeedbackTempStart->setEnabled(s.index==4);
|
---|
3036 | fFeedbackTempOffset->setEnabled(s.index<=4);
|
---|
3037 | fFeedbackOutputEnable->setEnabled(s.index<=6);
|
---|
3038 | fFeedbackOutputDisable->setEnabled(s.index!=5 && s.index!=6);
|
---|
3039 |
|
---|
3040 | fFeedbackFrameLeft->setEnabled(s.index!=5 && s.index!=7);
|
---|
3041 | fFeedbackCanvLeft->setEnabled(s.index!=5 && s.index!=7);
|
---|
3042 | }
|
---|
3043 |
|
---|
3044 | if (server=="RATE_CONTROL")
|
---|
3045 | {
|
---|
3046 | fStatusRateControlLabel->setText(s.name.c_str());
|
---|
3047 | fStatusRateControlLabel->setToolTip(s.comment.c_str());
|
---|
3048 |
|
---|
3049 | if (s.index==7) // InProgress
|
---|
3050 | SetLedColor(fStatusRateControlLed, kLedGreenCheck, time);
|
---|
3051 | if (s.index==6) // GlobalThresholdSet
|
---|
3052 | SetLedColor(fStatusRateControlLed, kLedGreen, time);
|
---|
3053 | if (s.index==5) // SettingGlobalThreshold
|
---|
3054 | SetLedColor(fStatusRateControlLed, kLedInProgress, time);
|
---|
3055 | if (s.index==4) // Connected
|
---|
3056 | SetLedColor(fStatusRateControlLed, kLedGreenBar, time);
|
---|
3057 | if (s.index==3) // Connecting
|
---|
3058 | SetLedColor(fStatusRateControlLed, kLedOrange, time);
|
---|
3059 | if (s.index<3) // NoDim / Disconnected
|
---|
3060 | SetLedColor(fStatusRateControlLed, kLedRed, time);
|
---|
3061 | if (s.index<1) // No Dim connection
|
---|
3062 | SetLedColor(fStatusRateControlLed, kLedGray, time);
|
---|
3063 | }
|
---|
3064 |
|
---|
3065 | if (server=="DATA_LOGGER")
|
---|
3066 | {
|
---|
3067 | fStatusLoggerLabel->setText(s.name.c_str());
|
---|
3068 | fStatusLoggerLabel->setToolTip(s.comment.c_str());
|
---|
3069 |
|
---|
3070 | bool enable = true;
|
---|
3071 |
|
---|
3072 | if (s.index<30) // Ready/Waiting
|
---|
3073 | SetLedColor(fStatusLoggerLed, kLedYellow, time);
|
---|
3074 | if (s.index==30) // Ready/Waiting
|
---|
3075 | SetLedColor(fStatusLoggerLed, kLedGreen, time);
|
---|
3076 | if (s.index<-1) // Offline
|
---|
3077 | {
|
---|
3078 | SetLedColor(fStatusLoggerLed, kLedGray, time);
|
---|
3079 | enable = false;
|
---|
3080 | }
|
---|
3081 | if (s.index>=0x100) // Error
|
---|
3082 | SetLedColor(fStatusLoggerLed, kLedRed, time);
|
---|
3083 | if (s.index==40) // Logging
|
---|
3084 | SetLedColor(fStatusLoggerLed, kLedGreen, time);
|
---|
3085 |
|
---|
3086 | fLoggerWidget->setEnabled(enable);
|
---|
3087 | fLoggerStart->setEnabled(s.index>-1 && s.index<30);
|
---|
3088 | fLoggerStop->setEnabled(s.index>=30);
|
---|
3089 | }
|
---|
3090 |
|
---|
3091 | if (server=="CHAT")
|
---|
3092 | {
|
---|
3093 | fStatusChatLabel->setText(s.name.c_str());
|
---|
3094 |
|
---|
3095 | fChatOnline = s.index==0;
|
---|
3096 |
|
---|
3097 | SetLedColor(fStatusChatLed, fChatOnline ? kLedGreen : kLedGray, time);
|
---|
3098 |
|
---|
3099 | fChatSend->setEnabled(fChatOnline);
|
---|
3100 | fChatMessage->setEnabled(fChatOnline);
|
---|
3101 | }
|
---|
3102 |
|
---|
3103 | if (server=="RATESCAN")
|
---|
3104 | fRateScanControls->setEnabled(s.index>=4);
|
---|
3105 |
|
---|
3106 | if (server=="SCHEDULER")
|
---|
3107 | {
|
---|
3108 | fStatusSchedulerLabel->setText(s.name.c_str());
|
---|
3109 |
|
---|
3110 | SetLedColor(fStatusSchedulerLed, s.index>=0 ? kLedGreen : kLedRed, time);
|
---|
3111 | }
|
---|
3112 | }
|
---|
3113 |
|
---|
3114 | void on_fTabWidget_currentChanged(int which)
|
---|
3115 | {
|
---|
3116 | if (fTabWidget->tabText(which)=="Chat")
|
---|
3117 | fTabWidget->setTabIcon(which, QIcon());
|
---|
3118 | }
|
---|
3119 |
|
---|
3120 | void handleWrite(const Time &time, const string &text, int qos)
|
---|
3121 | {
|
---|
3122 | stringstream out;
|
---|
3123 |
|
---|
3124 | if (text.substr(0, 6)=="CHAT: ")
|
---|
3125 | {
|
---|
3126 | if (qos==MessageImp::kDebug)
|
---|
3127 | return;
|
---|
3128 |
|
---|
3129 | out << "<font size='-1' color='navy'>[<B>";
|
---|
3130 | out << time.GetAsStr("%H:%M:%S");
|
---|
3131 | out << "</B>]</FONT> " << text.substr(6);
|
---|
3132 | fChatText->append(out.str().c_str());
|
---|
3133 |
|
---|
3134 | if (fTabWidget->tabText(fTabWidget->currentIndex())=="Chat")
|
---|
3135 | return;
|
---|
3136 |
|
---|
3137 | static int num = 0;
|
---|
3138 | if (num++<2)
|
---|
3139 | return;
|
---|
3140 |
|
---|
3141 | for (int i=0; i<fTabWidget->count(); i++)
|
---|
3142 | if (fTabWidget->tabText(i)=="Chat")
|
---|
3143 | {
|
---|
3144 | fTabWidget->setTabIcon(i, QIcon(":/Resources/icons/warning 3.png"));
|
---|
3145 | break;
|
---|
3146 | }
|
---|
3147 |
|
---|
3148 | return;
|
---|
3149 | }
|
---|
3150 |
|
---|
3151 |
|
---|
3152 | out << "<font style='font-family:monospace' color='";
|
---|
3153 |
|
---|
3154 | switch (qos)
|
---|
3155 | {
|
---|
3156 | case kMessage: out << "black"; break;
|
---|
3157 | case kInfo: out << "green"; break;
|
---|
3158 | case kWarn: out << "#FF6600"; break;
|
---|
3159 | case kError: out << "maroon"; break;
|
---|
3160 | case kFatal: out << "maroon"; break;
|
---|
3161 | case kDebug: out << "navy"; break;
|
---|
3162 | default: out << "navy"; break;
|
---|
3163 | }
|
---|
3164 | out << "'>";
|
---|
3165 | out << time.GetAsStr("%H:%M:%S.%f").substr(0,12);
|
---|
3166 | out << " - " << text << "</font>";
|
---|
3167 |
|
---|
3168 | fLogText->append(out.str().c_str());
|
---|
3169 |
|
---|
3170 | if (qos>=kWarn && qos!=kDebug)
|
---|
3171 | fTextEdit->append(out.str().c_str());
|
---|
3172 | }
|
---|
3173 |
|
---|
3174 | void IndicateStateChange(const Time &time, const std::string &server)
|
---|
3175 | {
|
---|
3176 | const State s = GetState(server, GetCurrentState(server));
|
---|
3177 |
|
---|
3178 | QApplication::postEvent(this,
|
---|
3179 | new FunctionEvent(boost::bind(&FactGui::handleStateChanged, this, time, server, s)));
|
---|
3180 | }
|
---|
3181 |
|
---|
3182 | int Write(const Time &time, const string &txt, int qos)
|
---|
3183 | {
|
---|
3184 | QApplication::postEvent(this,
|
---|
3185 | new FunctionEvent(boost::bind(&FactGui::handleWrite, this, time, txt, qos)));
|
---|
3186 |
|
---|
3187 | return 0;
|
---|
3188 | }
|
---|
3189 |
|
---|
3190 | // ====================== Dim infoHandler================================
|
---|
3191 |
|
---|
3192 | void handleDimService(const string &txt)
|
---|
3193 | {
|
---|
3194 | fDimSvcText->append(txt.c_str());
|
---|
3195 | }
|
---|
3196 |
|
---|
3197 | void infoHandlerService(DimInfo &info)
|
---|
3198 | {
|
---|
3199 | const string fmt = string(info.getFormat()).empty() ? "C" : info.getFormat();
|
---|
3200 |
|
---|
3201 | stringstream dummy;
|
---|
3202 | const Converter conv(dummy, fmt, false);
|
---|
3203 |
|
---|
3204 | const Time tm(info.getTimestamp(), info.getTimestampMillisecs()*1000);
|
---|
3205 |
|
---|
3206 | stringstream out;
|
---|
3207 | out << "<font size'-1' color='navy'>[";
|
---|
3208 | out << tm.GetAsStr("%H:%M:%S.%f").substr(0,12);
|
---|
3209 | out << "]</font> <B>" << info.getName() << "</B> - ";
|
---|
3210 |
|
---|
3211 | bool iserr = 2;
|
---|
3212 | if (!conv)
|
---|
3213 | {
|
---|
3214 | out << "Compilation of format string '" << fmt << "' failed!";
|
---|
3215 | }
|
---|
3216 | else
|
---|
3217 | {
|
---|
3218 | try
|
---|
3219 | {
|
---|
3220 | const string dat = info.getSize()==0 ? "<empty>" : conv.GetString(info.getData(), info.getSize());
|
---|
3221 | out << dat;
|
---|
3222 | iserr = info.getSize()==0;
|
---|
3223 | }
|
---|
3224 | catch (const runtime_error &e)
|
---|
3225 | {
|
---|
3226 | out << "Conversion to string failed!<pre>" << e.what() << "</pre>";
|
---|
3227 | }
|
---|
3228 | }
|
---|
3229 |
|
---|
3230 | // srand(hash<string>()(string(info.getName())));
|
---|
3231 | // int bg = rand()&0xffffff;
|
---|
3232 |
|
---|
3233 | int bg = hash<string>()(string(info.getName()));
|
---|
3234 |
|
---|
3235 | // allow only light colors
|
---|
3236 | bg = ~(bg&0x1f1f1f)&0xffffff;
|
---|
3237 |
|
---|
3238 | if (iserr==2)
|
---|
3239 | bg = 0xffffff;
|
---|
3240 |
|
---|
3241 | stringstream bgcol;
|
---|
3242 | bgcol << hex << setfill('0') << setw(6) << bg;
|
---|
3243 |
|
---|
3244 | const string col = iserr==0 ? "black" : (iserr==1 ? "#FF6600" : "black");
|
---|
3245 | const string str = "<table width='100%' bgcolor=#"+bgcol.str()+"><tr><td><font color='"+col+"'>"+out.str()+"</font></td></tr></table>";
|
---|
3246 |
|
---|
3247 | QApplication::postEvent(this,
|
---|
3248 | new FunctionEvent(boost::bind(&FactGui::handleDimService, this, str)));
|
---|
3249 | }
|
---|
3250 |
|
---|
3251 | void CallInfoHandler(void (FactGui::*handler)(const DimData&), const DimData &d)
|
---|
3252 | {
|
---|
3253 | fInHandler = true;
|
---|
3254 | (this->*handler)(d);
|
---|
3255 | fInHandler = false;
|
---|
3256 | }
|
---|
3257 |
|
---|
3258 | /*
|
---|
3259 | void CallInfoHandler(const boost::function<void()> &func)
|
---|
3260 | {
|
---|
3261 | // This ensures that newly received values are not sent back to the emitter
|
---|
3262 | // because changing the value emits the valueChanged signal (or similar)
|
---|
3263 | fInHandler = true;
|
---|
3264 | func();
|
---|
3265 | fInHandler = false;
|
---|
3266 | }*/
|
---|
3267 |
|
---|
3268 | void PostInfoHandler(void (FactGui::*handler)(const DimData&))
|
---|
3269 | {
|
---|
3270 | //const boost::function<void()> f = boost::bind(handler, this, DimData(getInfo()));
|
---|
3271 |
|
---|
3272 | FunctionEvent *evt = new FunctionEvent(boost::bind(&FactGui::CallInfoHandler, this, handler, DimData(getInfo())));
|
---|
3273 | // FunctionEvent *evt = new FunctionEvent(boost::bind(&FactGui::CallInfoHandler, this, f));
|
---|
3274 | // FunctionEvent *evt = new FunctionEvent(boost::bind(handler, this, DimData(getInfo()))));
|
---|
3275 |
|
---|
3276 | QApplication::postEvent(this, evt);
|
---|
3277 | }
|
---|
3278 |
|
---|
3279 | void infoHandler()
|
---|
3280 | {
|
---|
3281 | // Initialize the time-stamp (what a weird workaround...)
|
---|
3282 | if (getInfo())
|
---|
3283 | getInfo()->getTimestamp();
|
---|
3284 |
|
---|
3285 | if (getInfo()==&fDimDNS)
|
---|
3286 | return PostInfoHandler(&FactGui::handleDimDNS);
|
---|
3287 | #ifdef DEBUG_DIM
|
---|
3288 | cout << "HandleDimInfo " << getInfo()->getName() << endl;
|
---|
3289 | #endif
|
---|
3290 | if (getInfo()==&fDimLoggerStats)
|
---|
3291 | return PostInfoHandler(&FactGui::handleLoggerStats);
|
---|
3292 |
|
---|
3293 | // if (getInfo()==&fDimFadFiles)
|
---|
3294 | // return PostInfoHandler(&FactGui::handleFadFiles);
|
---|
3295 |
|
---|
3296 | if (getInfo()==&fDimFadWriteStats)
|
---|
3297 | return PostInfoHandler(&FactGui::handleFadWriteStats);
|
---|
3298 |
|
---|
3299 | if (getInfo()==&fDimFadConnections)
|
---|
3300 | return PostInfoHandler(&FactGui::handleFadConnections);
|
---|
3301 |
|
---|
3302 | if (getInfo()==&fDimFadFwVersion)
|
---|
3303 | return PostInfoHandler(&FactGui::handleFadFwVersion);
|
---|
3304 |
|
---|
3305 | if (getInfo()==&fDimFadRunNumber)
|
---|
3306 | return PostInfoHandler(&FactGui::handleFadRunNumber);
|
---|
3307 |
|
---|
3308 | if (getInfo()==&fDimFadDNA)
|
---|
3309 | return PostInfoHandler(&FactGui::handleFadDNA);
|
---|
3310 |
|
---|
3311 | if (getInfo()==&fDimFadTemperature)
|
---|
3312 | return PostInfoHandler(&FactGui::handleFadTemperature);
|
---|
3313 |
|
---|
3314 | if (getInfo()==&fDimFadRefClock)
|
---|
3315 | return PostInfoHandler(&FactGui::handleFadRefClock);
|
---|
3316 |
|
---|
3317 | if (getInfo()==&fDimFadRoi)
|
---|
3318 | return PostInfoHandler(&FactGui::handleFadRoi);
|
---|
3319 |
|
---|
3320 | if (getInfo()==&fDimFadDac)
|
---|
3321 | return PostInfoHandler(&FactGui::handleFadDac);
|
---|
3322 |
|
---|
3323 | if (getInfo()==&fDimFadDrsCalibration)
|
---|
3324 | return PostInfoHandler(&FactGui::handleFadDrsCalibration);
|
---|
3325 |
|
---|
3326 | if (getInfo()==&fDimFadPrescaler)
|
---|
3327 | return PostInfoHandler(&FactGui::handleFadPrescaler);
|
---|
3328 |
|
---|
3329 | if (getInfo()==&fDimFadStatus)
|
---|
3330 | return PostInfoHandler(&FactGui::handleFadStatus);
|
---|
3331 |
|
---|
3332 | if (getInfo()==&fDimFadStatistics1)
|
---|
3333 | return PostInfoHandler(&FactGui::handleFadStatistics1);
|
---|
3334 |
|
---|
3335 | if (getInfo()==&fDimFadStatistics2)
|
---|
3336 | return PostInfoHandler(&FactGui::handleFadStatistics2);
|
---|
3337 |
|
---|
3338 | if (getInfo()==&fDimFadFileFormat)
|
---|
3339 | return PostInfoHandler(&FactGui::handleFadFileFormat);
|
---|
3340 |
|
---|
3341 | if (getInfo()==&fDimFadEvents)
|
---|
3342 | return PostInfoHandler(&FactGui::handleFadEvents);
|
---|
3343 |
|
---|
3344 | if (getInfo()==&fDimFadRuns)
|
---|
3345 | return PostInfoHandler(&FactGui::handleFadRuns);
|
---|
3346 |
|
---|
3347 | if (getInfo()==&fDimFadStartRun)
|
---|
3348 | return PostInfoHandler(&FactGui::handleFadStartRun);
|
---|
3349 |
|
---|
3350 | if (getInfo()==&fDimFadRawData)
|
---|
3351 | return PostInfoHandler(&FactGui::handleFadRawData);
|
---|
3352 |
|
---|
3353 | if (getInfo()==&fDimFadEventData)
|
---|
3354 | return PostInfoHandler(&FactGui::handleFadEventData);
|
---|
3355 |
|
---|
3356 | /*
|
---|
3357 | if (getInfo()==&fDimFadSetup)
|
---|
3358 | return PostInfoHandler(&FactGui::handleFadSetup);
|
---|
3359 | */
|
---|
3360 | if (getInfo()==&fDimLoggerFilenameNight)
|
---|
3361 | return PostInfoHandler(&FactGui::handleLoggerFilenameNight);
|
---|
3362 |
|
---|
3363 | if (getInfo()==&fDimLoggerNumSubs)
|
---|
3364 | return PostInfoHandler(&FactGui::handleLoggerNumSubs);
|
---|
3365 |
|
---|
3366 | if (getInfo()==&fDimLoggerFilenameRun)
|
---|
3367 | return PostInfoHandler(&FactGui::handleLoggerFilenameRun);
|
---|
3368 |
|
---|
3369 | if (getInfo()==&fDimFtmTriggerRates)
|
---|
3370 | return PostInfoHandler(&FactGui::handleFtmTriggerRates);
|
---|
3371 |
|
---|
3372 | if (getInfo()==&fDimFtmCounter)
|
---|
3373 | return PostInfoHandler(&FactGui::handleFtmCounter);
|
---|
3374 |
|
---|
3375 | if (getInfo()==&fDimFtmDynamicData)
|
---|
3376 | return PostInfoHandler(&FactGui::handleFtmDynamicData);
|
---|
3377 |
|
---|
3378 | if (getInfo()==&fDimFtmPassport)
|
---|
3379 | return PostInfoHandler(&FactGui::handleFtmPassport);
|
---|
3380 |
|
---|
3381 | if (getInfo()==&fDimFtmFtuList)
|
---|
3382 | return PostInfoHandler(&FactGui::handleFtmFtuList);
|
---|
3383 |
|
---|
3384 | if (getInfo()==&fDimFtmStaticData)
|
---|
3385 | return PostInfoHandler(&FactGui::handleFtmStaticData);
|
---|
3386 |
|
---|
3387 | if (getInfo()==&fDimFtmError)
|
---|
3388 | return PostInfoHandler(&FactGui::handleFtmError);
|
---|
3389 |
|
---|
3390 | if (getInfo()==&fDimFscTemp)
|
---|
3391 | return PostInfoHandler(&FactGui::handleFscTemp);
|
---|
3392 |
|
---|
3393 | if (getInfo()==&fDimFscVolt)
|
---|
3394 | return PostInfoHandler(&FactGui::handleFscVolt);
|
---|
3395 |
|
---|
3396 | if (getInfo()==&fDimFscCurrent)
|
---|
3397 | return PostInfoHandler(&FactGui::handleFscCurrent);
|
---|
3398 |
|
---|
3399 | if (getInfo()==&fDimFscHumidity)
|
---|
3400 | return PostInfoHandler(&FactGui::handleFscHumidity);
|
---|
3401 |
|
---|
3402 | if (getInfo()==&fDimBiasVolt)
|
---|
3403 | return PostInfoHandler(&FactGui::handleBiasVolt);
|
---|
3404 |
|
---|
3405 | if (getInfo()==&fDimBiasCurrent)
|
---|
3406 | return PostInfoHandler(&FactGui::handleBiasCurrent);
|
---|
3407 |
|
---|
3408 | if (getInfo()==&fDimFeedbackReference)
|
---|
3409 | return PostInfoHandler(&FactGui::handleFeedbackReference);
|
---|
3410 |
|
---|
3411 | if (getInfo()==&fDimFeedbackDeviation)
|
---|
3412 | return PostInfoHandler(&FactGui::handleFeedbackDeviation);
|
---|
3413 |
|
---|
3414 | if (getInfo()==&fDimFeedbackCalibration)
|
---|
3415 | return PostInfoHandler(&FactGui::handleFeedbackCalibration);
|
---|
3416 |
|
---|
3417 | if (getInfo()==&fDimRateScan)
|
---|
3418 | return PostInfoHandler(&FactGui::handleRateScan);
|
---|
3419 |
|
---|
3420 | // if (getInfo()==&fDimFadFiles)
|
---|
3421 | // return PostInfoHandler(&FactGui::handleFadFiles);
|
---|
3422 |
|
---|
3423 | for (map<string,DimInfo*>::iterator i=fServices.begin(); i!=fServices.end(); i++)
|
---|
3424 | if (i->second==getInfo())
|
---|
3425 | {
|
---|
3426 | infoHandlerService(*i->second);
|
---|
3427 | return;
|
---|
3428 | }
|
---|
3429 |
|
---|
3430 | DimNetwork::infoHandler();
|
---|
3431 | }
|
---|
3432 |
|
---|
3433 |
|
---|
3434 | // ======================================================================
|
---|
3435 |
|
---|
3436 | bool event(QEvent *evt)
|
---|
3437 | {
|
---|
3438 | if (dynamic_cast<FunctionEvent*>(evt))
|
---|
3439 | return static_cast<FunctionEvent*>(evt)->Exec();
|
---|
3440 |
|
---|
3441 | if (dynamic_cast<CheckBoxEvent*>(evt))
|
---|
3442 | {
|
---|
3443 | const QStandardItem &item = static_cast<CheckBoxEvent*>(evt)->item;
|
---|
3444 | const QStandardItem *par = item.parent();
|
---|
3445 | if (par)
|
---|
3446 | {
|
---|
3447 | const QString server = par->text();
|
---|
3448 | const QString service = item.text();
|
---|
3449 |
|
---|
3450 | const string s = (server+'/'+service).toStdString();
|
---|
3451 |
|
---|
3452 | if (item.checkState()==Qt::Checked)
|
---|
3453 | SubscribeService(s);
|
---|
3454 | else
|
---|
3455 | UnsubscribeService(s);
|
---|
3456 | }
|
---|
3457 | }
|
---|
3458 |
|
---|
3459 | return MainWindow::event(evt); // unrecognized
|
---|
3460 | }
|
---|
3461 |
|
---|
3462 | void on_fDimCmdSend_clicked()
|
---|
3463 | {
|
---|
3464 | const QString server = fDimCmdServers->currentIndex().data().toString();
|
---|
3465 | const QString command = fDimCmdCommands->currentIndex().data().toString();
|
---|
3466 | const QString arguments = fDimCmdLineEdit->displayText();
|
---|
3467 |
|
---|
3468 | // FIXME: Sending a command exactly when the info Handler changes
|
---|
3469 | // the list it might lead to confusion.
|
---|
3470 | try
|
---|
3471 | {
|
---|
3472 | SendDimCommand(server.toStdString(), command.toStdString()+" "+arguments.toStdString());
|
---|
3473 | fTextEdit->append("<font color='green'>Command '"+server+'/'+command+"' successfully emitted.</font>");
|
---|
3474 | fDimCmdLineEdit->clear();
|
---|
3475 | }
|
---|
3476 | catch (const runtime_error &e)
|
---|
3477 | {
|
---|
3478 | stringstream txt;
|
---|
3479 | txt << e.what();
|
---|
3480 |
|
---|
3481 | string buffer;
|
---|
3482 | while (getline(txt, buffer, '\n'))
|
---|
3483 | fTextEdit->append(("<font color='red'><pre>"+buffer+"</pre></font>").c_str());
|
---|
3484 | }
|
---|
3485 | }
|
---|
3486 |
|
---|
3487 | #ifdef HAVE_ROOT
|
---|
3488 | void slot_RootEventProcessed(TObject *obj, unsigned int evt, TCanvas *canv)
|
---|
3489 | {
|
---|
3490 | // kMousePressEvent // TCanvas processed QEvent mousePressEvent
|
---|
3491 | // kMouseMoveEvent // TCanvas processed QEvent mouseMoveEvent
|
---|
3492 | // kMouseReleaseEvent // TCanvas processed QEvent mouseReleaseEvent
|
---|
3493 | // kMouseDoubleClickEvent // TCanvas processed QEvent mouseDoubleClickEvent
|
---|
3494 | // kKeyPressEvent // TCanvas processed QEvent keyPressEvent
|
---|
3495 | // kEnterEvent // TCanvas processed QEvent enterEvent
|
---|
3496 | // kLeaveEvent // TCanvas processed QEvent leaveEvent
|
---|
3497 |
|
---|
3498 | if (dynamic_cast<TCanvas*>(obj))
|
---|
3499 | return;
|
---|
3500 |
|
---|
3501 | TQtWidget *tipped = static_cast<TQtWidget*>(sender());
|
---|
3502 |
|
---|
3503 | if (evt==11/*kMouseReleaseEvent*/)
|
---|
3504 | return;
|
---|
3505 |
|
---|
3506 | if (evt==61/*kMouseDoubleClickEvent*/)
|
---|
3507 | return;
|
---|
3508 |
|
---|
3509 | if (obj)
|
---|
3510 | {
|
---|
3511 | // Find the object which will get picked by the GetObjectInfo
|
---|
3512 | // due to buffer overflows in many root-versions
|
---|
3513 | // in TH1 and TProfile we have to work around and implement
|
---|
3514 | // our own GetObjectInfo which make everything a bit more
|
---|
3515 | // complicated.
|
---|
3516 | canv->cd();
|
---|
3517 | #if ROOT_VERSION_CODE > ROOT_VERSION(5,22,00)
|
---|
3518 | const char *objectInfo =
|
---|
3519 | obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());
|
---|
3520 | #else
|
---|
3521 | const char *objectInfo = dynamic_cast<TH1*>(obj) ?
|
---|
3522 | "" : obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());
|
---|
3523 | #endif
|
---|
3524 |
|
---|
3525 | QString tipText;
|
---|
3526 | tipText += obj->GetName();
|
---|
3527 | tipText += " [";
|
---|
3528 | tipText += obj->ClassName();
|
---|
3529 | tipText += "]: ";
|
---|
3530 | tipText += objectInfo;
|
---|
3531 |
|
---|
3532 | fStatusBar->showMessage(tipText, 3000);
|
---|
3533 | }
|
---|
3534 |
|
---|
3535 | gSystem->DispatchOneEvent(kFALSE);
|
---|
3536 | //gSystem->ProcessEvents();
|
---|
3537 | //QWhatsThis::display(tipText)
|
---|
3538 | }
|
---|
3539 |
|
---|
3540 | void slot_RootUpdate()
|
---|
3541 | {
|
---|
3542 | gSystem->DispatchOneEvent(kFALSE);
|
---|
3543 | //gSystem->ProcessEvents();
|
---|
3544 | QTimer::singleShot(10, this, SLOT(slot_RootUpdate()));
|
---|
3545 | }
|
---|
3546 | #endif
|
---|
3547 |
|
---|
3548 | void ChoosePatchThreshold(Camera &cam, int isw)
|
---|
3549 | {
|
---|
3550 | cam.Reset();
|
---|
3551 |
|
---|
3552 | fThresholdIdx->setValue(isw);
|
---|
3553 |
|
---|
3554 | const int ihw = isw<0 ? 0 : fPatchMapHW[isw];
|
---|
3555 |
|
---|
3556 | fPatchRate->setEnabled(isw>=0);
|
---|
3557 | fThresholdCrate->setEnabled(isw>=0);
|
---|
3558 | fThresholdBoard->setEnabled(isw>=0);
|
---|
3559 | fThresholdPatch->setEnabled(isw>=0);
|
---|
3560 |
|
---|
3561 | if (isw<0)
|
---|
3562 | return;
|
---|
3563 |
|
---|
3564 | const int patch = ihw%4;
|
---|
3565 | const int board = (ihw/4)%10;
|
---|
3566 | const int crate = (ihw/4)/10;
|
---|
3567 |
|
---|
3568 | fInChoosePatchTH = true;
|
---|
3569 |
|
---|
3570 | fThresholdCrate->setValue(crate);
|
---|
3571 | fThresholdBoard->setValue(board);
|
---|
3572 | fThresholdPatch->setValue(patch);
|
---|
3573 |
|
---|
3574 | fInChoosePatchTH = false;
|
---|
3575 |
|
---|
3576 | fThresholdVal->setValue(fFtmStaticData.fThreshold[ihw]);
|
---|
3577 | fPatchRate->setValue(fTriggerRates.fPatchRate[ihw]);
|
---|
3578 | fBoardRate->setValue(fTriggerRates.fBoardRate[ihw/4]);
|
---|
3579 |
|
---|
3580 | // Loop over the software idx of all pixels
|
---|
3581 | // for (unsigned int i=0; i<1440; i++)
|
---|
3582 | // if (fPatchHW[i]==ihw)
|
---|
3583 | // cam.SetBold(i);
|
---|
3584 | }
|
---|
3585 |
|
---|
3586 | /*
|
---|
3587 | void ChoosePatchBias(Camera &cam, int isw)
|
---|
3588 | {
|
---|
3589 | cam.Reset();
|
---|
3590 |
|
---|
3591 | fBiasChannel->setValue(isw);
|
---|
3592 |
|
---|
3593 | const int ihw = isw<0 ? 0 : fPatchMapHW[isw];
|
---|
3594 |
|
---|
3595 | fBiasCurrent->setEnabled(isw>=0);
|
---|
3596 | fBiasCrate->setEnabled(isw>=0);
|
---|
3597 | fBiasBoard->setEnabled(isw>=0);
|
---|
3598 | fBiasPatch->setEnabled(isw>=0);
|
---|
3599 |
|
---|
3600 | if (isw<0)
|
---|
3601 | return;
|
---|
3602 |
|
---|
3603 | const int patch = ihw%4;
|
---|
3604 | const int board = (ihw/4)%10;
|
---|
3605 | const int crate = (ihw/4)/10;
|
---|
3606 |
|
---|
3607 | fInChoosePatchBias = true;
|
---|
3608 |
|
---|
3609 | fBiasCrate->setValue(crate);
|
---|
3610 | fBiasBoard->setValue(board);
|
---|
3611 | fBiasPatch->setValue(patch);
|
---|
3612 |
|
---|
3613 | fInChoosePatchBias = false;
|
---|
3614 |
|
---|
3615 | if (fVecBias.size()>0)
|
---|
3616 | {
|
---|
3617 | // FIXME: Mapping
|
---|
3618 | fBiasVoltDac->setValue(fVecBias[ihw]);
|
---|
3619 | fBiasVolt->setValue(fVecBias[ihw]*90./4096);
|
---|
3620 | }
|
---|
3621 |
|
---|
3622 | fBiasCurrent->setValue(cam.GetData(isw));
|
---|
3623 |
|
---|
3624 | // Loop over the software idx of all pixels
|
---|
3625 | for (unsigned int i=0; i<1440; i++)
|
---|
3626 | if (fPatchHW[i]==ihw)
|
---|
3627 | cam.SetBold(i);
|
---|
3628 | }*/
|
---|
3629 |
|
---|
3630 | void slot_ChoosePixelThreshold(int isw)
|
---|
3631 | {
|
---|
3632 | fPixelIdx->setValue(isw);
|
---|
3633 |
|
---|
3634 | const PixelMapEntry &entry = fPixelMap.index(isw);
|
---|
3635 | fPixelEnable->setChecked(fFtmStaticData.IsEnabled(entry.hw()));
|
---|
3636 | }
|
---|
3637 |
|
---|
3638 | void slot_CameraDoubleClick(int isw)
|
---|
3639 | {
|
---|
3640 | fPixelIdx->setValue(isw);
|
---|
3641 |
|
---|
3642 | const PixelMapEntry &entry = fPixelMap.index(isw);
|
---|
3643 | Dim::SendCommand("FTM_CONTROL/TOGGLE_PIXEL", uint16_t(entry.hw()));
|
---|
3644 | }
|
---|
3645 |
|
---|
3646 | void slot_CameraMouseMove(int isw)
|
---|
3647 | {
|
---|
3648 | const PixelMapEntry &entry = fPixelMap.index(isw);
|
---|
3649 |
|
---|
3650 | QString tipText;
|
---|
3651 | tipText += fRatesCanv->GetName();
|
---|
3652 | ostringstream str;
|
---|
3653 | str << setfill('0') <<
|
---|
3654 | " || HW: " << entry.crate() << "|" << entry.board() << "|" << entry.patch() << "|" << entry.pixel() << " (crate|board|patch|pixel)" <<
|
---|
3655 | " || HV: " << entry.hv_board << "|" << setw(2) << entry.hv_channel << " (board|channel)" <<
|
---|
3656 | " || ID: " << isw;
|
---|
3657 |
|
---|
3658 |
|
---|
3659 | tipText += str.str().c_str();
|
---|
3660 | fStatusBar->showMessage(tipText, 3000);
|
---|
3661 | }
|
---|
3662 |
|
---|
3663 | /*
|
---|
3664 | void on_fThresholdIdx_valueChanged(int isw)
|
---|
3665 | {
|
---|
3666 | // fRatesCanv->SetBold(isw);
|
---|
3667 | // fRatesCanv->updateGL();
|
---|
3668 | }*/
|
---|
3669 |
|
---|
3670 | /*
|
---|
3671 | void UpdateThresholdIdx()
|
---|
3672 | {
|
---|
3673 | if (fInChoosePatchTH)
|
---|
3674 | return;
|
---|
3675 |
|
---|
3676 | const int crate = fThresholdCrate->value();
|
---|
3677 | const int board = fThresholdBoard->value();
|
---|
3678 | const int patch = fThresholdPatch->value();
|
---|
3679 |
|
---|
3680 | const int ihw = patch + board*4 + crate*40;
|
---|
3681 |
|
---|
3682 | int isw = 0;
|
---|
3683 | for (; isw<160; isw++)
|
---|
3684 | if (ihw==fPatchMapHW[isw])
|
---|
3685 | break;
|
---|
3686 |
|
---|
3687 | on_fThresholdIdx_valueChanged(isw);
|
---|
3688 | }*/
|
---|
3689 |
|
---|
3690 | void on_fPixelIdx_valueChanged(int isw)
|
---|
3691 | {
|
---|
3692 | int ii = 0;
|
---|
3693 | for (; ii<160; ii++)
|
---|
3694 | if (fPixelMap.index(isw).hw()/9==fPatchMapHW[ii])
|
---|
3695 | break;
|
---|
3696 |
|
---|
3697 | fRatesCanv->SetWhite(isw);
|
---|
3698 | ChoosePatchThreshold(*fRatesCanv, ii);
|
---|
3699 |
|
---|
3700 | const PixelMapEntry &entry = fPixelMap.index(isw);
|
---|
3701 | fPixelEnable->setChecked(fFtmStaticData.IsEnabled(entry.hw()));
|
---|
3702 | }
|
---|
3703 |
|
---|
3704 | // ------------------- Bias display ---------------------
|
---|
3705 |
|
---|
3706 | void UpdateBiasValues()
|
---|
3707 | {
|
---|
3708 | const int b = fBiasHvBoard->value();
|
---|
3709 | const int c = fBiasHvChannel->value();
|
---|
3710 |
|
---|
3711 | const int ihw = b*32+c;
|
---|
3712 |
|
---|
3713 | if (fVecBiasVolt.size()>0)
|
---|
3714 | {
|
---|
3715 | fBiasVoltCur->setValue(fVecBiasVolt[ihw]*90./4096);
|
---|
3716 | fBiasVoltRef->setValue(fVecBiasVolt[ihw+416]*90./4096);
|
---|
3717 |
|
---|
3718 | SetLedColor(fBiasNominalLed,
|
---|
3719 | fVecBiasVolt[ihw]==fVecBiasVolt[ihw+416]?kLedGreen:kLedRed, Time());
|
---|
3720 | }
|
---|
3721 |
|
---|
3722 | if (fVecBiasCurrent.size()>0)
|
---|
3723 | {
|
---|
3724 | double val = abs(fVecBiasCurrent[ihw]);
|
---|
3725 | if (fBiasOffsets.size()>0)
|
---|
3726 | val -= fBiasOffsets[ihw];
|
---|
3727 | val *= 5000/4096;
|
---|
3728 |
|
---|
3729 | fBiasCurrent->setValue(val);
|
---|
3730 | SetLedColor(fBiasOverCurrentLed,
|
---|
3731 | fVecBiasCurrent[ihw]<0?kLedRed:kLedGreen, Time());
|
---|
3732 | }
|
---|
3733 |
|
---|
3734 | if (fBiasOffsets.size()>0)
|
---|
3735 | fBiasOffset->setValue(fBiasOffsets[ihw]*5000./4096);
|
---|
3736 | fBiasOffset->setEnabled(fBiasOffsets.size()>0);
|
---|
3737 | }
|
---|
3738 |
|
---|
3739 | void UpdateBiasCam(const PixelMapEntry &entry)
|
---|
3740 | {
|
---|
3741 | fInChooseBiasCam = true;
|
---|
3742 |
|
---|
3743 | fBiasCamCrate->setValue(entry.crate());
|
---|
3744 | fBiasCamBoard->setValue(entry.board());
|
---|
3745 | fBiasCamPatch->setValue(entry.patch());
|
---|
3746 | fBiasCamPixel->setValue(entry.pixel());
|
---|
3747 |
|
---|
3748 | fInChooseBiasCam = false;
|
---|
3749 | }
|
---|
3750 |
|
---|
3751 | void BiasHvChannelChanged()
|
---|
3752 | {
|
---|
3753 | if (fInChooseBiasHv)
|
---|
3754 | return;
|
---|
3755 |
|
---|
3756 | const int b = fBiasHvBoard->value();
|
---|
3757 | const int ch = fBiasHvChannel->value();
|
---|
3758 |
|
---|
3759 | // FIXME: Mark corresponding patch in camera
|
---|
3760 | const PixelMapEntry &entry = fPixelMap.hv(b, ch);
|
---|
3761 | fBiasCamV->SetWhite(entry.index);
|
---|
3762 | fBiasCamA->SetWhite(entry.index);
|
---|
3763 | fBiasCamV->updateCamera();
|
---|
3764 | fBiasCamA->updateCamera();
|
---|
3765 |
|
---|
3766 | UpdateBiasCam(entry);
|
---|
3767 | UpdateBiasValues();
|
---|
3768 | }
|
---|
3769 |
|
---|
3770 | void UpdateBiasHv(const PixelMapEntry &entry)
|
---|
3771 | {
|
---|
3772 | fInChooseBiasHv = true;
|
---|
3773 |
|
---|
3774 | fBiasHvBoard->setValue(entry.hv_board);
|
---|
3775 | fBiasHvChannel->setValue(entry.hv_channel);
|
---|
3776 |
|
---|
3777 | fInChooseBiasHv = false;
|
---|
3778 | }
|
---|
3779 |
|
---|
3780 | void BiasCamChannelChanged()
|
---|
3781 | {
|
---|
3782 | if (fInChooseBiasCam)
|
---|
3783 | return;
|
---|
3784 |
|
---|
3785 | const int crate = fBiasCamCrate->value();
|
---|
3786 | const int board = fBiasCamBoard->value();
|
---|
3787 | const int patch = fBiasCamPatch->value();
|
---|
3788 | const int pixel = fBiasCamPixel->value();
|
---|
3789 |
|
---|
3790 | // FIXME: Display corresponding patches
|
---|
3791 | const PixelMapEntry &entry = fPixelMap.cbpx(crate, board, patch, pixel);
|
---|
3792 | fBiasCamV->SetWhite(entry.index);
|
---|
3793 | fBiasCamA->SetWhite(entry.index);
|
---|
3794 | fBiasCamV->updateCamera();
|
---|
3795 | fBiasCamA->updateCamera();
|
---|
3796 |
|
---|
3797 | UpdateBiasHv(entry);
|
---|
3798 | UpdateBiasValues();
|
---|
3799 | }
|
---|
3800 |
|
---|
3801 | void slot_ChooseBiasChannel(int isw)
|
---|
3802 | {
|
---|
3803 | const PixelMapEntry &entry = fPixelMap.index(isw);
|
---|
3804 |
|
---|
3805 | UpdateBiasHv(entry);
|
---|
3806 | UpdateBiasCam(entry);
|
---|
3807 | UpdateBiasValues();
|
---|
3808 | }
|
---|
3809 |
|
---|
3810 | void on_fBiasDispRefVolt_stateChanged(int = 0)
|
---|
3811 | {
|
---|
3812 | // FIXME: Display patches for which ref==cur
|
---|
3813 |
|
---|
3814 | valarray<double> dat(0., 1440);
|
---|
3815 |
|
---|
3816 | int offset = 0;
|
---|
3817 | if (!fBiasDispRefVolt->isChecked())
|
---|
3818 | fBiasCamV->setTitle("Applied BIAS voltage");
|
---|
3819 | else
|
---|
3820 | {
|
---|
3821 | fBiasCamV->setTitle("Reference BIAS voltage");
|
---|
3822 | offset = 416;
|
---|
3823 | }
|
---|
3824 |
|
---|
3825 | if (fVecBiasVolt.size()>0)
|
---|
3826 | {
|
---|
3827 | for (int i=0; i<1440; i++)
|
---|
3828 | {
|
---|
3829 | const PixelMapEntry &entry = fPixelMap.index(i);
|
---|
3830 | dat[i] = fVecBiasVolt[entry.hv()+offset]*90./4096;
|
---|
3831 |
|
---|
3832 | fBiasCamV->highlightPixel(i, fVecBiasVolt[entry.hv()]!=fVecBiasVolt[entry.hv()+416]);
|
---|
3833 | }
|
---|
3834 |
|
---|
3835 | fBiasCamV->SetData(dat);
|
---|
3836 | }
|
---|
3837 |
|
---|
3838 | fBiasCamV->updateCamera();
|
---|
3839 | }
|
---|
3840 |
|
---|
3841 | // ------------------------------------------------------
|
---|
3842 |
|
---|
3843 | void on_fPixelEnable_stateChanged(int b)
|
---|
3844 | {
|
---|
3845 | if (fInHandler)
|
---|
3846 | return;
|
---|
3847 |
|
---|
3848 | const PixelMapEntry &entry = fPixelMap.index(fPixelIdx->value());
|
---|
3849 |
|
---|
3850 | Dim::SendCommand(b==Qt::Unchecked ?
|
---|
3851 | "FTM_CONTROL/DISABLE_PIXEL" : "FTM_CONTROL/ENABLE_PIXEL",
|
---|
3852 | uint16_t(entry.hw()));
|
---|
3853 | }
|
---|
3854 |
|
---|
3855 | void on_fPixelDisableOthers_clicked()
|
---|
3856 | {
|
---|
3857 | const PixelMapEntry &entry = fPixelMap.index(fPixelIdx->value());
|
---|
3858 | Dim::SendCommand("FTM_CONTROL/DISABLE_ALL_PIXELS_EXCEPT", uint16_t(entry.hw()));
|
---|
3859 | }
|
---|
3860 |
|
---|
3861 | void on_fThresholdDisableOthers_clicked()
|
---|
3862 | {
|
---|
3863 | const int16_t isw = fThresholdIdx->value();
|
---|
3864 | const int16_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
|
---|
3865 | if (ihw<0)
|
---|
3866 | return;
|
---|
3867 |
|
---|
3868 | Dim::SendCommand("FTM_CONTROL/DISABLE_ALL_PATCHES_EXCEPT", ihw);
|
---|
3869 | }
|
---|
3870 |
|
---|
3871 | void on_fThresholdEnablePatch_clicked()
|
---|
3872 | {
|
---|
3873 | const int16_t isw = fThresholdIdx->value();
|
---|
3874 | const int16_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
|
---|
3875 | if (ihw<0)
|
---|
3876 | return;
|
---|
3877 |
|
---|
3878 | Dim::SendCommand("FTM_CONTROL/ENABLE_PATCH", ihw);
|
---|
3879 | }
|
---|
3880 |
|
---|
3881 | void on_fThresholdDisablePatch_clicked()
|
---|
3882 | {
|
---|
3883 | const int16_t isw = fThresholdIdx->value();
|
---|
3884 | const int16_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
|
---|
3885 | if (ihw<0)
|
---|
3886 | return;
|
---|
3887 |
|
---|
3888 | Dim::SendCommand("FTM_CONTROL/DISABLE_PATCH", ihw);
|
---|
3889 | }
|
---|
3890 |
|
---|
3891 | void on_fThresholdVal_valueChanged(int v)
|
---|
3892 | {
|
---|
3893 | fThresholdVolt->setValue(2500./4095*v);
|
---|
3894 |
|
---|
3895 | const int32_t isw = fThresholdIdx->value();
|
---|
3896 | const int32_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
|
---|
3897 |
|
---|
3898 | const int32_t d[2] = { ihw, v };
|
---|
3899 |
|
---|
3900 | if (!fInHandler)
|
---|
3901 | Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", d);
|
---|
3902 | }
|
---|
3903 |
|
---|
3904 | TGraph fGraphFtmTemp[4];
|
---|
3905 | TGraph fGraphFtmRate;
|
---|
3906 | TGraph fGraphPatchRate[160];
|
---|
3907 | TGraph fGraphBoardRate[40];
|
---|
3908 |
|
---|
3909 | #ifdef HAVE_ROOT
|
---|
3910 | TH1 *DrawTimeFrame(const char *ytitle)
|
---|
3911 | {
|
---|
3912 | const double tm = Time().RootTime();
|
---|
3913 |
|
---|
3914 | TH1F *h=new TH1F("TimeFrame", "", 1, tm, tm+60);//Time().RootTime()-1./24/60/60, Time().RootTime());
|
---|
3915 | h->SetDirectory(0);
|
---|
3916 | h->SetBit(kCanDelete);
|
---|
3917 | h->SetStats(kFALSE);
|
---|
3918 | // h.SetMinimum(0);
|
---|
3919 | // h.SetMaximum(1);
|
---|
3920 | h->SetXTitle("Time");
|
---|
3921 | h->SetYTitle(ytitle);
|
---|
3922 | h->GetXaxis()->CenterTitle();
|
---|
3923 | h->GetYaxis()->CenterTitle();
|
---|
3924 | h->GetXaxis()->SetTimeDisplay(true);
|
---|
3925 | h->GetXaxis()->SetTimeFormat("%Mh%S'");
|
---|
3926 | h->GetXaxis()->SetLabelSize(0.025);
|
---|
3927 | h->GetYaxis()->SetLabelSize(0.025);
|
---|
3928 | h->GetYaxis()->SetTitleOffset(1.2);
|
---|
3929 | // h.GetYaxis()->SetTitleSize(1.2);
|
---|
3930 | h->Draw();
|
---|
3931 |
|
---|
3932 | return h;
|
---|
3933 | }
|
---|
3934 | #endif
|
---|
3935 |
|
---|
3936 | pair<string,string> Split(const string &str) const
|
---|
3937 | {
|
---|
3938 | const size_t p = str.find_first_of('|');
|
---|
3939 | if (p==string::npos)
|
---|
3940 | return make_pair(str, "");
|
---|
3941 |
|
---|
3942 | return make_pair(str.substr(0, p), str.substr(p+1));
|
---|
3943 | }
|
---|
3944 |
|
---|
3945 | public:
|
---|
3946 | FactGui(Configuration &conf) :
|
---|
3947 | fFtuStatus(40),
|
---|
3948 | /*fPixelMapHW(1440),*/ fPatchMapHW(160),
|
---|
3949 | fInChoosePatchTH(false),
|
---|
3950 | fInChooseBiasHv(false), fInChooseBiasCam(false),
|
---|
3951 | fDimDNS("DIS_DNS/VERSION_NUMBER", 1, int(0), this),
|
---|
3952 | //-
|
---|
3953 | fDimLoggerStats ("DATA_LOGGER/STATS", (void*)NULL, 0, this),
|
---|
3954 | fDimLoggerFilenameNight("DATA_LOGGER/FILENAME_NIGHTLY", (void*)NULL, 0, this),
|
---|
3955 | fDimLoggerFilenameRun ("DATA_LOGGER/FILENAME_RUN", (void*)NULL, 0, this),
|
---|
3956 | fDimLoggerNumSubs ("DATA_LOGGER/NUM_SUBS", (void*)NULL, 0, this),
|
---|
3957 | //-
|
---|
3958 | fDimFtmPassport ("FTM_CONTROL/PASSPORT", (void*)NULL, 0, this),
|
---|
3959 | fDimFtmTriggerRates ("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, this),
|
---|
3960 | fDimFtmError ("FTM_CONTROL/ERROR", (void*)NULL, 0, this),
|
---|
3961 | fDimFtmFtuList ("FTM_CONTROL/FTU_LIST", (void*)NULL, 0, this),
|
---|
3962 | fDimFtmStaticData ("FTM_CONTROL/STATIC_DATA", (void*)NULL, 0, this),
|
---|
3963 | fDimFtmDynamicData ("FTM_CONTROL/DYNAMIC_DATA", (void*)NULL, 0, this),
|
---|
3964 | fDimFtmCounter ("FTM_CONTROL/COUNTER", (void*)NULL, 0, this),
|
---|
3965 | //-
|
---|
3966 | fDimFadWriteStats ("FAD_CONTROL/STATS", (void*)NULL, 0, this),
|
---|
3967 | fDimFadStartRun ("FAD_CONTROL/START_RUN", (void*)NULL, 0, this),
|
---|
3968 | fDimFadRuns ("FAD_CONTROL/RUNS", (void*)NULL, 0, this),
|
---|
3969 | fDimFadEvents ("FAD_CONTROL/EVENTS", (void*)NULL, 0, this),
|
---|
3970 | fDimFadRawData ("FAD_CONTROL/RAW_DATA", (void*)NULL, 0, this),
|
---|
3971 | fDimFadEventData ("FAD_CONTROL/EVENT_DATA", (void*)NULL, 0, this),
|
---|
3972 | fDimFadConnections ("FAD_CONTROL/CONNECTIONS", (void*)NULL, 0, this),
|
---|
3973 | fDimFadFwVersion ("FAD_CONTROL/FIRMWARE_VERSION", (void*)NULL, 0, this),
|
---|
3974 | fDimFadRunNumber ("FAD_CONTROL/RUN_NUMBER", (void*)NULL, 0, this),
|
---|
3975 | fDimFadDNA ("FAD_CONTROL/DNA", (void*)NULL, 0, this),
|
---|
3976 | fDimFadTemperature ("FAD_CONTROL/TEMPERATURE", (void*)NULL, 0, this),
|
---|
3977 | fDimFadPrescaler ("FAD_CONTROL/PRESCALER", (void*)NULL, 0, this),
|
---|
3978 | fDimFadRefClock ("FAD_CONTROL/REFERENCE_CLOCK", (void*)NULL, 0, this),
|
---|
3979 | fDimFadRoi ("FAD_CONTROL/REGION_OF_INTEREST", (void*)NULL, 0, this),
|
---|
3980 | fDimFadDac ("FAD_CONTROL/DAC", (void*)NULL, 0, this),
|
---|
3981 | fDimFadDrsCalibration ("FAD_CONTROL/DRS_CALIBRATION", (void*)NULL, 0, this),
|
---|
3982 | fDimFadStatus ("FAD_CONTROL/STATUS", (void*)NULL, 0, this),
|
---|
3983 | fDimFadStatistics1 ("FAD_CONTROL/STATISTICS1", (void*)NULL, 0, this),
|
---|
3984 | fDimFadStatistics2 ("FAD_CONTROL/STATISTICS2", (void*)NULL, 0, this),
|
---|
3985 | fDimFadFileFormat ("FAD_CONTROL/FILE_FORMAT", (void*)NULL, 0, this),
|
---|
3986 | //-
|
---|
3987 | fDimFscTemp ("FSC_CONTROL/TEMPERATURE", (void*)NULL, 0, this),
|
---|
3988 | fDimFscVolt ("FSC_CONTROL/VOLTAGE", (void*)NULL, 0, this),
|
---|
3989 | fDimFscCurrent ("FSC_CONTROL/CURRENT", (void*)NULL, 0, this),
|
---|
3990 | fDimFscHumidity ("FSC_CONTROL/HUMIDITY", (void*)NULL, 0, this),
|
---|
3991 | //-
|
---|
3992 | fDimFeedbackDeviation ("FEEDBACK/DEVIATION", (void*)NULL, 0, this),
|
---|
3993 | fDimFeedbackReference ("FEEDBACK/REFERENCE", (void*)NULL, 0, this),
|
---|
3994 | fDimFeedbackCalibration("FEEDBACK/CALIBRATION", (void*)NULL, 0, this),
|
---|
3995 | //-
|
---|
3996 | fDimBiasVolt ("BIAS_CONTROL/VOLTAGE", (void*)NULL, 0, this),
|
---|
3997 | fDimBiasCurrent ("BIAS_CONTROL/CURRENT", (void*)NULL, 0, this),
|
---|
3998 | //-
|
---|
3999 | fDimRateScan ("RATE_SCAN/DATA", (void*)NULL, 0, this),
|
---|
4000 | //-
|
---|
4001 | fEventData(0), fDrsCalibration(1440*1024*6+160*1024*2),
|
---|
4002 | fTimeStamp0(0)
|
---|
4003 | {
|
---|
4004 | fClockCondFreq->addItem("--- Hz", QVariant(-1));
|
---|
4005 | fClockCondFreq->addItem("800 MHz", QVariant(800));
|
---|
4006 | fClockCondFreq->addItem("1 GHz", QVariant(1000));
|
---|
4007 | fClockCondFreq->addItem("2 GHz", QVariant(2000));
|
---|
4008 | fClockCondFreq->addItem("3 GHz", QVariant(3000));
|
---|
4009 | fClockCondFreq->addItem("4 GHz", QVariant(4000));
|
---|
4010 | fClockCondFreq->addItem("5 GHz", QVariant(5000));
|
---|
4011 |
|
---|
4012 | cout << "-- run counter ---" << endl;
|
---|
4013 | fMcpNumEvents->addItem("unlimited", QVariant(0));
|
---|
4014 | const vector<uint32_t> runcount = conf.Vec<uint32_t>("run-count");
|
---|
4015 | for (vector<uint32_t>::const_iterator it=runcount.begin(); it!=runcount.end(); it++)
|
---|
4016 | {
|
---|
4017 | cout << *it << endl;
|
---|
4018 | ostringstream str;
|
---|
4019 | str << *it;
|
---|
4020 | fMcpNumEvents->addItem(str.str().c_str(), QVariant(*it));
|
---|
4021 | }
|
---|
4022 |
|
---|
4023 | cout << "-- run times ---" << endl;
|
---|
4024 | fMcpTime->addItem("unlimited", QVariant(0));
|
---|
4025 | const vector<string> runtime = conf.Vec<string>("run-time");
|
---|
4026 | for (vector<string>::const_iterator it=runtime.begin(); it!=runtime.end(); it++)
|
---|
4027 | {
|
---|
4028 | const pair<string,string> p = Split(*it);
|
---|
4029 | cout << *it << "|" << p.second << "|" << p.first << "|" << endl;
|
---|
4030 | fMcpTime->addItem(p.second.c_str(), QVariant(stoi(p.first)));
|
---|
4031 | }
|
---|
4032 |
|
---|
4033 | cout << "-- run types ---" << endl;
|
---|
4034 | const vector<string> runtype = conf.Vec<string>("run-type");
|
---|
4035 | for (vector<string>::const_iterator it=runtype.begin(); it!=runtype.end(); it++)
|
---|
4036 | {
|
---|
4037 | const pair<string,string> p = Split(*it);
|
---|
4038 | cout << *it << "|" << p.second << "|" << p.first << "|" << endl;
|
---|
4039 | fMcpRunType->addItem(p.second.c_str(), QVariant(p.first.c_str()));
|
---|
4040 | }
|
---|
4041 |
|
---|
4042 | fTriggerWidget->setEnabled(false);
|
---|
4043 | fFtuWidget->setEnabled(false);
|
---|
4044 | fFtuGroupEnable->setEnabled(false);
|
---|
4045 | fRatesControls->setEnabled(false);
|
---|
4046 | fFadWidget->setEnabled(false);
|
---|
4047 | fEvtBldWidget->setEnabled(false);
|
---|
4048 | fLoggerWidget->setEnabled(false);
|
---|
4049 | fBiasWidget->setEnabled(false);
|
---|
4050 | fAuxWidget->setEnabled(false);
|
---|
4051 |
|
---|
4052 | fChatSend->setEnabled(false);
|
---|
4053 | fChatMessage->setEnabled(false);
|
---|
4054 |
|
---|
4055 | DimClient::sendCommand("CHAT/MSG", "GUI online.");
|
---|
4056 | // + MessageDimRX
|
---|
4057 |
|
---|
4058 | // --------------------------------------------------------------------------
|
---|
4059 |
|
---|
4060 | if (!fPixelMap.Read(conf.Get<string>("pixel-map-file")))
|
---|
4061 | {
|
---|
4062 | cerr << "ERROR - Problems reading " << conf.Get<string>("pixel-map-file") << endl;
|
---|
4063 | exit(-1);
|
---|
4064 | }
|
---|
4065 |
|
---|
4066 | // --------------------------------------------------------------------------
|
---|
4067 |
|
---|
4068 | /*
|
---|
4069 | ifstream fin1("Trigger-Patches.txt");
|
---|
4070 |
|
---|
4071 | string buf;
|
---|
4072 |
|
---|
4073 | int l = 0;
|
---|
4074 | while (getline(fin1, buf, '\n'))
|
---|
4075 | {
|
---|
4076 | buf = Tools::Trim(buf);
|
---|
4077 | if (buf[0]=='#')
|
---|
4078 | continue;
|
---|
4079 |
|
---|
4080 | stringstream str(buf);
|
---|
4081 | for (int i=0; i<9; i++)
|
---|
4082 | {
|
---|
4083 | unsigned int n;
|
---|
4084 | str >> n;
|
---|
4085 |
|
---|
4086 | if (n>=fPatchHW.size())
|
---|
4087 | continue;
|
---|
4088 |
|
---|
4089 | fPatchHW[n] = l;
|
---|
4090 | }
|
---|
4091 | l++;
|
---|
4092 | }
|
---|
4093 |
|
---|
4094 | if (l!=160)
|
---|
4095 | cerr << "WARNING - Problems reading Trigger-Patches.txt" << endl;
|
---|
4096 | */
|
---|
4097 | // --------------------------------------------------------------------------
|
---|
4098 |
|
---|
4099 | /*
|
---|
4100 | ifstream fin2("MasterList-v3.txt");
|
---|
4101 |
|
---|
4102 | l = 0;
|
---|
4103 |
|
---|
4104 | while (getline(fin2, buf, '\n'))
|
---|
4105 | {
|
---|
4106 | buf = Tools::Trim(buf);
|
---|
4107 | if (buf[0]=='#')
|
---|
4108 | continue;
|
---|
4109 |
|
---|
4110 | unsigned int softid, hardid, dummy;
|
---|
4111 |
|
---|
4112 | stringstream str(buf);
|
---|
4113 |
|
---|
4114 | str >> softid;
|
---|
4115 | str >> dummy;
|
---|
4116 | str >> hardid;
|
---|
4117 |
|
---|
4118 | if (softid>=fPixelMapHW.size())
|
---|
4119 | continue;
|
---|
4120 |
|
---|
4121 | fPixelMapHW[softid] = hardid;
|
---|
4122 |
|
---|
4123 | l++;
|
---|
4124 | }
|
---|
4125 |
|
---|
4126 | if (l!=1440)
|
---|
4127 | cerr << "WARNING - Problems reading MasterList-v3.txt" << endl;
|
---|
4128 | */
|
---|
4129 | // --------------------------------------------------------------------------
|
---|
4130 |
|
---|
4131 | ifstream fin3("PatchList.txt");
|
---|
4132 |
|
---|
4133 | string buf;
|
---|
4134 |
|
---|
4135 | int l = 0;
|
---|
4136 | while (getline(fin3, buf, '\n'))
|
---|
4137 | {
|
---|
4138 | buf = Tools::Trim(buf);
|
---|
4139 | if (buf[0]=='#')
|
---|
4140 | continue;
|
---|
4141 |
|
---|
4142 | unsigned int softid, hardid;
|
---|
4143 |
|
---|
4144 | stringstream str(buf);
|
---|
4145 |
|
---|
4146 | str >> softid;
|
---|
4147 | str >> hardid;
|
---|
4148 |
|
---|
4149 | if (softid>=fPatchMapHW.size())
|
---|
4150 | continue;
|
---|
4151 |
|
---|
4152 | fPatchMapHW[softid] = hardid-1;
|
---|
4153 |
|
---|
4154 | l++;
|
---|
4155 | }
|
---|
4156 |
|
---|
4157 | if (l!=160)
|
---|
4158 | cerr << "WARNING - Problems reading PatchList.txt" << endl;
|
---|
4159 |
|
---|
4160 | // --------------------------------------------------------------------------
|
---|
4161 | #ifdef HAVE_ROOT
|
---|
4162 |
|
---|
4163 | fGraphFeedbackDev.SetLineColor(kBlue);
|
---|
4164 | fGraphFeedbackDev.SetMarkerColor(kBlue);
|
---|
4165 | fGraphFeedbackDev.SetMarkerStyle(kFullDotMedium);
|
---|
4166 |
|
---|
4167 | fGraphFeedbackCmd.SetLineColor(kBlue);
|
---|
4168 | fGraphFeedbackCmd.SetMarkerColor(kBlue);
|
---|
4169 | fGraphFeedbackCmd.SetMarkerStyle(kFullDotMedium);
|
---|
4170 |
|
---|
4171 | // Evolution of control deviation
|
---|
4172 | // Evolution of command values (bias voltage change)
|
---|
4173 | fGraphFeedbackDev.SetName("ControlDev");
|
---|
4174 | fGraphFeedbackCmd.SetName("CommandVal");
|
---|
4175 |
|
---|
4176 | TCanvas *c = fFeedbackDev->GetCanvas();
|
---|
4177 | c->SetBorderMode(0);
|
---|
4178 | c->SetFrameBorderMode(0);
|
---|
4179 | c->SetFillColor(kWhite);
|
---|
4180 | c->SetRightMargin(0.03);
|
---|
4181 | c->SetTopMargin(0.03);
|
---|
4182 | c->SetGrid();
|
---|
4183 | c->cd();
|
---|
4184 |
|
---|
4185 | TH1 *hf = DrawTimeFrame("Control deviation [mV] ");
|
---|
4186 | hf->GetXaxis()->SetLabelSize(0.07);
|
---|
4187 | hf->GetYaxis()->SetLabelSize(0.07);
|
---|
4188 | hf->GetYaxis()->SetTitleSize(0.08);
|
---|
4189 | hf->GetYaxis()->SetTitleOffset(0.55);
|
---|
4190 | hf->GetXaxis()->SetTitle("");
|
---|
4191 | hf->GetYaxis()->SetRangeUser(-99, 99);
|
---|
4192 |
|
---|
4193 | fGraphFeedbackDev.Draw("LP");
|
---|
4194 |
|
---|
4195 | c = fFeedbackCmd->GetCanvas();
|
---|
4196 | c->SetBorderMode(0);
|
---|
4197 | c->SetFrameBorderMode(0);
|
---|
4198 | c->SetFillColor(kWhite);
|
---|
4199 | c->SetRightMargin(0.03);
|
---|
4200 | c->SetTopMargin(0.03);
|
---|
4201 | c->SetGrid();
|
---|
4202 | c->cd();
|
---|
4203 |
|
---|
4204 | hf = DrawTimeFrame("Command delta value [mV] ");
|
---|
4205 | hf->GetXaxis()->SetLabelSize(0.07);
|
---|
4206 | hf->GetYaxis()->SetLabelSize(0.07);
|
---|
4207 | hf->GetYaxis()->SetTitleSize(0.08);
|
---|
4208 | hf->GetYaxis()->SetTitleOffset(0.55);
|
---|
4209 | hf->GetXaxis()->SetTitle("");
|
---|
4210 | hf->GetYaxis()->SetRangeUser(-99*10, 99*10);
|
---|
4211 |
|
---|
4212 | fGraphFeedbackCmd.Draw("LP");
|
---|
4213 |
|
---|
4214 | // --------------------------------------------------------------------------
|
---|
4215 |
|
---|
4216 | c = fRateScanCanv->GetCanvas();
|
---|
4217 | //c->SetBit(TCanvas::kNoContextMenu);
|
---|
4218 | c->SetBorderMode(0);
|
---|
4219 | c->SetFrameBorderMode(0);
|
---|
4220 | c->SetFillColor(kWhite);
|
---|
4221 | c->SetRightMargin(0.03);
|
---|
4222 | c->SetTopMargin(0.03);
|
---|
4223 | c->SetGrid();
|
---|
4224 | c->cd();
|
---|
4225 |
|
---|
4226 | TH1F *h=new TH1F("Frame", "", 1, 0, 1);
|
---|
4227 | h->SetDirectory(0);
|
---|
4228 | h->SetBit(kCanDelete);
|
---|
4229 | h->SetStats(kFALSE);
|
---|
4230 | h->SetXTitle("Threshold [DAC]");
|
---|
4231 | h->SetYTitle("Rate [Hz]");
|
---|
4232 | h->GetXaxis()->CenterTitle();
|
---|
4233 | h->GetYaxis()->CenterTitle();
|
---|
4234 | h->GetXaxis()->SetLabelSize(0.025);
|
---|
4235 | h->GetYaxis()->SetLabelSize(0.025);
|
---|
4236 | h->GetYaxis()->SetTitleOffset(1.2);
|
---|
4237 | h->Draw();
|
---|
4238 |
|
---|
4239 | fGraphRateScan[0].SetName("CameraRate");
|
---|
4240 | for (int i=0; i<40; i++)
|
---|
4241 | {
|
---|
4242 | fGraphRateScan[i+1].SetName("BoardRate");
|
---|
4243 | fGraphRateScan[i+1].SetMarkerStyle(kFullDotMedium);
|
---|
4244 | }
|
---|
4245 | for (int i=0; i<160; i++)
|
---|
4246 | {
|
---|
4247 | fGraphRateScan[i+41].SetName("PatchRate");
|
---|
4248 | fGraphRateScan[i+41].SetMarkerStyle(kFullDotMedium);
|
---|
4249 | }
|
---|
4250 |
|
---|
4251 | fGraphRateScan[0].SetLineColor(kBlue);
|
---|
4252 | fGraphRateScan[0].SetMarkerColor(kBlue);
|
---|
4253 | fGraphRateScan[0].SetMarkerStyle(kFullDotSmall);
|
---|
4254 | fGraphRateScan[0].Draw("LP");
|
---|
4255 |
|
---|
4256 | // --------------------------------------------------------------------------
|
---|
4257 |
|
---|
4258 | c = fFtmRateCanv->GetCanvas();
|
---|
4259 | //c->SetBit(TCanvas::kNoContextMenu);
|
---|
4260 | c->SetBorderMode(0);
|
---|
4261 | c->SetFrameBorderMode(0);
|
---|
4262 | c->SetFillColor(kWhite);
|
---|
4263 | c->SetRightMargin(0.03);
|
---|
4264 | c->SetTopMargin(0.03);
|
---|
4265 | c->SetGrid();
|
---|
4266 | c->cd();
|
---|
4267 |
|
---|
4268 | hf = DrawTimeFrame("Trigger rate [Hz]");
|
---|
4269 | hf->GetYaxis()->SetRangeUser(0, 1010);
|
---|
4270 |
|
---|
4271 | for (int i=0; i<160; i++)
|
---|
4272 | {
|
---|
4273 | fGraphPatchRate[i].SetName("PatchRate");
|
---|
4274 | //fGraphPatchRate[i].SetLineColor(kBlue);
|
---|
4275 | //fGraphPatchRate[i].SetMarkerColor(kBlue);
|
---|
4276 | fGraphPatchRate[i].SetMarkerStyle(kFullDotMedium);
|
---|
4277 | }
|
---|
4278 | for (int i=0; i<40; i++)
|
---|
4279 | {
|
---|
4280 | fGraphBoardRate[i].SetName("BoardRate");
|
---|
4281 | //fGraphBoardRate[i].SetLineColor(kBlue);
|
---|
4282 | //fGraphBoardRate[i].SetMarkerColor(kBlue);
|
---|
4283 | fGraphBoardRate[i].SetMarkerStyle(kFullDotMedium);
|
---|
4284 | }
|
---|
4285 |
|
---|
4286 | fGraphFtmRate.SetLineColor(kBlue);
|
---|
4287 | fGraphFtmRate.SetMarkerColor(kBlue);
|
---|
4288 | fGraphFtmRate.SetMarkerStyle(kFullDotSmall);
|
---|
4289 | fGraphFtmRate.Draw("LP");
|
---|
4290 |
|
---|
4291 | /*
|
---|
4292 | TCanvas *c = fFtmTempCanv->GetCanvas();
|
---|
4293 | c->SetBit(TCanvas::kNoContextMenu);
|
---|
4294 | c->SetBorderMode(0);
|
---|
4295 | c->SetFrameBorderMode(0);
|
---|
4296 | c->SetFillColor(kWhite);
|
---|
4297 | c->SetRightMargin(0.03);
|
---|
4298 | c->SetTopMargin(0.03);
|
---|
4299 | c->cd();
|
---|
4300 | */
|
---|
4301 | //CreateTimeFrame("Temperature / �C");
|
---|
4302 |
|
---|
4303 | fGraphFtmTemp[0].SetMarkerStyle(kFullDotSmall);
|
---|
4304 | fGraphFtmTemp[1].SetMarkerStyle(kFullDotSmall);
|
---|
4305 | fGraphFtmTemp[2].SetMarkerStyle(kFullDotSmall);
|
---|
4306 | fGraphFtmTemp[3].SetMarkerStyle(kFullDotSmall);
|
---|
4307 |
|
---|
4308 | fGraphFtmTemp[1].SetLineColor(kBlue);
|
---|
4309 | fGraphFtmTemp[2].SetLineColor(kRed);
|
---|
4310 | fGraphFtmTemp[3].SetLineColor(kGreen);
|
---|
4311 |
|
---|
4312 | fGraphFtmTemp[1].SetMarkerColor(kBlue);
|
---|
4313 | fGraphFtmTemp[2].SetMarkerColor(kRed);
|
---|
4314 | fGraphFtmTemp[3].SetMarkerColor(kGreen);
|
---|
4315 |
|
---|
4316 | //fGraphFtmTemp[0].Draw("LP");
|
---|
4317 | //fGraphFtmTemp[1].Draw("LP");
|
---|
4318 | //fGraphFtmTemp[2].Draw("LP");
|
---|
4319 | //fGraphFtmTemp[3].Draw("LP");
|
---|
4320 |
|
---|
4321 | // --------------------------------------------------------------------------
|
---|
4322 |
|
---|
4323 | c = fAdcDataCanv->GetCanvas();
|
---|
4324 | //c->SetBit(TCanvas::kNoContextMenu);
|
---|
4325 | c->SetBorderMode(0);
|
---|
4326 | c->SetFrameBorderMode(0);
|
---|
4327 | c->SetFillColor(kWhite);
|
---|
4328 | c->SetRightMargin(0.10);
|
---|
4329 | c->SetGrid();
|
---|
4330 | //c->cd();
|
---|
4331 | #endif
|
---|
4332 |
|
---|
4333 | // --------------------------------------------------------------------------
|
---|
4334 | fFeedbackDevCam->assignPixelMap(fPixelMap);
|
---|
4335 | fFeedbackDevCam->setAutoscaleLowerLimit((fFeedbackDevMin->minimum()+0.5*fFeedbackDevMin->singleStep()));
|
---|
4336 | fFeedbackDevCam->SetMin(fFeedbackDevMin->value());
|
---|
4337 | fFeedbackDevCam->SetMax(fFeedbackDevMax->value());
|
---|
4338 | fFeedbackDevCam->updateCamera();
|
---|
4339 |
|
---|
4340 | fFeedbackCmdCam->assignPixelMap(fPixelMap);
|
---|
4341 | fFeedbackCmdCam->setAutoscaleLowerLimit((fFeedbackCmdMin->minimum()+0.5*fFeedbackCmdMin->singleStep()));
|
---|
4342 | fFeedbackCmdCam->SetMin(fFeedbackCmdMin->value());
|
---|
4343 | fFeedbackCmdCam->SetMax(fFeedbackCmdMax->value());
|
---|
4344 | fFeedbackCmdCam->updateCamera();
|
---|
4345 |
|
---|
4346 | // --------------------------------------------------------------------------
|
---|
4347 |
|
---|
4348 | fBiasCamV->assignPixelMap(fPixelMap);
|
---|
4349 | fBiasCamV->setAutoscaleLowerLimit((fBiasVoltMin->minimum()+0.5*fBiasVoltMin->singleStep()));
|
---|
4350 | fBiasCamV->SetMin(fBiasVoltMin->value());
|
---|
4351 | fBiasCamV->SetMax(fBiasVoltMax->value());
|
---|
4352 | fBiasCamV->updateCamera();
|
---|
4353 |
|
---|
4354 | fBiasCamA->assignPixelMap(fPixelMap);
|
---|
4355 | fBiasCamA->setAutoscaleLowerLimit((fBiasCurrentMin->minimum()+0.5*fBiasCurrentMin->singleStep()));
|
---|
4356 | fBiasCamA->SetMin(fBiasCurrentMin->value());
|
---|
4357 | fBiasCamA->SetMax(fBiasCurrentMax->value());
|
---|
4358 | fBiasCamA->updateCamera();
|
---|
4359 |
|
---|
4360 | // --------------------------------------------------------------------------
|
---|
4361 |
|
---|
4362 | fRatesCanv->assignPixelMap(fPixelMap);
|
---|
4363 | fRatesCanv->setAutoscaleLowerLimit((fRatesMin->minimum()+0.5*fRatesMin->singleStep())*0.001);
|
---|
4364 | fRatesCanv->SetMin(fRatesMin->value());
|
---|
4365 | fRatesCanv->SetMax(fRatesMax->value());
|
---|
4366 | fRatesCanv->updateCamera();
|
---|
4367 | on_fPixelIdx_valueChanged(0);
|
---|
4368 |
|
---|
4369 | // --------------------------------------------------------------------------
|
---|
4370 |
|
---|
4371 | fRatesCanv->setTitle("Patch rates");
|
---|
4372 | fRatesCanv->setUnits("Hz");
|
---|
4373 |
|
---|
4374 | fBiasCamA->setTitle("BIAS current");
|
---|
4375 | fBiasCamA->setUnits("uA");
|
---|
4376 |
|
---|
4377 | fBiasCamV->setTitle("Applied BIAS voltage");
|
---|
4378 | fBiasCamV->setUnits("V");
|
---|
4379 |
|
---|
4380 | fEventCanv1->setTitle("Average (all slices)");
|
---|
4381 | fEventCanv2->setTitle("RMS (all slices)");
|
---|
4382 | fEventCanv3->setTitle("Maximum (all slices)");
|
---|
4383 | fEventCanv4->setTitle("Position of maximum (all slices)");
|
---|
4384 |
|
---|
4385 | fEventCanv1->setUnits("mV");
|
---|
4386 | fEventCanv2->setUnits("mV");
|
---|
4387 | fEventCanv3->setUnits("mV");
|
---|
4388 | fEventCanv4->setUnits("slice");
|
---|
4389 |
|
---|
4390 | // --------------------------------------------------------------------------
|
---|
4391 |
|
---|
4392 | fFeedbackDevCam->setTitle("Control deviation (Pulser amplitude voltage)");
|
---|
4393 | fFeedbackCmdCam->setTitle("Applied voltage change (BIAS voltage)");
|
---|
4394 |
|
---|
4395 | fFeedbackDevCam->setUnits("mV");
|
---|
4396 | fFeedbackCmdCam->setUnits("mV");
|
---|
4397 |
|
---|
4398 | // --------------------------------------------------------------------------
|
---|
4399 |
|
---|
4400 | QTimer::singleShot(1000, this, SLOT(slot_RootUpdate()));
|
---|
4401 |
|
---|
4402 | //widget->setMouseTracking(true);
|
---|
4403 | //widget->EnableSignalEvents(kMouseMoveEvent);
|
---|
4404 |
|
---|
4405 | fFtmRateCanv->setMouseTracking(true);
|
---|
4406 | fFtmRateCanv->EnableSignalEvents(kMouseMoveEvent);
|
---|
4407 |
|
---|
4408 | fAdcDataCanv->setMouseTracking(true);
|
---|
4409 | fAdcDataCanv->EnableSignalEvents(kMouseMoveEvent);
|
---|
4410 |
|
---|
4411 | fRatesCanv->setMouseTracking(true);
|
---|
4412 | fEventCanv1->setMouseTracking(true);
|
---|
4413 | fEventCanv2->setMouseTracking(true);
|
---|
4414 | fEventCanv3->setMouseTracking(true);
|
---|
4415 | fEventCanv4->setMouseTracking(true);
|
---|
4416 |
|
---|
4417 | fBiasCamV->setMouseTracking(true);
|
---|
4418 | fBiasCamA->setMouseTracking(true);
|
---|
4419 |
|
---|
4420 | fFeedbackDevCam->setMouseTracking(true);
|
---|
4421 | fFeedbackCmdCam->setMouseTracking(true);
|
---|
4422 |
|
---|
4423 | fEventCanv1->ShowPixelCursor(true);
|
---|
4424 | fEventCanv2->ShowPixelCursor(true);
|
---|
4425 | fEventCanv3->ShowPixelCursor(true);
|
---|
4426 | fEventCanv4->ShowPixelCursor(true);
|
---|
4427 |
|
---|
4428 | fEventCanv1->ShowPatchCursor(true);
|
---|
4429 | fEventCanv2->ShowPatchCursor(true);
|
---|
4430 | fEventCanv3->ShowPatchCursor(true);
|
---|
4431 | fEventCanv4->ShowPatchCursor(true);
|
---|
4432 |
|
---|
4433 | fFeedbackDevCam->ShowPixelCursor(true);
|
---|
4434 | fFeedbackCmdCam->ShowPixelCursor(true);
|
---|
4435 |
|
---|
4436 | fFeedbackDevCam->ShowPatchCursor(true);
|
---|
4437 | fFeedbackCmdCam->ShowPatchCursor(true);
|
---|
4438 |
|
---|
4439 | connect(fRatesCanv, SIGNAL(signalPixelMoveOver(int)),
|
---|
4440 | this, SLOT(slot_CameraMouseMove(int)));
|
---|
4441 | connect(fEventCanv1, SIGNAL(signalPixelMoveOver(int)),
|
---|
4442 | this, SLOT(slot_CameraMouseMove(int)));
|
---|
4443 | connect(fEventCanv2, SIGNAL(signalPixelMoveOver(int)),
|
---|
4444 | this, SLOT(slot_CameraMouseMove(int)));
|
---|
4445 | connect(fEventCanv3, SIGNAL(signalPixelMoveOver(int)),
|
---|
4446 | this, SLOT(slot_CameraMouseMove(int)));
|
---|
4447 | connect(fEventCanv4, SIGNAL(signalPixelMoveOver(int)),
|
---|
4448 | this, SLOT(slot_CameraMouseMove(int)));
|
---|
4449 |
|
---|
4450 | connect(fBiasCamV, SIGNAL(signalPixelMoveOver(int)),
|
---|
4451 | this, SLOT(slot_CameraMouseMove(int)));
|
---|
4452 | connect(fBiasCamA, SIGNAL(signalPixelMoveOver(int)),
|
---|
4453 | this, SLOT(slot_CameraMouseMove(int)));
|
---|
4454 |
|
---|
4455 | connect(fFeedbackDevCam, SIGNAL(signalPixelMoveOver(int)),
|
---|
4456 | this, SLOT(slot_CameraMouseMove(int)));
|
---|
4457 | connect(fFeedbackCmdCam, SIGNAL(signalPixelMoveOver(int)),
|
---|
4458 | this, SLOT(slot_CameraMouseMove(int)));
|
---|
4459 |
|
---|
4460 | connect(fRatesCanv, SIGNAL(signalPixelDoubleClick(int)),
|
---|
4461 | this, SLOT(slot_CameraDoubleClick(int)));
|
---|
4462 | connect(fRatesCanv, SIGNAL(signalCurrentPixel(int)),
|
---|
4463 | this, SLOT(slot_ChoosePixelThreshold(int)));
|
---|
4464 | connect(fBiasCamV, SIGNAL(signalCurrentPixel(int)),
|
---|
4465 | this, SLOT(slot_ChooseBiasChannel(int)));
|
---|
4466 | connect(fBiasCamA, SIGNAL(signalCurrentPixel(int)),
|
---|
4467 | this, SLOT(slot_ChooseBiasChannel(int)));
|
---|
4468 |
|
---|
4469 | connect(fFtmRateCanv, SIGNAL( RootEventProcessed(TObject*, unsigned int, TCanvas*)),
|
---|
4470 | this, SLOT (slot_RootEventProcessed(TObject*, unsigned int, TCanvas*)));
|
---|
4471 | connect(fAdcDataCanv, SIGNAL( RootEventProcessed(TObject*, unsigned int, TCanvas*)),
|
---|
4472 | this, SLOT (slot_RootEventProcessed(TObject*, unsigned int, TCanvas*)));
|
---|
4473 | }
|
---|
4474 |
|
---|
4475 | ~FactGui()
|
---|
4476 | {
|
---|
4477 | // Unsubscribe all services
|
---|
4478 | for (map<string,DimInfo*>::iterator i=fServices.begin();
|
---|
4479 | i!=fServices.end(); i++)
|
---|
4480 | delete i->second;
|
---|
4481 |
|
---|
4482 | delete fEventData;
|
---|
4483 | }
|
---|
4484 | };
|
---|
4485 |
|
---|
4486 | #endif
|
---|