mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 23:10:02 +02:00
WIP
This commit is contained in:
parent
039a725c5c
commit
a373609b08
@ -36,7 +36,7 @@ class qCloneWidget : public QMainWindow {
|
||||
* @param lines style of plot if lines or dots
|
||||
* @param markers style of plot markers or not
|
||||
*/
|
||||
void SetCloneHists(unsigned int nHists, int histNBins, double *histXAxis, std::vector<double*> histYAxis, std::vector<std::string> histTitle, bool lines, bool markers);
|
||||
void SetCloneHists(unsigned int nHists, int histNBins, double *histXAxis, std::vector<double*> histYAxis, QString histTitle, bool lines, bool markers);
|
||||
|
||||
/**
|
||||
* Get the 1D hist values to plot for angle plotting
|
||||
|
@ -79,13 +79,11 @@ class qDrawPlot : public QWidget {
|
||||
private slots:
|
||||
void SetSaveFileName(QString val);
|
||||
void CloneCloseEvent(int id);
|
||||
|
||||
|
||||
void UpdatePlot();
|
||||
void AcquireThread();
|
||||
|
||||
signals:
|
||||
void UpdatingPlotFinished();
|
||||
void UpdatePlotSignal();
|
||||
void AcquireSignal();
|
||||
void AcquireFinishedSignal();
|
||||
|
||||
private:
|
||||
void SetupWidgetWindow();
|
||||
@ -98,23 +96,15 @@ class qDrawPlot : public QWidget {
|
||||
void GetStatistics(double &min, double &max, double &sum, double *array, int size);
|
||||
void DetachHists();
|
||||
void UpdateXYRange();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool StartOrStopThread(bool start);
|
||||
void SetupMeasurement();
|
||||
static void *DataStartAcquireThread(void *this_pointer);
|
||||
static int GetDataCallBack(detectorData *data, int fIndex, int subIndex, void *this_pointer);
|
||||
int GetData(detectorData *data, int fIndex, int subIndex);
|
||||
static int GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer);
|
||||
int AcquisitionFinished(double currentProgress, int detectorStatus);
|
||||
static int GetMeasurementFinishedCallBack(int currentMeasurementIndex, int fileIndex, void *this_pointer);
|
||||
int MeasurementFinished(int currentMeasurementIndex, int fileIndex);
|
||||
static int GetProgressCallBack(double currentProgress, void *this_pointer);
|
||||
static void GetProgressCallBack(double currentProgress, void *this_pointer);
|
||||
static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer);
|
||||
static void GetMeasurementFinishedCallBack(int currentMeasurementIndex, void *this_pointer);
|
||||
static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer);
|
||||
void AcquisitionFinished(double currentProgress, int detectorStatus);
|
||||
void MeasurementFinished(int currentMeasurementIndex);
|
||||
void GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex);
|
||||
void toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest = NULL);
|
||||
|
||||
void UpdatePlot();
|
||||
|
||||
static const int NUM_PEDESTAL_FRAMES = 20;
|
||||
multiSlsDetector *myDet;
|
||||
@ -131,14 +121,10 @@ class qDrawPlot : public QWidget {
|
||||
|
||||
bool is1d{true};
|
||||
bool isRunning{false};
|
||||
int progress{0};
|
||||
|
||||
|
||||
// titles
|
||||
QString plotTitle{""};
|
||||
QString plotTitle_prefix{""};
|
||||
QLabel *lblFrameIndexTitle1d{nullptr};
|
||||
std::vector<std::string> title1d;
|
||||
std::string title2d{""};
|
||||
QString xTitle1d{"Channel Number"};
|
||||
QString yTitle1d{"Counts"};
|
||||
QString xTitle2d{"Pixel"};
|
||||
@ -155,11 +141,12 @@ class qDrawPlot : public QWidget {
|
||||
double *data2d{nullptr};
|
||||
|
||||
//options
|
||||
bool binary{false};
|
||||
bool plotEnable{true};
|
||||
bool binary{false};
|
||||
int binaryFrom{0};
|
||||
int binaryTo{0};
|
||||
int persistency{0};
|
||||
int currentPersistency0};
|
||||
int currentPersistency{0};
|
||||
bool isLines{true};
|
||||
bool isMarkers{false};
|
||||
QwtSymbol *marker{nullptr};
|
||||
@ -191,9 +178,9 @@ class qDrawPlot : public QWidget {
|
||||
double endPixel{0};
|
||||
double pixelWidth{0};
|
||||
|
||||
int progress{0};
|
||||
int64_t currentMeasurement{0};
|
||||
int64_t currentFrame{0};
|
||||
int64_t lastImageNumber{0};
|
||||
pthread_mutex_t lastImageCompleteMutex;
|
||||
|
||||
const static int npixelsx_jctb = 400;
|
||||
|
@ -124,7 +124,7 @@ void qCloneWidget::SetupWidgetWindow(QString title, QString xTitle, QString yTit
|
||||
resize(500, 350);
|
||||
}
|
||||
|
||||
void qCloneWidget::SetCloneHists(unsigned int nHists, int histNBins, double *histXAxis, std::vector<double*> histYAxis, std::vector<std::string> histTitle, bool lines, bool markers) {
|
||||
void qCloneWidget::SetCloneHists(unsigned int nHists, int histNBins, double *histXAxis, std::vector<double*> histYAxis, QString histTitle, bool lines, bool markers) {
|
||||
//for each plot, create hists
|
||||
for (unsigned int hist_num = 0; hist_num < nHists; ++hist_num) {
|
||||
SlsQtH1D *h = new SlsQtH1D("1d plot", histNBins, histXAxis, histYAxis[hist_num]);
|
||||
@ -138,13 +138,14 @@ void qCloneWidget::SetCloneHists(unsigned int nHists, int histNBins, double *his
|
||||
cloneplot1D_hists.append(h);
|
||||
h->Attach(cloneplot1D);
|
||||
|
||||
lblHistTitle->setText(QString(histTitle[0].c_str()));
|
||||
lblHistTitle->setText(histTitle);
|
||||
}
|
||||
}
|
||||
|
||||
void qCloneWidget::SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d) {
|
||||
void qCloneWidget::SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d, QwtText frameIndexTitle) {
|
||||
cloneplot2D->GetPlot()->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d);
|
||||
cloneplot2D->KeepZRangeIfSet();
|
||||
cloneplot2D->setTitle(frameIndexTitle);
|
||||
}
|
||||
|
||||
void qCloneWidget::SetRange(bool IsXYRange[], double XYRange[]) {
|
||||
|
@ -699,7 +699,7 @@ void qDetectorMain::EnableTabs() {
|
||||
tabDeveloper->Refresh();
|
||||
|
||||
tabPlot->Refresh();
|
||||
myPlot->StartStopDaqToggle();
|
||||
myPlot->StartAcquisition();
|
||||
} else { // to enable scan box
|
||||
tabPlot->Refresh();
|
||||
// to start adc timer
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -523,16 +523,18 @@ void qTabMeasurement::SetRunIndex(int val) {
|
||||
|
||||
void qTabMeasurement::ResetProgress() {
|
||||
FILE_LOG(logDEBUG) << "Resetting progress";
|
||||
lblCurrentFrame->setText(QString::number(0));
|
||||
lblCurrentMeasurement->setText(QString::number(0));
|
||||
lblCurrentFrame->setText("");
|
||||
lblCurrentMeasurement->setText("");
|
||||
progressBar->setValue(0);
|
||||
}
|
||||
|
||||
void qTabMeasurement::UpdateProgress() {
|
||||
FILE_LOG(logDEBUG) << "Updating progress";
|
||||
progressBar->setValue(myPlot->GetProgress());
|
||||
lblCurrentFrame->setText(QString::number(myPlot->GetCurrentFrameIndex()));
|
||||
lblCurrentMeasurement->setText(QString::number(myPlot->GetCurrentMeasurementIndex()));
|
||||
int64_t temp = myPlot->GetCurrentFrameIndex();
|
||||
lblCurrentFrame->setText(temp >= 0 ? QString::number(temp) : "");
|
||||
temp = myPlot->GetCurrentMeasurementIndex();
|
||||
lblCurrentMeasurement->setText(temp >= 0 ? QString::number(temp) : "");
|
||||
}
|
||||
|
||||
int qTabMeasurement::VerifyOutputDirectoryError() {
|
||||
@ -574,8 +576,8 @@ void qTabMeasurement::StartAcquisition() {
|
||||
}
|
||||
|
||||
FILE_LOG(logINFOBLUE) << "Starting Acquisition";
|
||||
lblCurrentFrame->setText(QString::number(0));
|
||||
lblCurrentMeasurement->setText(QString::number(0));
|
||||
lblCurrentFrame->setText("");
|
||||
lblCurrentMeasurement->setText("");
|
||||
Enable(0);
|
||||
progressBar->setValue(0);
|
||||
progressTimer->start(100);
|
||||
|
@ -1,71 +1,60 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
#ifndef DETECTOR_DATA_H
|
||||
#define DETECTOR_DATA_H
|
||||
#pragma once
|
||||
/**
|
||||
@short data structure to hold the detector data after postprocessing (e.g. to plot, store in a root tree etc.)
|
||||
@short data structure to hold the detector data after postprocessing
|
||||
*/
|
||||
class detectorData {
|
||||
public:
|
||||
/** @short The constructor
|
||||
\param f_ind file index
|
||||
\param fname file name to which the data are saved
|
||||
\param np number of points in x coordinate defaults to the number of detector channels (1D detector) or dimension in x (2D detector)
|
||||
\param ny dimension in y (2D detector)
|
||||
\param cval pointer to data in char* format
|
||||
\param dbytes number of bytes of image pointed to by cval pointer
|
||||
\param dr dynamic range or bits per pixel
|
||||
\param file_ind file index
|
||||
/**
|
||||
* Constructor
|
||||
* @param progress progress index
|
||||
* @param fname file name prefix
|
||||
* @param nx number of detector channels (1D detector) or dimension in x (2D detector)
|
||||
* @param ny dimension in y (2D detector)
|
||||
* @param d pointer to data in char* format
|
||||
* @param dbytes number of bytes of image pointed to by cval pointer
|
||||
* @param dr dynamic range or bits per pixel
|
||||
* @param fIndex file index
|
||||
*/
|
||||
detectorData(double f_ind=-1,
|
||||
const char *fname="", int np=-1, int ny=1, char *cval=NULL, int dbytes=0, int dr=0,
|
||||
long long int file_ind=-1) :
|
||||
progressIndex(f_ind),
|
||||
npoints(np), npy(ny), cvalues(cval), databytes(dbytes),
|
||||
dynamicRange(dr), dgainvalues(NULL), fileIndex(file_ind) {
|
||||
strcpy(fileName,fname);
|
||||
};
|
||||
|
||||
|
||||
int64_t getChannel(int i) {
|
||||
int off=dynamicRange/8;
|
||||
if (off==1) {
|
||||
char val=*(cvalues+i);
|
||||
return val;
|
||||
}
|
||||
if (off==2) {
|
||||
int16_t val=*((int16_t*)(cvalues+i*off));
|
||||
return val;
|
||||
}
|
||||
if (off==4) {
|
||||
int32_t val=*((int32_t*)(cvalues+i*off));
|
||||
return val;
|
||||
}
|
||||
if (off==8) {
|
||||
int64_t val=*((int64_t*)(cvalues+i*off));
|
||||
return val;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
detectorData(double progress, std::string fname, int x, int y, char *d, int dbytes, int dr, uint64_t fIndex) :
|
||||
progressIndex(progress), fileName(fname), nx(x), ny(y), data(d), databytes(dbytes), dynamicRange(dr), gain(nullptr), fileIndex(fIndex) {};
|
||||
|
||||
/**
|
||||
@short The destructor
|
||||
deletes also the arrays pointing to data/errors/angles if not NULL
|
||||
cvalues are deleted by caller
|
||||
* Destructor
|
||||
* Also deletes gain
|
||||
* data has to be deleted by caller
|
||||
*/
|
||||
~detectorData() {if(dgainvalues) delete [] dgainvalues;};
|
||||
~detectorData() {if(gain) delete [] gain;};
|
||||
|
||||
int64_t getChannel(int i) {
|
||||
int off=dynamicRange/8;
|
||||
if (off==1) {
|
||||
char val=*(data+i);
|
||||
return val;
|
||||
}
|
||||
if (off==2) {
|
||||
int16_t val=*((int16_t*)(data+i*off));
|
||||
return val;
|
||||
}
|
||||
if (off==4) {
|
||||
int32_t val=*((int32_t*)(data+i*off));
|
||||
return val;
|
||||
}
|
||||
if (off==8) {
|
||||
int64_t val=*((int64_t*)(data+i*off));
|
||||
return val;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
//private:
|
||||
double progressIndex;/**< @short file index */
|
||||
char fileName[1000];/**< @short file name */
|
||||
int npoints;/**< @short number of points */
|
||||
int npy;/**< @short dimensions in y coordinate*/
|
||||
char* cvalues; /**< @short pointer to the data as char arary */
|
||||
int databytes; /**< @short number of bytes of data. Used with cvalues */
|
||||
int dynamicRange; /**< @short dynamic range */
|
||||
double* dgainvalues; /**< @short pointer to gain data as double array for Jungfrau only in show gain mode */
|
||||
long long int fileIndex; /**< @short file index */
|
||||
double progressIndex;
|
||||
std::string fileName;
|
||||
uint64_t fileIndex;
|
||||
int nx;
|
||||
int ny;
|
||||
char* data;
|
||||
double* gain;
|
||||
int databytes;
|
||||
int dynamicRange;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -2091,16 +2091,16 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
* gets detector status and progress index as arguments
|
||||
* @param pArg argument
|
||||
*/
|
||||
void registerAcquisitionFinishedCallback(int (*func)(double, int, void *),
|
||||
void registerAcquisitionFinishedCallback(void (*func)(double, int, void *),
|
||||
void *pArg);
|
||||
|
||||
/**
|
||||
* register callback for accessing measurement final data
|
||||
* @param func function to be called at the end of the acquisition.
|
||||
* gets detector status and progress index as arguments
|
||||
* gets measurement index
|
||||
* @param pArg argument
|
||||
*/
|
||||
void registerMeasurementFinishedCallback(int (*func)(int, int, void *),
|
||||
void registerMeasurementFinishedCallback(void (*func)(int, void *),
|
||||
void *pArg);
|
||||
|
||||
/**
|
||||
@ -2109,7 +2109,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
* gets detector status and progress index as arguments
|
||||
* @param pArg argument
|
||||
*/
|
||||
void registerProgressCallback(int (*func)(double, void *), void *pArg);
|
||||
void registerProgressCallback(void (*func)(double, void *), void *pArg);
|
||||
|
||||
/**
|
||||
* register calbback for accessing detector final data,
|
||||
@ -2120,7 +2120,7 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
* s is for subframe number for eiger for 32 bit mode
|
||||
* @param pArg argument
|
||||
*/
|
||||
void registerDataCallback(int (*userCallback)(detectorData *, int, int,
|
||||
void registerDataCallback(void (*userCallback)(detectorData *, uint64_t, uint32_t,
|
||||
void *),
|
||||
void *pArg);
|
||||
|
||||
@ -2299,16 +2299,16 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
/** detector data packed for the gui */
|
||||
detectorData *thisData{nullptr};
|
||||
|
||||
int (*acquisition_finished)(double, int, void *){nullptr};
|
||||
void (*acquisition_finished)(double, int, void *){nullptr};
|
||||
void *acqFinished_p{nullptr};
|
||||
|
||||
int (*measurement_finished)(int, int, void *){nullptr};
|
||||
void (*measurement_finished)(int, void *){nullptr};
|
||||
void *measFinished_p{nullptr};
|
||||
|
||||
int (*progress_call)(double, void *){nullptr};
|
||||
void (*progress_call)(double, void *){nullptr};
|
||||
void *pProgressCallArg{nullptr};
|
||||
|
||||
int (*dataReady)(detectorData *, int, int, void *){nullptr};
|
||||
void (*dataReady)(detectorData *, uint64_t, uint32_t, void *){nullptr};
|
||||
void *pCallbackArg{nullptr};
|
||||
};
|
||||
|
||||
|
@ -813,7 +813,7 @@ public:
|
||||
* @param pArg argument
|
||||
*/
|
||||
|
||||
void registerDataCallback(int( *userCallback)(detectorData* d, int f, int s, void*), void *pArg);
|
||||
void registerDataCallback(void( *userCallback)(detectorData* d, uint64_t f, uint32_t s, void*), void *pArg);
|
||||
|
||||
/**
|
||||
* register callback for accessing acquisition final data in client,
|
||||
@ -821,15 +821,15 @@ public:
|
||||
* gets detector status and progress index as arguments
|
||||
* @param pArg argument
|
||||
*/
|
||||
void registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg);
|
||||
void registerAcquisitionFinishedCallback(void( *func)(double,int, void*), void *pArg);
|
||||
|
||||
/**
|
||||
* register callback for accessing measurement final data in client,
|
||||
* @param func function to be called at the end of the acquisition.
|
||||
* gets detector status and progress index as arguments
|
||||
* gets measurement index
|
||||
* @param pArg argument
|
||||
*/
|
||||
void registerMeasurementFinishedCallback(int( *func)(int,int, void*), void *pArg);
|
||||
void registerMeasurementFinishedCallback(void( *func)(int, void*), void *pArg);
|
||||
|
||||
/**
|
||||
* register callback for accessing detector progress in client,
|
||||
@ -837,7 +837,7 @@ public:
|
||||
* gets detector status and progress index as arguments
|
||||
* @param pArg argument
|
||||
*/
|
||||
void registerProgressCallback(int( *func)(double,void*), void *pArg);
|
||||
void registerProgressCallback(void( *func)(double,void*), void *pArg);
|
||||
|
||||
/**
|
||||
@short [usage strongly discouraged] sets parameters trough command line interface http://www.psi.ch/detectors/UsersSupportEN/slsDetectorClientHowTo.pdf
|
||||
|
@ -4069,24 +4069,24 @@ int multiSlsDetector::dumpDetectorSetup(const std::string &fname, int level) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
void multiSlsDetector::registerAcquisitionFinishedCallback(int (*func)(double, int, void *),
|
||||
void multiSlsDetector::registerAcquisitionFinishedCallback(void (*func)(double, int, void *),
|
||||
void *pArg) {
|
||||
acquisition_finished = func;
|
||||
acqFinished_p = pArg;
|
||||
}
|
||||
|
||||
void multiSlsDetector::registerMeasurementFinishedCallback(int (*func)(int, int, void *),
|
||||
void multiSlsDetector::registerMeasurementFinishedCallback(void (*func)(int, void *),
|
||||
void *pArg) {
|
||||
measurement_finished = func;
|
||||
measFinished_p = pArg;
|
||||
}
|
||||
|
||||
void multiSlsDetector::registerProgressCallback(int (*func)(double, void *), void *pArg) {
|
||||
void multiSlsDetector::registerProgressCallback(void (*func)(double, void *), void *pArg) {
|
||||
progress_call = func;
|
||||
pProgressCallArg = pArg;
|
||||
}
|
||||
|
||||
void multiSlsDetector::registerDataCallback(int (*userCallback)(detectorData *, int, int, void *),
|
||||
void multiSlsDetector::registerDataCallback(void (*userCallback)(detectorData *, uint64_t, uint32_t, void *),
|
||||
void *pArg) {
|
||||
dataReady = userCallback;
|
||||
pCallbackArg = pArg;
|
||||
@ -4233,7 +4233,7 @@ int multiSlsDetector::acquire() {
|
||||
findex = incrementFileIndex();
|
||||
|
||||
if (measurement_finished != nullptr) {
|
||||
measurement_finished(im, findex, measFinished_p);
|
||||
measurement_finished(im, measFinished_p);
|
||||
}
|
||||
if (multi_shm()->stoppedFlag != 0) {
|
||||
break;
|
||||
|
@ -398,19 +398,19 @@ int slsDetectorUsers::setDetectorMode(int value, int detPos) {
|
||||
|
||||
*********************************************************************/
|
||||
|
||||
void slsDetectorUsers::registerDataCallback(int( *userCallback)(detectorData*, int, int, void*), void *pArg) {
|
||||
void slsDetectorUsers::registerDataCallback(void( *userCallback)(detectorData*, uint64_t, uint32_t, void*), void *pArg) {
|
||||
detector.registerDataCallback(userCallback,pArg);
|
||||
}
|
||||
|
||||
void slsDetectorUsers::registerAcquisitionFinishedCallback(int( *func)(double,int, void*), void *pArg) {
|
||||
void slsDetectorUsers::registerAcquisitionFinishedCallback(void( *func)(double,int, void*), void *pArg) {
|
||||
detector.registerAcquisitionFinishedCallback(func,pArg);
|
||||
}
|
||||
|
||||
void slsDetectorUsers::registerMeasurementFinishedCallback(int( *func)(int,int, void*), void *pArg) {
|
||||
void slsDetectorUsers::registerMeasurementFinishedCallback(void( *func)(int,void*), void *pArg) {
|
||||
detector.registerMeasurementFinishedCallback(func,pArg);
|
||||
}
|
||||
|
||||
void slsDetectorUsers::registerProgressCallback(int( *func)(double,void*), void *pArg) {
|
||||
void slsDetectorUsers::registerProgressCallback(void( *func)(double,void*), void *pArg) {
|
||||
detector.registerProgressCallback(func,pArg);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user