mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 19:30:03 +02:00
commit
f9eed62a45
@ -208,6 +208,9 @@ if (NOT TARGET libzmq)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
get_target_property(VAR libzmq INTERFACE_INCLUDE_DIRECTORIES)
|
||||
message(STATUS "zmq: ${VAR}")
|
||||
|
||||
if (SLS_USE_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
|
@ -19,6 +19,7 @@ This document describes the differences between v6.1.0 and v6.0.0.
|
||||
1. New or Changed Features
|
||||
==========================
|
||||
|
||||
- Fixed minor warnings (will fix commandline print of excess packets for missing packets)
|
||||
|
||||
|
||||
2. Resolved Issues
|
||||
|
@ -588,7 +588,9 @@ class Detector {
|
||||
|
||||
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>>
|
||||
getNumMissingPackets(Positions pos = {}) const;
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "CmdProxy.h"
|
||||
@ -1273,6 +1274,40 @@ std::string CmdProxy::DetectorStatus(int action) {
|
||||
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::ostringstream os;
|
||||
os << cmd << ' ';
|
||||
|
@ -859,7 +859,7 @@ class CmdProxy {
|
||||
{"rx_status", &CmdProxy::ReceiverStatus},
|
||||
{"status", &CmdProxy::DetectorStatus},
|
||||
{"rx_framescaught", &CmdProxy::rx_framescaught},
|
||||
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
|
||||
{"rx_missingpackets", &CmdProxy::RxMissingPackets},
|
||||
{"nextframenumber", &CmdProxy::nextframenumber},
|
||||
{"trigger", &CmdProxy::Trigger},
|
||||
{"scan", &CmdProxy::Scan},
|
||||
@ -1128,6 +1128,7 @@ class CmdProxy {
|
||||
/* acquisition */
|
||||
std::string ReceiverStatus(int action);
|
||||
std::string DetectorStatus(int action);
|
||||
std::string RxMissingPackets(int action);
|
||||
std::string Scan(int action);
|
||||
std::string Trigger(int action);
|
||||
/* Network Configuration (Detector<->Receiver) */
|
||||
|
@ -34,15 +34,14 @@ DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
|
||||
uint32_t *streamingTimerInMs,
|
||||
uint32_t *streamingStartFnum, bool *framePadding,
|
||||
std::vector<int> *ctbDbitList, int *ctbDbitOffset,
|
||||
int *ctbAnalogDataBytes, std::mutex *hdf5Lib)
|
||||
int *ctbAnalogDataBytes)
|
||||
: ThreadObject(index, typeName_), fifo_(fifo), detectorType_(detectorType),
|
||||
dataStreamEnable_(dataStreamEnable), activated_(activated),
|
||||
streamingFrequency_(streamingFrequency),
|
||||
streamingTimerInMs_(streamingTimerInMs),
|
||||
streamingStartFnum_(streamingStartFnum), framePadding_(framePadding),
|
||||
ctbDbitList_(ctbDbitList), ctbDbitOffset_(ctbDbitOffset),
|
||||
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false),
|
||||
hdf5Lib_(hdf5Lib) {
|
||||
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) {
|
||||
|
||||
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
||||
|
||||
@ -124,16 +123,16 @@ void DataProcessor::DeleteFiles() {
|
||||
void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
||||
const bool masterFilewriteEnable,
|
||||
const fileFormat fileFormatType,
|
||||
const int modulePos) {
|
||||
const int modulePos, std::mutex *hdf5Lib) {
|
||||
DeleteFiles();
|
||||
if (filewriteEnable) {
|
||||
switch (fileFormatType) {
|
||||
#ifdef HDF5C
|
||||
case HDF5:
|
||||
dataFile_ = new HDF5DataFile(index, hdf5Lib_);
|
||||
dataFile_ = new HDF5DataFile(index, hdf5Lib);
|
||||
if (modulePos == 0 && index == 0) {
|
||||
if (masterFilewriteEnable) {
|
||||
masterFile_ = new HDF5MasterFile(hdf5Lib_);
|
||||
masterFile_ = new HDF5MasterFile(hdf5Lib);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -208,12 +207,13 @@ void DataProcessor::CreateVirtualFile(
|
||||
const uint64_t fileIndex, const bool overWriteEnable, const bool silentMode,
|
||||
const int modulePos, const int numUnitsPerReadout,
|
||||
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_) {
|
||||
delete virtualFile_;
|
||||
}
|
||||
virtualFile_ = new HDF5VirtualFile(hdf5Lib_);
|
||||
virtualFile_ = new HDF5VirtualFile(hdf5Lib);
|
||||
|
||||
uint64_t numImagesProcessed = GetProcessedIndex() + 1;
|
||||
// maxframesperfile = 0 for infinite files
|
||||
|
@ -32,7 +32,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
uint32_t *streamingFrequency, uint32_t *streamingTimerInMs,
|
||||
uint32_t *streamingStartFnum, bool *framePadding,
|
||||
std::vector<int> *ctbDbitList, int *ctbDbitOffset,
|
||||
int *ctbAnalogDataBytes, std::mutex *hdf5Lib);
|
||||
int *ctbAnalogDataBytes);
|
||||
|
||||
~DataProcessor() override;
|
||||
|
||||
@ -52,7 +52,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
void DeleteFiles();
|
||||
void SetupFileWriter(const bool filewriteEnable,
|
||||
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,
|
||||
const std::string fileNamePrefix,
|
||||
@ -73,7 +74,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
const uint32_t maxFramesPerFile,
|
||||
const uint64_t numImages,
|
||||
const uint32_t dynamicRange, const int numModX,
|
||||
const int numModY);
|
||||
const int numModY, std::mutex *hdf5Lib);
|
||||
void LinkDataInMasterFile(const bool silentMode);
|
||||
#endif
|
||||
void UpdateMasterFile(bool silentMode);
|
||||
@ -188,7 +189,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
||||
|
||||
File *dataFile_{nullptr};
|
||||
File *masterFile_{nullptr};
|
||||
std::mutex *hdf5Lib_;
|
||||
#ifdef HDF5C
|
||||
File *virtualFile_{nullptr};
|
||||
#endif
|
||||
|
@ -167,14 +167,14 @@ void Implementation::setDetectorType(const detectorType d) {
|
||||
auto fifo_ptr = fifo[i].get();
|
||||
listener.push_back(sls::make_unique<Listener>(
|
||||
i, detType, fifo_ptr, &status, &udpPortNum[i], ð[i],
|
||||
&numberOfTotalFrames, &udpSocketBufferSize,
|
||||
&actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode,
|
||||
&activated, &detectorDataStream[i], &silentMode));
|
||||
&udpSocketBufferSize, &actualUDPSocketBufferSize,
|
||||
&framesPerFile, &frameDiscardMode, &activated,
|
||||
&detectorDataStream[i], &silentMode));
|
||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(
|
||||
i, detType, fifo_ptr, &activated, &dataStreamEnable,
|
||||
&streamingFrequency, &streamingTimerInMs, &streamingStartFnum,
|
||||
&framePadding, &ctbDbitList, &ctbDbitOffset,
|
||||
&ctbAnalogDataBytes, &hdf5Lib));
|
||||
&ctbAnalogDataBytes));
|
||||
} catch (...) {
|
||||
listener.clear();
|
||||
dataProcessor.clear();
|
||||
@ -237,7 +237,7 @@ void Implementation::setModulePositionId(const int id) {
|
||||
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
||||
fileFormatType, modulePos);
|
||||
fileFormatType, modulePos, &hdf5Lib);
|
||||
assert(numMods[1] != 0);
|
||||
for (unsigned int i = 0; i < listener.size(); ++i) {
|
||||
uint16_t row = 0, col = 0;
|
||||
@ -345,7 +345,7 @@ void Implementation::setFileFormat(const fileFormat f) {
|
||||
}
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
||||
fileFormatType, modulePos);
|
||||
fileFormatType, modulePos, &hdf5Lib);
|
||||
}
|
||||
|
||||
LOG(logINFO) << "File Format: " << sls::ToString(fileFormatType);
|
||||
@ -382,7 +382,7 @@ void Implementation::setFileWriteEnable(const bool b) {
|
||||
fileWriteEnable = b;
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
||||
fileFormatType, modulePos);
|
||||
fileFormatType, modulePos, &hdf5Lib);
|
||||
}
|
||||
LOG(logINFO) << "File Write Enable: "
|
||||
<< (fileWriteEnable ? "enabled" : "disabled");
|
||||
@ -397,7 +397,7 @@ void Implementation::setMasterFileWriteEnable(const bool b) {
|
||||
masterFileWriteEnable = b;
|
||||
for (const auto &it : dataProcessor)
|
||||
it->SetupFileWriter(fileWriteEnable, masterFileWriteEnable,
|
||||
fileFormatType, modulePos);
|
||||
fileFormatType, modulePos, &hdf5Lib);
|
||||
}
|
||||
LOG(logINFO) << "Master File Write Enable: "
|
||||
<< (masterFileWriteEnable ? "enabled" : "disabled");
|
||||
@ -473,9 +473,9 @@ double Implementation::getProgress() const {
|
||||
((double)(currentFrameIndex + 1) / (double)numberOfTotalFrames));
|
||||
}
|
||||
|
||||
std::vector<uint64_t> Implementation::getNumMissingPackets() const {
|
||||
std::vector<uint64_t> mp(numThreads);
|
||||
for (int i = 0; i < numThreads; i++) {
|
||||
std::vector<int64_t> Implementation::getNumMissingPackets() const {
|
||||
std::vector<int64_t> mp(numThreads);
|
||||
for (int i = 0; i < numThreads; ++i) {
|
||||
int np = generalData->packetsPerFrame;
|
||||
uint64_t totnp = np;
|
||||
// ReadNRows
|
||||
@ -566,7 +566,7 @@ void Implementation::stopReceiver() {
|
||||
dataProcessor[0]->CreateVirtualFile(
|
||||
filePath, fileName, fileIndex, overwriteEnable, silentMode,
|
||||
modulePos, numThreads, framesPerFile, numberOfTotalFrames,
|
||||
dynamicRange, numMods[X], numMods[Y]);
|
||||
dynamicRange, numMods[X], numMods[Y], &hdf5Lib);
|
||||
}
|
||||
// link file in master
|
||||
dataProcessor[0]->LinkDataInMasterFile(silentMode);
|
||||
@ -595,18 +595,19 @@ void Implementation::stopReceiver() {
|
||||
LOG(logINFO) << "Status: " << sls::ToString(status);
|
||||
|
||||
{ // statistics
|
||||
std::vector<uint64_t> mp = getNumMissingPackets();
|
||||
auto mp = getNumMissingPackets();
|
||||
// print summary
|
||||
uint64_t tot = 0;
|
||||
for (int i = 0; i < numThreads; i++) {
|
||||
int nf = dataProcessor[i]->GetNumCompleteFramesCaught();
|
||||
tot += nf;
|
||||
std::string mpMessage = std::to_string((int64_t)mp[i]);
|
||||
if ((int64_t)mp[i] < 0) {
|
||||
std::string mpMessage = std::to_string(mp[i]);
|
||||
if (mp[i] < 0) {
|
||||
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) <<
|
||||
// udp port number could be the second if selected interface is
|
||||
// 2 for jungfrau
|
||||
@ -880,17 +881,16 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
|
||||
auto fifo_ptr = fifo[i].get();
|
||||
listener.push_back(sls::make_unique<Listener>(
|
||||
i, detType, fifo_ptr, &status, &udpPortNum[i], ð[i],
|
||||
&numberOfTotalFrames, &udpSocketBufferSize,
|
||||
&actualUDPSocketBufferSize, &framesPerFile,
|
||||
&frameDiscardMode, &activated, &detectorDataStream[i],
|
||||
&silentMode));
|
||||
&udpSocketBufferSize, &actualUDPSocketBufferSize,
|
||||
&framesPerFile, &frameDiscardMode, &activated,
|
||||
&detectorDataStream[i], &silentMode));
|
||||
listener[i]->SetGeneralData(generalData);
|
||||
|
||||
dataProcessor.push_back(sls::make_unique<DataProcessor>(
|
||||
i, detType, fifo_ptr, &activated, &dataStreamEnable,
|
||||
&streamingFrequency, &streamingTimerInMs,
|
||||
&streamingStartFnum, &framePadding, &ctbDbitList,
|
||||
&ctbDbitOffset, &ctbAnalogDataBytes, &hdf5Lib));
|
||||
&ctbDbitOffset, &ctbAnalogDataBytes));
|
||||
dataProcessor[i]->SetGeneralData(generalData);
|
||||
} catch (...) {
|
||||
listener.clear();
|
||||
|
@ -83,7 +83,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
uint64_t getFramesCaught() const;
|
||||
uint64_t getAcquisitionIndex() const;
|
||||
double getProgress() const;
|
||||
std::vector<uint64_t> getNumMissingPackets() const;
|
||||
std::vector<int64_t> getNumMissingPackets() const;
|
||||
void setScan(slsDetectorDefs::scanParameters s);
|
||||
void startReceiver();
|
||||
void setStoppedFlag(bool stopped);
|
||||
|
@ -23,10 +23,10 @@ const std::string Listener::TypeName = "Listener";
|
||||
|
||||
Listener::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 *fpf,
|
||||
frameDiscardPolicy *fdp, bool *act, bool *detds, bool *sm)
|
||||
int *us, int *as, uint32_t *fpf, frameDiscardPolicy *fdp,
|
||||
bool *act, bool *detds, bool *sm)
|
||||
: 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),
|
||||
activated(act), detectorDataStream(detds), silentMode(sm) {
|
||||
LOG(logDEBUG) << "Listener " << ind << " created";
|
||||
@ -40,8 +40,8 @@ uint64_t Listener::GetLastFrameIndexCaught() const {
|
||||
return lastCaughtFrameIndex;
|
||||
}
|
||||
|
||||
uint64_t Listener::GetNumMissingPacket(bool stoppedFlag,
|
||||
uint64_t numPackets) const {
|
||||
int64_t Listener::GetNumMissingPacket(bool stoppedFlag,
|
||||
uint64_t numPackets) const {
|
||||
if (!stoppedFlag) {
|
||||
return (numPackets - numPacketsCaught);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* @param s pointer to receiver status
|
||||
* @param portno pointer to udp port number
|
||||
* @param e ethernet interface
|
||||
* @param nf pointer to number of images to catch
|
||||
* @param dr pointer to dynamic range
|
||||
* @param us pointer to 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
|
||||
*/
|
||||
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 *fpf, frameDiscardPolicy *fdp, bool *act, bool *detds,
|
||||
bool *sm);
|
||||
uint32_t *portno, std::string *e, int *us, int *as, uint32_t *fpf,
|
||||
frameDiscardPolicy *fdp, bool *act, bool *detds, bool *sm);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -65,8 +63,8 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
*/
|
||||
uint64_t GetLastFrameIndexCaught() const;
|
||||
|
||||
/** Get number of missing packets */
|
||||
uint64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const;
|
||||
/** Get number of missing packets, returns negative values in case to extra packet */
|
||||
int64_t GetNumMissingPacket(bool stoppedFlag, uint64_t numPackets) const;
|
||||
|
||||
/**
|
||||
* Set Fifo pointer to the one given
|
||||
@ -171,9 +169,6 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/** ethernet interface */
|
||||
std::string *eth;
|
||||
|
||||
/** Number of Images to catch */
|
||||
uint64_t *numImages;
|
||||
|
||||
/** UDP Socket Buffer Size */
|
||||
int *udpSocketBufferSize;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user