1 #include "PixMonitor.hh"
11 PixMonitor::PixMonitor(TGGroupFrame *f,
PixGui *pixGui) {
13 fMonitorFrame =
new TGVerticalFrame(f);
14 fHFrame1 =
new TGHorizontalFrame(fMonitorFrame);
15 fHFrame2 =
new TGHorizontalFrame(fMonitorFrame);
17 TGString *a =
new TGString(
"I(ana) ");
18 TGString *d =
new TGString(
"I(digi) ");
20 fAna =
new TGLabel(fHFrame1, a);
21 fDigi =
new TGLabel(fHFrame2, d);
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")));
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()");
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()");
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));
50 fActTime = time(NULL);
51 fTimeinfo = localtime(&fActTime);
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));
60 fMonitorFrame->AddFrame(fHFrame1,
new TGLayoutHints(kLHintsTop | kLHintsExpandX,1,1,1,1));
61 fMonitorFrame->AddFrame(fHFrame2,
new TGLayoutHints(kLHintsTop | kLHintsExpandX,1,1,1,1));
64 if (
"fpix" == fGui->getHdiType()) {
65 fMonitorFrame->AddFrame(fHFrame_TDegree,
new TGLayoutHints(kLHintsTop | kLHintsExpandX,1,1,1,1));
68 f->AddFrame(fMonitorFrame,
new TGLayoutHints(kLHintsTop,2,2,2,2));
74 PixMonitor::~PixMonitor() {
79 void PixMonitor::handleButtons(Int_t
id) {
81 TGButton *btn = (TGButton *) gTQSender;
86 fActTime = time(NULL);
87 fTimeinfo = gmtime (&fActTime);
91 LOG(logINFO) <<
"Draw ana XXX FIXME IMPLEMENT THIS XXX";
94 LOG(logINFO) <<
"Draw digi XXX FIXME IMPLEMENT THIS XXX";
97 LOG(logINFO) <<
"Something went wrong in the PixMonitor::handleButons method!";
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());
113 fNmrAna->SetText(Form(
"%4.3f", ia));
114 fNmrDigi->SetText(Form(
"%4.3f",
id));
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));
122 fNmrTDegree->SetText(Form(
"---"));
130 string PixMonitor::stringify(
int x) {