From 6715243d2753367b45f54753864f922c41eb8580 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 12 Sep 2024 15:24:46 +0200 Subject: [PATCH] reducing the number of data call backs. incoming from developer --- .../src/FrameSynchronizerApp.cpp | 69 +++---------------- 1 file changed, 11 insertions(+), 58 deletions(-) diff --git a/slsReceiverSoftware/src/FrameSynchronizerApp.cpp b/slsReceiverSoftware/src/FrameSynchronizerApp.cpp index 6ceec06a6b..8a56c1d492 100644 --- a/slsReceiverSoftware/src/FrameSynchronizerApp.cpp +++ b/slsReceiverSoftware/src/FrameSynchronizerApp.cpp @@ -91,10 +91,15 @@ void AcquisitionFinished( << "\n\t]"; } -void printDataCallBackHeader(slsDetectorDefs::sls_receiver_header &header, - slsDetectorDefs::dataCallbackHeader callbackHeader, - char *dataPointer, size_t imageSize, - void *objectPointer) { +/** + * Get Receiver Data Call back + * Prints in different colors(for each receiver process) the different headers + * for each image call back. + */ +void GetData(slsDetectorDefs::sls_receiver_header &header, + slsDetectorDefs::dataCallbackHeader callbackHeader, + char *dataPointer, size_t &imageSize, void *objectPointer) { + slsDetectorDefs::sls_detector_header detectorHeader = header.detHeader; PRINT_IN_COLOR( @@ -143,36 +148,9 @@ void printDataCallBackHeader(slsDetectorDefs::sls_receiver_header &header, detectorHeader.version, // header->packetsMask.to_string().c_str(), ((uint8_t)(*((uint8_t *)(dataPointer)))), imageSize); -} - -/** - * Get Receiver Data Call back - * Prints in different colors(for each receiver process) the different headers - * for each image call back. - */ -void GetData(slsDetectorDefs::sls_receiver_header &header, - slsDetectorDefs::dataCallbackHeader callbackHeader, - char *dataPointer, size_t imageSize, void *objectPointer) { - printDataCallBackHeader(header, callbackHeader, dataPointer, imageSize, - objectPointer); -} - -/** - * Get Receiver Data Call back (modified) - * Prints in different colors(for each receiver process) the different headers - * for each image call back. - * @param modifiedImageSize new data size in bytes after the callback. - * This will be the size written/streamed. (only smaller value is allowed). - */ -void GetData(slsDetectorDefs::sls_receiver_header &header, - slsDetectorDefs::dataCallbackHeader callbackHeader, - char *dataPointer, size_t &modifiedImageSize, - void *objectPointer) { - printDataCallBackHeader(header, callbackHeader, dataPointer, - modifiedImageSize, objectPointer); // if data is modified, eg ROI and size is reduced - modifiedImageSize = 26000; + imageSize = 26000; } /** @@ -239,41 +217,16 @@ int main(int argc, char *argv[]) { sem_t *semaphore = new sem_t; sem_init(semaphore, 1, 0); semaphores.push_back(semaphore); - threads.emplace_back([semaphore, i, startTCPPort, withCallback, numReceivers]() { sls::Receiver receiver(startTCPPort + i); - - /** - register callbacks. remember to set file write enable to 0 - (using the client) if we should not write files and you will write - data using the callbacks */ if (withCallback) { - - /** - Call back for start acquisition */ - cprintf(BLUE, "%d: Registering Start Acquisition Callback\n", - i); receiver.registerCallBackStartAcquisition(StartAcq, nullptr); - - /** - Call back for acquisition finished */ - cprintf(BLUE, "%d: Registering Acquisition Finished Callback\n", - i); receiver.registerCallBackAcquisitionFinished( AcquisitionFinished, nullptr); - - /* - Call back for raw data */ - cprintf(BLUE, "%d: Registering Data Callback \n", i); - if (withCallback == 1) - receiver.registerCallBackRawDataReady(GetData, nullptr); - else if (withCallback == 2) - receiver.registerCallBackRawDataModifyReady(GetData, - nullptr); + receiver.registerCallBackRawDataReady(GetData, nullptr); } - /** - Print Ready and Instructions how to exit */ - if (i == (numReceivers - 1)) { - std::cout << "Ready ... " << std::endl; - cprintf(RESET, "[ Press \'Ctrl+c\' to exit ]\n"); - } /** - as long as no Ctrl+C */ sem_wait(semaphore); sem_destroy(semaphore);