update release

This commit is contained in:
maliakal_d 2022-04-08 11:10:15 +02:00
commit 5d16ba7e16
15 changed files with 159 additions and 177 deletions

View File

@ -19,6 +19,7 @@ Checks: '*,
-google-readability-braces-around-statements, -google-readability-braces-around-statements,
-modernize-use-trailing-return-type, -modernize-use-trailing-return-type,
-readability-isolate-declaration, -readability-isolate-declaration,
-readability-implicit-bool-conversion,
-llvmlibc-*' -llvmlibc-*'
HeaderFilterRegex: \.h HeaderFilterRegex: \.h

View File

@ -61,7 +61,9 @@ This document describes the differences between v7.0.0 and v6.x.x
- fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile - fixed bug introduced in 6.0.0: hdf5 files created 1 file per frame after the initial file which had maxframesperfile
- updatedetectorserver - removes old server current binary pointing to for blackfin - updatedetectorserver - removes old server current binary pointing to for blackfin
- removing copydetectorserver using tftp - removing copydetectorserver using tftp
- registerCallBackRawDataReady and registerCallBackRawDataModifyReady now gives a sls_receiver_header* instead of a char*, and uint32_t to size_t
- registerCallBackStartAcquisition gave incorrect imagesize (+120 bytes). corrected.
- registerCallBackStartAcquisition parameter is a const string reference
2. Resolved Issues 2. Resolved Issues
================== ==================

View File

@ -45,6 +45,7 @@ int main() {
for (const auto &cmd : commands) { for (const auto &cmd : commands) {
std::ostringstream os; std::ostringstream os;
std::cout << cmd << '\n';
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os); proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os);
auto tmp = os.str().erase(0, cmd.size()); auto tmp = os.str().erase(0, cmd.size());

View File

@ -1056,7 +1056,18 @@ std::string CmdProxy::TemperatureValues(int action) {
std::string CmdProxy::Dac(int action) { std::string CmdProxy::Dac(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (args.size() == 0) {
os << GetHelpDac(std::to_string(0)) << '\n';
} else {
os << args[0] << ' ' << GetHelpDac(args[0]) << '\n';
}
return os.str();
}
auto type = det->getDetectorType().squash(); auto type = det->getDetectorType().squash();
// dac indices only for ctb // dac indices only for ctb
if (args.size() > 0 && action != defs::HELP_ACTION) { if (args.size() > 0 && action != defs::HELP_ACTION) {
if (is_int(args[0]) && type != defs::CHIPTESTBOARD) { if (is_int(args[0]) && type != defs::CHIPTESTBOARD) {
@ -1066,13 +1077,7 @@ std::string CmdProxy::Dac(int action) {
} }
} }
if (action == defs::HELP_ACTION) { if (action == defs::GET_ACTION) {
if (args.size() == 0) {
os << GetHelpDac(std::to_string(0)) << '\n';
} else {
os << args[0] << ' ' << GetHelpDac(args[0]) << '\n';
}
} else if (action == defs::GET_ACTION) {
if (args.empty()) if (args.empty())
WrongNumberOfParameters(1); // This prints slightly wrong WrongNumberOfParameters(1); // This prints slightly wrong

View File

@ -16,6 +16,17 @@ using sls::Detector;
using test::GET; using test::GET;
using test::PUT; using test::PUT;
TEST_CASE("Calling help doesn't throw or cause segfault"){
//Dont add [.cmd] tag this should run with normal tests
CmdProxy proxy(nullptr);
auto commands = proxy.GetProxyCommands();
std::ostringstream os;
for (const auto &cmd : commands)
REQUIRE_NOTHROW(proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
}
TEST_CASE("Unknown command", "[.cmd]") { TEST_CASE("Unknown command", "[.cmd]") {
Detector det; Detector det;

View File

@ -39,52 +39,50 @@ class Receiver : private virtual slsDetectorDefs {
int64_t getReceiverVersion(); int64_t getReceiverVersion();
/** /**
* Call back for start acquisition * Start Acquisition Call back (slsMultiReceiver writes data if file write enabled)
* callback arguments are * if registerCallBackRawDataReady or registerCallBackRawDataModifyReady registered,
* filepath * users get data
* filename * callback arguments are:
* fileindex * - file path
* datasize * - file name prefix
* * - file index
* return value is undefined at the moment * - image size in bytes
* we write depending on file write enable
* users get data to write depending on call backs registered
*/ */
void registerCallBackStartAcquisition(int (*func)(std::string, std::string, void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
uint64_t, uint32_t, uint64_t, size_t, void *),
void *),
void *arg); void *arg);
/** /**
* Call back for acquisition finished * Call back for acquisition finished
* callback argument is * callback argument is:
* total frames caught * - total frames caught
*/ */
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *), void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
void *arg); void *arg);
/** /**
* Call back for raw data * Call back for raw data
* args to raw data ready callback are * args to raw data ready callback are:
* sls_receiver_header frame metadata, * - sls_receiver_header frame metadata,
* dataPointer is the pointer to the data, * - pointer to data
* dataSize in bytes is the size of the data in bytes. * - image size in bytes
*/ */
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t, void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
void *), char *, size_t, void *),
void *arg); void *arg);
/** /**
* Call back for raw data (modified) * Call back for raw data (modified)
* args to raw data ready callback are * args to raw data ready callback are:
* sls_receiver_header frame metadata, * - sls_receiver_header frame metadata,
* dataPointer is the pointer to the data, * - pointer to data
* revDatasize is the reference of data size in bytes. * - revDatasize is the reference of data size in bytes.
* Can be modified to the new size to be written/streamed. (only smaller * Can be modified to the new size to be written/streamed. (only smaller
* value). * value allowed).
*/ */
void registerCallBackRawDataModifyReady(void (*func)(char *, char *, void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
uint32_t &, void *), char *, size_t &,
void *),
void *arg); void *arg);
private: private:

