mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-21 03:10:02 +02:00
Merge branch 'developer' into fixtests
This commit is contained in:
commit
388b68829c
@ -1,10 +1,10 @@
|
|||||||
from slsdet import Detector, currentSrcParameters
|
from slsdet import Detector, currentSrcParameters
|
||||||
|
|
||||||
s = currentSrcParameters()
|
s = currentSrcParameters()
|
||||||
s.enable_ = 1
|
s.enable = 1
|
||||||
s.fix_= 1
|
s.fix= 1
|
||||||
s.normal_ = 1
|
s.normal = 1
|
||||||
s.select_ = 10
|
s.select = 10
|
||||||
|
|
||||||
|
|
||||||
d = Detector()
|
d = Detector()
|
||||||
|
@ -15,10 +15,10 @@ void init_source(py::module &m) {
|
|||||||
py::class_<src> currentSrcParameters(m, "currentSrcParameters");
|
py::class_<src> currentSrcParameters(m, "currentSrcParameters");
|
||||||
|
|
||||||
currentSrcParameters.def(py::init());
|
currentSrcParameters.def(py::init());
|
||||||
currentSrcParameters.def_readwrite("enable_", &src::enable_);
|
currentSrcParameters.def_readwrite("enable", &src::enable);
|
||||||
currentSrcParameters.def_readwrite("fix_", &src::fix_);
|
currentSrcParameters.def_readwrite("fix", &src::fix);
|
||||||
currentSrcParameters.def_readwrite("normal_", &src::normal_);
|
currentSrcParameters.def_readwrite("normal", &src::normal);
|
||||||
currentSrcParameters.def_readwrite("select_", &src::select_);
|
currentSrcParameters.def_readwrite("select", &src::select);
|
||||||
currentSrcParameters.def(pybind11::self == pybind11::self);
|
currentSrcParameters.def(pybind11::self == pybind11::self);
|
||||||
|
|
||||||
currentSrcParameters.def("__repr__",
|
currentSrcParameters.def("__repr__",
|
||||||
|
@ -20,7 +20,7 @@ TEST_CASE("Create SharedMemory read and write", "[detector]") {
|
|||||||
SharedMemory<Data> shm(shm_id, -1);
|
SharedMemory<Data> shm(shm_id, -1);
|
||||||
shm.CreateSharedMemory();
|
shm.CreateSharedMemory();
|
||||||
CHECK(shm.GetName() ==
|
CHECK(shm.GetName() ==
|
||||||
std::string("/slsDetectorPackage_multi_") + std::to_string(shm_id));
|
std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id));
|
||||||
|
|
||||||
shm()->x = 3;
|
shm()->x = 3;
|
||||||
shm()->y = 5.7;
|
shm()->y = 5.7;
|
||||||
@ -91,7 +91,7 @@ TEST_CASE("Move SharedMemory", "[detector]") {
|
|||||||
|
|
||||||
SharedMemory<Data> shm(shm_id, -1);
|
SharedMemory<Data> shm(shm_id, -1);
|
||||||
CHECK(shm.GetName() ==
|
CHECK(shm.GetName() ==
|
||||||
std::string("/slsDetectorPackage_multi_") + std::to_string(shm_id));
|
std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id));
|
||||||
shm.CreateSharedMemory();
|
shm.CreateSharedMemory();
|
||||||
shm()->x = 9;
|
shm()->x = 9;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ TEST_CASE("Move SharedMemory", "[detector]") {
|
|||||||
CHECK(shm.size() == 0);
|
CHECK(shm.size() == 0);
|
||||||
|
|
||||||
CHECK(shm2.GetName() ==
|
CHECK(shm2.GetName() ==
|
||||||
std::string("/slsDetectorPackage_multi_") + std::to_string(shm_id));
|
std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id));
|
||||||
shm2.RemoveSharedMemory();
|
shm2.RemoveSharedMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ TEST_CASE("Create several shared memories", "[detector]") {
|
|||||||
|
|
||||||
for (int i = 0; i != N; ++i) {
|
for (int i = 0; i != N; ++i) {
|
||||||
CHECK(*v[i]() == i);
|
CHECK(*v[i]() == i);
|
||||||
CHECK(v[i].GetName() == std::string("/slsDetectorPackage_multi_") +
|
CHECK(v[i].GetName() == std::string("/slsDetectorPackage_detector_") +
|
||||||
std::to_string(i + shm_id));
|
std::to_string(i + shm_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -462,36 +462,36 @@ typedef struct {
|
|||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
struct currentSrcParameters {
|
struct currentSrcParameters {
|
||||||
int enable_;
|
int enable;
|
||||||
int fix_;
|
int fix;
|
||||||
int normal_;
|
int normal;
|
||||||
uint64_t select_;
|
uint64_t select;
|
||||||
|
|
||||||
/** [Gotthard2][Jungfrau] disable */
|
/** [Gotthard2][Jungfrau] disable */
|
||||||
currentSrcParameters()
|
currentSrcParameters()
|
||||||
: enable_(0), fix_(-1), normal_(-1), select_(0) {}
|
: enable(0), fix(-1), normal(-1), select(0) {}
|
||||||
|
|
||||||
/** [Gotthard2] enable or disable */
|
/** [Gotthard2] enable or disable */
|
||||||
explicit currentSrcParameters(bool enable)
|
explicit currentSrcParameters(bool srcEnable)
|
||||||
: enable_(static_cast<int>(enable)), fix_(-1), normal_(-1),
|
: enable(static_cast<int>(srcEnable)), fix(-1), normal(-1),
|
||||||
select_(0) {}
|
select(0) {}
|
||||||
|
|
||||||
/** [Jungfrau](chipv1.0) enable current src with fix or no fix,
|
/** [Jungfrau](chipv1.0) enable current src with fix or no fix,
|
||||||
* select is 0 to 63 columns only */
|
* select is 0 to 63 columns only */
|
||||||
currentSrcParameters(bool fix, uint64_t select)
|
currentSrcParameters(bool fixCurrent, uint64_t selectCurrent)
|
||||||
: enable_(1), fix_(static_cast<int>(fix)), normal_(-1),
|
: enable(1), fix(static_cast<int>(fixCurrent)), normal(-1),
|
||||||
select_(select) {}
|
select(selectCurrent) {}
|
||||||
|
|
||||||
/** [Jungfrau](chipv1.1) enable current src, fix[fix|no fix],
|
/** [Jungfrau](chipv1.1) enable current src, fix[fix|no fix],
|
||||||
* select is a mask of 63 bits (muliple columns can be selected
|
* select is a mask of 63 bits (muliple columns can be selected
|
||||||
* simultaneously, normal [normal|low] */
|
* simultaneously, normal [normal|low] */
|
||||||
currentSrcParameters(bool fix, uint64_t select, bool normal)
|
currentSrcParameters(bool fixCurrent, uint64_t selectCurrent, bool normalCurrent)
|
||||||
: enable_(1), fix_(static_cast<int>(fix)),
|
: enable(1), fix(static_cast<int>(fixCurrent)),
|
||||||
normal_(static_cast<int>(normal)), select_(select) {}
|
normal(static_cast<int>(normalCurrent)), select(selectCurrent) {}
|
||||||
|
|
||||||
bool operator==(const currentSrcParameters &other) const {
|
bool operator==(const currentSrcParameters &other) const {
|
||||||
return ((enable_ == other.enable_) && (fix_ == other.fix_) &&
|
return ((enable == other.enable) && (fix == other.fix) &&
|
||||||
(normal_ == other.normal_) && (select_ == other.select_));
|
(normal == other.normal) && (select == other.select));
|
||||||
}
|
}
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
@ -116,25 +116,25 @@ std::ostream &operator<<(std::ostream &os,
|
|||||||
|
|
||||||
std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
|
std::string ToString(const slsDetectorDefs::currentSrcParameters &r) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
if (r.fix_ < -1 || r.fix_ > 1 || r.normal_ < -1 || r.normal_ > 1) {
|
if (r.fix < -1 || r.fix > 1 || r.normal < -1 || r.normal > 1) {
|
||||||
throw sls::RuntimeError(
|
throw sls::RuntimeError(
|
||||||
"Invalid current source parameters. Cannot print.");
|
"Invalid current source parameters. Cannot print.");
|
||||||
}
|
}
|
||||||
oss << '[';
|
oss << '[';
|
||||||
if (r.enable_) {
|
if (r.enable) {
|
||||||
oss << "enabled";
|
oss << "enabled";
|
||||||
// [jungfrau]
|
// [jungfrau]
|
||||||
if (r.fix_ != -1) {
|
if (r.fix != -1) {
|
||||||
oss << (r.fix_ == 1 ? ", fix" : ", nofix");
|
oss << (r.fix == 1 ? ", fix" : ", nofix");
|
||||||
}
|
}
|
||||||
// [jungfrau chip v1.1]
|
// [jungfrau chip v1.1]
|
||||||
if (r.normal_ != -1) {
|
if (r.normal != -1) {
|
||||||
oss << ", " << ToStringHex(r.select_, 16);
|
oss << ", " << ToStringHex(r.select, 16);
|
||||||
oss << (r.normal_ == 1 ? ", normal" : ", low");
|
oss << (r.normal == 1 ? ", normal" : ", low");
|
||||||
}
|
}
|
||||||
// [jungfrau chip v1.0]
|
// [jungfrau chip v1.0]
|
||||||
else {
|
else {
|
||||||
oss << ", " << r.select_;
|
oss << ", " << r.select;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
oss << "disabled";
|
oss << "disabled";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user