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