pxar
 All Classes Namespaces Functions Variables Typedefs Friends
PixMonitor.cc
1 #include "PixMonitor.hh"
2 #include "log.h"
3 
4 #include "PixGui.hh"
5 #include "PixSetup.hh"
6 
7 using namespace std;
8 using namespace pxar;
9 
10 // ----------------------------------------------------------------------
11 PixMonitor::PixMonitor(TGGroupFrame *f, PixGui *pixGui) {
12  fGui = pixGui;
13  fMonitorFrame = new TGVerticalFrame(f);
14  fHFrame1 = new TGHorizontalFrame(fMonitorFrame);
15  fHFrame2 = new TGHorizontalFrame(fMonitorFrame);
16 
17  TGString *a = new TGString("I(ana) ");
18  TGString *d = new TGString("I(digi) ");
19 
20  fAna = new TGLabel(fHFrame1, a);
21  fDigi = new TGLabel(fHFrame2, d);
22 
23  fNmrAna = new TGTextEntry(fHFrame1, fAnaFileBuffer = new TGTextBuffer(50));
24  fNmrAna->SetWidth(50);
25  fNmrAna->SetToolTipText(Form("Total analog current drawn by %s", (fGui->getPixSetup()->getConfigParameters()->getNrocs()>1?"module":"ROC")));
26  fNmrDigi = new TGTextEntry(fHFrame2, fDigiFileBuffer = new TGTextBuffer(50));
27  fNmrDigi->SetWidth(50);
28  fNmrDigi->SetToolTipText(Form("Total digital current drawn by %s", (fGui->getPixSetup()->getConfigParameters()->getNrocs()>1?"module":"ROC")));
29 
30  fAnaButton = new TGTextButton(fHFrame1," Draw ", B_DRAWANA);
31  fAnaButton->SetToolTipText("not yet implemented");
32  fAnaButton->ChangeOptions(fAnaButton->GetOptions() | kFixedWidth);
33  fAnaButton->Connect("Clicked()", "PixMonitor", this, "handleButtons()");
34 
35  fDigiButton = new TGTextButton(fHFrame2," Draw ", B_DRAWDIGI);
36  fDigiButton->SetToolTipText("not yet implemented");
37  fDigiButton->ChangeOptions(fDigiButton->GetOptions() | kFixedWidth);
38  fDigiButton->Connect("Clicked()", "PixMonitor", this, "handleButtons()");
39 
40  if ("fpix" == fGui->getHdiType()) {
41  TGString *temperature_degree = new TGString("T (deg C) ");
42  fHFrame_TDegree = new TGHorizontalFrame(fMonitorFrame);
43  fTemperatureDegree = new TGLabel(fHFrame_TDegree, temperature_degree);
44  fNmrTDegree = new TGTextEntry(fHFrame_TDegree, fTDegreeFileBuffer = new TGTextBuffer(40));
45  fNmrTDegree->SetWidth(40);
46  fHFrame_TDegree->AddFrame(fTemperatureDegree, new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
47  fHFrame_TDegree->AddFrame(fNmrTDegree, new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
48  }
49 
50  fActTime = time(NULL);
51  fTimeinfo = localtime(&fActTime);
52 
53  fHFrame1->AddFrame(fAna, new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
54  fHFrame1->AddFrame(fNmrAna, new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
55  fHFrame1->AddFrame(fAnaButton, new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2,2));
56  fHFrame2->AddFrame(fDigi, new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2));
57  fHFrame2->AddFrame(fNmrDigi, new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2));
58  fHFrame2->AddFrame(fDigiButton, new TGLayoutHints(kLHintsTop | kLHintsLeft,2,2,2));
59 
60  fMonitorFrame->AddFrame(fHFrame1, new TGLayoutHints(kLHintsTop | kLHintsExpandX,1,1,1,1));
61  fMonitorFrame->AddFrame(fHFrame2, new TGLayoutHints(kLHintsTop | kLHintsExpandX,1,1,1,1));
62 
63 
64  if ("fpix" == fGui->getHdiType()) {
65  fMonitorFrame->AddFrame(fHFrame_TDegree, new TGLayoutHints(kLHintsTop | kLHintsExpandX,1,1,1,1));
66  }
67 
68  f->AddFrame(fMonitorFrame, new TGLayoutHints(kLHintsTop,2,2,2,2));
69 
70 }
71 
72 
73 // ----------------------------------------------------------------------
74 PixMonitor::~PixMonitor() {
75 }
76 
77 
78 // ----------------------------------------------------------------------
79 void PixMonitor::handleButtons(Int_t id) {
80  if(id == -1) {
81  TGButton *btn = (TGButton *) gTQSender;
82  id = btn->WidgetId();
83  }
84 
85  // timer initializing
86  fActTime = time(NULL);
87  fTimeinfo = gmtime (&fActTime);
88 
89  switch(id) {
90  case B_DRAWANA:
91  LOG(logINFO) << "Draw ana XXX FIXME IMPLEMENT THIS XXX";
92  break;
93  case B_DRAWDIGI:
94  LOG(logINFO) << "Draw digi XXX FIXME IMPLEMENT THIS XXX";
95  break;
96  default:
97  LOG(logINFO) << "Something went wrong in the PixMonitor::handleButons method!";
98  break;
99  }
100 }
101 
102 // ----------------------------------------------------------------------
103 void PixMonitor::Update() {
104  static float ia(0.), id(0.);
105  if (fGui->getApi()) {
106  ia = static_cast<float>(fGui->getApi()->getTBia());
107  id = static_cast<float>(fGui->getApi()->getTBid());
108  } else {
109  ia += 1.0;
110  id += 1.0;
111  }
112 
113  fNmrAna->SetText(Form("%4.3f", ia));
114  fNmrDigi->SetText(Form("%4.3f", id));
115 
116  if ("fpix" == fGui->getHdiType()) {
117  if (fGui->getApi()) {
118  uint16_t v_ref = fGui->getApi()->GetADC(5);
119  uint16_t v_val = fGui->getApi()->GetADC(4);
120  fNmrTDegree->SetText(Form("%3.1f", (-(v_val - v_ref) - 0.92) / 6.55));
121  } else {
122  fNmrTDegree->SetText(Form("---"));
123  }
124  }
125 
126 }
127 
128 
129 // ----------------------------------------------------------------------
130 string PixMonitor::stringify(int x) {
131  ostringstream o;
132  o << x;
133  return o.str();
134 
135 }
Definition: PixGui.hh:43