1 #include "PixMonitorFrame.hh" 
    7 #include "PixMonitor.hh" 
   13 PixMonitorFrame::PixMonitorFrame(TGVerticalFrame *f, 
PixGui *pixGui) {
 
   15   fMonitorFrame = 
new TGVerticalFrame(f);
 
   16   fHFrame1 = 
new TGHorizontalFrame(fMonitorFrame);
 
   17   fHFrame2 = 
new TGHorizontalFrame(fMonitorFrame);
 
   19   TGString *a = 
new TGString(
"I(ana)    ");
 
   20   TGString *d = 
new TGString(
"I(digi)    ");
 
   22   fAna = 
new TGLabel(fHFrame1, a);
 
   23   fDigi = 
new TGLabel(fHFrame2, d);
 
   25   fNmrAna = 
new TGTextEntry(fHFrame1, fAnaFileBuffer = 
new TGTextBuffer(50));
 
   26   fNmrAna->SetWidth(50);
 
   27   fNmrAna->SetToolTipText(Form(
"Total analog current drawn by %s", (fGui->getPixSetup()->getConfigParameters()->getNrocs()>1?
"module":
"ROC")));
 
   28   fNmrDigi = 
new TGTextEntry(fHFrame2, fDigiFileBuffer = 
new TGTextBuffer(50));
 
   29   fNmrDigi->SetWidth(50);
 
   30   fNmrDigi->SetToolTipText(Form(
"Total digital current drawn by %s", (fGui->getPixSetup()->getConfigParameters()->getNrocs()>1?
"module":
"ROC")));
 
   32   fAnaButton = 
new TGTextButton(fHFrame1,
" Draw ", B_DRAWANA);
 
   33   fAnaButton->SetToolTipText(
"draw analog current measurements vs time");
 
   34   fAnaButton->ChangeOptions(fAnaButton->GetOptions() | kFixedWidth);
 
   35   fAnaButton->Connect(
"Clicked()", 
"PixMonitorFrame", 
this, 
"handleButtons()");
 
   37   fDigiButton = 
new TGTextButton(fHFrame2,
" Draw ", B_DRAWDIGI);
 
   38   fDigiButton->SetToolTipText(
"draw digital current measurements vs time");
 
   39   fDigiButton->ChangeOptions(fDigiButton->GetOptions() | kFixedWidth);
 
   40   fDigiButton->Connect(
"Clicked()", 
"PixMonitorFrame", 
this, 
"handleButtons()");
 
   42   if (
"fpix" == fGui->getHdiType()) {
 
   43     TGString *temperature_degree = 
new TGString(
"T (deg C) ");
 
   44     fHFrame_TDegree = 
new TGHorizontalFrame(fMonitorFrame);
 
   45     fTemperatureDegree = 
new TGLabel(fHFrame_TDegree, temperature_degree);
 
   46     fNmrTDegree = 
new TGTextEntry(fHFrame_TDegree, fTDegreeFileBuffer = 
new TGTextBuffer(40));
 
   47     fNmrTDegree->SetWidth(40);
 
   48     fHFrame_TDegree->AddFrame(fTemperatureDegree, 
new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
 
   49     fHFrame_TDegree->AddFrame(fNmrTDegree, 
new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
 
   52   fActTime = time(NULL);
 
   53   fTimeinfo = localtime(&fActTime);
 
   55   fHFrame1->AddFrame(fAna, 
new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
 
   56   fHFrame1->AddFrame(fNmrAna, 
new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
 
   57   fHFrame1->AddFrame(fAnaButton, 
new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
 
   58   fHFrame2->AddFrame(fDigi, 
new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2));
 
   59   fHFrame2->AddFrame(fNmrDigi, 
new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2));
 
   60   fHFrame2->AddFrame(fDigiButton, 
new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2));
 
   62   fMonitorFrame->AddFrame(fHFrame1, 
new TGLayoutHints(kLHintsTop | kLHintsExpandX,1,1,1,1));
 
   63   fMonitorFrame->AddFrame(fHFrame2, 
new TGLayoutHints(kLHintsTop | kLHintsExpandX,1,1,1,1));
 
   66   if (
"fpix" == fGui->getHdiType()) {
 
   67     fMonitorFrame->AddFrame(fHFrame_TDegree, 
new TGLayoutHints(kLHintsTop | kLHintsExpandX,1,1,1,1));
 
   70   f->AddFrame(fMonitorFrame, 
new TGLayoutHints(kLHintsTop,2,2,2,2));
 
   76 PixMonitorFrame::~PixMonitorFrame() {
 
   81 void PixMonitorFrame::handleButtons(Int_t 
id) {
 
   83     TGButton *btn = (TGButton *) gTQSender;
 
   88   fActTime = time(NULL);
 
   89   fTimeinfo = gmtime (&fActTime);
 
   91   PixMonitor *a = fGui->getPixSetup()->getPixMonitor();
 
   95     if (fGui->getPixTab()) fGui->getPixTab()->update();
 
  101     if (fGui->getPixTab()) fGui->getPixTab()->update();
 
  104     LOG(logINFO) << 
"Something went wrong in the PixMonitorFrame::handleButons method!";
 
  110 void PixMonitorFrame::Update() {
 
  111   static float ia(0.), id(0.); 
 
  112   PixMonitor *a = fGui->getPixSetup()->getPixMonitor();
 
  113   if (fGui->getApi()) {
 
  117     ia = 
static_cast<float>(a->getIana());
 
  118     id = 
static_cast<float>(a->getIdig());
 
  119     if (!fGui->isPowerOff()) {
 
  121     LOG(logERROR) << 
"analog current reading unphysical";
 
  124     LOG(logERROR) << 
"digital current reading unphysical";
 
  132   fNmrAna->SetText(Form(
"%4.3f", ia));
 
  133   fNmrDigi->SetText(Form(
"%4.3f", 
id));
 
  135   if (
"fpix" == fGui->getHdiType()) {
 
  136     if (fGui->getApi()) {
 
  137       uint16_t v_ref =  fGui->getApi()->GetADC(5);
 
  138       uint16_t v_val =  fGui->getApi()->GetADC(4);
 
  139       fNmrTDegree->SetText(Form(
"%3.1f", (-(v_val - v_ref) - 0.92) / 6.55));
 
  141       fNmrTDegree->SetText(Form(
"---"));