included position scan

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@40 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-08-29 09:06:49 +00:00
parent 51e7feb605
commit c9ecec183f
11 changed files with 116 additions and 303 deletions

View File

@ -369,6 +369,11 @@
<string>Trimbits Scan</string>
</property>
</item>
<item>
<property name="text">
<string>Position Scan</string>
</property>
</item>
<item>
<property name="text">
<string>Custom Script</string>

View File

@ -31,208 +31,6 @@
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>25</x>
<y>83</y>
<width>740</width>
<height>93</height>
</rect>
</property>
<property name="title">
<string>Files:</string>
</property>
<layout class="QGridLayout" name="gridLayout_2" rowstretch="0,0,0">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<property name="horizontalSpacing">
<number>-1</number>
</property>
<property name="verticalSpacing">
<number>9</number>
</property>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Trimbit File:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="pushButton_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="1" column="4">
<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>120</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="5">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Calibration File:</string>
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="pushButton_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="QPushButton" name="pushButton_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
<item row="1" column="8">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" colspan="7">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Output File:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
@ -310,19 +108,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Offline Improvement</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>

View File

@ -68,6 +68,8 @@ private:
multiSlsDetector *myDet;
/** sls detector id */
int detID;
/** true for mythen and eiger */
bool digitalDetector;
/** The Plot widget */
qDrawPlot *myPlot;
/**Tab Widget */

View File

@ -206,6 +206,7 @@ private:
multiSlsDetector *myDet;
/** Widgets needed to plot the clone */
/** Max Number of Clone Windows */
static const int MAXCloneWindows = 50;

View File

@ -45,7 +45,7 @@ private:
int id;
/**type of steps*/
enum sizeIndex{RangeValues, CustomValues, FileValues};
enum modes{None,EnergyScan,ThresholdScan,TrimbitsScan,CustomScript,NumModes};
enum modes{None,EnergyScan,ThresholdScan,TrimbitsScan,PositionScan,CustomScript,NumModes};
static const string modeNames[NumModes];
/**values*/

View File

@ -6,7 +6,7 @@ UI_HEADERS_DIR = forms/include
RESOURCES += icons.qrc
DEFINES += VERBOSE DACS_INT #VERYVERBOSE
DEFINES += VERBOSE DACS_INT VERYVERBOSE
target.path += $(DESTDIR)

View File

@ -79,7 +79,7 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot
//cloneplot2D->setContentsMargins(0,0,0,0);
gridClone->addWidget(cloneplot2D,0,0);
cloneBox->setFlat(true);
cloneBox->setContentsMargins(0,5,0,0);
cloneBox->setContentsMargins(0,20,0,0);
}
/** main window widgets */

View File

