This commit is contained in:
maliakal_d 2022-06-08 09:38:47 +02:00
parent 1cfebf667b
commit 4fe520fdaf
10 changed files with 44 additions and 34 deletions

View File

@ -1783,7 +1783,7 @@ int ClientInterface::set_receiver_roi_metadata(Interface &socket) {
} }
int ClientInterface::get_bunch_size(Interface &socket) { int ClientInterface::get_bunch_size(Interface &socket) {
int retval = impl()->getBunchSize(); int retval = static_cast<int>(impl()->getBunchSize());
LOG(logDEBUG1) << "bunch size retval:" << retval; LOG(logDEBUG1) << "bunch size retval:" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
@ -1796,7 +1796,7 @@ int ClientInterface::set_bunch_size(Interface &socket) {
verifyIdle(socket); verifyIdle(socket);
LOG(logDEBUG1) << "Setting bunch size:" << value; LOG(logDEBUG1) << "Setting bunch size:" << value;
try { try {
impl()->setBunchSize(value); impl()->setBunchSize(static_cast<size_t>(value));
} catch (const RuntimeError &e) { } catch (const RuntimeError &e) {
throw RuntimeError("Could not set rx bunch size due to fifo structure memory allocation."); throw RuntimeError("Could not set rx bunch size due to fifo structure memory allocation.");
} }

View File

@ -60,7 +60,7 @@ void DataProcessor::SetReceiverROI(ROI roi) {
receiverRoiEnabled_ = receiverRoi_.completeRoi() ? false : true; receiverRoiEnabled_ = receiverRoi_.completeRoi() ? false : true;
} }
void DataProcessor::SetBunchSize(uint32_t value) { void DataProcessor::SetBunchSize(size_t value) {
fifoBunchSize = value; fifoBunchSize = value;
} }
@ -267,7 +267,8 @@ void DataProcessor::ThreadExecution() {
<< static_cast<void *>(buffer) << std::dec; << static_cast<void *>(buffer) << std::dec;
char* tempBuffer = buffer; char* tempBuffer = buffer;
for (uint32_t iFrame = 0; iFrame != fifoBunchSize; iFrame ++) { for (size_t iFrame = 0; iFrame != fifoBunchSize; iFrame ++) {
LOG(logDEBUG1) << "iFrame:" << iFrame;
// end of acquisition (check dummy) // end of acquisition (check dummy)
auto numBytes = *reinterpret_cast<uint32_t *>(tempBuffer); auto numBytes = *reinterpret_cast<uint32_t *>(tempBuffer);
@ -295,19 +296,26 @@ void DataProcessor::ThreadExecution() {
memcpy(buffer + generalData_->fifoBufferHeaderSize, &completeImageToStreamBeforeCropping[0], generalData_->imageSize); memcpy(buffer + generalData_->fifoBufferHeaderSize, &completeImageToStreamBeforeCropping[0], generalData_->imageSize);
} }
fifo_->PushAddressToStream(buffer); fifo_->PushAddressToStream(buffer);
LOG(logINFORED) << "push to stream!??";
} else { } else {
fifo_->FreeAddress(buffer); fifo_->FreeAddress(buffer);
LOG(logDEBUG1) << "Pushed (free) dataprocessing bunch (EOA) " << std::hex << static_cast<void *>(buffer) << std::dec;
} }
} }
void DataProcessor::StopProcessing(char *buf) { void DataProcessor::StopProcessing(char *buf) {
LOG(logINFORED) << "DataProcessing " << index << ": Dummy"; LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy";
// stream dummy or free // stream dummy or free
if (*dataStreamEnable_) if (*dataStreamEnable_) {
LOG(logINFORED) << "push to stream!??";
fifo_->PushAddressToStream(buf); fifo_->PushAddressToStream(buf);
else }
else {
fifo_->FreeAddress(buf); fifo_->FreeAddress(buf);
LOG(logDEBUG1) << "Pushed (free) stop proc dataprocessing bunch (EOA) " << std::hex << static_cast<void *>(buf) << std::dec;
}
CloseFiles(); CloseFiles();
StopRunning(); StopRunning();

View File

@ -44,7 +44,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
void SetReceiverROI(ROI roi); void SetReceiverROI(ROI roi);
void ResetParametersforNewAcquisition(); void ResetParametersforNewAcquisition();
void SetGeneralData(GeneralData *generalData); void SetGeneralData(GeneralData *generalData);
void SetBunchSize(uint32_t value); void SetBunchSize(size_t value);
void CloseFiles(); void CloseFiles();
void DeleteFiles(); void DeleteFiles();
@ -187,9 +187,9 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
File *dataFile_{nullptr}; File *dataFile_{nullptr};
uint32_t fifoBunchSize{0}; size_t fifoBunchSize{0};
/** size in memory including headers */ /** size in memory including headers */
uint32_t fifoBunchSizeBytes{0}; size_t fifoBunchSizeBytes{0};
// call back // call back
/** /**

View File

@ -81,7 +81,7 @@ void DataStreamer::SetAdditionalJsonHeader(
isAdditionalJsonUpdated = true; isAdditionalJsonUpdated = true;
} }
void DataStreamer::SetBunchSize(uint32_t value) { void DataStreamer::SetBunchSize(size_t value) {
fifoBunchSize = value; fifoBunchSize = value;
} }
@ -126,7 +126,7 @@ void DataStreamer::ThreadExecution() {
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer; << std::hex << (void *)(buffer) << std::dec << ":" << buffer;
char* tempBuffer = buffer; char* tempBuffer = buffer;
for (uint32_t iFrame = 0; iFrame != fifoBunchSize; iFrame ++) { for (size_t iFrame = 0; iFrame != fifoBunchSize; iFrame ++) {
// end of acquisition (check dummy) // end of acquisition (check dummy)
auto numBytes = *reinterpret_cast<uint32_t *>(tempBuffer); auto numBytes = *reinterpret_cast<uint32_t *>(tempBuffer);

View File

@ -56,7 +56,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
void SetFlipRows(bool fd); void SetFlipRows(bool fd);
void void
SetAdditionalJsonHeader(const std::map<std::string, std::string> &json); SetAdditionalJsonHeader(const std::map<std::string, std::string> &json);
void SetBunchSize(uint32_t value); void SetBunchSize(size_t value);
/** /**
* Creates Zmq Sockets * Creates Zmq Sockets
@ -137,9 +137,9 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
bool *quadEnable; bool *quadEnable;
uint64_t *totalNumFrames; uint64_t *totalNumFrames;
uint32_t fifoBunchSize{0}; size_t fifoBunchSize{0};
/** size in memory including headers */ /** size in memory including headers */
uint32_t fifoBunchSizeBytes{0}; size_t fifoBunchSizeBytes{0};
}; };
} // namespace sls } // namespace sls

