From e6444bf060147202ccc092e59d3324a9ef30a7e3 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 8 Oct 2021 12:32:46 +0200 Subject: [PATCH 1/2] fixed shm tests --- slsDetectorSoftware/tests/test-SharedMemory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/slsDetectorSoftware/tests/test-SharedMemory.cpp b/slsDetectorSoftware/tests/test-SharedMemory.cpp index 2d5c99785..45d3ec7d7 100644 --- a/slsDetectorSoftware/tests/test-SharedMemory.cpp +++ b/slsDetectorSoftware/tests/test-SharedMemory.cpp @@ -20,7 +20,7 @@ TEST_CASE("Create SharedMemory read and write", "[detector]") { SharedMemory shm(shm_id, -1); shm.CreateSharedMemory(); 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()->y = 5.7; @@ -91,7 +91,7 @@ TEST_CASE("Move SharedMemory", "[detector]") { SharedMemory shm(shm_id, -1); CHECK(shm.GetName() == - std::string("/slsDetectorPackage_multi_") + std::to_string(shm_id)); + std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id)); shm.CreateSharedMemory(); shm()->x = 9; @@ -105,7 +105,7 @@ TEST_CASE("Move SharedMemory", "[detector]") { CHECK(shm.size() == 0); CHECK(shm2.GetName() == - std::string("/slsDetectorPackage_multi_") + std::to_string(shm_id)); + std::string("/slsDetectorPackage_detector_") + std::to_string(shm_id)); shm2.RemoveSharedMemory(); } @@ -123,7 +123,7 @@ TEST_CASE("Create several shared memories", "[detector]") { for (int i = 0; i != N; ++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)); } From 6394fba85d76694f0428cdc93ab47a78326308a1 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 8 Oct 2021 12:52:37 +0200 Subject: [PATCH 2/2] removing trailing _ for members of currentsrcParameters --- python/examples/use_currentsource.py | 8 ++--- python/src/current.cpp | 8 ++--- slsSupportLib/include/sls/sls_detector_defs.h | 32 +++++++++---------- slsSupportLib/src/ToString.cpp | 16 +++++----- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/python/examples/use_currentsource.py b/python/examples/use_currentsource.py index a895126b0..ecc0a588f 100644 --- a/python/examples/use_currentsource.py +++ b/python/examples/use_currentsource.py @@ -1,10 +1,10 @@ from slsdet import Detector, currentSrcParameters s = currentSrcParameters() -s.enable_ = 1 -s.fix_= 1 -s.normal_ = 1 -s.select_ = 10 +s.enable = 1 +s.fix= 1 +s.normal = 1 +s.select = 10 d = Detector() diff --git a/python/src/current.cpp b/python/src/current.cpp index e6d0d62b7..f24ced0c4 100644 --- a/python/src/current.cpp +++ b/python/src/current.cpp @@ -15,10 +15,10 @@ void init_source(py::module &m) { py::class_ currentSrcParameters(m, "currentSrcParameters"); currentSrcParameters.def(py::init()); - currentSrcParameters.def_readwrite("enable_", &src::enable_); - currentSrcParameters.def_readwrite("fix_", &src::fix_); - currentSrcParameters.def_readwrite("normal_", &src::normal_); - currentSrcParameters.def_readwrite("select_", &src::select_); + currentSrcParameters.def_readwrite("enable", &src::enable); + currentSrcParameters.def_readwrite("fix", &src::fix); + currentSrcParameters.def_readwrite("normal", &src::normal); + currentSrcParameters.def_readwrite("select", &src::select); currentSrcParameters.def(pybind11::self == pybind11::self); currentSrcParameters.def("__repr__", diff --git a/slsSupportLib/include/sls/sls_detector_defs.h b/slsSupportLib/include/sls/sls_detector_defs.h index 6106504ee..5f8eae3b9 100644 --- a/slsSupportLib/include/sls/sls_detector_defs.h +++ b/slsSupportLib/include/sls/sls_detector_defs.h @@ -462,36 +462,36 @@ typedef struct { } __attribute__((packed)); struct currentSrcParameters { - int enable_; - int fix_; - int normal_; - uint64_t select_; + int enable; + int fix; + int normal; + uint64_t select; /** [Gotthard2][Jungfrau] disable */ currentSrcParameters() - : enable_(0), fix_(-1), normal_(-1), select_(0) {} + : enable(0), fix(-1), normal(-1), select(0) {} /** [Gotthard2] enable or disable */ - explicit currentSrcParameters(bool enable) - : enable_(static_cast(enable)), fix_(-1), normal_(-1), - select_(0) {} + explicit currentSrcParameters(bool srcEnable) + : enable(static_cast(srcEnable)), fix(-1), normal(-1), + select(0) {} /** [Jungfrau](chipv1.0) enable current src with fix or no fix, * select is 0 to 63 columns only */ - currentSrcParameters(bool fix, uint64_t select) - : enable_(1), fix_(static_cast(fix)), normal_(-1), - select_(select) {} + currentSrcParameters(bool fixCurrent, uint64_t selectCurrent) + : enable(1), fix(static_cast(fixCurrent)), normal(-1), + select(selectCurrent) {} /** [Jungfrau](chipv1.1) enable current src, fix[fix|no fix], * select is a mask of 63 bits (muliple columns can be selected * simultaneously, normal [normal|low] */ - currentSrcParameters(bool fix, uint64_t select, bool normal) - : enable_(1), fix_(static_cast(fix)), - normal_(static_cast(normal)), select_(select) {} + currentSrcParameters(bool fixCurrent, uint64_t selectCurrent, bool normalCurrent) + : enable(1), fix(static_cast(fixCurrent)), + normal(static_cast(normalCurrent)), select(selectCurrent) {} bool operator==(const currentSrcParameters &other) const { - return ((enable_ == other.enable_) && (fix_ == other.fix_) && - (normal_ == other.normal_) && (select_ == other.select_)); + return ((enable == other.enable) && (fix == other.fix) && + (normal == other.normal) && (select == other.select)); } } __attribute__((packed)); diff --git a/slsSupportLib/src/ToString.cpp b/slsSupportLib/src/ToString.cpp index 20d6774c8..7d68f2fb9 100644 --- a/slsSupportLib/src/ToString.cpp +++ b/slsSupportLib/src/ToString.cpp @@ -116,25 +116,25 @@ std::ostream &operator<<(std::ostream &os, std::string ToString(const slsDetectorDefs::currentSrcParameters &r) { 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( "Invalid current source parameters. Cannot print."); } oss << '['; - if (r.enable_) { + if (r.enable) { oss << "enabled"; // [jungfrau] - if (r.fix_ != -1) { - oss << (r.fix_ == 1 ? ", fix" : ", nofix"); + if (r.fix != -1) { + oss << (r.fix == 1 ? ", fix" : ", nofix"); } // [jungfrau chip v1.1] - if (r.normal_ != -1) { - oss << ", " << ToStringHex(r.select_, 16); - oss << (r.normal_ == 1 ? ", normal" : ", low"); + if (r.normal != -1) { + oss << ", " << ToStringHex(r.select, 16); + oss << (r.normal == 1 ? ", normal" : ", low"); } // [jungfrau chip v1.0] else { - oss << ", " << r.select_; + oss << ", " << r.select; } } else { oss << "disabled";