View File

@ -55,7 +55,7 @@ int64_t ClientInterface::getReceiverVersion() { return APIRECEIVER; }
/***callback functions***/ /***callback functions***/
void ClientInterface::registerCallBackStartAcquisition( void ClientInterface::registerCallBackStartAcquisition(
int (*func)(std::string, std::string, uint64_t, uint32_t, void *), int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
void *arg) { void *arg) {
startAcquisitionCallBack = func; startAcquisitionCallBack = func;
pStartAcquisition = arg; pStartAcquisition = arg;
@ -69,13 +69,13 @@ void ClientInterface::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
} }
void ClientInterface::registerCallBackRawDataReady( void ClientInterface::registerCallBackRawDataReady(
void (*func)(char *, char *, uint32_t, void *), void *arg) { void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
rawDataReadyCallBack = func; rawDataReadyCallBack = func;
pRawDataReady = arg; pRawDataReady = arg;
} }
void ClientInterface::registerCallBackRawDataModifyReady( void ClientInterface::registerCallBackRawDataModifyReady(
void (*func)(char *, char *, uint32_t &, void *), void *arg) { void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
rawDataModifyReadyCallBack = func; rawDataModifyReadyCallBack = func;
pRawDataReady = arg; pRawDataReady = arg;
} }

View File

