Merge pull request #339 from slsdetectorgroup/fixes

Fixes
This commit is contained in:
Dhanya Thattil 2022-01-06 15:51:33 +01:00 committed by GitHub
commit f9eed62a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 88 additions and 51 deletions

View File

@ -208,6 +208,9 @@ if (NOT TARGET libzmq)
endif() endif()
endif() endif()
get_target_property(VAR libzmq INTERFACE_INCLUDE_DIRECTORIES)
message(STATUS "zmq: ${VAR}")
if (SLS_USE_TESTS) if (SLS_USE_TESTS)
enable_testing() enable_testing()
add_subdirectory(tests) add_subdirectory(tests)

View File

@ -19,6 +19,7 @@ This document describes the differences between v6.1.0 and v6.0.0.
1. New or Changed Features 1. New or Changed Features
========================== ==========================
- Fixed minor warnings (will fix commandline print of excess packets for missing packets)
2. Resolved Issues 2. Resolved Issues

View File

@ -588,7 +588,9 @@ class Detector {
Result<int64_t> getFramesCaught(Positions pos = {}) const; Result<int64_t> getFramesCaught(Positions pos = {}) const;
/** Gets the number of missing packets for each port in receiver. */ /** Gets the number of missing packets for each port in receiver.
* Troubleshoot: If they are large numbers, convert it to signed to get
* number of access packets received */
Result<std::vector<uint64_t>> Result<std::vector<uint64_t>>
getNumMissingPackets(Positions pos = {}) const; getNumMissingPackets(Positions pos = {}) const;

View File

@ -1,3 +1,4 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
#include "CmdProxy.h" #include "CmdProxy.h"
@ -1273,6 +1274,40 @@ std::string CmdProxy::DetectorStatus(int action) {
return os.str(); return os.str();
} }
std::string CmdProxy::RxMissingPackets(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "Number of missing packets for each port in receiver. If "
"negative, they are packets in excess. "
<< '\n';
} else if (action == defs::GET_ACTION) {
if (!args.empty()) {
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");
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::Scan(int action) { std::string CmdProxy::Scan(int action) {
std::ostringstream os; std::ostringstream os;
os << cmd << ' '; os << cmd << ' ';

View File

@ -859,7 +859,7 @@ class CmdProxy {
{"rx_status", &CmdProxy::ReceiverStatus}, {"rx_status", &CmdProxy::ReceiverStatus},
{"status", &CmdProxy::DetectorStatus}, {"status", &CmdProxy::DetectorStatus},
{"rx_framescaught", &CmdProxy::rx_framescaught}, {"rx_framescaught", &CmdProxy::rx_framescaught},
{"rx_missingpackets", &CmdProxy::rx_missingpackets}, {"rx_missingpackets", &CmdProxy::RxMissingPackets},
{"nextframenumber", &CmdProxy::nextframenumber}, {"nextframenumber", &CmdProxy::nextframenumber},
{"trigger", &CmdProxy::Trigger}, {"trigger", &CmdProxy::Trigger},
{"scan", &CmdProxy::Scan}, {"scan", &CmdProxy::Scan},
@ -1128,6 +1128,7 @@ class CmdProxy {
/* acquisition */ /* acquisition */
std::string ReceiverStatus(int action); std::string ReceiverStatus(int action);
std::string DetectorStatus(int action); std::string DetectorStatus(int action);
std::string RxMissingPackets(int action);
std::string Scan(int action); std::string Scan(int action);
std::string Trigger(int action); std::string Trigger(int action);
/* Network Configuration (Detector<->Receiver) */ /* Network Configuration (Detector<->Receiver) */

View File

@ -34,15 +34,14 @@ DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
uint32_t *streamingTimerInMs, uint32_t *streamingTimerInMs,
uint32_t *streamingStartFnum, bool *framePadding, uint32_t *streamingStartFnum, bool *framePadding,
std::vector<int> *ctbDbitList, int *ctbDbitOffset, std::vector<int> *ctbDbitList, int *ctbDbitOffset,
int *ctbAnalogDataBytes, std::mutex *hdf5Lib) int *ctbAnalogDataBytes)
: ThreadObject(index, typeName_), fifo_(fifo), detectorType_(detectorType), : ThreadObject(index, typeName_), fifo_(fifo), detectorType_(detectorType),
dataStreamEnable_(dataStreamEnable), activated_(activated), dataStreamEnable_(dataStreamEnable), activated_(activated),
streamingFrequency_(streamingFrequency), streamingFrequency_(streamingFrequency),
streamingTimerInMs_(streamingTimerInMs), streamingTimerInMs_(streamingTimerInMs),
streamingStartFnum_(streamingStartFnum), framePadding_(framePadding), streamingStartFnum_(streamingStartFnum), framePadding_(framePadding),
ctbDbitList_(ctbDbitList), ctbDbitOffset_(ctbDbitOffset), ctbDbitList_(ctbDbitList), ctbDbitOffset_(ctbDbitOffset),
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false), ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) {
hdf5Lib_(hdf5Lib) {
LOG(logDEBUG) << "DataProcessor " << index << " created"; LOG(logDEBUG) << "DataProcessor " << index << " created";
@ -124,16 +123,16 @@ void DataProcessor::DeleteFiles() {
void DataProcessor::SetupFileWriter(const bool filewriteEnable, void DataProcessor::SetupFileWriter(const bool filewriteEnable,
const bool masterFilewriteEnable, const bool masterFilewriteEnable,
const fileFormat fileFormatType, const fileFormat fileFormatType,
const int modulePos) { const int modulePos, std::mutex *hdf5Lib) {
DeleteFiles(); DeleteFiles();
if (filewriteEnable) { if (filewriteEnable) {
switch (fileFormatType) { switch (fileFormatType) {
#ifdef HDF5C #ifdef HDF5C
case HDF5: case HDF5:
dataFile_ = new HDF5DataFile(index, hdf5Lib_); dataFile_ = new HDF5DataFile(index, hdf5Lib);
if (modulePos == 0 && index == 0) { if (modulePos == 0 && index == 0) {
if (masterFilewriteEnable) { if (masterFilewriteEnable) {
masterFile_ = new HDF5MasterFile(hdf5Lib_); masterFile_ = new HDF5MasterFile(hdf5Lib);
} }
} }
break; break;
@ -208,12 +207,13 @@ void DataProcessor::CreateVirtualFile(
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode, const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
const int modulePos, const int numUnitsPerReadout, const int modulePos, const int numUnitsPerReadout,
const uint32_t maxFramesPerFile, const uint64_t numImages, const uint32_t maxFramesPerFile, const uint64_t numImages,
const uint32_t dynamicRange, const int numModX, const int numModY) { const uint32_t dynamicRange, const int numModX, const int numModY,
std::mutex *hdf5Lib) {
if (virtualFile_) { if (virtualFile_) {
delete virtualFile_; delete virtualFile_;
} }
virtualFile_ = new HDF5VirtualFile(hdf5Lib_); virtualFile_ = new HDF5VirtualFile(hdf5Lib);
uint64_t numImagesProcessed = GetProcessedIndex() + 1; uint64_t numImagesProcessed = GetProcessedIndex() + 1;
// maxframesperfile = 0 for infinite files // maxframesperfile = 0 for infinite files

View File

@ -32,7 +32,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
uint32_t *streamingFrequency, uint32_t *streamingTimerInMs, uint32_t *streamingFrequency, uint32_t *streamingTimerInMs,
uint32_t *streamingStartFnum, bool *framePadding, uint32_t *streamingStartFnum, bool *framePadding,
std::vector<int> *ctbDbitList, int *ctbDbitOffset, std::vector<int> *ctbDbitList, int *ctbDbitOffset,
int *ctbAnalogDataBytes, std::mutex *hdf5Lib); int *ctbAnalogDataBytes);
~DataProcessor() override; ~DataProcessor() override;
@ -52,7 +52,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
void DeleteFiles(); void DeleteFiles();
void SetupFileWriter(const bool filewriteEnable, void SetupFileWriter(const bool filewriteEnable,
const bool masterFilewriteEnable, const bool masterFilewriteEnable,
const fileFormat fileFormatType, const int modulePos); const fileFormat fileFormatType, const int modulePos,
std::mutex *hdf5Lib);
void CreateFirstFiles(MasterAttributes *attr, const std::string filePath, void CreateFirstFiles(MasterAttributes *attr, const std::string filePath,
const std::string fileNamePrefix, const std::string fileNamePrefix,
@ -73,7 +74,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
const uint32_t maxFramesPerFile, const uint32_t maxFramesPerFile,
const uint64_t numImages, const uint64_t numImages,
const uint32_t dynamicRange, const int numModX, const uint32_t dynamicRange, const int numModX,
const int numModY); const int numModY, std::mutex *hdf5Lib);
void LinkDataInMasterFile(const bool silentMode); void LinkDataInMasterFile(const bool silentMode);
#endif #endif
void UpdateMasterFile(bool silentMode); void UpdateMasterFile(bool silentMode);
@ -188,7 +189,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
File *dataFile_{nullptr}; File *dataFile_{nullptr};
File *masterFile_{nullptr}; File *masterFile_{nullptr};
std::mutex *hdf5Lib_;
#ifdef HDF5C #ifdef HDF5C
File *virtualFile_{nullptr}; File *virtualFile_{nullptr};
#endif #endif

View File

@ -167,14 +167,14 @@ void Implementation::setDetectorType(const detectorType d) {
auto fifo_ptr = fifo[i].get(); auto fifo_ptr = fifo[i].get();
listener.push_back(sls::make_unique<Listener>( listener.push_back(sls::make_unique<Listener>(
i, detType, fifo_ptr, &status, &udpPortNum[i], &eth[i], i, detType, fifo_ptr, &status, &udpPortNum[i], &eth[i],
&numberOfTotalFrames, &udpSocketBufferSize, &udpSocketBufferSize, &actualUDPSocketBufferSize,
&actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode, &framesPerFile, &frameDiscardMode, &activated,
&activated, &detectorDataStream[i], &silentMode)); &detectorDataStream[i], &silentMode));
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, detType, fifo_ptr, &activated, &dataStreamEnable, i, detType, fifo_ptr, &activated, &dataStreamEnable,
&streamingFrequency, &streamingTimerInMs, &streamingStartFnum, &streamingFrequency, &streamingTimerInMs, &streamingStartFnum,
&framePadding, &ctbDbitList, &ctbDbitOffset, &framePadding, &ctbDbitList, &ctbDbitOffset,
&ctbAnalogDataBytes, &hdf5Lib)); &ctbAnalogDataBytes));
} catch (...) { } catch (...) {
listener.clear(); listener.clear();
dataProcessor.clear(); dataProcessor.clear();
@ -237,7 +237,7 @@ void Implementation::setModulePositionId(const int id) {
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable, it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
fileFormatType, modulePos); fileFormatType, modulePos, &hdf5Lib);
assert(numMods[1] != 0); assert(numMods[1] != 0);
for (unsigned int i = 0; i < listener.size(); ++i) { for (unsigned int i = 0; i < listener.size(); ++i) {
uint16_t row = 0, col = 0; uint16_t row = 0, col = 0;
@ -345,7 +345,7 @@ void Implementation::setFileFormat(const fileFormat f) {
} }
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable, it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
fileFormatType, modulePos); fileFormatType, modulePos, &hdf5Lib);
} }
LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType); LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
@ -382,7 +382,7 @@ void Implementation::setFileWriteEnable(const bool b) {
fileWriteEnable = b; fileWriteEnable = b;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable, it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
fileFormatType, modulePos); fileFormatType, modulePos, &hdf5Lib);
} }
LOG(logINFO) << "File Write Enable: " LOG(logINFO) << "File Write Enable: "
<< (fileWriteEnable ? "enabled" : "disabled"); << (fileWriteEnable ? "enabled" : "disabled");
@ -397,7 +397,7 @@ void Implementation::setMasterFileWriteEnable(const bool b) {
masterFileWriteEnable = b; masterFileWriteEnable = b;
for (const auto &it : dataProcessor) for (const auto &it : dataProcessor)
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable, it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
fileFormatType, modulePos); fileFormatType, modulePos, &hdf5Lib);
} }
LOG(logINFO) << "Master File Write Enable: " LOG(logINFO) << "Master File Write Enable: "
<< (masterFileWriteEnable ? "enabled" : "disabled"); << (masterFileWriteEnable ? "enabled" : "disabled");
@ -473,9 +473,9 @@ double Implementation::getProgress() const {
((double)(currentFrameIndex + 1) / (double)numberOfTotalFrames)); ((double)(currentFrameIndex + 1) / (double)numberOfTotalFrames));
} }
std::vector<uint64_t> Implementation::getNumMissingPackets() const { std::vector<int64_t> Implementation::getNumMissingPackets() const {
std::vector<uint64_t> mp(numThreads); std::vector<int64_t> mp(numThreads);
for (int i = 0; i < numThreads; i++) { for (int i = 0; i < numThreads; ++i) {
int np = generalData->packetsPerFrame; int np = generalData->packetsPerFrame;
uint64_t totnp = np; uint64_t totnp = np;
// ReadNRows // ReadNRows
@ -566,7 +566,7 @@ void Implementation::stopReceiver() {
dataProcessor[0]->CreateVirtualFile( dataProcessor[0]->CreateVirtualFile(
filePath, fileName, fileIndex, overwriteEnable, silentMode, filePath, fileName, fileIndex, overwriteEnable, silentMode,
modulePos, numThreads, framesPerFile, numberOfTotalFrames, modulePos, numThreads, framesPerFile, numberOfTotalFrames,
dynamicRange, numMods[X], numMods[Y]); dynamicRange, numMods[X], numMods[Y], &hdf5Lib);
} }
// link file in master // link file in master
dataProcessor[0]->LinkDataInMasterFile(silentMode); dataProcessor[0]->LinkDataInMasterFile(silentMode);
@ -595,18 +595,19 @@ void Implementation::stopReceiver() {
LOG(logINFO) << "Status: " << sls::ToString(status); LOG(logINFO) << "Status: " << sls::ToString(status);
{ // statistics { // statistics
std::vector<uint64_t> mp = getNumMissingPackets(); auto mp = getNumMissingPackets();
// print summary
uint64_t tot = 0; uint64_t tot = 0;
for (int i = 0; i < numThreads; i++) { for (int i = 0; i < numThreads; i++) {
int nf = dataProcessor[i]->GetNumCompleteFramesCaught(); int nf = dataProcessor[i]->GetNumCompleteFramesCaught();
tot += nf; tot += nf;
std::string mpMessage = std::to_string((int64_t)mp[i]); std::string mpMessage = std::to_string(mp[i]);
if ((int64_t)mp[i] < 0) { if (mp[i] < 0) {
mpMessage = mpMessage =
std::to_string(abs(mp[i])) + std::string(" (Extra)"); std::to_string(std::abs(mp[i])) + std::string(" (Extra)");
} }
TLogLevel lev = (((int64_t)mp[i]) > 0) ? logINFORED : logINFOGREEN; TLogLevel lev = ((mp[i]) > 0) ? logINFORED : logINFOGREEN;
LOG(lev) << LOG(lev) <<
// udp port number could be the second if selected interface is // udp port number could be the second if selected interface is
// 2 for jungfrau // 2 for jungfrau
@ -880,17 +881,16 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
auto fifo_ptr = fifo[i].get(); auto fifo_ptr = fifo[i].get();
listener.push_back(sls::make_unique<Listener>( listener.push_back(sls::make_unique<Listener>(
i, detType, fifo_ptr, &status, &udpPortNum[i], &eth[i], i, detType, fifo_ptr, &status, &udpPortNum[i], &eth[i],
&numberOfTotalFrames, &udpSocketBufferSize, &udpSocketBufferSize, &actualUDPSocketBufferSize,
&actualUDPSocketBufferSize, &framesPerFile, &framesPerFile, &frameDiscardMode, &activated,
&frameDiscardMode, &activated, &detectorDataStream[i], &detectorDataStream[i], &silentMode));
&silentMode));
listener[i]->SetGeneralData(generalData); listener[i]->SetGeneralData(generalData);
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, detType, fifo_ptr, &activated, &dataStreamEnable, i, detType, fifo_ptr, &activated, &dataStreamEnable,
&streamingFrequency, &streamingTimerInMs, &streamingFrequency, &streamingTimerInMs,
&streamingStartFnum, &framePadding, &ctbDbitList, &streamingStartFnum, &framePadding, &ctbDbitList,
&ctbDbitOffset, &ctbAnalogDataBytes, &hdf5Lib)); &ctbDbitOffset, &ctbAnalogDataBytes));
dataProcessor[i]->SetGeneralData(generalData); dataProcessor[i]->SetGeneralData(generalData);
} catch (...) { } catch (...) {
listener.clear(); listener.clear();

View File

@ -83,7 +83,7 @@ class Implementation : private virtual slsDetectorDefs {
uint64_t getFramesCaught() const; uint64_t getFramesCaught() const;
uint64_t getAcquisitionIndex() const; uint64_t getAcquisitionIndex() const;
double getProgress() const; double getProgress() const;
std::vector<uint64_t> getNumMissingPackets() const; std::vector<int64_t> getNumMissingPackets() const;
void setScan(slsDetectorDefs::scanParameters s); void setScan(slsDetectorDefs::scanParameters s);
void startReceiver(); void startReceiver();
void setStoppedFlag(bool stopped); void setStoppedFlag(bool stopped);

View File

@ -23,10 +23,10 @@ const std::string Listener::TypeName = "Listener";
Listener::Listener(int ind, detectorType dtype, Fifo *f, Listener::Listener(int ind, detectorType dtype, Fifo *f,
std::atomic<runStatus> *s, uint32_t *portno, std::string *e, std::atomic<runStatus> *s, uint32_t *portno, std::string *e,
uint64_t *nf, int *us, int *as, uint32_t *fpf, int *us, int *as, uint32_t *fpf, frameDiscardPolicy *fdp,
frameDiscardPolicy *fdp, bool *act, bool *detds, bool *sm) bool *act, bool *detds, bool *sm)
: ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype), status(s), : ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype), status(s),
udpPortNumber(portno), eth(e), numImages(nf), udpSocketBufferSize(us), udpPortNumber(portno), eth(e), udpSocketBufferSize(us),
actualUDPSocketBufferSize(as), framesPerFile(fpf), frameDiscardMode(fdp), actualUDPSocketBufferSize(as), framesPerFile(fpf), frameDiscardMode(fdp),
activated(act), detectorDataStream(detds), silentMode(sm) { activated(act), detectorDataStream(detds), silentMode(sm) {
LOG(logDEBUG) << "Listener " << ind << " created"; LOG(logDEBUG) << "Listener " << ind << " created";
@ -40,7 +40,7 @@ uint64_t Listener::GetLastFrameIndexCaught() const {
return lastCaughtFrameIndex; return lastCaughtFrameIndex;
} }
uint64_t Listener::GetNumMissingPacket(bool stoppedFlag, int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
uint64_t numPackets) const { uint64_t numPackets) const {
if (!stoppedFlag) { if (!stoppedFlag) {
return (numPackets - numPacketsCaught); return (numPackets - numPacketsCaught);

View File

@ -32,7 +32,6 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
* @param s pointer to receiver status * @param s pointer to receiver status
* @param portno pointer to udp port number * @param portno pointer to udp port number
* @param e ethernet interface * @param e ethernet interface
* @param nf pointer to number of images to catch
* @param dr pointer to dynamic range * @param dr pointer to dynamic range
* @param us pointer to udp socket buffer size * @param us pointer to udp socket buffer size
* @param as pointer to actual udp socket buffer size * @param as pointer to actual udp socket buffer size
@ -43,9 +42,8 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
* @param sm pointer to silent mode * @param sm pointer to silent mode
*/ */
Listener(int ind, detectorType dtype, Fifo *f, std::atomic<runStatus> *s, Listener(int ind, detectorType dtype, Fifo *f, std::atomic<runStatus> *s,
uint32_t *portno, std::string *e, uint64_t *nf, int *us, int *as, uint32_t *portno, std::string *e, int *us, int *as, uint32_t *fpf,
uint32_t *fpf, frameDiscardPolicy *fdp, bool *act, bool *detds, frameDiscardPolicy *fdp, bool *act, bool *detds, bool *sm);
bool *sm);
/** /**
* Destructor * Destructor
@ -65,8 +63,8 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
*/ */
uint64_t GetLastFrameIndexCaught() const; uint64_t GetLastFrameIndexCaught() const;
/** Get number of missing packets */ /** Get number of missing packets, returns negative values in case to extra packet */
uint64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const; int64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const;
/** /**
* Set Fifo pointer to the one given * Set Fifo pointer to the one given
@ -171,9 +169,6 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
/** ethernet interface */ /** ethernet interface */
std::string *eth; std::string *eth;
/** Number of Images to catch */
uint64_t *numImages;
/** UDP Socket Buffer Size */ /** UDP Socket Buffer Size */
int *udpSocketBufferSize; int *udpSocketBufferSize;