indiviual dac control for each detector enabled in gui

This commit is contained in:
Dhanya Maliakal 2015-04-01 12:05:09 +02:00
parent 5c14453c5d
commit 85416acbea
2 changed files with 112 additions and 33 deletions

View File

@ -68,10 +68,6 @@ public:
*/ */
~qTabDeveloper(); ~qTabDeveloper();
/** To refresh and update widgets
*/
void Refresh();
/** To stop ADC Timer when starting acquisition /** To stop ADC Timer when starting acquisition
*/ */
void StopADCTimer(){if(adcTimer) adcTimer->stop();}; void StopADCTimer(){if(adcTimer) adcTimer->stop();};
@ -79,6 +75,8 @@ public:
private: private:
/** The sls detector object */ /** The sls detector object */
multiSlsDetector *myDet; multiSlsDetector *myDet;
/** The sls detector object */
slsDetector *det;
/** detector type */ /** detector type */
slsDetectorDefs::detectorType detType; slsDetectorDefs::detectorType detType;
/**number of dac widgets*/ /**number of dac widgets*/
@ -108,6 +106,7 @@ private:
QGridLayout *dacLayout; QGridLayout *dacLayout;
QString tipHV; QString tipHV;
QPalette red; QPalette red;
QComboBox *comboDetector;
/** Sets up the widget /** Sets up the widget
*/ */
void SetupWidgetWindow(); void SetupWidgetWindow();
@ -130,21 +129,25 @@ private:
*/ */
slsDetectorDefs::dacIndex getSLSIndex(int index); slsDetectorDefs::dacIndex getSLSIndex(int index);
public slots:
/** To refresh and update widgets
*/
void Refresh();
private slots: private slots:
/** Refreshes the adcs /** Refreshes the adcs
*/ */
void RefreshAdcs(); void RefreshAdcs();
/** Set Dac values /** Set Dac values
* @param id id of dac * @param id id of dac
*/ */
void SetDacValues(int id); void SetDacValues(int id);
/** Set High Voltage /** Set High Voltage
*/ */
void SetHighVoltage(); void SetHighVoltage();
}; };

View File

