From d261a9f0d5f06bfb339a62f8f4341efd97b8b11f Mon Sep 17 00:00:00 2001 From: Valentin Valls <valentin.valls@esrf.fr> Date: Wed, 13 Oct 2021 16:51:51 +0200 Subject: [PATCH 1/4] Typo --- include/simulator/SimulatorCamera.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/simulator/SimulatorCamera.h b/include/simulator/SimulatorCamera.h index 99bf59d..f68ffa1 100644 --- a/include/simulator/SimulatorCamera.h +++ b/include/simulator/SimulatorCamera.h @@ -163,7 +163,7 @@ private: FrameGetter *m_frame_getter; //<! The current frame getter (according to the mode) HwMaxImageSizeCallback *m_cbk; //<! Keep a reference to the HwMaxImageSizeCallback (used when switching between FrameGetter) - + SimuThread m_thread; }; -- GitLab From 653b065d4ae5ef44a70684712673ae49cba72650 Mon Sep 17 00:00:00 2001 From: Valentin Valls <valentin.valls@esrf.fr> Date: Wed, 13 Oct 2021 16:54:01 +0200 Subject: [PATCH 2/4] Expose detector pixel size getter/setter from the simulator camera --- include/simulator/SimulatorCamera.h | 6 ++++++ sip/SimulatorCamera.sip | 3 +++ src/SimulatorCamera.cpp | 16 ++++++++++++++++ src/SimulatorDetInfoCtrlObj.cpp | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/simulator/SimulatorCamera.h b/include/simulator/SimulatorCamera.h index f68ffa1..1c87cdc 100644 --- a/include/simulator/SimulatorCamera.h +++ b/include/simulator/SimulatorCamera.h @@ -93,6 +93,9 @@ public: void setTrigMode(TrigMode trig_mode) { m_trig_mode = trig_mode; }; void getTrigMode(TrigMode &trig_mode) { trig_mode = m_trig_mode; }; + void setPixelSize(double x_size, double y_size); + void getPixelSize(double &x_size, double &y_size); + void setFrameDim(const FrameDim &frame_dim); void getFrameDim(FrameDim &frame_dim); @@ -155,6 +158,9 @@ private: double m_lat_time; int m_nb_frames; + double m_x_size = 1e-6; + double m_y_size = 1e-6; + TrigMode m_trig_mode; SoftBufferCtrlObj m_buffer_ctrl_obj; diff --git a/sip/SimulatorCamera.sip b/sip/SimulatorCamera.sip index f8f28c5..000c07c 100644 --- a/sip/SimulatorCamera.sip +++ b/sip/SimulatorCamera.sip @@ -83,6 +83,9 @@ public: void setLatTime(double lat_time); void getLatTime(double& lat_time /Out/); + void setPixelSize(double x_size, double y_size); + void getPixelSize(double &x_size, double &y_size); + void setFrameDim(const FrameDim& frame_dim); void getFrameDim(FrameDim& frame_dim /Out/); diff --git a/src/SimulatorCamera.cpp b/src/SimulatorCamera.cpp index 2be5dc1..747284e 100644 --- a/src/SimulatorCamera.cpp +++ b/src/SimulatorCamera.cpp @@ -237,6 +237,22 @@ void Camera::setMode(const Mode &mode) } } +void Camera::setPixelSize(double x_size, double y_size) +{ + DEB_MEMBER_FUNCT(); + + this->m_x_size = x_size; + this->m_y_size = y_size; +} + +void Camera::getPixelSize(double &x_size, double &y_size) +{ + DEB_MEMBER_FUNCT(); + + x_size = this->m_x_size; + y_size = this->m_y_size; +} + void Camera::setFrameDim(const FrameDim &frame_dim) { DEB_MEMBER_FUNCT(); diff --git a/src/SimulatorDetInfoCtrlObj.cpp b/src/SimulatorDetInfoCtrlObj.cpp index ce369cc..16d5957 100644 --- a/src/SimulatorDetInfoCtrlObj.cpp +++ b/src/SimulatorDetInfoCtrlObj.cpp @@ -61,7 +61,7 @@ void DetInfoCtrlObj::getCurrImageType(ImageType &curr_image_type) void DetInfoCtrlObj::getPixelSize(double &x_size, double &y_size) { - x_size = y_size = 1e-6; + m_simu.getPixelSize(x_size, y_size); } void DetInfoCtrlObj::getDetectorType(std::string &det_type) -- GitLab From e9a1ca8a37bc3294c68035cc3dadcf2e31bccc8b Mon Sep 17 00:00:00 2001 From: Valentin Valls <valentin.valls@esrf.fr> Date: Wed, 13 Oct 2021 16:54:42 +0200 Subject: [PATCH 3/4] Test the default and edited camera pixel size --- test/test.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/test.py b/test/test.py index d330066..2af0d30 100644 --- a/test/test.py +++ b/test/test.py @@ -170,3 +170,28 @@ def test_update_mode(): dim = ct.image().getImageDim() assert dim.getSize() == Core.Size(100, 100) + + +def test_default_pixel_size(): + """Create the simulator camera + + Check the default pixel size + """ + cam = Simulator.Camera() + hw = Simulator.Interface(cam) + detInfo = hw.getHwCtrlObj(Core.HwCap.DetInfo) + pixelsize = detInfo.getPixelSize() + assert pixelsize == (1e-6, 1e-6) + + +def test_custom_pixel_size(): + """Change the simulator pixel size + + Check that the pixel size is the expected one + """ + cam = Simulator.Camera() + cam.setPixelSize(1e-3, 1e-4) + hw = Simulator.Interface(cam) + detInfo = hw.getHwCtrlObj(Core.HwCap.DetInfo) + pixelsize = detInfo.getPixelSize() + assert pixelsize == (1e-3, 1e-4) -- GitLab From c50168643c9e51af4e272fd079eec43a2d03e8c0 Mon Sep 17 00:00:00 2001 From: Valentin Valls <valentin.valls@esrf.fr> Date: Wed, 13 Oct 2021 17:17:38 +0200 Subject: [PATCH 4/4] Allow to setup pixel size at tango lima startup --- tango/Simulator.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tango/Simulator.py b/tango/Simulator.py index 484042f..00cfda1 100644 --- a/tango/Simulator.py +++ b/tango/Simulator.py @@ -120,6 +120,10 @@ class Simulator(PyTango.Device_4Impl): frame_dim = self.getFrameDimFromLongArray(self.frame_dim) _SimuCamera.setFrameDim(frame_dim) + if self.pixel_size: + pixel_size = self.pixel_size + _SimuCamera.setPixelSize(pixel_size[0], pixel_size[1]) + self.set_state(PyTango.DevState.ON) @Core.DEB_MEMBER_FUNCT @@ -220,6 +224,9 @@ class SimulatorClass(PyTango.DeviceClass): 'frame_dim': [PyTango.DevVarLongArray, "Frame dimension in the form: width, height, depth", []], + 'pixel_size': + [PyTango.DevVarDoubleArray, + "Pixel size in the form: width, height (in meter)", []], 'mode': [PyTango.DevString, "Simulator mode: GENERATOR, GENERATOR_PREFETCH, LOADER, LOADER_PREFETCH",[]], -- GitLab