mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
rxr: missing packets, stopacquistion lets rxr know to calculate missing packets from last frame caught
This commit is contained in:
@ -679,6 +679,7 @@ class CmdProxy {
|
||||
{"rx_status", &CmdProxy::rx_status},
|
||||
{"status", &CmdProxy::status},
|
||||
{"rx_framescaught", &CmdProxy::rx_framescaught},
|
||||
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
|
||||
{"startingfnum", &CmdProxy::startingfnum},
|
||||
{"trigger", &CmdProxy::trigger},
|
||||
|
||||
@ -1288,6 +1289,9 @@ class CmdProxy {
|
||||
GET_COMMAND(rx_framescaught, getFramesCaught,
|
||||
"\n\tNumber of frames caught by receiver.");
|
||||
|
||||
GET_COMMAND(rx_missingpackets, getNumMissingPackets,
|
||||
"\n\tNumber of missing packets for each port in receiver.");
|
||||
|
||||
INTEGER_COMMAND(startingfnum, getStartingFrameNumber, setStartingFrameNumber, std::stoull,
|
||||
"[n_value]\n\t[Eiger[Jungfrau] Starting frame number for next acquisition.");
|
||||
|
||||
|
@ -296,6 +296,8 @@ class Detector {
|
||||
|
||||
Result<int64_t> getFramesCaught(Positions pos = {}) const;
|
||||
|
||||
Result<std::vector<uint64_t>> getNumMissingPackets(Positions pos = {}) const;
|
||||
|
||||
/** [Eiger][Jungfrau] */
|
||||
Result<uint64_t> getStartingFrameNumber(Positions pos = {}) const;
|
||||
|
||||
|
@ -178,6 +178,9 @@ struct sharedSlsDetector {
|
||||
|
||||
/** num udp interfaces */
|
||||
int numUDPInterfaces;
|
||||
|
||||
/** stopped flag to inform rxr */
|
||||
bool stoppedFlag;
|
||||
};
|
||||
|
||||
class slsDetector : public virtual slsDetectorDefs {
|
||||
@ -1611,6 +1614,9 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
int64_t getFramesCaughtByReceiver() const;
|
||||
|
||||
/** Gets number of missing packets */
|
||||
std::vector<uint64_t> getNumMissingPackets() const;
|
||||
|
||||
/**
|
||||
* Gets the current frame index of receiver
|
||||
* @returns current frame index of receiver
|
||||
|
@ -405,6 +405,10 @@ Result<int64_t> Detector::getFramesCaught(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos);
|
||||
}
|
||||
|
||||
Result<std::vector<uint64_t>> Detector::getNumMissingPackets(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getNumMissingPackets, pos);
|
||||
}
|
||||
|
||||
Result<uint64_t> Detector::getStartingFrameNumber(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getStartingFrameNumber, pos);
|
||||
}
|
||||
|
@ -385,6 +385,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
shm()->rxFileOverWrite = true;
|
||||
shm()->rxDbitOffset = 0;
|
||||
shm()->numUDPInterfaces = 1;
|
||||
shm()->stoppedFlag = false;
|
||||
|
||||
// get the detector parameters based on type
|
||||
detParameters parameters{type};
|
||||
@ -1117,6 +1118,7 @@ void slsDetector::prepareAcquisition() {
|
||||
|
||||
void slsDetector::startAcquisition() {
|
||||
FILE_LOG(logDEBUG1) << "Starting Acquisition";
|
||||
shm()->stoppedFlag = false;
|
||||
sendToDetector(F_START_ACQUISITION);
|
||||
FILE_LOG(logDEBUG1) << "Starting Acquisition successful";
|
||||
}
|
||||
@ -1130,6 +1132,7 @@ void slsDetector::stopAcquisition() {
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Stopping Acquisition";
|
||||
sendToDetectorStop(F_STOP_ACQUISITION);
|
||||
shm()->stoppedFlag = true;
|
||||
FILE_LOG(logDEBUG1) << "Stopping Acquisition successful";
|
||||
// if rxr streaming and acquisition finished, restream dummy stop packet
|
||||
if ((shm()->rxUpstream) && (s == IDLE) && (r == IDLE)) {
|
||||
@ -1145,6 +1148,7 @@ void slsDetector::sendSoftwareTrigger() {
|
||||
|
||||
void slsDetector::startAndReadAll() {
|
||||
FILE_LOG(logDEBUG1) << "Starting and reading all frames";
|
||||
shm()->stoppedFlag = false;
|
||||
sendToDetector(F_START_AND_READ_ALL);
|
||||
FILE_LOG(logDEBUG1) << "Detector successfully finished acquisition";
|
||||
}
|
||||
@ -3435,7 +3439,8 @@ void slsDetector::startReceiver() {
|
||||
void slsDetector::stopReceiver() {
|
||||
FILE_LOG(logDEBUG1) << "Stopping Receiver";
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_STOP_RECEIVER);
|
||||
int arg = static_cast<int>(shm()->stoppedFlag);
|
||||
sendToReceiver(F_STOP_RECEIVER, arg, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3459,6 +3464,33 @@ int64_t slsDetector::getFramesCaughtByReceiver() const {
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::vector<uint64_t> slsDetector::getNumMissingPackets() const {
|
||||
FILE_LOG(logDEBUG1) << "Getting num missing packets";
|
||||
if (shm()->useReceiverFlag) {
|
||||
int fnum = F_GET_NUM_MISSING_PACKETS;
|
||||
int ret = FAIL;
|
||||
auto client = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
client.Send(&fnum, sizeof(fnum));
|
||||
client.Receive(&ret, sizeof(ret));
|
||||
if (ret == FAIL) {
|
||||
char mess[MAX_STR_LENGTH]{};
|
||||
client.Receive(mess, MAX_STR_LENGTH);
|
||||
throw RuntimeError("Receiver " + std::to_string(detId) +
|
||||
" returned error: " + std::string(mess));
|
||||
} else {
|
||||
int nports = -1;
|
||||
client.Receive(&nports, sizeof(nports));
|
||||
uint64_t mp[nports];
|
||||
memset(mp, 0, sizeof(mp));
|
||||
client.Receive(mp, sizeof(mp));
|
||||
std::vector<uint64_t> retval(mp, mp + nports);
|
||||
FILE_LOG(logDEBUG1) << "Missing packets of Receiver" << detId << ": " << sls::ToString(retval);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
throw RuntimeError("No receiver to get missing packets.");
|
||||
}
|
||||
|
||||
uint64_t slsDetector::getReceiverCurrentFrameIndex() const {
|
||||
uint64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver";
|
||||
|
@ -9,6 +9,12 @@
|
||||
auto GET = slsDetectorDefs::GET_ACTION;
|
||||
auto PUT = slsDetectorDefs::PUT_ACTION;
|
||||
|
||||
|
||||
|
||||
TEST_CASE("rx_missingpackets", "[.cmd]") {
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_missingpackets", GET));
|
||||
}
|
||||
|
||||
TEST_CASE("burstmode", "[.cmd][.gotthard2]") {
|
||||
if (test::type == slsDetectorDefs::GOTTHARD2) {
|
||||
REQUIRE_NOTHROW(multiSlsDetectorClient("burstmode 0", PUT));
|
||||
|
Reference in New Issue
Block a user