Skip to content

Commit

Permalink
reducing the number of data call backs. incoming from developer
Browse files Browse the repository at this point in the history
  • Loading branch information
thattil committed Sep 12, 2024
1 parent a81a56c commit 6715243
Showing 1 changed file with 11 additions and 58 deletions.
69 changes: 11 additions & 58 deletions slsReceiverSoftware/src/FrameSynchronizerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6715243

Please sign in to comment.