diff --git a/mx_bec/sample_info.py b/mx_bec/sample_info.py new file mode 100644 index 0000000..39d7e34 --- /dev/null +++ b/mx_bec/sample_info.py @@ -0,0 +1,21 @@ +from __future__ import annotations + +from pydantic import BaseModel, Field + + +class OpticalCenteringResults: + """Outputs from the optical centering stage""" + + found: bool + smargon_coordinates: tuple[float, float, float] = Field( + description="x,y,z motor coords of the smargon where the crystal was centred" + ) + type_used: str = Field(description="Image analysis element used to determine the center") + + +class SampleInfo(BaseModel): + """Information about the currently mounted sample. Gradually filled out as + information from previous stages is obtained""" + + sample_id: int + optical_centering_results: OpticalCenteringResults | None = None diff --git a/mx_bec/service.py b/mx_bec/service.py index 6cfc0bb..51ab267 100644 --- a/mx_bec/service.py +++ b/mx_bec/service.py @@ -14,6 +14,7 @@ from mx_bec.endpoints import TaskEndpoints from mx_bec.jfjoch import JFJoch from mx_bec.messages import MXTaskQueueChangedMessage from mx_bec.optical_centering import OpticalPrediction +from mx_bec.sample_info import SampleInfo from mx_bec.tasks import MxTaskQueue, MxTasks if TYPE_CHECKING: @@ -49,6 +50,7 @@ class AareBec(BECClient): self.jfjoch = JFJoch(client=self) # connects lazily on first use self.tasks = MxTasks(self) self.task_queue: MxTaskQueue | None = None + self.sample_info: SampleInfo | None = None def start(self): super().start() @@ -78,6 +80,9 @@ class AareBec(BECClient): def _start_actor_manager(self): self.actor_manager = AareActorManager(self) + def reset_sample_info(self, sample_id: int): + self.sample_info = SampleInfo(sample_id=sample_id) + def shutdown(self, per_thread_timeout_s: float | None = None) -> None: """shutdown the service""" if self.actor_manager is not None: