diff --git a/slsDetectorGui/forms/form_detectormain.ui b/slsDetectorGui/forms/form_detectormain.ui index 06396987c..60a1a4afe 100644 --- a/slsDetectorGui/forms/form_detectormain.ui +++ b/slsDetectorGui/forms/form_detectormain.ui @@ -241,7 +241,6 @@ &Modes - diff --git a/slsDetectorGui/forms/form_tab_advanced.ui b/slsDetectorGui/forms/form_tab_advanced.ui index 1478fff63..374ac2249 100644 --- a/slsDetectorGui/forms/form_tab_advanced.ui +++ b/slsDetectorGui/forms/form_tab_advanced.ui @@ -656,7 +656,7 @@ Plots Trimbits from Detector. This will take time. - + 405 diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h index d8494a4c0..0e798f0c6 100644 --- a/slsDetectorGui/include/qDetectorMain.h +++ b/slsDetectorGui/include/qDetectorMain.h @@ -123,9 +123,13 @@ private: * */ void Initialization(); + /** Loads config file at start up + * */ + void LoadConfigFile(const string fName); + private slots: -/** Enables modes as selected -Debug, Beamline, Expert, Dockable(calls setdockablemode()) +/** Enables modes as selected -Debug, Expert, Dockable(calls setdockablemode()) * */ void EnableModes(QAction *action); diff --git a/slsDetectorGui/include/qTabAdvanced.h b/slsDetectorGui/include/qTabAdvanced.h index 0f5dd3bab..30462698f 100644 --- a/slsDetectorGui/include/qTabAdvanced.h +++ b/slsDetectorGui/include/qTabAdvanced.h @@ -113,6 +113,8 @@ private: /** Trimming mode */ slsDetectorDefs::trimMode trimmingMode; + bool isEnergy; + bool isAngular; }; diff --git a/slsDetectorGui/slsDetectorGui.pro b/slsDetectorGui/slsDetectorGui.pro index 5fd91c07c..bdd716277 100644 --- a/slsDetectorGui/slsDetectorGui.pro +++ b/slsDetectorGui/slsDetectorGui.pro @@ -6,7 +6,7 @@ UI_HEADERS_DIR = forms/include RESOURCES += icons.qrc -DEFINES += VERBOSE VERYVERBOSE #DACS_INT #VERYVERBOSE +DEFINES += VERBOSE #DACS_INT #VERYVERBOSE target.path += $(DESTDIR) diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index c97da8e0a..7ea0fb139 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -48,11 +48,12 @@ int main (int argc, char **argv) { qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent) : QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(NULL),tabs(NULL),isDeveloper(0){ + string configFName = ""; // Getting all the command line arguments for(int iarg=1; iargsetTabEnabled(Debugging,false); - //beamline mode to false tabs->setTabEnabled(Advanced,false); + tabs->setTabEnabled(Developer,isDeveloper); actionLoadTrimbits->setVisible(false); actionSaveTrimbits->setVisible(false); actionLoadCalibration->setVisible(false); actionSaveCalibration->setVisible(false); + dockWidgetPlot->setFloating(false); dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); - tabs->setTabEnabled(Developer,isDeveloper); - if(!digitalDetector) actionExpert->setEnabled(false); -#ifdef VERBOSE - cout << "Advanced Enabled:" << digitalDetector << endl; -#endif + // Other setup //Height of plot and central widget heightPlotWindow = dockWidgetPlot->size().height(); @@ -175,7 +176,7 @@ void qDetectorMain::SetUpDetector(){ //instantiate detector and set window title - myDet = new multiSlsDetector(); + myDet = new multiSlsDetector(detID); string host = myDet->getHostname(); //if hostname doesnt exist even in shared memory @@ -198,11 +199,10 @@ void qDetectorMain::SetUpDetector(){ // Check if type valid. If not, exit slsDetectorDefs::detectorType detType = myDet->getDetectorsType(); switch(detType){ - //digitalDetector decides if trimbits should be shown - case slsDetectorDefs::MYTHEN: digitalDetector = true; break; - case slsDetectorDefs::EIGER: digitalDetector = true; break; - case slsDetectorDefs::GOTTHARD: digitalDetector = false;break; - case slsDetectorDefs::AGIPD: digitalDetector = false;break; + case slsDetectorDefs::MYTHEN: break; + case slsDetectorDefs::EIGER: break; + case slsDetectorDefs::GOTTHARD: actionLoadTrimbits->setText("Load Settings"); actionSaveTrimbits->setText("Save Settings"); break; + case slsDetectorDefs::AGIPD: actionLoadTrimbits->setText("Load Settings"); actionSaveTrimbits->setText("Save Settings"); break; default: string detName = myDet->slsDetectorBase::getDetectorType(detType); string errorMess = host+string(" has unknown detector type \"")+ @@ -236,9 +236,11 @@ void qDetectorMain::Initialization(){ connect(tab_measurement, SIGNAL(EnableNthFrameSignal(bool)), tab_plot,SLOT(EnableNthFrame(bool))); // Data Output Tab connect(tab_dataoutput, SIGNAL(AngularConversionSignal(bool)), tab_actions,SLOT(EnablePositions(bool))); + //enable scanbox( for angles) + connect(tab_dataoutput, SIGNAL(AngularConversionSignal(bool)), tab_plot,SLOT(EnableScanBox())); // Plot tab connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool))); - // Actions tab (also for angles) + // Actions tab (only for scan) connect(tab_actions, SIGNAL(EnableScanBox()), tab_plot,SLOT(EnableScanBox())); //settings to advanced tab(int=id is always 0 to only refresh) connect(tab_settings, SIGNAL(UpdateTrimbitSignal(int)), tab_advanced,SLOT(UpdateTrimbitPlot(int))); @@ -259,6 +261,23 @@ void qDetectorMain::Initialization(){ } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qDetectorMain::LoadConfigFile(const string fName){ +#ifdef VERBOSe + cout << "Loading config file at start up:" << fName << endl; +#endif + QString file = QString(fName.c_str());//.section('/',-1); + if((file.contains('.'))&&(QFile::exists(file))){ + if(myDet->readConfigurationFile(fName)!=slsDetectorDefs::FAIL) + qDefs::Message(qDefs::INFORMATION,"The Configuration Parameters have been loaded successfully at start up.","Main"); + else qDefs::Message(qDefs::WARNING,string("Could not load the Configuration Parameters at start up from file:\n")+fName,"Main"); + }else qDefs::Message(qDefs::WARNING,string("Start up configuration failed to load. The following file does not exist:\n")+fName,"Main"); +} + + //------------------------------------------------------------------------------------------------------------------------------------------------- @@ -274,14 +293,6 @@ void qDetectorMain::EnableModes(QAction *action){ #endif } - //Set BeamlineMode - else if(action==actionBeamline){ - enable = actionBeamline->isChecked(); -#ifdef VERBOSE - cout << "Setting Beamline Mode to " << enable << endl; -#endif - } - //Set ExpertMode(comes here only if its a digital detector) else if(action==actionExpert){ enable = actionExpert->isChecked(); @@ -291,13 +302,8 @@ void qDetectorMain::EnableModes(QAction *action){ actionSaveTrimbits->setVisible(enable); actionLoadCalibration->setVisible(enable); actionSaveCalibration->setVisible(enable); - - if(digitalDetector){ - tab_measurement->SetExpertMode(enable); - tab_settings->SetExpertMode(enable); - } - - + tab_measurement->SetExpertMode(enable); + tab_settings->SetExpertMode(enable); #ifdef VERBOSE cout << "Setting Expert Mode to " << enable << endl; #endif @@ -385,33 +391,71 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ } } else if(action==actionLoadTrimbits){ -#ifdef VERBOSE - cout << "Loading Trimbits" << endl; -#endif QString fName = QString(myDet->getSettingsDir()); - fName = QFileDialog::getOpenFileName(this, - tr("Load Detector Trimbits"),fName, - tr("Trimbit files (*.trim noise.sn*)")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Trimbits have been loaded successfully.","Main"); - else qDefs::Message(qDefs::WARNING,string("Could not load the Trimbits from file:\n")+fName.toAscii().constData(),"Main"); + //gotthard + if(actionLoadTrimbits->text().contains("Settings")){ +#ifdef VERBOSE + cout << "Loading Settings" << endl; +#endif + fName = QFileDialog::getOpenFileName(this, + tr("Load Detector Settings"),fName, + tr("Settings files (*.settings settings.sn*)")); + // Gets called when cancelled as well + if (!fName.isEmpty()){ + if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) + qDefs::Message(qDefs::INFORMATION,"The Settings have been loaded successfully.","Main"); + else qDefs::Message(qDefs::WARNING,string("Could not load the Settings from file:\n")+fName.toAscii().constData(),"Main"); + } + + }//mythen and eiger + else{ +#ifdef VERBOSE + cout << "Loading Trimbits" << endl; +#endif + + fName = QFileDialog::getOpenFileName(this, + tr("Load Detector Trimbits"),fName, + tr("Trimbit files (*.trim noise.sn*)")); + // Gets called when cancelled as well + if (!fName.isEmpty()){ + if(myDet->loadSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) + qDefs::Message(qDefs::INFORMATION,"The Trimbits have been loaded successfully.","Main"); + else qDefs::Message(qDefs::WARNING,string("Could not load the Trimbits from file:\n")+fName.toAscii().constData(),"Main"); + } } } else if(action==actionSaveTrimbits){ + //gotthard + if(actionLoadTrimbits->text().contains("Settings")){ #ifdef VERBOSE - cout << "Saving Trimbits" << endl; + cout << "Saving Settings" << endl; +#endif + //different output directory so as not to overwrite + QString fName = QString(myDet->getSettingsDir()); + fName = QFileDialog::getSaveFileName(this, + tr("Save Current Detector Settings"),fName, + tr("Settings files (*.settings settings.sn*) ")); + // Gets called when cancelled as well + if (!fName.isEmpty()){ + if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) + qDefs::Message(qDefs::INFORMATION,"The Settings have been saved successfully.","Main"); + else qDefs::Message(qDefs::WARNING,string("Could not save the Settings to file:\n")+fName.toAscii().constData(),"Main"); + } + }//mythen and eiger + else{ +#ifdef VERBOSE + cout << "Saving Trimbits" << endl; #endif//different output directory so as not to overwrite - QString fName = QString(myDet->getSettingsDir()); - fName = QFileDialog::getSaveFileName(this, - tr("Save Current Detector Trimbits"),fName, - tr("Trimbit files (*.trim noise.sn*) ")); - // Gets called when cancelled as well - if (!fName.isEmpty()){ - if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) - qDefs::Message(qDefs::INFORMATION,"The Trimbits have been saved successfully.","Main"); - else qDefs::Message(qDefs::WARNING,string("Could not save the Trimbits to file:\n")+fName.toAscii().constData(),"Main"); + QString fName = QString(myDet->getSettingsDir()); + fName = QFileDialog::getSaveFileName(this, + tr("Save Current Detector Trimbits"),fName, + tr("Trimbit files (*.trim noise.sn*) ")); + // Gets called when cancelled as well + if (!fName.isEmpty()){ + if(myDet->saveSettingsFile(string(fName.toAscii().constData()),-1)!=slsDetectorDefs::FAIL) + qDefs::Message(qDefs::INFORMATION,"The Trimbits have been saved successfully.","Main"); + else qDefs::Message(qDefs::WARNING,string("Could not save the Trimbits to file:\n")+fName.toAscii().constData(),"Main"); + } } } else if(action==actionLoadCalibration){ @@ -579,41 +623,20 @@ void qDetectorMain::EnableTabs(){ actionSaveConfiguration->setEnabled(enable); actionMeasurementWizard->setEnabled(enable); actionDebug->setEnabled(enable); - actionBeamline->setEnabled(enable); actionExpert->setEnabled(enable); // special tabs - if(enable==false){ - tabs->setTabEnabled(Debugging,enable); - tabs->setTabEnabled(Advanced,enable); - actionLoadTrimbits->setVisible(false); - actionSaveTrimbits->setVisible(false); - actionLoadCalibration->setVisible(false); - actionSaveCalibration->setVisible(false); - tabs->setTabEnabled(Developer,enable); - } - else{ - // enable these tabs only if they were enabled earlier - if(actionDebug->isChecked()) - tabs->setTabEnabled(Debugging,enable); - if(actionExpert->isChecked()){ - tabs->setTabEnabled(Advanced,enable); - if((enable)&&(digitalDetector)){ - actionLoadTrimbits->setVisible(true); - actionSaveTrimbits->setVisible(true); - actionLoadCalibration->setVisible(true); - actionSaveCalibration->setVisible(true); - }else{ - actionLoadTrimbits->setVisible(false); - actionSaveTrimbits->setVisible(false); - actionLoadCalibration->setVisible(false); - actionSaveCalibration->setVisible(false); - } - } - if(isDeveloper) - tabs->setTabEnabled(Developer,enable); - } + tabs->setTabEnabled(Debugging,enable && (actionDebug->isChecked())); + tabs->setTabEnabled(Developer,enable && isDeveloper); + //expert + bool expertTab = enable && (actionExpert->isChecked()); + tabs->setTabEnabled(Advanced,expertTab); + actionLoadTrimbits->setVisible(expertTab); + actionSaveTrimbits->setVisible(expertTab); + actionLoadCalibration->setVisible(expertTab); + actionSaveCalibration->setVisible(expertTab); + } diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 99421e7b8..c7e12b13b 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -468,13 +468,14 @@ void qDrawPlot::SetupMeasurement(int currentIndex){ endPixel = maxPixelsY + (pixelWidth/2); } } - - cout<<"\nnPixelsY:"<angles==NULL){ + cout<<"\n\nWARNING:RETURNED NULL instead of angles."<values,nAnglePixelsX*sizeof(double)); + SetHistXAxisTitle("Channel Number"); + + } + else{ + + lastImageNumber= currentFrame+1; + nAnglePixelsX = data->npoints; + histNBins = nAnglePixelsX; + nHists=1; + if(histXAngleAxis) delete [] histXAngleAxis; histXAngleAxis = new double[nAnglePixelsX]; + if(histYAngleAxis) delete [] histYAngleAxis; histYAngleAxis = new double[nAnglePixelsX]; + memcpy(histXAngleAxis,data->angles,nAnglePixelsX*sizeof(double)); + memcpy(histYAngleAxis,data->values,nAnglePixelsX*sizeof(double)); + SetHistXAxisTitle("Angles"); + } + pthread_mutex_unlock(&(last_image_complete_mutex)); + } + currentFrame++; + return 0; + } + + + //Nth Frame if(frameFactor){ //plots if numfactor becomes 0 @@ -535,7 +573,7 @@ int qDrawPlot::GetData(detectorData *data){ //Not Nth Frame, to check time out(NOT for 2dScans and angle plots) else{ - if((scanArgument==None)&&(!anglePlot)){ + if(scanArgument==None){ //if the time is not over, RETURN if(!data_pause_over){ return 0; @@ -548,25 +586,6 @@ int qDrawPlot::GetData(detectorData *data){ - //angle plotting - if(anglePlot){ - if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ - lastImageNumber= currentFrame+1; - nAnglePixelsX = data->npoints; - histNBins = nAnglePixelsX; - nHists=1; - if(histXAngleAxis) delete [] histXAngleAxis; histXAngleAxis = new double[nAnglePixelsX]; - if(histYAngleAxis) delete [] histYAngleAxis; histYAngleAxis = new double[nAnglePixelsX]; - memcpy(histXAngleAxis,data->angles,nAnglePixelsX*sizeof(double)); - memcpy(histYAngleAxis,data->values,nAnglePixelsX*sizeof(double)); - pthread_mutex_unlock(&(last_image_complete_mutex)); - } - currentFrame++; - return 0; - } - - - //if scan argument is 2d if(scanArgument!=None){ //alframes @@ -708,9 +727,12 @@ int qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress,int detecto int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){ +#ifdef VERBOSE + cout << "\nEntering Acquisition Finished with status " ; +#endif QString status = QString(slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detectorStatus)).c_str()); #ifdef VERBOSE - cout << "\nEntering Acquisition Finished with status " << status.toAscii().constData() << " and progress " << currentProgress << endl; + cout << status.toAscii().constData() << " and progress " << currentProgress << endl; #endif //error or stopped if((stop_signal)||(detectorStatus==slsDetectorDefs::ERROR)){ @@ -766,7 +788,8 @@ int qDrawPlot::MeasurementFinished(int currentMeasurementIndex, int fileIndex){ cout << "Entering Measurement Finished with currentMeasurement " << currentMeasurementIndex << " and fileIndex " << fileIndex << endl; #endif //to make sure it plots the last frame before setting lastimagearray all to 0 - if(plot_in_scope==2) usleep(500000); + //if(plot_in_scope==2) + usleep(500000); currentMeasurement = currentMeasurementIndex + 1; #ifdef VERBOSE @@ -827,6 +850,9 @@ void qDrawPlot::UpdatePlot(){ //1-d plot stuff if(plot_in_scope==1){ if(lastImageNumber){ +#ifdef VERYVERBOSE + cout << "Last Image Number:" << lastImageNumber << endl; +#endif if(histNBins){ Clear1DPlot(); plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); @@ -902,7 +928,9 @@ void qDrawPlot::UpdatePlot(){ else plot_update_timer->start((int)PLOT_TIMER_MS); } - +#ifdef VERYVERBOSE + cout << "Exiting UpdatePlot function" << endl; +#endif } @@ -1071,20 +1099,6 @@ void qDrawPlot::SavePlot(){ } -//------------------------------------------------------------------------------------------------------------------------------------------------- - -/* - -void qDrawPlot::SaveAll(bool enable){ - string msg = string("The Files will be saved as:\n")+ - string(myDet->getFilePath().c_str())+string("/")+ - string(myDet->getFileName().c_str())+string("[title].png"); - qDefs::Message(qDefs::INFORMATION,msg,"Dock"); - saveAll = enable; -} -*/ - - //------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qTabActions.cpp b/slsDetectorGui/src/qTabActions.cpp index 46d9d5bb6..da533052b 100644 --- a/slsDetectorGui/src/qTabActions.cpp +++ b/slsDetectorGui/src/qTabActions.cpp @@ -324,7 +324,6 @@ void qTabActions::SetPosition(){ qDefs::Message(qDefs::WARNING,"The positions list was not set for some reason.","Actions"); - emit EnableScanBox(); } @@ -375,6 +374,7 @@ void qTabActions::EnablePositions(bool enable){ lblName[NumPositions]->setEnabled(false); btnExpand[NumPositions]->setEnabled(false); } + } @@ -383,7 +383,7 @@ void qTabActions::EnablePositions(bool enable){ void qTabActions::Refresh(){ #ifdef VERBOSE - cout << "\nUpdating all action widgets: " << endl; + cout << endl <<"**Updating all action widgets: " << endl; #endif if((detType == slsDetectorDefs::MYTHEN) || (detType == slsDetectorDefs::GOTTHARD)){ //positions is enabled only if angular conversion is enabled @@ -428,8 +428,10 @@ void qTabActions::Refresh(){ scanWidget[i]->Refresh(); for(int i=0;iRefresh(); - cout << endl; UpdateCollapseColors(); +#ifdef VERBOSE + cout << "**Updated all action widgets: " << endl << endl; +#endif } diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index 08412ada6..defb1032b 100644 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -21,7 +21,7 @@ using namespace std; qTabAdvanced::qTabAdvanced(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot): - QWidget(parent),myDet(detector),myPlot(plot),btnGroup(NULL){ + QWidget(parent),myDet(detector),myPlot(plot),btnGroup(NULL),isEnergy(false),isAngular(false){ setupUi(this); SetupWidgetWindow(); } @@ -42,27 +42,42 @@ qTabAdvanced::~qTabAdvanced(){ void qTabAdvanced::SetupWidgetWindow(){ //executed even for non digital, so make sure its necessary slsDetectorDefs::detectorType detType = myDet->getDetectorsType(); - if((detType==slsDetectorDefs::MYTHEN)||(detType==slsDetectorDefs::EIGER)){ - outputDirTip = dispFile->toolTip(); - errOutputTip = QString("

