mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 04:47:14 +02:00
ctb callback used
This commit is contained in:
@ -39,11 +39,15 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* @param act pointer to activated
|
||||
* @param depaden pointer to deactivated padding enable
|
||||
* @param sm pointer to silent mode
|
||||
* @param ct pointer to ctb type
|
||||
* @param cdo pointer to ctb digital offset
|
||||
* @param cad pointer to ctb analog databytes
|
||||
*/
|
||||
DataProcessor(int ind, detectorType dtype, Fifo* f, fileFormat* ftype,
|
||||
bool fwenable, bool* mfwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||
uint32_t* freq, uint32_t* timer,
|
||||
bool* fp, bool* act, bool* depaden, bool* sm);
|
||||
bool* fp, bool* act, bool* depaden, bool* sm,
|
||||
int* ct, int* cdo, int* cad);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -217,8 +221,21 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* 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);
|
||||
char*, uint32_t &, void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw CTB data that will be modified
|
||||
* args to raw data call back are
|
||||
* 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).
|
||||
* type CTB chip type
|
||||
* digitalOffset digital offset
|
||||
* analogdataBytes analog databytes
|
||||
*/
|
||||
void registerCallBackCTBReceiverReady(void (*func)(char*,
|
||||
char*, uint32_t &, int, int, int, void*),void *arg);
|
||||
|
||||
|
||||
|
||||
@ -387,6 +404,16 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/** Frame Number of latest processed frame number of an entire Acquisition (including all scans) */
|
||||
uint64_t currentFrameIndex;
|
||||
|
||||
// for ctb call back
|
||||
/** ctb type*/
|
||||
int* ctbType;
|
||||
/** ctb digital offset */
|
||||
int* ctbDigitalOffset;
|
||||
/** ctb analog databytes */
|
||||
int* ctbAnalogDataBytes;
|
||||
|
||||
|
||||
|
||||
|
||||
//call back
|
||||
/**
|
||||
@ -409,6 +436,20 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
void (*rawDataModifyReadyCallBack)(char*,
|
||||
char*, uint32_t &, void*);
|
||||
|
||||
/**
|
||||
* Call back for raw CTB data that will be modified
|
||||
* args to raw data call back are
|
||||
* 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).
|
||||
* type CTB chip type
|
||||
* digitalOffset digital offset
|
||||
* analogdataBytes analog databytes
|
||||
*/
|
||||
void (*ctbRawDataReadyCallBack)(char*,
|
||||
char*, uint32_t &, int, int, int, void*);
|
||||
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
|
@ -95,6 +95,20 @@ class slsReceiver : private virtual slsDetectorDefs {
|
||||
void registerCallBackRawDataModifyReady(void (*func)(char* ,
|
||||
char*, uint32_t &,void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw CTB data that will be modified
|
||||
* args to raw data call back are
|
||||
* 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).
|
||||
* type CTB chip type
|
||||
* digitalOffset digital offset
|
||||
* analogdataBytes analog databytes
|
||||
*/
|
||||
void registerCallBackCTBReceiverReady(void (*func)(char*,
|
||||
char*, uint32_t &, int, int, int, void*),void *arg);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
@ -751,6 +751,20 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
void registerCallBackRawDataModifyReady(void (*func)(char* ,
|
||||
char*, uint32_t &,void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw CTB data that will be modified
|
||||
* args to raw data call back are
|
||||
* 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).
|
||||
* type CTB chip type
|
||||
* digitalOffset digital offset
|
||||
* analogdataBytes analog databytes
|
||||
*/
|
||||
void registerCallBackCTBReceiverReady(void (*func)(char*,
|
||||
char*, uint32_t &, int, int, int, void*),void *arg);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@ -924,6 +938,13 @@ private:
|
||||
/** Fifo Structure to store addresses of memory writes */
|
||||
std::vector<std::unique_ptr<Fifo>> fifo;
|
||||
|
||||
/** ctb type for callback*/
|
||||
int ctbType;
|
||||
/* ctb digital offset for callback */
|
||||
int ctbDigitalOffset;
|
||||
/* analog data bytes */
|
||||
int ctbAnalogDataBytes;
|
||||
|
||||
//***callback parameters***
|
||||
/**
|
||||
* Call back for start acquisition
|
||||
@ -964,6 +985,21 @@ private:
|
||||
*/
|
||||
void (*rawDataModifyReadyCallBack)(char* ,
|
||||
char*, uint32_t &, void*);
|
||||
|
||||
/**
|
||||
* Call back for raw CTB data that will be modified
|
||||
* args to raw data call back are
|
||||
* 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).
|
||||
* type CTB chip type
|
||||
* digitalOffset digital offset
|
||||
* analogdataBytes analog databytes
|
||||
*/
|
||||
void (*ctbRawDataReadyCallBack)(char*,
|
||||
char*, uint32_t &, int, int, int, void*);
|
||||
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
|
@ -92,6 +92,21 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
void registerCallBackRawDataModifyReady(void (*func)(char* ,
|
||||
char*, uint32_t &,void*),void *arg);
|
||||
|
||||
/**
|
||||
* Call back for raw CTB data that will be modified
|
||||
* args to raw data call back are
|
||||
* 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).
|
||||
* type CTB chip type
|
||||
* digitalOffset digital offset
|
||||
* analogdataBytes analog databytes
|
||||
*/
|
||||
void registerCallBackCTBReceiverReady(void (*func)(char*,
|
||||
char*, uint32_t &, int, int, int, void*),void *arg);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@ -367,6 +382,21 @@ class slsReceiverTCPIPInterface : private virtual slsDetectorDefs {
|
||||
void (*rawDataModifyReadyCallBack)(char* ,
|
||||
char*, uint32_t &, void*);
|
||||
|
||||
/**
|
||||
* Call back for raw CTB data that will be modified
|
||||
* args to raw data call back are
|
||||
* 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).
|
||||
* type CTB chip type
|
||||
* digitalOffset digital offset
|
||||
* analogdataBytes analog databytes
|
||||
*/
|
||||
void (*ctbRawDataReadyCallBack)(char*,
|
||||
char*, uint32_t &, int, int, int, void*);
|
||||
|
||||
|
||||
void *pRawDataReady;
|
||||
|
||||
|
||||
|
@ -87,6 +87,16 @@ public:
|
||||
void registerCallBackRawDataModifyReady(void (*func)(char* header,
|
||||
char* datapointer, uint32_t &revDatasize, void*),void *arg);
|
||||
|
||||
/**
|
||||
@short register callback to be called when CTB data are available in receiver (to process and/or save the data).
|
||||
\param func raw data ready callback. arguments are sls_receiver_header, dataPointer, revDatasize is the reference of data size in bytes, chip type, digital offset, analog databytes. revDatasize be modified to the new size to be written/streamed. (only smaller value).
|
||||
\param arg argument
|
||||
\returns nothing
|
||||
*/
|
||||
void registerCallBackCTBReceiverReady(void (*func)(char* header,
|
||||
char* datapointer, uint32_t &revDatasize, int type, int digitalOffset, int analogDataBytes, void*),void *arg);
|
||||
|
||||
|
||||
//receiver object
|
||||
std::unique_ptr<slsReceiver> receiver;
|
||||
};
|
||||
|
@ -27,7 +27,8 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
||||
fileFormat* ftype, bool fwenable, bool* mfwenable,
|
||||
bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||
uint32_t* freq, uint32_t* timer,
|
||||
bool* fp, bool* act, bool* depaden, bool* sm) :
|
||||
bool* fp, bool* act, bool* depaden, bool* sm,
|
||||
int* ct, int* cdo, int* cad) :
|
||||
|
||||
ThreadObject(ind),
|
||||
runningFlag(0),
|
||||
@ -56,8 +57,12 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
||||
numTotalFramesCaught(0),
|
||||
numFramesCaught(0),
|
||||
currentFrameIndex(0),
|
||||
ctbType(ct),
|
||||
ctbDigitalOffset(cdo),
|
||||
ctbAnalogDataBytes(cad),
|
||||
rawDataReadyCallBack(nullptr),
|
||||
rawDataModifyReadyCallBack(nullptr),
|
||||
ctbRawDataReadyCallBack(nullptr),
|
||||
pRawDataReady(nullptr)
|
||||
{
|
||||
if(ThreadObject::CreateThread() == FAIL)
|
||||
@ -370,6 +375,20 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
pRawDataReady);
|
||||
(*((uint32_t*)buf)) = revsize;
|
||||
}
|
||||
|
||||
// ctb call back
|
||||
else if (ctbRawDataReadyCallBack) {
|
||||
uint32_t revsize = (uint32_t)(*((uint32_t*)buf));
|
||||
ctbRawDataReadyCallBack(
|
||||
(char*)rheader,
|
||||
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
||||
revsize,
|
||||
*ctbType,
|
||||
*ctbDigitalOffset,
|
||||
*ctbAnalogDataBytes,
|
||||
pRawDataReady);
|
||||
(*((uint32_t*)buf)) = revsize;
|
||||
}
|
||||
|
||||
|
||||
// write to file
|
||||
@ -445,7 +464,11 @@ void DataProcessor::registerCallBackRawDataModifyReady(void (*func)(char* ,
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
|
||||
void DataProcessor::registerCallBackCTBReceiverReady(void (*func)(char* ,
|
||||
char*, uint32_t&, int, int, int, void*),void *arg) {
|
||||
ctbRawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
void DataProcessor::PadMissingPackets(char* buf) {
|
||||
FILE_LOG(logDEBUG) << index << ": Padding Missing Packets";
|
||||
|
@ -26,14 +26,16 @@ void sigInterruptHandler(int p){
|
||||
|
||||
|
||||
#ifdef MYTHEN302
|
||||
void GetData(char* metadata, char* datapointer, uint32_t& datasize, void* p) {
|
||||
void GetData(char* metadata, char* datapointer, uint32_t& datasize,
|
||||
int ctbType, int ctbDigitalOffset, int ctbAnalogDataBytes, void* p) {
|
||||
|
||||
constexpr int dynamicRange = 24;
|
||||
constexpr int numSamples = 32 * 3; // 32 channels * 3 counters = 96
|
||||
constexpr int numCounters = numSamples * 2; // 2 strips
|
||||
// validate datasize
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Datasize:" << datasize;
|
||||
int wordsCaught = (datasize / sizeof(uint64_t)) - ctbOffset;
|
||||
int wordsCaught = ((datasize - ctbAnalogDataBytes) / sizeof(uint64_t)) - ctbOffset;
|
||||
int expectedWordSize = numSamples * dynamicRange;
|
||||
if (expectedWordSize != wordsCaught) {
|
||||
FILE_LOG(logWARNING) << "Number of words do not match, Expected "
|
||||
@ -42,7 +44,7 @@ void GetData(char* metadata, char* datapointer, uint32_t& datasize, void* p) {
|
||||
}
|
||||
|
||||
// source
|
||||
uint64_t* ptr = (uint64_t*)datapointer;
|
||||
uint64_t* ptr = (uint64_t*)(datapointer + ctbAnalogDataBytes);
|
||||
// remove the offset from source
|
||||
ptr += ctbOffset;
|
||||
// destination
|
||||
@ -79,8 +81,9 @@ void GetData(char* metadata, char* datapointer, uint32_t& datasize, void* p) {
|
||||
|
||||
// update the size to be written to file & overwrite data in memory
|
||||
datasize = numCounters * sizeof(int);
|
||||
memcpy(datapointer, (char*)result, datasize);
|
||||
memcpy(datapointer + ctbAnalogDataBytes, (char*)result, datasize);
|
||||
delete[] result;
|
||||
datasize += ctbAnalogDataBytes;
|
||||
FILE_LOG(logDEBUG) << "Modified Size: " << datasize;
|
||||
}
|
||||
#endif
|
||||
@ -158,7 +161,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
//register callbacks
|
||||
receiver->registerCallBackRawDataModifyReady(GetData, NULL);
|
||||
receiver->registerCallBackCTBReceiverReady(GetData, NULL);
|
||||
|
||||
//start tcp server thread
|
||||
if (receiver->start() == slsDetectorDefs::FAIL){
|
||||
|
@ -130,3 +130,9 @@ void slsReceiver::registerCallBackRawDataModifyReady(void (*func)(char*,
|
||||
char*, uint32_t &, void*),void *arg){
|
||||
tcpipInterface->registerCallBackRawDataModifyReady(func,arg);
|
||||
}
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackCTBReceiverReady(void (*func)(char* ,
|
||||
char*, uint32_t &, int, int, int, void*),void *arg){
|
||||
tcpipInterface->registerCallBackCTBReceiverReady(func,arg);
|
||||
}
|
||||
|
@ -120,6 +120,7 @@ void slsReceiverImplementation::InitializeMembers() {
|
||||
pAcquisitionFinished = nullptr;
|
||||
rawDataReadyCallBack = nullptr;
|
||||
rawDataModifyReadyCallBack = nullptr;
|
||||
ctbRawDataReadyCallBack = nullptr;
|
||||
pRawDataReady = nullptr;
|
||||
}
|
||||
|
||||
@ -696,7 +697,8 @@ int slsReceiverImplementation::setNumberofUDPInterfaces(const int n) {
|
||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(i, myDetectorType, fifo_ptr, &fileFormatType,
|
||||
fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
||||
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
|
||||
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode));
|
||||
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode,
|
||||
&ctbType, &ctbDigitalOffset, &ctbAnalogDataBytes));
|
||||
dataProcessor[i]->SetGeneralData(generalData);
|
||||
}
|
||||
catch (...) {
|
||||
@ -741,6 +743,10 @@ int slsReceiverImplementation::setNumberofUDPInterfaces(const int n) {
|
||||
for (const auto& it : dataProcessor)
|
||||
it->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady);
|
||||
}
|
||||
if(ctbRawDataReadyCallBack) {
|
||||
for (const auto& it : dataProcessor)
|
||||
it->registerCallBackCTBReceiverReady(ctbRawDataReadyCallBack,pRawDataReady);
|
||||
}
|
||||
|
||||
// test socket buffer size with current set up
|
||||
if (setUDPSocketBufferSize(0) == FAIL) {
|
||||
@ -1136,7 +1142,8 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
|
||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(i, myDetectorType, fifo_ptr, &fileFormatType,
|
||||
fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
||||
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
|
||||
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode));
|
||||
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode,
|
||||
&ctbType, &ctbDigitalOffset, &ctbAnalogDataBytes));
|
||||
}
|
||||
catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
||||
@ -1422,6 +1429,15 @@ void slsReceiverImplementation::registerCallBackRawDataModifyReady(void (*func)(
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverImplementation::registerCallBackCTBReceiverReady(void (*func)(char* ,
|
||||
char*, uint32_t&, int, int, int, void*),void *arg) {
|
||||
ctbRawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
for (const auto& it : dataProcessor)
|
||||
it->registerCallBackCTBReceiverReady(ctbRawDataReadyCallBack,pRawDataReady);
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverImplementation::SetLocalNetworkParameters() {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
|
@ -53,6 +53,7 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
||||
pAcquisitionFinished = nullptr;
|
||||
rawDataReadyCallBack = nullptr;
|
||||
rawDataModifyReadyCallBack = nullptr;
|
||||
ctbRawDataReadyCallBack = nullptr;
|
||||
pRawDataReady = nullptr;
|
||||
|
||||
// create socket
|
||||
@ -130,7 +131,11 @@ void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(void (*func)(
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverTCPIPInterface::registerCallBackCTBReceiverReady(void (*func)(char* ,
|
||||
char*, uint32_t &, int, int, int, void*),void *arg){
|
||||
ctbRawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){
|
||||
((slsReceiverTCPIPInterface*)this_pointer)->startTCPServer();
|
||||
@ -616,6 +621,8 @@ int slsReceiverTCPIPInterface::set_detector_type(){
|
||||
receiver->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady);
|
||||
if(rawDataModifyReadyCallBack)
|
||||
receiver->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady);
|
||||
if(ctbRawDataReadyCallBack)
|
||||
receiver->registerCallBackCTBReceiverReady(ctbRawDataReadyCallBack, pRawDataReady);
|
||||
|
||||
// client has started updating receiver, update ip
|
||||
if (!lockStatus)
|
||||
|
@ -45,3 +45,9 @@ void slsReceiverUsers::registerCallBackRawDataModifyReady(void (*func)(char* hea
|
||||
char* datapointer, uint32_t& revDatasize, void*), void *arg){
|
||||
receiver->registerCallBackRawDataModifyReady(func,arg);
|
||||
}
|
||||
|
||||
void slsReceiverUsers::registerCallBackCTBReceiverReady(void (*func)(char* header,
|
||||
char* datapointer, uint32_t& revDatasize,
|
||||
int type, int digitalOffset, int analogDataBytes, void*), void *arg){
|
||||
receiver->registerCallBackCTBReceiverReady(func,arg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user