From daae091945453a7970d22695b485aa00e62eed5d Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Thu, 8 Aug 2013 09:53:28 +0000 Subject: [PATCH] a HUGE number of changes in measurement tab, and changes probes to be still disabled until #frames>1 and set cycles to 1 if probes >1 git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@219 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/forms/form_tab_measurement.ui | 27 +- slsDetectorGui/include/qTabMeasurement.h | 13 +- slsDetectorGui/include/svnInfoGui.h | 6 +- slsDetectorGui/src/qTabMeasurement.cpp | 529 +++++++++++-------- 4 files changed, 329 insertions(+), 246 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui index fc31c2344..425bfdfc8 100644 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -423,7 +423,19 @@ - <nobr>The data are accumulated over several (frames) pump-cycles. Set cycles to 1.</nobr><br> <b>Available only in Expert Mode.</b><br>#probes# + <nobr> +The data are accumulated over several (frames) pump cycles. +</nobr> +<br> +<nobr> <b> +Enabled only in Expert Mode and if Number of Frames > 1. +</b></nobr> +<br> +<nobr>Setting Number of Probes will reset Number of Triggers to 1. +</nobr> +<br> +#probes# + Number of Probes: @@ -442,7 +454,18 @@ - <nobr>The data are accumulated over several (frames) pump-cycles. Set cycles to 1.</nobr><br> <b>Available only in Expert Mode.</b><br>#probes# + <nobr> +The data are accumulated over several (frames) pump cycles. +</nobr> +<br> +<nobr> <b> +Enabled only in Expert Mode and if Number of Frames > 1. +</b></nobr> +<br> +<nobr>Setting Number of Probes will reset Number of Triggers to 1. +</nobr> +<br> +#probes# diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index 4788fbb5d..23717717d 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -87,21 +87,16 @@ private: void SetupTimingMode(); /** Sets up all the slots and signals - * @param timingChange only some of the signals are disconnected when timing mode is changed - * This method is to reconnect them again. */ - void Initialization(int timingChange=0); - - /** Disconnects all the slots and signals (which depend on timing mode) - * to retrieve all the parameters from client. - * This is done only when Timing mode is changed - */ - void DeInitialization(); + void Initialization(); /** Enables/Disables all the widgets */ void Enable(bool enable); + /** Validates before enabling or disabling probes */ + void EnableProbes(); + private slots: /** Sets the timing mode diff --git a/slsDetectorGui/include/svnInfoGui.h b/slsDetectorGui/include/svnInfoGui.h index d1d10ecaf..066d56873 100644 --- a/slsDetectorGui/include/svnInfoGui.h +++ b/slsDetectorGui/include/svnInfoGui.h @@ -2,10 +2,10 @@ #define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui" //#define SVNREPPATH "" #define SVNREPUUID "af1100a4-978c-4157-bff7-07162d2ba061" -//#define SVNREV 0x200 +//#define SVNREV 0x218 //#define SVNKIND "" //#define SVNSCHED "" #define SVNAUTH "l_maliakal_d" -#define SVNREV 0x200 -#define SVNDATE 0x20130711 +#define SVNREV 0x218 +#define SVNDATE 0x20130807 // diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 085959aee..dab5f6e11 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -49,15 +49,48 @@ qTabMeasurement::~qTabMeasurement(){ void qTabMeasurement::SetupWidgetWindow(){ //Number of measurements spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1)); - - //Timer to update the progress bar - progressTimer = new QTimer(this); - //btnStartStop->setStyleSheet("color:green"); + //Number of frames + spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); //Exp Time qDefs::timeUnit unit; double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); spinExpTime->setValue(time); comboExpUnit->setCurrentIndex((int)unit); + //period + time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); + spinPeriod->setValue(time); + comboPeriodUnit->setCurrentIndex((int)unit); + //Number of Triggers + spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); + //delay + time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); + spinDelay->setValue(time); + comboDelayUnit->setCurrentIndex((int)unit); + //gates + spinNumGates->setValue((int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1)); + //probes + spinNumProbes->setValue((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1)); + //File Name + dispFileName->setText(QString(myDet->getFileName().c_str())); + //File Index + spinIndex->setValue(myDet->getFileIndex()); + //only initially + lblProgressIndex->setText(QString::number(0)); + //ly initially + progressBar->setValue(0); + //file write enabled/disabled + chkFile->setChecked(myDet->enableWriteToFile()); + dispFileName->setEnabled(myDet->enableWriteToFile()); + + + //creating the icons for the buttons + iconStart = new QIcon(":/icons/images/start.png"); + iconStop = new QIcon(":/icons/images/stop.png"); + + + //Timer to update the progress bar + progressTimer = new QTimer(this); + //Hide the error message red = QPalette(); red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); @@ -67,25 +100,7 @@ void qTabMeasurement::SetupWidgetWindow(){ QString("Acquisition Period should be" " greater than or equal to Exposure Time."); - //File Name - dispFileName->setText(QString(myDet->getFileName().c_str())); - //File Index - spinIndex->setValue(myDet->getFileIndex()); - //only initially - lblProgressIndex->setText(QString::number(0)); - //ly initially - progressBar->setValue(0); - - //file write enabled/disabled - chkFile->setChecked(myDet->enableWriteToFile()); - dispFileName->setEnabled(myDet->enableWriteToFile()); - - //creating the icons for the buttons - iconStart = new QIcon(":/icons/images/start.png"); - iconStop = new QIcon(":/icons/images/stop.png"); - qDefs::checkErrorMessage(myDet,"qTabMeasurement::SetupWidgetWindow"); - } @@ -94,17 +109,9 @@ void qTabMeasurement::SetupWidgetWindow(){ void qTabMeasurement::SetExpertMode(bool enable){ expertMode = enable; - lblNumProbes->setEnabled(enable); - spinNumProbes->setEnabled(enable); - //Number of Probes - if((enable)&&(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN)){ - int val = (int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1); - spinNumProbes->setValue(val); -#ifdef VERBOSE - cout << "Getting number of probes : " << val << endl; -#endif - } qDefs::checkErrorMessage(myDet,"qTabMeasurement::SetExpertMode"); + + EnableProbes(); } @@ -163,8 +170,8 @@ void qTabMeasurement::SetupTimingMode(){ // then the timing mode is 'None'. // This is for the inexperienced user if(mode==slsDetectorDefs::AUTO_TIMING){ - int frames = (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1); - int triggers = (int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1); + int frames = spinNumFrames->value(); + int triggers = spinNumTriggers->value(); if((frames==1)&&(triggers==1)){ comboTimingMode->setCurrentIndex((int)None); SetTimingMode((int)None); @@ -206,24 +213,21 @@ void qTabMeasurement::SetupTimingMode(){ //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMeasurement::Initialization(int timingChange){ - //These signals are connected only at start up. The others are reinitialized when changing timing mode - if(!timingChange){ - //Number of Measurements - connect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); - //File Name - connect(dispFileName, SIGNAL(textChanged(const QString&)),this, SLOT(setFileName(const QString&))); - //File Index - connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - //Start/Stop Acquisition - connect(btnStartStop, SIGNAL(clicked()), this, SLOT(startStopAcquisition())); - //Timing Mode - connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));// - //progress bar - connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); - //enable write to file - connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); - } +void qTabMeasurement::Initialization(){ + //Number of Measurements + connect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); + //File Name + connect(dispFileName, SIGNAL(textChanged(const QString&)),this, SLOT(setFileName(const QString&))); + //File Index + connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + //Start/Stop Acquisition + connect(btnStartStop, SIGNAL(clicked()), this, SLOT(startStopAcquisition())); + //Timing Mode + connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));// + //progress bar + connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); + //enable write to file + connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); //Number of Frames connect(spinNumFrames,SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); //Exposure Time @@ -247,37 +251,10 @@ void qTabMeasurement::Initialization(int timingChange){ //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMeasurement::DeInitialization(){ - //Number of Frames - disconnect(spinNumFrames,SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); - //Exposure Time - disconnect(spinExpTime,SIGNAL(valueChanged(double)), this, SLOT(setExposureTime()));//..myplot - disconnect(comboExpUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setExposureTime())); - //Frame Period between exposures - disconnect(spinPeriod,SIGNAL(valueChanged(double)), this, SLOT(setAcquisitionPeriod()));//..myplot - disconnect(comboPeriodUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setAcquisitionPeriod())); - //Number of Triggers - disconnect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); - //Delay After Trigger - disconnect(spinDelay,SIGNAL(valueChanged(double)), this, SLOT(setDelay())); - disconnect(comboDelayUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); - //Number of Gates - disconnect(spinNumGates,SIGNAL(valueChanged(int)), this, SLOT(setNumGates(int))); - //Number of Probes - disconnect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabMeasurement::Enable(bool enable){ frameTimeResolved->setEnabled(enable); frameNotTimeResolved->setEnabled(enable); - //Enable this always - //if(!enable) btnStartStop->setEnabled(true); - //shortcut each time, else it doesnt work a second time btnStartStop->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); } @@ -286,28 +263,6 @@ void qTabMeasurement::Enable(bool enable){ //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMeasurement::setFileName(const QString& fName){ - myDet->setFileName(fName.toAscii().data()); -#ifdef VERBOSE - cout << "Setting File name to " << myDet->getFileName() << endl; -#endif - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setFileName"); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - -void qTabMeasurement::setRunIndex(int index){ - myDet->setFileIndex(index); -#ifdef VERBOSE - cout << "Setting File Index to " << myDet->getFileIndex() << endl; -#endif - qDefs::checkErrorMessage(myDet,"qTabMeasurement::setRunIndex"); -} - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabMeasurement::startStopAcquisition(){ if(btnStartStop->isChecked()){ @@ -349,14 +304,12 @@ void qTabMeasurement::startStopAcquisition(){ myDet->stopAcquisition(); /* commented out to prevent undefined state myDet->waitForReceiverReadToFinish(); - UpdateProgress(); //spin index disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); spinIndex->setValue(myDet->getFileIndex()); connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); progressTimer->stop(); - btnStartStop->setText("Start"); btnStartStop->setIcon(*iconStart); btnStartStop->setChecked(false); @@ -370,23 +323,18 @@ void qTabMeasurement::startStopAcquisition(){ void qTabMeasurement::UpdateFinished(){ - //if(btnStartStop->isChecked()){ + UpdateProgress(); + disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + spinIndex->setValue(myDet->getFileIndex()); + connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + progressTimer->stop(); - UpdateProgress(); - disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - spinIndex->setValue(myDet->getFileIndex()); - connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); - progressTimer->stop(); - - disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); - btnStartStop->setText("Start"); - btnStartStop->setIcon(*iconStart); - btnStartStop->setChecked(false); - Enable(1); - connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); - - - //} + disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); + btnStartStop->setText("Start"); + btnStartStop->setIcon(*iconStart); + btnStartStop->setChecked(false); + Enable(1); + connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition())); qDefs::checkErrorMessage(myDet,"qTabMeasurement::UpdateFinished"); } @@ -413,11 +361,48 @@ void qTabMeasurement::UpdateProgress(){ //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabMeasurement::setNumMeasurements(int val){ - myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,val); +void qTabMeasurement::setFileName(const QString& fName){ #ifdef VERBOSE - cout << "Setting Number of Measurements to " << (int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1) << endl; + cout << "Setting File name to " << fName.toAscii().constData() << endl; #endif + myDet->setFileName(fName.toAscii().data()); + + disconnect(dispFileName, SIGNAL(textChanged(const QString&)),this, SLOT(setFileName(const QString&))); + dispFileName->setText(QString(myDet->getFileName().c_str())); + connect(dispFileName, SIGNAL(textChanged(const QString&)),this, SLOT(setFileName(const QString&))); + + qDefs::checkErrorMessage(myDet,"qTabMeasurement::setFileName"); +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabMeasurement::setRunIndex(int index){ +#ifdef VERBOSE + cout << "Setting File Index to " << index << endl; +#endif + myDet->setFileIndex(index); + + disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + spinIndex->setValue(myDet->getFileIndex()); + connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(setRunIndex(int))); + + qDefs::checkErrorMessage(myDet,"qTabMeasurement::setRunIndex"); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabMeasurement::setNumMeasurements(int val){ +#ifdef VERBOSE + cout << "Setting Number of Measurements to " << val << endl; +#endif + myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,val); + + disconnect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); + spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1)); + connect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); + qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumMeasurements"); } @@ -426,11 +411,18 @@ void qTabMeasurement::setNumMeasurements(int val){ void qTabMeasurement::setNumFrames(int val){ - myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,val); #ifdef VERBOSE - cout << "Setting number of frames to " << (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1) << endl; + cout << "Setting number of frames to " << val << endl; #endif + myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,val); + + disconnect(spinNumFrames,SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); + spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); + connect(spinNumFrames,SIGNAL(valueChanged(int)), this, SLOT(setNumFrames(int))); + qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumFrames"); + + EnableProbes(); } @@ -438,17 +430,28 @@ void qTabMeasurement::setNumFrames(int val){ void qTabMeasurement::setExposureTime(){ - double exptimeNS; //Get the value of timer in ns - exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); + double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); #ifdef VERBOSE cout << "Setting acquisition time to " << exptimeNS << " clocks" << "/" << spinExpTime->value() << qDefs::getUnitString((qDefs::timeUnit)comboExpUnit->currentIndex()) << endl; #endif myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,(int64_t)exptimeNS); + //updating value set + disconnect(spinExpTime,SIGNAL(valueChanged(double)), this, SLOT(setExposureTime())); + disconnect(comboExpUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setExposureTime())); + qDefs::timeUnit unit; + double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); + spinExpTime->setValue(time); + comboExpUnit->setCurrentIndex((int)unit); + connect(spinExpTime,SIGNAL(valueChanged(double)), this, SLOT(setExposureTime())); + connect(comboExpUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setExposureTime())); + + //could be different if it didnt work + exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); + if(lblPeriod->isEnabled()){ - double acqtimeNS; - acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); + double acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); if(exptimeNS>acqtimeNS) { spinPeriod->setToolTip(errPeriodTip); lblPeriod->setToolTip(errPeriodTip); @@ -470,16 +473,27 @@ void qTabMeasurement::setExposureTime(){ void qTabMeasurement::setAcquisitionPeriod(){ - double acqtimeNS; //Get the value of timer in ns - acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); + double acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); #ifdef VERBOSE cout << "Setting frame period between exposures to " << acqtimeNS << " clocks"<< "/" << spinPeriod->value() << qDefs::getUnitString((qDefs::timeUnit)comboPeriodUnit->currentIndex()) << endl; #endif myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,(int64_t)acqtimeNS); - double exptimeNS; - exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); + //updating value set + disconnect(spinPeriod,SIGNAL(valueChanged(double)), this, SLOT(setAcquisitionPeriod())); + disconnect(comboPeriodUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setAcquisitionPeriod())); + qDefs::timeUnit unit; + double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); + spinPeriod->setValue(time); + comboPeriodUnit->setCurrentIndex((int)unit); + connect(spinPeriod,SIGNAL(valueChanged(double)), this, SLOT(setAcquisitionPeriod())); + connect(comboPeriodUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setAcquisitionPeriod())); + + //could be different if it didnt work + acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); + + double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); if(exptimeNS>acqtimeNS){ spinPeriod->setToolTip(errPeriodTip); lblPeriod->setToolTip(errPeriodTip); @@ -503,10 +517,15 @@ void qTabMeasurement::setAcquisitionPeriod(){ void qTabMeasurement::setNumTriggers(int val){ - myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,val); #ifdef VERBOSE - cout << "Setting number of triggers to " << (int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1) << endl; + cout << "Setting number of triggers to " << val << endl; #endif + myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,val); + + disconnect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); + spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); + connect(spinNumTriggers,SIGNAL(valueChanged(int)), this, SLOT(setNumTriggers(int))); + qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumTriggers"); } @@ -515,13 +534,24 @@ void qTabMeasurement::setNumTriggers(int val){ void qTabMeasurement::setDelay(){ - double exptimeNS; //Get the value of timer in ns - exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(),spinDelay->value()); + double exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(),spinDelay->value()); #ifdef VERBOSE cout << "Setting delay after trigger to " << exptimeNS << " clocks" << "/" << spinDelay->value() << qDefs::getUnitString((qDefs::timeUnit)comboDelayUnit->currentIndex()) << endl; #endif myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,(int64_t)exptimeNS); + + //updating value set + disconnect(spinDelay,SIGNAL(valueChanged(double)), this, SLOT(setDelay())); + disconnect(comboDelayUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); + qDefs::timeUnit unit; + double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); + spinDelay->setValue(time); + comboDelayUnit->setCurrentIndex((int)unit); + connect(spinDelay,SIGNAL(valueChanged(double)), this, SLOT(setDelay())); + connect(comboDelayUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(setDelay())); + + qDefs::checkErrorMessage(myDet,"qTabMeasurement::setDelay"); } @@ -530,10 +560,15 @@ void qTabMeasurement::setDelay(){ void qTabMeasurement::setNumGates(int val){ - myDet->setTimer(slsDetectorDefs::GATES_NUMBER,val); #ifdef VERBOSE - cout << "Setting number of gates to " << (int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1) << endl; + cout << "Setting number of gates to " << val << endl; #endif + myDet->setTimer(slsDetectorDefs::GATES_NUMBER,val); + + disconnect(spinNumGates,SIGNAL(valueChanged(int)), this, SLOT(setNumGates(int))); + spinNumGates->setValue((int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1)); + connect(spinNumGates,SIGNAL(valueChanged(int)), this, SLOT(setNumGates(int))); + qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumGates"); } @@ -542,10 +577,24 @@ void qTabMeasurement::setNumGates(int val){ void qTabMeasurement::setNumProbes(int val){ - myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,val); #ifdef VERBOSE - cout << "Setting number of frames to " << (int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1) << endl; + cout << "Setting number of probes to " << val << endl; #endif + myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,val); + + disconnect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); + spinNumProbes->setValue((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1)); + connect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); + + qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumProbes"); + + //Setting number of probes should reset number of triggers to 1, need to check if enabled, cuz its updated when refresh + if((spinNumProbes->isEnabled()) && (val > 0) && (spinNumTriggers->value() != 1)){ + qDefs::Message(qDefs::INFORMATION,"Number of Triggers has been reset to 1.
" + "This is mandatory to use probes.","qTabMeasurement::setNumProbes"); + cout << "Resetting Number of triggers to 1" << endl; + spinNumTriggers->setValue(1); + } qDefs::checkErrorMessage(myDet,"qTabMeasurement::setNumProbes"); } @@ -570,13 +619,13 @@ void qTabMeasurement::SetTimingMode(int mode){ switch(mode){ case None://Exposure Time lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); - setNumFrames(1); - setNumTriggers(1); + spinNumTriggers->setValue(1); + spinNumFrames->setValue(1); if(myDet->setExternalCommunicationMode(slsDetectorDefs::AUTO_TIMING)==slsDetectorDefs::AUTO_TIMING) success = true; break; case Auto://#Frames, ExpTime, Period - setNumTriggers(1); + spinNumTriggers->setValue(1); lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); @@ -593,14 +642,14 @@ void qTabMeasurement::SetTimingMode(int mode){ success = true; break; case Trigger_Frame://ExpTime, #Triggers - setNumFrames(1); + spinNumFrames->setValue(1); lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); lblNumTriggers->setEnabled(true); spinNumTriggers->setEnabled(true); if(myDet->setExternalCommunicationMode(slsDetectorDefs::TRIGGER_FRAME)==slsDetectorDefs::TRIGGER_FRAME) success = true; break; case Trigger_Readout://#Frames, ExpTime, Period, Delay - setNumTriggers(1); + spinNumTriggers->setValue(1); lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); lblExpTime->setEnabled(true); spinExpTime->setEnabled(true); comboExpUnit->setEnabled(true); lblPeriod->setEnabled(true); spinPeriod->setEnabled(true); comboPeriodUnit->setEnabled(true); @@ -609,7 +658,7 @@ void qTabMeasurement::SetTimingMode(int mode){ success = true; break; case Gated://#Frames, #Gates - setNumTriggers(1); + spinNumTriggers->setValue(1); lblNumFrames->setEnabled(true); spinNumFrames->setEnabled(true); lblNumGates->setEnabled(true); spinNumGates->setEnabled(true); if(myDet->setExternalCommunicationMode(slsDetectorDefs::GATE_FIX_NUMBER)==slsDetectorDefs::GATE_FIX_NUMBER) @@ -625,7 +674,7 @@ void qTabMeasurement::SetTimingMode(int mode){ success = true; break; case Trigger_Window://#Triggers - setNumFrames(1); + spinNumFrames->setValue(1); lblNumTriggers->setEnabled(true); spinNumTriggers->setEnabled(true); if(myDet->setExternalCommunicationMode(slsDetectorDefs::TRIGGER_WINDOW)==slsDetectorDefs::TRIGGER_WINDOW) success = true; @@ -642,53 +691,18 @@ void qTabMeasurement::SetTimingMode(int mode){ "Please check the external flags." "\n\nSetting the following defaults:\nTiming Mode \t: None\n" "Number of Frames \t: 1\nNumber of Triggers \t: 1","qTabMeasurement::SetTimingMode"); + spinNumFrames->setValue(1); + spinNumTriggers->setValue(1); comboTimingMode->setCurrentIndex((int)None); return; } - //Number of Probes - if((expertMode)&&(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN)){ - lblNumProbes->setEnabled(true); spinNumProbes->setEnabled(true); - } - - - //To disconnect all the signals before changing their values - DeInitialization(); - - - double time; - int val; - qDefs::timeUnit unit; - //Number of Frames - if(lblNumFrames->isEnabled()){ - val = (int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1); - spinNumFrames->setValue(val); -#ifdef VERBOSE - cout << "Getting number of frames : " << val <isEnabled()){ - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); -#ifdef VERBOSE - cout << "Getting acquisition time : " << time << qDefs::getUnitString(unit) << endl; -#endif - spinExpTime->setValue(time); - comboExpUnit->setCurrentIndex((int)unit); - } - //Frame Period between exposures + double exptimeNS,acqtimeNS; + double time; + qDefs::timeUnit unit; if(lblPeriod->isEnabled()){ - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); -#ifdef VERBOSE - cout << "Getting frame period between exposures : " << time << qDefs::getUnitString(unit) << endl; -#endif - spinPeriod->setValue(time); - comboPeriodUnit->setCurrentIndex((int)unit); - - double exptimeNS,acqtimeNS; exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); if(exptimeNS>acqtimeNS) { @@ -712,46 +726,9 @@ void qTabMeasurement::SetTimingMode(int mode){ lblPeriod->setText("Acquisition Period:"); } - //Number of Triggers - if(lblNumTriggers->isEnabled()){ - val = (int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1); - spinNumTriggers->setValue(val); -#ifdef VERBOSE - cout << "Getting number of triggers : " << val <isEnabled()){ - time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); -#ifdef VERBOSE - cout << "Getting delay after trigger : " << time << qDefs::getUnitString(unit) << endl; -#endif - spinDelay->setValue(time); - comboDelayUnit->setCurrentIndex((int)unit); - } - - //Number of Gates - if(lblNumGates->isEnabled()){ - val = (int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1); - spinNumGates->setValue(val); -#ifdef VERBOSE - cout << "Getting number of gates : " << val << endl; -#endif - } - - // Number of Probes - if(lblNumProbes->isEnabled()){ - val = (int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1); - spinNumProbes->setValue(val); -#ifdef VERBOSE - cout << "Getting number of probes : " << val << endl; -#endif - } - - //To reconnect all the signals after changing their values - Initialization(1); + //Check if Number of Probes should be enabled + EnableProbes(); // to let qdrawplot know that triggers or frames are used myPlot->setFrameEnabled(lblNumFrames->isEnabled()); @@ -776,6 +753,11 @@ void qTabMeasurement::EnableFileWrite(bool enable){ dispFileName->setEnabled(enable); if(enable) setFileName(dispFileName->text()); myPlot->SetEnableFileWrite(enable); + + disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + chkFile->setChecked(myDet->enableWriteToFile()); + connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(EnableFileWrite(bool))); + qDefs::checkErrorMessage(myDet,"qTabMeasurement::EnableFileWrite"); }; @@ -790,23 +772,76 @@ void qTabMeasurement::Refresh(){ if(!myPlot->isRunning()){ //Number of measurements + spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1)); #ifdef VERBOSE cout << "Getting number of measurements" << endl; #endif - spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1)); + //Number of frames + spinNumFrames->setValue((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); +#ifdef VERBOSE + cout << "Getting number of frames" << endl; +#endif + //Exp Time + qDefs::timeUnit unit; + double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); + spinExpTime->setValue(time); + comboExpUnit->setCurrentIndex((int)unit); +#ifdef VERBOSE + cout << "Getting Exposure time" << endl; +#endif + + //period + time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); + spinPeriod->setValue(time); + comboPeriodUnit->setCurrentIndex((int)unit); +#ifdef VERBOSE + cout << "Getting Acquisition Period" << endl; +#endif + + //Number of Triggers + spinNumTriggers->setValue((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); +#ifdef VERBOSE + cout << "Getting number of triggers" << endl; +#endif + + //delay + time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); + spinDelay->setValue(time); + comboDelayUnit->setCurrentIndex((int)unit); +#ifdef VERBOSE + cout << "Getting delay after trigger" << endl; +#endif + + //gates + spinNumGates->setValue((int)myDet->setTimer(slsDetectorDefs::GATES_NUMBER,-1)); +#ifdef VERBOSE + cout << "Getting number of gates" << endl; +#endif + + //probes + spinNumProbes->setValue((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1)); +#ifdef VERBOSE + cout << "Getting number of probes" << endl; +#endif //File Name -#ifdef VERBOSE - cout << "Getting file name" << endl; -#endif dispFileName->setText(QString(myDet->getFileName().c_str())); +#ifdef VERBOSE + cout << "Getting file name prefix" << endl; +#endif //File Index + spinIndex->setValue(myDet->getFileIndex()); #ifdef VERBOSE cout << "Getting file index" << endl; #endif - spinIndex->setValue(myDet->getFileIndex()); + + //file write enabled/disabled + chkFile->setChecked(myDet->enableWriteToFile()); +#ifdef VERBOSE + cout << "Getting file write enable" << endl; +#endif //progress label index if(myDet->getFrameIndex()==-1) @@ -814,7 +849,7 @@ void qTabMeasurement::Refresh(){ else lblProgressIndex->setText(QString::number(myDet->getFrameIndex())); - //Timing mode + //Timing mode - will also check if exptime>acq period and also enableprobes() SetupTimingMode(); // to let qdrawplot know that triggers or frames are used @@ -830,4 +865,34 @@ void qTabMeasurement::Refresh(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabMeasurement::EnableProbes(){ +#ifdef VERBOSE + cout << "Validating if probes should be enabled" << endl; +#endif + //enabled only in expert mode and if #Frames > 1 + if((expertMode)&&(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN)&&(spinNumFrames->value()>1)){ + lblNumProbes->setEnabled(true); + spinNumProbes->setEnabled(true); + disconnect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); + spinNumProbes->setValue((int)myDet->setTimer(slsDetectorDefs::PROBES_NUMBER,-1)); + connect(spinNumProbes,SIGNAL(valueChanged(int)), this, SLOT(setNumProbes(int))); +#ifdef VERBOSE + cout << "Getting number of probes : " << spinNumProbes->value() << endl; +#endif + //ensure that #triggers is reset + setNumProbes(spinNumProbes->value()); + + qDefs::checkErrorMessage(myDet,"qTabMeasurement::EnableProbes"); + return; + } + cout << "Probes not enabled" << endl; + spinNumProbes->setValue(0); + lblNumProbes->setEnabled(false); + spinNumProbes->setEnabled(false); +} + + //-------------------------------------------------------------------------------------------------------------------------------------------------