From b21b4d066cdb452918378f8328b5b4bb385b9baa Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Fri, 17 Aug 2012 13:12:08 +0000 Subject: [PATCH] included high voltage for developer tab in gotthard git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@32 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/include/qTabDeveloper.h | 12 +++- slsDetectorGui/src/qTabDeveloper.cpp | 99 ++++++++++++++++++++++++-- 2 files changed, 104 insertions(+), 7 deletions(-) diff --git a/slsDetectorGui/include/qTabDeveloper.h b/slsDetectorGui/include/qTabDeveloper.h index ab1ca4c1b..525e372d1 100644 --- a/slsDetectorGui/include/qTabDeveloper.h +++ b/slsDetectorGui/include/qTabDeveloper.h @@ -16,9 +16,12 @@ class multiSlsDetector; #include #include #include +#include #include #include #include +#include +#include /** C++ Include Headers */ #include #include @@ -92,8 +95,12 @@ private: QLabel *lblAdcs[20]; MyDoubleSpinBox *spinDacs[20]; QDoubleSpinBox *spinAdcs[20]; + QLabel *lblHV; + QComboBox *comboHV; QTimer *adcTimer; - + QGridLayout *dacLayout; + QString tipHV; + QPalette red; /** Sets up the widget */ void SetupWidgetWindow(); @@ -128,6 +135,9 @@ void RefreshAdcs(); */ void SetDacValues(int id); +/** Set High Voltage + */ +void SetHighVoltage(); }; diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index 015df584c..9abd46c6d 100644 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -47,7 +47,12 @@ void qTabDeveloper::SetupWidgetWindow(){ //Detector Type detType=myDet->getDetectorsType(); - //the nu + //palette + red = QPalette(); + red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); + + + //the number of dacs and adcs switch(detType){ case slsDetectorDefs::MYTHEN: NUM_DAC_WIDGETS = 6; @@ -102,8 +107,31 @@ void qTabDeveloper::SetupWidgetWindow(){ //dacs boxDacs = new QGroupBox("Dacs",this); boxDacs->setFixedHeight(25+(NUM_DAC_WIDGETS/2)*35); - layout->addWidget(boxDacs,0,0); CreateDACWidgets(); + + //HV for gotthard + if(detType==slsDetectorDefs::GOTTHARD){ + boxDacs->setFixedHeight(boxDacs->height()+35); + + lblHV = new QLabel("High Voltage",boxDacs); + comboHV = new QComboBox(boxDacs); + comboHV->addItem("0"); + comboHV->addItem("90"); + comboHV->addItem("110"); + comboHV->addItem("120"); + comboHV->addItem("150"); + comboHV->addItem("180"); + comboHV->addItem("200"); + tipHV = "Set high voltage to 0, 90, 110, 120, 150 or 200V."; + lblHV->setToolTip(tipHV); + comboHV->setToolTip(tipHV); + dacLayout->addWidget(lblHV,(int)(NUM_DAC_WIDGETS/2),1); + dacLayout->addWidget(comboHV,(int)(NUM_DAC_WIDGETS/2),2); + connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); + } + layout->addWidget(boxDacs,0,0); + + //adcs if((detType==slsDetectorDefs::GOTTHARD)||(detType==slsDetectorDefs::AGIPD)){ setFixedHeight((50+(NUM_DAC_WIDGETS/2)*35)+(50+(NUM_ADC_WIDGETS/2)*35)); @@ -138,7 +166,7 @@ void qTabDeveloper::Initialization(){ void qTabDeveloper::CreateDACWidgets(){ - QGridLayout *dacLayout = new QGridLayout(boxDacs); + dacLayout = new QGridLayout(boxDacs); for(int i=0;ivalue() << endl; + cout << "Setting dac:" << dacNames[id] << " : " << spinDacs[id]->value() << endl; #endif + spinDacs[id]->setValue((double)myDet->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id))); +} - spinDacs[id]->setValue((double)myDet->setDAC(spinDacs[id]->value(),getSLSIndex(id))); + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDeveloper::SetHighVoltage(){ +#ifdef VERBOSE + cout << "Setting high voltage:" << comboHV->currentText().toAscii().constData() << endl; +#endif + int highvoltage = comboHV->currentText().toInt(); + int ret = myDet->setDAC(highvoltage,slsDetectorDefs::HV_POT); + //error + if(ret != highvoltage){ + qDefs::ErrorMessage("High Voltage could not be set to this value.","Developer"); + lblHV->setPalette(red); + lblHV->setText("High Voltage:*"); + QString errTip = tipHV+QString("

High Voltage could not be set. The return value is ")+ + QString::number(ret)+ QString(""); + lblHV->setToolTip(errTip); + comboHV->setToolTip(errTip); + }else{ + lblHV->setPalette(lblDacs[0]->palette()); + lblHV->setText("High Voltage:"); + lblHV->setToolTip(tipHV); + comboHV->setToolTip(tipHV); + } } @@ -223,7 +277,7 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index){ case 6: return slsDetectorDefs::G_VREF_COMP; case 7: return slsDetectorDefs::G_IB_TESTC; case 8: return slsDetectorDefs::TEMPERATURE_ADC; - case 9: return slsDetectorDefs::TEMPERATURE_FPGA; + case 9:return slsDetectorDefs::TEMPERATURE_FPGA; default: qDefs::ErrorMessage("Unknown DAC/ADC Index. Weird Error","Developer"); Refresh(); @@ -263,6 +317,39 @@ void qTabDeveloper::Refresh(){ spinDacs[i]->setValue((double)myDet->setDAC(-1,getSLSIndex(i))); //adcs RefreshAdcs(); + + //gotthard -high voltage + if(detType == slsDetectorDefs::GOTTHARD){ + disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); + + //default should be correct + lblHV->setPalette(lblDacs[0]->palette()); + lblHV->setText("High Voltage:"); + lblHV->setToolTip(tipHV); + comboHV->setToolTip(tipHV); + //getting hv value + int ret = myDet->setDAC(-1,slsDetectorDefs::HV_POT); + switch(ret){ + case 0: comboHV->setCurrentIndex(0);break; + case 90: comboHV->setCurrentIndex(1);break; + case 110: comboHV->setCurrentIndex(2);break; + case 120: comboHV->setCurrentIndex(3);break; + case 150: comboHV->setCurrentIndex(4);break; + case 180: comboHV->setCurrentIndex(5);break; + case 200: comboHV->setCurrentIndex(6);break; + default: comboHV->setCurrentIndex(0);//error + lblHV->setPalette(red); + lblHV->setText("High Voltage:*"); + QString errTip = tipHV+QString("

High Voltage could not be set. The return value is ")+ + QString::number(ret)+ QString(""); + lblHV->setToolTip(errTip); + comboHV->setToolTip(errTip); + break; + } + + connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); + } + }