@ -30,25 +30,24 @@ class ClientInterface : private virtual slsDetectorDefs {
int64_t getReceiverVersion(); int64_t getReceiverVersion();
//***callback functions*** //***callback functions***
/** params: filepath, filename, fileindex, datasize */ /** params: file path, file name, file index, image size */
void registerCallBackStartAcquisition(int (*func)(std::string, std::string, void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
uint64_t, uint32_t, uint64_t, size_t, void *),
void *),
void *arg); void *arg);
/** params: total frames caught */ /** params: total frames caught */
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *), void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
void *arg); void *arg);
/** params: sls_receiver_header frame metadata, dataPointer, dataSize */ /** params: sls_receiver_header pointer, pointer to data, image size */
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t, void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
void *), char *, size_t, void *),
void *arg); void *arg);
/** params: sls_receiver_header frame metadata, dataPointer, modified size /** params: sls_receiver_header pointer, pointer to data, reference to image size */
*/ void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
void registerCallBackRawDataModifyReady(void (*func)(char *, char *, char *, size_t &,
uint32_t &, void *), void *),
void *arg); void *arg);
private: private:
@ -180,13 +179,14 @@ class ClientInterface : private virtual slsDetectorDefs {
//***callback parameters*** //***callback parameters***
int (*startAcquisitionCallBack)(std::string, std::string, uint64_t, int (*startAcquisitionCallBack)(const std::string &, const std::string &, uint64_t, size_t,
uint32_t, void *) = nullptr; void *) = nullptr;
void *pStartAcquisition{nullptr}; void *pStartAcquisition{nullptr};
void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr; void (*acquisitionFinishedCallBack)(uint64_t, void *) = nullptr;
void *pAcquisitionFinished{nullptr}; void *pAcquisitionFinished{nullptr};
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *) = nullptr; void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &, void *) = nullptr;
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
void *) = nullptr; void *) = nullptr;
void *pRawDataReady{nullptr}; void *pRawDataReady{nullptr};

View File

