mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-19 18:40:01 +02:00
slsDetector -> Module
This commit is contained in:
parent
012c66bbbf
commit
5784ce8231
@ -4,7 +4,7 @@
|
||||
#include "ClientSocket.h"
|
||||
#include "logger.h"
|
||||
#include "DetectorImpl.h"
|
||||
#include "slsDetector.h"
|
||||
#include "Module.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include "Timer.h"
|
||||
@ -23,10 +23,10 @@
|
||||
// extern dt type;
|
||||
|
||||
TEST_CASE("Single detector no receiver", "[.integration][.single]") {
|
||||
auto t = slsDetector::getTypeFromDetector(test::hostname);
|
||||
auto t = Module::getTypeFromDetector(test::hostname);
|
||||
CHECK(t == test::type);
|
||||
|
||||
slsDetector d(t);
|
||||
Module d(t);
|
||||
CHECK(d.getDetectorTypeAsEnum() == t);
|
||||
CHECK(d.getDetectorTypeAsString() == test::detector_type);
|
||||
|
||||
@ -51,7 +51,7 @@ TEST_CASE("Set control port then create a new object with this control port",
|
||||
int new_cport = 1993;
|
||||
int new_sport = 2000;
|
||||
{
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
CHECK(d.getControlPort() == old_cport);
|
||||
d.setControlPort(new_cport);
|
||||
@ -60,7 +60,7 @@ TEST_CASE("Set control port then create a new object with this control port",
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
{
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
d.setControlPort(new_cport);
|
||||
d.setStopPort(new_sport);
|
||||
@ -73,7 +73,7 @@ TEST_CASE("Set control port then create a new object with this control port",
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
CHECK(d.getStopPort() == DEFAULT_PORTNO + 1);
|
||||
d.freeSharedMemory();
|
||||
@ -86,11 +86,11 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
|
||||
SingleDetectorConfig c;
|
||||
|
||||
// Read type by connecting to the detector
|
||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
auto type = Module::getTypeFromDetector(c.hostname);
|
||||
CHECK(type == c.type_enum);
|
||||
|
||||
// Create slsDetector of said type and set hostname and detector online
|
||||
slsDetector d(type);
|
||||
// Create Module of said type and set hostname and detector online
|
||||
Module d(type);
|
||||
CHECK(d.getDetectorTypeAsEnum() == type);
|
||||
CHECK(d.getDetectorTypeAsString() == c.type_string);
|
||||
|
||||
@ -133,7 +133,7 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
|
||||
|
||||
|
||||
TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
|
||||
// Check that detector server is unlocked then lock
|
||||
@ -155,7 +155,7 @@ TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
|
||||
}
|
||||
|
||||
TEST_CASE("Set settings", "[.integration][.single]"){
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD);
|
||||
}
|
||||
@ -185,7 +185,7 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
|
||||
// MEASURED_SUBPERIOD, /**< measured subperiod */
|
||||
// MAX_TIMERS
|
||||
|
||||
slsDetector d(test::type);
|
||||
Module d(test::type);
|
||||
d.setHostname(test::hostname);
|
||||
|
||||
// Number of frames
|
||||
@ -226,8 +226,8 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
|
||||
|
||||
// TEST_CASE("Aquire", "[.integration][eiger]"){
|
||||
// SingleDetectorConfig c;
|
||||
// auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
// slsDetector d(type);
|
||||
// auto type = Module::getTypeFromDetector(c.hostname);
|
||||
// Module d(type);
|
||||
// d.setHostname(c.hostname);
|
||||
|
||||
// auto period = 1000000000;
|
||||
|
@ -1,7 +1,7 @@
|
||||
set(SOURCES
|
||||
src/DetectorImpl.cpp
|
||||
src/slsDetectorUsers.cpp
|
||||
src/slsDetector.cpp
|
||||
src/Module.cpp
|
||||
src/Detector.cpp
|
||||
src/CmdProxy.cpp
|
||||
src/CmdParser.cpp
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
||||
#include "detectorData.h"
|
||||
#include "file_utils.h"
|
||||
#include "logger.h"
|
||||
#include "slsDetector.h"
|
||||
#include "Module.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "versionAPI.h"
|
||||
|
||||
@ -172,7 +172,7 @@ void DetectorImpl::initializeMembers(bool verify) {
|
||||
for (int i = 0; i < multi_shm()->numberOfDetectors; i++) {
|
||||
try {
|
||||
detectors.push_back(
|
||||
sls::make_unique<slsDetector>(multiId, i, verify));
|
||||
sls::make_unique<Module>(multiId, i, verify));
|
||||
} catch (...) {
|
||||
detectors.clear();
|
||||
throw;
|
||||
@ -275,17 +275,17 @@ void DetectorImpl::addSlsDetector(const std::string &hostname) {
|
||||
}
|
||||
|
||||
// get type by connecting
|
||||
detectorType type = slsDetector::getTypeFromDetector(host, port);
|
||||
detectorType type = Module::getTypeFromDetector(host, port);
|
||||
auto pos = detectors.size();
|
||||
detectors.emplace_back(
|
||||
sls::make_unique<slsDetector>(type, multiId, pos, false));
|
||||
sls::make_unique<Module>(type, multiId, pos, false));
|
||||
multi_shm()->numberOfDetectors = detectors.size();
|
||||
detectors[pos]->setControlPort(port);
|
||||
detectors[pos]->setStopPort(port + 1);
|
||||
detectors[pos]->setHostname(host, multi_shm()->initialChecks);
|
||||
// detector type updated by now
|
||||
multi_shm()->multiDetectorType =
|
||||
Parallel(&slsDetector::getDetectorType, {})
|
||||
Parallel(&Module::getDetectorType, {})
|
||||
.tsquash("Inconsistent detector types.");
|
||||
// for moench and ctb
|
||||
detectors[pos]->updateNumberOfChannels();
|
||||
@ -345,10 +345,10 @@ void DetectorImpl::setNumberOfChannels(const slsDetectorDefs::xy c) {
|
||||
}
|
||||
|
||||
void DetectorImpl::setGapPixelsinReceiver(bool enable) {
|
||||
Parallel(&slsDetector::enableGapPixels, {}, static_cast<int>(enable));
|
||||
Parallel(&Module::enableGapPixels, {}, static_cast<int>(enable));
|
||||
// update number of channels
|
||||
Result<slsDetectorDefs::xy> res =
|
||||
Parallel(&slsDetector::getNumberOfChannels, {});
|
||||
Parallel(&Module::getNumberOfChannels, {});
|
||||
multi_shm()->numberOfChannels.x = 0;
|
||||
multi_shm()->numberOfChannels.y = 0;
|
||||
for (auto &it : res) {
|
||||
@ -377,7 +377,7 @@ int DetectorImpl::createReceivingDataSockets(const bool destroy) {
|
||||
if (multi_shm()->multiDetectorType == EIGER) {
|
||||
numSocketsPerDetector = 2;
|
||||
}
|
||||
if (Parallel(&slsDetector::getNumberofUDPInterfacesFromShm, {}).squash() ==
|
||||
if (Parallel(&Module::getNumberofUDPInterfacesFromShm, {}).squash() ==
|
||||
2) {
|
||||
numSocketsPerDetector = 2;
|
||||
}
|
||||
@ -419,7 +419,7 @@ void DetectorImpl::readFrameFromReceiver() {
|
||||
bool quadEnable = false;
|
||||
bool eiger = false;
|
||||
bool numInterfaces =
|
||||
Parallel(&slsDetector::getNumberofUDPInterfacesFromShm, {})
|
||||
Parallel(&Module::getNumberofUDPInterfacesFromShm, {})
|
||||
.squash(); // cannot pick up from zmq
|
||||
|
||||
bool runningList[zmqSocket.size()], connectList[zmqSocket.size()];
|
||||
@ -829,7 +829,7 @@ void DetectorImpl::savePattern(const std::string &fname) {
|
||||
// throw RuntimeError("Could not create file to save pattern");
|
||||
// }
|
||||
// // get pattern limits
|
||||
// auto r = Parallel(&slsDetector::setPatternLoopAddresses, {}, -1, -1, -1)
|
||||
// auto r = Parallel(&Module::setPatternLoopAddresses, {}, -1, -1, -1)
|
||||
// .tsquash("Inconsistent pattern limits");
|
||||
// // pattern words
|
||||
// for (int i = r[0]; i <= r[1]; ++i) {
|
||||
@ -879,7 +879,7 @@ void DetectorImpl::registerDataCallback(void (*userCallback)(detectorData *,
|
||||
}
|
||||
|
||||
double DetectorImpl::setTotalProgress() {
|
||||
int64_t tot = Parallel(&slsDetector::getTotalNumFramesToReceive, {})
|
||||
int64_t tot = Parallel(&Module::getTotalNumFramesToReceive, {})
|
||||
.tsquash("Inconsistent number of total frames (#frames x #triggers(or bursts) x #storage cells)");
|
||||
if (tot == 0) {
|
||||
throw RuntimeError("Invalid Total Number of frames (0)");
|
||||
@ -929,15 +929,15 @@ int DetectorImpl::acquire() {
|
||||
sem_init(&sem_endRTAcquisition, 1, 0);
|
||||
|
||||
bool receiver =
|
||||
Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false);
|
||||
Parallel(&Module::getUseReceiverFlag, {}).squash(false);
|
||||
progressIndex = 0;
|
||||
setJoinThreadFlag(false);
|
||||
|
||||
// verify receiver is idle
|
||||
if (receiver) {
|
||||
if (Parallel(&slsDetector::getReceiverStatus, {}).squash(ERROR) !=
|
||||
if (Parallel(&Module::getReceiverStatus, {}).squash(ERROR) !=
|
||||
IDLE) {
|
||||
Parallel(&slsDetector::stopReceiver, {});
|
||||
Parallel(&Module::stopReceiver, {});
|
||||
}
|
||||
}
|
||||
setTotalProgress();
|
||||
@ -946,7 +946,7 @@ int DetectorImpl::acquire() {
|
||||
|
||||
// start receiver
|
||||
if (receiver) {
|
||||
Parallel(&slsDetector::startReceiver, {});
|
||||
Parallel(&Module::startReceiver, {});
|
||||
// let processing thread listen to these packets
|
||||
sem_post(&sem_newRTAcquisition);
|
||||
}
|
||||
@ -954,24 +954,24 @@ int DetectorImpl::acquire() {
|
||||
// start and read all
|
||||
try {
|
||||
if (multi_shm()->multiDetectorType == EIGER) {
|
||||
Parallel(&slsDetector::prepareAcquisition, {});
|
||||
Parallel(&Module::prepareAcquisition, {});
|
||||
}
|
||||
Parallel(&slsDetector::startAndReadAll, {});
|
||||
Parallel(&Module::startAndReadAll, {});
|
||||
} catch (...) {
|
||||
Parallel(&slsDetector::stopReceiver, {});
|
||||
Parallel(&Module::stopReceiver, {});
|
||||
throw;
|
||||
}
|
||||
|
||||
// stop receiver
|
||||
if (receiver) {
|
||||
Parallel(&slsDetector::stopReceiver, {});
|
||||
Parallel(&Module::stopReceiver, {});
|
||||
if (dataReady != nullptr) {
|
||||
sem_wait(&sem_endRTAcquisition); // waits for receiver's
|
||||
}
|
||||
// external process to be
|
||||
// done sending data to gui
|
||||
|
||||
Parallel(&slsDetector::incrementFileIndex, {});
|
||||
Parallel(&Module::incrementFileIndex, {});
|
||||
}
|
||||
|
||||
// waiting for the data processing thread to finish!
|
||||
@ -982,7 +982,7 @@ int DetectorImpl::acquire() {
|
||||
if (acquisition_finished != nullptr) {
|
||||
// same status for all, else error
|
||||
int status = static_cast<int>(ERROR);
|
||||
auto t = Parallel(&slsDetector::getRunStatus, {});
|
||||
auto t = Parallel(&Module::getRunStatus, {});
|
||||
if (t.equal())
|
||||
status = t.front();
|
||||
acquisition_finished(getCurrentProgress(), status, acqFinished_p);
|
||||
@ -1010,7 +1010,7 @@ void DetectorImpl::startProcessingThread() {
|
||||
}
|
||||
|
||||
void DetectorImpl::processData() {
|
||||
if (Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false)) {
|
||||
if (Parallel(&Module::getUseReceiverFlag, {}).squash(false)) {
|
||||
if (dataReady != nullptr) {
|
||||
readFrameFromReceiver();
|
||||
}
|
||||
@ -1023,11 +1023,11 @@ void DetectorImpl::processData() {
|
||||
if (fgetc(stdin) == 'q') {
|
||||
LOG(logINFO)
|
||||
<< "Caught the command to stop acquisition";
|
||||
Parallel(&slsDetector::stopAcquisition, {});
|
||||
Parallel(&Module::stopAcquisition, {});
|
||||
}
|
||||
}
|
||||
// get progress
|
||||
caught = Parallel(&slsDetector::getFramesCaughtByReceiver, {0})
|
||||
caught = Parallel(&Module::getFramesCaughtByReceiver, {0})
|
||||
.squash();
|
||||
|
||||
// updating progress
|
||||
|
@ -5,7 +5,10 @@
|
||||
#include "logger.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
class slsDetector;
|
||||
namespace sls{
|
||||
class Module;
|
||||
}
|
||||
|
||||
class ZmqSocket;
|
||||
class detectorData;
|
||||
|
||||
@ -87,7 +90,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
|
||||
template <class CT> struct NonDeduced { using type = CT; };
|
||||
template <typename RT, typename... CT>
|
||||
sls::Result<RT> Parallel(RT (slsDetector::*somefunc)(CT...),
|
||||
sls::Result<RT> Parallel(RT (sls::Module::*somefunc)(CT...),
|
||||
std::vector<int> positions,
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
@ -115,7 +118,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
}
|
||||
|
||||
template <typename RT, typename... CT>
|
||||
sls::Result<RT> Parallel(RT (slsDetector::*somefunc)(CT...) const,
|
||||
sls::Result<RT> Parallel(RT (sls::Module::*somefunc)(CT...) const,
|
||||
std::vector<int> positions,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
@ -143,7 +146,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
}
|
||||
|
||||
template <typename... CT>
|
||||
void Parallel(void (slsDetector::*somefunc)(CT...),
|
||||
void Parallel(void (sls::Module::*somefunc)(CT...),
|
||||
std::vector<int> positions,
|
||||
typename NonDeduced<CT>::type... Args) {
|
||||
|
||||
@ -168,7 +171,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
}
|
||||
|
||||
template <typename... CT>
|
||||
void Parallel(void (slsDetector::*somefunc)(CT...) const,
|
||||
void Parallel(void (sls::Module::*somefunc)(CT...) const,
|
||||
std::vector<int> positions,
|
||||
typename NonDeduced<CT>::type... Args) const {
|
||||
|
||||
@ -404,8 +407,8 @@ class DetectorImpl : public virtual slsDetectorDefs {
|
||||
/** Shared Memory object */
|
||||
sls::SharedMemory<sharedMultiSlsDetector> multi_shm{0, -1};
|
||||
|
||||
/** pointers to the slsDetector structures */
|
||||
std::vector<std::unique_ptr<slsDetector>> detectors;
|
||||
/** pointers to the Module structures */
|
||||
std::vector<std::unique_ptr<sls::Module>> detectors;
|
||||
|
||||
/** data streaming (down stream) enabled in client (zmq sckets created) */
|
||||
bool client_downstream{false};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,8 @@ class ServerInterface;
|
||||
#define SLS_SHMAPIVERSION 0x190726
|
||||
#define SLS_SHMVERSION 0x200309
|
||||
|
||||
namespace sls{
|
||||
|
||||
/**
|
||||
* @short structure allocated in shared memory to store detector settings for
|
||||
* IPC and cache
|
||||
@ -178,7 +180,7 @@ struct sharedSlsDetector {
|
||||
bool stoppedFlag;
|
||||
};
|
||||
|
||||
class slsDetector : public virtual slsDetectorDefs {
|
||||
class Module : public virtual slsDetectorDefs {
|
||||
public:
|
||||
/**
|
||||
* Constructor called when creating new shared memory
|
||||
@ -188,7 +190,7 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
* @param verify true to verify if shared memory version matches existing
|
||||
* one
|
||||
*/
|
||||
explicit slsDetector(detectorType type, int multi_id = 0, int det_id = 0,
|
||||
explicit Module(detectorType type, int multi_id = 0, int det_id = 0,
|
||||
bool verify = true);
|
||||
|
||||
/**
|
||||
@ -198,12 +200,12 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
* @param verify true to verify if shared memory version matches existing
|
||||
* one
|
||||
*/
|
||||
explicit slsDetector(int multi_id = 0, int det_id = 0, bool verify = true);
|
||||
explicit Module(int multi_id = 0, int det_id = 0, bool verify = true);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~slsDetector();
|
||||
virtual ~Module();
|
||||
|
||||
/**
|
||||
* Returns false if it cannot get fixed pattern from an old version of shm
|
||||
@ -235,7 +237,7 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
/**
|
||||
* Free shared memory and delete shared memory structure
|
||||
* occupied by the sharedSlsDetector structure
|
||||
* Is only safe to call if one deletes the slsDetector object afterward
|
||||
* Is only safe to call if one deletes the Module object afterward
|
||||
* and frees multi shared memory/updates
|
||||
* thisMultiDetector->numberOfDetectors
|
||||
*/
|
||||
@ -2083,9 +2085,11 @@ class slsDetector : public virtual slsDetectorDefs {
|
||||
*/
|
||||
std::vector<std::string> getSettingsFileDacNames();
|
||||
|
||||
/** slsDetector Id or position in the detectors list */
|
||||
/** Module Id or position in the detectors list */
|
||||
const int detId;
|
||||
|
||||
/** Shared Memory object */
|
||||
mutable sls::SharedMemory<sharedSlsDetector> shm{0, 0};
|
||||
};
|
||||
|
||||
}// sls
|
Loading…
x
Reference in New Issue
Block a user