From d92ebcfc18a9fce1aaa6c19be7f2082eab46bd95 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Thu, 6 Aug 2026 10:42:43 +0200 Subject: [PATCH] fix(mo1_bragg): omit ACS scan settings from the device configuration --- .../devices/mo1_bragg/mo1_bragg_devices.py | 12 +++++---- tests/tests_devices/test_mo1_bragg.py | 26 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/debye_bec/devices/mo1_bragg/mo1_bragg_devices.py b/debye_bec/devices/mo1_bragg/mo1_bragg_devices.py index 1da65a2..de68ee5 100644 --- a/debye_bec/devices/mo1_bragg/mo1_bragg_devices.py +++ b/debye_bec/devices/mo1_bragg/mo1_bragg_devices.py @@ -151,16 +151,18 @@ class Mo1BraggScanSettings(Device): # EpicsSignalWithRBV, suffix="s_scan_scantime", kind="config", auto_monitor=True # ) - # cache_ttl: baseline/config reads are served from cache; every put() drops the - # cache, so a fresh hardware read follows each real configuration change + # kind="omitted": these live on the ACS controller and are written by the scan at + # stage time, which also records them in scan_info — so nothing is lost by keeping + # them out of read_configuration(), and no passive device-server read path ever + # touches the socket. cache_ttl still guards explicit reads; put() drops the cache. s_scan_energy_lo = Cpt( - AcsSignal, tag=53003, prec=6, kind="config", auto_monitor=False, cache_ttl=30.0 + AcsSignal, tag=53003, prec=6, kind="omitted", auto_monitor=False, cache_ttl=30.0 ) s_scan_energy_hi = Cpt( - AcsSignal, tag=53004, prec=6, kind="config", auto_monitor=False, cache_ttl=30.0 + AcsSignal, tag=53004, prec=6, kind="omitted", auto_monitor=False, cache_ttl=30.0 ) s_scan_scantime = Cpt( - AcsSignal, tag=53002, prec=3, kind="config", auto_monitor=False, cache_ttl=30.0 + AcsSignal, tag=53002, prec=3, kind="omitted", auto_monitor=False, cache_ttl=30.0 ) # XAS advanced scan settings diff --git a/tests/tests_devices/test_mo1_bragg.py b/tests/tests_devices/test_mo1_bragg.py index aec8e45..869f2c8 100644 --- a/tests/tests_devices/test_mo1_bragg.py +++ b/tests/tests_devices/test_mo1_bragg.py @@ -136,15 +136,17 @@ def test_set_xtal(mock_bragg): assert dev.crystal.xtal_enum.get() == 1 -def test_read_configuration_uses_acs_cache_and_omits_status_pvs(mock_bragg): +def test_read_configuration_never_touches_acs_and_omits_status_pvs(mock_bragg): """The device server re-reads the full configuration whenever any auto-monitored - signal updates; the ticking status PVs must not be part of it, and repeated - config reads must not hit the ACS controller again while the cache is fresh.""" + signal updates; neither the ticking status PVs nor the ACS socket signals may be + part of it, so no passive read path ever produces a GETVAR.""" dev = mock_bragg config = dev.read_configuration() - assert "bragg_scan_settings_s_scan_energy_lo" in config - assert "bragg_scan_settings_s_scan_energy_hi" in config - assert "bragg_scan_settings_s_scan_scantime" in config + # ACS scan settings are omitted: config reads must not touch the socket at all + assert "bragg_scan_settings_s_scan_energy_lo" not in config + assert "bragg_scan_settings_s_scan_energy_hi" not in config + assert "bragg_scan_settings_s_scan_scantime" not in config + assert dev.controller.get_var.call_count == 0 # live status/progress PVs are omitted from the configuration assert "bragg_status_heartbeat" not in config assert "bragg_scan_control_scan_msg" not in config @@ -153,15 +155,13 @@ def test_read_configuration_uses_acs_cache_and_omits_status_pvs(mock_bragg): assert "bragg_scan_control_scan_time_left" not in config assert "bragg_scan_control_scan_done" not in config - acs_reads = dev.controller.get_var.call_count - dev.read_configuration() - assert dev.controller.get_var.call_count == acs_reads # served from cache - - # a config change drops the cache for exactly that signal + # explicit reads still work, are cached, and refresh after a put + assert dev.scan_settings.s_scan_energy_lo.get() == 0.0 + dev.scan_settings.s_scan_energy_lo.get() + assert dev.controller.get_var.call_count == 1 # second read served from cache dev.scan_settings.s_scan_energy_lo.put(7000.0) - dev.read_configuration() - assert dev.controller.get_var.call_count == acs_reads + 1 assert dev.scan_settings.s_scan_energy_lo.get() == 7000.0 + assert dev.controller.get_var.call_count == 2 # put dropped the cache def test_set_xas_settings(mock_bragg):