@ -42,14 +42,10 @@ DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) { ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) {
LOG(logDEBUG) << "DataProcessor " << index << " created"; LOG(logDEBUG) << "DataProcessor " << index << " created";
memset((void *)&timerbegin_, 0, sizeof(timespec));
} }
DataProcessor::~DataProcessor() { DeleteFiles(); } DataProcessor::~DataProcessor() { DeleteFiles(); }
/** getters */
bool DataProcessor::GetStartedFlag() const { return startedFlag_; } bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; } void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
@ -66,10 +62,8 @@ void DataProcessor::ResetParametersforNewAcquisition() {
void DataProcessor::RecordFirstIndex(uint64_t fnum) { void DataProcessor::RecordFirstIndex(uint64_t fnum) {
// listen to this fnum, later +1 // listen to this fnum, later +1
currentFrameIndex_ = fnum; currentFrameIndex_ = fnum;
startedFlag_ = true; startedFlag_ = true;
firstIndex_ = fnum; firstIndex_ = fnum;
LOG(logDEBUG1) << index << " First Index:" << firstIndex_; LOG(logDEBUG1) << index << " First Index:" << firstIndex_;
} }
@ -84,10 +78,8 @@ void DataProcessor::CloseFiles() {
void DataProcessor::DeleteFiles() { void DataProcessor::DeleteFiles() {
CloseFiles(); CloseFiles();
if (dataFile_) { delete dataFile_;
delete dataFile_; dataFile_ = nullptr;
dataFile_ = nullptr;
}
} }
void DataProcessor::SetupFileWriter(const bool filewriteEnable, void DataProcessor::SetupFileWriter(const bool filewriteEnable,
const fileFormat fileFormatType, const fileFormat fileFormatType,
@ -231,13 +223,11 @@ std::string DataProcessor::CreateMasterFile(
void DataProcessor::ThreadExecution() { void DataProcessor::ThreadExecution() {
char *buffer = nullptr; char *buffer = nullptr;
fifo_->PopAddress(buffer); fifo_->PopAddress(buffer);
LOG(logDEBUG5) << "DataProcessor " << index LOG(logDEBUG5) << "DataProcessor " << index << ", " << std::hex
<< ", " << static_cast<void *>(buffer) << std::dec << ":" << buffer;
"pop 0x"
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
// check dummy // check dummy
auto numBytes = (uint32_t)(*((uint32_t *)buffer)); auto numBytes = *reinterpret_cast<uint32_t *>(buffer);
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes; LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
if (numBytes == DUMMY_PACKET_VALUE) { if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer); StopProcessing(buffer);
@ -282,7 +272,7 @@ void DataProcessor::StopProcessing(char *buf) {
uint64_t DataProcessor::ProcessAnImage(char *buf) { uint64_t DataProcessor::ProcessAnImage(char *buf) {
auto *rheader = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES); auto *rheader = reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
sls_detector_header header = rheader->detHeader; sls_detector_header header = rheader->detHeader;
uint64_t fnum = header.frameNumber; uint64_t fnum = header.frameNumber;
currentFrameIndex_ = fnum; currentFrameIndex_ = fnum;
@ -316,16 +306,17 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
try { try {
// normal call back // normal call back
if (rawDataReadyCallBack != nullptr) { if (rawDataReadyCallBack != nullptr) {
rawDataReadyCallBack((char *)rheader, std::size_t dsize = *reinterpret_cast<uint32_t *>(buf);
rawDataReadyCallBack(rheader,
buf + FIFO_HEADER_NUMBYTES + buf + FIFO_HEADER_NUMBYTES +
sizeof(sls_receiver_header), sizeof(sls_receiver_header),
(uint32_t)(*((uint32_t *)buf)), pRawDataReady); dsize, pRawDataReady);
} }
// call back with modified size // call back with modified size
else if (rawDataModifyReadyCallBack != nullptr) { else if (rawDataModifyReadyCallBack != nullptr) {
auto revsize = (uint32_t)(*((uint32_t *)buf)); std::size_t revsize = *reinterpret_cast<uint32_t *>(buf);
rawDataModifyReadyCallBack((char *)rheader, rawDataModifyReadyCallBack(rheader,
buf + FIFO_HEADER_NUMBYTES + buf + FIFO_HEADER_NUMBYTES +
sizeof(sls_receiver_header), sizeof(sls_receiver_header),
revsize, pRawDataReady); revsize, pRawDataReady);
@ -369,14 +360,15 @@ bool DataProcessor::CheckTimer() {
struct timespec end; struct timespec end;
clock_gettime(CLOCK_REALTIME, &end); clock_gettime(CLOCK_REALTIME, &end);
LOG(logDEBUG1) << index << " Timer elapsed time:" auto elapsed_s = (end.tv_sec - timerbegin_.tv_sec) +
<< ((end.tv_sec - timerbegin_.tv_sec) + (end.tv_nsec - timerbegin_.tv_nsec) / 1e9;
(end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0) double timer_s = *streamingTimerInMs_ / 1e3;
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
<< " seconds"; << " seconds";
// still less than streaming timer, keep waiting // still less than streaming timer, keep waiting
if (((end.tv_sec - timerbegin_.tv_sec) + if (elapsed_s < timer_s)
(end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0) <
((double)*streamingTimerInMs_ / 1000.00))
return false; return false;
// restart timer // restart timer
@ -393,15 +385,14 @@ bool DataProcessor::CheckCount() {
return false; return false;
} }
void DataProcessor::registerCallBackRawDataReady(void (*func)(char *, char *, void DataProcessor::registerCallBackRawDataReady(
uint32_t, void *), void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
void *arg) {
rawDataReadyCallBack = func; rawDataReadyCallBack = func;
pRawDataReady = arg; pRawDataReady = arg;
} }
void DataProcessor::registerCallBackRawDataModifyReady( void DataProcessor::registerCallBackRawDataModifyReady(
void (*func)(char *, char *, uint32_t &, void *), void *arg) { void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
rawDataModifyReadyCallBack = func; rawDataModifyReadyCallBack = func;
pRawDataReady = arg; pRawDataReady = arg;
} }
@ -410,7 +401,8 @@ void DataProcessor::PadMissingPackets(char *buf) {
LOG(logDEBUG) << index << ": Padding Missing Packets"; LOG(logDEBUG) << index << ": Padding Missing Packets";
uint32_t pperFrame = generalData_->packetsPerFrame; uint32_t pperFrame = generalData_->packetsPerFrame;
auto *header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES); auto *header =
reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
uint32_t nmissing = pperFrame - header->detHeader.packetNumber; uint32_t nmissing = pperFrame - header->detHeader.packetNumber;
sls_bitset pmask = header->packetsMask; sls_bitset pmask = header->packetsMask;
@ -483,7 +475,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
// ceil as numResult8Bits could be decimal // ceil as numResult8Bits could be decimal
const int numResult8Bits = const int numResult8Bits =
ceil((double)(numSamples * (*ctbDbitList_).size()) / 8.00); ceil((numSamples * (*ctbDbitList_).size()) / 8.00);
std::vector<uint8_t> result(numResult8Bits); std::vector<uint8_t> result(numResult8Bits);
uint8_t *dest = &result[0]; uint8_t *dest = &result[0];
@ -499,7 +491,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
} }
// loop through the frame digital data // loop through the frame digital data
for (auto ptr = source; ptr < (source + numSamples);) { for (auto *ptr = source; ptr < (source + numSamples);) {
// get selected bit from each 8 bit // get selected bit from each 8 bit
uint8_t bit = (*ptr++ >> bi) & 1; uint8_t bit = (*ptr++ >> bi) & 1;
*dest |= bit << bitoffset; *dest |= bit << bitoffset;

View File

@ -79,28 +79,16 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
const fileFormat fileFormatType, const fileFormat fileFormatType,
MasterAttributes *attr, MasterAttributes *attr,
std::mutex *hdf5LibMutex); std::mutex *hdf5LibMutex);
/**
* Call back for raw data /** params: sls_receiver_header pointer, pointer to data, image size */
* args to raw data ready callback are void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
* sls_receiver_header frame metadata char *, size_t, void *),
* 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); void *arg);
/** /** params: sls_receiver_header pointer, pointer to data, reference to image size */
* Call back for raw data (modified) void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
* args to raw data ready callback are char *, size_t &,
* sls_receiver_header frame metadata void *),
* 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); void *arg);
private: private:
@ -167,7 +155,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
uint32_t *streamingTimerInMs_; uint32_t *streamingTimerInMs_;
uint32_t *streamingStartFnum_; uint32_t *streamingStartFnum_;
uint32_t currentFreqCount_{0}; uint32_t currentFreqCount_{0};
struct timespec timerbegin_; struct timespec timerbegin_{};
bool *framePadding_; bool *framePadding_;
std::vector<int> *ctbDbitList_; std::vector<int> *ctbDbitList_;
int *ctbDbitOffset_; int *ctbDbitOffset_;
@ -195,7 +183,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* dataPointer is the pointer to the data * dataPointer is the pointer to the data
* dataSize in bytes is the size of the data in bytes. * dataSize in bytes is the size of the data in bytes.
*/ */
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *) = nullptr; void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
void *) = nullptr;
/** /**
* Call back for raw data (modified) * Call back for raw data (modified)
@ -205,7 +194,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* revDatasize is the reference of data size in bytes. Can be modified to * revDatasize is the reference of data size in bytes. Can be modified to
* the new size to be written/streamed. (only smaller value). * the new size to be written/streamed. (only smaller value).
*/ */
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &, void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
void *) = nullptr; void *) = nullptr;
void *pRawDataReady{nullptr}; void *pRawDataReady{nullptr};

View File

@ -523,10 +523,10 @@ void Implementation::startReceiver() {
// callbacks // callbacks
if (startAcquisitionCallBack) { if (startAcquisitionCallBack) {
try { try {
startAcquisitionCallBack(filePath, fileName, fileIndex, std::size_t imageSize = static_cast<uint32_t>(generalData->imageSize);
(generalData->imageSize) + startAcquisitionCallBack(
(generalData->fifoBufferHeaderSize), filePath, fileName, fileIndex, imageSize,
pStartAcquisition); pStartAcquisition);
} catch (const std::exception &e) { } catch (const std::exception &e) {
throw sls::RuntimeError("Start Acquisition Callback Error: " + throw sls::RuntimeError("Start Acquisition Callback Error: " +
std::string(e.what())); std::string(e.what()));
@ -1627,7 +1627,7 @@ void Implementation::setDbitOffset(const int s) { ctbDbitOffset = s; }
* * * *
* ************************************************/ * ************************************************/
void Implementation::registerCallBackStartAcquisition( void Implementation::registerCallBackStartAcquisition(
int (*func)(std::string, std::string, uint64_t, uint32_t, void *), int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
void *arg) { void *arg) {
startAcquisitionCallBack = func; startAcquisitionCallBack = func;
pStartAcquisition = arg; pStartAcquisition = arg;
@ -1641,7 +1641,7 @@ void Implementation::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
} }
void Implementation::registerCallBackRawDataReady( void Implementation::registerCallBackRawDataReady(
void (*func)(char *, char *, uint32_t, void *), void *arg) { void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
rawDataReadyCallBack = func; rawDataReadyCallBack = func;
pRawDataReady = arg; pRawDataReady = arg;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
@ -1649,7 +1649,7 @@ void Implementation::registerCallBackRawDataReady(
} }
void Implementation::registerCallBackRawDataModifyReady( void Implementation::registerCallBackRawDataModifyReady(
void (*func)(char *, char *, uint32_t &, void *), void *arg) { void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
rawDataModifyReadyCallBack = func; rawDataModifyReadyCallBack = func;
pRawDataReady = arg; pRawDataReady = arg;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)

View File

@ -252,17 +252,21 @@ class Implementation : private virtual slsDetectorDefs {
* Callbacks * * Callbacks *
* * * *
* ************************************************/ * ************************************************/
void registerCallBackStartAcquisition(int (*func)(std::string, std::string, /** params: file path, file name, file index, image size */
uint64_t, uint32_t, void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
void *), uint64_t, size_t, void *),
void *arg); void *arg);
/** params: total frames caught */
void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *), void registerCallBackAcquisitionFinished(void (*func)(uint64_t, void *),
void *arg); void *arg);
void registerCallBackRawDataReady(void (*func)(char *, char *, uint32_t, /** params: sls_receiver_header pointer, pointer to data, image size */
void *), void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
char *, size_t, void *),
void *arg); void *arg);
void registerCallBackRawDataModifyReady(void (*func)(char *, char *, /** params: sls_receiver_header pointer, pointer to data, reference to image size */
uint32_t &, void *), void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
char *, size_t &,
void *),
void *arg); void *arg);
private: private:
@ -369,13 +373,14 @@ class Implementation : private virtual slsDetectorDefs {
int ctbDbitOffset{0}; int ctbDbitOffset{0};
// callbacks // callbacks
int (*startAcquisitionCallBack)(std::string, std::string, uint64_t, int (*startAcquisitionCallBack)(const std::string &, const std::string &, uint64_t, size_t,
uint32_t, void *){nullptr}; void *){nullptr};
void *pStartAcquisition{nullptr}; void *pStartAcquisition{nullptr};
void (*acquisitionFinishedCallBack)(uint64_t, void *){nullptr}; void (*acquisitionFinishedCallBack)(uint64_t, void *){nullptr};
void *pAcquisitionFinished{nullptr}; void *pAcquisitionFinished{nullptr};
void (*rawDataReadyCallBack)(char *, char *, uint32_t, void *){nullptr}; void (*rawDataReadyCallBack)(sls_receiver_header *, char *, size_t,
void (*rawDataModifyReadyCallBack)(char *, char *, uint32_t &, void *){nullptr};
void (*rawDataModifyReadyCallBack)(sls_receiver_header *, char *, size_t &,
void *){nullptr}; void *){nullptr};
void *pRawDataReady{nullptr}; void *pRawDataReady{nullptr};

View File

@ -47,32 +47,21 @@ void printHelp() {
} }
/** /**
* Start Acquisition Call back * Start Acquisition Call back (slsMultiReceiver writes data if file write enabled)
* slsReceiver writes data if file write enabled. * if registerCallBackRawDataReady or registerCallBackRawDataModifyReady registered,
* Users get data to write using call back if registerCallBackRawDataReady is * users get data
* registered.
* @param filepath file path
* @param filename file name
* @param fileindex file index
* @param datasize data size in bytes
* @param p pointer to object
* \returns ignored
*/ */
int StartAcq(std::string filepath, std::string filename, uint64_t fileindex, int StartAcq(const std::string & filePath, const std::string & fileName, uint64_t fileIndex,
uint32_t datasize, void *p) { size_t imageSize, void *objectPointer) {
LOG(logINFOBLUE) << "#### StartAcq: filepath:" << filepath LOG(logINFOBLUE) << "#### StartAcq: filePath:" << filePath
<< " filename:" << filename << " fileindex:" << fileindex << " fileName:" << fileName << " fileIndex:" << fileIndex
<< " datasize:" << datasize << " ####"; << " imageSize:" << imageSize << " ####";
return 0; return 0;
} }
/** /** Acquisition Finished Call back */
* Acquisition Finished Call back void AcquisitionFinished(uint64_t framesCaught, void *objectPointer) {
* @param frames Number of frames caught LOG(logINFOBLUE) << "#### AcquisitionFinished: framesCaught:" << framesCaught
* @param p pointer to object
*/
void AcquisitionFinished(uint64_t frames, void *p) {
LOG(logINFOBLUE) << "#### AcquisitionFinished: frames:" << frames
<< " ####"; << " ####";
} }
@ -80,14 +69,9 @@ void AcquisitionFinished(uint64_t frames, void *p) {
* Get Receiver Data Call back * Get Receiver Data Call back
* Prints in different colors(for each receiver process) the different headers * Prints in different colors(for each receiver process) the different headers
* for each image call back. * for each image call back.
* @param metadata sls_receiver_header metadata
* @param datapointer pointer to data
* @param datasize data size in bytes.
* @param p pointer to object
*/ */
void GetData(char *metadata, char *datapointer, uint32_t datasize, void *p) { void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
slsDetectorDefs::sls_receiver_header *header = size_t imageSize, void *objectPointer) {
(slsDetectorDefs::sls_receiver_header *)metadata;
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader; slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR( PRINT_IN_COLOR(
@ -98,7 +82,7 @@ void GetData(char *metadata, char *datapointer, uint32_t datasize, void *p) {
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u" "row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
//"\t\tpacketsMask:%s" //"\t\tpacketsMask:%s"
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", "\t\tfirstbytedata: 0x%x\t\tdatsize: %zu\n\n",
detectorHeader.row, (long unsigned int)detectorHeader.frameNumber, detectorHeader.row, (long unsigned int)detectorHeader.frameNumber,
detectorHeader.expLength, detectorHeader.packetNumber, detectorHeader.expLength, detectorHeader.packetNumber,
(long unsigned int)detectorHeader.bunchId, (long unsigned int)detectorHeader.bunchId,
@ -107,23 +91,18 @@ void GetData(char *metadata, char *datapointer, uint32_t datasize, void *p) {
detectorHeader.debug, detectorHeader.roundRNumber, detectorHeader.debug, detectorHeader.roundRNumber,
detectorHeader.detType, detectorHeader.version, detectorHeader.detType, detectorHeader.version,
// header->packetsMask.to_string().c_str(), // header->packetsMask.to_string().c_str(),
((uint8_t)(*((uint8_t *)(datapointer)))), datasize); ((uint8_t)(*((uint8_t *)(dataPointer)))), imageSize);
} }
/** /**
* Get Receiver Data Call back (modified) * Get Receiver Data Call back (modified)
* Prints in different colors(for each receiver process) the different headers * Prints in different colors(for each receiver process) the different headers
* for each image call back. * for each image call back.
* @param metadata sls_receiver_header metadata * @param modifiedImageSize new data size in bytes after the callback.
* @param datapointer pointer to data
* @param revDatasize new data size in bytes after the callback.
* This will be the size written/streamed. (only smaller value is allowed). * This will be the size written/streamed. (only smaller value is allowed).
* @param p pointer to object
*/ */
void GetData(char *metadata, char *datapointer, uint32_t &revDatasize, void GetData(slsDetectorDefs::sls_receiver_header *header, char *dataPointer,
void *p) { size_t &modifiedImageSize, void *objectPointer) {
slsDetectorDefs::sls_receiver_header *header =
(slsDetectorDefs::sls_receiver_header *)metadata;
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader; slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
PRINT_IN_COLOR( PRINT_IN_COLOR(
@ -135,7 +114,7 @@ void GetData(char *metadata, char *datapointer, uint32_t &revDatasize,
"row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u" "row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u"
"\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u"
//"\t\tpacketsMask:%s" //"\t\tpacketsMask:%s"
"\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", "\t\tfirstbytedata: 0x%x\t\tdatsize: %zu\n\n",
detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber, detectorHeader.row, (long long unsigned int)detectorHeader.frameNumber,
detectorHeader.expLength, detectorHeader.packetNumber, detectorHeader.expLength, detectorHeader.packetNumber,
(long long unsigned int)detectorHeader.bunchId, (long long unsigned int)detectorHeader.bunchId,
@ -144,10 +123,10 @@ void GetData(char *metadata, char *datapointer, uint32_t &revDatasize,
detectorHeader.debug, detectorHeader.roundRNumber, detectorHeader.debug, detectorHeader.roundRNumber,
detectorHeader.detType, detectorHeader.version, detectorHeader.detType, detectorHeader.version,
// header->packetsMask.to_string().c_str(), // header->packetsMask.to_string().c_str(),
((uint8_t)(*((uint8_t *)(datapointer)))), revDatasize); ((uint8_t)(*((uint8_t *)(dataPointer)))), modifiedImageSize);
// if data is modified, eg ROI and size is reduced // if data is modified, eg ROI and size is reduced
revDatasize = 26000; modifiedImageSize = 26000;
} }
/** /**

View File

@ -129,7 +129,7 @@ int64_t Receiver::getReceiverVersion() {
} }
void Receiver::registerCallBackStartAcquisition( void Receiver::registerCallBackStartAcquisition(
int (*func)(std::string, std::string, uint64_t, uint32_t, void *), int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
void *arg) { void *arg) {
tcpipInterface->registerCallBackStartAcquisition(func, arg); tcpipInterface->registerCallBackStartAcquisition(func, arg);
} }
@ -140,14 +140,13 @@ void Receiver::registerCallBackAcquisitionFinished(void (*func)(uint64_t,
tcpipInterface->registerCallBackAcquisitionFinished(func, arg); tcpipInterface->registerCallBackAcquisitionFinished(func, arg);
} }
void Receiver::registerCallBackRawDataReady(void (*func)(char *, char *, void Receiver::registerCallBackRawDataReady(
uint32_t, void *), void (*func)(sls_receiver_header *, char *, size_t, void *), void *arg) {
void *arg) {
tcpipInterface->registerCallBackRawDataReady(func, arg); tcpipInterface->registerCallBackRawDataReady(func, arg);
} }
void Receiver::registerCallBackRawDataModifyReady( void Receiver::registerCallBackRawDataModifyReady(
void (*func)(char *, char *, uint32_t &, void *), void *arg) { void (*func)(sls_receiver_header *, char *, size_t &, void *), void *arg) {
tcpipInterface->registerCallBackRawDataModifyReady(func, arg); tcpipInterface->registerCallBackRawDataModifyReady(func, arg);
} }

View File

@ -6,7 +6,7 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
TEST_CASE("Time 1s restart then time 2s") { TEST_CASE("Time 1s restart then time 2s", "[.timer]") {
auto sleep_duration = std::chrono::seconds(1); auto sleep_duration = std::chrono::seconds(1);
auto t = sls::Timer(); auto t = sls::Timer();
std::this_thread::sleep_for(sleep_duration); std::this_thread::sleep_for(sleep_duration);
@ -17,7 +17,7 @@ TEST_CASE("Time 1s restart then time 2s") {
REQUIRE(t.elapsed_s() == Approx(2).epsilon(0.01)); REQUIRE(t.elapsed_s() == Approx(2).epsilon(0.01));
} }
TEST_CASE("Return ms") { TEST_CASE("Return ms", "[.timer]") {
auto sleep_duration = std::chrono::milliseconds(1300); auto sleep_duration = std::chrono::milliseconds(1300);
auto t = sls::Timer(); auto t = sls::Timer();
std::this_thread::sleep_for(sleep_duration); std::this_thread::sleep_for(sleep_duration);