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