mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
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:
@ -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 */
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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("");
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user