mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 03:40:04 +02:00
- framescaught and frameindex now returns a vector for each port
- progress looks at activated or enabled ports, so progress does not stagnate - (eiger) disable datastreaming also for virtual servers only for 10g - missing packets also takes care of disabled ports
This commit is contained in:
parent
939fc70284
commit
a1ee681135
@ -42,6 +42,10 @@ This document describes the differences between v7.0.0 and v6.x.x
|
||||
- start non blocking acquisition at modular level
|
||||
- hostname cmd failed when connecting to servers in update mode (ctb, moench, jungfrau, eiger)
|
||||
- missingpackets signed (negative => extra packets)
|
||||
- framescaught and frameindex now returns a vector for each port
|
||||
- progress looks at activated or enabled ports, so progress does not stagnate
|
||||
- (eiger) disable datastreaming also for virtual servers only for 10g
|
||||
- missing packets also takes care of disabled ports
|
||||
|
||||
|
||||
2. Resolved Issues
|
||||
|
@ -599,7 +599,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def rx_framescaught(self):
|
||||
"""Number of frames caught by receiver."""
|
||||
"""Number of frames caught by each port in receiver."""
|
||||
return self.getFramesCaught()
|
||||
|
||||
@property
|
||||
@ -1905,7 +1905,7 @@ class Detector(CppDetectorApi):
|
||||
@property
|
||||
@element
|
||||
def rx_frameindex(self):
|
||||
"""Current frame index received in receiver during acquisition."""
|
||||
"""Current frame index received for each port in receiver during acquisition."""
|
||||
return self.getRxCurrentFrameIndex()
|
||||
|
||||
@property
|
||||
|
@ -487,13 +487,17 @@ void init_det(py::module &m) {
|
||||
Detector::getReceiverStatus,
|
||||
py::arg() = Positions{})
|
||||
.def("getFramesCaught",
|
||||
(Result<int64_t>(Detector::*)(sls::Positions) const) &
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getFramesCaught,
|
||||
py::arg() = Positions{})
|
||||
.def("getNumMissingPackets",
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNumMissingPackets,
|
||||
py::arg() = Positions{})
|
||||
.def("getRxCurrentFrameIndex",
|
||||
(Result<std::vector<int64_t>>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxCurrentFrameIndex,
|
||||
py::arg() = Positions{})
|
||||
.def("getNextFrameNumber",
|
||||
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getNextFrameNumber,
|
||||
@ -1647,9 +1651,5 @@ void init_det(py::module &m) {
|
||||
Detector::getMeasurementTime,
|
||||
py::arg() = Positions{})
|
||||
.def("getUserDetails",
|
||||
(std::string(Detector::*)() const) & Detector::getUserDetails)
|
||||
.def("getRxCurrentFrameIndex",
|
||||
(Result<uint64_t>(Detector::*)(sls::Positions) const) &
|
||||
Detector::getRxCurrentFrameIndex,
|
||||
py::arg() = Positions{});
|
||||
(std::string(Detector::*)() const) & Detector::getUserDetails);
|
||||
}
|
||||
|
@ -2285,15 +2285,17 @@ void *start_timer(void *arg) {
|
||||
}
|
||||
|
||||
int skipData = 0;
|
||||
int tgEnable = send_to_ten_gig;
|
||||
if (!eiger_virtual_activate ||
|
||||
(!eiger_virtual_left_datastream && !eiger_virtual_right_datastream)) {
|
||||
(tgEnable &&
|
||||
(!eiger_virtual_left_datastream && !eiger_virtual_right_datastream))) {
|
||||
skipData = 1;
|
||||
LOG(logWARNING, ("Not sending Left and Right datastream\n"));
|
||||
}
|
||||
if (!eiger_virtual_left_datastream) {
|
||||
if (tgEnable && !eiger_virtual_left_datastream) {
|
||||
LOG(logWARNING, ("Not sending Left datastream\n"));
|
||||
}
|
||||
if (!eiger_virtual_right_datastream) {
|
||||
if (tgEnable && !eiger_virtual_right_datastream) {
|
||||
LOG(logWARNING, ("Not sending Right datastream\n"));
|
||||
}
|
||||
|
||||
@ -2303,7 +2305,6 @@ void *start_timer(void *arg) {
|
||||
|
||||
int dr = eiger_dynamicrange;
|
||||
double bytesPerPixel = (double)dr / 8.00;
|
||||
int tgEnable = send_to_ten_gig;
|
||||
int datasize = (tgEnable ? 4096 : 1024);
|
||||
int packetsize = datasize + sizeof(sls_detector_header);
|
||||
int maxPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
|
||||
@ -2465,14 +2466,16 @@ void *start_timer(void *arg) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eiger_virtual_left_datastream && i >= startval &&
|
||||
i <= endval) {
|
||||
if ((!tgEnable ||
|
||||
(tgEnable && eiger_virtual_left_datastream)) &&
|
||||
i >= startval && i <= endval) {
|
||||
usleep(eiger_virtual_transmission_delay_left);
|
||||
sendUDPPacket(iRxEntry, 0, packetData, packetsize);
|
||||
LOG(logDEBUG1, ("Sent left packet: %d\n", i));
|
||||
}
|
||||
if (eiger_virtual_right_datastream && i >= startval &&
|
||||
i <= endval) {
|
||||
if ((!tgEnable ||
|
||||
(tgEnable && eiger_virtual_right_datastream)) &&
|
||||
i >= startval && i <= endval) {
|
||||
usleep(eiger_virtual_transmission_delay_right);
|
||||
sendUDPPacket(iRxEntry, 1, packetData2, packetsize);
|
||||
LOG(logDEBUG1, ("Sent right packet: %d\n", i));
|
||||
|
@ -586,12 +586,17 @@ class Detector {
|
||||
/** Options: IDLE, TRANSMITTING, RUNNING */
|
||||
Result<defs::runStatus> getReceiverStatus(Positions pos = {}) const;
|
||||
|
||||
Result<int64_t> getFramesCaught(Positions pos = {}) const;
|
||||
/** Gets the number of frames caught for each port in receiver. */
|
||||
Result<std::vector<int64_t>> getFramesCaught(Positions pos = {}) const;
|
||||
|
||||
/** Gets the number of missing packets for each port in receiver. Negative
|
||||
* number denotes extra packets. */
|
||||
Result<std::vector<int64_t>> getNumMissingPackets(Positions pos = {}) const;
|
||||
|
||||
/** Gets frame index for each port in receiver. */
|
||||
Result<std::vector<int64_t>>
|
||||
getRxCurrentFrameIndex(Positions pos = {}) const;
|
||||
|
||||
/** [Eiger][Jungfrau][Moench][CTB] */
|
||||
Result<uint64_t> getNextFrameNumber(Positions pos = {}) const;
|
||||
|
||||
@ -1902,7 +1907,6 @@ class Detector {
|
||||
*/
|
||||
std::string getUserDetails() const;
|
||||
|
||||
Result<uint64_t> getRxCurrentFrameIndex(Positions pos = {}) const;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
@ -1286,19 +1286,6 @@ std::string CmdProxy::RxMissingPackets(int action) {
|
||||
WrongNumberOfParameters(0);
|
||||
}
|
||||
auto mp = det->getNumMissingPackets(std::vector<int>{det_id});
|
||||
/*
|
||||
auto tmp = det->getNumMissingPackets(std::vector<int>{det_id});
|
||||
// convert to signed missing packets (to get excess)
|
||||
Result<std::vector<int64_t>> mp(tmp.size());
|
||||
for (unsigned int i = 0; i < mp.size(); ++i) {
|
||||
mp[i] = static_cast<int64_t>(tmp[i]);
|
||||
}
|
||||
OR
|
||||
Result<std::vector<int64_t>> tmp;
|
||||
for (auto val : tmp) {
|
||||
mp.push_back(static_cast<int64_t>(val));
|
||||
}
|
||||
*/
|
||||
os << OutString(mp) << '\n';
|
||||
} else if (action == defs::PUT_ACTION) {
|
||||
throw sls::RuntimeError("Cannot put");
|
||||
|
@ -860,6 +860,7 @@ class CmdProxy {
|
||||
{"status", &CmdProxy::DetectorStatus},
|
||||
{"rx_framescaught", &CmdProxy::rx_framescaught},
|
||||
{"rx_missingpackets", &CmdProxy::RxMissingPackets},
|
||||
{"rx_frameindex", &CmdProxy::rx_frameindex},
|
||||
{"nextframenumber", &CmdProxy::nextframenumber},
|
||||
{"trigger", &CmdProxy::Trigger},
|
||||
{"scan", &CmdProxy::Scan},
|
||||
@ -1084,8 +1085,7 @@ class CmdProxy {
|
||||
{"framecounter", &CmdProxy::framecounter},
|
||||
{"runtime", &CmdProxy::runtime},
|
||||
{"frametime", &CmdProxy::frametime},
|
||||
{"user", &CmdProxy::UserDetails},
|
||||
{"rx_frameindex", &CmdProxy::rx_frameindex}
|
||||
{"user", &CmdProxy::UserDetails}
|
||||
|
||||
};
|
||||
|
||||
@ -1533,11 +1533,11 @@ class CmdProxy {
|
||||
"to IDLE or STOPPED. Goes to stop server.");
|
||||
|
||||
GET_COMMAND(rx_framescaught, getFramesCaught,
|
||||
"\n\tNumber of frames caught by receiver.");
|
||||
"\n\tNumber of frames caught by each port in receiver.");
|
||||
|
||||
GET_COMMAND(rx_missingpackets, getNumMissingPackets,
|
||||
"\n\tNumber of missing packets for each port in receiver. "
|
||||
"Negative number denotes extra packets.");
|
||||
GET_COMMAND(
|
||||
rx_frameindex, getRxCurrentFrameIndex,
|
||||
"\n\tCurrent frame index received in receiver during acquisition.");
|
||||
|
||||
INTEGER_COMMAND_VEC_ID(
|
||||
nextframenumber, getNextFrameNumber, setNextFrameNumber,
|
||||
@ -2251,10 +2251,6 @@ class CmdProxy {
|
||||
"ns|us|ms|s]\n\t[Jungfrau][Mythen3][Gotthard2][Moench]["
|
||||
"CTB] Timestamp at a frame start."
|
||||
"\n\t[Gotthard2] not in burst and auto mode.");
|
||||
|
||||
GET_COMMAND(
|
||||
rx_frameindex, getRxCurrentFrameIndex,
|
||||
"\n\tCurrent frame index received in receiver during acquisition.");
|
||||
};
|
||||
|
||||
} // namespace sls
|
||||
|
@ -793,7 +793,7 @@ Result<defs::runStatus> Detector::getReceiverStatus(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverStatus, pos);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getFramesCaught(Positions pos) const {
|
||||
Result<std::vector<int64_t>> Detector::getFramesCaught(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getFramesCaughtByReceiver, pos);
|
||||
}
|
||||
|
||||
@ -802,6 +802,11 @@ Detector::getNumMissingPackets(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getNumMissingPackets, pos);
|
||||
}
|
||||
|
||||
Result<std::vector<int64_t>>
|
||||
Detector::getRxCurrentFrameIndex(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverCurrentFrameIndex, pos);
|
||||
}
|
||||
|
||||
Result<uint64_t> Detector::getNextFrameNumber(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getNextFrameNumber, pos);
|
||||
}
|
||||
@ -2311,10 +2316,6 @@ Result<ns> Detector::getMeasurementTime(Positions pos) const {
|
||||
|
||||
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
|
||||
|
||||
Result<uint64_t> Detector::getRxCurrentFrameIndex(Positions pos) const {
|
||||
return pimpl->Parallel(&Module::getReceiverCurrentFrameIndex, pos);
|
||||
}
|
||||
|
||||
std::vector<int> Detector::getPortNumbers(int start_port) {
|
||||
int num_sockets_per_detector = pimpl->getNumberofUDPInterfaces({}).tsquash(
|
||||
"Number of UDP Interfaces is not consistent among modules");
|
||||
|
@ -1142,7 +1142,7 @@ int DetectorImpl::acquire() {
|
||||
if (acquisition_finished != nullptr) {
|
||||
int status = Parallel(&Module::getRunStatus, {}).squash(ERROR);
|
||||
auto a = Parallel(&Module::getReceiverProgress, {});
|
||||
double progress = (*std::min_element(a.begin(), a.end()));
|
||||
double progress = (*std::max_element(a.begin(), a.end()));
|
||||
acquisition_finished(progress, status, acqFinished_p);
|
||||
}
|
||||
|
||||
|
@ -866,8 +866,26 @@ double Module::getReceiverProgress() const {
|
||||
return sendToReceiver<double>(F_GET_RECEIVER_PROGRESS);
|
||||
}
|
||||
|
||||
int64_t Module::getFramesCaughtByReceiver() const {
|
||||
return sendToReceiver<int64_t>(F_GET_RECEIVER_FRAMES_CAUGHT);
|
||||
std::vector<int64_t> Module::getFramesCaughtByReceiver() const {
|
||||
// TODO!(Erik) Refactor
|
||||
LOG(logDEBUG1) << "Getting frames caught";
|
||||
if (shm()->useReceiverFlag) {
|
||||
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
client.Send(F_GET_RECEIVER_FRAMES_CAUGHT);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError(
|
||||
"Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
} else {
|
||||
auto nports = client.Receive<int>();
|
||||
std::vector<int64_t> retval(nports);
|
||||
client.Receive(retval);
|
||||
LOG(logDEBUG1) << "Frames caught of Receiver" << moduleIndex << ": "
|
||||
<< sls::ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
throw RuntimeError("No receiver to get frames caught.");
|
||||
}
|
||||
|
||||
std::vector<int64_t> Module::getNumMissingPackets() const {
|
||||
@ -892,6 +910,28 @@ std::vector<int64_t> Module::getNumMissingPackets() const {
|
||||
throw RuntimeError("No receiver to get missing packets.");
|
||||
}
|
||||
|
||||
std::vector<int64_t> Module::getReceiverCurrentFrameIndex() const {
|
||||
// TODO!(Erik) Refactor
|
||||
LOG(logDEBUG1) << "Getting frame index";
|
||||
if (shm()->useReceiverFlag) {
|
||||
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
client.Send(F_GET_RECEIVER_FRAME_INDEX);
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
throw ReceiverError(
|
||||
"Receiver " + std::to_string(moduleIndex) +
|
||||
" returned error: " + client.readErrorMessage());
|
||||
} else {
|
||||
auto nports = client.Receive<int>();
|
||||
std::vector<int64_t> retval(nports);
|
||||
client.Receive(retval);
|
||||
LOG(logDEBUG1) << "Frame index of Receiver" << moduleIndex << ": "
|
||||
<< sls::ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
throw RuntimeError("No receiver to get frame index.");
|
||||
}
|
||||
|
||||
uint64_t Module::getNextFrameNumber() const {
|
||||
return sendToDetector<uint64_t>(F_GET_NEXT_FRAME_NUMBER);
|
||||
}
|
||||
@ -2743,10 +2783,6 @@ int64_t Module::getMeasurementTime() const {
|
||||
return sendToDetectorStop<int64_t>(F_GET_MEASUREMENT_TIME);
|
||||
}
|
||||
|
||||
uint64_t Module::getReceiverCurrentFrameIndex() const {
|
||||
return sendToReceiver<uint64_t>(F_GET_RECEIVER_FRAME_INDEX);
|
||||
}
|
||||
|
||||
// private
|
||||
|
||||
void Module::checkArgs(const void *args, size_t args_size, void *retval,
|
||||
|
@ -199,8 +199,9 @@ class Module : public virtual slsDetectorDefs {
|
||||
runStatus getRunStatus() const;
|
||||
runStatus getReceiverStatus() const;
|
||||
double getReceiverProgress() const;
|
||||
int64_t getFramesCaughtByReceiver() const;
|
||||
std::vector<int64_t> getFramesCaughtByReceiver() const;
|
||||
std::vector<int64_t> getNumMissingPackets() const;
|
||||
std::vector<int64_t> getReceiverCurrentFrameIndex() const;
|
||||
uint64_t getNextFrameNumber() const;
|
||||
void setNextFrameNumber(uint64_t value);
|
||||
void sendSoftwareTrigger(const bool block);
|
||||
@ -576,7 +577,6 @@ class Module : public virtual slsDetectorDefs {
|
||||
int64_t getNumberOfFramesFromStart() const;
|
||||
int64_t getActualTime() const;
|
||||
int64_t getMeasurementTime() const;
|
||||
uint64_t getReceiverCurrentFrameIndex() const;
|
||||
|
||||
private:
|
||||
void checkArgs(const void *args, size_t args_size, void *retval,
|
||||
|
@ -99,7 +99,11 @@ TEST_CASE("rx_framescaught", "[.cmd][.rx]") {
|
||||
{
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
||||
REQUIRE(oss.str() == "rx_framescaught 0\n");
|
||||
if (det.getNumberofUDPInterfaces() == 1) {
|
||||
REQUIRE(oss.str() == "rx_framescaught [0]\n");
|
||||
} else {
|
||||
REQUIRE(oss.str() == "rx_framescaught [0, 0]\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Currently disabled may activate if we have a stable env
|
||||
@ -138,6 +142,19 @@ TEST_CASE("rx_missingpackets", "[.cmd][.rx]") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("rx_frameindex", "[.cmd][.rx]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
proxy.Call("rx_frameindex", {}, -1, GET);
|
||||
|
||||
// This is a get only command
|
||||
REQUIRE_THROWS(proxy.Call("rx_frameindex", {"2"}, -1, PUT));
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_frameindex", {}, 0, GET, oss);
|
||||
std::string s = (oss.str()).erase(0, strlen("rx_frameindex "));
|
||||
REQUIRE(std::stoi(s) >= 0);
|
||||
}
|
||||
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
|
||||
TEST_CASE("rx_printconfig", "[.cmd][.rx]") {
|
||||
@ -884,16 +901,3 @@ TEST_CASE("rx_jsonpara", "[.cmd][.rx]") {
|
||||
}
|
||||
|
||||
/* Insignificant */
|
||||
|
||||
TEST_CASE("rx_frameindex", "[.cmd][.rx]") {
|
||||
Detector det;
|
||||
CmdProxy proxy(&det);
|
||||
proxy.Call("rx_frameindex", {}, -1, GET);
|
||||
|
||||
// This is a get only command
|
||||
REQUIRE_THROWS(proxy.Call("rx_frameindex", {"2"}, -1, PUT));
|
||||
std::ostringstream oss;
|
||||
proxy.Call("rx_frameindex", {}, 0, GET, oss);
|
||||
std::string s = (oss.str()).erase(0, strlen("rx_frameindex "));
|
||||
REQUIRE(std::stoi(s) >= 0);
|
||||
}
|
||||
|
@ -847,9 +847,13 @@ int ClientInterface::get_file_index(Interface &socket) {
|
||||
}
|
||||
|
||||
int ClientInterface::get_frame_index(Interface &socket) {
|
||||
uint64_t retval = impl()->getCurrentFrameIndex();
|
||||
LOG(logDEBUG1) << "frame index:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
auto retval = impl()->getCurrentFrameIndex();
|
||||
LOG(logDEBUG1) << "frames index:" << sls::ToString(retval);
|
||||
auto size = static_cast<int>(retval.size());
|
||||
socket.Send(OK);
|
||||
socket.Send(size);
|
||||
socket.Send(retval);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ClientInterface::get_missing_packets(Interface &socket) {
|
||||
@ -863,9 +867,13 @@ int ClientInterface::get_missing_packets(Interface &socket) {
|
||||
}
|
||||
|
||||
int ClientInterface::get_frames_caught(Interface &socket) {
|
||||
int64_t retval = impl()->getFramesCaught();
|
||||
LOG(logDEBUG1) << "frames caught:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
auto retval = impl()->getFramesCaught();
|
||||
LOG(logDEBUG1) << "frames caught:" << sls::ToString(retval);
|
||||
auto size = static_cast<int>(retval.size());
|
||||
socket.Send(OK);
|
||||
socket.Send(size);
|
||||
socket.Send(retval);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ClientInterface::set_file_write(Interface &socket) {
|
||||
|
@ -52,19 +52,7 @@ DataProcessor::~DataProcessor() { DeleteFiles(); }
|
||||
|
||||
/** getters */
|
||||
|
||||
bool DataProcessor::GetStartedFlag() { return startedFlag_; }
|
||||
|
||||
uint64_t DataProcessor::GetNumFramesCaught() { return numFramesCaught_; }
|
||||
|
||||
uint64_t DataProcessor::GetNumCompleteFramesCaught() {
|
||||
return numCompleteFramesCaught_;
|
||||
}
|
||||
|
||||
uint64_t DataProcessor::GetCurrentFrameIndex() { return currentFrameIndex_; }
|
||||
|
||||
uint64_t DataProcessor::GetProcessedIndex() {
|
||||
return currentFrameIndex_ - firstIndex_;
|
||||
}
|
||||
bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
|
||||
|
||||
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
|
||||
|
||||
@ -72,7 +60,6 @@ void DataProcessor::ResetParametersforNewAcquisition() {
|
||||
StopRunning();
|
||||
startedFlag_ = false;
|
||||
numFramesCaught_ = 0;
|
||||
numCompleteFramesCaught_ = 0;
|
||||
firstIndex_ = 0;
|
||||
currentFrameIndex_ = 0;
|
||||
firstStreamerFrame_ = true;
|
||||
@ -215,10 +202,9 @@ void DataProcessor::CreateVirtualFile(
|
||||
}
|
||||
virtualFile_ = new HDF5VirtualFile(hdf5Lib);
|
||||
|
||||
uint64_t numImagesProcessed = GetProcessedIndex() + 1;
|
||||
// maxframesperfile = 0 for infinite files
|
||||
uint32_t framesPerFile =
|
||||
((maxFramesPerFile == 0) ? numImagesProcessed + 1 : maxFramesPerFile);
|
||||
((maxFramesPerFile == 0) ? numFramesCaught_ : maxFramesPerFile);
|
||||
|
||||
// TODO: assumption 1: create virtual file even if no data in other
|
||||
// files (they exist anyway) assumption2: virtual file max frame index
|
||||
@ -344,9 +330,6 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
||||
currentFrameIndex_ = fnum;
|
||||
numFramesCaught_++;
|
||||
uint32_t nump = header.packetNumber;
|
||||
if (nump == generalData_->packetsPerFrame) {
|
||||
numCompleteFramesCaught_++;
|
||||
}
|
||||
|
||||
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
||||
|
||||
|
@ -36,13 +36,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
|
||||
~DataProcessor() override;
|
||||
|
||||
bool GetStartedFlag();
|
||||
uint64_t GetNumFramesCaught();
|
||||
uint64_t GetNumCompleteFramesCaught();
|
||||
/** (-1 if no frames have been caught */
|
||||
uint64_t GetCurrentFrameIndex();
|
||||
/** (-1 if no frames have been caught) */
|
||||
uint64_t GetProcessedIndex();
|
||||
bool GetStartedFlag() const;
|
||||
|
||||
void SetFifo(Fifo *f);
|
||||
void ResetParametersforNewAcquisition();
|
||||
@ -178,9 +172,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/** Number of frames caught */
|
||||
uint64_t numFramesCaught_{0};
|
||||
|
||||
/** Number of complete frames caught */
|
||||
uint64_t numCompleteFramesCaught_{0};
|
||||
|
||||
/** Frame Number of latest processed frame number */
|
||||
std::atomic<uint64_t> currentFrameIndex_{0};
|
||||
|
||||
|
@ -453,51 +453,51 @@ void Implementation::setFramesPerFile(const uint32_t i) {
|
||||
* ************************************************/
|
||||
slsDetectorDefs::runStatus Implementation::getStatus() const { return status; }
|
||||
|
||||
uint64_t Implementation::getFramesCaught() const {
|
||||
uint64_t min = -1;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
for (const auto &it : dataProcessor) {
|
||||
flagsum += it->GetStartedFlag();
|
||||
min = std::min(min, it->GetNumCompleteFramesCaught());
|
||||
std::vector<int64_t> Implementation::getFramesCaught() const {
|
||||
std::vector<int64_t> numFramesCaught(numUDPInterfaces);
|
||||
int index = 0;
|
||||
for (const auto &it : listener) {
|
||||
if (it->GetStartedFlag()) {
|
||||
numFramesCaught[index] = it->GetNumCompleteFramesCaught();
|
||||
}
|
||||
++index;
|
||||
}
|
||||
// no data processed
|
||||
if (flagsum != dataProcessor.size())
|
||||
return 0;
|
||||
|
||||
return min;
|
||||
return numFramesCaught;
|
||||
}
|
||||
|
||||
uint64_t Implementation::getCurrentFrameIndex() const {
|
||||
uint64_t max = 0;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
std::vector<int64_t> Implementation::getCurrentFrameIndex() const {
|
||||
std::vector<int64_t> frameIndex(numUDPInterfaces);
|
||||
int index = 0;
|
||||
for (const auto &it : listener) {
|
||||
flagsum += it->GetStartedFlag();
|
||||
max = std::max(max, it->GetCurrentFrameIndex());
|
||||
if (it->GetStartedFlag()) {
|
||||
frameIndex[index] = it->GetCurrentFrameIndex();
|
||||
}
|
||||
++index;
|
||||
}
|
||||
// no data processed
|
||||
if (flagsum != listener.size())
|
||||
return 0;
|
||||
return max;
|
||||
return frameIndex;
|
||||
}
|
||||
|
||||
double Implementation::getProgress() const {
|
||||
// get minimum of processed frame indices
|
||||
uint64_t currentFrameIndex = 0;
|
||||
uint32_t flagsum = 0;
|
||||
if (!activated || (!detectorDataStream[0] && !detectorDataStream[1])) {
|
||||
return 100.00;
|
||||
}
|
||||
|
||||
// if disabled, considering only 1 port
|
||||
double totalFrames = (double)(numberOfTotalFrames * listener.size());
|
||||
if (!detectorDataStream[0] || !detectorDataStream[1]) {
|
||||
totalFrames /= 2;
|
||||
}
|
||||
|
||||
double progress = 0;
|
||||
int index = 0;
|
||||
for (const auto &it : listener) {
|
||||
flagsum += it->GetStartedFlag();
|
||||
currentFrameIndex = std::max(currentFrameIndex, it->GetListenedIndex());
|
||||
if (detectorDataStream[index] && it->GetStartedFlag()) {
|
||||
progress += (it->GetListenedIndex() + 1) / totalFrames;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
// no data processed
|
||||
if (flagsum != listener.size()) {
|
||||
currentFrameIndex = -1;
|
||||
}
|
||||
|
||||
return (100.00 *
|
||||
((double)(currentFrameIndex + 1) / (double)numberOfTotalFrames));
|
||||
progress *= 100;
|
||||
return progress;
|
||||
}
|
||||
|
||||
std::vector<int64_t> Implementation::getNumMissingPackets() const {
|
||||
@ -627,7 +627,7 @@ void Implementation::stopReceiver() {
|
||||
// print summary
|
||||
uint64_t tot = 0;
|
||||
for (int i = 0; i < numUDPInterfaces; i++) {
|
||||
int nf = dataProcessor[i]->GetNumCompleteFramesCaught();
|
||||
int nf = listener[i]->GetNumCompleteFramesCaught();
|
||||
tot += nf;
|
||||
std::string mpMessage = std::to_string(mp[i]);
|
||||
if (mp[i] < 0) {
|
||||
|
@ -84,8 +84,8 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
* *
|
||||
* ************************************************/
|
||||
runStatus getStatus() const;
|
||||
uint64_t getFramesCaught() const;
|
||||
uint64_t getCurrentFrameIndex() const;
|
||||
std::vector<int64_t> getFramesCaught() const;
|
||||
std::vector<int64_t> getCurrentFrameIndex() const;
|
||||
double getProgress() const;
|
||||
std::vector<int64_t> getNumMissingPackets() const;
|
||||
void setScan(slsDetectorDefs::scanParameters s);
|
||||
|
@ -36,12 +36,22 @@ Listener::~Listener() = default;
|
||||
|
||||
uint64_t Listener::GetPacketsCaught() const { return numPacketsCaught; }
|
||||
|
||||
uint64_t Listener::GetNumCompleteFramesCaught() const {
|
||||
return numCompleteFramesCaught;
|
||||
}
|
||||
|
||||
uint64_t Listener::GetLastFrameIndexCaught() const {
|
||||
return lastCaughtFrameIndex;
|
||||
}
|
||||
|
||||
int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
|
||||
uint64_t numPackets) const {
|
||||
if (!activated) {
|
||||
return 0;
|
||||
}
|
||||
if (!(*detectorDataStream)) {
|
||||
return 0;
|
||||
}
|
||||
if (!stoppedFlag) {
|
||||
return (numPackets - numPacketsCaught);
|
||||
}
|
||||
@ -53,11 +63,11 @@ int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
|
||||
numPacketsCaught;
|
||||
}
|
||||
|
||||
bool Listener::GetStartedFlag() { return startedFlag; }
|
||||
bool Listener::GetStartedFlag() const { return startedFlag; }
|
||||
|
||||
uint64_t Listener::GetCurrentFrameIndex() { return lastCaughtFrameIndex; }
|
||||
uint64_t Listener::GetCurrentFrameIndex() const { return lastCaughtFrameIndex; }
|
||||
|
||||
uint64_t Listener::GetListenedIndex() {
|
||||
uint64_t Listener::GetListenedIndex() const {
|
||||
return lastCaughtFrameIndex - firstIndex;
|
||||
}
|
||||
|
||||
@ -67,6 +77,7 @@ void Listener::ResetParametersforNewAcquisition() {
|
||||
StopRunning();
|
||||
startedFlag = false;
|
||||
numPacketsCaught = 0;
|
||||
numCompleteFramesCaught = 0;
|
||||
firstIndex = 0;
|
||||
currentFrameIndex = 0;
|
||||
lastCaughtFrameIndex = 0;
|
||||
@ -607,6 +618,9 @@ uint32_t Listener::ListenToAnImage(char *buf) {
|
||||
// complete image
|
||||
new_header->detHeader.packetNumber = numpackets; // number of packets caught
|
||||
new_header->detHeader.frameNumber = currentFrameIndex;
|
||||
if (numpackets == pperFrame) {
|
||||
++numCompleteFramesCaught;
|
||||
}
|
||||
++currentFrameIndex;
|
||||
return imageSize;
|
||||
}
|
||||
|
@ -51,53 +51,19 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
*/
|
||||
~Listener();
|
||||
|
||||
/**
|
||||
* Get Packets caught
|
||||
* @return Packets caught
|
||||
*/
|
||||
uint64_t GetPacketsCaught() const;
|
||||
|
||||
/**
|
||||
* Get Last Frame index caught
|
||||
* @return last frame index caught
|
||||
*/
|
||||
uint64_t GetNumCompleteFramesCaught() const;
|
||||
uint64_t GetLastFrameIndexCaught() const;
|
||||
|
||||
/** Get number of missing packets, returns negative values in case to extra
|
||||
* packet */
|
||||
/** negative values in case of extra packets */
|
||||
int64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const;
|
||||
bool GetStartedFlag() const;
|
||||
uint64_t GetCurrentFrameIndex() const;
|
||||
uint64_t GetListenedIndex() 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
|
||||
*/
|
||||
void SetFifo(Fifo *f);
|
||||
|
||||
/**
|
||||
* Reset parameters for new acquisition
|
||||
*/
|
||||
void ResetParametersforNewAcquisition();
|
||||
|
||||
/**
|
||||
* Set GeneralData pointer to the one given
|
||||
* @param g address of GeneralData (Detector Data) pointer
|
||||
*/
|
||||
void SetGeneralData(GeneralData *g);
|
||||
|
||||
/**
|
||||
* Creates UDP Sockets
|
||||
*/
|
||||
void CreateUDPSockets();
|
||||
|
||||
/**
|
||||
* Shuts down and deletes UDP Sockets
|
||||
*/
|
||||
void ShutDownUDPSocket();
|
||||
|
||||
/**
|
||||
@ -116,10 +82,6 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
void SetHardCodedPosition(uint16_t r, uint16_t c);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Record First Acquisition Index
|
||||
* @param fnum frame index to record
|
||||
*/
|
||||
void RecordFirstIndex(uint64_t fnum);
|
||||
|
||||
/**
|
||||
@ -146,55 +108,25 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
*/
|
||||
uint32_t ListenToAnImage(char *buf);
|
||||
|
||||
/**
|
||||
* Print Fifo Statistics
|
||||
*/
|
||||
void PrintFifoStatistics();
|
||||
|
||||
/** type of thread */
|
||||
static const std::string TypeName;
|
||||
|
||||
/** GeneralData (Detector Data) object */
|
||||
GeneralData *generalData{nullptr};
|
||||
|
||||
/** Fifo structure */
|
||||
Fifo *fifo;
|
||||
|
||||
// individual members
|
||||
/** Detector Type */
|
||||
detectorType myDetectorType;
|
||||
|
||||
/** Receiver Status */
|
||||
std::atomic<runStatus> *status;
|
||||
|
||||
/** UDP Socket - Detector to Receiver */
|
||||
std::unique_ptr<sls::UdpRxSocket> udpSocket{nullptr};
|
||||
|
||||
/** UDP Port Number */
|
||||
uint32_t *udpPortNumber;
|
||||
|
||||
/** ethernet interface */
|
||||
std::string *eth;
|
||||
|
||||
/** UDP Socket Buffer Size */
|
||||
int *udpSocketBufferSize;
|
||||
|
||||
/** actual UDP Socket Buffer Size (double due to kernel bookkeeping) */
|
||||
/** double due to kernel bookkeeping */
|
||||
int *actualUDPSocketBufferSize;
|
||||
|
||||
/** frames per file */
|
||||
uint32_t *framesPerFile;
|
||||
|
||||
/** frame discard policy */
|
||||
frameDiscardPolicy *frameDiscardMode;
|
||||
|
||||
/** Activated/Deactivated */
|
||||
bool *activated;
|
||||
|
||||
/** detector data stream */
|
||||
bool *detectorDataStream;
|
||||
|
||||
/** Silent Mode */
|
||||
bool *silentMode;
|
||||
|
||||
/** row hardcoded as 1D or 2d,
|
||||
@ -209,15 +141,12 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
// acquisition start
|
||||
/** Aquisition Started flag */
|
||||
std::atomic<bool> startedFlag{false};
|
||||
|
||||
/** Frame Number of First Frame */
|
||||
uint64_t firstIndex{0};
|
||||
|
||||
// for acquisition summary
|
||||
/** Number of complete Packets caught */
|
||||
std::atomic<uint64_t> numPacketsCaught{0};
|
||||
|
||||
/** Last Frame Index caught from udp network */
|
||||
std::atomic<uint64_t> numCompleteFramesCaught{0};
|
||||
std::atomic<uint64_t> lastCaughtFrameIndex{0};
|
||||
|
||||
// parameters to acquire image
|
||||
@ -225,25 +154,16 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* ( always check startedFlag for validity first)
|
||||
*/
|
||||
uint64_t currentFrameIndex{0};
|
||||
|
||||
/** True if there is a packet carry over from previous Image */
|
||||
bool carryOverFlag{false};
|
||||
|
||||
/** Carry over packet buffer */
|
||||
std::unique_ptr<char[]> carryOverPacket;
|
||||
|
||||
/** Listening buffer for one packet - might be removed when we can peek and
|
||||
* eiger fnum is in header */
|
||||
std::unique_ptr<char[]> listeningPacket;
|
||||
|
||||
/** if the udp socket is connected */
|
||||
std::atomic<bool> udpSocketAlive{false};
|
||||
|
||||
// for print progress during acquisition
|
||||
/** number of packets for statistic */
|
||||
// for print progress during acquisition*/
|
||||
uint32_t numPacketsStatistic{0};
|
||||
|
||||
/** number of images for statistic */
|
||||
uint32_t numFramesStatistic{0};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user