" - "Output Trim File should contain both existing directory and a file name.
" - "The extensions are automatically added.

" - "Enter valid Output Trim File to enable Start Trimming button.
"); - red = QPalette(); - red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); - - boxTrimming->setChecked(false); - SetOptimize(false); - - btnGroup = new QButtonGroup(this); - btnGroup->addButton(btnRefresh,0); - btnGroup->addButton(btnGetTrimbits,1); + switch(detType){ + case slsDetectorDefs::MYTHEN: isEnergy = true; isAngular = true; break; + case slsDetectorDefs::EIGER: isEnergy = true; isAngular = false; break; + case slsDetectorDefs::GOTTHARD: isEnergy = false; isAngular = true; break; + default: break; + } + if(!isAngular && !isEnergy) boxLogs->setEnabled(false); + else{ + if(!isAngular) chkAngularLog->setEnabled(false); + if(!isEnergy){ + chkEnergyLog->setEnabled(false); + boxPlot->setEnabled(false); + boxTrimming->setEnabled(false); + } + else{ + outputDirTip = dispFile->toolTip(); + errOutputTip = QString("

" + "Output Trim File should contain both existing directory and a file name.
" + "The extensions are automatically added.

" + "Enter valid Output Trim File to enable Start Trimming button.
"); + red = QPalette(); + red.setColor(QPalette::Active,QPalette::WindowText,Qt::red); + + boxTrimming->setChecked(false); + SetOptimize(false); + + btnGroup = new QButtonGroup(this); + btnGroup->addButton(btnRefresh,0); + btnGroup->addButton(btnGetTrimbits,1); + } + Initialization(); } - } @@ -71,35 +86,38 @@ void qTabAdvanced::SetupWidgetWindow(){ void qTabAdvanced::Initialization(){ //energy/angular logs - connect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - connect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); + if(isAngular) + connect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - //exptime - connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); - connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); + if(isEnergy){ + connect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - //threshold dac - connect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); + //exptime + connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); + connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); - //output directory - connect(dispFile, SIGNAL(editingFinished()), this, SLOT(SetOutputFile())); - connect(btnFile, SIGNAL(clicked()), this, SLOT(BrowseOutputFile())); + //threshold dac + connect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); - //enable trimming method group box - connect(boxTrimming, SIGNAL(toggled(bool)), this, SLOT(EnableTrimming(bool))); + //output directory + connect(dispFile, SIGNAL(editingFinished()), this, SLOT(SetOutputFile())); + connect(btnFile, SIGNAL(clicked()), this, SLOT(BrowseOutputFile())); - //trimming method combo - connect(comboMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTrimmingMethod(int))); + //enable trimming method group box + connect(boxTrimming, SIGNAL(toggled(bool)), this, SLOT(EnableTrimming(bool))); - //method options - connect(chkOptimize, SIGNAL(toggled(bool)), this, SLOT(SetOptimize(bool))); + //trimming method combo + connect(comboMethod, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTrimmingMethod(int))); - //start Trimming - connect(btnStart, SIGNAL(clicked()), this, SLOT(StartTrimming())); + //method options + connect(chkOptimize, SIGNAL(toggled(bool)), this, SLOT(SetOptimize(bool))); - //refresh - connect(btnGroup, SIGNAL(buttonClicked(int)), this, SLOT(UpdateTrimbitPlot(int))); + //start Trimming + connect(btnStart, SIGNAL(clicked()), this, SLOT(StartTrimming())); + //refresh + connect(btnGroup, SIGNAL(buttonClicked(int)), this, SLOT(UpdateTrimbitPlot(int))); + } } @@ -295,7 +313,7 @@ void qTabAdvanced::SetTrimmingMethod(int mode){ void qTabAdvanced::StartTrimming(){ - int parameter1, parameter2; + int parameter1=0, parameter2=0; //optimize bool optimize = chkOptimize->isChecked(); @@ -364,45 +382,66 @@ void qTabAdvanced::UpdateTrimbitPlot(int id){ void qTabAdvanced::Refresh(){ - //disconnect - disconnect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - disconnect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - disconnect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); - disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); - disconnect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); - - //energy/angular logs - chkEnergyLog->setChecked(myDet->getActionMode(slsDetectorDefs::enCalLog)); - chkAngularLog->setChecked(myDet->getActionMode(slsDetectorDefs::angCalLog)); #ifdef VERBOSE - cout << "Energy Calibration Log set to " << chkEnergyLog->isChecked() << endl; - cout << "Angular Calibration Log set to " << chkAngularLog->isChecked() << endl; + cout << endl << "**Updating Advanced Tab" << endl; #endif - //exptime - qDefs::timeUnit unit; - double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); + if(isAngular){ #ifdef VERBOSE - cout << "Getting acquisition time : " << time << qDefs::getUnitString(unit) << endl; + cout << "Angular Calibration Log set to " << chkAngularLog->isChecked() << endl; #endif - spinExpTime->setValue(time); - comboExpUnit->setCurrentIndex((int)unit); + + disconnect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); + + chkAngularLog->setChecked(myDet->getActionMode(slsDetectorDefs::angCalLog)); + + connect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); + } - //threshold - double threshold = (double)myDet->setDAC(-1,slsDetectorDefs::THRESHOLD); + if(isEnergy){ + //disconnect + disconnect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); + disconnect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); + disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); + disconnect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); + + + //energy/angular logs + chkEnergyLog->setChecked(myDet->getActionMode(slsDetectorDefs::enCalLog)); +#ifdef VERBOSE + cout << "Energy Calibration Log set to " << chkEnergyLog->isChecked() << endl; +#endif + + + //exptime + qDefs::timeUnit unit; + double 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); + + + //threshold + double threshold = (double)myDet->setDAC(-1,slsDetectorDefs::THRESHOLD); #ifdef VERBOSE cout << "Getting Threshold DACu : " << threshold << endl; #endif - spinThreshold->setValue(threshold); + spinThreshold->setValue(threshold); - //connect - connect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - connect(chkAngularLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); - connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); - connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); - connect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); + //connect + connect(chkEnergyLog, SIGNAL(toggled(bool)), this, SLOT(SetLogs())); + connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); + connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); + connect(spinThreshold, SIGNAL(valueChanged(double)), this, SLOT(SetThreshold())); + } + +#ifdef VERBOSE + cout << "**Updated Advanced Tab" << endl << endl; +#endif } diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index 18b68a98e..9096c4471 100644 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -30,8 +30,6 @@ qTabDataOutput::qTabDataOutput(QWidget *parent,multiSlsDetector*& detector): QWidget(parent),myDet(detector){ setupUi(this); SetupWidgetWindow(); - Initialization(); - Refresh(); } @@ -66,6 +64,52 @@ void qTabDataOutput::SetupWidgetWindow(){ QString("" "Enter a valid file to enable Flat Field."); + + Initialization(); + + + // output dir +#ifdef VERBOSE + cout << "Getting output directory" << endl; +#endif + dispOutputDir->setText(QString(myDet->getFilePath().c_str())); + + + //flat field correction from server +#ifdef VERBOSE + cout << "Getting flat field" << endl; +#endif + UpdateFlatFieldFromServer(); + + + //rate correction - not for charge integrating detectors + if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)){ +#ifdef VERBOSE + cout << "Getting rate correction" << endl; +#endif + UpdateRateCorrectionFromServer(); + } + + + //update angular conversion from server + if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::GOTTHARD)){ +#ifdef VERBOSE + cout << "Getting angular conversion" << endl; +#endif + int ang; + if(myDet->getAngularConversion(ang)) + chkAngular->setChecked(true); + emit AngularConversionSignal(chkAngular->isChecked()); + } + + + //discard bad channels from server +#ifdef VERBOSE + cout << "Getting bad channel correction" << endl; +#endif + if(myDet->getBadChannelCorrection()) chkDiscardBad->setChecked(true); + + } @@ -396,22 +440,56 @@ void qTabDataOutput::DiscardBadChannels(){ void qTabDataOutput::Refresh(){ +#ifdef VERBOSE + cout << endl << "**Updating DataOutput Tab" << endl; +#endif + + // output dir +#ifdef VERBOSE + cout << "Getting output directory" << endl; +#endif dispOutputDir->setText(QString(myDet->getFilePath().c_str())); + + //flat field correction from server +#ifdef VERBOSE + cout << "Getting flat field" << endl; +#endif UpdateFlatFieldFromServer(); + + //rate correction - not for charge integrating detectors - if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)) + if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)){ +#ifdef VERBOSE + cout << "Getting rate correction" << endl; +#endif UpdateRateCorrectionFromServer(); + } + + //update angular conversion from server if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::GOTTHARD)){ +#ifdef VERBOSE + cout << "Getting angular conversion" << endl; +#endif int ang; if(myDet->getAngularConversion(ang)) chkAngular->setChecked(true); emit AngularConversionSignal(chkAngular->isChecked()); } + + //discard bad channels from server +#ifdef VERBOSE + cout << "Getting bad channel correction" << endl; +#endif if(myDet->getBadChannelCorrection()) chkDiscardBad->setChecked(true); + + +#ifdef VERBOSE + cout << "**Updated DataOutput Tab" << endl << endl; +#endif } diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index 93d512f91..d7806ed67 100644 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -112,6 +112,9 @@ void qTabDebugging::Initialization(){ void qTabDebugging::UpdateModuleList(){ +#ifdef VERBOSE + cout << "Getting Module List" << endl; +#endif det = myDet->getSlsDetector(comboDetector->currentIndex()); //deletes all modules except "all modules" for(int i=0;icount()-1;i++) @@ -127,6 +130,9 @@ void qTabDebugging::UpdateModuleList(){ void qTabDebugging::UpdateStatus(){ +#ifdef VERBOSE + cout << "Getting Status" << endl; +#endif det = myDet->getSlsDetector(comboDetector->currentIndex()); int detStatus = (int)det->getRunStatus(); string status = slsDetectorBase::runStatusType(slsDetectorDefs::runStatus(detStatus)); @@ -140,6 +146,9 @@ void qTabDebugging::UpdateStatus(){ void qTabDebugging::GetInfo(){ +#ifdef VERBOSE + cout << "Getting Info" << endl; +#endif //window QFrame* popup1 = new QFrame(this, Qt::Popup | Qt::SubWindow ); QList items; @@ -477,8 +486,13 @@ void qTabDebugging::TestDetector(){ void qTabDebugging::Refresh(){ +#ifdef VERBOSE + cout << endl << "**Updating Debugging Tab" << endl; +#endif UpdateStatus(); - +#ifdef VERBOSE + cout << "**Updated Debugging Tab" << endl << endl; +#endif } diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index fdc2e43d5..32a00201d 100644 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -313,7 +313,11 @@ void qTabDeveloper::RefreshAdcs(){ void qTabDeveloper::Refresh(){ #ifdef VERBOSE - cout << "Updating Dacs and Adcs" <setToolTip(tipHV); comboHV->setToolTip(tipHV); //getting hv value - int ret = myDet->setDAC(-1,slsDetectorDefs::HV_POT); + int ret = (int)myDet->setDAC(-1,slsDetectorDefs::HV_POT); switch(ret){ case 0: comboHV->setCurrentIndex(0);break; case 90: comboHV->setCurrentIndex(1);break; @@ -353,6 +357,9 @@ void qTabDeveloper::Refresh(){ connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); } +#ifdef VERBOSE + cout << "**Updated Developer Tab" << endl << endl; +#endif } diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 4032474ec..801618133 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -726,16 +726,35 @@ void qTabMeasurement::EnableFileWrite(bool enable){ void qTabMeasurement::Refresh(){ +#ifdef VERBOSE + cout << endl << "**Updating Measurement Tab" << endl; +#endif + if(!myPlot->isRunning()){ + //Number of measurements +#ifdef VERBOSE + cout << "Getting number of measurements" << endl; +#endif spinNumMeasurements->setValue((int)myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1)); + + //File Name +#ifdef VERBOSE + cout << "Getting file name" << endl; +#endif dispFileName->setText(QString(myDet->getFileName().c_str())); + //File Index +#ifdef VERBOSE + cout << "Getting file index" << endl; +#endif spinIndex->setValue(myDet->getFileIndex());cout<<"file index:"<getFileIndex()<setText(QString::number(myDet->getFileIndex())); - //Timing mode* + + //Timing mode SetupTimingMode(); // to let qdrawplot know that triggers or frames are used @@ -743,6 +762,9 @@ void qTabMeasurement::Refresh(){ myPlot->setTriggerEnabled(lblNumTriggers->isEnabled()); } +#ifdef VERBOSE + cout << "**Updated Measurement Tab" << endl << endl; +#endif } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index c56919add..d4ba8a550 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -506,9 +506,9 @@ void qTabPlot::EnableScanBox(){ //if it was checked before or disabled before, it remembers to check it again bool checkedBefore = boxScan->isChecked();//||(!boxScan->isEnabled())); - + int ang; //none of these scan plotting options make sense if positions>0 - bool positionsExist = myDet->getPositions(); + bool positionsExist = myDet->getAngularConversion(ang);//myDet->getPositions(); //only now enable/disable boxScan->setEnabled((mode0||mode1)&&(!positionsExist)); @@ -603,6 +603,7 @@ void qTabPlot::SetScanArgument(){ } Select1DPlot(isOrginallyOneD); + int ang; //if scans(1D or 2D) if(boxScan->isEnabled()){ //setting the title according to the scans @@ -613,7 +614,8 @@ void qTabPlot::SetScanArgument(){ Select1DPlot(isOrginallyOneD); }//angles (1D) - else if(myDet->getPositions()){ + else if(myDet->getAngularConversion(ang)){ + //else if(myDet->getPositions()){ //if scan, change title if((myDet->getScanMode(0))||(myDet->getScanMode(1))){ QString mainTitle = QString(" Level 0 : ") + modeNames[myDet->getScanMode(0)] + @@ -674,6 +676,9 @@ void qTabPlot::SetScanArgument(){ void qTabPlot::Refresh(){ +#ifdef VERBOSE + cout << endl << "**Updating Plot Tab" << endl; +#endif if(!myPlot->isRunning()){ connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); SetFrequency(); @@ -682,6 +687,9 @@ void qTabPlot::Refresh(){ disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); boxScan->setEnabled(false); } +#ifdef VERBOSE + cout << "**Updated Plot Tab" << endl << endl; +#endif } diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index 1b3812ab3..068811924 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -56,6 +56,7 @@ void qTabSettings::SetupWidgetWindow(){ // Dynamic Range switch(myDet->setDynamicRange(-1)){ case 32: comboDynamicRange->setCurrentIndex(0); break; + case 24: comboDynamicRange->setCurrentIndex(0); break; case 16: comboDynamicRange->setCurrentIndex(1); break; case 8: comboDynamicRange->setCurrentIndex(2); break; case 4: comboDynamicRange->setCurrentIndex(3); break; @@ -214,10 +215,11 @@ void qTabSettings::SetDynamicRange(int index){ case 3: dr=4; break; default: dr=32; break; } + ret=myDet->setDynamicRange(dr); + if((ret==24)&&(dr==32)) dr = ret; #ifdef VERBOSE cout << "Setting dynamic range to "<< dr << endl; #endif - ret=myDet->setDynamicRange(dr); if(ret!=dr){ qDefs::Message(qDefs::WARNING,"Dynamic Range cannot be set to this value.","Settings"); #ifdef VERBOSE @@ -225,6 +227,7 @@ void qTabSettings::SetDynamicRange(int index){ #endif switch(ret){ case 32: comboDynamicRange->setCurrentIndex(0); break; + case 24: comboDynamicRange->setCurrentIndex(0); break; case 16: comboDynamicRange->setCurrentIndex(1); break; case 8: comboDynamicRange->setCurrentIndex(2); break; case 4: comboDynamicRange->setCurrentIndex(3); break; @@ -246,11 +249,10 @@ void qTabSettings::SetEnergy(){ int ret = (int)myDet->getThresholdEnergy(); if((ret-index)>200){ qDefs::Message(qDefs::WARNING,"Threshold energy could not be set. The difference is greater than 200.","Settings"); - disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); - spinThreshold->setValue(ret); - connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); } - + disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); + spinThreshold->setValue(ret); + connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); } @@ -258,19 +260,34 @@ void qTabSettings::SetEnergy(){ void qTabSettings::Refresh(){ +#ifdef VERBOSE + cout << endl << "**Updating Settings Tab" << endl; +#endif + // Settings +#ifdef VERBOSE + cout << "Getting settings" << endl; +#endif SetupDetectorSettings(); //changin the combo settings also plots the trimbits for mythen and eiger, so disconnect disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); comboSettings->setCurrentIndex(myDet->getSettings()); connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); + // Number of Modules +#ifdef VERBOSE + cout << "Getting number of modules" << endl; +#endif spinNumModules->setValue(myDet->setNumberOfModules()); // Dynamic Range +#ifdef VERBOSE + cout << "Getting dynamic range" << endl; +#endif switch(myDet->setDynamicRange(-1)){ case 32: comboDynamicRange->setCurrentIndex(0); break; + case 24: comboDynamicRange->setCurrentIndex(0); break; case 16: comboDynamicRange->setCurrentIndex(1); break; case 8: comboDynamicRange->setCurrentIndex(2); break; case 4: comboDynamicRange->setCurrentIndex(3); break; @@ -287,11 +304,16 @@ void qTabSettings::Refresh(){ }else{ lblThreshold->setEnabled(true); spinThreshold->setEnabled(true); +#ifdef VERBOSE + cout << "Getting threshold energy" << endl; +#endif SetEnergy(); } } - +#ifdef VERBOSE + cout << "**Updated Settings Tab" << endl << endl; +#endif }