mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-29 17:40:01 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
commit
786b14e88b
@ -119,9 +119,10 @@ class Detector(CppDetectorApi):
|
|||||||
return NotImplementedError("parameters is set only")
|
return NotImplementedError("parameters is set only")
|
||||||
|
|
||||||
@parameters.setter
|
@parameters.setter
|
||||||
def parameters(self, fname):
|
def parameters(self, value):
|
||||||
fname = ut.make_string_path(fname)
|
if isinstance(value, str):
|
||||||
self.loadParameters(fname)
|
value = ut.make_string_path(value)
|
||||||
|
self.loadParameters(value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hostname(self):
|
def hostname(self):
|
||||||
@ -873,6 +874,8 @@ class Detector(CppDetectorApi):
|
|||||||
|
|
||||||
@ratecorr.setter
|
@ratecorr.setter
|
||||||
def ratecorr(self, tau):
|
def ratecorr(self, tau):
|
||||||
|
if isinstance(tau, int):
|
||||||
|
tau = float(tau)
|
||||||
self.setRateCorrection(tau)
|
self.setRateCorrection(tau)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -36,6 +36,10 @@ void init_det(py::module &m) {
|
|||||||
(void (Detector::*)(const std::string &)) &
|
(void (Detector::*)(const std::string &)) &
|
||||||
Detector::loadParameters,
|
Detector::loadParameters,
|
||||||
py::arg())
|
py::arg())
|
||||||
|
.def("loadParameters",
|
||||||
|
(void (Detector::*)(const std::vector<std::string> &)) &
|
||||||
|
Detector::loadParameters,
|
||||||
|
py::arg())
|
||||||
.def("getHostname",
|
.def("getHostname",
|
||||||
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
(Result<std::string>(Detector::*)(sls::Positions) const) &
|
||||||
Detector::getHostname,
|
Detector::getHostname,
|
||||||
|
@ -53,6 +53,8 @@ class Detector {
|
|||||||
/** Shared memory not freed prior. Set up per measurement. */
|
/** Shared memory not freed prior. Set up per measurement. */
|
||||||
void loadParameters(const std::string &fname);
|
void loadParameters(const std::string &fname);
|
||||||
|
|
||||||
|
void loadParameters(const std::vector<std::string>& parameters);
|
||||||
|
|
||||||
Result<std::string> getHostname(Positions pos = {}) const;
|
Result<std::string> getHostname(Positions pos = {}) const;
|
||||||
|
|
||||||
/* Frees shared memory, adds detectors to the list */
|
/* Frees shared memory, adds detectors to the list */
|
||||||
|
@ -60,29 +60,31 @@ void Detector::loadConfig(const std::string &fname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Detector::loadParameters(const std::string &fname) {
|
void Detector::loadParameters(const std::string &fname) {
|
||||||
CmdProxy proxy(this);
|
std::ifstream input_file(fname);
|
||||||
CmdParser parser;
|
if (!input_file) {
|
||||||
std::ifstream input_file;
|
|
||||||
input_file.open(fname.c_str(), std::ios_base::in);
|
|
||||||
if (!input_file.is_open()) {
|
|
||||||
throw RuntimeError("Could not open configuration file " + fname +
|
throw RuntimeError("Could not open configuration file " + fname +
|
||||||
" for reading");
|
" for reading");
|
||||||
}
|
}
|
||||||
std::string current_line;
|
std::vector<std::string> parameters;
|
||||||
while (input_file.good()) {
|
for (std::string line; std::getline(input_file, line);) {
|
||||||
getline(input_file, current_line);
|
if (line.find('#') != std::string::npos) {
|
||||||
if (current_line.find('#') != std::string::npos) {
|
line.erase(line.find('#'));
|
||||||
current_line.erase(current_line.find('#'));
|
|
||||||
}
|
}
|
||||||
LOG(logDEBUG1) << "current_line after removing comments:\n\t"
|
if (line.length() > 1) {
|
||||||
<< current_line;
|
parameters.push_back(line);
|
||||||
if (current_line.length() > 1) {
|
|
||||||
parser.Parse(current_line);
|
|
||||||
proxy.Call(parser.command(), parser.arguments(),
|
|
||||||
parser.detector_id(), defs::PUT_ACTION);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input_file.close();
|
loadParameters(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::loadParameters(const std::vector<std::string> ¶meters) {
|
||||||
|
CmdProxy proxy(this);
|
||||||
|
CmdParser parser;
|
||||||
|
for (const auto ¤t_line : parameters) {
|
||||||
|
parser.Parse(current_line);
|
||||||
|
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
||||||
|
defs::PUT_ACTION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<std::string> Detector::getHostname(Positions pos) const {
|
Result<std::string> Detector::getHostname(Positions pos) const {
|
||||||
|
@ -1863,7 +1863,7 @@ std::vector<int> Module::getReceiverDbitList() const {
|
|||||||
F_GET_RECEIVER_DBIT_LIST);
|
F_GET_RECEIVER_DBIT_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::setReceiverDbitList(const std::vector<int> &list) {
|
void Module::setReceiverDbitList(std::vector<int> list) {
|
||||||
LOG(logDEBUG1) << "Setting Receiver Dbit List";
|
LOG(logDEBUG1) << "Setting Receiver Dbit List";
|
||||||
if (list.size() > 64) {
|
if (list.size() > 64) {
|
||||||
throw sls::RuntimeError("Dbit list size cannot be greater than 64\n");
|
throw sls::RuntimeError("Dbit list size cannot be greater than 64\n");
|
||||||
@ -1874,6 +1874,10 @@ void Module::setReceiverDbitList(const std::vector<int> &list) {
|
|||||||
"Dbit list value must be between 0 and 63\n");
|
"Dbit list value must be between 0 and 63\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::sort(begin(list), end(list));
|
||||||
|
auto last = std::unique(begin(list), end(list));
|
||||||
|
list.erase(last, list.end());
|
||||||
|
|
||||||
sls::StaticVector<int, MAX_RX_DBIT> arg = list;
|
sls::StaticVector<int, MAX_RX_DBIT> arg = list;
|
||||||
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
sendToReceiver(F_SET_RECEIVER_DBIT_LIST, arg, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
bool getExternalSampling() const;
|
bool getExternalSampling() const;
|
||||||
void setExternalSampling(bool value);
|
void setExternalSampling(bool value);
|
||||||
std::vector<int> getReceiverDbitList() const;
|
std::vector<int> getReceiverDbitList() const;
|
||||||
void setReceiverDbitList(const std::vector<int> &list);
|
void setReceiverDbitList(std::vector<int> list);
|
||||||
int getReceiverDbitOffset() const;
|
int getReceiverDbitOffset() const;
|
||||||
void setReceiverDbitOffset(int value);
|
void setReceiverDbitOffset(int value);
|
||||||
void setDigitalIODelay(uint64_t pinMask, int delay);
|
void setDigitalIODelay(uint64_t pinMask, int delay);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user