verifying output directory works for receiver based detectors.. before acquisition

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@206 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2013-07-23 08:39:15 +00:00
parent b6145510ad
commit 6ea6f44824
6 changed files with 457 additions and 91 deletions

View File

@ -35,9 +35,9 @@
<property name="geometry">
<rect>
<x>20</x>
<y>110</y>
<y>160</y>
<width>731</width>
<height>206</height>
<height>166</height>
</rect>
</property>
<property name="title">
@ -47,12 +47,15 @@
<property name="geometry">
<rect>
<x>15</x>
<y>20</y>
<y>25</y>
<width>701</width>
<height>176</height>
<height>126</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="verticalSpacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="chkFlatField">
<property name="toolTip">
@ -85,6 +88,9 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="toolTip">
<string>Flat field corrections.
#flatfield# filename</string>
@ -270,93 +276,217 @@
</layout>
</widget>
</widget>
<widget class="QFrame" name="frameOutput">
<widget class="QGroupBox" name="boxOutDir">
<property name="geometry">
<rect>
<x>19</x>
<y>20</y>
<width>746</width>
<height>41</height>
<x>20</x>
<y>25</y>
<width>731</width>
<height>116</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
<property name="title">
<string>Output Directory</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<widget class="QFrame" name="frameOutput">
<property name="geometry">
<rect>
<x>10</x>
<y>6</y>
<width>706</width>
<height>28</height>
<x>5</x>
<y>10</y>
<width>721</width>
<height>96</height>
</rect>
</property>
<layout class="QHBoxLayout" name="layoutOutput">
<property name="spacing">
<number>-1</number>
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>701</width>
<height>86</height>
</rect>
</property>
<item>
<widget class="QLabel" name="lblOutputDir">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>4</number>
</property>
<item row="2" column="3">
<widget class="QPushButton" name="btnOutputBrowse">
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
<property name="text">
<string>Output Directory :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="dispOutputDir">
<property name="toolTip">
<string>&lt;nobr&gt;
</property>
<property name="text">
<string>Browse</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/browse.png</normaloff>:/icons/images/browse.png</iconset>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="dispReadOutputDir">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnOutputBrowse">
<property name="toolTip">
<string>&lt;nobr&gt;
</property>
<property name="frame">
<bool>false</bool>
</property>
<property name="echoMode">
<enum>QLineEdit::Normal</enum>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="dispOutputDir">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
<property name="text">
<string>Browse</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/browse.png</normaloff>:/icons/images/browse.png</iconset>
</property>
</widget>
</item>
</layout>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lblDetector">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>2</red>
<green>2</green>
<blue>2</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>119</red>
<green>119</green>
<blue>119</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="toolTip">
<string>&lt;nobr&gt;
Directory where one saves the data.
&lt;/nobr&gt;&lt;br&gt;
#outdir#
&lt;br&gt;
</string>
</property>
<property name="text">
<string>Readout:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="comboDetector">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</widget>
</widget>
<tabstops>
<tabstop>dispOutputDir</tabstop>
<tabstop>btnOutputBrowse</tabstop>
<tabstop>dispReadOutputDir</tabstop>
<tabstop>chkFlatField</tabstop>
<tabstop>dispFlatField</tabstop>
<tabstop>btnFlatField</tabstop>

View File

@ -14,7 +14,7 @@
/** Qt Project Class Headers */
#include "qDrawPlot.h"
#include "qTabMeasurement.h"
class qTabDataOutput;
#include "qTabDataOutput.h"
class qTabPlot;
class qTabActions;
class qTabAdvanced;
@ -80,6 +80,9 @@ public:
/** Returns file path */
QString GetFilePath(){QString s = QString(myDet->getFilePath().c_str());qDefs::checkErrorMessage(myDet); return s;};
/** Verifies if output directories for all the receivers exist */
int DoesOutputDirExist(){return tab_dataoutput->VerifyOutputDirectory();};
private:
/** The Qt Application */
QApplication *theApp;

View File

