Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions bec_ipython_client/tests/end-2-end/test_scans_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def test_mv_scan_nested_device(capsys, bec_ipython_client_fixture):
if not bec.connector._messages_queue.empty():
print("Waiting for messages to be processed")
time.sleep(0.5)
current_pos_hexapod_x = dev.hexapod.x.read(cached=True)["hexapod_x"]["value"]
current_pos_hexapod_y = dev.hexapod.y.read(cached=True)["hexapod_y"]["value"]
current_pos_hexapod_x = dev.hexapod.x.read(cached=True)["hexapod-x"]["value"]
current_pos_hexapod_y = dev.hexapod.y.read(cached=True)["hexapod-y"]["value"]
assert np.isclose(
current_pos_hexapod_x, 10, atol=dev.hexapod._config["deviceConfig"].get("tolerance", 0.5)
)
Expand All @@ -122,8 +122,8 @@ def test_mv_scan_nested_device(capsys, bec_ipython_client_fixture):
if not bec.connector._messages_queue.empty():
print("Waiting for messages to be processed")
time.sleep(0.5)
current_pos_hexapod_x = dev.hexapod.x.read(cached=True)["hexapod_x"]["value"]
current_pos_hexapod_y = dev.hexapod.y.read(cached=True)["hexapod_y"]["value"]
current_pos_hexapod_x = dev.hexapod.x.read(cached=True)["hexapod-x"]["value"]
current_pos_hexapod_y = dev.hexapod.y.read(cached=True)["hexapod-y"]["value"]
captured = capsys.readouterr()
ref_out_hexapod_x = (
f"━━━━━━━━━━ {current_pos_hexapod_x:10.2f} / 10.00 / 100 % 0:00:00 0:00:00"
Expand Down Expand Up @@ -492,11 +492,11 @@ def test_file_writer(bec_ipython_client_fixture):
assert all(file_data == stream_data)

assert (
file["entry"]["collection"]["configuration"]["samx"]["samx_velocity"]["value"][...]
file["entry"]["collection"]["configuration"]["samx"]["samx-velocity"]["value"][...]
== 98
)
assert (
file["entry"]["collection"]["configuration"]["samy"]["samy_velocity"]["value"][...]
file["entry"]["collection"]["configuration"]["samy"]["samy-velocity"]["value"][...]
== 101
)

Expand Down Expand Up @@ -780,15 +780,15 @@ def test_async_data(bec_ipython_client_fixture):
s1 = scans.line_scan(dev.samx, 0, 1, steps=10, relative=False)
s1.wait()
while True:
waveform_data = s1.scan.data.devices.waveform.waveform_waveform.read()
waveform_data = s1.scan.data.devices.waveform["waveform-waveform"].read()
if len(waveform_data["value"]) == 10:
break
np.testing.assert_array_equal(waveform_data["value"], amplitude * np.ones((10, 10)))
dev.waveform.async_update.set("extend")
s1 = scans.line_scan(dev.samx, 0, 1, steps=10, relative=False)
s1.wait()
while True:
waveform_data = s1.scan.data.devices.waveform.waveform_waveform.read()
waveform_data = s1.scan.data.devices.waveform["waveform-waveform"].read()
if len(waveform_data["value"]) == 100:
break
np.testing.assert_array_equal(waveform_data["value"], amplitude * np.ones(100))
Expand Down
18 changes: 9 additions & 9 deletions bec_ipython_client/tests/end-2-end/test_scans_lib_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ def test_config_updates(bec_client_lib):
assert dev.rt_controller.limits == [-50, 50]

dev.rt_controller.velocity.set(10).wait()
assert dev.rt_controller.velocity.read(cached=True)["rt_controller_velocity"]["value"] == 10
assert dev.rt_controller.velocity.read()["rt_controller_velocity"]["value"] == 10
assert dev.rt_controller.read_configuration()["rt_controller_velocity"]["value"] == 10
assert dev.rt_controller.read_configuration()["rt_controller_velocity"]["value"] == 10
assert dev.rt_controller.velocity.read(cached=True)["rt_controller-velocity"]["value"] == 10
assert dev.rt_controller.velocity.read()["rt_controller-velocity"]["value"] == 10
assert dev.rt_controller.read_configuration()["rt_controller-velocity"]["value"] == 10
assert dev.rt_controller.read_configuration()["rt_controller-velocity"]["value"] == 10

dev.rt_controller.velocity.put(5)
assert dev.rt_controller.velocity.get() == 5
Expand Down Expand Up @@ -470,22 +470,22 @@ def test_cached_device_readout(bec_client_lib):
assert data == 10

config = dev.samx.read_configuration()
assert config["samx_velocity"]["value"] == 10
assert config["samx-velocity"]["value"] == 10

dev.samx.velocity.put(orig_velocity)

data = dev.hexapod.x.readback.read()
timestamp = data["hexapod_x"]["timestamp"]
timestamp = data["hexapod-x"]["timestamp"]
data = dev.hexapod.x.readback.read(cached=True)
assert data["hexapod_x"]["timestamp"] == timestamp
assert data["hexapod-x"]["timestamp"] == timestamp

# check that .get also updates the cache
dev.hexapod.x.readback.get()
timestamp_2 = dev.hexapod.x.readback.read(cached=True)["hexapod_x"]["timestamp"]
timestamp_2 = dev.hexapod.x.readback.read(cached=True)["hexapod-x"]["timestamp"]
assert timestamp_2 != timestamp

dev.hexapod.x.readback.get(cached=True)
timestamp_3 = dev.hexapod.x.readback.read(cached=True)["hexapod_x"]["timestamp"]
timestamp_3 = dev.hexapod.x.readback.read(cached=True)["hexapod-x"]["timestamp"]
assert timestamp_3 == timestamp_2


Expand Down
1 change: 1 addition & 0 deletions bec_lib/bec_lib/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEVICE_NAME_SEPARATOR = "-"
3 changes: 2 additions & 1 deletion bec_lib/bec_lib/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from typeguard import typechecked

from bec_lib.atlas_models import _DeviceModelCore
from bec_lib.constants import DEVICE_NAME_SEPARATOR
from bec_lib.endpoints import MessageEndpoints
from bec_lib.logger import bec_logger
from bec_lib.queue_items import QueueItem
Expand Down Expand Up @@ -527,7 +528,7 @@ class DeviceBaseWithConfig(DeviceBase):
@property
def full_name(self):
"""Returns the full name of the device or signal, separated by "_" e.g. samx_velocity"""
return self._compile_function_path().replace(".", "_")
return self._compile_function_path().replace(".", DEVICE_NAME_SEPARATOR)

@property
def dotted_name(self):
Expand Down
10 changes: 5 additions & 5 deletions bec_lib/tests/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ def test_read_use_read(dev: Any):
def test_read_nested_device(dev: Any):
with mock.patch.object(dev.dyn_signals.root.parent.connector, "get") as mock_get:
data = {
"dyn_signals_messages_message1": {"value": 0, "timestamp": 1701105880.0716832},
"dyn_signals_messages_message2": {"value": 0, "timestamp": 1701105880.071722},
"dyn_signals_messages_message3": {"value": 0, "timestamp": 1701105880.071739},
"dyn_signals_messages_message4": {"value": 0, "timestamp": 1701105880.071753},
"dyn_signals_messages_message5": {"value": 0, "timestamp": 1701105880.071766},
"dyn_signals-messages-message1": {"value": 0, "timestamp": 1701105880.0716832},
"dyn_signals-messages-message2": {"value": 0, "timestamp": 1701105880.071722},
"dyn_signals-messages-message3": {"value": 0, "timestamp": 1701105880.071739},
"dyn_signals-messages-message4": {"value": 0, "timestamp": 1701105880.071753},
"dyn_signals-messages-message5": {"value": 0, "timestamp": 1701105880.071766},
}
mock_get.return_value = messages.DeviceMessage(
signals=data, metadata={"scan_id": "scan_id", "scan_type": "scan_type"}
Expand Down
3 changes: 3 additions & 0 deletions bec_server/bec_server/device_server/devices/devicemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from bec_lib import messages, plugin_helper
from bec_lib.bec_errors import DeviceConfigError
from bec_lib.bec_service import BECService
from bec_lib.constants import DEVICE_NAME_SEPARATOR
from bec_lib.device import DeviceBaseWithConfig
from bec_lib.devicemanager import DeviceManagerBase
from bec_lib.endpoints import MessageEndpoints
Expand Down Expand Up @@ -298,6 +299,8 @@ def construct_device_obj(dev: dict, device_manager: DeviceManagerDS) -> (OphydOb
class_params_and_config_keys = class_params & config.keys()

init_kwargs = {key: config.pop(key) for key in class_params_and_config_keys}
if issubclass(dev_cls, ophyd.Device):
init_kwargs["child_name_separator"] = DEVICE_NAME_SEPARATOR
device_access = config.pop("device_access", None)
if device_access or (device_access is None and config.get("device_mapping")):
init_kwargs["device_manager"] = device_manager
Expand Down
Loading