mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 14:38:14 +02:00
removed create and delete module
This commit is contained in:
parent
ee20cfab1e
commit
849d3ba049
@ -1488,13 +1488,6 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
|||||||
*/
|
*/
|
||||||
int setAutoComparatorDisableMode(int ival = -1, int detPos = -1);
|
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 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);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Rate correction ( Eiger)
|
* Set Rate correction ( Eiger)
|
||||||
|
@ -1305,12 +1305,12 @@ class slsDetector : public virtual slsDetectorDefs{
|
|||||||
*/
|
*/
|
||||||
int setAutoComparatorDisableMode(int ival = -1);
|
int setAutoComparatorDisableMode(int ival = -1);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the trimbits from the detector's shared memmory (Eiger)
|
* Get trimbit filename with path for settings and energy
|
||||||
* @param retval is the array with the trimbits
|
*
|
||||||
* @returns total number of channels for the detector
|
|
||||||
*/
|
*/
|
||||||
int getChanRegs(double *retval);
|
std::string getTrimbitFilename(detectorSettings settings, int e_eV);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure Module (Eiger)
|
* Configure Module (Eiger)
|
||||||
@ -1327,7 +1327,7 @@ class slsDetector : public virtual slsDetectorDefs{
|
|||||||
* Get module structure from detector (all detectors)
|
* Get module structure from detector (all detectors)
|
||||||
* @returns pointer to module structure (which has been created and must then be deleted)
|
* @returns pointer to module structure (which has been created and must then be deleted)
|
||||||
*/
|
*/
|
||||||
sls_detector_module *getModule();
|
sls_detector_module getModule();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Rate correction (Eiger)
|
* Set Rate correction (Eiger)
|
||||||
@ -1742,27 +1742,6 @@ class slsDetector : public virtual slsDetectorDefs{
|
|||||||
*/
|
*/
|
||||||
void initializeDetectorStructure(detectorType type);
|
void initializeDetectorStructure(detectorType type);
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocates the memory for a sls_detector_module structure and initializes it
|
|
||||||
* Uses current detector type
|
|
||||||
* @returns myMod the pointer to the allocate memory location
|
|
||||||
*/
|
|
||||||
sls_detector_module *createModule();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allocates the memory for a sls_detector_module structure and initializes it
|
|
||||||
* Has detector type
|
|
||||||
* @param type detector type
|
|
||||||
* @returns myMod the pointer to the allocate dmemory location
|
|
||||||
*/
|
|
||||||
sls_detector_module *createModule(detectorType type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Frees the memory for a sls_detector_module structure
|
|
||||||
* @param myMod the pointer to the memory to be freed
|
|
||||||
*/
|
|
||||||
void deleteModule(sls_detector_module *myMod);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a sls_detector_module structure over socket
|
* Send a sls_detector_module structure over socket
|
||||||
* @param myMod module structure to send
|
* @param myMod module structure to send
|
||||||
@ -1818,7 +1797,7 @@ class slsDetector : public virtual slsDetectorDefs{
|
|||||||
* @returns the pointer to myMod or NULL if reading the file failed
|
* @returns the pointer to myMod or NULL if reading the file failed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sls_detector_module *readSettingsFile(const std::string &fname, sls_detector_module *myMod = nullptr, int tb = 1);
|
sls_detector_module readSettingsFile(const std::string &fname, int tb = 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* writes a trim/settings file
|
* writes a trim/settings file
|
||||||
|
@ -2729,18 +2729,6 @@ int multiSlsDetector::setAutoComparatorDisableMode(int ival, int detPos) {
|
|||||||
return sls::minusOneIfDifferent(r);
|
return sls::minusOneIfDifferent(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
|
||||||
memcpy(retval + offset, result, nch * sizeof(double));
|
|
||||||
}
|
|
||||||
return sls::minusOneIfDifferent(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
int multiSlsDetector::setRateCorrection(int64_t t, int detPos) {
|
int multiSlsDetector::setRateCorrection(int64_t t, int detPos) {
|
||||||
// single
|
// single
|
||||||
|
@ -368,37 +368,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sls_detector_module *slsDetector::createModule() {
|
|
||||||
return createModule(detector_shm()->myDetectorType);
|
|
||||||
}
|
|
||||||
|
|
||||||
sls_detector_module *
|
|
||||||
slsDetector::createModule(detectorType type) {
|
|
||||||
// get the detector parameters based on type
|
|
||||||
detParameters parameters{type};
|
|
||||||
int nch = parameters.nChanX * parameters.nChanY;
|
|
||||||
int nc = parameters.nChipX * parameters.nChipY;
|
|
||||||
int nd = parameters.nDacs;
|
|
||||||
|
|
||||||
int *dacs = new int[nd];
|
|
||||||
int *chanregs = new int[nch * nc];
|
|
||||||
|
|
||||||
auto *myMod = new sls_detector_module;
|
|
||||||
myMod->ndac = nd;
|
|
||||||
myMod->nchip = nc;
|
|
||||||
myMod->nchan = nch * nc;
|
|
||||||
myMod->dacs = dacs;
|
|
||||||
myMod->chanregs = chanregs;
|
|
||||||
return myMod;
|
|
||||||
}
|
|
||||||
|
|
||||||
void slsDetector::deleteModule(sls_detector_module *myMod) {
|
|
||||||
if (myMod != nullptr) {
|
|
||||||
delete[] myMod->dacs;
|
|
||||||
delete[] myMod->chanregs;
|
|
||||||
delete myMod;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int slsDetector::sendModule(sls_detector_module *myMod,
|
int slsDetector::sendModule(sls_detector_module *myMod,
|
||||||
sls::ClientSocket &client) {
|
sls::ClientSocket &client) {
|
||||||
@ -1235,34 +1204,6 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV,
|
|||||||
detectorSettings is =
|
detectorSettings is =
|
||||||
((isettings != GET_SETTINGS) ? isettings
|
((isettings != GET_SETTINGS) ? isettings
|
||||||
: detector_shm()->currentSettings);
|
: detector_shm()->currentSettings);
|
||||||
std::string ssettings;
|
|
||||||
switch (is) {
|
|
||||||
case STANDARD:
|
|
||||||
ssettings = "/standard";
|
|
||||||
detector_shm()->currentSettings = STANDARD;
|
|
||||||
break;
|
|
||||||
case HIGHGAIN:
|
|
||||||
ssettings = "/highgain";
|
|
||||||
detector_shm()->currentSettings = HIGHGAIN;
|
|
||||||
break;
|
|
||||||
case LOWGAIN:
|
|
||||||
ssettings = "/lowgain";
|
|
||||||
detector_shm()->currentSettings = LOWGAIN;
|
|
||||||
break;
|
|
||||||
case VERYHIGHGAIN:
|
|
||||||
ssettings = "/veryhighgain";
|
|
||||||
detector_shm()->currentSettings = VERYHIGHGAIN;
|
|
||||||
break;
|
|
||||||
case VERYLOWGAIN:
|
|
||||||
ssettings = "/verylowgain";
|
|
||||||
detector_shm()->currentSettings = VERYLOWGAIN;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
std::ostringstream ss;
|
|
||||||
ss << "Unknown settings " << getDetectorSettings(is)
|
|
||||||
<< " for this detector!";
|
|
||||||
throw RuntimeError(ss.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify e_eV exists in trimEneregies[]
|
// verify e_eV exists in trimEneregies[]
|
||||||
if ((detector_shm()->nTrimEn == 0) ||
|
if ((detector_shm()->nTrimEn == 0) ||
|
||||||
@ -1272,28 +1213,18 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV,
|
|||||||
" not defined for this module!");
|
" not defined for this module!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// find if interpolation required
|
|
||||||
bool interpolate = true;
|
|
||||||
for (int i = 0; i < detector_shm()->nTrimEn; ++i) {
|
|
||||||
if (detector_shm()->trimEnergies[i] == e_eV) {
|
|
||||||
interpolate = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sls_detector_module myMod{detector_shm()->myDetectorType};
|
|
||||||
// normal
|
|
||||||
if (interpolate == false) {
|
|
||||||
// find their directory names
|
|
||||||
std::ostringstream ostfn;
|
|
||||||
ostfn << detector_shm()->settingsDir << ssettings << "/" << e_eV << "eV"
|
|
||||||
<< "/noise.sn" << std::setfill('0') << std::setw(3) << std::dec
|
|
||||||
<< getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10);
|
|
||||||
std::string settingsfname = ostfn.str();
|
|
||||||
FILE_LOG(logDEBUG1) << "Settings File is " << settingsfname;
|
|
||||||
|
|
||||||
if (readSettingsFile(settingsfname, &myMod, tb) == nullptr) {
|
bool interpolate =
|
||||||
return FAIL;
|
std::all_of(detector_shm()->trimEnergies,
|
||||||
}
|
detector_shm()->trimEnergies + detector_shm()->nTrimEn,
|
||||||
|
[e_eV](const int &e) { return e != e_eV; });
|
||||||
|
|
||||||
|
sls_detector_module myMod{detector_shm()->myDetectorType};
|
||||||
|
|
||||||
|
if (!interpolate) {
|
||||||
|
std::string settingsfname = getTrimbitFilename(is, e_eV);
|
||||||
|
FILE_LOG(logDEBUG1) << "Settings File is " << settingsfname;
|
||||||
|
myMod = readSettingsFile(settingsfname, tb);
|
||||||
}else{
|
}else{
|
||||||
// find the trim values
|
// find the trim values
|
||||||
int trim1 = -1, trim2 = -1;
|
int trim1 = -1, trim2 = -1;
|
||||||
@ -1304,47 +1235,23 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// find their directory names
|
std::string settingsfname1 = getTrimbitFilename(is, trim1);
|
||||||
std::ostringstream ostfn;
|
std::string settingsfname2 = getTrimbitFilename(is, trim2);
|
||||||
ostfn << detector_shm()->settingsDir << ssettings << "/" << trim1
|
|
||||||
<< "eV"
|
|
||||||
<< "/noise.sn" << std::setfill('0') << std::setw(3) << std::dec
|
|
||||||
<< getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10);
|
|
||||||
std::string settingsfname1 = ostfn.str();
|
|
||||||
ostfn.str("");
|
|
||||||
ostfn.clear();
|
|
||||||
ostfn << detector_shm()->settingsDir << ssettings << "/" << trim2
|
|
||||||
<< "eV"
|
|
||||||
<< "/noise.sn" << std::setfill('0') << std::setw(3) << std::dec
|
|
||||||
<< getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10);
|
|
||||||
std::string settingsfname2 = ostfn.str();
|
|
||||||
// read the files
|
|
||||||
FILE_LOG(logDEBUG1) << "Settings Files are " << settingsfname1
|
FILE_LOG(logDEBUG1) << "Settings Files are " << settingsfname1
|
||||||
<< " and " << settingsfname2;
|
<< " and " << settingsfname2;
|
||||||
sls_detector_module myMod1{detector_shm()->myDetectorType};
|
auto myMod1 = readSettingsFile(settingsfname1, tb);
|
||||||
sls_detector_module myMod2{detector_shm()->myDetectorType};
|
auto myMod2 = readSettingsFile(settingsfname2, tb);
|
||||||
if (readSettingsFile(settingsfname1, &myMod1, tb) == nullptr) {
|
|
||||||
throw RuntimeError(
|
|
||||||
"setThresholdEnergyAndSettings: Could not open settings file");
|
|
||||||
}
|
|
||||||
if (readSettingsFile(settingsfname2, &myMod2, tb) == nullptr) {
|
|
||||||
throw RuntimeError(
|
|
||||||
"setThresholdEnergyAndSettings: Could not open settings file");
|
|
||||||
}
|
|
||||||
if (myMod1.iodelay != myMod2.iodelay) {
|
if (myMod1.iodelay != myMod2.iodelay) {
|
||||||
throw RuntimeError("setThresholdEnergyAndSettings: Iodelays do not "
|
throw RuntimeError("setThresholdEnergyAndSettings: Iodelays do not "
|
||||||
"match between files");
|
"match between files");
|
||||||
}
|
}
|
||||||
|
|
||||||
// interpolate module
|
|
||||||
myMod = interpolateTrim(&myMod1, &myMod2, e_eV, trim1, trim2, tb);
|
myMod = interpolateTrim(&myMod1, &myMod2, e_eV, trim1, trim2, tb);
|
||||||
|
|
||||||
// // interpolate tau
|
|
||||||
myMod.iodelay = myMod1.iodelay;
|
myMod.iodelay = myMod1.iodelay;
|
||||||
myMod.tau =
|
myMod.tau =
|
||||||
linearInterpolation(e_eV, trim1, trim2, myMod1.tau, myMod2.tau);
|
linearInterpolation(e_eV, trim1, trim2, myMod1.tau, myMod2.tau);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
detector_shm()->currentSettings = is;
|
||||||
myMod.reg = detector_shm()->currentSettings;
|
myMod.reg = detector_shm()->currentSettings;
|
||||||
myMod.eV = e_eV;
|
myMod.eV = e_eV;
|
||||||
setModule(myMod, tb);
|
setModule(myMod, tb);
|
||||||
@ -1355,6 +1262,37 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string slsDetector::getTrimbitFilename(detectorSettings s, int e_eV){
|
||||||
|
std::string ssettings;
|
||||||
|
switch (s) {
|
||||||
|
case STANDARD:
|
||||||
|
ssettings = "/standard";
|
||||||
|
break;
|
||||||
|
case HIGHGAIN:
|
||||||
|
ssettings = "/highgain";
|
||||||
|
break;
|
||||||
|
case LOWGAIN:
|
||||||
|
ssettings = "/lowgain";
|
||||||
|
break;
|
||||||
|
case VERYHIGHGAIN:
|
||||||
|
ssettings = "/veryhighgain";
|
||||||
|
break;
|
||||||
|
case VERYLOWGAIN:
|
||||||
|
ssettings = "/verylowgain";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::ostringstream ss;
|
||||||
|
ss << "Unknown settings " << getDetectorSettings(s)
|
||||||
|
<< " for this detector!";
|
||||||
|
throw RuntimeError(ss.str());
|
||||||
|
}
|
||||||
|
std::ostringstream ostfn;
|
||||||
|
ostfn << detector_shm()->settingsDir << ssettings << "/" << e_eV << "eV"
|
||||||
|
<< "/noise.sn" << std::setfill('0') << std::setw(3) << std::dec
|
||||||
|
<< getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10);
|
||||||
|
return ostfn.str();
|
||||||
|
}
|
||||||
|
|
||||||
std::string slsDetector::getSettingsDir() {
|
std::string slsDetector::getSettingsDir() {
|
||||||
return std::string(detector_shm()->settingsDir);
|
return std::string(detector_shm()->settingsDir);
|
||||||
}
|
}
|
||||||
@ -1379,19 +1317,8 @@ int slsDetector::loadSettingsFile(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn = ostfn.str();
|
fn = ostfn.str();
|
||||||
|
auto myMod = readSettingsFile(fn);
|
||||||
// read settings file
|
int ret = setModule(myMod);
|
||||||
sls_detector_module *myMod = nullptr;
|
|
||||||
myMod = readSettingsFile(fn, myMod);
|
|
||||||
|
|
||||||
// set module
|
|
||||||
int ret = FAIL;
|
|
||||||
if (myMod != nullptr) {
|
|
||||||
myMod->reg = -1;
|
|
||||||
myMod->eV = -1;
|
|
||||||
ret = setModule(*myMod);
|
|
||||||
deleteModule(myMod);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1406,14 +1333,8 @@ int slsDetector::saveSettingsFile(const std::string &fname) {
|
|||||||
<< getId(DETECTOR_SERIAL_NUMBER);
|
<< getId(DETECTOR_SERIAL_NUMBER);
|
||||||
}
|
}
|
||||||
fn = ostfn.str();
|
fn = ostfn.str();
|
||||||
|
sls_detector_module myMod = getModule();
|
||||||
// get module
|
int ret = writeSettingsFile(fn, myMod);
|
||||||
int ret = FAIL;
|
|
||||||
sls_detector_module *myMod = getModule();
|
|
||||||
if (myMod != nullptr) {
|
|
||||||
ret = writeSettingsFile(fn, *myMod);
|
|
||||||
deleteModule(myMod);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3625,23 +3546,6 @@ int slsDetector::setAutoComparatorDisableMode(int ival) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsDetector::getChanRegs(double *retval) {
|
|
||||||
int n = getTotalNumberOfChannels();
|
|
||||||
// update chanregs
|
|
||||||
sls_detector_module *myMod = getModule();
|
|
||||||
|
|
||||||
if (myMod != nullptr) {
|
|
||||||
// the original array has 0 initialized
|
|
||||||
if (myMod->chanregs != nullptr) {
|
|
||||||
for (int i = 0; i < n; ++i) {
|
|
||||||
retval[i] =
|
|
||||||
static_cast<double>(myMod->chanregs[i] & TRIMBITMASK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
deleteModule(myMod);
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int slsDetector::setModule(sls_detector_module& module, int tb) {
|
int slsDetector::setModule(sls_detector_module& module, int tb) {
|
||||||
int fnum = F_SET_MODULE;
|
int fnum = F_SET_MODULE;
|
||||||
@ -3682,27 +3586,24 @@ int slsDetector::setModule(sls_detector_module& module, int tb) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
sls_detector_module *slsDetector::getModule() {
|
sls_detector_module slsDetector::getModule() {
|
||||||
int fnum = F_GET_MODULE;
|
int fnum = F_GET_MODULE;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
FILE_LOG(logDEBUG1) << "Getting module";
|
FILE_LOG(logDEBUG1) << "Getting module";
|
||||||
|
|
||||||
sls_detector_module *myMod = createModule();
|
sls_detector_module myMod{detector_shm()->myDetectorType};
|
||||||
if (myMod == nullptr) {
|
|
||||||
throw RuntimeError("Could not create module");
|
|
||||||
}
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
auto client = DetectorSocket(detector_shm()->hostname,
|
||||||
detector_shm()->controlPort);
|
detector_shm()->controlPort);
|
||||||
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
ret = client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0);
|
||||||
receiveModule(myMod, client);
|
receiveModule(&myMod, client);
|
||||||
}
|
}
|
||||||
if (ret == FORCE_UPDATE) {
|
if (ret == FORCE_UPDATE) {
|
||||||
ret = updateDetector();
|
ret = updateDetector();
|
||||||
}
|
}
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
if (myMod->eV != -1) {
|
if (myMod.eV != -1) {
|
||||||
detector_shm()->currentThresholdEV = myMod->eV;
|
detector_shm()->currentThresholdEV = myMod.eV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return myMod;
|
return myMod;
|
||||||
@ -4856,20 +4757,11 @@ slsDetector::interpolateTrim(sls_detector_module *a, sls_detector_module *b,
|
|||||||
return myMod;
|
return myMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
sls_detector_module *
|
sls_detector_module
|
||||||
slsDetector::readSettingsFile(const std::string &fname,
|
slsDetector::readSettingsFile(const std::string &fname, int tb) {
|
||||||
sls_detector_module *myMod, int tb) {
|
|
||||||
|
|
||||||
FILE_LOG(logDEBUG1) << "Read settings file " << fname;
|
FILE_LOG(logDEBUG1) << "Read settings file " << fname;
|
||||||
bool modCreated =
|
sls_detector_module myMod(detector_shm()->myDetectorType);
|
||||||
false; // If we create a module it must be deleted, TODO! usre RAII
|
|
||||||
if (myMod == nullptr) {
|
|
||||||
myMod = createModule(detector_shm()->myDetectorType);
|
|
||||||
if (myMod == nullptr) {
|
|
||||||
throw RuntimeError("Could not create module");
|
|
||||||
}
|
|
||||||
modCreated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
switch (detector_shm()->myDetectorType) {
|
switch (detector_shm()->myDetectorType) {
|
||||||
@ -4896,11 +4788,6 @@ slsDetector::readSettingsFile(const std::string &fname,
|
|||||||
names.emplace_back("VDAC7");
|
names.emplace_back("VDAC7");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (modCreated) {
|
|
||||||
if (myMod != nullptr) {
|
|
||||||
deleteModule(myMod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Unknown detector type - unknown format for settings file");
|
"Unknown detector type - unknown format for settings file");
|
||||||
}
|
}
|
||||||
@ -4913,9 +4800,6 @@ slsDetector::readSettingsFile(const std::string &fname,
|
|||||||
infile.open(fname.c_str(), std::ios_base::in);
|
infile.open(fname.c_str(), std::ios_base::in);
|
||||||
}
|
}
|
||||||
if (!infile.is_open()) {
|
if (!infile.is_open()) {
|
||||||
if (modCreated) {
|
|
||||||
deleteModule(myMod);
|
|
||||||
}
|
|
||||||
throw RuntimeError("Could not open settings file for reading: " +
|
throw RuntimeError("Could not open settings file for reading: " +
|
||||||
fname);
|
fname);
|
||||||
}
|
}
|
||||||
@ -4923,18 +4807,18 @@ slsDetector::readSettingsFile(const std::string &fname,
|
|||||||
// eiger
|
// eiger
|
||||||
if (detector_shm()->myDetectorType == EIGER) {
|
if (detector_shm()->myDetectorType == EIGER) {
|
||||||
bool allread = false;
|
bool allread = false;
|
||||||
infile.read(reinterpret_cast<char *>(myMod->dacs),
|
infile.read(reinterpret_cast<char *>(myMod.dacs),
|
||||||
sizeof(int) * (myMod->ndac));
|
sizeof(int) * (myMod.ndac));
|
||||||
if (infile.good()) {
|
if (infile.good()) {
|
||||||
infile.read(reinterpret_cast<char *>(&myMod->iodelay),
|
infile.read(reinterpret_cast<char *>(&myMod.iodelay),
|
||||||
sizeof(myMod->iodelay));
|
sizeof(myMod.iodelay));
|
||||||
if (infile.good()) {
|
if (infile.good()) {
|
||||||
infile.read(reinterpret_cast<char *>(&myMod->tau),
|
infile.read(reinterpret_cast<char *>(&myMod.tau),
|
||||||
sizeof(myMod->tau));
|
sizeof(myMod.tau));
|
||||||
if (tb != 0) {
|
if (tb != 0) {
|
||||||
if (infile.good()) {
|
if (infile.good()) {
|
||||||
infile.read(reinterpret_cast<char *>(myMod->chanregs),
|
infile.read(reinterpret_cast<char *>(myMod.chanregs),
|
||||||
sizeof(int) * (myMod->nchan));
|
sizeof(int) * (myMod.nchan));
|
||||||
if (infile) {
|
if (infile) {
|
||||||
allread = true;
|
allread = true;
|
||||||
}
|
}
|
||||||
@ -4945,19 +4829,16 @@ slsDetector::readSettingsFile(const std::string &fname,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!allread) {
|
if (!allread) {
|
||||||
if (modCreated) {
|
|
||||||
deleteModule(myMod);
|
|
||||||
}
|
|
||||||
infile.close();
|
infile.close();
|
||||||
throw RuntimeError("readSettingsFile: Could not load all values "
|
throw RuntimeError("readSettingsFile: Could not load all values "
|
||||||
"for settings for " +
|
"for settings for " +
|
||||||
fname);
|
fname);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < myMod->ndac; ++i) {
|
for (int i = 0; i < myMod.ndac; ++i) {
|
||||||
FILE_LOG(logDEBUG1) << "dac " << i << ":" << myMod->dacs[i];
|
FILE_LOG(logDEBUG1) << "dac " << i << ":" << myMod.dacs[i];
|
||||||
}
|
}
|
||||||
FILE_LOG(logDEBUG1) << "iodelay:" << myMod->iodelay;
|
FILE_LOG(logDEBUG1) << "iodelay:" << myMod.iodelay;
|
||||||
FILE_LOG(logDEBUG1) << "tau:" << myMod->tau;
|
FILE_LOG(logDEBUG1) << "tau:" << myMod.tau;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gotthard, jungfrau
|
// gotthard, jungfrau
|
||||||
@ -4977,7 +4858,7 @@ slsDetector::readSettingsFile(const std::string &fname,
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
for (size_t i = 0; i < names.size(); ++i) {
|
for (size_t i = 0; i < names.size(); ++i) {
|
||||||
if (sargname == names[i]) {
|
if (sargname == names[i]) {
|
||||||
myMod->dacs[i] = ival;
|
myMod.dacs[i] = ival;
|
||||||
found = true;
|
found = true;
|
||||||
FILE_LOG(logDEBUG1)
|
FILE_LOG(logDEBUG1)
|
||||||
<< names[i] << "(" << i << "): " << ival;
|
<< names[i] << "(" << i << "): " << ival;
|
||||||
@ -4987,17 +4868,11 @@ slsDetector::readSettingsFile(const std::string &fname,
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
throw RuntimeError("readSettingsFile: Unknown dac: " +
|
throw RuntimeError("readSettingsFile: Unknown dac: " +
|
||||||
sargname);
|
sargname);
|
||||||
if (modCreated) {
|
|
||||||
deleteModule(myMod);
|
|
||||||
}
|
|
||||||
infile.close();
|
infile.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not all read
|
// not all read
|
||||||
if (idac != names.size()) {
|
if (idac != names.size()) {
|
||||||
if (modCreated) {
|
|
||||||
deleteModule(myMod);
|
|
||||||
}
|
|
||||||
infile.close();
|
infile.close();
|
||||||
throw RuntimeError("Could read only " + std::to_string(idac) +
|
throw RuntimeError("Could read only " + std::to_string(idac) +
|
||||||
" dacs. Expected " +
|
" dacs. Expected " +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user