source: trunk/FACT++/gui/FactGui.h@ 11235

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