@ -147,10 +147,10 @@ void qDetectorMain::SetUpWidgetWindow(){
tabs->setTabEnabled(Debugging,false);
//beamline mode to false
tabs->setTabEnabled(Advanced,false);
actionLoadTrimbits->hide();
actionSaveTrimbits->hide();
actionLoadCalibration->hide();
actionSaveCalibration->hide();
actionLoadTrimbits->setVisible(false);
actionSaveTrimbits->setVisible(false);
actionLoadCalibration->setVisible(false);
actionSaveCalibration->setVisible(false);
dockWidgetPlot->setFloating(false);
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
tabs->setTabEnabled(Developer,isDeveloper);
@ -193,10 +193,11 @@ void qDetectorMain::SetUpDetector(){
else{
slsDetectorDefs::detectorType detType = myDet->getDetectorsType();
// Check if type valid. If not, exit
switch(detType){
case slsDetectorDefs::MYTHEN: break;
case slsDetectorDefs::EIGER: break;
case slsDetectorDefs::GOTTHARD: break;
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;
default:
string detName = myDet->slsDetectorBase::getDetectorType(detType);
string errorMess = host+string(" has unknown detector type \"")+
@ -275,16 +276,16 @@ void qDetectorMain::EnableModes(QAction *action){
else if(action==actionExpert){
enable = actionExpert->isChecked();
tabs->setTabEnabled(Advanced,enable);
if(enable){
actionLoadTrimbits->show();
actionSaveTrimbits->show();
actionLoadCalibration->show();
actionSaveCalibration->show();
if((enable)&&(digitalDetector)){
actionLoadTrimbits->setVisible(true);
actionSaveTrimbits->setVisible(true);
actionLoadCalibration->setVisible(true);
actionSaveCalibration->setVisible(true);
}else{
actionLoadTrimbits->hide();
actionSaveTrimbits->hide();
actionLoadCalibration->hide();
actionSaveCalibration->hide();
actionLoadTrimbits->setVisible(false);
actionSaveTrimbits->setVisible(false);
actionLoadCalibration->setVisible(false);
actionSaveCalibration->setVisible(false);
}
#ifdef VERBOSE
cout << "Setting Expert Mode to " << enable << endl;
@ -373,6 +374,20 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
qDefs::InfoMessage("The configuration parameters have been successfully saved.","Main");
}
}
else if(action==actionLoadTrimbits){
#ifdef VERBOSE
cout << "Loading Trimbits" << endl;
#endif
QString fName = QString(myDet->getFilePath().c_str());
fName = QFileDialog::getOpenFileName(this,
tr("Load Detector Trimbits"),fName,
tr("Trimbit files (*.trim *.sn*)"));
// Gets called when cancelled as well
if (!fName.isEmpty()){
//myDet->readConfigurationFile(string(fName.toAscii().constData()));
qDefs::InfoMessage("The parameters have been successfully configured.","Main");
}
}
Refresh(tabs->currentIndex());
}
@ -492,10 +507,10 @@ void qDetectorMain::EnableTabs(){
if(enable==false){
tabs->setTabEnabled(Debugging,enable);
tabs->setTabEnabled(Advanced,enable);
actionLoadTrimbits->hide();
actionSaveTrimbits->hide();
actionLoadCalibration->hide();
actionSaveCalibration->hide();
actionLoadTrimbits->setVisible(false);
actionSaveTrimbits->setVisible(false);
actionLoadCalibration->setVisible(false);
actionSaveCalibration->setVisible(false);
tabs->setTabEnabled(Developer,enable);
}
else{
@ -504,16 +519,16 @@ void qDetectorMain::EnableTabs(){
tabs->setTabEnabled(Debugging,enable);
if(actionExpert->isChecked()){
tabs->setTabEnabled(Advanced,enable);
if(enable){
actionLoadTrimbits->show();
actionSaveTrimbits->show();
actionLoadCalibration->show();
actionSaveCalibration->show();
if((enable)&&(digitalDetector)){
actionLoadTrimbits->setVisible(true);
actionSaveTrimbits->setVisible(true);
actionLoadCalibration->setVisible(true);
actionSaveCalibration->setVisible(true);
}else{
actionLoadTrimbits->hide();
actionSaveTrimbits->hide();
actionLoadCalibration->hide();
actionSaveCalibration->hide();
actionLoadTrimbits->setVisible(false);
actionSaveTrimbits->setVisible(false);
actionLoadCalibration->setVisible(false);
actionSaveCalibration->setVisible(false);
}
}
if(isDeveloper)

View File

@ -264,6 +264,7 @@ bool qDrawPlot::StartOrStopThread(bool start){
progress = 0;
currentFrame = 0;
stop_signal = 0;
histTitle[0] = "";
//for 2d scans
int currentIndex = myDet->getFileIndex();
@ -283,7 +284,6 @@ bool qDrawPlot::StartOrStopThread(bool start){
}else if(scanArgument==Level0){
//no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab
int numSteps = myDet->getScanSteps(0);
//if(values) delete [] values;
double *values = new double[numSteps];
myDet->getScanSteps(0,values);
@ -292,6 +292,17 @@ bool qDrawPlot::StartOrStopThread(bool start){
nPixelsY = numSteps;
currentScanValue = values[0];
}
else {
//no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab
int numSteps = myDet->getScanSteps(1);
double *values = new double[numSteps];
myDet->getScanSteps(1,values);
maxPixelsY = values[numSteps-1];
minPixelsY = values[0];
nPixelsY = numSteps;
currentScanValue = values[0];
}
pixelWidth = (maxPixelsY -minPixelsY)/(nPixelsY-1);
startPixel = minPixelsY -(pixelWidth/2);
endPixel = maxPixelsY + (pixelWidth/2);
@ -375,6 +386,8 @@ int qDrawPlot::GetData(detectorData *data){
cout << "Entering GetDatafunction" << endl;
#endif
if(!stop_signal){
//set title
SetPlotTitle(QString(data->fileName).section('/',-1));
//Plot Disabled
if(!plotEnable) {
@ -432,7 +445,6 @@ int qDrawPlot::GetData(detectorData *data){
//if scan argument is 2d
if(scanArgument!=None){
if(scanArgument==AllFrames){
/*title should include which scan, also by measurement tab*/
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
@ -444,12 +456,10 @@ int qDrawPlot::GetData(detectorData *data){
return 0;
}
else if(scanArgument==FileIndex){
/*title should include which scan, also by measurement tab*/
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
if(currentIndex == minPixelsY) currentScanDivLevel = 0;
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
//memcpy(lastImageArray+(currentIndex*nPixelsX),data->values,nPixelsX*sizeof(double));
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
@ -458,28 +468,29 @@ int qDrawPlot::GetData(detectorData *data){
return 0;
}
else if(scanArgument==Level0){
/*title should include which scan, also by measurement tab*/
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
if(currentScanVariable0!=currentScanValue) currentScanDivLevel++;
currentScanValue = currentScanVariable0;
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
//memcpy(lastImageArray+(currentIndex*nPixelsX),data->values,nPixelsX*sizeof(double));
//for(int i=values[currentScan];i<values[currentScan+1];i++)
//memcpy(lastImageArray+(currentScanVariable0-1*nPixelsX),data->values,nPixelsX*sizeof(double));
//memcpy(lastImageArray+(currentScanDivLevel*nPixelsX),data->values,nPixelsX*sizeof(double));
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
cout<<"lastImageArray[0*1280+500]:"<<lastImageArray[currentScanDivLevel*nPixelsX+500]<<endl;
//lastImageArray + ((pixelWidth/2) + currentScanDivLevel * pixelWidth) * nPixelsX + px += data->values[px];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
return 0;
}
else {
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
if(currentScanVariable1!=currentScanValue) currentScanDivLevel++;
currentScanValue = currentScanVariable1;
lastImageNumber= currentFrame+1;
char temp_title[2000]; sprintf(temp_title,"Image Index %d",currentIndex); imageTitle = temp_title;
for(unsigned int px=0;px<nPixelsX;px++) lastImageArray[currentScanDivLevel*nPixelsX+px] += data->values[px];
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentFrame++;
return 0;
}
}
//normal measurement or 1d scans
@ -490,8 +501,9 @@ int qDrawPlot::GetData(detectorData *data){
//1d
if(plot_in_scope==1){
// Titles
sprintf(temp_title,"Frame Index %d",currentIndex); histTitle[0] = temp_title;
// Titles changed to "" inside startstopthread
//sprintf(temp_title,"Frame Index %d",currentIndex); histTitle[0] = temp_title;
// Persistency
if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency;

View File

@ -25,7 +25,7 @@ using namespace std;
int qScanWidget::NUM_SCAN_WIDGETS(0);
const string qScanWidget::modeNames[NumModes]={"","energy","threshold","trimbits","custom script"};
const string qScanWidget::modeNames[NumModes]={"","energy","threshold","trimbits","position","custom script"};
//-------------------------------------------------------------------------------------------------------------------------------------------------
qScanWidget::qScanWidget(QWidget *parent,multiSlsDetector*& detector):
@ -331,7 +331,7 @@ void qScanWidget::SetMode(int mode){
EnableSizeWidgets();
//set the mode
SetScan(mode);
/*SetScan(mode);*/
}
@ -354,27 +354,15 @@ int qScanWidget::SetScan(int mode){
else values = NULL;
for(int i=0;i<actualNumSteps;i++) values[i] = positions[i];
cout<<"modeNames[mode]:"<<modeNames[mode]<<endl;cout<<"actualNumSteps:"<<actualNumSteps<<endl;
//setting the mode
switch(mode){
case None:
myDet->setScan(id,modeNames[mode],actualNumSteps,values,parameter);
break;
case EnergyScan:
myDet->setScan(id,modeNames[mode],actualNumSteps,values,parameter);
break;
case ThresholdScan:
myDet->setScan(id,modeNames[mode],actualNumSteps,values,parameter);
break;
case TrimbitsScan:
myDet->setScan(id,modeNames[mode],actualNumSteps,values,parameter);
break;
case CustomScript:
if(mode==CustomScript)
myDet->setScan(id,script,actualNumSteps,values,parameter);
break;
}
else
cout<<"return values:"<<myDet->setScan(id,modeNames[mode],actualNumSteps,values,parameter)<<endl;
//custom script
int actualMode = myDet->getScanMode(id);
int actualMode = myDet->getScanMode(id);cout<<"actualmode:"<<actualMode<<endl;
if((mode==CustomScript)&&((script=="")||(script=="none"))){
return qDefs::OK;
}else{//mode NOT set
@ -429,13 +417,18 @@ void qScanWidget::SetScriptFile(){
//blank
if(fName.isEmpty())
set = true;
else if( (!fName.compare("none"))||
(!fName.compare("energy"))||
(!fName.compare("threshold"))||
(!fName.compare("trimbits")) )
set = true;
//not blank
else{
//none isnt in the modeNames list, so check separately
else if(!fName.compare("none"))
set = true;
else{//if one of the other modes
for(int i=1;i<NumModes;i++)
if(!fName.compare(QString(modeNames[i].c_str()))){
set = true;
break;
}
}
//not blank and custom script mode
if(!set){
QString file = dispScript->text().section('/',-1);
//is a file
if(file.contains('.')){
@ -468,12 +461,12 @@ void qScanWidget::SetScriptFile(){
//dont display if theres a none
fName = dispScript->text();
if( (!fName.compare("none"))||
(!fName.compare("energy"))||
(!fName.compare("threshold"))||
(!fName.compare("trimbits")) )
dispScript->setText("");
//none isnt in the modeNames list, so check separately
if(!fName.compare("none"))
dispScript->setText("");
for(int i=1;i<NumModes;i++)
if(!fName.compare(QString(modeNames[i].c_str())))
dispScript->setText("");
}
@ -492,11 +485,12 @@ void qScanWidget::SetParameter(){
myDet->setScanParameter(id,parameter.toAscii().constData());
//dont display if theres a none
parameter = dispParameter->text();
if( (!parameter.compare("none"))||
(!parameter.compare("energy"))||
(!parameter.compare("threshold"))||
(!parameter.compare("trimbits")) )
//none isnt in the modeNames list, so check separately
if(!parameter.compare("none"))
dispParameter->setText("");
for(int i=1;i<NumModes;i++)
if(!parameter.compare(QString(modeNames[i].c_str())))
dispParameter->setText("");
}

View File

@ -572,7 +572,6 @@ void qTabPlot::SetScanArgument(){
//if scans
if(boxScan->isEnabled()){
//setting the title according to the scans
QString mainTitle = QString(" Level 0 : ") + modeNames[myDet->getScanMode(0)] +
QString(" | Level 1 : ") + modeNames[myDet->getScanMode(1)] + QString("");
@ -641,7 +640,7 @@ void qTabPlot::SetScanArgument(){
void qTabPlot::Refresh(){
SetFrequency();
EnableScanBox();
if(!myPlot->isRunning()) EnableScanBox();
}