View File

@ -455,9 +455,9 @@ void Implementation::setReceiverROIMetadata(const ROI arg) {
LOG(logINFO) << "receiver roi Metadata: " << ToString(receiverRoiMetadata); LOG(logINFO) << "receiver roi Metadata: " << ToString(receiverRoiMetadata);
} }
uint32_t Implementation::getBunchSize() const { return bunchSize; } size_t Implementation::getBunchSize() const { return bunchSize; }
void Implementation::setBunchSize(const uint32_t i) { void Implementation::setBunchSize(const size_t i) {
if (bunchSize != i) { if (bunchSize != i) {
bunchSize = i; bunchSize = i;
for (const auto &it : listener) for (const auto &it : listener)

View File

@ -59,8 +59,8 @@ class Implementation : private virtual slsDetectorDefs {
ROI getReceiverROI() const; ROI getReceiverROI() const;
void setReceiverROI(const ROI arg); void setReceiverROI(const ROI arg);
void setReceiverROIMetadata(const ROI arg); void setReceiverROIMetadata(const ROI arg);
uint32_t getBunchSize() const; size_t getBunchSize() const;
void setBunchSize(const uint32_t i); void setBunchSize(const size_t i);
/************************************************** /**************************************************
* * * *
@ -313,7 +313,7 @@ class Implementation : private virtual slsDetectorDefs {
std::array<ROI, 2> portRois{}; std::array<ROI, 2> portRois{};
// receiver roi for complete detector for metadata // receiver roi for complete detector for metadata
ROI receiverRoiMetadata{}; ROI receiverRoiMetadata{};
uint32_t bunchSize{0}; size_t bunchSize{0};
// file parameters // file parameters
fileFormat fileFormatType{BINARY}; fileFormat fileFormatType{BINARY};

View File

@ -126,7 +126,7 @@ void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
void Listener::SetActivate(bool enable) { activated = enable; } void Listener::SetActivate(bool enable) { activated = enable; }
void Listener::SetBunchSize(uint32_t value) { void Listener::SetBunchSize(size_t value) {
fifoBunchSize = value; fifoBunchSize = value;
} }
@ -232,47 +232,51 @@ void Listener::SetHardCodedPosition(uint16_t r, uint16_t c) {
void Listener::ThreadExecution() { void Listener::ThreadExecution() {
char *buffer; char *buffer;
fifo->GetNewAddress(buffer); fifo->GetNewAddress(buffer);
LOG(logDEBUG5) << "Listener " << index LOG(logDEBUG1) << "Listener " << index
<< ", " << ", "
"pop 0x" "pop 0x"
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer; << std::hex << (void *)(buffer) << std::dec << ":" << buffer;
// get data // get data
char* tempBuffer = buffer; char* tempBuffer = buffer;
for (uint32_t iFrame = 0; iFrame != fifoBunchSize; iFrame ++) { for (size_t iFrame = 0; iFrame != fifoBunchSize; iFrame ++) {
// end of acquisition or not activated // end of acquisition or not activated
if ((*status == TRANSMITTING || !udpSocketAlive) && !carryOverFlag) { if ((*status == TRANSMITTING || !udpSocketAlive) && !carryOverFlag) {
(*((uint32_t *)tempBuffer)) = DUMMY_PACKET_VALUE; (*((uint32_t *)tempBuffer)) = DUMMY_PACKET_VALUE;
LOG(logDEBUG1) << iFrame << ": dummy=" << DUMMY_PACKET_VALUE;
StopListening(buffer); StopListening(buffer);
return; return;
} }
LOG(logDEBUG) << "iframe:" << iFrame << " currentframeindex:" << currentFrameIndex; LOG(logDEBUG1) << "iframe:" << iFrame << " currentframeindex:" << currentFrameIndex;
int rc = ListenToAnImage(tempBuffer); int rc = ListenToAnImage(tempBuffer);
// socket closed or discarding image (free retake) // socket closed or discarding image (free retake)
// weird frame numbers (print and rc = 0), then retake // weird frame numbers (print and rc = 0), then retake
if (rc <= 0) { if (rc <= 0) {
if (udpSocketAlive) { if (udpSocketAlive) {
LOG(logDEBUG1) << iFrame << ": rc<=0" << std::hex << static_cast<void *>(tempBuffer) << std::dec;
--iFrame; --iFrame;
} }
} else { } else {
(*((uint32_t *)tempBuffer)) = rc; (*((uint32_t *)tempBuffer)) = rc;
LOG(logDEBUG1) << iFrame << ": rc=" << rc << " addr:" << std::hex << static_cast<void *>(tempBuffer) << std::dec;
tempBuffer += fifoBunchSizeBytes; tempBuffer += fifoBunchSizeBytes;
} }
} }
// last check // last check
if ((*status != TRANSMITTING || !udpSocketAlive) && !carryOverFlag) { /* if ((*status != TRANSMITTING || !udpSocketAlive) && !carryOverFlag) {
LOG(logINFOBLUE) << "Last check " << std::hex << static_cast<void *>(tempBuffer) << std::dec; LOG(logINFOBLUE) << "Last check " << std::hex << static_cast<void *>(tempBuffer) << std::dec;
(*((uint32_t *)tempBuffer)) = DUMMY_PACKET_VALUE; (*((uint32_t *)tempBuffer)) = DUMMY_PACKET_VALUE;
LOG(logINFOBLUE) << ": dummy=" << DUMMY_PACKET_VALUE;
StopListening(buffer); StopListening(buffer);
return; return;
} }*/
// push into fifo // push into fifo
fifo->PushAddress(buffer); fifo->PushAddress(buffer);
LOG(logINFOBLUE) << "Pushed Listening bunch " << (void*)(buffer); LOG(logDEBUG1) << "Pushed Listening bunch " << std::hex << static_cast<void *>(tempBuffer) << std::dec;
// Statistics // Statistics
if (!(*silentMode)) { if (!(*silentMode)) {
@ -287,7 +291,7 @@ void Listener::ThreadExecution() {
void Listener::StopListening(char *buf) { void Listener::StopListening(char *buf) {
fifo->PushAddress(buf); fifo->PushAddress(buf);
LOG(logINFOBLUE) << "Pushed Listening bunch (EOA) " << (void*)(buf); LOG(logDEBUG1) << "Pushed Listening bunch (EOA) " << std::hex << static_cast<void *>(buf) << std::dec;
StopRunning(); StopRunning();
LOG(logDEBUG1) << index << ": Listening Packets (" << *udpPortNumber LOG(logDEBUG1) << index << ": Listening Packets (" << *udpPortNumber
<< ") : " << numPacketsCaught; << ") : " << numPacketsCaught;

View File

@ -65,7 +65,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
void ResetParametersforNewAcquisition(); void ResetParametersforNewAcquisition();
void SetGeneralData(GeneralData *g); void SetGeneralData(GeneralData *g);
void SetActivate(bool enable); void SetActivate(bool enable);
void SetBunchSize(uint32_t value); void SetBunchSize(size_t value);
void CreateUDPSockets(); void CreateUDPSockets();
void ShutDownUDPSocket(); void ShutDownUDPSocket();
@ -167,9 +167,9 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
std::unique_ptr<char[]> listeningPacket; std::unique_ptr<char[]> listeningPacket;
std::atomic<bool> udpSocketAlive{false}; std::atomic<bool> udpSocketAlive{false};
uint32_t fifoBunchSize{0}; size_t fifoBunchSize{0};
/** size in memory including headers */ /** size in memory including headers */
uint32_t fifoBunchSizeBytes{0}; size_t fifoBunchSizeBytes{0};
// for print progress during acquisition*/ // for print progress during acquisition*/
uint32_t numPacketsStatistic{0}; uint32_t numPacketsStatistic{0};

View File

@ -37,10 +37,8 @@ namespace sls {
#define FILE_BUFFER_SIZE (16 * 1024 * 1024) // 16mb #define FILE_BUFFER_SIZE (16 * 1024 * 1024) // 16mb
// fifo // fifo
#define FIFO_HEADER_NUMBYTES (8) #define FIFO_HEADER_NUMBYTES (16)
#define FIFO_DATASIZE_NUMBYTES (4) #define FIFO_DATASIZE_NUMBYTES (4)
#define FIFO_PADDING_NUMBYTES \
(4) // for 8 byte alignment due to sls_receiver_header structure
// hdf5 // hdf5
#define MAX_CHUNKED_IMAGES (1) #define MAX_CHUNKED_IMAGES (1)