Merge branch 'refactor' of github.com:slsdetectorgroup/slsDetectorPackage into refactor

This commit is contained in:
Erik Frojdh 2019-03-08 15:13:23 +01:00
commit b8f071dcf6
4 changed files with 52 additions and 25 deletions

View File

@ -38,17 +38,11 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* @param act pointer to activated * @param act pointer to activated
* @param depaden pointer to deactivated padding enable * @param depaden pointer to deactivated padding enable
* @param sm pointer to silent mode * @param sm pointer to silent mode
* @param dataReadycb pointer to data ready call back function
* @param dataModifyReadycb pointer to data ready call back function with modified
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
*/ */
DataProcessor(int ind, detectorType dtype, Fifo* f, fileFormat* ftype, DataProcessor(int ind, detectorType dtype, Fifo* f, fileFormat* ftype,
bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer, uint32_t* freq, uint32_t* timer,
bool* fp, bool* act, bool* depaden, bool* sm, bool* fp, bool* act, bool* depaden, bool* sm);
void (*dataReadycb)(char*, char*, uint32_t, void*),
void (*dataModifyReadycb)(char*, char*, uint32_t &, void*),
void *pDataReadycb);
/** /**
* Destructor * Destructor
@ -203,6 +197,27 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
*/ */
void SetPixelDimension(); void SetPixelDimension();
/**
* Call back for raw data
* args to raw data ready callback are
* sls_receiver_header frame metadata
* dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes.
*/
void registerCallBackRawDataReady(void (*func)(char* ,
char*, uint32_t, void*),void *arg);
/**
* Call back for raw data (modified)
* args to raw data ready callback are
* sls_receiver_header frame metadata
* dataPointer is the pointer to the data
* revDatasize is the reference of data size in bytes.
* Can be modified to the new size to be written/streamed. (only smaller value).
*/
void registerCallBackRawDataModifyReady(void (*func)(char* ,
char*, uint32_t &,void*),void *arg);

View File

@ -26,10 +26,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
fileFormat* ftype, bool fwenable, fileFormat* ftype, bool fwenable,
bool* dsEnable, bool* gpEnable, uint32_t* dr, bool* dsEnable, bool* gpEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer, uint32_t* freq, uint32_t* timer,
bool* fp, bool* act, bool* depaden, bool* sm, bool* fp, bool* act, bool* depaden, bool* sm) :
void (*dataReadycb)(char*, char*, uint32_t, void*),
void (*dataModifyReadycb)(char*, char*, uint32_t &, void*),
void *pDataReadycb) :
ThreadObject(ind), ThreadObject(ind),
runningFlag(0), runningFlag(0),
@ -56,10 +53,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
firstMeasurementIndex(0), firstMeasurementIndex(0),
numTotalFramesCaught(0), numTotalFramesCaught(0),
numFramesCaught(0), numFramesCaught(0),
currentFrameIndex(0), currentFrameIndex(0)
rawDataReadyCallBack(dataReadycb),
rawDataModifyReadyCallBack(dataModifyReadycb),
pRawDataReady(pDataReadycb)
{ {
if(ThreadObject::CreateThread() == FAIL) if(ThreadObject::CreateThread() == FAIL)
throw std::exception(); throw std::exception();
@ -434,6 +428,19 @@ void DataProcessor::SetPixelDimension() {
} }
} }
void DataProcessor::registerCallBackRawDataReady(void (*func)(char* ,
char*, uint32_t, void*),void *arg) {
rawDataReadyCallBack=func;
pRawDataReady=arg;
}
void DataProcessor::registerCallBackRawDataModifyReady(void (*func)(char* ,
char*, uint32_t&, void*),void *arg) {
rawDataModifyReadyCallBack=func;
pRawDataReady=arg;
}
void DataProcessor::PadMissingPackets(char* buf) { void DataProcessor::PadMissingPackets(char* buf) {
FILE_LOG(logDEBUG) << index << ": Padding Missing Packets"; FILE_LOG(logDEBUG) << index << ": Padding Missing Packets";

View File

@ -946,8 +946,7 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
dataProcessor.push_back(sls::make_unique<DataProcessor>(i, myDetectorType, fifo_ptr, &fileFormatType, dataProcessor.push_back(sls::make_unique<DataProcessor>(i, myDetectorType, fifo_ptr, &fileFormatType,
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
&dynamicRange, &streamingFrequency, &streamingTimerInMs, &dynamicRange, &streamingFrequency, &streamingTimerInMs,
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode, &framePadding, &activated, &deactivatedPaddingEnable, &silentMode));
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady));
} }
catch (...) { catch (...) {
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")"; FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
@ -1222,12 +1221,16 @@ void slsReceiverImplementation::registerCallBackRawDataReady(void (*func)(char*
char*, uint32_t, void*),void *arg) { char*, uint32_t, void*),void *arg) {
rawDataReadyCallBack=func; rawDataReadyCallBack=func;
pRawDataReady=arg; pRawDataReady=arg;
for (const auto& it : dataProcessor)
it->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady);
} }
void slsReceiverImplementation::registerCallBackRawDataModifyReady(void (*func)(char* , void slsReceiverImplementation::registerCallBackRawDataModifyReady(void (*func)(char* ,
char*, uint32_t&, void*),void *arg) { char*, uint32_t&, void*),void *arg) {
rawDataModifyReadyCallBack=func; rawDataModifyReadyCallBack=func;
pRawDataReady=arg; pRawDataReady=arg;
for (const auto& it : dataProcessor)
it->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady);
} }

View File

@ -597,6 +597,12 @@ int slsReceiverTCPIPInterface::set_detector_type(){
if(ret == OK) { if(ret == OK) {
if(receiver == nullptr){ if(receiver == nullptr){
receiver = new slsReceiverImplementation(); receiver = new slsReceiverImplementation();
}
myDetectorType = arg;
ret = receiver->setDetectorType(myDetectorType);
retval = myDetectorType;
// callbacks after (in setdetectortype, the object is reinitialized)
if(startAcquisitionCallBack) if(startAcquisitionCallBack)
receiver->registerCallBackStartAcquisition(startAcquisitionCallBack,pStartAcquisition); receiver->registerCallBackStartAcquisition(startAcquisitionCallBack,pStartAcquisition);
if(acquisitionFinishedCallBack) if(acquisitionFinishedCallBack)
@ -605,10 +611,6 @@ int slsReceiverTCPIPInterface::set_detector_type(){
receiver->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady); receiver->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady);
if(rawDataModifyReadyCallBack) if(rawDataModifyReadyCallBack)
receiver->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady); receiver->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady);
}
myDetectorType = arg;
ret = receiver->setDetectorType(myDetectorType);
retval = myDetectorType;
// client has started updating receiver, update ip // client has started updating receiver, update ip
if (!lockStatus) if (!lockStatus)