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