@ -27,6 +27,7 @@ int qTabDeveloper::NUM_ADC_WIDGETS(0);
qTabDeveloper::qTabDeveloper(QWidget *parent,multiSlsDetector*& detector): qTabDeveloper::qTabDeveloper(QWidget *parent,multiSlsDetector*& detector):
QWidget(parent), QWidget(parent),
myDet(detector), myDet(detector),
det(0),
boxDacs(0), boxDacs(0),
boxAdcs(0), boxAdcs(0),
lblHV(0), lblHV(0),
@ -50,6 +51,7 @@ qTabDeveloper::qTabDeveloper(QWidget *parent,multiSlsDetector*& detector):
qTabDeveloper::~qTabDeveloper(){ qTabDeveloper::~qTabDeveloper(){
delete myDet; delete myDet;
if(det) delete det;
} }
@ -143,10 +145,11 @@ void qTabDeveloper::SetupWidgetWindow(){
//layout //layout
setFixedWidth(765); setFixedWidth(765);
setFixedHeight(50+(NUM_DAC_WIDGETS/2)*35); setFixedHeight(20+50+(NUM_DAC_WIDGETS/2)*35);
//setHeight(340); //setHeight(340);
scroll = new QScrollArea; scroll = new QScrollArea;
scroll->setFrameShape(QFrame::NoFrame); //scroll->setFrameShape(QFrame::NoFrame);
scroll->setWidget(this); scroll->setWidget(this);
scroll->setWidgetResizable(true); scroll->setWidgetResizable(true);
@ -154,6 +157,16 @@ void qTabDeveloper::SetupWidgetWindow(){
layout->setContentsMargins(20,10,10,5); layout->setContentsMargins(20,10,10,5);
setLayout(layout); setLayout(layout);
//readout
comboDetector = new QComboBox(this);
//comboDetector->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
comboDetector->addItem("All");
//add detectors
for(int i=1;i<myDet->getNumberOfDetectors()+1;i++)
comboDetector->addItem(QString(myDet->getHostname(i-1).c_str()));
comboDetector->setCurrentIndex(0);
//dacs //dacs
boxDacs = new QGroupBox("Dacs",this); boxDacs = new QGroupBox("Dacs",this);
boxDacs->setFixedHeight(25+(NUM_DAC_WIDGETS/2)*35); boxDacs->setFixedHeight(25+(NUM_DAC_WIDGETS/2)*35);
@ -179,20 +192,21 @@ void qTabDeveloper::SetupWidgetWindow(){
dacLayout->addWidget(comboHV,(int)(NUM_DAC_WIDGETS/2),2); dacLayout->addWidget(comboHV,(int)(NUM_DAC_WIDGETS/2),2);
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
} }
layout->addWidget(boxDacs,0,0); layout->addWidget(comboDetector,0,0);
layout->addWidget(boxDacs,1,0);
//adcs //adcs
if((detType==slsDetectorDefs::GOTTHARD) || (detType==slsDetectorDefs::MOENCH)){ if((detType==slsDetectorDefs::GOTTHARD) || (detType==slsDetectorDefs::MOENCH)){
setFixedHeight((50+(NUM_DAC_WIDGETS/2)*35)+(50+(NUM_ADC_WIDGETS/2)*35)); setFixedHeight(20+(50+(NUM_DAC_WIDGETS/2)*35)+(50+(NUM_ADC_WIDGETS/2)*35));
boxAdcs = new QGroupBox("ADCs",this); boxAdcs = new QGroupBox("ADCs",this);
boxAdcs->setFixedHeight(25+(NUM_ADC_WIDGETS/2)*35); boxAdcs->setFixedHeight(25+(NUM_ADC_WIDGETS/2)*35);
layout->addWidget(boxAdcs,1,0); layout->addWidget(boxAdcs,2,0);
CreateADCWidgets(); CreateADCWidgets();
//to make the adcs at the bottom most //to make the adcs at the bottom most
int diff = 340-height(); int diff = 340-height();
setFixedHeight(340); setFixedHeight(340);
layout->setVerticalSpacing(diff); layout->setVerticalSpacing(diff/2);
//timer to check adcs //timer to check adcs
adcTimer = new QTimer(this); adcTimer = new QTimer(this);
} }
@ -209,6 +223,8 @@ void qTabDeveloper::Initialization(){
for(int i=0;i<NUM_DAC_WIDGETS;i++) for(int i=0;i<NUM_DAC_WIDGETS;i++)
connect(spinDacs[i], SIGNAL(editingFinished(int)), this, SLOT(SetDacValues(int))); connect(spinDacs[i], SIGNAL(editingFinished(int)), this, SLOT(SetDacValues(int)));
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(Refresh()));
} }
@ -268,11 +284,24 @@ void qTabDeveloper::SetDacValues(int id){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Setting dac:" << dacNames[id] << " : " << spinDacs[id]->value() << endl; cout << "Setting dac:" << dacNames[id] << " : " << spinDacs[id]->value() << endl;
#endif #endif
//spinDacs[id]->setValue((double)myDet->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id)));
int detid = comboDetector->currentIndex();
if(detid)
det = myDet->getSlsDetector(detid-1);
//all detectors
if(!detid){
myDet->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id),0); myDet->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id),0);
lblDacsmV[id]->setText(QString("%1mV").arg(myDet->setDAC(-1,getSLSIndex(id),1),-10)); lblDacsmV[id]->setText(QString("%1mV").arg(myDet->setDAC(-1,getSLSIndex(id),1),-10));
qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetDacValues"); qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetDacValues");
}
//specific detector
else{
det->setDAC((dacs_t)spinDacs[id]->value(),getSLSIndex(id),0);
lblDacsmV[id]->setText(QString("%1mV").arg(det->setDAC(-1,getSLSIndex(id),1),-10));
qDefs::checkErrorMessage(det,"qTabDeveloper::SetDacValues");
}
} }
@ -283,9 +312,26 @@ void qTabDeveloper::SetHighVoltage(){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Setting high voltage:" << comboHV->currentText().toAscii().constData() << endl; cout << "Setting high voltage:" << comboHV->currentText().toAscii().constData() << endl;
#endif #endif
int detid = comboDetector->currentIndex();
if(detid)
det = myDet->getSlsDetector(detid-1);
int highvoltage = comboHV->currentText().toInt(); int highvoltage = comboHV->currentText().toInt();
int ret = myDet->setDAC(highvoltage,slsDetectorDefs::HV_POT,0); int ret;
//all detectors
if(!detid){
ret = myDet->setDAC(highvoltage,slsDetectorDefs::HV_POT,0);
qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetHighVoltage"); qDefs::checkErrorMessage(myDet,"qTabDeveloper::SetHighVoltage");
}
//specific detector
else{
ret = det->setDAC(highvoltage,slsDetectorDefs::HV_POT,0);
qDefs::checkErrorMessage(det,"qTabDeveloper::SetHighVoltage");
}
//error //error
if(ret != highvoltage){ if(ret != highvoltage){
qDefs::Message(qDefs::CRITICAL,"High Voltage could not be set to this value.","qTabDeveloper::SetHighVoltage"); qDefs::Message(qDefs::CRITICAL,"High Voltage could not be set to this value.","qTabDeveloper::SetHighVoltage");
@ -407,8 +453,20 @@ void qTabDeveloper::RefreshAdcs(){
cout << "Updating ADCs" <<endl; cout << "Updating ADCs" <<endl;
#endif #endif
adcTimer->stop(); adcTimer->stop();
for(int i=0;i<NUM_ADC_WIDGETS;i++)
int detid = comboDetector->currentIndex();
if(detid)
det = myDet->getSlsDetector(detid-1);
for(int i=0;i<NUM_ADC_WIDGETS;i++){
//all detectors
if(!detid)
spinAdcs[i]->setValue((double)myDet->getADC(getSLSIndex(i+NUM_DAC_WIDGETS))); spinAdcs[i]->setValue((double)myDet->getADC(getSLSIndex(i+NUM_DAC_WIDGETS)));
//specific detector
else
spinAdcs[i]->setValue((double)det->getADC(getSLSIndex(i+NUM_DAC_WIDGETS)));
}
adcTimer->start(ADC_TIMEOUT); adcTimer->start(ADC_TIMEOUT);
qDefs::checkErrorMessage(myDet,"qTabDeveloper::RefreshAdcs"); qDefs::checkErrorMessage(myDet,"qTabDeveloper::RefreshAdcs");
@ -423,15 +481,30 @@ void qTabDeveloper::Refresh(){
cout << endl << "**Updating Developer Tab" << endl; cout << endl << "**Updating Developer Tab" << endl;
#endif #endif
int detid = comboDetector->currentIndex();
if(detid)
det = myDet->getSlsDetector(detid-1);
//dacs
#ifdef VERBOSE #ifdef VERBOSE
cout << "Gettings DACs" << endl; cout << "Gettings DACs" << endl;
#endif #endif
//dacs
for(int i=0;i<NUM_DAC_WIDGETS;i++){ for(int i=0;i<NUM_DAC_WIDGETS;i++){
//all detectors
if(!detid){
spinDacs[i]->setValue((double)myDet->setDAC(-1,getSLSIndex(i),0)); spinDacs[i]->setValue((double)myDet->setDAC(-1,getSLSIndex(i),0));
lblDacsmV[i]->setText(QString("%1mV").arg(myDet->setDAC(-1,getSLSIndex(i),1),-10)); lblDacsmV[i]->setText(QString("%1mV").arg(myDet->setDAC(-1,getSLSIndex(i),1),-10));
} }
//specific detector
else{
spinDacs[i]->setValue((double)det->setDAC(-1,getSLSIndex(i),0));
lblDacsmV[i]->setText(QString("%1mV").arg(det->setDAC(-1,getSLSIndex(i),1),-10));
}
}
//adcs //adcs
if(NUM_ADC_WIDGETS) RefreshAdcs(); if(NUM_ADC_WIDGETS) RefreshAdcs();
@ -445,7 +518,10 @@ void qTabDeveloper::Refresh(){
lblHV->setToolTip(tipHV); lblHV->setToolTip(tipHV);
comboHV->setToolTip(tipHV); comboHV->setToolTip(tipHV);
//getting hv value //getting hv value
int ret = (int)myDet->setDAC(-1,slsDetectorDefs::HV_POT,0); int ret;
if(!detid) ret = (int)myDet->setDAC(-1,slsDetectorDefs::HV_POT,0);
else ret = (int)det->setDAC(-1,slsDetectorDefs::HV_POT,0);
switch(ret){ switch(ret){
case 0: comboHV->setCurrentIndex(0);break; case 0: comboHV->setCurrentIndex(0);break;
case 90: comboHV->setCurrentIndex(1);break; case 90: comboHV->setCurrentIndex(1);break;