From e2eb1598d319a4a3a309cd809d434099134c53a0 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Thu, 28 May 2020 09:28:53 +0200 Subject: [PATCH] jf stuff --- python/api-tests/test_jungfrau.py | 27 ++++++++++++++++++++++ python/slsdet/detector.py | 32 ++++++++++++++++++++++++++ python/src/detector.cpp | 4 ++-- slsDetectorSoftware/include/Detector.h | 2 +- slsDetectorSoftware/src/CmdProxy.h | 2 +- slsDetectorSoftware/src/Detector.cpp | 6 ++--- slsDetectorSoftware/src/Module.cpp | 2 +- slsDetectorSoftware/src/Module.h | 2 +- 8 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 python/api-tests/test_jungfrau.py diff --git a/python/api-tests/test_jungfrau.py b/python/api-tests/test_jungfrau.py new file mode 100644 index 000000000..19d6d1138 --- /dev/null +++ b/python/api-tests/test_jungfrau.py @@ -0,0 +1,27 @@ +import pytest +import datetime as dt + +@pytest.fixture +def jf(): + from slsdet import Jungfrau + return Jungfrau() + + +def test_storagecells(jf): + for i in range(16): + jf.storagecells = i + assert jf.storagecells == i + jf.storagecells = 0 #default + +def test_storagecell_start(jf): + for i in range(16): + jf.storagecell_start = i + assert jf.storagecell_start == i + jf.storagecells = 15 #default + + +def test_storagecell_delay(jf): + for t in [0.001, 0.0002, 0.0013]: + jf.storagecell_delay = t + assert jf.storagecell_delay == t + jf.storagecell_delay = 0 #default \ No newline at end of file diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 0f5ec95f9..8da6c2de9 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -748,6 +748,38 @@ class Detector(CppDetectorApi): def storeinram(self, value): self.setStoreInRamMode(value) + + """ + Jungfrau specific + """ + + @property + @element + def storagecells(self): + return self.getNumberOfAdditionalStorageCells() + + @storagecells.setter + def storagecells(self, n_cells): + self.setNumberOfAdditionalStorageCells(n_cells) + + @property + @element + def storagecell_start(self): + return self.getStorageCellStart() + + @storagecell_start.setter + def storagecell_start(self, value): + self.setStorageCellStart(value) + + @property + @element + def storagecell_delay(self): + return ut.reduce_time(self.getStorageCellDelay()) + + @storagecell_delay.setter + def storagecell_delay(self, t): + self.setStorageCellDelay(ut.make_timedelta(t)) + """ Gotthard2 """ diff --git a/python/src/detector.cpp b/python/src/detector.cpp index 87dda5feb..2aa49aaf2 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -880,9 +880,9 @@ void init_det(py::module &m) { (Result(Detector::*)(sls::Positions) const) & Detector::getStorageCellStart, py::arg() = Positions{}) - .def("setStoragecellStart", + .def("setStorageCellStart", (void (Detector::*)(int, sls::Positions)) & - Detector::setStoragecellStart, + Detector::setStorageCellStart, py::arg(), py::arg() = Positions{}) .def("getStorageCellDelay", (Result(Detector::*)(sls::Positions) const) & diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 2fde25a2c..03e4b18af 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -884,7 +884,7 @@ class Detector { /** [Jungfrau] Advanced. Sets the storage cell storing the first acquisition * of the series. Options: 0-15 */ - void setStoragecellStart(int cell, Positions pos = {}); + void setStorageCellStart(int cell, Positions pos = {}); /** [Jungfrau] Advanced*/ Result getStorageCellDelay(Positions pos = {}) const; diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index 942cd6222..99d1fd717 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -1844,7 +1844,7 @@ class CmdProxy { "(#storagecells + 1)."); INTEGER_COMMAND( - storagecell_start, getStorageCellStart, setStoragecellStart, + storagecell_start, getStorageCellStart, setStorageCellStart, StringTo, "[0-15]\n\t[Jungfrau] Storage cell that stores the first acquisition " "of the series. Default is 15. For advanced users only."); diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index aa6d2a881..1a8988fa0 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1132,11 +1132,11 @@ void Detector::setNumberOfAdditionalStorageCells(int value) { } Result Detector::getStorageCellStart(Positions pos) const { - return pimpl->Parallel(&Module::setStoragecellStart, pos, -1); + return pimpl->Parallel(&Module::setStorageCellStart, pos, -1); } -void Detector::setStoragecellStart(int cell, Positions pos) { - pimpl->Parallel(&Module::setStoragecellStart, pos, cell); +void Detector::setStorageCellStart(int cell, Positions pos) { + pimpl->Parallel(&Module::setStorageCellStart, pos, cell); } Result Detector::getStorageCellDelay(Positions pos) const { diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index a8706594a..4940ed213 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -2355,7 +2355,7 @@ int Module::setTemperatureEvent(int val) { return retval; } -int Module::setStoragecellStart(int pos) { +int Module::setStorageCellStart(int pos) { return sendToDetector(F_STORAGE_CELL_START, pos); } diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index c716174f3..234ca6439 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -1200,7 +1200,7 @@ class Module : public virtual slsDetectorDefs { * @param value storage cell index. Value can be 0 to 15. (-1 gets) * @returns the storage cell that stores the first acquisition of the series */ - int setStoragecellStart(int pos = -1); + int setStorageCellStart(int pos = -1); /** * [Jungfau][Ctb] Programs FPGA with raw file from pof file