mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
Fixed container (#19)
* added FixedCapacityContainer * added empty to FixedCapacityContainer * removed commented out section * added FixedCapacityContainer to public headers
This commit is contained in:

committed by
Dhanya Thattil

parent
0e0e7ea81f
commit
2a1c89f712
@ -6,12 +6,14 @@
|
||||
#include "logger.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include "network_utils.h"
|
||||
#include "FixedCapacityContainer.h"
|
||||
class ClientInterface;
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
|
||||
class multiSlsDetector;
|
||||
class ServerInterface;
|
||||
class MySocketTCP;
|
||||
@ -62,11 +64,8 @@ struct sharedSlsDetector {
|
||||
/** path of the trimbits/settings files */
|
||||
char settingsDir[MAX_STR_LENGTH];
|
||||
|
||||
/** number of energies at which the detector has been trimmed */
|
||||
int nTrimEn;
|
||||
|
||||
/** list of the energies at which the detector has been trimmed */
|
||||
int trimEnergies[MAX_TRIMEN];
|
||||
sls::FixedCapacityContainer<int, MAX_TRIMEN> trimEnergies;
|
||||
|
||||
/** number of channels per chip */
|
||||
int nChans;
|
||||
|
@ -300,10 +300,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
shm()->controlPort = DEFAULT_PORTNO;
|
||||
shm()->stopPort = DEFAULT_PORTNO + 1;
|
||||
sls::strcpy_safe(shm()->settingsDir, getenv("HOME"));
|
||||
shm()->nTrimEn = 0;
|
||||
for (int &trimEnergie : shm()->trimEnergies) {
|
||||
trimEnergie = 0;
|
||||
}
|
||||
shm()->nROI = 0;
|
||||
memset(shm()->roiLimits, 0, MAX_ROIS * sizeof(ROI));
|
||||
shm()->adcEnableMask = BIT32_MASK;
|
||||
@ -1166,14 +1162,14 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV,
|
||||
((isettings != GET_SETTINGS) ? isettings : shm()->currentSettings);
|
||||
|
||||
// verify e_eV exists in trimEneregies[]
|
||||
if ((shm()->nTrimEn == 0) || (e_eV < shm()->trimEnergies[0]) ||
|
||||
(e_eV > shm()->trimEnergies[shm()->nTrimEn - 1])) {
|
||||
if (shm()->trimEnergies.empty() || (e_eV < shm()->trimEnergies.front()) ||
|
||||
(e_eV > shm()->trimEnergies.back())) {
|
||||
throw RuntimeError("This energy " + std::to_string(e_eV) +
|
||||
" not defined for this module!");
|
||||
}
|
||||
|
||||
bool interpolate =
|
||||
std::all_of(shm()->trimEnergies, shm()->trimEnergies + shm()->nTrimEn,
|
||||
std::all_of(shm()->trimEnergies.begin(), shm()->trimEnergies.end(),
|
||||
[e_eV](const int &e) { return e != e_eV; });
|
||||
|
||||
sls_detector_module myMod{shm()->myDetectorType};
|
||||
@ -1185,7 +1181,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV,
|
||||
} else {
|
||||
// find the trim values
|
||||
int trim1 = -1, trim2 = -1;
|
||||
for (int i = 0; i < shm()->nTrimEn; ++i) {
|
||||
for (size_t i = 0; i < shm()->trimEnergies.size(); ++i) {
|
||||
if (e_eV < shm()->trimEnergies[i]) {
|
||||
trim2 = shm()->trimEnergies[i];
|
||||
trim1 = shm()->trimEnergies[i - 1];
|
||||
@ -2908,14 +2904,13 @@ int slsDetector::setTrimEn(std::vector<int> energies) {
|
||||
<< "\n";
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
std::copy(begin(energies), end(energies), shm()->trimEnergies);
|
||||
shm()->nTrimEn = energies.size();
|
||||
return shm()->nTrimEn;
|
||||
shm()->trimEnergies = energies;
|
||||
return shm()->trimEnergies.size();
|
||||
}
|
||||
|
||||
std::vector<int> slsDetector::getTrimEn() {
|
||||
return std::vector<int>(shm()->trimEnergies,
|
||||
shm()->trimEnergies + shm()->nTrimEn);
|
||||
return std::vector<int>(shm()->trimEnergies.begin(),
|
||||
shm()->trimEnergies.end());
|
||||
}
|
||||
|
||||
int slsDetector::pulsePixel(int n, int x, int y) {
|
||||
|
Reference in New Issue
Block a user