renamed multiSlsDetector

This commit is contained in:
Erik Frojdh 2020-02-03 14:57:37 +01:00
parent 6bb1188c37
commit 972f21258a
10 changed files with 77 additions and 77 deletions

View File

@ -1,12 +1,12 @@
#include "catch.hpp" #include "catch.hpp"
#include "multiSlsDetector.h" #include "DetectorImpl.h"
#include "string_utils.h" #include "string_utils.h"
#include "tests/globals.h" #include "tests/globals.h"
#include <iostream> #include <iostream>
class MultiDetectorFixture { class MultiDetectorFixture {
protected: protected:
multiSlsDetector d; DetectorImpl d;
public: public:
MultiDetectorFixture() : d(0, true, true) { MultiDetectorFixture() : d(0, true, true) {

View File

@ -3,7 +3,7 @@
#include "ClientSocket.h" #include "ClientSocket.h"
#include "logger.h" #include "logger.h"
#include "multiSlsDetector.h" #include "DetectorImpl.h"
#include "slsDetector.h" #include "slsDetector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
@ -252,7 +252,7 @@ TEST_CASE(
int ratecorr = 125; int ratecorr = 125;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure eiger detector type, hostname and online // ensure eiger detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum); REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
@ -302,7 +302,7 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure ctb detector type, hostname and online // ensure ctb detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum); REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
@ -387,7 +387,7 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure ctb detector type, hostname and online // ensure ctb detector type, hostname and online
REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum); REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum);
@ -457,7 +457,7 @@ TEST_CASE("Eiger or Jungfrau startingfnum", "[.eigerintegration][.jungfrauintegr
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure ctb detector type, hostname and online // ensure ctb detector type, hostname and online
REQUIRE(((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::JUNGFRAU))); REQUIRE(((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::JUNGFRAU)));
@ -495,7 +495,7 @@ TEST_CASE("Eiger readnlines", "[.eigerintegration][readnlines]") {
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
multiSlsDetector m(0); DetectorImpl m(0);
// ensure detector type, hostname // ensure detector type, hostname
REQUIRE((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER)); REQUIRE((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER));

View File

@ -1,5 +1,5 @@
#include "catch.hpp" #include "catch.hpp"
#include "multiSlsDetector.h" #include "DetectorImpl.h"
#include "string_utils.h" #include "string_utils.h"
#include "tests/globals.h" #include "tests/globals.h"
#include <iostream> #include <iostream>
@ -9,7 +9,7 @@ using namespace Catch::literals;
TEST_CASE("Initialize a multi detector", "[.integration][.multi]") { TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
auto hostnames = sls::split(test::hostname, '+'); auto hostnames = sls::split(test::hostname, '+');
multiSlsDetector d(0, true, true); DetectorImpl d(0, true, true);
d.setHostname(test::hostname.c_str()); d.setHostname(test::hostname.c_str());
CHECK(d.getHostname() == test::hostname); CHECK(d.getHostname() == test::hostname);
@ -28,7 +28,7 @@ TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
TEST_CASE("Set and read timers", "[.integration][.multi]") { TEST_CASE("Set and read timers", "[.integration][.multi]") {
multiSlsDetector d(0, true, true); DetectorImpl d(0, true, true);
d.setHostname(test::hostname.c_str()); d.setHostname(test::hostname.c_str());
// FRAME_NUMBER // FRAME_NUMBER

View File

@ -2,7 +2,7 @@ sls_detector - Python interface for the slsDetectorsPackage
============================================================== ==============================================================
sls_detector provide Python bindings to the slsDetectorsPackage using mainly the sls_detector provide Python bindings to the slsDetectorsPackage using mainly the
multiSlsDetector API. This module contains two parts, a compiled C module to DetectorImpl API. This module contains two parts, a compiled C module to
expose the API and a Python class to offer a more Pythonic interface. expose the API and a Python class to offer a more Pythonic interface.

View File

@ -1,5 +1,5 @@
set(SOURCES set(SOURCES
src/multiSlsDetector.cpp src/DetectorImpl.cpp
src/slsDetectorUsers.cpp src/slsDetectorUsers.cpp
src/slsDetector.cpp src/slsDetector.cpp
src/Detector.cpp src/Detector.cpp

View File

@ -5,7 +5,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
class multiSlsDetector; class DetectorImpl;
class detectorData; class detectorData;
namespace sls { namespace sls {
@ -23,7 +23,7 @@ void freeSharedMemory(int multiId, int detPos = -1);
* \class Detector * \class Detector
*/ */
class Detector { class Detector {
std::unique_ptr<multiSlsDetector> pimpl; std::unique_ptr<DetectorImpl> pimpl;
public: public:
/** /**

View File

@ -4,7 +4,7 @@
#include "container_utils.h" #include "container_utils.h"
#include "detectorData.h" #include "detectorData.h"
#include "logger.h" #include "logger.h"
#include "multiSlsDetector.h" #include "DetectorImpl.h"
#include "slsDetector.h" #include "slsDetector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
@ -41,7 +41,7 @@ void freeSharedMemory(int multiId, int detPos) {
using defs = slsDetectorDefs; using defs = slsDetectorDefs;
Detector::Detector(int shm_id) Detector::Detector(int shm_id)
: pimpl(sls::make_unique<multiSlsDetector>(shm_id)) {} : pimpl(sls::make_unique<DetectorImpl>(shm_id)) {}
Detector::~Detector() = default; Detector::~Detector() = default;
@ -51,7 +51,7 @@ void Detector::freeSharedMemory() { pimpl->freeSharedMemory(); }
void Detector::loadConfig(const std::string &fname) { void Detector::loadConfig(const std::string &fname) {
int shm_id = getShmId(); int shm_id = getShmId();
freeSharedMemory(); freeSharedMemory();
pimpl = sls::make_unique<multiSlsDetector>(shm_id); pimpl = sls::make_unique<DetectorImpl>(shm_id);
FILE_LOG(logINFO) << "Loading configuration file: " << fname; FILE_LOG(logINFO) << "Loading configuration file: " << fname;
loadParameters(fname); loadParameters(fname);
} }

View File

@ -1,4 +1,4 @@
#include "multiSlsDetector.h" #include "DetectorImpl.h"
#include "SharedMemory.h" #include "SharedMemory.h"
#include "ZmqSocket.h" #include "ZmqSocket.h"
#include "detectorData.h" #include "detectorData.h"
@ -28,14 +28,14 @@
using namespace sls; using namespace sls;
multiSlsDetector::multiSlsDetector(int multi_id, bool verify, bool update) DetectorImpl::DetectorImpl(int multi_id, bool verify, bool update)
: multiId(multi_id), multi_shm(multi_id, -1) { : multiId(multi_id), multi_shm(multi_id, -1) {
setupMultiDetector(verify, update); setupMultiDetector(verify, update);
} }
multiSlsDetector::~multiSlsDetector() = default; DetectorImpl::~DetectorImpl() = default;
void multiSlsDetector::setupMultiDetector(bool verify, bool update) { void DetectorImpl::setupMultiDetector(bool verify, bool update) {
initSharedMemory(verify); initSharedMemory(verify);
initializeMembers(verify); initializeMembers(verify);
if (update) { if (update) {
@ -45,7 +45,7 @@ void multiSlsDetector::setupMultiDetector(bool verify, bool update) {
template <typename RT, typename... CT> template <typename RT, typename... CT>
std::vector<RT> std::vector<RT>
multiSlsDetector::serialCall(RT (slsDetector::*somefunc)(CT...), DetectorImpl::serialCall(RT (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) { typename NonDeduced<CT>::type... Args) {
std::vector<RT> result; std::vector<RT> result;
result.reserve(detectors.size()); result.reserve(detectors.size());
@ -57,7 +57,7 @@ multiSlsDetector::serialCall(RT (slsDetector::*somefunc)(CT...),
template <typename RT, typename... CT> template <typename RT, typename... CT>
std::vector<RT> std::vector<RT>
multiSlsDetector::serialCall(RT (slsDetector::*somefunc)(CT...) const, DetectorImpl::serialCall(RT (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const { typename NonDeduced<CT>::type... Args) const {
std::vector<RT> result; std::vector<RT> result;
result.reserve(detectors.size()); result.reserve(detectors.size());
@ -69,7 +69,7 @@ multiSlsDetector::serialCall(RT (slsDetector::*somefunc)(CT...) const,
template <typename RT, typename... CT> template <typename RT, typename... CT>
std::vector<RT> std::vector<RT>
multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT...), DetectorImpl::parallelCall(RT (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) { typename NonDeduced<CT>::type... Args) {
std::vector<std::future<RT>> futures; std::vector<std::future<RT>> futures;
for (auto &d : detectors) { for (auto &d : detectors) {
@ -86,7 +86,7 @@ multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT...),
template <typename RT, typename... CT> template <typename RT, typename... CT>
std::vector<RT> std::vector<RT>
multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT...) const, DetectorImpl::parallelCall(RT (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const { typename NonDeduced<CT>::type... Args) const {
std::vector<std::future<RT>> futures; std::vector<std::future<RT>> futures;
for (auto &d : detectors) { for (auto &d : detectors) {
@ -102,7 +102,7 @@ multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT...) const,
} }
template <typename... CT> template <typename... CT>
void multiSlsDetector::parallelCall(void (slsDetector::*somefunc)(CT...), void DetectorImpl::parallelCall(void (slsDetector::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) { typename NonDeduced<CT>::type... Args) {
std::vector<std::future<void>> futures; std::vector<std::future<void>> futures;
for (auto &d : detectors) { for (auto &d : detectors) {
@ -116,7 +116,7 @@ void multiSlsDetector::parallelCall(void (slsDetector::*somefunc)(CT...),
} }
template <typename... CT> template <typename... CT>
void multiSlsDetector::parallelCall( void DetectorImpl::parallelCall(
void (slsDetector::*somefunc)(CT...) const, void (slsDetector::*somefunc)(CT...) const,
typename NonDeduced<CT>::type... Args) const { typename NonDeduced<CT>::type... Args) const {
std::vector<std::future<void>> futures; std::vector<std::future<void>> futures;
@ -130,17 +130,17 @@ void multiSlsDetector::parallelCall(
return; return;
} }
void multiSlsDetector::setAcquiringFlag(bool flag) { void DetectorImpl::setAcquiringFlag(bool flag) {
multi_shm()->acquiringFlag = flag; multi_shm()->acquiringFlag = flag;
} }
int multiSlsDetector::getMultiId() const { return multiId; } int DetectorImpl::getMultiId() const { return multiId; }
std::string multiSlsDetector::getPackageVersion() const { return GITBRANCH; } std::string DetectorImpl::getPackageVersion() const { return GITBRANCH; }
int64_t multiSlsDetector::getClientSoftwareVersion() const { return APILIB; } int64_t DetectorImpl::getClientSoftwareVersion() const { return APILIB; }
void multiSlsDetector::freeSharedMemory(int multiId, int detPos) { void DetectorImpl::freeSharedMemory(int multiId, int detPos) {
// single // single
if (detPos >= 0) { if (detPos >= 0) {
SharedMemory<sharedSlsDetector> temp_shm(multiId, detPos); SharedMemory<sharedSlsDetector> temp_shm(multiId, detPos);
@ -166,7 +166,7 @@ void multiSlsDetector::freeSharedMemory(int multiId, int detPos) {
} }
} }
void multiSlsDetector::freeSharedMemory() { void DetectorImpl::freeSharedMemory() {
zmqSocket.clear(); zmqSocket.clear();
for (auto &d : detectors) { for (auto &d : detectors) {
d->freeSharedMemory(); d->freeSharedMemory();
@ -178,7 +178,7 @@ void multiSlsDetector::freeSharedMemory() {
client_downstream = false; client_downstream = false;
} }
std::string multiSlsDetector::getUserDetails() { std::string DetectorImpl::getUserDetails() {
if (detectors.empty()) { if (detectors.empty()) {
return std::string("none"); return std::string("none");
} }
@ -213,15 +213,15 @@ std::string multiSlsDetector::getUserDetails() {
} }
bool multiSlsDetector::getInitialChecks() const { bool DetectorImpl::getInitialChecks() const {
return multi_shm()->initialChecks; return multi_shm()->initialChecks;
} }
void multiSlsDetector::setInitialChecks(const bool value) { void DetectorImpl::setInitialChecks(const bool value) {
multi_shm()->initialChecks = value; multi_shm()->initialChecks = value;
} }
void multiSlsDetector::initSharedMemory(bool verify) { void DetectorImpl::initSharedMemory(bool verify) {
if (!multi_shm.IsExisting()) { if (!multi_shm.IsExisting()) {
multi_shm.CreateSharedMemory(); multi_shm.CreateSharedMemory();
initializeDetectorStructure(); initializeDetectorStructure();
@ -239,7 +239,7 @@ void multiSlsDetector::initSharedMemory(bool verify) {
} }
} }
void multiSlsDetector::initializeDetectorStructure() { void DetectorImpl::initializeDetectorStructure() {
multi_shm()->shmversion = MULTI_SHMVERSION; multi_shm()->shmversion = MULTI_SHMVERSION;
multi_shm()->numberOfDetectors = 0; multi_shm()->numberOfDetectors = 0;
multi_shm()->multiDetectorType = GENERIC; multi_shm()->multiDetectorType = GENERIC;
@ -252,8 +252,8 @@ void multiSlsDetector::initializeDetectorStructure() {
multi_shm()->initialChecks = true; multi_shm()->initialChecks = true;
} }
void multiSlsDetector::initializeMembers(bool verify) { void DetectorImpl::initializeMembers(bool verify) {
// multiSlsDetector // DetectorImpl
zmqSocket.clear(); zmqSocket.clear();
// get objects from single det shared memory (open) // get objects from single det shared memory (open)
@ -268,7 +268,7 @@ void multiSlsDetector::initializeMembers(bool verify) {
} }
} }
void multiSlsDetector::updateUserdetails() { void DetectorImpl::updateUserdetails() {
multi_shm()->lastPID = getpid(); multi_shm()->lastPID = getpid();
memset(multi_shm()->lastUser, 0, SHORT_STRING_LENGTH); memset(multi_shm()->lastUser, 0, SHORT_STRING_LENGTH);
memset(multi_shm()->lastDate, 0, SHORT_STRING_LENGTH); memset(multi_shm()->lastDate, 0, SHORT_STRING_LENGTH);
@ -281,7 +281,7 @@ void multiSlsDetector::updateUserdetails() {
} }
} }
bool multiSlsDetector::isAcquireReady() { bool DetectorImpl::isAcquireReady() {
if (multi_shm()->acquiringFlag) { if (multi_shm()->acquiringFlag) {
FILE_LOG(logWARNING) FILE_LOG(logWARNING)
<< "Acquire has already started. " << "Acquire has already started. "
@ -293,7 +293,7 @@ bool multiSlsDetector::isAcquireReady() {
return true; return true;
} }
std::string multiSlsDetector::exec(const char *cmd) { std::string DetectorImpl::exec(const char *cmd) {
int bufsize = 128; int bufsize = 128;
char buffer[bufsize]; char buffer[bufsize];
std::string result = ""; std::string result = "";
@ -316,7 +316,7 @@ std::string multiSlsDetector::exec(const char *cmd) {
return result; return result;
} }
void multiSlsDetector::setVirtualDetectorServers(const int numdet, void DetectorImpl::setVirtualDetectorServers(const int numdet,
const int port) { const int port) {
std::vector<std::string> hostnames; std::vector<std::string> hostnames;
for (int i = 0; i < numdet; ++i) { for (int i = 0; i < numdet; ++i) {
@ -327,7 +327,7 @@ void multiSlsDetector::setVirtualDetectorServers(const int numdet,
setHostname(hostnames); setHostname(hostnames);
} }
void multiSlsDetector::setHostname(const std::vector<std::string> &name) { void DetectorImpl::setHostname(const std::vector<std::string> &name) {
// this check is there only to allow the previous detsizechan command // this check is there only to allow the previous detsizechan command
if (multi_shm()->numberOfDetectors != 0) { if (multi_shm()->numberOfDetectors != 0) {
FILE_LOG(logWARNING) FILE_LOG(logWARNING)
@ -344,7 +344,7 @@ void multiSlsDetector::setHostname(const std::vector<std::string> &name) {
updateDetectorSize(); updateDetectorSize();
} }
void multiSlsDetector::addSlsDetector(const std::string &hostname) { void DetectorImpl::addSlsDetector(const std::string &hostname) {
FILE_LOG(logINFO) << "Adding detector " << hostname; FILE_LOG(logINFO) << "Adding detector " << hostname;
int port = DEFAULT_PORTNO; int port = DEFAULT_PORTNO;
@ -380,7 +380,7 @@ void multiSlsDetector::addSlsDetector(const std::string &hostname) {
multi_shm()->multiDetectorType = Parallel(&slsDetector::getDetectorType, {}).tsquash("Inconsistent detector types."); multi_shm()->multiDetectorType = Parallel(&slsDetector::getDetectorType, {}).tsquash("Inconsistent detector types.");
} }
void multiSlsDetector::updateDetectorSize() { void DetectorImpl::updateDetectorSize() {
FILE_LOG(logDEBUG) << "Updating Multi-Detector Size: " << size(); FILE_LOG(logDEBUG) << "Updating Multi-Detector Size: " << size();
const slsDetectorDefs::xy det_size = detectors[0]->getNumberOfChannels(); const slsDetectorDefs::xy det_size = detectors[0]->getNumberOfChannels();
@ -415,17 +415,17 @@ void multiSlsDetector::updateDetectorSize() {
} }
} }
int multiSlsDetector::size() const { return detectors.size(); } int DetectorImpl::size() const { return detectors.size(); }
slsDetectorDefs::xy multiSlsDetector::getNumberOfDetectors() const { slsDetectorDefs::xy DetectorImpl::getNumberOfDetectors() const {
return multi_shm()->numberOfDetector; return multi_shm()->numberOfDetector;
} }
slsDetectorDefs::xy multiSlsDetector::getNumberOfChannels() const { slsDetectorDefs::xy DetectorImpl::getNumberOfChannels() const {
return multi_shm()->numberOfChannels; return multi_shm()->numberOfChannels;
} }
void multiSlsDetector::setNumberOfChannels(const slsDetectorDefs::xy c) { void DetectorImpl::setNumberOfChannels(const slsDetectorDefs::xy c) {
if (size() > 1) { if (size() > 1) {
throw RuntimeError( throw RuntimeError(
"Set the number of channels before setting hostname."); "Set the number of channels before setting hostname.");
@ -433,7 +433,7 @@ void multiSlsDetector::setNumberOfChannels(const slsDetectorDefs::xy c) {
multi_shm()->numberOfChannels = c; multi_shm()->numberOfChannels = c;
} }
void multiSlsDetector::setGapPixelsinReceiver(bool enable) { void DetectorImpl::setGapPixelsinReceiver(bool enable) {
Parallel(&slsDetector::enableGapPixels, {}, static_cast<int>(enable)); Parallel(&slsDetector::enableGapPixels, {}, static_cast<int>(enable));
// update number of channels // update number of channels
Result<slsDetectorDefs::xy> res = Result<slsDetectorDefs::xy> res =
@ -446,7 +446,7 @@ void multiSlsDetector::setGapPixelsinReceiver(bool enable) {
} }
} }
int multiSlsDetector::createReceivingDataSockets(const bool destroy) { int DetectorImpl::createReceivingDataSockets(const bool destroy) {
if (destroy) { if (destroy) {
FILE_LOG(logINFO) << "Going to destroy data sockets"; FILE_LOG(logINFO) << "Going to destroy data sockets";
// close socket // close socket
@ -494,7 +494,7 @@ int multiSlsDetector::createReceivingDataSockets(const bool destroy) {
return OK; return OK;
} }
void multiSlsDetector::readFrameFromReceiver() { void DetectorImpl::readFrameFromReceiver() {
int nX = 0; int nX = 0;
int nY = 0; int nY = 0;
@ -754,7 +754,7 @@ void multiSlsDetector::readFrameFromReceiver() {
delete[] multigappixels; delete[] multigappixels;
} }
int multiSlsDetector::processImageWithGapPixels(char *image, char *&gpImage, int DetectorImpl::processImageWithGapPixels(char *image, char *&gpImage,
bool quadEnable) { bool quadEnable) {
// eiger 4 bit mode // eiger 4 bit mode
int nxb = int nxb =
@ -889,7 +889,7 @@ int multiSlsDetector::processImageWithGapPixels(char *image, char *&gpImage,
return gapdatabytes; return gapdatabytes;
} }
bool multiSlsDetector::enableDataStreamingToClient(int enable) { bool DetectorImpl::enableDataStreamingToClient(int enable) {
if (enable >= 0) { if (enable >= 0) {
// destroy data threads // destroy data threads
if (enable == 0) { if (enable == 0) {
@ -905,7 +905,7 @@ bool multiSlsDetector::enableDataStreamingToClient(int enable) {
} }
void multiSlsDetector::savePattern(const std::string &fname) { void DetectorImpl::savePattern(const std::string &fname) {
// std::ofstream outfile; // std::ofstream outfile;
// outfile.open(fname.c_str(), std::ios_base::out); // outfile.open(fname.c_str(), std::ios_base::out);
// if (!outfile.is_open()) { // if (!outfile.is_open()) {
@ -947,13 +947,13 @@ void multiSlsDetector::savePattern(const std::string &fname) {
void multiSlsDetector::registerAcquisitionFinishedCallback( void DetectorImpl::registerAcquisitionFinishedCallback(
void (*func)(double, int, void *), void *pArg) { void (*func)(double, int, void *), void *pArg) {
acquisition_finished = func; acquisition_finished = func;
acqFinished_p = pArg; acqFinished_p = pArg;
} }
void multiSlsDetector::registerDataCallback( void DetectorImpl::registerDataCallback(
void (*userCallback)(detectorData *, uint64_t, uint32_t, void *), void (*userCallback)(detectorData *, uint64_t, uint32_t, void *),
void *pArg) { void *pArg) {
dataReady = userCallback; dataReady = userCallback;
@ -961,7 +961,7 @@ void multiSlsDetector::registerDataCallback(
enableDataStreamingToClient(dataReady == nullptr ? 0 : 1); enableDataStreamingToClient(dataReady == nullptr ? 0 : 1);
} }
double multiSlsDetector::setTotalProgress() { double DetectorImpl::setTotalProgress() {
int64_t nf = Parallel(&slsDetector::getNumberOfFramesFromShm, {}) int64_t nf = Parallel(&slsDetector::getNumberOfFramesFromShm, {})
.tsquash("Inconsistent number of frames"); .tsquash("Inconsistent number of frames");
int64_t nc = Parallel(&slsDetector::getNumberOfTriggersFromShm, {}) int64_t nc = Parallel(&slsDetector::getNumberOfTriggersFromShm, {})
@ -983,12 +983,12 @@ double multiSlsDetector::setTotalProgress() {
return totalProgress; return totalProgress;
} }
double multiSlsDetector::getCurrentProgress() { double DetectorImpl::getCurrentProgress() {
std::lock_guard<std::mutex> lock(mp); std::lock_guard<std::mutex> lock(mp);
return 100. * progressIndex / totalProgress; return 100. * progressIndex / totalProgress;
} }
void multiSlsDetector::incrementProgress() { void DetectorImpl::incrementProgress() {
std::lock_guard<std::mutex> lock(mp); std::lock_guard<std::mutex> lock(mp);
progressIndex += 1; progressIndex += 1;
std::cout << std::fixed << std::setprecision(2) << std::setw(6) std::cout << std::fixed << std::setprecision(2) << std::setw(6)
@ -997,7 +997,7 @@ void multiSlsDetector::incrementProgress() {
std::cout << '\r' << std::flush; std::cout << '\r' << std::flush;
} }
void multiSlsDetector::setCurrentProgress(int64_t i) { void DetectorImpl::setCurrentProgress(int64_t i) {
std::lock_guard<std::mutex> lock(mp); std::lock_guard<std::mutex> lock(mp);
progressIndex = (double)i; progressIndex = (double)i;
std::cout << std::fixed << std::setprecision(2) << std::setw(6) std::cout << std::fixed << std::setprecision(2) << std::setw(6)
@ -1006,7 +1006,7 @@ void multiSlsDetector::setCurrentProgress(int64_t i) {
std::cout << '\r' << std::flush; std::cout << '\r' << std::flush;
} }
int multiSlsDetector::acquire() { int DetectorImpl::acquire() {
// ensure acquire isnt started multiple times by same client // ensure acquire isnt started multiple times by same client
if (!isAcquireReady()) { if (!isAcquireReady()) {
return FAIL; return FAIL;
@ -1099,12 +1099,12 @@ int multiSlsDetector::acquire() {
return OK; return OK;
} }
void multiSlsDetector::startProcessingThread() { void DetectorImpl::startProcessingThread() {
setTotalProgress(); setTotalProgress();
dataProcessingThread = std::thread(&multiSlsDetector::processData, this); dataProcessingThread = std::thread(&DetectorImpl::processData, this);
} }
void multiSlsDetector::processData() { void DetectorImpl::processData() {
if (Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false)) { if (Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false)) {
if (dataReady != nullptr) { if (dataReady != nullptr) {
readFrameFromReceiver(); readFrameFromReceiver();
@ -1139,17 +1139,17 @@ void multiSlsDetector::processData() {
} }
} }
bool multiSlsDetector::getJoinThreadFlag() const { bool DetectorImpl::getJoinThreadFlag() const {
std::lock_guard<std::mutex> lock(mp); std::lock_guard<std::mutex> lock(mp);
return jointhread; return jointhread;
} }
void multiSlsDetector::setJoinThreadFlag(bool value) { void DetectorImpl::setJoinThreadFlag(bool value) {
std::lock_guard<std::mutex> lock(mp); std::lock_guard<std::mutex> lock(mp);
jointhread = value; jointhread = value;
} }
int multiSlsDetector::kbhit() { int DetectorImpl::kbhit() {
struct timeval tv; struct timeval tv;
fd_set fds; fd_set fds;
tv.tv_sec = 0; tv.tv_sec = 0;
@ -1160,7 +1160,7 @@ int multiSlsDetector::kbhit() {
return FD_ISSET(STDIN_FILENO, &fds); return FD_ISSET(STDIN_FILENO, &fds);
} }
std::vector<char> multiSlsDetector::readProgrammingFile(const std::string &fname) { std::vector<char> DetectorImpl::readProgrammingFile(const std::string &fname) {
// validate type of file // validate type of file
bool isPof = false; bool isPof = false;
switch (multi_shm()->multiDetectorType) { switch (multi_shm()->multiDetectorType) {

View File

@ -69,7 +69,7 @@ struct sharedMultiSlsDetector {
bool initialChecks; bool initialChecks;
}; };
class multiSlsDetector : public virtual slsDetectorDefs { class DetectorImpl : public virtual slsDetectorDefs {
public: public:
/** /**
* Constructor * Constructor
@ -78,13 +78,13 @@ class multiSlsDetector : public virtual slsDetectorDefs {
* one * one
* @param update true to update last user pid, date etc * @param update true to update last user pid, date etc
*/ */
explicit multiSlsDetector(int multi_id = 0, bool verify = true, explicit DetectorImpl(int multi_id = 0, bool verify = true,
bool update = true); bool update = true);
/** /**
* Destructor * Destructor
*/ */
virtual ~multiSlsDetector(); virtual ~DetectorImpl();
template <class CT> struct NonDeduced { using type = CT; }; template <class CT> struct NonDeduced { using type = CT; };
template <typename RT, typename... CT> template <typename RT, typename... CT>

View File

@ -2023,7 +2023,7 @@ TEST_CASE("stopport", "[.cmd]") {
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:flippeddatax", GET, // REQUIRE_NOTHROW(multiSlsDetectorClient("0:flippeddatax", GET,
// nullptr, oss)); REQUIRE(oss.str() == "flippeddatax 0\n"); // nullptr, oss)); REQUIRE(oss.str() == "flippeddatax 0\n");
// } // }
// multiSlsDetector d; // DetectorImpl d;
// if (d.size() > 1) { // if (d.size() > 1) {
// std::ostringstream oss; // std::ostringstream oss;
// REQUIRE_NOTHROW(multiSlsDetectorClient("1:flippeddatax", GET, // REQUIRE_NOTHROW(multiSlsDetectorClient("1:flippeddatax", GET,
@ -2301,7 +2301,7 @@ TEST_CASE("fformat", "[.cmd]") {
// oss)); REQUIRE(oss.str() == "udp_dstport 6200\n"); // oss)); REQUIRE(oss.str() == "udp_dstport 6200\n");
// } // }
// { // {
// multiSlsDetector d; // DetectorImpl d;
// int socketsperdetector = 1; // int socketsperdetector = 1;
// if (test::type == slsDetectorDefs::EIGER) { // if (test::type == slsDetectorDefs::EIGER) {
// socketsperdetector *= 2; // socketsperdetector *= 2;