This commit is contained in:
2019-08-21 12:45:08 +02:00
parent 62c4bfab64
commit 4b0fb5029f
8 changed files with 48 additions and 39 deletions

View File

@ -74,7 +74,6 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void SetupPlots(); void SetupPlots();
void GetStatistics(double &min, double &max, double &sum); void GetStatistics(double &min, double &max, double &sum);
void DetachHists(); void DetachHists();
static void GetProgressCallBack(double currentProgress, void *this_pointer);
static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer); static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer);
static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer); static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer);
std::string AcquireThread(); std::string AcquireThread();

View File

@ -64,7 +64,6 @@ void qDrawPlot::SetupWidgetWindow() {
SetupPlots(); SetupPlots();
SetDataCallBack(true); SetDataCallBack(true);
myDet->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this); myDet->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this);
myDet->registerProgressCallback(&(GetProgressCallBack), this);
// future watcher to watch result of AcquireThread only because it uses signals/slots to handle acquire exception // future watcher to watch result of AcquireThread only because it uses signals/slots to handle acquire exception
acqResultWatcher = new QFutureWatcher<std::string>(); acqResultWatcher = new QFutureWatcher<std::string>();
@ -590,11 +589,6 @@ std::string qDrawPlot::AcquireThread() {
return std::string(""); return std::string("");
} }
void qDrawPlot::GetProgressCallBack(double currentProgress, void *this_pointer) {
((qDrawPlot *)this_pointer)->progress = currentProgress;
FILE_LOG(logDEBUG) << "Progress Call back successful";
}
void qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer) { void qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer) {
((qDrawPlot *)this_pointer)->AcquisitionFinished(currentProgress, detectorStatus); ((qDrawPlot *)this_pointer)->AcquisitionFinished(currentProgress, detectorStatus);
FILE_LOG(logDEBUG) << "Acquisition Finished Call back successful"; FILE_LOG(logDEBUG) << "Acquisition Finished Call back successful";
@ -606,6 +600,7 @@ void qDrawPlot::GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_
} }
void qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus) { void qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus) {
progress = currentProgress;
std::string status = slsDetectorDefs::runStatusType(static_cast<slsDetectorDefs::runStatus>(detectorStatus)); std::string status = slsDetectorDefs::runStatusType(static_cast<slsDetectorDefs::runStatus>(detectorStatus));
if (detectorStatus == slsDetectorDefs::ERROR) { if (detectorStatus == slsDetectorDefs::ERROR) {

View File

@ -6,6 +6,8 @@
#include <vector> #include <vector>
class multiSlsDetector; class multiSlsDetector;
class detectorData;
namespace sls { namespace sls {
using ns = std::chrono::nanoseconds; using ns = std::chrono::nanoseconds;
class MacAddr; class MacAddr;
@ -83,6 +85,35 @@ class Detector {
/** [Jungfrau][Gotthard] */ /** [Jungfrau][Gotthard] */
void setSettings(defs::detectorSettings value, Positions pos = {}); void setSettings(defs::detectorSettings value, Positions pos = {});
/**************************************************
* *
* Callbacks *
* *
* ************************************************/
/**
* register callback for end of acquisition
* @param func function to be called with parameters:
* current progress in percentage, detector status, pArg pointer
* @param pArg pointer that is returned in call back
*/
void registerAcquisitionFinishedCallback(void (*func)(double, int, void *),
void *pArg);
/**
* register callback for accessing reconstructed complete images
* Receiver sends out images via zmq, the client reconstructs them into
* complete images. Therefore, it also enables zmq streaming from receiver
* and the client.
* @param func function to be called for each image with parameters:
* detector data structure, frame number, sub frame number (for eiger in 32
* bit mode), pArg pointer
* @param pArg pointer that is returned in call back
*/
void registerDataCallback(void (*func)(detectorData *, uint64_t, uint32_t,
void *),
void *pArg);
/************************************************** /**************************************************
* * * *
* Acquisition Parameters * * Acquisition Parameters *

View File

@ -1993,13 +1993,6 @@ class multiSlsDetector : public virtual slsDetectorDefs {
*/ */
void registerAcquisitionFinishedCallback(void (*func)(double, int, void *), void registerAcquisitionFinishedCallback(void (*func)(double, int, void *),
void *pArg); void *pArg);
/**
* register callback for accessing detector progress
* @param func function to be called at the end of the acquisition.
* gets detector status and progress index as arguments
* @param pArg argument
*/
void registerProgressCallback(void (*func)(double, void *), void *pArg);
/** /**
* register calbback for accessing detector final data, * register calbback for accessing detector final data,
@ -2260,9 +2253,6 @@ class multiSlsDetector : public virtual slsDetectorDefs {
void (*acquisition_finished)(double, int, void *){nullptr}; void (*acquisition_finished)(double, int, void *){nullptr};
void *acqFinished_p{nullptr}; void *acqFinished_p{nullptr};
void (*progress_call)(double, void *){nullptr};
void *pProgressCallArg{nullptr};
void (*dataReady)(detectorData *, uint64_t, uint32_t, void *){nullptr}; void (*dataReady)(detectorData *, uint64_t, uint32_t, void *){nullptr};
void *pCallbackArg{nullptr}; void *pCallbackArg{nullptr};
}; };

View File

@ -775,14 +775,6 @@ public:
*/ */
void registerAcquisitionFinishedCallback(void( *func)(double,int, void*), void *pArg); void registerAcquisitionFinishedCallback(void( *func)(double,int, void*), void *pArg);
/**
* register callback for accessing detector progress in client,
* @param func function to be called at the end of the acquisition.
* gets detector status and progress index as arguments
* @param pArg argument
*/
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 @short [usage strongly discouraged] sets parameters trough command line interface http://www.psi.ch/detectors/UsersSupportEN/slsDetectorClientHowTo.pdf
\param command string as it would be written on the command line \param command string as it would be written on the command line

View File

@ -4,6 +4,8 @@
#include "multiSlsDetector.h" #include "multiSlsDetector.h"
#include "slsDetector.h" #include "slsDetector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "detectorData.h"
namespace sls { namespace sls {
using defs = slsDetectorDefs; using defs = slsDetectorDefs;
@ -82,6 +84,20 @@ void Detector::setSettings(defs::detectorSettings value, Positions pos) {
pimpl->Parallel(&slsDetector::setSettings, pos, value); pimpl->Parallel(&slsDetector::setSettings, pos, value);
} }
// Callback
void Detector::registerAcquisitionFinishedCallback(void (*func)(double, int,
void *),
void *pArg) {
pimpl->registerAcquisitionFinishedCallback(func, pArg);
}
void Detector::registerDataCallback(void (*func)(detectorData *, uint64_t,
uint32_t, void *),
void *pArg) {
pimpl->registerDataCallback(func, pArg);
}
// Acquisition Parameters // Acquisition Parameters
Result<int64_t> Detector::getNumberOfFrames() const { Result<int64_t> Detector::getNumberOfFrames() const {

View File

@ -3604,12 +3604,6 @@ void multiSlsDetector::registerAcquisitionFinishedCallback(
acqFinished_p = pArg; acqFinished_p = pArg;
} }
void multiSlsDetector::registerProgressCallback(void (*func)(double, void *),
void *pArg) {
progress_call = func;
pProgressCallArg = pArg;
}
void multiSlsDetector::registerDataCallback( void multiSlsDetector::registerDataCallback(
void (*userCallback)(detectorData *, uint64_t, uint32_t, void *), void (*userCallback)(detectorData *, uint64_t, uint32_t, void *),
void *pArg) { void *pArg) {
@ -3733,10 +3727,6 @@ int multiSlsDetector::acquire() {
sem_post(&sem_newRTAcquisition); sem_post(&sem_newRTAcquisition);
dataProcessingThread.join(); dataProcessingThread.join();
if (progress_call != nullptr) {
progress_call(getCurrentProgress(), pProgressCallArg);
}
if (acquisition_finished != nullptr) { if (acquisition_finished != nullptr) {
acquisition_finished(getCurrentProgress(), getRunStatus(), acquisition_finished(getCurrentProgress(), getRunStatus(),
acqFinished_p); acqFinished_p);

View File

@ -383,10 +383,6 @@ void slsDetectorUsers::registerAcquisitionFinishedCallback(void( *func)(double,i
detector.registerAcquisitionFinishedCallback(func,pArg); detector.registerAcquisitionFinishedCallback(func,pArg);
} }
void slsDetectorUsers::registerProgressCallback(void( *func)(double,void*), void *pArg) {
detector.registerProgressCallback(func,pArg);
}
void slsDetectorUsers::putCommand(const std::string& command){ void slsDetectorUsers::putCommand(const std::string& command){
multiSlsDetectorClient(command, slsDetectorDefs::PUT_ACTION, &detector); multiSlsDetectorClient(command, slsDetectorDefs::PUT_ACTION, &detector);
} }