@ -40,6 +40,10 @@ public:
*/
void Refresh();
/** verify output directories
* /returns success or fail
*/
int VerifyOutputDirectory();
private:
@ -53,6 +57,9 @@ private:
QString errFlatFieldTip;
QString outDirTip;
QPalette red;
QPalette black;
QPalette *red1;
QPalette *black1;
/** methods */
/** Sets up the widget */
@ -61,11 +68,12 @@ private:
/** Sets up all the slots and signals */
void Initialization();
/** Populate the readouts
*/
void PopulateDetectors();
private slots:
/** Sets the output directory
*/
void setOutputDir();
/** Open dialog to choose the output directory */
void browseOutputDir();
@ -91,6 +99,12 @@ void SetAngularCorrection();
/**discard bad channels*/
void DiscardBadChannels();
/** set output directory*/
void SetOutputDir();
/** set output directory*/
void GetOutputDir();
signals:
/**signal to enable/disable positions in Actions*/
void AngularConversionSignal(bool);

View File

@ -16,6 +16,7 @@
class multiSlsDetector;
/** Qt Project Class Headers */
#include "qDrawPlot.h"
class qDetectorMain;
/**
*@short sets up the measurement parameters
@ -33,7 +34,7 @@ public:
* @param detector is the detector returned from the detector tab
* @param plot plot object reference
*/
qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot);
qTabMeasurement(qDetectorMain *parent,multiSlsDetector*& detector, qDrawPlot*& plot);
/** Destructor
*/
@ -167,6 +168,8 @@ private slots:
private:
/** parent widget */
qDetectorMain *thisParent;
/** The sls detector object */
multiSlsDetector *myDet;
/** The Plot widget */

View File

