initial commit omny sample storage ophyd device

This commit is contained in:
Holler Mirko
2024-04-17 16:50:33 +02:00
parent 42f1265445
commit c90436b99f

View File

@ -59,7 +59,8 @@ class OMNYSampleStorage(Device):
parking_placed = Dcpt(parking_placed) parking_placed = Dcpt(parking_placed)
sample_placed = { sample_placed = {
f"parking{i}": (EpicsSignal, f"XOMNY-SAMPLE_DB_omny:{i}", {}) for i in [10,11,12,13,14,32,33,34,100,101] f"parking{i}": (EpicsSignal, f"XOMNY-SAMPLE_DB_omny:{i}", {})
for i in [10, 11, 12, 13, 14, 32, 33, 34, 100, 101]
} }
sample_placed = Dcpt(sample_placed) sample_placed = Dcpt(sample_placed)
@ -126,13 +127,13 @@ class OMNYSampleStorage(Device):
if slot_nr > 20: if slot_nr > 20:
raise OMNYSampleStorageError(f"Invalid slot number {slot_nr}.") raise OMNYSampleStorageError(f"Invalid slot number {slot_nr}.")
if container == 'A': if container == "A":
getattr(self.sample_shuttle_A_placed, f"sample{slot_nr}").set(1) getattr(self.sample_shuttle_A_placed, f"sample{slot_nr}").set(1)
getattr(self.sample_shuttle_A_names, f"sample{slot_nr}").set(name) getattr(self.sample_shuttle_A_names, f"sample{slot_nr}").set(name)
elif container == 'B': elif container == "B":
getattr(self.sample_shuttle_B_placed, f"sample{slot_nr}").set(1) getattr(self.sample_shuttle_B_placed, f"sample{slot_nr}").set(1)
getattr(self.sample_shuttle_B_names, f"sample{slot_nr}").set(name) getattr(self.sample_shuttle_B_names, f"sample{slot_nr}").set(name)
elif container == 'C': elif container == "C":
getattr(self.sample_shuttle_C_placed, f"sample{slot_nr}").set(1) getattr(self.sample_shuttle_C_placed, f"sample{slot_nr}").set(1)
getattr(self.sample_shuttle_C_names, f"sample{slot_nr}").set(name) getattr(self.sample_shuttle_C_names, f"sample{slot_nr}").set(name)
@ -140,13 +141,13 @@ class OMNYSampleStorage(Device):
if slot_nr > 20: if slot_nr > 20:
raise OMNYSampleStorageError(f"Invalid slot number {slot_nr}.") raise OMNYSampleStorageError(f"Invalid slot number {slot_nr}.")
if shuttle == 'A': if shuttle == "A":
getattr(self.sample_shuttle_A_placed, f"sample{slot_nr}").set(0) getattr(self.sample_shuttle_A_placed, f"sample{slot_nr}").set(0)
getattr(self.sample_shuttle_A_names, f"sample{slot_nr}").set("-") getattr(self.sample_shuttle_A_names, f"sample{slot_nr}").set("-")
if shuttle == 'B': if shuttle == "B":
getattr(self.sample_shuttle_B_placed, f"sample{slot_nr}").set(0) getattr(self.sample_shuttle_B_placed, f"sample{slot_nr}").set(0)
getattr(self.sample_shuttle_B_names, f"sample{slot_nr}").set("-") getattr(self.sample_shuttle_B_names, f"sample{slot_nr}").set("-")
if shuttle == 'C': if shuttle == "C":
getattr(self.sample_shuttle_C_placed, f"sample{slot_nr}").set(0) getattr(self.sample_shuttle_C_placed, f"sample{slot_nr}").set(0)
getattr(self.sample_shuttle_C_names, f"sample{slot_nr}").set("-") getattr(self.sample_shuttle_C_names, f"sample{slot_nr}").set("-")
@ -160,7 +161,7 @@ class OMNYSampleStorage(Device):
if slot_nr > 6: if slot_nr > 6:
raise OMNYSampleStorageError(f"Invalid slot number {slot_nr}.") raise OMNYSampleStorageError(f"Invalid slot number {slot_nr}.")
getattr(self.parking_placed, f"parking{slot_nr}").set(0) getattr(self.parking_placed, f"parking{slot_nr}").set(0)
getattr(self.parking_names, f"parking{slot_nr}").set('none') getattr(self.parking_names, f"parking{slot_nr}").set("none")
def set_sample_in_gripper(self, name: str) -> bool: def set_sample_in_gripper(self, name: str) -> bool:
self.sample_in_gripper.set(1) self.sample_in_gripper.set(1)
@ -179,13 +180,13 @@ class OMNYSampleStorage(Device):
self.sample_in_samplestage_name.set("-") self.sample_in_samplestage_name.set("-")
def is_sample_slot_used(self, container, slot_nr: int) -> bool: def is_sample_slot_used(self, container, slot_nr: int) -> bool:
if container == 'A': if container == "A":
val = getattr(self.sample_shuttle_A_placed, f"sample{slot_nr}").get() val = getattr(self.sample_shuttle_A_placed, f"sample{slot_nr}").get()
if container == 'B': if container == "B":
val = getattr(self.sample_shuttle_B_placed, f"sample{slot_nr}").get() val = getattr(self.sample_shuttle_B_placed, f"sample{slot_nr}").get()
if container == 'C': if container == "C":
val = getattr(self.sample_shuttle_C_placed, f"sample{slot_nr}").get() val = getattr(self.sample_shuttle_C_placed, f"sample{slot_nr}").get()
elif container == 'O': elif container == "O":
val = getattr(self.sample_placed, f"sample{slot_nr}").get() val = getattr(self.sample_placed, f"sample{slot_nr}").get()
return bool(val) return bool(val)
@ -202,13 +203,13 @@ class OMNYSampleStorage(Device):
return bool(val) return bool(val)
def get_sample_name(self, container, slot_nr) -> str: def get_sample_name(self, container, slot_nr) -> str:
if container == 'A': if container == "A":
val = getattr(self.sample_shuttle_A_names, f"sample{slot_nr}").get() val = getattr(self.sample_shuttle_A_names, f"sample{slot_nr}").get()
elif container == 'B': elif container == "B":
val = getattr(self.sample_shuttle_B_names, f"sample{slot_nr}").get() val = getattr(self.sample_shuttle_B_names, f"sample{slot_nr}").get()
elif container == 'C': elif container == "C":
val = getattr(self.sample_shuttle_C_names, f"sample{slot_nr}").get() val = getattr(self.sample_shuttle_C_names, f"sample{slot_nr}").get()
elif container == 'O': elif container == "O":
val = getattr(self.sample_names, f"sample{slot_nr}").get() val = getattr(self.sample_names, f"sample{slot_nr}").get()
else: else:
val = "unknown container" val = "unknown container"
@ -228,7 +229,7 @@ class OMNYSampleStorage(Device):
def show_all(self): def show_all(self):
t = PrettyTable() t = PrettyTable()
for ch in ['A','B','C']: for ch in ["A", "B", "C"]:
t.clear() t.clear()
t.title = "Shuttle " + ch t.title = "Shuttle " + ch
field_names = [""] field_names = [""]
@ -258,10 +259,9 @@ class OMNYSampleStorage(Device):
for i in [10, 11, 12, 13, 14, 32, 33, 34, 100, 101]: for i in [10, 11, 12, 13, 14, 32, 33, 34, 100, 101]:
row = [] row = []
row.extend([f"Position {i:3d}"]) row.extend([f"Position {i:3d}"])
if self.is_sample_slot_used('O',i): if self.is_sample_slot_used("O", i):
row.extend(self.get_sample_name('O',i)) row.extend(self.get_sample_name("O", i))
else: else:
row.extend(["free"]) row.extend(["free"])
t.add_row(row) t.add_row(row)
print(t) print(t)