mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 07:20:01 +02:00
reorder read settings func
This commit is contained in:
parent
28bafb012a
commit
1998f9541e
@ -3555,7 +3555,6 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a,
|
|||||||
sls_detector_module Module::readSettingsFile(const std::string &fname, int tb) {
|
sls_detector_module Module::readSettingsFile(const std::string &fname, int tb) {
|
||||||
LOG(logDEBUG1) << "Read settings file " << fname;
|
LOG(logDEBUG1) << "Read settings file " << fname;
|
||||||
sls_detector_module myMod(shm()->myDetectorType);
|
sls_detector_module myMod(shm()->myDetectorType);
|
||||||
auto names = getSettingsFileDacNames();
|
|
||||||
// open file
|
// open file
|
||||||
std::ifstream infile;
|
std::ifstream infile;
|
||||||
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
||||||
@ -3609,6 +3608,7 @@ sls_detector_module Module::readSettingsFile(const std::string &fname, int tb) {
|
|||||||
|
|
||||||
// gotthard, jungfrau
|
// gotthard, jungfrau
|
||||||
else {
|
else {
|
||||||
|
auto names = getSettingsFileDacNames();
|
||||||
size_t idac = 0;
|
size_t idac = 0;
|
||||||
std::string str;
|
std::string str;
|
||||||
while (infile.good()) {
|
while (infile.good()) {
|
||||||
@ -3649,7 +3649,7 @@ sls_detector_module Module::readSettingsFile(const std::string &fname, int tb) {
|
|||||||
void Module::writeSettingsFile(const std::string &fname,
|
void Module::writeSettingsFile(const std::string &fname,
|
||||||
sls_detector_module &mod) {
|
sls_detector_module &mod) {
|
||||||
LOG(logDEBUG1) << "Write settings file " << fname;
|
LOG(logDEBUG1) << "Write settings file " << fname;
|
||||||
auto names = getSettingsFileDacNames();
|
|
||||||
std::ofstream outfile;
|
std::ofstream outfile;
|
||||||
if (shm()->myDetectorType == EIGER) {
|
if (shm()->myDetectorType == EIGER) {
|
||||||
outfile.open(fname.c_str(), std::ofstream::binary);
|
outfile.open(fname.c_str(), std::ofstream::binary);
|
||||||
@ -3677,6 +3677,7 @@ void Module::writeSettingsFile(const std::string &fname,
|
|||||||
}
|
}
|
||||||
// gotthard, jungfrau
|
// gotthard, jungfrau
|
||||||
else {
|
else {
|
||||||
|
auto names = getSettingsFileDacNames();
|
||||||
for (int i = 0; i < mod.ndac; ++i) {
|
for (int i = 0; i < mod.ndac; ++i) {
|
||||||
LOG(logDEBUG1) << "dac " << i << ": " << mod.dacs[i];
|
LOG(logDEBUG1) << "dac " << i << ": " << mod.dacs[i];
|
||||||
outfile << names[i] << " " << mod.dacs[i] << std::endl;
|
outfile << names[i] << " " << mod.dacs[i] << std::endl;
|
||||||
@ -3689,21 +3690,14 @@ std::vector<std::string> Module::getSettingsFileDacNames() {
|
|||||||
case GOTTHARD:
|
case GOTTHARD:
|
||||||
return {"Vref", "VcascN", "VcascP", "Vout",
|
return {"Vref", "VcascN", "VcascP", "Vout",
|
||||||
"Vcasc", "Vin", "Vref_comp", "Vib_test"};
|
"Vcasc", "Vin", "Vref_comp", "Vib_test"};
|
||||||
break;
|
|
||||||
case EIGER:
|
|
||||||
break;
|
|
||||||
case JUNGFRAU:
|
case JUNGFRAU:
|
||||||
return {"VDAC0", "VDAC1", "VDAC2", "VDAC3", "VDAC4", "VDAC5",
|
return {"VDAC0", "VDAC1", "VDAC2", "VDAC3", "VDAC4", "VDAC5",
|
||||||
"VDAC6", "VDAC7", "VDAC8", "VDAC9", "VDAC10", "VDAC11",
|
"VDAC6", "VDAC7", "VDAC8", "VDAC9", "VDAC10", "VDAC11",
|
||||||
"VDAC12", "VDAC13", "VDAC14", "VDAC15"};
|
"VDAC12", "VDAC13", "VDAC14", "VDAC15"};
|
||||||
break;
|
|
||||||
case MYTHEN3:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Unknown detector type - unknown format for settings file");
|
"Unknown detector type - unknown format for settings file");
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
@ -13,6 +13,7 @@ target_sources(tests PRIVATE
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-global.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-global.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-Result.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-Result.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdParser.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/test-CmdParser.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/test-Module.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(tests PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>")
|
target_include_directories(tests PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>")
|
8
slsDetectorSoftware/tests/test-Module.cpp
Normal file
8
slsDetectorSoftware/tests/test-Module.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "Module.h"
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
using dt = slsDetectorDefs::detectorType;
|
||||||
|
TEST_CASE("Construction with a defined detector type") {
|
||||||
|
sls::Module m(dt::EIGER);
|
||||||
|
REQUIRE(m.getDetectorType() == dt::EIGER);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user