@ -57,23 +57,28 @@ void qTabDataOutput::SetupWidgetWindow(){
/** error message **/
red = QPalette();
red.setColor(QPalette::Active,QPalette::WindowText,Qt::red);
black = QPalette();
black.setColor(QPalette::Active,QPalette::WindowText,Qt::black);
red1 = new QPalette();
red1->setColor(QPalette::Text,Qt::red);
black1 = new QPalette();
black1->setColor(QPalette::Text,Qt::black);
flatFieldTip = dispFlatField->toolTip();
errFlatFieldTip = QString("<nobr>Flat field corrections.</nobr><br>"
"<nobr> #flatfield# filename</nobr><br><br>")+
QString("<nobr><font color=\"red\">"
"Enter a valid file to enable Flat Field.</font></nobr>");
outDirTip = boxOutDir->toolTip();
outDirTip = dispOutputDir->toolTip();
Initialization();
// output dir
#ifdef VERBOSE
cout << "Getting output directory" << endl;
#endif
dispOutputDir->setText(QString(myDet->getFilePath().c_str()));
disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir()));
PopulateDetectors();
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir()));
//flat field correction from server
#ifdef VERBOSE
@ -131,7 +136,10 @@ void qTabDataOutput::SetupWidgetWindow(){
void qTabDataOutput::Initialization(){
//output dir
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(setOutputDir()));
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir()));
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(browseOutputDir()));
//flat field correction
connect(chkFlatField, SIGNAL(toggled(bool)), this, SLOT(SetFlatField()));
@ -149,7 +157,7 @@ void qTabDataOutput::Initialization(){
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
/*
void qTabDataOutput::setOutputDir(){
disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(setOutputDir()));
@ -199,9 +207,6 @@ void qTabDataOutput::setOutputDir(){
break;
}
}
/* myDet->setFilePath(string(path.toAscii().constData()));
if(myDet->getFilePath()!=(string(path.toAscii().constData())))
error=true;*/
}
if(!error){
@ -233,7 +238,7 @@ void qTabDataOutput::setOutputDir(){
qDefs::checkErrorMessage(myDet);
}
*/
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -242,7 +247,7 @@ void qTabDataOutput::browseOutputDir()
QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Output Directory "),dispOutputDir->text());
if (!directory.isEmpty())
dispOutputDir->setText(directory);
setOutputDir();
SetOutputDir();
}
@ -542,14 +547,10 @@ void qTabDataOutput::Refresh(){
#ifdef VERBOSE
cout << "Getting output directory" << endl;
#endif
dispOutputDir->setText(QString(myDet->getFilePath().c_str()));
lblOutputDir->setText("Output Directory: ");
lblOutputDir->setPalette(chkRate->palette());
lblOutputDir->setToolTip(outDirTip);
dispOutputDir->setToolTip(outDirTip);
btnOutputBrowse->setToolTip(outDirTip);
//making sure it is set
setOutputDir();
disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir()));
PopulateDetectors();
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir()));
//flat field correction from server
#ifdef VERBOSE
@ -611,3 +612,208 @@ void qTabDataOutput::Refresh(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDataOutput::PopulateDetectors(){
#ifdef VERBOSE
cout << "Populating detectors" << endl;
#endif
comboDetector->clear();
if(myDet->setReceiverOnline() == slsDetectorDefs::OFFLINE_FLAG){
boxOutDir->setTitle("Output Directory");
comboDetector->addItem("All");
}
//if receiver, add detectors
else{
boxOutDir->setTitle("Receiver Output Directory");
for(int i=0;i<myDet->getNumberOfDetectors();i++)
comboDetector->addItem(QString(myDet->getHostname(i).c_str()));
}
GetOutputDir();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDataOutput::GetOutputDir(){
#ifdef VERBOSE
cout << "Getting output directory" << endl;
#endif
if(!comboDetector->itemText(0).compare("All")){
dispReadOutputDir->setText(QString(myDet->getFilePath().c_str()));
}else{
slsDetector *det = myDet->getSlsDetector(comboDetector->currentIndex());
qDefs::checkErrorMessage(myDet);
dispReadOutputDir->setText(QString(det->getFilePath().c_str()));
}
VerifyOutputDirectory();
//clear field to write
disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
dispOutputDir->setText("");
dispOutputDir->setPalette(*black1);
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qTabDataOutput::VerifyOutputDirectory(){
#ifdef VERBOSE
cout << "Verifying output directory" << endl;
#endif
bool error = false;
QString path = "";
QString errTip = outDirTip;
QString detName = "";
path = dispReadOutputDir->text();
//no receiver
if(!comboDetector->itemText(0).compare("All")){
if(myDet->setFilePath(string(path.toAscii().constData())).empty()){
qDefs::Message(qDefs::WARNING,string("Enter a valid output directory"),"Data Output");
error = true;
dispReadOutputDir->setText(QString(myDet->getFilePath().c_str()));
boxOutDir->setTitle("Receiver Output Directory*");
}else if(!qDefs::checkErrorMessage(myDet).empty()){
error = true;
dispReadOutputDir->setText(QString(myDet->getFilePath().c_str()));
dispReadOutputDir->setPalette(*red1);
boxOutDir->setPalette(red);
boxOutDir->setTitle("Output Directory*");
errTip = outDirTip +
QString("<nobr><font color=\"red\">"
"Enter a valid path to change <b>Output Directory</b>.</font></nobr>");
boxOutDir->setToolTip(errTip);
}
}
//receiver
else{
for(int i=0;i<myDet->getNumberOfDetectors();i++){
detName = comboDetector->itemText(i);
slsDetector *det = myDet->getSlsDetector(i);
qDefs::checkErrorMessage(myDet);
if(det->setFilePath(det->getFilePath()).empty()){
qDefs::Message(qDefs::WARNING,string("Enter a valid output directory for ") +
string(detName.toAscii().constData()) + string(" readout"),"Data Output");
error = true;
dispReadOutputDir->setText(QString(det->getFilePath().c_str()));
boxOutDir->setTitle("Receiver Output Directory*");
}else if(!qDefs::checkErrorMessage(det).empty()){
error = true;
dispReadOutputDir->setText(QString(det->getFilePath().c_str()));
boxOutDir->setTitle("Receiver Output Directory*");
}
}
}
//if error, display in red
if(error){
#ifdef VERBOSE
cout << "The output path doesnt exist anymore" << endl;
#endif
dispReadOutputDir->setPalette(*red1);
boxOutDir->setPalette(red);
errTip = errTip +
QString("<br><nobr><font color=\"red\">"
"Enter a valid path for ") + detName +
QString( " readout to change <b>Output Directory</b>.</font></nobr>");
boxOutDir->setToolTip(errTip);
return slsDetectorDefs::FAIL;
}
//no error
else{
#ifdef VERBOSE
cout << "The output path has been verified" << endl;
#endif
dispReadOutputDir->setPalette(*black1);
boxOutDir->setPalette(black);
if(!comboDetector->itemText(0).compare("All"))
boxOutDir->setTitle("Output Directory");
else
boxOutDir->setTitle("Receiver Output Directory");
boxOutDir->setToolTip(outDirTip);
}
return slsDetectorDefs::OK;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabDataOutput::SetOutputDir(){
#ifdef VERBOSE
cout << "Setting output directory" << endl;
#endif
bool error = false;
QString path = dispOutputDir->text();
if(path.isEmpty())
return;
disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
//gets rid of the end '/'s
while(path.endsWith('/')) path.chop(1);
dispOutputDir->setText(path);
if(!comboDetector->itemText(0).compare("All")){
myDet->setFilePath(string(dispOutputDir->text().toAscii().constData()));
if(!qDefs::checkErrorMessage(myDet).empty()){
#ifdef VERBOSE
cout << "The output path could not be set" << endl;
#endif
myDet->setFilePath(string(dispReadOutputDir->text().toAscii().constData()));
error = true;
dispOutputDir->setPalette(*red1);
}
}
else{
slsDetector *det = myDet->getSlsDetector(comboDetector->currentIndex());
qDefs::checkErrorMessage(myDet);
det->setFilePath(string(dispOutputDir->text().toAscii().constData()));
if(!qDefs::checkErrorMessage(det).empty()){
#ifdef VERBOSE
cout << "The output path could not be set" << endl;
#endif
det->setFilePath(string(dispReadOutputDir->text().toAscii().constData()));
error = true;
dispOutputDir->setPalette(*red1);
}
cout<<"filepath:"<<det->getFilePath()<<endl;
}
if(!error){
#ifdef VERBOSE
cout << "The output path has been modified" << endl;
#endif
dispOutputDir->setPalette(*black1);
dispReadOutputDir->setText(dispOutputDir->text());
dispOutputDir->setText("");
VerifyOutputDirectory();
}
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -7,6 +7,7 @@
//Qt Project Class Headers
#include "qTabMeasurement.h"
#include "qDetectorMain.h"
//Project Class Headers
#include "slsDetector.h"
#include "multiSlsDetector.h"
@ -23,8 +24,8 @@ using namespace std;
//-------------------------------------------------------------------------------------------------------------------------------------------------
qTabMeasurement::qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot):
QWidget(parent),myDet(detector),myPlot(plot),expertMode(false){
qTabMeasurement::qTabMeasurement(qDetectorMain *parent,multiSlsDetector*& detector, qDrawPlot*& plot):
thisParent(parent),myDet(detector),myPlot(plot),expertMode(false){
setupUi(this);
SetupWidgetWindow();
Initialization();
@ -38,6 +39,7 @@ qTabMeasurement::qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qD
qTabMeasurement::~qTabMeasurement(){
delete myDet;
delete myPlot;
delete thisParent;
}
@ -308,6 +310,14 @@ void qTabMeasurement::setRunIndex(int index){
void qTabMeasurement::startStopAcquisition(){
if(btnStartStop->isChecked()){
if(thisParent->DoesOutputDirExist() == slsDetectorDefs::FAIL){
disconnect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
btnStartStop->click();
connect(btnStartStop,SIGNAL(clicked()),this,SLOT(startStopAcquisition()));
return;
}
#ifdef VERBOSE
cout << endl << endl << "Starting Acquisition" << endl;
#endif