mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
Merge pull request #355 from slsdetectorgroup/rxframeindex
Rxframeindex
This commit is contained in:
commit
3eafcd69a7
@ -841,7 +841,7 @@ int ClientInterface::get_file_index(Interface &socket) {
|
||||
}
|
||||
|
||||
int ClientInterface::get_frame_index(Interface &socket) {
|
||||
uint64_t retval = impl()->getAcquisitionIndex();
|
||||
uint64_t retval = impl()->getCurrentFrameIndex();
|
||||
LOG(logDEBUG1) << "frame index:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
@ -443,32 +443,31 @@ uint64_t Implementation::getFramesCaught() const {
|
||||
return min;
|
||||
}
|
||||
|
||||
uint64_t Implementation::getAcquisitionIndex() const {
|
||||
uint64_t min = -1;
|
||||
uint64_t Implementation::getCurrentFrameIndex() const {
|
||||
uint64_t max = 0;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
for (const auto &it : dataProcessor) {
|
||||
for (const auto &it : listener) {
|
||||
flagsum += it->GetStartedFlag();
|
||||
min = std::min(min, it->GetCurrentFrameIndex());
|
||||
max = std::max(max, it->GetCurrentFrameIndex());
|
||||
}
|
||||
// no data processed
|
||||
if (flagsum != dataProcessor.size())
|
||||
if (flagsum != listener.size())
|
||||
return 0;
|
||||
return min;
|
||||
return max;
|
||||
}
|
||||
|
||||
double Implementation::getProgress() const {
|
||||
// get minimum of processed frame indices
|
||||
uint64_t currentFrameIndex = -1;
|
||||
uint64_t currentFrameIndex = 0;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
for (const auto &it : dataProcessor) {
|
||||
for (const auto &it : listener) {
|
||||
flagsum += it->GetStartedFlag();
|
||||
currentFrameIndex =
|
||||
std::min(currentFrameIndex, it->GetProcessedIndex());
|
||||
currentFrameIndex = std::max(currentFrameIndex, it->GetListenedIndex());
|
||||
}
|
||||
// no data processed
|
||||
if (flagsum != dataProcessor.size()) {
|
||||
if (flagsum != listener.size()) {
|
||||
currentFrameIndex = -1;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
* ************************************************/
|
||||
runStatus getStatus() const;
|
||||
uint64_t getFramesCaught() const;
|
||||
uint64_t getAcquisitionIndex() const;
|
||||
uint64_t getCurrentFrameIndex() const;
|
||||
double getProgress() const;
|
||||
std::vector<int64_t> getNumMissingPackets() const;
|
||||
void setScan(slsDetectorDefs::scanParameters s);
|
||||
|
@ -53,6 +53,12 @@ int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
|
||||
numPacketsCaught;
|
||||
}
|
||||
|
||||
bool Listener::GetStartedFlag() { return startedFlag; }
|
||||
|
||||
uint64_t Listener::GetCurrentFrameIndex() { return currentFrameIndex; }
|
||||
|
||||
uint64_t Listener::GetListenedIndex() { return currentFrameIndex - firstIndex; }
|
||||
|
||||
void Listener::SetFifo(Fifo *f) { fifo = f; }
|
||||
|
||||
void Listener::ResetParametersforNewAcquisition() {
|
||||
@ -232,16 +238,11 @@ void Listener::ThreadExecution() {
|
||||
|
||||
// discarding image
|
||||
else if (rc < 0) {
|
||||
LOG(logDEBUG) << index << " discarding fnum:" << currentFrameIndex;
|
||||
fifo->FreeAddress(buffer);
|
||||
currentFrameIndex++;
|
||||
return;
|
||||
}
|
||||
|
||||
(*((uint32_t *)buffer)) = rc;
|
||||
(*((uint64_t *)(buffer + FIFO_HEADER_NUMBYTES))) =
|
||||
currentFrameIndex; // for those returning earlier
|
||||
currentFrameIndex++;
|
||||
|
||||
// push into fifo
|
||||
fifo->PushAddress(buffer);
|
||||
@ -334,10 +335,17 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
}
|
||||
switch (*frameDiscardMode) {
|
||||
case DISCARD_EMPTY_FRAMES:
|
||||
if (!numpackets)
|
||||
if (!numpackets) {
|
||||
LOG(logDEBUG)
|
||||
<< index << " Skipped fnum:" << currentFrameIndex;
|
||||
currentFrameIndex = fnum;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case DISCARD_PARTIAL_FRAMES:
|
||||
LOG(logDEBUG)
|
||||
<< index << " discarding fnum:" << currentFrameIndex;
|
||||
currentFrameIndex = fnum;
|
||||
return -1;
|
||||
default:
|
||||
break;
|
||||
@ -347,6 +355,8 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
new_header->detHeader.row = row;
|
||||
new_header->detHeader.column = column;
|
||||
}
|
||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
||||
++currentFrameIndex;
|
||||
return imageSize;
|
||||
}
|
||||
|
||||
@ -423,10 +433,16 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
|
||||
switch (*frameDiscardMode) {
|
||||
case DISCARD_EMPTY_FRAMES:
|
||||
if (!numpackets)
|
||||
if (!numpackets) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case DISCARD_PARTIAL_FRAMES:
|
||||
// empty packet now, but not empty image (EOA)
|
||||
if (numpackets) {
|
||||
LOG(logDEBUG)
|
||||
<< index << " discarding fnum:" << currentFrameIndex;
|
||||
}
|
||||
return -1;
|
||||
default:
|
||||
break;
|
||||
@ -437,7 +453,8 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
new_header->detHeader.row = row;
|
||||
new_header->detHeader.column = column;
|
||||
}
|
||||
return imageSize; // empty packet now, but not empty image
|
||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
||||
return imageSize; // empty packet now, but not empty image (EOA)
|
||||
}
|
||||
|
||||
// update parameters
|
||||
@ -502,10 +519,17 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
|
||||
switch (*frameDiscardMode) {
|
||||
case DISCARD_EMPTY_FRAMES:
|
||||
if (!numpackets)
|
||||
if (!numpackets) {
|
||||
LOG(logDEBUG)
|
||||
<< index << " Skipped fnum:" << currentFrameIndex;
|
||||
currentFrameIndex = fnum;
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case DISCARD_PARTIAL_FRAMES:
|
||||
LOG(logDEBUG)
|
||||
<< index << " discarding fnum:" << currentFrameIndex;
|
||||
currentFrameIndex = fnum;
|
||||
return -1;
|
||||
default:
|
||||
break;
|
||||
@ -516,6 +540,8 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
new_header->detHeader.row = row;
|
||||
new_header->detHeader.column = column;
|
||||
}
|
||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
||||
++currentFrameIndex;
|
||||
return imageSize;
|
||||
}
|
||||
|
||||
@ -577,6 +603,8 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
|
||||
// complete image
|
||||
new_header->detHeader.packetNumber = numpackets; // number of packets caught
|
||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
||||
++currentFrameIndex;
|
||||
return imageSize;
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,12 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* packet */
|
||||
int64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const;
|
||||
|
||||
bool GetStartedFlag();
|
||||
|
||||
uint64_t GetCurrentFrameIndex();
|
||||
/** (-1 if no frames have been caught) */
|
||||
uint64_t GetListenedIndex();
|
||||
|
||||
/**
|
||||
* Set Fifo pointer to the one given
|
||||
* @param f address of Fifo pointer
|
||||
|
Loading…
x
Reference in New Issue
Block a user