9 #include <boost/regex.hpp> 12 #include <QtSql/QSqlError> 13 #include <QtSql/QSqlTableModel> 14 #include <QStandardItemModel> 30 #include "TGraphErrors.h" 65 : QEvent((QEvent::Type)QEvent::registerEventType()),
68 bool Exec() { fFunction(*
this);
return true; }
161 button->setIcon(QIcon(
":/Resources/icons/red circle 1.png"));
165 button->setIcon(QIcon(
":/Resources/icons/green circle 1.png"));
169 button->setIcon(QIcon(
":/Resources/icons/green bar.png"));
173 button->setIcon(QIcon(
":/Resources/icons/green warn.png"));
177 button->setIcon(QIcon(
":/Resources/icons/green check.png"));
181 button->setIcon(QIcon(
":/Resources/icons/yellow circle 1.png"));
185 button->setIcon(QIcon(
":/Resources/icons/orange circle 1.png"));
189 button->setIcon(QIcon(
":/Resources/icons/gray circle 1.png"));
193 button->setIcon(QIcon(
":/Resources/icons/warning 1.png"));
197 button->setIcon(QIcon(
":/Resources/icons/warning 2.png"));
200 case kLedWarnTriangle:
201 button->setIcon(QIcon(
":/Resources/icons/warning 3.png"));
204 case kLedWarnTriangleBorder:
205 button->setIcon(QIcon(
":/Resources/icons/warning 4.png"));
209 button->setIcon(QIcon(
":/Resources/icons/in progress.png"));
215 button->setToolTip((
"Last change: "+t.
GetAsStr()+
" (UTC)").c_str());
220 QStandardItem *
AddServiceItem(
const string &server,
const string &service,
bool iscmd)
222 QListView *servers = iscmd ? fDimCmdServers : fDimSvcServers;
223 QListView *services = iscmd ? fDimCmdCommands : fDimSvcServices;
224 QListView *description = iscmd ? fDimCmdDescription : fDimSvcDescription;
226 QStandardItemModel *m =
dynamic_cast<QStandardItemModel*
>(servers->model());
229 m =
new QStandardItemModel(
this);
230 servers->setModel(m);
231 services->setModel(m);
232 description->setModel(m);
235 QList<QStandardItem*> l = m->findItems(server.c_str());
239 cout <<
"hae" << endl;
243 QStandardItem *col = l.size()==0 ? NULL : l[0];
247 col =
new QStandardItem(server.c_str());
250 if (!services->rootIndex().isValid())
252 services->setRootIndex(col->index());
253 servers->setCurrentIndex(col->index());
257 QStandardItem *
item = 0;
258 for (
int i=0;
i<col->rowCount();
i++)
260 QStandardItem *coli = col->child(
i);
261 if (coli->text().toStdString()==service)
265 item =
new QStandardItem(service.c_str());
266 col->appendRow(item);
267 col->sortChildren(0);
269 if (!description->rootIndex().isValid())
271 description->setRootIndex(item->index());
272 services->setCurrentIndex(item->index());
276 item->setCheckable(
true);
288 item->setToolTip(vec[0].comment.c_str());
292 QStandardItem *desc =
new QStandardItem(str.c_str());
293 desc->setSelectable(
false);
294 item->setChild(0, 0, desc);
301 const State state = GetState(s, GetCurrentState(s));
303 QApplication::postEvent(
this,
307 void AddService(
const string &server,
const string &service,
const string &fmt,
bool iscmd)
309 const vector<Description> v = GetDescription(server, service);
311 QApplication::postEvent(
this,
317 UnsubscribeService(server+
'/'+service,
true);
319 QApplication::postEvent(
this,
325 UnsubscribeAllServices(server);
327 QApplication::postEvent(
this,
331 void AddDescription(
const string &server,
const string &service,
const vector<Description> &vec)
333 const bool iscmd = IsCommand(server, service)==
true;
335 QApplication::postEvent(
this,
343 handleStateChanged(
Time(), server, state);
346 void handleAddService(
const string &server,
const string &service,
const string &,
bool iscmd,
const vector<Description> &vec)
348 QStandardItem *
item = AddServiceItem(server, service, iscmd);
349 AddDescription(item, vec);
354 QListView *servers = iscmd ? fDimCmdServers : fDimSvcServers;
356 QStandardItemModel *m =
dynamic_cast<QStandardItemModel*
>(servers->model());
360 QList<QStandardItem*> l = m->findItems(server.c_str());
364 for (
int i=0;
i<l[0]->rowCount();
i++)
366 QStandardItem *row = l[0]->child(
i);
367 if (row->text().toStdString()==service)
369 l[0]->removeRow(row->index().row());
377 handleStateChanged(
Time(), server,
State(-2,
"Offline",
"No connection via DIM."));
379 QStandardItemModel *m = 0;
380 if ((m=dynamic_cast<QStandardItemModel*>(fDimCmdServers->model())))
382 QList<QStandardItem*> l = m->findItems(server.c_str());
384 m->removeRow(l[0]->index().row());
387 if ((m = dynamic_cast<QStandardItemModel*>(fDimSvcServers->model())))
389 QList<QStandardItem*> l = m->findItems(server.c_str());
391 m->removeRow(l[0]->index().row());
395 void handleAddDescription(
const string &server,
const string &service,
const vector<Description> &vec,
bool iscmd)
397 QStandardItem *
item = AddServiceItem(server, service, iscmd);
398 AddDescription(item, vec);
405 if (fServices.find(service)!=fServices.end())
407 cerr <<
"ERROR - We are already subscribed to " << service << endl;
411 fServices[service] =
new DimStampedInfo(service.c_str(), (
void*)NULL, 0,
this);
416 const map<string,DimInfo*>::iterator
i=fServices.find(service);
418 if (i==fServices.end())
420 if (!allow_unsubscribed)
421 cerr <<
"ERROR - We are not subscribed to " << service << endl;
432 for (map<string,DimInfo*>::iterator
i=fServices.begin();
433 i!=fServices.end();
i++)
434 if (
i->first.substr(0, server.length()+1)==server+
'/')
448 dns << (fDimVersion==0?
"No connection":
"Connection");
449 dns <<
" to DIM DNS (" << getenv(
"DIM_DNS_NODE") <<
")";
450 dns << (fDimVersion==0?
".":
" established");
453 str <<
"V" << fDimVersion/100 <<
'r' << fDimVersion%100;
458 dns << fixed << setprecision(1) << right;
459 if (fFreeSpaceLogger!=UINT64_MAX)
460 dns <<
"<pre> * Data logger: " << setw(7) << fFreeSpaceLogger*1e-7 <<
" GB</pre>";
461 if (fFreeSpaceData!=UINT64_MAX)
462 dns <<
"<pre> * Event Builder: " << setw(7) << fFreeSpaceData*1e-7 <<
" GB</pre>";
464 if (fFreeSpaceLogger<500000000 || fFreeSpaceData<500000000)
466 if (fFreeSpaceLogger<200000000 || fFreeSpaceData<200000000)
467 led = kLedWarnTriangleBorder;
470 str <<
" (Disk space!)";
473 fStatusDNSLabel->setToolTip(dns.str().c_str());
475 SetLedColor(fStatusDNSLed, fDimVersion==0 ? kLedRed : led,
Time());
477 fStatusDNSLabel->setText(fDimVersion==0?
"Offline":str.str().c_str());
482 fDimVersion = d.
size()!=4 ? 0 : d.
get<uint32_t>();
484 UpdateGlobalStatus();
486 fShutdown->setEnabled(fDimVersion!=0);
487 fShutdownAll->setEnabled(fDimVersion!=0);
497 const bool connected = d.
size()!=0;
499 fLoggerET->setEnabled(connected);
500 fLoggerRate->setEnabled(connected);
501 fLoggerWritten->setEnabled(connected);
502 fLoggerFreeSpace->setEnabled(connected);
503 fLoggerSpaceLeft->setEnabled(connected);
505 fFreeSpaceLogger = UINT64_MAX;
506 UpdateGlobalStatus();
511 const uint64_t *vals = d.
ptr<uint64_t>();
513 const size_t space = vals[0];
514 const size_t written = vals[1];
515 const size_t rate = float(vals[2])/vals[3];
517 fFreeSpaceLogger = space;
518 UpdateGlobalStatus();
520 fLoggerFreeSpace->setSuffix(
" MB");
521 fLoggerFreeSpace->setDecimals(0);
522 fLoggerFreeSpace->setValue(space*1e-6);
526 fLoggerFreeSpace->setSuffix(
" GB");
527 fLoggerFreeSpace->setDecimals(2);
528 fLoggerFreeSpace->setValue(space*1e-9);
532 fLoggerFreeSpace->setSuffix(
" GB");
533 fLoggerFreeSpace->setDecimals(1);
534 fLoggerFreeSpace->setValue(space*1e-9);
536 if (space>=100000000)
538 fLoggerFreeSpace->setSuffix(
" GB");
539 fLoggerFreeSpace->setDecimals(0);
540 fLoggerFreeSpace->setValue(space*1e-9);
543 fLoggerET->setTime(QTime().addSecs(rate>0?space/rate:0));
544 fLoggerRate->setValue(rate*1e-3);
545 fLoggerWritten->setValue(written*1e-6);
547 fLoggerRate->setSuffix(
" kB/s");
548 fLoggerRate->setDecimals(2);
549 fLoggerRate->setValue(rate);
552 fLoggerRate->setSuffix(
" kB/s");
553 fLoggerRate->setDecimals(1);
554 fLoggerRate->setValue(rate);
558 fLoggerRate->setSuffix(
" kB/s");
559 fLoggerRate->setDecimals(0);
560 fLoggerRate->setValue(rate);
564 fLoggerRate->setSuffix(
" MB/s");
565 fLoggerRate->setDecimals(2);
566 fLoggerRate->setValue(rate*1e-3);
570 fLoggerRate->setSuffix(
" MB/s");
571 fLoggerRate->setDecimals(1);
572 fLoggerRate->setValue(rate*1e-3);
576 fLoggerRate->setSuffix(
" MB/s");
577 fLoggerRate->setDecimals(0);
578 fLoggerRate->setValue(rate*1e-3);
581 if (space/1000000>static_cast<size_t>(fLoggerSpaceLeft->maximum()))
582 fLoggerSpaceLeft->setValue(fLoggerSpaceLeft->maximum());
584 fLoggerSpaceLeft->setValue(space/1000000);
589 const bool connected = d.
size()!=0;
591 fLoggerFilenameNight->setEnabled(connected);
595 fLoggerFilenameNight->setText(d.
c_str()+4);
597 const uint32_t files = d.
get<uint32_t>();
599 SetLedColor(fLoggerLedLog, files&1 ? kLedGreen : kLedGray, d.
time);
600 SetLedColor(fLoggerLedRep, files&2 ? kLedGreen : kLedGray, d.
time);
601 SetLedColor(fLoggerLedFits, files&4 ? kLedGreen : kLedGray, d.
time);
606 const bool connected = d.
size()!=0;
608 fLoggerFilenameRun->setEnabled(connected);
612 fLoggerFilenameRun->setText(d.
c_str()+4);
614 const uint32_t files = d.
get<uint32_t>();
616 SetLedColor(fLoggerLedLog, files&1 ? kLedGreen : kLedGray, d.
time);
617 SetLedColor(fLoggerLedRep, files&2 ? kLedGreen : kLedGray, d.
time);
618 SetLedColor(fLoggerLedFits, files&4 ? kLedGreen : kLedGray, d.
time);
623 const bool connected = d.
size()!=0;
625 fLoggerSubscriptions->setEnabled(connected);
626 fLoggerOpenFiles->setEnabled(connected);
630 const uint32_t *vals = d.
ptr<uint32_t>();
632 fLoggerSubscriptions->setValue(vals[0]);
633 fLoggerOpenFiles->setValue(vals[1]);
647 cerr <<
"Size mismatch in " << d.
name <<
": Found=" << d.
size() <<
" Expected=" << sz << endl;
660 const bool connected = d.
size()!=0;
662 fEvtBuilderET->setEnabled(connected);
663 fEvtBuilderRate->setEnabled(connected);
664 fEvtBuilderWritten->setEnabled(connected);
665 fEvtBuilderFreeSpace->setEnabled(connected);
666 fEvtBuilderSpaceLeft->setEnabled(connected);
668 fFreeSpaceData = UINT64_MAX;
669 UpdateGlobalStatus();
674 const uint64_t *vals = d.
ptr<uint64_t>();
676 const size_t space = vals[0];
677 const size_t written = vals[1];
678 const size_t rate = float(vals[2])/vals[3];
680 fFreeSpaceData = space;
681 UpdateGlobalStatus();
683 fEvtBuilderFreeSpace->setSuffix(
" MB");
684 fEvtBuilderFreeSpace->setDecimals(0);
685 fEvtBuilderFreeSpace->setValue(space*1e-6);
689 fEvtBuilderFreeSpace->setSuffix(
" GB");
690 fEvtBuilderFreeSpace->setDecimals(2);
691 fEvtBuilderFreeSpace->setValue(space*1e-9);
695 fEvtBuilderFreeSpace->setSuffix(
" GB");
696 fEvtBuilderFreeSpace->setDecimals(1);
697 fEvtBuilderFreeSpace->setValue(space*1e-9);
699 if (space>=100000000)
701 fEvtBuilderFreeSpace->setSuffix(
" GB");
702 fEvtBuilderFreeSpace->setDecimals(0);
703 fEvtBuilderFreeSpace->setValue(space*1e-9);
706 fEvtBuilderET->setTime(QTime().addSecs(rate>0?space/rate:0));
707 fEvtBuilderRate->setValue(rate*1e-3);
708 fEvtBuilderWritten->setValue(written*1e-6);
710 fEvtBuilderRate->setSuffix(
" kB/s");
711 fEvtBuilderRate->setDecimals(2);
712 fEvtBuilderRate->setValue(rate);
715 fEvtBuilderRate->setSuffix(
" kB/s");
716 fEvtBuilderRate->setDecimals(1);
717 fEvtBuilderRate->setValue(rate);
721 fEvtBuilderRate->setSuffix(
" kB/s");
722 fEvtBuilderRate->setDecimals(0);
723 fEvtBuilderRate->setValue(rate);
727 fEvtBuilderRate->setSuffix(
" MB/s");
728 fEvtBuilderRate->setDecimals(2);
729 fEvtBuilderRate->setValue(rate*1e-3);
733 fEvtBuilderRate->setSuffix(
" MB/s");
734 fEvtBuilderRate->setDecimals(1);
735 fEvtBuilderRate->setValue(rate*1e-3);
739 fEvtBuilderRate->setSuffix(
" MB/s");
740 fEvtBuilderRate->setDecimals(0);
741 fEvtBuilderRate->setValue(rate*1e-3);
744 if (space/1000000>static_cast<size_t>(fEvtBuilderSpaceLeft->maximum()))
745 fEvtBuilderSpaceLeft->setValue(fEvtBuilderSpaceLeft->maximum());
747 fEvtBuilderSpaceLeft->setValue(space/1000000);
757 cerr <<
"Size mismatch in " << d.
name <<
": Found=" << d.
size() <<
" Expected>=8" << endl;
761 const uint32_t *ptr = d.
ptr<uint32_t>();
763 fEvtBldLastOpened->setValue(ptr[0]);
764 fEvtBldLastClosed->setValue(ptr[1]);
767 fEvtBldFilename->setText(d.
ptr<
char>(8));
769 fEvtBldLastOpened->setEnabled(d.
qos);
770 fEvtBldLastClosed->setEnabled(d.
qos);
771 fEvtBldFilename->setEnabled(d.
qos);
776 if (!CheckSize(d, 16))
779 const int64_t *runs = d.
ptr<int64_t>();
781 fFadRunNoCur->setValue(runs[0]);
782 fFadRunNoNext->setValue(runs[1]);
783 fFadRunNoCur->setEnabled(runs[0]>=0);
790 if (!CheckSize(d, 16))
793 const uint32_t *ptr = d.
ptr<uint32_t>();
795 fEvtsSuccessCurRun->setValue(ptr[0]);
796 fEvtsSuccessTotal->setValue(ptr[1]);
797 fEvtBldEventId->setValue(ptr[2]);
798 fFadEvtCounter->setValue(ptr[2]);
799 fEvtBldTriggerId->setValue(ptr[3]);
806 fFadTempMin->setEnabled(
false);
807 fFadTempMax->setEnabled(
false);
808 SetLedColor(fFadLedTemp, kLedGray, d.
time);
812 if (!CheckSize(d,
sizeof(uint16_t)+160*
sizeof(
float)))
815 const float *ptr = d.
ptr<
float>(2);
817 fFadTempMin->setEnabled(
true);
818 fFadTempMax->setEnabled(
true);
821 float max = -FLT_MAX;
823 vector<float> mn(40, FLT_MAX);
824 vector<float> mx(40, -FLT_MAX);
825 for (
int i=0;
i<160;
i++)
841 fFadTempMin->setValue(min);
842 fFadTempMax->setValue(max);
844 handleFadToolTip(d.
time, fFadTempMin, mn.data());
845 handleFadToolTip(d.
time, fFadTempMax, mx.data());
852 fFadRefClockMin->setEnabled(
false);
853 fFadRefClockMax->setEnabled(
false);
854 SetLedColor(fFadLedRefClock, kLedGray, d.
time);
858 if (!CheckSize(d,
sizeof(uint16_t)+40*
sizeof(
float)))
861 const float *ptr = d.
ptr<
float>(2);
863 fFadRefClockMin->setEnabled(
true);
864 fFadRefClockMax->setEnabled(
true);
867 float max = -FLT_MAX;
868 for (
int i=0;
i<40;
i++)
879 fFadRefClockMin->setValue(min);
880 fFadRefClockMax->setValue(max);
882 const int64_t diff = int64_t(max) - int64_t(min);
884 SetLedColor(fFadLedRefClock, abs(diff)>3?kLedRed:kLedGreen, d.
time);
886 handleFadToolTip(d.
time, fFadLedRefClock, ptr);
893 fFadRoi->setEnabled(
false);
894 fFadRoiCh9->setEnabled(
false);
899 if (!CheckSize(d, 2*
sizeof(uint16_t)))
902 const uint16_t *ptr = d.
ptr<uint16_t>();
904 fFadRoi->setEnabled(
true);
905 fFadRoiCh9->setEnabled(
true);
907 fFadRoi->setValue(ptr[0]);
908 fFadRoiCh9->setValue(ptr[1]);
917 box->setEnabled(
false);
918 SetLedColor(led, kLedGray, d.
time);
922 const uint16_t *ptr = d.
ptr<uint16_t>()+idx*42;
924 box->setEnabled(
true);
925 box->setValue(ptr[40]==ptr[41]?ptr[40]:0);
927 SetLedColor(led, ptr[40]==ptr[41]?kLedGreen:kLedOrange, d.
time);
928 handleFadToolTip(d.
time, led, ptr);
933 if (!CheckSize(d, 8*42*
sizeof(uint16_t)) && !d.
size()==0)
936 handleDac(fFadLedDac0, fFadDac0, d, 0);
937 handleDac(fFadLedDac1, fFadDac1, d, 1);
938 handleDac(fFadLedDac2, fFadDac2, d, 2);
939 handleDac(fFadLedDac3, fFadDac3, d, 3);
940 handleDac(fFadLedDac4, fFadDac4, d, 4);
941 handleDac(fFadLedDac5, fFadDac5, d, 5);
942 handleDac(fFadLedDac6, fFadDac6, d, 6);
943 handleDac(fFadLedDac7, fFadDac7, d, 7);
950 for (Int_t
i=1;
i<=h.GetNbinsX();
i++)
952 if (h.GetBinContent(
i)<0.5 || h.GetBinContent(
i)>h.GetEntries()-0.5)
955 TBox * box=
new TBox(xmax, h.GetBinLowEdge(
i),
956 xmax+h.GetBinContent(
i)*scale,
957 h.GetBinLowEdge(
i+1));
959 box->SetFillStyle(0);
960 box->SetLineColor(h.GetLineColor());
961 box->SetLineStyle(kSolid);
962 box->SetBit(kCannotPick|kNoContextMenu);
965 hf->GetListOfFunctions()->Add(box);
975 TCanvas *c = fAdcDataCanv->GetCanvas();
977 TH1 *hf =
dynamic_cast<TH1*
>(c->FindObject(
"Frame"));
978 TH1 *h =
dynamic_cast<TH1*
>(c->FindObject(
"EventData"));
979 TH1 *d0 =
dynamic_cast<TH1*
>(c->FindObject(
"DrsCalib0"));
980 TH1 *d1 =
dynamic_cast<TH1*
>(c->FindObject(
"DrsCalib1"));
981 TH1 *d2 =
dynamic_cast<TH1*
>(c->FindObject(
"DrsCalib2"));
983 const int roi = fAdcPhysical->isChecked() ? 1024 : (fEventData->Roi>0 ? fEventData->Roi : 1);
985 if ((hf && hf->GetNbinsX()!=roi) ||
986 (dynamic_cast<TH2*>(h) && !fAdcPersistent->isChecked()) ||
987 (!dynamic_cast<TH2*>(h) && fAdcPersistent->isChecked()))
1002 hf =
new TH1F(
"Frame",
"", roi, -0.5, roi-0.5);
1003 hf->SetDirectory(0);
1004 hf->SetBit(kCanDelete);
1005 hf->SetStats(kFALSE);
1006 hf->SetYTitle(
"Voltage [mV]");
1007 hf->GetXaxis()->CenterTitle();
1008 hf->GetYaxis()->CenterTitle();
1009 hf->SetMinimum(-1250);
1010 hf->SetMaximum(2150);
1012 if (!fAdcPersistent->isChecked())
1013 h =
new TH1F(
"EventData",
"", roi, -0.5, roi-0.5);
1016 h =
new TH2F(
"EventData",
"", roi, -0.5, roi-0.5, 6751, -2350.5*2000/4096, 4400.5*2000/4096);
1018 gStyle->SetPalette(1, 0);
1022 h->SetBit(kCanDelete);
1023 h->SetMarkerStyle(kFullDotMedium);
1024 h->SetMarkerColor(
kBlue);
1026 c->GetListOfPrimitives()->Add(hf,
"");
1028 if (dynamic_cast<TH2*>(h))
1029 c->GetListOfPrimitives()->Add(h,
"col same");
1032 if (d0 && !(fDrsCalibBaselineOn->isChecked() && fDrsCalibBaseline->value()>0))
1037 if (d1 && !(fDrsCalibGainOn->isChecked() && fDrsCalibGain->value()>0))
1042 if (d2 && !(fDrsCalibTrgOffsetOn->isChecked() && fDrsCalibTrgOffset->value()>0))
1048 if (!d0 && fDrsCalibBaselineOn->isChecked() && fDrsCalibBaseline->value()>0)
1050 d0 =
new TH1F(
"DrsCalib0",
"", roi, -0.5, roi-0.5);
1051 d0->SetDirectory(0);
1052 d0->SetBit(kCanDelete);
1053 d0->SetMarkerStyle(kFullDotSmall);
1054 d0->SetMarkerColor(
kRed);
1055 d0->SetLineColor(
kRed);
1056 c->GetListOfPrimitives()->Add(d0,
"PEX0same");
1059 if (!d1 && fDrsCalibGainOn->isChecked() && fDrsCalibGain->value()>0)
1061 d1 =
new TH1F(
"DrsCalib1",
"", roi, -0.5, roi-0.5);
1062 d1->SetDirectory(0);
1063 d1->SetBit(kCanDelete);
1064 d1->SetMarkerStyle(kFullDotSmall);
1067 c->GetListOfPrimitives()->Add(d1,
"PEX0same");
1070 if (!d2 && fDrsCalibTrgOffsetOn->isChecked() && fDrsCalibTrgOffset->value()>0)
1072 d2 =
new TH1F(
"DrsCalib2",
"", roi, -0.5, roi-0.5);
1073 d2->SetDirectory(0);
1074 d2->SetBit(kCanDelete);
1075 d2->SetMarkerStyle(kFullDotSmall);
1076 d2->SetMarkerColor(
kGreen);
1077 d2->SetLineColor(
kGreen);
1078 c->GetListOfPrimitives()->Add(d2,
"PEX0same");
1081 if (!dynamic_cast<TH2*>(h) && !c->GetListOfPrimitives()->FindObject(h))
1082 c->GetListOfPrimitives()->Add(h,
"PLsame");
1087 fAdcChannel->value() +
1088 fAdcChip->value() * 9+
1089 fAdcBoard->value() * 36+
1090 fAdcCrate->value() *360;
1093 str <<
"CBPX = " << fAdcCrate->value() <<
'|' << fAdcBoard->value() <<
'|' << fAdcChip->value() <<
'|' << fAdcChannel->value() <<
" (" << p <<
")";
1094 str <<
" EventNum = " << fEventData->EventNum;
1095 str <<
" TriggerNum = " << fEventData->TriggerNum;
1096 str <<
" TriggerType = " << fEventData->TriggerType;
1097 str <<
" BoardTime = " << fEventData->BoardTime[fAdcBoard->value()+fAdcCrate->value()*10];
1098 str <<
" (" <<
Time(fEventData->PCTime, fEventData->PCUsec) <<
")";
1099 hf->SetTitle(str.str().c_str());
1101 str <<
"ADC Pipeline (start cell: " << fEventData->StartPix[p] <<
")";
1102 hf->SetXTitle(str.str().c_str());
1106 const int16_t
start = fEventData->StartPix[p];
1108 fDrsCalibBaseline->setEnabled(fDrsCalibBaseline->value()>0);
1109 fDrsCalibGain->setEnabled(fDrsCalibGain->value()>0);
1110 fDrsCalibTrgOffset->setEnabled(fDrsCalibTrgOffset->value()>0);
1111 fDrsCalibROI->setEnabled(fDrsCalibROI->value()>0);
1113 fDrsCalibBaseline2->setEnabled(fDrsCalibBaseline->value()>0);
1114 fDrsCalibGain2->setEnabled(fDrsCalibGain->value()>0);
1115 fDrsCalibTrgOffset2->setEnabled(fDrsCalibTrgOffset->value()>0);
1116 fDrsCalibROI2->setEnabled(fDrsCalibROI->value()>0);
1118 SetLedColor(fFadLedDrsBaseline, fDrsCalibBaseline->value()>0 ?kLedGreen:kLedGray,
Time());
1119 SetLedColor(fFadLedDrsGain, fDrsCalibGain->value()>0 ?kLedGreen:kLedGray,
Time());
1120 SetLedColor(fFadLedDrsTrgOff, fDrsCalibTrgOffset->value()>0?kLedGreen:kLedGray,
Time());
1129 if (!dynamic_cast<TH2*>(h))
1138 for (
int i=0;
i<fEventData->Roi;
i++)
1143 const int ii = fAdcPhysical->isChecked() ? (
i+
start)%1024 :
i;
1146 h->Fill(ii, reinterpret_cast<float*>(fEventData->Adc_Data)[p*fEventData->Roi+
i]);
1154 d0->SetBinContent(ii+1, fDrsCalibration[1440*1024*0 + p*1024+(start+
i)%1024]);
1155 d0->SetBinError(ii+1, fDrsCalibration[1440*1024*1 + p*1024+(start+
i)%1024]);
1160 d1->SetBinContent(ii+1, fDrsCalibration[1440*1024*2 + p*1024+(start+
i)%1024]);
1161 d1->SetBinError(ii+1, fDrsCalibration[1440*1024*3 + p*1024+(start+
i)%1024]);
1165 d2->SetBinContent(ii+1, fDrsCalibration[1440*1024*4 + p*1024 +
i]);
1166 d2->SetBinError(ii+1, fDrsCalibration[1440*1024*5 + p*1024 +
i]);
1171 if (fAdcDynamicScale->isEnabled() && fAdcDynamicScale->isChecked())
1176 hf->SetMinimum(h->GetMinimum());
1177 hf->SetMaximum(h->GetMaximum());
1179 if (fAdcManualScale->isEnabled() && fAdcManualScale->isChecked())
1181 if (h->GetMinimumStored()==-1111)
1183 h->SetMinimum(-1150);
1184 hf->SetMinimum(-1150);
1186 if (h->GetMaximumStored()==-1111)
1188 h->SetMaximum(2150);
1189 hf->SetMaximum(2150);
1193 if (fAdcAutoScale->isEnabled() && fAdcAutoScale->isChecked())
1198 if (h->GetMinimum()<hf->GetMinimum())
1199 hf->SetMinimum(h->GetMinimum());
1200 if (h->GetMaximum()>hf->GetMaximum())
1201 hf->SetMaximum(h->GetMaximum());
1204 if (dynamic_cast<TH2*>(h))
1212 const int imin = ceil(hf->GetMinimum());
1213 const int imax = floor(hf->GetMaximum());
1215 TH1S hd(
"",
"", imax-imin+1, imin-0.5, imax+0.5);
1217 TH1S h0(
"",
"", imax-imin+1, imin-0.5, imax+0.5);
1219 TH1S h1(
"",
"", imax-imin+1, imin-0.5, imax+0.5);
1221 TH1S h2(
"",
"", imax-imin+1, imin-0.5, imax+0.5);
1223 hd.SetLineColor(h->GetLineColor());
1225 h0.SetLineColor(d0->GetLineColor());
1227 h1.SetLineColor(d1->GetLineColor());
1229 h2.SetLineColor(d2->GetLineColor());
1231 for (
int i=0;
i<fEventData->Roi;
i++)
1233 if (!dynamic_cast<TH2*>(h))
1234 hd.Fill(h->GetBinContent(
i+1));
1236 h0.Fill(d0->GetBinContent(
i+1));
1238 h1.Fill(d1->GetBinContent(
i+1));
1240 h2.Fill(d2->GetBinContent(
i+1));
1243 double mm = hd.GetMaximum(hd.GetEntries());
1244 if (h0.GetMaximum(h0.GetEntries())>mm)
1245 mm = h0.GetMaximum();
1246 if (h1.GetMaximum(h1.GetEntries())>mm)
1247 mm = h1.GetMaximum();
1248 if (h2.GetMaximum(h2.GetEntries())>mm)
1249 mm = h2.GetMaximum();
1251 TIter Next(hf->GetListOfFunctions());
1253 while ((obj=Next()))
1254 if (dynamic_cast<TBox*>(obj))
1255 delete hf->GetListOfFunctions()->Remove(obj);
1257 const double l = h->GetBinLowEdge(h->GetXaxis()->GetLast()+1);
1258 const double m = c->GetX2();
1260 const double scale = 0.9*(m-l)/mm;
1262 DrawHorizontal(hf, l, h2, scale);
1263 DrawHorizontal(hf, l, h1, scale);
1264 DrawHorizontal(hf, l, h0, scale);
1265 DrawHorizontal(hf, l, hd, scale);
1279 if (fAdcStop->isChecked())
1282 const EVENT &dat = d.
ref<EVENT>();
1284 if (d.
size()<
sizeof(EVENT))
1286 cerr <<
"Size mismatch in " << d.
name <<
": Found=" << d.
size() <<
" Expected>=" <<
sizeof(EVENT) << endl;
1290 if (d.
size()!=
sizeof(EVENT)+dat.Roi*4*1440+dat.Roi*4*160)
1292 cerr <<
"Size mismatch in " << d.
name <<
": Found=" << d.
size() <<
" Expected=" << dat.Roi*4*1440+
sizeof(EVENT) <<
" [roi=" << dat.Roi <<
"]" << endl;
1296 delete []
reinterpret_cast<char*
>(fEventData);
1297 fEventData =
reinterpret_cast<EVENT*
>(
new char[d.
size()]);
1298 memcpy(fEventData, d.
ptr<
void>(), d.
size());
1305 if (!CheckSize(d, 4*1440*
sizeof(
float)))
1308 if (fEventsStop->isChecked())
1311 const float *ptr = d.
ptr<
float>();
1313 valarray<double> arr1(1440);
1314 valarray<double> arr2(1440);
1315 valarray<double> arr3(1440);
1316 valarray<double> arr4(1440);
1318 for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
1320 arr1[it->index] = ptr[0*1440+it->hw()];
1321 arr2[it->index] = ptr[1*1440+it->hw()];
1322 arr3[it->index] = ptr[2*1440+it->hw()];
1323 arr4[it->index] = ptr[3*1440+it->hw()];
1326 fEventCanv1->SetData(arr1);
1327 fEventCanv2->SetData(arr2);
1328 fEventCanv3->SetData(arr3);
1329 fEventCanv4->SetData(arr4);
1331 fEventCanv1->updateCamera();
1332 fEventCanv2->updateCamera();
1333 fEventCanv3->updateCamera();
1334 fEventCanv4->updateCamera();
1341 const size_t sz = 1024*1440*6+1024*160*2;
1345 fDrsCalibBaseline->setValue(-1);
1346 fDrsCalibGain->setValue(-1);
1347 fDrsCalibTrgOffset->setValue(-1);
1348 fDrsCalibROI->setValue(-1);
1350 fDrsCalibBaseline2->setValue(-1);
1351 fDrsCalibGain2->setValue(-1);
1352 fDrsCalibTrgOffset2->setValue(-1);
1353 fDrsCalibROI2->setValue(-1);
1355 fDrsCalibration.assign(sz, 0);
1360 if (!CheckSize(d, sz*
sizeof(
float)+4*
sizeof(uint32_t)))
1364 const uint32_t *
run = d.
ptr<uint32_t>();
1366 fDrsCalibROI->setValue(run[0]);
1367 fDrsCalibBaseline->setValue(run[1]);
1368 fDrsCalibGain->setValue(run[2]);
1369 fDrsCalibTrgOffset->setValue(run[3]);
1371 fDrsCalibROI2->setValue(run[0]);
1372 fDrsCalibBaseline2->setValue(run[1]);
1373 fDrsCalibGain2->setValue(run[2]);
1374 fDrsCalibTrgOffset2->setValue(run[3]);
1376 const float *dat = d.
ptr<
float>(
sizeof(uint32_t)*4);
1377 fDrsCalibration.assign(dat, dat+sz);
1386 if (!CheckSize(d, 41))
1388 fStatusEventBuilderLabel->setText(
"Offline");
1389 fStatusEventBuilderLabel->setToolTip(
"FADs or fadctrl seems to be offline.");
1390 fGroupEthernet->setEnabled(
false);
1391 fGroupOutput->setEnabled(
false);
1393 SetLedColor(fStatusEventBuilderLed, kLedGray, d.
time);
1397 const uint8_t *ptr = d.
ptr<uint8_t>();
1399 for (
int i=0;
i<40;
i++)
1401 const uint8_t stat1 = ptr[
i]&3;
1402 const uint8_t stat2 = ptr[
i]>>3;
1404 if (stat1==0 && stat2==0)
1406 SetLedColor(fFadLED[
i], kLedGray, d.
time);
1409 if (stat1>=2 && stat2==8)
1411 SetLedColor(fFadLED[
i], stat1==2?kLedGreen:kLedGreenCheck, d.
time);
1415 if (stat1==1 && stat2==1)
1416 SetLedColor(fFadLED[
i], kLedRed, d.
time);
1418 SetLedColor(fFadLED[i], kLedOrange, d.
time);
1422 const bool runs = ptr[40]!=0;
1424 fStatusEventBuilderLabel->setText(runs?
"Running":
"Not running");
1425 fStatusEventBuilderLabel->setToolTip(runs?
"Event builder thread running.":
"Event builder thread stopped.");
1427 fGroupEthernet->setEnabled(runs);
1428 fGroupOutput->setEnabled(runs);
1430 SetLedColor(fStatusEventBuilderLed, runs?kLedGreen:kLedRed, d.
time);
1435 template<
typename T>
1439 tip <<
"<table border='1'><tr><th colspan='11'>" << time.
GetAsStr() <<
" (UTC)</th></tr><tr><th></th>";
1440 for (
int b=0; b<10; b++)
1441 tip <<
"<th>" << b <<
"</th>";
1444 for (
int c=0; c<4; c++)
1446 tip <<
"<tr><th>" << c <<
"</th>";
1447 for (
int b=0; b<10; b++)
1448 tip <<
"<td>" << ptr[c*10+b] <<
"</td>";
1453 w->setToolTip(tip.str().c_str());
1456 template<
typename T,
class S>
1459 if (!CheckSize(d, 42*
sizeof(T)))
1462 const T *ptr = d.
ptr<T>();
1463 const T min = ptr[40];
1464 const T max = ptr[41];
1466 if (max==0 && min>max)
1467 SetLedColor(led, kLedGray, d.
time);
1469 SetLedColor(led, min==max?kLedGreen: kLedOrange, d.
time);
1471 if (!wmax && max!=min)
1474 wmin->setValue(min);
1477 wmax->setValue(max);
1479 handleFadToolTip(d.
time, led, ptr);
1484 handleFadMinMax<float, QDoubleSpinBox>(d, fFadLedFwVersion, fFadFwVersion);
1489 handleFadMinMax<uint32_t, QSpinBox>(d, fFadLedRunNumber, fFadRunNumber);
1494 handleFadMinMax<uint16_t, QSpinBox>(d, fFadLedPrescaler, fFadPrescaler);
1499 if (!CheckSize(d, 40*
sizeof(uint64_t)))
1502 const uint64_t *ptr = d.
ptr<uint64_t>();
1505 tip <<
"<table width='100%'>";
1506 tip <<
"<tr><th>Crate</th><td></td><th>Board</th><td></td><th>DNA</th></tr>";
1508 for (
int i=0;
i<40;
i++)
1512 tip <<
"<td align='center'>" <<
i/10 <<
"</td><td>:</td>";
1513 tip <<
"<td align='center'>" <<
i%10 <<
"</td><td>:</td>";
1515 tip <<
"<td>0x" << setfill(
'0') << setw(16) << ptr[
i] <<
"</td>";
1520 fFadDNA->setText(tip.str().c_str());
1527 SetLedColor(led, kLedGray, d.
time);
1531 const bool quality = d.
ptr<uint16_t>()[0]&bitmask;
1532 const bool value = d.
ptr<uint16_t>()[1]&bitmask;
1533 const uint16_t *ptr = d.
ptr<uint16_t>()+2;
1535 SetLedColor(led, quality?kLedOrange:(value^invert?kLedGreen:kLedGreenBar), d.
time);
1538 tip <<
"<table border='1'><tr><th colspan='11'>" << d.
time.
GetAsStr() <<
" (UTC)</th></tr><tr><th></th>";
1539 for (
int b=0; b<10; b++)
1540 tip <<
"<th>" << b <<
"</th>";
1550 for (
int c=0; c<4; c++)
1552 tip <<
"<tr><th>" << dec << c <<
"</th>" << hex;
1553 for (
int b=0; b<10; b++)
1556 << (ptr[c*10+b]&bitmask)
1563 led->setToolTip(tip.str().c_str());
1568 if (d.
size()!=0 && !CheckSize(d, 42*
sizeof(uint16_t)))
1571 SetFadLed(fFadLedDrsEnabled, d, FAD::EventHeader::kDenable);
1572 SetFadLed(fFadLedDrsWrite, d, FAD::EventHeader::kDwrite);
1573 SetFadLed(fFadLedDcmLocked, d, FAD::EventHeader::kDcmLocked);
1574 SetFadLed(fFadLedDcmReady, d, FAD::EventHeader::kDcmReady);
1575 SetFadLed(fFadLedSpiSclk, d, FAD::EventHeader::kSpiSclk);
1576 SetFadLed(fFadLedRefClockTooLow, d, FAD::EventHeader::kRefClkTooLow,
true);
1577 SetFadLed(fFadLedBusyOn, d, FAD::EventHeader::kBusyOn);
1578 SetFadLed(fFadLedBusyOff, d, FAD::EventHeader::kBusyOff);
1579 SetFadLed(fFadLedTriggerLine, d, FAD::EventHeader::kTriggerLine);
1580 SetFadLed(fFadLedContTrigger, d, FAD::EventHeader::kContTrigger);
1581 SetFadLed(fFadLedSocket, d, FAD::EventHeader::kSock17);
1582 SetFadLed(fFadLedPllLock, d, 0xf000);
1587 if (!CheckSize(d,
sizeof(GUI_STAT)))
1590 const GUI_STAT &stat = d.
ref<GUI_STAT>();
1592 fFadBufferMax->setValue(stat.totMem/1000000);
1593 fFadBuffer->setMaximum(stat.maxMem/100);
1594 fFadBuffer->setValue(stat.usdMem/100);
1599 for (
int i=0;
i<40;
i++)
1601 if (stat.numConn[
i]==1)
1603 sum += stat.rateBytes[
i];
1608 fFadEvtConn->setValue(cnt);
1610 fFadEvtBufNew->setValue(stat.bufNew);
1611 fFadEvtBufEvt->setValue(stat.bufTot);
1613 fFadEvtCheck->setValue(stat.bufEvt);
1614 fFadEvtWrite->setValue(stat.bufWrite);
1615 fFadEvtProc->setValue(stat.bufProc);
1622 fFadEthernetRateTot->setValue(sum/stat.deltaT);
1623 fFadEthernetRateAvg->setValue(cnt==0 ? 0 : sum/cnt/stat.deltaT);
1625 fFadTransmission->setValue(1000*stat.rateNew/stat.deltaT);
1626 fFadWriteRate->setValue(1000*stat.rateWrite/stat.deltaT);
1640 if (!CheckSize(d,
sizeof(uint16_t)))
1643 const uint16_t &fmt = d.
get<uint16_t>();
1645 SetLedColor(fFadLedFileFormatNone, fmt==
FAD::kNone ?kLedGreen:kLedGray, d.
time);
1646 SetLedColor(fFadLedFileFormatDebug, fmt==
FAD::kDebug?kLedGreen:kLedGray, d.
time);
1647 SetLedColor(fFadLedFileFormatRaw, fmt==
FAD::kRaw ?kLedGreen:kLedGray, d.
time);
1648 SetLedColor(fFadLedFileFormatFits, fmt==
FAD::kFits ?kLedGreen:kLedGray, d.
time);
1649 SetLedColor(fFadLedFileFormatZFits, fmt==
FAD::kZFits?kLedGreen:kLedGray, d.
time);
1650 SetLedColor(fFadLedFileFormatCalib, fmt==
FAD::kCalib?kLedGreen:kLedGray, d.
time);
1660 TCanvas *c = fFtmRateCanv->GetCanvas();
1662 TH1 *h = (TH1*)c->FindObject(
"TimeFrame");
1666 fGraphFtmRate.Set(0);
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");
1679 const double t1 = h->GetXaxis()->GetXmax();
1680 const double t0 = h->GetXaxis()->GetXmin();
1682 const double now = t0+sdata.
fTimeStamp/1000000.;
1684 h->SetBins(h->GetNbinsX()+1, t0, now+1);
1685 fGraphFtmRate.SetPoint(fGraphFtmRate.GetN(), now, sdata.
fTriggerRate);
1689 h->GetXaxis()->SetTimeFormat(
"%Hh%M'%F1995-01-01 00:00:00 GMT");
1690 h->GetXaxis()->SetTitle(
"Time");
1702 if (fThresholdIdx->value()>=0)
1704 const int isw = fThresholdIdx->value();
1705 const int ihw = fPatchMapHW[isw];
1710 const bool b = fBoardRatesEnabled->isChecked();
1712 valarray<double> dat(0., 1440);
1715 for (
int i=0;
i<1440;
i++)
1717 const int ihw = fPixelMap.
index(
i).
hw()/9;
1721 fRatesCanv->SetData(dat);
1722 fRatesCanv->updateCamera();
1729 UpdateRatesCam(fTriggerRates);
1741 TCanvas *c = fFtmRateCanv->GetCanvas();
1743 TH1 *h = (TH1*)c->FindObject(
"TimeFrame");
1745 const double tdiff = sdata.
fTimeStamp-fTimeStamp0;
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);
1759 const double t0 = h->GetXaxis()->GetXmin();
1761 for (
int i=0;
i<160;
i++)
1762 if (fFtuStatus[
i/4]>0)
1763 fGraphPatchRate[
i].SetPoint(fGraphPatchRate[
i].GetN(),
1765 for (
int i=0;
i<40;
i++)
1766 if (fFtuStatus[
i]>0)
1767 fGraphBoardRate[
i].SetPoint(fGraphBoardRate[
i].GetN(),
1782 fFtmTime->setText(QString::number(sdata.
fTimeStamp/1000000.,
'f', 6)+
" s");
1788 fTriggerCounterRate->setValue(0);
1797 fOnTimeRel->setValue(0);
1801 UpdateTriggerRate(sdata);
1802 UpdateRatesGraphs(sdata);
1803 UpdateRatesCam(sdata);
1805 fTriggerRates = sdata;
1810 if (!CheckSize(d,
sizeof(uint32_t)*6))
1813 const uint32_t *sdata = d.
ptr<uint32_t>();
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]);
1841 TCanvas *c = fFtmRateCanv->GetCanvas();
1843 TList * l = c->GetListOfPrimitives();
1846 while (c->FindObject(
"PatchRate"))
1847 l->Remove(c->FindObject(
"PatchRate"));
1849 while (c->FindObject(
"BoardRate"))
1850 l->Remove(c->FindObject(
"BoardRate"));
1852 if (fRatePatch1->value()>=0)
1854 fGraphPatchRate[fRatePatch1->value()].SetLineColor(
kRed);
1855 fGraphPatchRate[fRatePatch1->value()].SetMarkerColor(
kRed);
1856 l->Add(&fGraphPatchRate[fRatePatch1->value()],
"PL");
1858 if (fRatePatch2->value()>=0)
1860 fGraphPatchRate[fRatePatch2->value()].SetLineColor(
kGreen);
1861 fGraphPatchRate[fRatePatch2->value()].SetMarkerColor(
kGreen);
1862 l->Add(&fGraphPatchRate[fRatePatch2->value()],
"PL");
1864 if (fRateBoard1->value()>=0)
1866 fGraphBoardRate[fRateBoard1->value()].SetLineColor(
kMagenta);
1867 fGraphBoardRate[fRateBoard1->value()].SetMarkerColor(
kMagenta);
1868 l->Add(&fGraphBoardRate[fRateBoard1->value()],
"PL");
1870 if (fRateBoard2->value()>=0)
1872 fGraphBoardRate[fRateBoard2->value()].SetLineColor(
kCyan);
1873 fGraphBoardRate[fRateBoard2->value()].SetMarkerColor(
kCyan);
1874 l->Add(&fGraphBoardRate[fRateBoard2->value()],
"PL");
1886 if (counter==0 || counter>3)
1892 const LedColor_t col[4] = { kLedGray, kLedGreen, kLedOrange, kLedRed };
1894 SetLedColor(fFtuLED[idx], col[counter], t);
1901 const int max = fFtuStatus.max();
1906 SetLedColor(fStatusFTULed, kLedGray, t);
1907 fStatusFTULabel->setText(
"All disabled");
1908 fStatusFTULabel->setToolTip(
"All FTUs are disabled");
1912 SetLedColor(fStatusFTULed, kLedGreen, t);
1913 fStatusFTULabel->setToolTip(
"Communication with FTU is smooth.");
1914 fStatusFTULabel->setText(
"ok");
1918 SetLedColor(fStatusFTULed, kLedOrange, t);
1919 fStatusFTULabel->setText(
"Warning");
1920 fStatusFTULabel->setToolTip(
"At least one FTU didn't answer immediately");
1924 SetLedColor(fStatusFTULed, kLedRed, t);
1925 fStatusFTULabel->setToolTip(
"At least one FTU didn't answer!");
1926 fStatusFTULabel->setText(
"ERROR");
1930 const int cnt =
count(&fFtuStatus[0], &fFtuStatus[40], 0);
1931 fFtuAllOn->setEnabled(cnt!=0);
1932 fFtuAllOff->setEnabled(cnt!=40);
1965 const uint32_t Ndiv = (R15&0x1ffff00)<<2;
1966 const uint32_t Rdiv = (R14&0x007ff00)>>8;
1967 const uint32_t Cdiv = (R0 &0x000ff00)>>8;
1969 double freq = 40.*Ndiv/(Rdiv*Cdiv);
1971 fClockCondFreqRes->setValue(freq);
1974 fClockCondFreq->setCurrentIndex(0);
1983 fLpIntGroup1->setChecked(sdata.
HasLPintG1());
1984 fLpIntGroup2->setChecked(sdata.
HasLPintG2());
1985 fLpExtGroup1->setChecked(sdata.
HasLPextG1());
1986 fLpExtGroup2->setChecked(sdata.
HasLPextG2());
1988 fEnableTrigger->setChecked(sdata.
HasTrigger());
1989 fEnableVeto->setChecked(sdata.
HasVeto());
1990 fEnableExt1->setChecked(sdata.
HasExt1());
1991 fEnableExt2->setChecked(sdata.
HasExt2());
1996 for (
int i=0;
i<40;
i++)
1999 SetFtuLed(
i, -1, d.
time);
2002 if (fFtuStatus[
i]==0)
2003 SetFtuLed(
i, 1, d.
time);
2005 fFtuLED[
i]->setChecked(
false);
2011 SetFtuStatusLed(d.
time);
2013 fNoutof4Val->setValue(multiplicity);
2015 for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
2016 fRatesCanv->SetEnable(it->index, sdata.
IsEnabled(it->hw()));
2019 fPixelEnable->setChecked(sdata.
IsEnabled(entry.
hw()));
2021 if (fThresholdIdx->value()>=0)
2023 const int isw = fThresholdIdx->value();
2024 const int ihw = fPatchMapHW[isw];
2025 fThresholdVal->setValue(sdata.
fThreshold[ihw]);
2030 fFtmStaticData = sdata;
2040 stringstream str1, str2;
2041 str1 << hex <<
"0x" << setfill(
'0') << setw(16) << sdata.
fBoardId;
2044 fFtmBoardId->setText(str1.str().c_str());
2045 fFtmFirmwareId->setText(str2.str().c_str());
2053 fFtuPing->setChecked(
false);
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++)
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>";
2072 fFtuDNA->setText(str.str().c_str());
2074 fFtuAnswersTotal->setValue(sdata.
fNumBoards);
2080 for (
int i=0;
i<40;
i++)
2083 SetFtuStatusLed(d.
time);
2094 SetFtuStatusLed(d.
time);
2113 str << d.
time <<
" -- " << d.
get<
float>() <<
"s";
2115 box->setToolTip(str.str().c_str());
2116 box->setValue(d.
get<
float>(idx*4+4));
2122 const bool enable = d.
size()>0 && CheckSize(d, 60*
sizeof(
float));
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,
2135 fTempCrate0back, fTempCrate0front,
2136 fTempCrate1back, fTempCrate1front,
2137 fTempCrate2back, fTempCrate2front,
2138 fTempCrate3back, fTempCrate3front,
2140 fTempPS0back, fTempPS0front,
2141 fTempPS1back, fTempPS1front,
2142 fTempPS2back, fTempPS2front,
2143 fTempPS3back, fTempPS3front,
2145 fTempAuxFTMtop, fTempAuxFTMbottom,
2146 fTempAuxFSCtop, fTempAuxFSCbottom,
2148 fTempBackpanelFTMtop, fTempBackpanelFTMbottom,
2149 fTempBackpanelFSCtop, fTempBackpanelFSCbottom,
2151 fTempSwitchboxTopFront, fTempSwitchboxTopBack,
2152 fTempSwitchboxBottomFront, fTempSwitchboxBottomBack,
2155 for (
int i=0;
i<59;
i++)
2156 SetFscValue(boxes[
i], d, i, enable);
2161 const float *ptr = d.
ptr<
float>();
2165 for (
int i=1; i<32; i++)
2172 fTempCamAvg->setValue(num?avg/num:0);
2177 const bool enable = d.
size()>0 && CheckSize(d, 31*
sizeof(
float));
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,
2193 for (
int i=0;
i<30;
i++)
2194 SetFscValue(boxes[
i], d, i, enable);
2199 const bool enable = d.
size()>0 && CheckSize(d, 31*
sizeof(
float));
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,
2215 for (
int i=0;
i<30;
i++)
2216 SetFscValue(boxes[
i], d, i, enable);
2221 const bool enable = d.
size()>0 && CheckSize(d, 5*
sizeof(
float));
2223 SetFscValue(fHumidity1, d, 0, enable);
2224 SetFscValue(fHumidity2, d, 1, enable);
2225 SetFscValue(fHumidity3, d, 2, enable);
2226 SetFscValue(fHumidity4, d, 3, enable);
2232 TGraphErrors fGraphFeedbackDev;
2233 TGraphErrors fGraphFeedbackCmd;
2235 void UpdateFeedback(TQtWidget &rwidget,
const Time &
time, TGraphErrors &graph,
double avg,
double rms)
2237 TCanvas *c = rwidget.GetCanvas();
2239 TH1 *h = (TH1*)c->FindObject(
"TimeFrame");
2241 while (graph.GetN()>500)
2242 graph.RemovePoint(0);
2244 const double now = time.
RootTime();
2246 while (graph.GetN()>0 && now-graph.GetX()[0]>3600)
2247 graph.RemovePoint(0);
2249 const int n = graph.GetN();
2251 const double xmin = n>0 ? graph.GetX()[0] : now;
2253 h->SetBins(n+1, xmin-1, now+1);
2254 graph.SetPoint(n, now, avg);
2255 graph.SetPointError(n, 0, rms);
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");
2268 if (!CheckSize(d, (416+1+1+1+1+1+416+1+1)*
sizeof(
float)+
sizeof(uint32_t)))
2271 const float *ptr = d.
ptr<
float>();
2272 const float *Uov = ptr+416+6;
2274 fVecFeedbackCurrents.assign(ptr, ptr+416);
2276 valarray<double> datc(0., 1440);
2277 valarray<double> datu(0., 1440);
2280 for (
int i=0;
i<1440;
i++)
2284 datc[
i] = fVecFeedbackCurrents[entry.
hv()];
2285 datu[
i] = Uov[entry.
hv()];
2287 if (fVecBiasCurrent.size()>0)
2289 fBiasCamA->SetEnable(
i, uint16_t(fVecBiasCurrent[entry.
hv()])!=0x8000);
2290 fBiasCamA->highlightPixel(
i, fVecBiasCurrent[entry.
hv()]<0);
2294 fBiasCamA->SetData(datc);
2295 fBiasCamA->updateCamera();
2304 for (
int i=0;
i<320;
i++)
2307 rms += Uov[
i]*Uov[
i];
2312 rms = sqrt(rms-avg*avg);
2315 fFeedbackDevCam->SetData(datu);
2318 fFeedbackDevCam->updateCamera();
2322 UpdateFeedback(*fFeedbackDev, d.
time, fGraphFeedbackDev, avg, rms);
2329 TGraph fGraphRateScan[201];
2334 TCanvas *c = fRateScanCanv->GetCanvas();
2336 TH1 *h = (TH1*)c->FindObject(
"Frame");
2338 if (fGraphRateScan[0].GetN()==0 || th<fGraphRateScan[0].GetX()[fGraphRateScan[0].GetN()-1])
2340 h->SetBins(1, th<10 ? 0 : th-10, th+10);
2342 h->SetMaximum(rates[0]*2);
2344 for (
int i=0;
i<201;
i++)
2346 fGraphRateScan[
i].Set(0);
2347 fGraphRateScan[
i].SetPoint(fGraphRateScan[
i].GetN(), th, rates[
i]);
2358 const double dac = h->GetXaxis()->GetXmin();
2359 h->SetBins(h->GetNbinsX()+1, dac, th+10);
2361 for (
int i=0;
i<201;
i++)
2362 fGraphRateScan[
i].SetPoint(fGraphRateScan[
i].GetN(), th, rates[
i]);
2372 TCanvas *c = fRateScanCanv->GetCanvas();
2374 TList *l = c->GetListOfPrimitives();
2376 while (c->FindObject(
"PatchRate"))
2377 l->Remove(c->FindObject(
"PatchRate"));
2379 while (c->FindObject(
"BoardRate"))
2380 l->Remove(c->FindObject(
"BoardRate"));
2382 if (fRateScanPatch1->value()>=0)
2384 fGraphRateScan[fRateScanPatch1->value()+41].SetLineColor(
kRed);
2385 fGraphRateScan[fRateScanPatch1->value()+41].SetMarkerColor(
kRed);
2386 l->Add(&fGraphRateScan[fRateScanPatch1->value()+41],
"PL");
2388 if (fRateScanPatch2->value()>=0)
2390 fGraphRateScan[fRateScanPatch2->value()+41].SetLineColor(
kGreen);
2391 fGraphRateScan[fRateScanPatch2->value()+41].SetMarkerColor(
kGreen);
2392 l->Add(&fGraphRateScan[fRateScanPatch2->value()+41],
"PL");
2394 if (fRateScanBoard1->value()>=0)
2396 fGraphRateScan[fRateScanBoard1->value()+1].SetLineColor(
kMagenta);
2397 fGraphRateScan[fRateScanBoard1->value()+1].SetMarkerColor(
kMagenta);
2398 l->Add(&fGraphRateScan[fRateScanBoard1->value()+1],
"PL");
2400 if (fRateScanBoard2->value()>=0)
2402 fGraphRateScan[fRateScanBoard2->value()+1].SetLineColor(
kCyan);
2403 fGraphRateScan[fRateScanBoard2->value()+1].SetMarkerColor(
kCyan);
2404 l->Add(&fGraphRateScan[fRateScanBoard2->value()+1],
"PL");
2414 if (!CheckSize(d, 206*
sizeof(
float)))
2417 UpdateRateScan(d.
get<uint32_t>(8), d.
ptr<
float>(20));
2424 if (!CheckSize(d, 7*
sizeof(
float)+
sizeof(uint16_t)))
2427 const float *ptr = d.
ptr<
float>(2);
2429 fMagicTemp->setValue(ptr[0]);
2430 fMagicDew->setValue(ptr[1]);
2431 fMagicHum->setValue(ptr[2]);
2432 fMagicPressure->setValue(ptr[3]);
2433 fMagicWind->setValue(ptr[4]);
2434 fMagicGusts->setValue(ptr[5]);
2436 static const char *dir[] =
2438 "N",
"NNE",
"NE",
"ENE",
2439 "E",
"ESE",
"SE",
"SSE",
2440 "S",
"SSW",
"SW",
"WSW",
2441 "W",
"WNW",
"NW",
"NNW" 2444 const uint16_t
i = uint16_t(floor(fmod(ptr[6]+11.25, 360)/22.5));
2445 fMagicWindDir->setText(dir[i%16]);
2456 if (!CheckSize(d, 416*
sizeof(
float)))
2459 const float *ptr = d.
ptr<
float>();
2460 fVecBiasVolt.assign(ptr, ptr+416);
2462 on_fBiasDispRefVolt_stateChanged();
2467 if (!CheckSize(d, 2*416*
sizeof(int16_t)))
2470 const int16_t *ptr = d.
ptr<int16_t>();
2471 fVecBiasDac.assign(ptr, ptr+2*416);
2473 on_fBiasDispRefVolt_stateChanged();
2481 if (!CheckSize(d, 416*
sizeof(int16_t)))
2484 const int16_t *ptr = d.
ptr<int16_t>();
2486 fVecBiasCurrent.assign(ptr, ptr+416);
2488 valarray<double> dat(0., 1440);
2491 for (
int i=0;
i<1440;
i++)
2495 dat[
i] = abs(ptr[entry.
hv()]) * 5000./4096;
2497 fBiasCamA->SetEnable(
i, uint16_t(ptr[entry.
hv()])!=0x8000);
2498 fBiasCamA->highlightPixel(
i, ptr[entry.
hv()]<0);
2502 fBiasCamA->SetData(dat);
2504 fBiasCamA->updateCamera();
2520 fStatusMCPLabel->setText(s.
name.c_str());
2521 fStatusMCPLabel->setToolTip(s.
comment.c_str());
2524 SetLedColor(fStatusMCPLed, kLedGray, time);
2526 SetLedColor(fStatusMCPLed, kLedRed, time);
2528 SetLedColor(fStatusMCPLed, kLedOrange, time);
2530 SetLedColor(fStatusMCPLed, kLedYellow, time);
2532 SetLedColor(fStatusMCPLed, kLedGreen, time);
2535 SetLedColor(fStatusMCPLed, kLedGreenBar, time);
2542 if (server==
"FTM_CONTROL")
2545 fStatusFTMLabel->setText(s.
name.c_str());
2546 fStatusFTMLabel->setToolTip(s.
comment.c_str());
2548 bool enable =
false;
2549 const bool configuring =
2556 SetLedColor(fStatusFTMLed, kLedGray, time);
2558 SetLedColor(fStatusFTMLed, kLedYellow, time);
2563 SetLedColor(fStatusFTMLed, kLedGreen, time);
2565 SetLedColor(fStatusFTMLed, kLedGreenCheck, time);
2571 SetLedColor(fStatusFTMLed, kLedGreenWarn, time);
2574 fFtmStopRun->setEnabled(!configuring && !enable);
2576 fTriggerWidget->setEnabled(enable);
2577 fFtuGroupEnable->setEnabled(enable);
2578 fRatesControls->setEnabled(enable);
2582 SetFtuStatusLed(time);
2585 SetLedColor(fStatusFTULed, kLedGray, time);
2586 fStatusFTULabel->setText(
"Offline");
2587 fStatusFTULabel->setToolTip(
"FTM is not online.");
2591 if (server==
"FAD_CONTROL")
2593 fStatusFADLabel->setText(s.
name.c_str());
2594 fStatusFADLabel->setToolTip(s.
comment.c_str());
2596 bool enable =
false;
2598 if (s.
index<FAD::State::kOffline)
2600 SetLedColor(fStatusFADLed, kLedGray, time);
2614 if (s.
index==FAD::State::kOffline)
2615 SetLedColor(fStatusFADLed, kLedRed, time);
2617 SetLedColor(fStatusFADLed, kLedOrange, time);
2620 SetLedColor(fStatusFADLed, kLedYellow, time);
2626 SetLedColor(fStatusFADLed, kLedGreen, time);
2630 fFadWidget->setEnabled(enable);
2632 fFadStart->setEnabled (s.
index==FAD::State::kOffline);
2633 fFadStop->setEnabled (s.
index >FAD::State::kOffline);
2634 fFadAbort->setEnabled (s.
index >FAD::State::kOffline);
2635 fFadSoftReset->setEnabled(s.
index >FAD::State::kOffline);
2636 fFadHardReset->setEnabled(s.
index >FAD::State::kOffline);
2639 if (server==
"FSC_CONTROL")
2641 fStatusFSCLabel->setText(s.
name.c_str());
2642 fStatusFSCLabel->setToolTip(s.
comment.c_str());
2644 bool enable =
false;
2647 SetLedColor(fStatusFSCLed, kLedGray, time);
2649 SetLedColor(fStatusFSCLed, kLedRed, time);
2652 SetLedColor(fStatusFSCLed, kLedGreen, time);
2656 fAuxWidget->setEnabled(enable);
2659 if (server==
"DRIVE_CONTROL")
2661 fStatusDriveLabel->setText(s.
name.c_str());
2662 fStatusDriveLabel->setToolTip(s.
comment.c_str());
2665 SetLedColor(fStatusDriveLed, kLedGray, time);
2667 SetLedColor(fStatusDriveLed, kLedRed, time);
2670 SetLedColor(fStatusDriveLed, kLedGreenBar, time);
2672 SetLedColor(fStatusDriveLed, kLedGreen, time);
2674 SetLedColor(fStatusDriveLed, kLedInProgress, time);
2676 SetLedColor(fStatusDriveLed, kLedGreenCheck, time);
2678 SetLedColor(fStatusDriveLed, kLedGreenWarn, time);
2681 if (server==
"BIAS_CONTROL")
2683 fStatusBiasLabel->setText(s.
name.c_str());
2684 fStatusBiasLabel->setToolTip(s.
comment.c_str());
2687 SetLedColor(fStatusBiasLed, kLedGray, time);
2689 SetLedColor(fStatusBiasLed, kLedRed, time);
2691 SetLedColor(fStatusBiasLed, kLedOrange, time);
2693 SetLedColor(fStatusBiasLed, kLedGreenBar, time);
2695 SetLedColor(fStatusBiasLed, kLedGreenWarn, time);
2697 SetLedColor(fStatusBiasLed, kLedInProgress, time);
2699 SetLedColor(fStatusBiasLed, kLedGreenCheck, time);
2701 SetLedColor(fStatusBiasLed, kLedWarnBorder, time);
2703 SetLedColor(fStatusBiasLed, kLedWarnTriangleBorder, time);
2708 if (server==
"FEEDBACK")
2710 fStatusFeedbackLabel->setText(s.
name.c_str());
2711 fStatusFeedbackLabel->setToolTip(s.
comment.c_str());
2717 SetLedColor(fStatusFeedbackLed, kLedRed, time);
2719 SetLedColor(fStatusFeedbackLed, kLedGray, time);
2721 SetLedColor(fStatusFeedbackLed, kLedOrange, time);
2723 SetLedColor(fStatusFeedbackLed, kLedYellow, time);
2725 SetLedColor(fStatusFeedbackLed, kLedGreen, time);
2727 SetLedColor(fStatusFeedbackLed, kLedGreenCheck, time);
2729 SetLedColor(fStatusFeedbackLed, kLedInProgress, time);
2731 fFeedbackWidget->setEnabled(connected);
2736 fFeedbackOvervoltage->setEnabled(connected);
2740 fFeedbackFrameLeft->setEnabled(enable);
2741 fFeedbackCanvLeft->setEnabled(enable);
2743 fStateFeedback = s.
index;
2746 if (server==
"RATE_CONTROL")
2748 fStatusRateControlLabel->setText(s.
name.c_str());
2749 fStatusRateControlLabel->setToolTip(s.
comment.c_str());
2752 SetLedColor(fStatusRateControlLed, kLedGreenCheck, time);
2754 SetLedColor(fStatusRateControlLed, kLedGreen, time);
2756 SetLedColor(fStatusRateControlLed, kLedInProgress, time);
2758 SetLedColor(fStatusRateControlLed, kLedGreenBar, time);
2760 SetLedColor(fStatusRateControlLed, kLedOrange, time);
2762 SetLedColor(fStatusRateControlLed, kLedRed, time);
2764 SetLedColor(fStatusRateControlLed, kLedGray, time);
2767 if (server==
"DATA_LOGGER")
2769 fStatusLoggerLabel->setText(s.
name.c_str());
2770 fStatusLoggerLabel->setToolTip(s.
comment.c_str());
2775 SetLedColor(fStatusLoggerLed, kLedYellow, time);
2777 SetLedColor(fStatusLoggerLed, kLedGreen, time);
2780 SetLedColor(fStatusLoggerLed, kLedGray, time);
2784 SetLedColor(fStatusLoggerLed, kLedRed, time);
2786 SetLedColor(fStatusLoggerLed, kLedGreen, time);
2788 fLoggerWidget->setEnabled(enable);
2789 fLoggerStart->setEnabled(s.
index>-1 && s.
index<30);
2790 fLoggerStop->setEnabled(s.
index>=30);
2793 if (server==
"MAGIC_WEATHER")
2795 fStatusWeatherLabel->setText(s.
name.c_str());
2798 SetLedColor(fStatusWeatherLed, kLedGreen, time);
2800 SetLedColor(fStatusWeatherLed, kLedRed, time);
2802 SetLedColor(fStatusWeatherLed, kLedGray, time);
2807 fStatusChatLabel->setText(s.
name.c_str());
2809 fChatOnline = s.
index==0;
2811 SetLedColor(fStatusChatLed, fChatOnline ? kLedGreen : kLedGray, time);
2813 fChatSend->setEnabled(fChatOnline);
2814 fChatMessage->setEnabled(fChatOnline);
2817 if (server==
"RATESCAN")
2820 if (server==
"SCHEDULER")
2822 fStatusSchedulerLabel->setText(s.
name.c_str());
2824 SetLedColor(fStatusSchedulerLed, s.
index>=0 ? kLedGreen : kLedRed, time);
2830 if (fTabWidget->tabText(which)==
"Chat")
2831 fTabWidget->setTabIcon(which, QIcon());
2838 if (text.substr(0, 6)==
"CHAT: ")
2843 out <<
"<font size='-1' color='navy'>[<B>";
2845 out <<
"</B>]</FONT> " << text.substr(6);
2846 fChatText->append(out.str().c_str());
2848 if (fTabWidget->tabText(fTabWidget->currentIndex())==
"Chat")
2855 for (
int i=0;
i<fTabWidget->count();
i++)
2856 if (fTabWidget->tabText(
i)==
"Chat")
2858 fTabWidget->setTabIcon(
i, QIcon(
":/Resources/icons/warning 3.png"));
2866 out <<
"<font style='font-family:monospace' color='";
2870 case kMessage: out <<
"black";
break;
2871 case kInfo: out <<
"green";
break;
2872 case kWarn: out <<
"#FF6600";
break;
2873 case kError: out <<
"maroon";
break;
2874 case kFatal: out <<
"maroon";
break;
2875 case kDebug: out <<
"navy";
break;
2876 default: out <<
"navy";
break;
2879 out << time.
GetAsStr(
"%H:%M:%S.%f").substr(0,12);
2880 out <<
" - " << text <<
"</font>";
2882 fLogText->append(out.str().c_str());
2884 if (qos>=kWarn && qos!=
kDebug && qos!=kComment)
2885 fTextEdit->append(out.str().c_str());
2890 const State s = GetState(server, GetCurrentState(server));
2892 QApplication::postEvent(
this,
2898 QApplication::postEvent(
this,
2908 fDimSvcText->append(txt.c_str());
2916 const Converter conv(dummy, fmt,
false);
2921 out <<
"<font size'-1' color='navy'>[";
2922 out << tm.
GetAsStr(
"%H:%M:%S.%f").substr(0,12);
2923 out <<
"]</font> <B>" << info.
getName() <<
"</B> - ";
2928 out <<
"Compilation of format string '" << fmt <<
"' failed!";
2938 catch (
const runtime_error &e)
2940 out <<
"Conversion to string failed!<pre>" << e.what() <<
"</pre>";
2947 int bg = hash<string>()(
string(info.
getName()));
2950 bg = ~(bg&0x1f1f1f)&0xffffff;
2956 bgcol << hex << setfill(
'0') << setw(6) << bg;
2958 const string col = iserr==0 ?
"black" : (iserr==1 ?
"#FF6600" :
"black");
2959 const string str =
"<table width='100%' bgcolor=#"+bgcol.str()+
"><tr><td><font color='"+col+
"'>"+out.str()+
"</font></td></tr></table>";
2961 QApplication::postEvent(
this,
2990 QApplication::postEvent(
this, evt);
2997 getInfo()->getTimestamp();
2999 if (getInfo()==&fDimDNS)
3002 cout <<
"HandleDimInfo " << getInfo()->getName() << endl;
3004 if (getInfo()==&fDimLoggerStats)
3010 if (getInfo()==&fDimFadWriteStats)
3013 if (getInfo()==&fDimFadConnections)
3016 if (getInfo()==&fDimFadFwVersion)
3019 if (getInfo()==&fDimFadRunNumber)
3022 if (getInfo()==&fDimFadDNA)
3025 if (getInfo()==&fDimFadTemperature)
3028 if (getInfo()==&fDimFadRefClock)
3031 if (getInfo()==&fDimFadRoi)
3034 if (getInfo()==&fDimFadDac)
3037 if (getInfo()==&fDimFadDrsCalibration)
3040 if (getInfo()==&fDimFadPrescaler)
3043 if (getInfo()==&fDimFadStatus)
3046 if (getInfo()==&fDimFadStatistics1)
3052 if (getInfo()==&fDimFadFileFormat)
3055 if (getInfo()==&fDimFadEvents)
3058 if (getInfo()==&fDimFadRuns)
3061 if (getInfo()==&fDimFadStartRun)
3064 if (getInfo()==&fDimFadRawData)
3067 if (getInfo()==&fDimFadEventData)
3074 if (getInfo()==&fDimLoggerFilenameNight)
3077 if (getInfo()==&fDimLoggerNumSubs)
3080 if (getInfo()==&fDimLoggerFilenameRun)
3083 if (getInfo()==&fDimFtmTriggerRates)
3086 if (getInfo()==&fDimFtmCounter)
3089 if (getInfo()==&fDimFtmDynamicData)
3092 if (getInfo()==&fDimFtmPassport)
3095 if (getInfo()==&fDimFtmFtuList)
3098 if (getInfo()==&fDimFtmStaticData)
3101 if (getInfo()==&fDimFtmError)
3104 if (getInfo()==&fDimFscTemp)
3107 if (getInfo()==&fDimFscVolt)
3110 if (getInfo()==&fDimFscCurrent)
3113 if (getInfo()==&fDimFscHumidity)
3119 if (getInfo()==&fDimBiasVolt)
3122 if (getInfo()==&fDimBiasDac)
3125 if (getInfo()==&fDimBiasCurrent)
3128 if (getInfo()==&fDimFeedbackCalibrated)
3131 if (getInfo()==&fDimRateScan)
3134 if (getInfo()==&fDimMagicWeather)
3140 for (map<string,DimInfo*>::iterator
i=fServices.begin();
i!=fServices.end();
i++)
3141 if (
i->second==getInfo())
3143 infoHandlerService(*
i->second);
3155 if (dynamic_cast<FunctionEvent*>(evt))
3158 if (dynamic_cast<CheckBoxEvent*>(evt))
3161 const QStandardItem *par = item.parent();
3164 const QString server = par->text();
3165 const QString service = item.text();
3167 const string s = (server+
'/'+service).toStdString();
3169 if (item.checkState()==Qt::Checked)
3170 SubscribeService(s);
3172 UnsubscribeService(s);
3176 return MainWindow::event(evt);
3181 const QString server = fDimCmdServers->currentIndex().data().toString();
3182 const QString command = fDimCmdCommands->currentIndex().data().toString();
3183 const QString arguments = fDimCmdLineEdit->displayText();
3189 SendDimCommand(server.toStdString(), command.toStdString()+
" "+arguments.toStdString());
3190 fTextEdit->append(
"<font color='green'>Command '"+server+
'/'+command+
"' successfully emitted.</font>");
3191 fDimCmdLineEdit->clear();
3193 catch (
const runtime_error &e)
3199 while (getline(txt, buffer,
'\n'))
3200 fTextEdit->append((
"<font color='red'><pre>"+buffer+
"</pre></font>").c_str());
3205 void slot_RootEventProcessed(TObject *obj,
unsigned int evt, TCanvas *canv)
3215 if (dynamic_cast<TCanvas*>(obj))
3218 TQtWidget *tipped =
static_cast<TQtWidget*
>(sender());
3234 #if ROOT_VERSION_CODE > ROOT_VERSION(5,22,00) 3235 const char *objectInfo =
3236 obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());
3238 const char *objectInfo =
dynamic_cast<TH1*
>(obj) ?
3239 "" : obj->GetObjectInfo(tipped->GetEventX(),tipped->GetEventY());
3243 tipText += obj->GetName();
3245 tipText += obj->ClassName();
3247 tipText += objectInfo;
3249 fStatusBar->showMessage(tipText, 3000);
3252 gSystem->DispatchOneEvent(kFALSE);
3257 void slot_RootUpdate()
3259 gSystem->DispatchOneEvent(kFALSE);
3261 QTimer::singleShot(10,
this, SLOT(slot_RootUpdate()));
3269 fThresholdIdx->setValue(isw);
3271 const int ihw = isw<0 ? 0 : fPatchMapHW[isw];
3274 fThresholdCrate->setEnabled(isw>=0);
3275 fThresholdBoard->setEnabled(isw>=0);
3276 fThresholdPatch->setEnabled(isw>=0);
3281 const int patch = ihw%4;
3282 const int board = (ihw/4)%10;
3283 const int crate = (ihw/4)/10;
3285 fInChoosePatchTH =
true;
3287 fThresholdCrate->setValue(crate);
3288 fThresholdBoard->setValue(board);
3289 fThresholdPatch->setValue(patch);
3291 fInChoosePatchTH =
false;
3293 fThresholdVal->setValue(fFtmStaticData.
fThreshold[ihw]);
3305 fPixelIdx->setValue(isw);
3308 fPixelEnable->setChecked(fFtmStaticData.
IsEnabled(entry.
hw()));
3313 fPixelIdx->setValue(isw);
3324 tipText += fRatesCanv->GetName();
3326 str << setfill(
'0') <<
3327 " || HW: " << entry.
crate() <<
"|" << entry.
board() <<
"|" << entry.
patch() <<
"|" << entry.
pixel() <<
" (crate|board|patch|pixel)" <<
3328 " || HV: " << entry.
hv_board <<
"|" << setw(2) << entry.
hv_channel <<
" (board|channel)" <<
3332 tipText += str.str().c_str();
3333 fStatusBar->showMessage(tipText, 3000);
3339 for (; ii<160; ii++)
3340 if (fPixelMap.
index(isw).
hw()/9==fPatchMapHW[ii])
3343 fRatesCanv->SetWhite(isw);
3344 ChoosePatchThreshold(*fRatesCanv, ii);
3347 fPixelEnable->setChecked(fFtmStaticData.
IsEnabled(entry.
hw()));
3354 const int b = fBiasHvBoard->value();
3355 const int c = fBiasHvChannel->value();
3357 const int ihw = b*32+c;
3359 if (fVecBiasVolt.size()>0)
3361 fBiasVoltCur->setValue(fVecBiasVolt[ihw]);
3362 SetLedColor(fBiasNominalLed,
3363 fVecBiasDac[ihw]==fVecBiasDac[ihw+416]?kLedGreen:kLedRed,
Time());
3366 if (fVecBiasCurrent.size()>0)
3368 const double val = abs(fVecBiasCurrent[ihw]) * 5000./4096;
3369 fBiasCurrent->setValue(val);
3370 SetLedColor(fBiasOverCurrentLed,
3371 fVecBiasCurrent[ihw]<0?kLedRed:kLedGreen,
Time());
3375 fVecFeedbackCurrents.size()>0;
3377 fBiasCalibrated->setValue(calibrated ? fVecFeedbackCurrents[ihw] : 0);
3378 fBiasCalibrated->setEnabled(calibrated);
3383 fInChooseBiasCam =
true;
3385 fBiasCamCrate->setValue(entry.
crate());
3386 fBiasCamBoard->setValue(entry.
board());
3387 fBiasCamPatch->setValue(entry.
patch());
3388 fBiasCamPixel->setValue(entry.
pixel());
3390 fInChooseBiasCam =
false;
3395 if (fInChooseBiasHv)
3398 const int b = fBiasHvBoard->value();
3399 const int ch = fBiasHvChannel->value();
3403 fBiasCamV->SetWhite(entry.
index);
3404 fBiasCamA->SetWhite(entry.
index);
3405 fBiasCamV->updateCamera();
3406 fBiasCamA->updateCamera();
3408 UpdateBiasCam(entry);
3414 fInChooseBiasHv =
true;
3416 fBiasHvBoard->setValue(entry.
hv_board);
3419 fInChooseBiasHv =
false;
3424 if (fInChooseBiasCam)
3427 const int crate = fBiasCamCrate->value();
3428 const int board = fBiasCamBoard->value();
3429 const int patch = fBiasCamPatch->value();
3430 const int pixel = fBiasCamPixel->value();
3434 fBiasCamV->SetWhite(entry.
index);
3435 fBiasCamA->SetWhite(entry.
index);
3436 fBiasCamV->updateCamera();
3437 fBiasCamA->updateCamera();
3439 UpdateBiasHv(entry);
3447 UpdateBiasHv(entry);
3448 UpdateBiasCam(entry);
3456 valarray<double> dat(0., 1440);
3457 fBiasCamV->setTitle(
"Applied BIAS voltage");
3459 if (fVecBiasVolt.size()>0 && fVecBiasDac.size()>0)
3461 for (
int i=0;
i<1440;
i++)
3465 dat[
i] = fVecBiasVolt[entry.
hv()];
3466 fBiasCamV->highlightPixel(
i, fVecBiasDac[entry.
hv()]!=fVecBiasDac[entry.
hv()+416]);
3469 fBiasCamV->SetData(dat);
3472 fBiasCamV->updateCamera();
3485 "FTM_CONTROL/DISABLE_PIXEL" :
"FTM_CONTROL/ENABLE_PIXEL",
3486 uint16_t(entry.
hw()));
3497 const int16_t isw = fThresholdIdx->value();
3498 const int16_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
3507 const int16_t isw = fThresholdIdx->value();
3508 const int16_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
3517 const int16_t isw = fThresholdIdx->value();
3518 const int16_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
3527 fThresholdVolt->setValue(2500./4095*v);
3529 const int32_t isw = fThresholdIdx->value();
3530 const int32_t ihw = isw<0 ? -1 : fPatchMapHW[isw];
3532 const int32_t d[2] = { ihw, v };
3538 TGraph fGraphFtmTemp[4];
3540 TGraph fGraphPatchRate[160];
3541 TGraph fGraphBoardRate[40];
3544 TH1 *DrawTimeFrame(
const char *ytitle)
3548 TH1F *h=
new TH1F(
"TimeFrame",
"", 1, tm, tm+60);
3550 h->SetBit(kCanDelete);
3551 h->SetStats(kFALSE);
3554 h->SetXTitle(
"Time");
3555 h->SetYTitle(ytitle);
3556 h->GetXaxis()->CenterTitle();
3557 h->GetYaxis()->CenterTitle();
3558 h->GetXaxis()->SetTimeDisplay(
true);
3559 h->GetXaxis()->SetTimeFormat(
"%Mh%S'%F1995-01-01 00:00:00 GMT");
3560 h->GetXaxis()->SetLabelSize(0.025);
3561 h->GetYaxis()->SetLabelSize(0.025);
3562 h->GetYaxis()->SetTitleOffset(1.2);
3570 const size_t p = str.find_first_of(
'|');
3571 if (p==string::npos)
3572 return make_pair(str,
"");
3574 return make_pair(str.substr(0, p), str.substr(p+1));
3581 fInChoosePatchTH(false),
3582 fInChooseBiasHv(false), fInChooseBiasCam(false),
3583 fDimDNS(
"DIS_DNS/VERSION_NUMBER", 1, int(0), this),
3585 fDimLoggerStats (
"DATA_LOGGER/STATS", (void*)NULL, 0, this),
3586 fDimLoggerFilenameNight(
"DATA_LOGGER/FILENAME_NIGHTLY", (void*)NULL, 0, this),
3587 fDimLoggerFilenameRun (
"DATA_LOGGER/FILENAME_RUN", (void*)NULL, 0, this),
3588 fDimLoggerNumSubs (
"DATA_LOGGER/NUM_SUBS", (void*)NULL, 0, this),
3590 fDimFtmPassport (
"FTM_CONTROL/PASSPORT", (void*)NULL, 0, this),
3591 fDimFtmTriggerRates (
"FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, this),
3592 fDimFtmError (
"FTM_CONTROL/ERROR", (void*)NULL, 0, this),
3593 fDimFtmFtuList (
"FTM_CONTROL/FTU_LIST", (void*)NULL, 0, this),
3594 fDimFtmStaticData (
"FTM_CONTROL/STATIC_DATA", (void*)NULL, 0, this),
3595 fDimFtmDynamicData (
"FTM_CONTROL/DYNAMIC_DATA", (void*)NULL, 0, this),
3596 fDimFtmCounter (
"FTM_CONTROL/COUNTER", (void*)NULL, 0, this),
3598 fDimFadWriteStats (
"FAD_CONTROL/STATS", (void*)NULL, 0, this),
3599 fDimFadStartRun (
"FAD_CONTROL/START_RUN", (void*)NULL, 0, this),
3600 fDimFadRuns (
"FAD_CONTROL/RUNS", (void*)NULL, 0, this),
3601 fDimFadEvents (
"FAD_CONTROL/EVENTS", (void*)NULL, 0, this),
3602 fDimFadRawData (
"FAD_CONTROL/RAW_DATA", (void*)NULL, 0, this),
3603 fDimFadEventData (
"FAD_CONTROL/EVENT_DATA", (void*)NULL, 0, this),
3604 fDimFadConnections (
"FAD_CONTROL/CONNECTIONS", (void*)NULL, 0, this),
3605 fDimFadFwVersion (
"FAD_CONTROL/FIRMWARE_VERSION", (void*)NULL, 0, this),
3606 fDimFadRunNumber (
"FAD_CONTROL/RUN_NUMBER", (void*)NULL, 0, this),
3607 fDimFadDNA (
"FAD_CONTROL/DNA", (void*)NULL, 0, this),
3608 fDimFadTemperature (
"FAD_CONTROL/TEMPERATURE", (void*)NULL, 0, this),
3609 fDimFadPrescaler (
"FAD_CONTROL/PRESCALER", (void*)NULL, 0, this),
3610 fDimFadRefClock (
"FAD_CONTROL/REFERENCE_CLOCK", (void*)NULL, 0, this),
3611 fDimFadRoi (
"FAD_CONTROL/REGION_OF_INTEREST", (void*)NULL, 0, this),
3612 fDimFadDac (
"FAD_CONTROL/DAC", (void*)NULL, 0, this),
3613 fDimFadDrsCalibration (
"FAD_CONTROL/DRS_CALIBRATION", (void*)NULL, 0, this),
3614 fDimFadStatus (
"FAD_CONTROL/STATUS", (void*)NULL, 0, this),
3615 fDimFadStatistics1 (
"FAD_CONTROL/STATISTICS1", (void*)NULL, 0, this),
3617 fDimFadFileFormat (
"FAD_CONTROL/FILE_FORMAT", (void*)NULL, 0, this),
3619 fDimFscTemp (
"FSC_CONTROL/TEMPERATURE", (void*)NULL, 0, this),
3620 fDimFscVolt (
"FSC_CONTROL/VOLTAGE", (void*)NULL, 0, this),
3621 fDimFscCurrent (
"FSC_CONTROL/CURRENT", (void*)NULL, 0, this),
3622 fDimFscHumidity (
"FSC_CONTROL/HUMIDITY", (void*)NULL, 0, this),
3624 fDimFeedbackCalibrated (
"FEEDBACK/CALIBRATED_CURRENTS", (void*)NULL, 0, this),
3626 fDimBiasNominal (
"BIAS_CONTROL/NOMINAL", (void*)NULL, 0, this),
3627 fDimBiasVolt (
"BIAS_CONTROL/VOLTAGE", (void*)NULL, 0, this),
3628 fDimBiasDac (
"BIAS_CONTROL/DAC", (void*)NULL, 0, this),
3629 fDimBiasCurrent (
"BIAS_CONTROL/CURRENT", (void*)NULL, 0, this),
3631 fDimRateScan (
"RATE_SCAN/DATA", (void*)NULL, 0, this),
3633 fDimMagicWeather (
"MAGIC_WEATHER/DATA", (void*)NULL, 0, this),
3636 fFreeSpaceLogger(UINT64_MAX), fFreeSpaceData(UINT64_MAX),
3638 fDrsCalibration(1440*1024*6+160*1024*2),
3641 fClockCondFreq->addItem(
"--- Hz", QVariant(-1));
3642 fClockCondFreq->addItem(
"800 MHz", QVariant(800));
3643 fClockCondFreq->addItem(
"1 GHz", QVariant(1000));
3644 fClockCondFreq->addItem(
"2 GHz", QVariant(2000));
3645 fClockCondFreq->addItem(
"3 GHz", QVariant(3000));
3646 fClockCondFreq->addItem(
"4 GHz", QVariant(4000));
3647 fClockCondFreq->addItem(
"5 GHz", QVariant(5000));
3649 cout <<
"-- run counter ---" << endl;
3650 fMcpNumEvents->addItem(
"unlimited", QVariant(0));
3651 const vector<uint32_t> runcount = conf.
Vec<uint32_t>(
"run-count");
3652 for (vector<uint32_t>::const_iterator it=runcount.begin(); it!=runcount.end(); it++)
3654 cout << *it << endl;
3657 fMcpNumEvents->addItem(str.str().c_str(), QVariant(*it));
3660 cout <<
"-- run times ---" << endl;
3661 fMcpTime->addItem(
"unlimited", QVariant(0));
3662 const vector<string> runtime = conf.
Vec<
string>(
"run-time");
3663 for (vector<string>::const_iterator it=runtime.begin(); it!=runtime.end(); it++)
3665 const pair<string,string> p =
Split(*it);
3666 cout << *it <<
"|" << p.second <<
"|" << p.first <<
"|" << endl;
3667 fMcpTime->addItem(p.second.c_str(), QVariant(stoi(p.first)));
3670 cout <<
"-- run types ---" << endl;
3671 const vector<string> runtype = conf.
Vec<
string>(
"run-type");
3672 for (vector<string>::const_iterator it=runtype.begin(); it!=runtype.end(); it++)
3674 const pair<string,string> p =
Split(*it);
3675 cout << *it <<
"|" << p.second <<
"|" << p.first <<
"|" << endl;
3676 fMcpRunType->addItem(p.second.c_str(), QVariant(p.first.c_str()));
3679 fTriggerWidget->setEnabled(
false);
3680 fFtuWidget->setEnabled(
false);
3681 fFtuGroupEnable->setEnabled(
false);
3682 fRatesControls->setEnabled(
false);
3683 fFadWidget->setEnabled(
false);
3684 fGroupEthernet->setEnabled(
false);
3685 fGroupOutput->setEnabled(
false);
3686 fLoggerWidget->setEnabled(
false);
3687 fBiasWidget->setEnabled(
false);
3688 fAuxWidget->setEnabled(
false);
3690 fChatSend->setEnabled(
false);
3691 fChatMessage->setEnabled(
false);
3698 if (!fPixelMap.
Read(conf.
Get<
string>(
"pixel-map-file")))
3700 cerr <<
"ERROR - Problems reading " << conf.
Get<
string>(
"pixel-map-file") << endl;
3706 ifstream fin3(
"PatchList.txt");
3711 while (getline(fin3, buf,
'\n'))
3717 unsigned int softid, hardid;
3719 stringstream
str(buf);
3724 if (softid>=fPatchMapHW.size())
3727 fPatchMapHW[softid] = hardid-1;
3733 cerr <<
"WARNING - Problems reading PatchList.txt" << endl;
3737 fCommentsWidget->setEnabled(
false);
3739 static const boost::regex expr(
"(([[:word:].-]+)(:(.+))?@)?([[:word:].-]+)(:([[:digit:]]+))?(/([[:word:].-]+))");
3741 const string database = conf.
Get<
string>(
"CommentDB");
3743 if (!database.empty())
3746 if (!boost::regex_match(database, what, expr, boost::match_extra))
3747 throw runtime_error(
"Couldn't parse '"+database+
"'.");
3749 if (what.size()!=10)
3750 throw runtime_error(
"Error parsing '"+database+
"'.");
3752 const string user = what[2];
3753 const string passwd = what[4];
3754 const string server = what[5];
3755 const string db = what[9];
3756 const int port = atoi(
string(what[7]).c_str());
3758 QSqlDatabase qdb = QSqlDatabase::addDatabase(
"QMYSQL");
3759 qdb.setHostName(server.c_str());
3760 qdb.setDatabaseName(db.c_str());
3761 qdb.setUserName(user.c_str());
3762 qdb.setPassword(passwd.c_str());
3764 qdb.setConnectOptions(
"CLIENT_SSL=1;MYSQL_OPT_RECONNECT=1");
3767 QSqlTableModel *model =
new QSqlTableModel(fTableComments, qdb);
3768 model->setTable(
"runcomments");
3769 model->setEditStrategy(QSqlTableModel::OnManualSubmit);
3771 const bool ok2 = model->select();
3775 fTableComments->setModel(model);
3776 fTableComments->resizeColumnsToContents();
3777 fTableComments->resizeRowsToContents();
3779 connect(fCommentSubmit, SIGNAL(clicked()), model, SLOT(submitAll()));
3780 connect(fCommentRevert, SIGNAL(clicked()), model, SLOT(revertAll()));
3781 connect(fCommentUpdateLayout, SIGNAL(clicked()), fTableComments, SLOT(resizeColumnsToContents()));
3782 connect(fCommentUpdateLayout, SIGNAL(clicked()), fTableComments, SLOT(resizeRowsToContents()));
3784 fCommentsWidget->setEnabled(
true);
3787 cout <<
"\n==> ERROR: Select on table failed.\n" << endl;
3790 cout <<
"\n==> ERROR: Connection to database failed:\n " 3791 << qdb.lastError().text().toStdString() << endl << endl;
3797 fGraphFeedbackDev.SetLineColor(
kBlue);
3798 fGraphFeedbackDev.SetMarkerColor(
kBlue);
3799 fGraphFeedbackDev.SetMarkerStyle(kFullDotMedium);
3801 fGraphFeedbackCmd.SetLineColor(
kBlue);
3802 fGraphFeedbackCmd.SetMarkerColor(
kBlue);
3803 fGraphFeedbackCmd.SetMarkerStyle(kFullDotMedium);
3807 fGraphFeedbackDev.SetName(
"ControlDev");
3808 fGraphFeedbackCmd.SetName(
"CommandVal");
3810 TCanvas *c = fFeedbackDev->GetCanvas();
3811 c->SetBorderMode(0);
3812 c->SetFrameBorderMode(0);
3814 c->SetRightMargin(0.03);
3815 c->SetTopMargin(0.03);
3818 TH1 *hf = DrawTimeFrame(
"Overvoltage [V] ");
3819 hf->GetXaxis()->SetLabelSize(0.07);
3820 hf->GetYaxis()->SetLabelSize(0.07);
3821 hf->GetYaxis()->SetTitleSize(0.08);
3822 hf->GetYaxis()->SetTitleOffset(0.55);
3823 hf->GetXaxis()->SetTitle(
"");
3824 hf->GetYaxis()->SetRangeUser(0, 1.5);
3826 c->GetListOfPrimitives()->Add(hf,
"");
3827 c->GetListOfPrimitives()->Add(&fGraphFeedbackDev,
"LP");
3829 c = fFeedbackCmd->GetCanvas();
3830 c->SetBorderMode(0);
3831 c->SetFrameBorderMode(0);
3833 c->SetRightMargin(0.03);
3834 c->SetTopMargin(0.03);
3837 hf = DrawTimeFrame(
"Command temp delta [V] ");
3838 hf->GetXaxis()->SetLabelSize(0.07);
3839 hf->GetYaxis()->SetLabelSize(0.07);
3840 hf->GetYaxis()->SetTitleSize(0.08);
3841 hf->GetYaxis()->SetTitleOffset(0.55);
3842 hf->GetXaxis()->SetTitle(
"");
3843 hf->GetYaxis()->SetRangeUser(-2, 2);
3845 c->GetListOfPrimitives()->Add(hf,
"");
3846 c->GetListOfPrimitives()->Add(&fGraphFeedbackCmd,
"LP");
3850 c = fRateScanCanv->GetCanvas();
3852 c->SetBorderMode(0);
3853 c->SetFrameBorderMode(0);
3855 c->SetRightMargin(0.03);
3856 c->SetTopMargin(0.03);
3859 TH1F *h=
new TH1F(
"Frame",
"", 1, 0, 1);
3861 h->SetBit(kCanDelete);
3862 h->SetStats(kFALSE);
3863 h->SetXTitle(
"Threshold [DAC]");
3864 h->SetYTitle(
"Rate [Hz]");
3865 h->GetXaxis()->CenterTitle();
3866 h->GetYaxis()->CenterTitle();
3867 h->GetXaxis()->SetLabelSize(0.025);
3868 h->GetYaxis()->SetLabelSize(0.025);
3869 h->GetYaxis()->SetTitleOffset(1.2);
3870 c->GetListOfPrimitives()->Add(h,
"");
3872 fGraphRateScan[0].SetName(
"CameraRate");
3873 for (
int i=0;
i<40;
i++)
3875 fGraphRateScan[
i+1].SetName(
"BoardRate");
3876 fGraphRateScan[
i+1].SetMarkerStyle(kFullDotMedium);
3878 for (
int i=0;
i<160;
i++)
3880 fGraphRateScan[
i+41].SetName(
"PatchRate");
3881 fGraphRateScan[
i+41].SetMarkerStyle(kFullDotMedium);
3884 fGraphRateScan[0].SetLineColor(
kBlue);
3885 fGraphRateScan[0].SetMarkerColor(
kBlue);
3886 fGraphRateScan[0].SetMarkerStyle(kFullDotSmall);
3887 c->GetListOfPrimitives()->Add(&fGraphRateScan[0],
"LP");
3891 c = fFtmRateCanv->GetCanvas();
3893 c->SetBorderMode(0);
3894 c->SetFrameBorderMode(0);
3896 c->SetRightMargin(0.03);
3897 c->SetTopMargin(0.03);
3900 hf = DrawTimeFrame(
"Trigger rate [Hz]");
3901 hf->GetYaxis()->SetRangeUser(0, 1010);
3903 for (
int i=0;
i<160;
i++)
3905 fGraphPatchRate[
i].SetName(
"PatchRate");
3908 fGraphPatchRate[
i].SetMarkerStyle(kFullDotMedium);
3910 for (
int i=0;
i<40;
i++)
3912 fGraphBoardRate[
i].SetName(
"BoardRate");
3915 fGraphBoardRate[
i].SetMarkerStyle(kFullDotMedium);
3918 fGraphFtmRate.SetLineColor(
kBlue);
3919 fGraphFtmRate.SetMarkerColor(
kBlue);
3920 fGraphFtmRate.SetMarkerStyle(kFullDotSmall);
3922 c->GetListOfPrimitives()->Add(hf,
"");
3923 c->GetListOfPrimitives()->Add(&fGraphFtmRate,
"LP");
3937 fGraphFtmTemp[0].SetMarkerStyle(kFullDotSmall);
3938 fGraphFtmTemp[1].SetMarkerStyle(kFullDotSmall);
3939 fGraphFtmTemp[2].SetMarkerStyle(kFullDotSmall);
3940 fGraphFtmTemp[3].SetMarkerStyle(kFullDotSmall);
3942 fGraphFtmTemp[1].SetLineColor(
kBlue);
3943 fGraphFtmTemp[2].SetLineColor(
kRed);
3944 fGraphFtmTemp[3].SetLineColor(
kGreen);
3946 fGraphFtmTemp[1].SetMarkerColor(
kBlue);
3947 fGraphFtmTemp[2].SetMarkerColor(
kRed);
3948 fGraphFtmTemp[3].SetMarkerColor(
kGreen);
3957 c = fAdcDataCanv->GetCanvas();
3959 c->SetBorderMode(0);
3960 c->SetFrameBorderMode(0);
3962 c->SetRightMargin(0.10);
3968 fFeedbackDevCam->assignPixelMap(fPixelMap);
3969 fFeedbackDevCam->setAutoscaleLowerLimit((fFeedbackDevMin->minimum()+0.5*fFeedbackDevMin->singleStep()));
3970 fFeedbackDevCam->SetMin(fFeedbackDevMin->value());
3971 fFeedbackDevCam->SetMax(fFeedbackDevMax->value());
3972 fFeedbackDevCam->updateCamera();
3974 fFeedbackCmdCam->assignPixelMap(fPixelMap);
3975 fFeedbackCmdCam->setAutoscaleLowerLimit((fFeedbackCmdMin->minimum()+0.5*fFeedbackCmdMin->singleStep()));
3976 fFeedbackCmdCam->SetMin(fFeedbackCmdMin->value());
3977 fFeedbackCmdCam->SetMax(fFeedbackCmdMax->value());
3978 fFeedbackCmdCam->updateCamera();
3982 fBiasCamV->assignPixelMap(fPixelMap);
3983 fBiasCamV->setAutoscaleLowerLimit((fBiasVoltMin->minimum()+0.5*fBiasVoltMin->singleStep()));
3984 fBiasCamV->SetMin(fBiasVoltMin->value());
3985 fBiasCamV->SetMax(fBiasVoltMax->value());
3986 fBiasCamV->updateCamera();
3988 fBiasCamA->assignPixelMap(fPixelMap);
3989 fBiasCamA->setAutoscaleLowerLimit((fBiasCurrentMin->minimum()+0.5*fBiasCurrentMin->singleStep()));
3990 fBiasCamA->SetMin(fBiasCurrentMin->value());
3991 fBiasCamA->SetMax(fBiasCurrentMax->value());
3992 fBiasCamA->updateCamera();
3996 fRatesCanv->assignPixelMap(fPixelMap);
3997 fRatesCanv->setAutoscaleLowerLimit((fRatesMin->minimum()+0.5*fRatesMin->singleStep())*0.001);
3998 fRatesCanv->SetMin(fRatesMin->value());
3999 fRatesCanv->SetMax(fRatesMax->value());
4000 fRatesCanv->updateCamera();
4001 on_fPixelIdx_valueChanged(0);
4005 fRatesCanv->setTitle(
"Patch rates");
4006 fRatesCanv->setUnits(
"Hz");
4008 fBiasCamA->setTitle(
"BIAS current");
4009 fBiasCamA->setUnits(
"uA");
4011 fBiasCamV->setTitle(
"Applied BIAS voltage");
4012 fBiasCamV->setUnits(
"V");
4014 fEventCanv1->setTitle(
"Average (all slices)");
4015 fEventCanv2->setTitle(
"RMS (all slices)");
4016 fEventCanv3->setTitle(
"Maximum (all slices)");
4017 fEventCanv4->setTitle(
"Position of maximum (all slices)");
4019 fEventCanv1->setUnits(
"mV");
4020 fEventCanv2->setUnits(
"mV");
4021 fEventCanv3->setUnits(
"mV");
4022 fEventCanv4->setUnits(
"slice");
4026 fFeedbackDevCam->setTitle(
"Control deviation (Pulser amplitude voltage)");
4027 fFeedbackCmdCam->setTitle(
"Applied voltage change (BIAS voltage)");
4029 fFeedbackDevCam->setUnits(
"mV");
4030 fFeedbackCmdCam->setUnits(
"mV");
4034 QTimer::singleShot(1000,
this, SLOT(slot_RootUpdate()));
4039 fFtmRateCanv->setMouseTracking(
true);
4040 fFtmRateCanv->EnableSignalEvents(kMouseMoveEvent);
4042 fAdcDataCanv->setMouseTracking(
true);
4043 fAdcDataCanv->EnableSignalEvents(kMouseMoveEvent);
4045 fRatesCanv->setMouseTracking(
true);
4046 fEventCanv1->setMouseTracking(
true);
4047 fEventCanv2->setMouseTracking(
true);
4048 fEventCanv3->setMouseTracking(
true);
4049 fEventCanv4->setMouseTracking(
true);
4051 fBiasCamV->setMouseTracking(
true);
4052 fBiasCamA->setMouseTracking(
true);
4054 fFeedbackDevCam->setMouseTracking(
true);
4055 fFeedbackCmdCam->setMouseTracking(
true);
4057 fEventCanv1->ShowPixelCursor(
true);
4058 fEventCanv2->ShowPixelCursor(
true);
4059 fEventCanv3->ShowPixelCursor(
true);
4060 fEventCanv4->ShowPixelCursor(
true);
4062 fEventCanv1->ShowPatchCursor(
true);
4063 fEventCanv2->ShowPatchCursor(
true);
4064 fEventCanv3->ShowPatchCursor(
true);
4065 fEventCanv4->ShowPatchCursor(
true);
4067 fFeedbackDevCam->ShowPixelCursor(
true);
4068 fFeedbackCmdCam->ShowPixelCursor(
true);
4070 fFeedbackDevCam->ShowPatchCursor(
true);
4071 fFeedbackCmdCam->ShowPatchCursor(
true);
4073 connect(fRatesCanv, SIGNAL(signalPixelMoveOver(
int)),
4074 this, SLOT(slot_CameraMouseMove(
int)));
4075 connect(fEventCanv1, SIGNAL(signalPixelMoveOver(
int)),
4076 this, SLOT(slot_CameraMouseMove(
int)));
4077 connect(fEventCanv2, SIGNAL(signalPixelMoveOver(
int)),
4078 this, SLOT(slot_CameraMouseMove(
int)));
4079 connect(fEventCanv3, SIGNAL(signalPixelMoveOver(
int)),
4080 this, SLOT(slot_CameraMouseMove(
int)));
4081 connect(fEventCanv4, SIGNAL(signalPixelMoveOver(
int)),
4082 this, SLOT(slot_CameraMouseMove(
int)));
4084 connect(fBiasCamV, SIGNAL(signalPixelMoveOver(
int)),
4085 this, SLOT(slot_CameraMouseMove(
int)));
4086 connect(fBiasCamA, SIGNAL(signalPixelMoveOver(
int)),
4087 this, SLOT(slot_CameraMouseMove(
int)));
4089 connect(fFeedbackDevCam, SIGNAL(signalPixelMoveOver(
int)),
4090 this, SLOT(slot_CameraMouseMove(
int)));
4091 connect(fFeedbackCmdCam, SIGNAL(signalPixelMoveOver(
int)),
4092 this, SLOT(slot_CameraMouseMove(
int)));
4094 connect(fRatesCanv, SIGNAL(signalPixelDoubleClick(
int)),
4095 this, SLOT(slot_CameraDoubleClick(
int)));
4096 connect(fRatesCanv, SIGNAL(signalCurrentPixel(
int)),
4097 this, SLOT(slot_ChoosePixelThreshold(
int)));
4098 connect(fBiasCamV, SIGNAL(signalCurrentPixel(
int)),
4099 this, SLOT(slot_ChooseBiasChannel(
int)));
4100 connect(fBiasCamA, SIGNAL(signalCurrentPixel(
int)),
4101 this, SLOT(slot_ChooseBiasChannel(
int)));
4103 connect(fFtmRateCanv, SIGNAL( RootEventProcessed(TObject*,
unsigned int, TCanvas*)),
4104 this, SLOT (slot_RootEventProcessed(TObject*,
unsigned int, TCanvas*)));
4105 connect(fAdcDataCanv, SIGNAL( RootEventProcessed(TObject*,
unsigned int, TCanvas*)),
4106 this, SLOT (slot_RootEventProcessed(TObject*,
unsigned int, TCanvas*)));
4112 for (map<string,DimInfo*>::iterator
i=fServices.begin();
4113 i!=fServices.end();
i++)
4117 delete [] reinterpret_cast<char*>(fEventData);
void handleFadWriteStats(const DimData &d)
void UpdateRateScan(uint32_t th, const float *rates)
vector< float > fVecFeedbackCurrents
void handleStateChanged(const Time &time, const string &server, const State &s)
void UpdateTriggerRate(const FTM::DimTriggerRates &sdata)
static int sendCommand(const char *name, int data)
void handleFadStatistics1(const DimData &d)
void handleFscVolt(const DimData &d)
FTM::DimStaticData fFtmStaticData
DimStampedInfo fDimFadDNA
int crate() const
Bias supply channel.
DimStampedInfo fDimLoggerStats
DimStampedInfo fDimFtmStaticData
void handleFadPrescaler(const DimData &d)
DimStampedInfo fDimFadRawData
void handleFadRunNumber(const DimData &d)
void handleFtmFtuList(const DimData &d)
void on_fThresholdDisableOthers_clicked()
void PostInfoHandler(void(FactGui::*handler)(const DimData &))
void infoHandlerService(DimInfo &info)
DimStampedInfo fDimFeedbackCalibration
void slot_CameraDoubleClick(int isw)
const PixelMapEntry & cbpx(int c) const
DimStampedInfo fDimFadDrsCalibration
std::string comment
Name (e.g. 'Connected')
void handleRemoveAllServices(const string &server)
void handleAddService(const string &server, const string &service, const string &, bool iscmd, const vector< Description > &vec)
vector< float > fVecBiasVolt
void on_fBoardRatesEnabled_toggled(bool)
void handleFadDac(const DimData &d)
void handleAddServer(const string &server, const State &state)
void handleAddDescription(const string &server, const string &service, const vector< Description > &vec, bool iscmd)
bool CheckSize(const DimData &d, size_t sz, bool print=true) const
void handleDimService(const string &txt)
DimStampedInfo fDimFeedbackCalibrated
void UpdateBiasHv(const PixelMapEntry &entry)
void on_fBiasDispRefVolt_stateChanged(int=0)
DimStampedInfo fDimBiasVolt
Adds some functionality to boost::posix_time::ptime for our needs.
void AddServer(const string &s)
T Get(const std::string &var)
uint8_t fIntensityLPext
Intensity of LEDs (0-127)
void handleLoggerFilenameRun(const DimData &d)
int Write(const Time &time, const string &txt, int qos)
void SetFtuStatusLed(const Time &t)
void slot_ChoosePixelThreshold(int isw)
void handleFtmTriggerRates(const DimData &d)
void handleFadStartRun(const DimData &d)
void on_fPixelDisableOthers_clicked()
void handleFtmPassport(const DimData &d)
uint8_t fPing[40]
Address of FTU board.
uint32_t fClockConditioner[8]
void AddDescription(QStandardItem *item, const vector< Description > &vec)
DimStampedInfo fDimFadRunNumber
void on_fThresholdVal_valueChanged(int v)
void CallInfoHandler(void(FactGui::*handler)(const DimData &), const DimData &d)
void handleLoggerNumSubs(const DimData &d)
uint16_t fMultiplicityPhysics
Intensity of LEDs (0-127)
pair< string, string > Split(const string &str) const
uint8_t fIntensityLPint
Enable for LED group 1/2 (LightPulserEnable)
DimStampedInfo fDimFscCurrent
std::vector< T > Vec(const std::string &var)
DimStampedInfo fDimFadFileFormat
DimStampedInfo fDimFtmTriggerRates
void handleFadToolTip(const Time &time, QWidget *w, T *ptr)
void on_fThresholdEnablePatch_clicked()
void handleDac(QPushButton *led, QSpinBox *box, const DimData &d, int idx)
DimStampedInfo fDimBiasDac
DimStampedInfo fDimFadStartRun
void ChoosePatchThreshold(Camera &cam, int isw)
void handleFadRawData(const DimData &d)
std::string GetString(std::stringstream &line) const
int getTimestampMillisecs()
DimStampedInfo fDimFadStatistics1
DimStampedInfo fDimFtmFtuList
void handleFadFileFormat(const DimData &d)
QStandardItem * AddServiceItem(const string &server, const string &service, bool iscmd)
void SetLedColor(QPushButton *button, LedColor_t col, const Time &t)
void handleRateScan(const DimData &d)
void AddDescription(const string &server, const string &service, const vector< Description > &vec)
uint16_t fDelayTimeMarker
void handleFadEventData(const DimData &d)
DimStampedInfo fDimRateScan
void UpdateRatesGraphs(const FTM::DimTriggerRates &sdata)
FTM::DimTriggerRates fTriggerRates
void AddService(const string &server, const string &service, const string &fmt, bool iscmd)
DimStampedInfo fDimFtmCounter
DimStampedInfo fDimBiasNominal
void handleFadDrsCalibration(const DimData &d)
void handleFeedbackCalibratedCurrents(const DimData &d)
void DrawHorizontal(TH1 *hf, double xmax, TH1 &h, double scale)
void SetFscValue(QDoubleSpinBox *box, const DimData &d, int idx, bool enable)
uint8_t fNumBoardsCrate[4]
Number of boards answered in total.
DimStampedInfo fDimFadWriteStats
void handleWrite(const Time &time, const string &text, int qos)
void UpdateRatesCam(const FTM::DimTriggerRates &sdata)
void handleFtmDynamicData(const DimData &d)
Implements automatic subscription to MESSAGE and STATE services.
void handleFadRefClock(const DimData &d)
bool SendCommand(const std::string &command)
FactGui(Configuration &conf)
void SetFadLed(QPushButton *led, const DimData &d, uint16_t bitmask, bool invert=false)
void handleFscHumidity(const DimData &d)
uint8_t fAddr[40]
DNA of FTU board.
DimStampedInfo fDimFadConnections
void UpdateBiasCam(const PixelMapEntry &entry)
void AddServer(const std::string &s)
A list with all MESSAGE services to which we subscribed.
void on_fDimCmdSend_clicked()
Needs access to DimNetwork thus it is implemented in the derived class.
FunctionEvent(const function< void(const QEvent &)> &f)
void slot_ChooseBiasChannel(int isw)
DimStampedInfo fDimFscTemp
const T & ref(uint32_t offset=0) const
DimStampedInfo fDimFadTemperature
void handleRemoveService(const string &server, const string &service, bool iscmd)
A message used for debugging only.
void handleBiasCurrent(const DimData &d)
static std::string GetHtmlDescription(const std::vector< Description > &vec)
uint16_t fMultiplicity[40]
DimStampedInfo fDimFscVolt
void BiasCamChannelChanged()
DimStampedInfo fDimFadRefClock
const PixelMapEntry & index(int idx) const
int hv_channel
Bias suppply board.
void handleFadStatus(const DimData &d)
DimStampedInfo fDimFtmError
uint64_t fDNA[40]
Number of boards answered per crate.
void handleFadRoi(const DimData &d)
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
void UpdateGlobalStatus()
DimStampedInfo fDimBiasCurrent
DimStampedInfo fDimFadEventData
T get(uint32_t offset=0) const
void handleBiasVolt(const DimData &d)
Commandline parsing, resource file parsing and database access.
DimStampedInfo fDimFadRuns
void handleFadFwVersion(const DimData &d)
DimStampedInfo fDimFadFwVersion
const char * c_str() const
void handleFscTemp(const DimData &d)
DimStampedInfo fDimLoggerNumSubs
uint16_t fTriggerInterval
void handleFtmCounter(const DimData &d)
valarray< int8_t > fFtuStatus
uint16_t fMultiplicityCalib
void handleDimDNS(const DimData &d)
vector< float > fDrsCalibration
DimStampedInfo fDimFtmDynamicData
bool HasClockConditioner() const
vector< int16_t > fVecBiasDac
uint16_t fTriggerSeqLPint
bool IsEnabled(int i) const
void handleFtmStaticData(const DimData &d)
uint16_t fTriggerSeqLPext
function< void(const QEvent &)> fFunction
bool IsActive(int i) const
void on_fPixelEnable_stateChanged(int b)
void RemoveService(string server, string service, bool iscmd)
void handleLoggerFilenameNight(const DimData &d)
void handleLoggerStats(const DimData &d)
static void handler(int conn_id, char *packet, int size, int status)
void handleFtmError(const DimData &d)
std::string name
Index (e.g. 1)
void handleFadMinMax(const DimData &d, QPushButton *led, S *wmin, S *wmax=0)
void slot_CameraMouseMove(int isw)
void handleFadTemperature(const DimData &d)
DimStampedInfo fDimFscHumidity
uint64_t fFreeSpaceLogger
void on_fPixelIdx_valueChanged(int isw)
DimStampedInfo fDimMagicWeather
void handleMagicWeather(const DimData &d)
void handleFadConnections(const DimData &d)
DimStampedInfo fDimLoggerFilenameRun
void SubscribeService(const string &service)
void handleBiasDac(const DimData &d)
DimStampedInfo fDimFadPrescaler
vector< int16_t > fVecBiasCurrent
void UnsubscribeService(const string &service, bool allow_unsubscribed=false)
void handleFadEvents(const DimData &d)
bool IsActive(int i) const
std::string GetAsStr(const char *fmt="%Y-%m-%d %H:%M:%S") const
void IndicateStateChange(const Time &time, const string &server)
void BiasHvChannelChanged()
void SetFtuLed(int idx, int counter, const Time &t)
DimStampedInfo fDimFadStatus
bool Read(const std::string &fname)
void on_fThresholdDisablePatch_clicked()
void handleFscCurrent(const DimData &d)
void handleFadRuns(const DimData &d)
DimStampedInfo fDimFadDac
void on_fTabWidget_currentChanged(int which)
A compiler for the DIM data format string.
void handleFadDNA(const DimData &d)
void RemoveAllServices(const string &server)
DimStampedInfo fDimFtmPassport
const T * ptr(uint32_t offset=0) const
DimStampedInfo fDimFadEvents
DimStampedInfo fDimLoggerFilenameNight
An event posted by the CheckBoxDelegate if the CheckBox is used.
const PixelMapEntry & hv(int board, int channel) const
DimStampedInfo fDimFadRoi
void UnsubscribeAllServices(const string &server)
map< string, DimInfo * > fServices
vector< int > fPatchMapHW