mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 08:17:13 +02:00
Merge branch 'refactor' of github.com:slsdetectorgroup/slsDetectorPackage into refactor
This commit is contained in:
@ -8,6 +8,8 @@
|
||||
#include "slsDetector.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "utilities.h"
|
||||
#include "detectorData.h"
|
||||
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
@ -2107,19 +2109,9 @@ int multiSlsDetector::writeAdcRegister(int addr, int val, int detPos) {
|
||||
return detectors[detPos]->writeAdcRegister(addr, val);
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::writeAdcRegister, addr, val);
|
||||
if (sls::allEqual(r))
|
||||
return r.front();
|
||||
|
||||
// can't have different values
|
||||
FILE_LOG(logERROR)
|
||||
<< "Error: Different Values for function writeAdcRegister "
|
||||
"(write 0x"
|
||||
<< std::hex << val << " to addr 0x" << std::hex << addr << std::dec
|
||||
<< ")";
|
||||
setErrorMask(getErrorMask() | MULTI_HAVE_DIFFERENT_VALUES);
|
||||
return -1;
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::writeAdcRegister, addr, val);
|
||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||
}
|
||||
|
||||
int multiSlsDetector::activate(int const enable, int detPos) {
|
||||
@ -2356,62 +2348,50 @@ int multiSlsDetector::setAutoComparatorDisableMode(int ival, int detPos) {
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::getChanRegs(double *retval, bool fromDetector,
|
||||
int detPos) {
|
||||
int multiSlsDetector::getChanRegs(double* retval, int detPos) {
|
||||
|
||||
int offset = 0;
|
||||
std::vector<int> r;
|
||||
for (auto &d : detectors) {
|
||||
int nch = d->getTotalNumberOfChannels();
|
||||
double result[nch];
|
||||
r.push_back(d->getChanRegs(result, fromDetector));
|
||||
memcpy(retval + offset, result, nch * sizeof(double));
|
||||
}
|
||||
return sls::minusOneIfDifferent(r);
|
||||
int offset = 0;
|
||||
std::vector<int> r;
|
||||
for (auto& d : detectors) {
|
||||
int nch = d->getTotalNumberOfChannels();
|
||||
double result[nch];
|
||||
r.push_back(d->getChanRegs(result));
|
||||
memcpy(retval + offset, result, nch * sizeof(double));
|
||||
}
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::calibratePedestal(int frames, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->calibratePedestal(frames);
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::calibratePedestal, frames);
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::setRateCorrection(int t, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->setRateCorrection(t);
|
||||
}
|
||||
int multiSlsDetector::setRateCorrection(int64_t t, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->setRateCorrection(t);
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::setRateCorrection, t);
|
||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||
}
|
||||
|
||||
int multiSlsDetector::getRateCorrection(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getRateCorrection();
|
||||
}
|
||||
int64_t multiSlsDetector::getRateCorrection(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getRateCorrection();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::getRateCorrection);
|
||||
return sls::minusOneIfDifferent(r);
|
||||
}
|
||||
|
||||
int multiSlsDetector::printReceiverConfiguration(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->printReceiverConfiguration();
|
||||
}
|
||||
void multiSlsDetector::printReceiverConfiguration(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->printReceiverConfiguration();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::printReceiverConfiguration);
|
||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||
// multi
|
||||
for (auto& d : detectors)
|
||||
d->printReceiverConfiguration();
|
||||
}
|
||||
|
||||
int multiSlsDetector::setReceiverOnline(int off, int detPos) {
|
||||
@ -3768,4 +3748,4 @@ bool multiSlsDetector::isDetectorIndexOutOfBounds(int detPos) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,10 @@
|
||||
* @short This is the base class for multi detector system functionalities
|
||||
* @author Anna Bergamaschi
|
||||
*/
|
||||
|
||||
#include "error_defs.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "error_defs.h"
|
||||
#include "logger.h"
|
||||
|
||||
|
||||
class slsDetector;
|
||||
class SharedMemory;
|
||||
@ -230,21 +231,6 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
||||
*/
|
||||
int64_t getId(idMode mode, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Get sls detector object from position in detectors array
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns pointer to sls detector object
|
||||
*/
|
||||
// slsDetector* getSlsDetector(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Accessing the sls detector from the multi list using position
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns slsDetector object
|
||||
*/
|
||||
// slsDetector *operator()(int detPos = -1) const;
|
||||
|
||||
// slsDetector* operator[](int detPos) const;
|
||||
/**
|
||||
* Free shared memory from the command line
|
||||
* avoiding creating the constructor classes and mapping
|
||||
@ -1192,48 +1178,36 @@ class multiSlsDetector : public virtual slsDetectorDefs,
|
||||
*/
|
||||
int setAutoComparatorDisableMode(int ival = -1, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Returns the trimbits from the detector's shared memmory (Mythen, Eiger)
|
||||
* @param retval is the array with the trimbits
|
||||
* @param fromDetector is true if the trimbits shared memory have to be
|
||||
* uploaded from detector
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns total number of channels for the detector
|
||||
*/
|
||||
int getChanRegs(double *retval, bool fromDetector, int detPos = -1);
|
||||
/**
|
||||
* Returns the trimbits from the detector's shared memmory (Mythen, Eiger)
|
||||
* @param retval is the array with the trimbits
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns total number of channels for the detector
|
||||
*/
|
||||
int getChanRegs(double* retval, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Calibrate Pedestal (ChipTestBoard)
|
||||
* Starts acquisition, calibrates pedestal and writes to fpga
|
||||
* @param frames number of frames
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns number of frames
|
||||
*/
|
||||
int calibratePedestal(int frames = 0, int detPos = -1);
|
||||
/**
|
||||
* Set Rate correction ( Eiger)
|
||||
* @param t dead time in ns - if 0 disable correction,
|
||||
* if >0 set dead time to t, if < 0 set deadtime to default dead time
|
||||
* for current settings
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns 0 if rate correction disabled, >0 otherwise
|
||||
*/
|
||||
int setRateCorrection(int64_t t = 0, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Set Rate correction ( Eiger)
|
||||
* @param t dead time in ns - if 0 disable correction,
|
||||
* if >0 set dead time to t, if < 0 set deadtime to default dead time
|
||||
* for current settings
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns 0 if rate correction disabled, >0 otherwise
|
||||
*/
|
||||
int setRateCorrection(int t = 0, int detPos = -1);
|
||||
/**
|
||||
* Get rate correction ( Eiger)
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns 0 if rate correction disabled, > 0 otherwise (ns)
|
||||
*/
|
||||
int64_t getRateCorrection(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Get rate correction ( Eiger)
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns 0 if rate correction disabled, > 0 otherwise (ns)
|
||||
*/
|
||||
int getRateCorrection(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Prints receiver configuration
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int printReceiverConfiguration(int detPos = -1);
|
||||
/**
|
||||
* Prints receiver configuration
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
*/
|
||||
void printReceiverConfiguration(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Sets up receiver socket if online and sets the flag
|
||||
|
Reference in New Issue
Block a user