From 02f950de8d6b2eba142495f71b2f470133f13187 Mon Sep 17 00:00:00 2001 From: Holler Mirko Date: Tue, 5 Mar 2024 17:04:29 +0100 Subject: [PATCH] added show all to sample storage --- .../epics/devices/flomni_sample_storage.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ophyd_devices/epics/devices/flomni_sample_storage.py b/ophyd_devices/epics/devices/flomni_sample_storage.py index e9f1b7f..18c48fa 100644 --- a/ophyd_devices/epics/devices/flomni_sample_storage.py +++ b/ophyd_devices/epics/devices/flomni_sample_storage.py @@ -4,6 +4,7 @@ from ophyd import Component as Cpt from ophyd import Device from ophyd import DynamicDeviceComponent as Dcpt from ophyd import EpicsSignal +from prettytable import PrettyTable class FlomniSampleStorageError(Exception): @@ -18,6 +19,7 @@ class FlomniSampleStorage(Device): "unset_sample_slot", "set_sample_in_gripper", "unset_sample_in_gripper", + "show_all", ] SUB_VALUE = "value" _default_sub = SUB_VALUE @@ -80,3 +82,36 @@ class FlomniSampleStorage(Device): def is_sample_in_gripper(self) -> bool: val = self.sample_in_gripper.get() return bool(val) + + def get_sample_name(self, slot_nr) -> str: + val = getattr(self.sample_names, f"sample{slot_nr}").get() + return str(val) + + def show_all(self): + t = PrettyTable() + t.title = "flOMNI sample storage" + field_names = [""] + field_names.extend(str(ax) for ax in range(1,11)) + for ct in range(0,2): + t.field_names = field_names + row = ["Container " + str(ct)] + row.extend( + "used" if self.is_sample_slot_used(slot_nr) else "free" + for slot_nr in range((ct*10)+1,(ct*10)+11) + ) + t.add_row(row) + print(t) + print("\n\nFollowing samples are currently loaded:\n") + for ct in range(1,21): + if self.is_sample_slot_used(ct): + print(f" Position {ct:2.0f}: {self.get_sample_name(ct)}") + if self.sample_in_gripper.get(): + print(f"\nGripper: {self.sample_in_gripper_name.get()}\n") + else: + print(f"\nGripper: no sample\n") + + if self.is_sample_slot_used(0): + print(f"flOMNI stage: {self.get_sample_name(0)}\n") + else: + print(f"flOMNI stage: no sample\n") +