diff --git a/manual/manual-api/mainReceiver.cpp b/manual/manual-api/mainReceiver.cpp index ac0eb2233..e39663d3d 100644 --- a/manual/manual-api/mainReceiver.cpp +++ b/manual/manual-api/mainReceiver.cpp @@ -86,6 +86,7 @@ void AcquisitionFinished(uint64_t frames, void*p){ cprintf(BLUE, "#### AcquisitionFinished: frames:%llu ####\n",frames); } + /** * Get Receiver Data Call back * Prints in different colors(for each receiver process) the different headers for each image call back. @@ -94,6 +95,42 @@ void AcquisitionFinished(uint64_t frames, void*p){ * @param packetNumber number of packets caught for this frame * @param bunchId bunch id from beamline * @param timestamp time stamp in 10MHz clock (not implemented for most) + * @param modId module id (not implemented for most) + * @param xCoord x coordinates (detector id in 1D) + * @param yCoord y coordinates (not implemented) + * @param zCoord z coordinates (not implemented) + * @param debug debug values if any + * @param roundRNumber (not implemented) + * @param detType detector type see :: detectorType + * @param version version of standard header (structure format) + * @param datapointer pointer to data + * @param datasize data size in bytes. + * @param p pointer to object + */ +void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, + uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, + char* datapointer, uint32_t datasize, void* p){ + + PRINT_IN_COLOR (modId?modId:xCoord, + "#### %d GetData: ####\n" + "frameNumber: %llu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %llu\t\ttimestamp: %llu\t\tmodId: %u\t\t" + "xCoord: %u\t\tyCoord: %u\t\tzCoord: %u\t\tdebug: %u\t\troundRNumber: %u\t\tdetType: %u\t\t" + "version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", + xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId, + xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, + ((uint8_t)(*((uint8_t*)(datapointer)))), datasize); +} + + + +/** + * Get Receiver Data Call back (modified) + * Prints in different colors(for each receiver process) the different headers for each image call back. + * @param frameNumber frame number + * @param expLength real time exposure length (in 100ns) or sub frame number (Eiger 32 bit mode only) + * @param packetNumber number of packets caught for this frame + * @param bunchId bunch id from beamline + * @param timestamp time stamp in 10MHz clock (not implemented for most) * @param modId module id (not implemented for most) * @param xCoord x coordinates (detector id in 1D) * @param yCoord y coordinates (not implemented) @@ -103,12 +140,14 @@ void AcquisitionFinished(uint64_t frames, void*p){ * @param detType detector type see :: detectorType * @param version version of standard header (structure format) * @param datapointer pointer to data - * @param datasize data size in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). + * @param datasize data size in bytes. + * @param revDatasize new data size in bytes after the callback. + * This will be the size written/streamed. (only smaller value is allowed). * @param p pointer to object */ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, - char* datapointer, uint32_t* datasize, void* p){ + char* datapointer, uint32_t &revDatasize, void* p){ PRINT_IN_COLOR (modId?modId:xCoord, "#### %d GetData: ####\n" @@ -117,12 +156,15 @@ void GetData(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, ui "version: %u\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", xCoord, frameNumber, expLength, packetNumber, bunchId, timestamp, modId, xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, - ((uint8_t)(*((uint8_t*)(datapointer)))), *datasize); - *datasize = 26000; + ((uint8_t)(*((uint8_t*)(datapointer)))), revDatasize); + + // if data is modified, eg ROI and size is reduced + revDatasize = 26000; } + /** * Example of main program using the slsReceiverUsers class * @@ -210,7 +252,8 @@ int main(int argc, char *argv[]) { /* - Call back for raw data */ cprintf(BLUE, "Registering GetData() \n"); - receiver->registerCallBackRawDataReady(GetData,NULL); + if (withCallback == 1) receiver->registerCallBackRawDataReady(GetData,NULL); + else if (withCallback == 2) receiver->registerCallBackRawDataModifyReady(GetData,NULL); } diff --git a/slsReceiverSoftware/include/DataProcessor.h b/slsReceiverSoftware/include/DataProcessor.h index 1636b203b..db559e0d2 100644 --- a/slsReceiverSoftware/include/DataProcessor.h +++ b/slsReceiverSoftware/include/DataProcessor.h @@ -40,7 +40,11 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*), + char*, uint32_t, void*), + void (*dataModifyReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, + uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, + uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*), void *pDataReadycb); /** @@ -378,28 +382,55 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject { //call back - /** - * Call back for raw data - * args to raw data ready callback are - * frameNumber is the frame number - * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) - * packetNumber is the packet number - * bunchId is the bunch id from beamline - * timestamp is the time stamp with 10 MHz clock - * modId is the unique module id (unique even for left, right, top, bottom) - * xCoord is the x coordinate in the complete detector system - * yCoord is the y coordinate in the complete detector system - * zCoord is the z coordinate in the complete detector system - * debug is for debugging purposes - * roundRNumber is the round robin set number - * detType is the detector type see :: detectorType - * version is the version number of this structure format - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). - */ - void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, - uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*); + /** + * Call back for raw data + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * dataSize in bytes is the size of the data in bytes. + */ + void (*rawDataReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t, void*); + + + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * 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 (*rawDataModifyReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*); + void *pRawDataReady; diff --git a/slsReceiverSoftware/include/UDPBaseImplementation.h b/slsReceiverSoftware/include/UDPBaseImplementation.h index 5babfc50c..144fff951 100644 --- a/slsReceiverSoftware/include/UDPBaseImplementation.h +++ b/slsReceiverSoftware/include/UDPBaseImplementation.h @@ -583,31 +583,53 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter */ void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void*),void *arg); - /** - * Call back for raw data - * args to raw data ready callback are - * frameNumber is the frame number - * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) - * packetNumber is the packet number - * bunchId is the bunch id from beamline - * timestamp is the time stamp with 10 MHz clock - * modId is the unique module id (unique even for left, right, top, bottom) - * xCoord is the x coordinate in the complete detector system - * yCoord is the y coordinate in the complete detector system - * zCoord is the z coordinate in the complete detector system - * debug is for debugging purposes - * roundRNumber is the round robin set number - * detType is the detector type see :: detectorType - * version is the version number of this structure format - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). - */ - void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, - uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, - uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*),void *arg); - + /** + * Call back for raw data + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * dataSize in bytes is the size of the data in bytes. + */ + void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t, void*),void *arg); + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * 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)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg); protected: @@ -721,28 +743,55 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter void *pAcquisitionFinished; - /** - * Call back for raw data - * args to raw data ready callback are - * frameNumber is the frame number - * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) - * packetNumber is the packet number - * bunchId is the bunch id from beamline - * timestamp is the time stamp with 10 MHz clock - * modId is the unique module id (unique even for left, right, top, bottom) - * xCoord is the x coordinate in the complete detector system - * yCoord is the y coordinate in the complete detector system - * zCoord is the z coordinate in the complete detector system - * debug is for debugging purposes - * roundRNumber is the round robin set number - * detType is the detector type see :: detectorType - * version is the version number of this structure format - * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). - */ - void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, - uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*); + /** + * Call back for raw data + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * dataPointer is the pointer to the data + * dataSize in bytes is the size of the data in bytes. + */ + void (*rawDataReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t, void*); + + + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * 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 (*rawDataModifyReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*); + void *pRawDataReady; diff --git a/slsReceiverSoftware/include/UDPInterface.h b/slsReceiverSoftware/include/UDPInterface.h index 35e756587..a058ea301 100644 --- a/slsReceiverSoftware/include/UDPInterface.h +++ b/slsReceiverSoftware/include/UDPInterface.h @@ -689,10 +689,36 @@ class UDPInterface { * detType is the detector type see :: detectorType * version is the version number of this structure format * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). + * dataSize in bytes is the size of the data in bytes. */ - virtual void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*),void *arg) = 0; + virtual void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t, void*),void *arg) = 0; + + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * 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). + */ + virtual void registerCallBackRawDataModifyReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg) = 0; protected: diff --git a/slsReceiverSoftware/include/slsReceiver.h b/slsReceiverSoftware/include/slsReceiver.h index 69155ad76..efd0050b9 100644 --- a/slsReceiverSoftware/include/slsReceiver.h +++ b/slsReceiverSoftware/include/slsReceiver.h @@ -91,12 +91,36 @@ class slsReceiver : private virtual slsReceiverDefs { * detType is the detector type see :: detectorType * version is the version number of this structure format * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). + * dataSize in bytes is the size of the data in bytes. */ void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*),void *arg); + char*, uint32_t, void*),void *arg); + + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * 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)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg); diff --git a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h index e75253f14..7e33d6e77 100644 --- a/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h +++ b/slsReceiverSoftware/include/slsReceiverTCPIPInterface.h @@ -98,7 +98,32 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs { void registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*),void *arg); + char*, uint32_t, void*),void *arg); + + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * 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)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg); + private: @@ -346,11 +371,36 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs { * detType is the detector type see :: detectorType * version is the version number of this structure format * dataPointer is the pointer to the data - * dataSize in bytes is the size of the data in bytes. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). + * dataSize in bytes is the size of the data in bytes. */ void (*rawDataReadyCallBack)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*); + char*, uint32_t, void*); + + /** + * Call back for raw data (modified) + * args to raw data ready callback are + * frameNumber is the frame number + * expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) + * packetNumber is the packet number + * bunchId is the bunch id from beamline + * timestamp is the time stamp with 10 MHz clock + * modId is the unique module id (unique even for left, right, top, bottom) + * xCoord is the x coordinate in the complete detector system + * yCoord is the y coordinate in the complete detector system + * zCoord is the z coordinate in the complete detector system + * debug is for debugging purposes + * roundRNumber is the round robin set number + * detType is the detector type see :: detectorType + * version is the version number of this structure format + * 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 (*rawDataModifyReadyCallBack)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*); + void *pRawDataReady; diff --git a/slsReceiverSoftware/include/slsReceiverUsers.h b/slsReceiverSoftware/include/slsReceiverUsers.h index 8035d33b4..b257e64a0 100644 --- a/slsReceiverSoftware/include/slsReceiverUsers.h +++ b/slsReceiverSoftware/include/slsReceiverUsers.h @@ -69,8 +69,18 @@ public: */ void registerCallBackRawDataReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, - char* datapointer, uint32_t* datasize, void*),void *arg); + char* datapointer, uint32_t datasize, void*),void *arg); + + /** + @sort register callback to be called when data are available (to process and/or save the data). + \param func raw data ready callback. arguments are frameNumber, expLength, packetNumber, bunchId, timestamp, modId, xCoord, yCoord, zCoord, debug, roundRNumber, detType, version, dataPointer, revDatasize is the reference of data size in bytes. Can be modified to the new size to be written/streamed. (only smaller value). + \returns nothing + */ + void registerCallBackRawDataModifyReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, + uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, + char* datapointer, uint32_t &revDatasize, void*),void *arg); + //receiver object slsReceiver* receiver; }; diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index d78c8bc48..99835b6ed 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -37,7 +37,11 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* d uint32_t* freq, uint32_t* timer, void (*dataReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*), + char*, uint32_t, void*), + void (*dataModifyReadycb)(uint64_t, uint32_t, uint32_t, uint64_t, + uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, + uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*), void *pDataReadycb) : ThreadObject(NumberofDataProcessors), @@ -62,6 +66,7 @@ DataProcessor::DataProcessor(Fifo*& f, fileFormat* ftype, bool fwenable, bool* d numFramesCaught(0), currentFrameIndex(0), rawDataReadyCallBack(dataReadycb), + rawDataModifyReadyCallBack(dataModifyReadycb), pRawDataReady(pDataReadycb) { if(ThreadObject::CreateThread()){ @@ -411,10 +416,32 @@ void DataProcessor::ProcessAnImage(char* buf) { header->detType, header->version, buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header), - (uint32_t*)buf, + (uint32_t)(*((uint32_t*)buf)), pRawDataReady); } + else if (rawDataModifyReadyCallBack) {cprintf(BG_GREEN,"Calling rawdatamodify\n"); + uint32_t revsize = (uint32_t)(*((uint32_t*)buf)); + rawDataModifyReadyCallBack( + header->frameNumber, + header->expLength, + header->packetNumber, + header->bunchId, + header->timestamp, + header->modId, + header->xCoord, + header->yCoord, + header->zCoord, + header->debug, + header->roundRNumber, + header->detType, + header->version, + buf + FIFO_HEADER_NUMBYTES + sizeof(sls_detector_header), + revsize, + pRawDataReady); + (*((uint32_t*)buf)) = revsize; + } + if (file) file->WriteToFile(buf + FIFO_HEADER_NUMBYTES, sizeof(sls_detector_header) + (uint32_t)(*((uint32_t*)buf)), fnum-firstMeasurementIndex, nump); diff --git a/slsReceiverSoftware/src/UDPBaseImplementation.cpp b/slsReceiverSoftware/src/UDPBaseImplementation.cpp index 64996cb74..cf3c3265d 100644 --- a/slsReceiverSoftware/src/UDPBaseImplementation.cpp +++ b/slsReceiverSoftware/src/UDPBaseImplementation.cpp @@ -30,6 +30,7 @@ UDPBaseImplementation::UDPBaseImplementation(){ acquisitionFinishedCallBack = NULL; pAcquisitionFinished = NULL; rawDataReadyCallBack = NULL; + rawDataModifyReadyCallBack = NULL; pRawDataReady = NULL; } @@ -617,9 +618,16 @@ void UDPBaseImplementation::registerCallBackAcquisitionFinished(void (*func)(uin void UDPBaseImplementation::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*),void *arg){ + char*, uint32_t, void*),void *arg){ rawDataReadyCallBack=func; pRawDataReady=arg; } +void UDPBaseImplementation::registerCallBackRawDataModifyReady(void (*func)(uint64_t, + uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t&, void*),void *arg){ + rawDataModifyReadyCallBack=func; + pRawDataReady=arg; +} //#endif diff --git a/slsReceiverSoftware/src/UDPStandardImplementation.cpp b/slsReceiverSoftware/src/UDPStandardImplementation.cpp index bf6aa324c..ecf061c44 100644 --- a/slsReceiverSoftware/src/UDPStandardImplementation.cpp +++ b/slsReceiverSoftware/src/UDPStandardImplementation.cpp @@ -367,7 +367,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) { listener.push_back(new Listener(myDetectorType, fifo[i], &status, &udpPortNum[i], eth, &activated, &numberOfFrames, &dynamicRange)); dataProcessor.push_back(new DataProcessor(fifo[i], &fileFormatType, fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS, - rawDataReadyCallBack,pRawDataReady)); + rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady)); if (Listener::GetErrorMask() || DataProcessor::GetErrorMask()) { FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")"; for (vector::const_iterator it = listener.begin(); it != listener.end(); ++it) diff --git a/slsReceiverSoftware/src/slsReceiver.cpp b/slsReceiverSoftware/src/slsReceiver.cpp index 9e54c3a45..838554bb3 100644 --- a/slsReceiverSoftware/src/slsReceiver.cpp +++ b/slsReceiverSoftware/src/slsReceiver.cpp @@ -153,7 +153,7 @@ void slsReceiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t, voi void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*),void *arg){ + char*, uint32_t, void*),void *arg){ //tcpipInterface if(udp_interface) udp_interface->registerCallBackRawDataReady(func,arg); @@ -162,3 +162,13 @@ void slsReceiver::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, } +void slsReceiver::registerCallBackRawDataModifyReady(void (*func)(uint64_t, uint32_t, + uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, + uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &, void*),void *arg){ + //tcpipInterface + if(udp_interface) + udp_interface->registerCallBackRawDataModifyReady(func,arg); + else + tcpipInterface->registerCallBackRawDataModifyReady(func,arg); +} diff --git a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp index 9701e983f..e8a703043 100644 --- a/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp +++ b/slsReceiverSoftware/src/slsReceiverTCPIPInterface.cpp @@ -46,6 +46,7 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* acquisitionFinishedCallBack = NULL; pAcquisitionFinished = NULL; rawDataReadyCallBack = NULL; + rawDataModifyReadyCallBack = NULL; pRawDataReady = NULL; unsigned short int port_no=portNumber; @@ -173,11 +174,18 @@ void slsReceiverTCPIPInterface::registerCallBackAcquisitionFinished(void (*func) void slsReceiverTCPIPInterface::registerCallBackRawDataReady(void (*func)(uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, - char*, uint32_t*, void*),void *arg){ + char*, uint32_t, void*),void *arg){ rawDataReadyCallBack=func; pRawDataReady=arg; } +void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(void (*func)(uint64_t, + uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, + uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, + char*, uint32_t &,void*),void *arg){ + rawDataModifyReadyCallBack=func; + pRawDataReady=arg; +} @@ -787,6 +795,8 @@ int slsReceiverTCPIPInterface::set_detector_type(){ receiverBase->registerCallBackAcquisitionFinished(acquisitionFinishedCallBack,pAcquisitionFinished); if(rawDataReadyCallBack) receiverBase->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady); + if(rawDataModifyReadyCallBack) + receiverBase->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady); } myDetectorType = dr; ret = receiverBase->setDetectorType(myDetectorType); diff --git a/slsReceiverSoftware/src/slsReceiverUsers.cpp b/slsReceiverSoftware/src/slsReceiverUsers.cpp index 1ce7de26b..ab19b9bac 100644 --- a/slsReceiverSoftware/src/slsReceiverUsers.cpp +++ b/slsReceiverSoftware/src/slsReceiverUsers.cpp @@ -31,7 +31,12 @@ void slsReceiverUsers::registerCallBackAcquisitionFinished(void (*func)(uint64_t void slsReceiverUsers::registerCallBackRawDataReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, - char* datapointer, uint32_t* datasize, void*), void *arg){ + char* datapointer, uint32_t datasize, void*), void *arg){ receiver->registerCallBackRawDataReady(func,arg); } +void slsReceiverUsers::registerCallBackRawDataModifyReady(void (*func)(uint64_t frameNumber, uint32_t expLength, uint32_t packetNumber, uint64_t bunchId, uint64_t timestamp, + uint16_t modId, uint16_t xCoord, uint16_t yCoord, uint16_t zCoord, uint32_t debug, uint16_t roundRNumber, uint8_t detType, uint8_t version, + char* datapointer, uint32_t& revDatasize, void*), void *arg){ + receiver->registerCallBackRawDataModifyReady(func,arg); +}