Skip to content

Commit

Permalink
add properties
Browse files Browse the repository at this point in the history
  • Loading branch information
rickwierenga committed Jan 17, 2025
1 parent 30d8dd1 commit 54482cb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pylabrobot/liquid_handling/backends/backend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from abc import ABCMeta, abstractmethod
from typing import List, Optional, Union
from typing import Dict, List, Optional, Union

from pylabrobot.liquid_handling.standard import (
Aspiration,
Expand All @@ -20,6 +20,7 @@
)
from pylabrobot.machines.backends import MachineBackend
from pylabrobot.resources import Deck, Resource
from pylabrobot.resources.tip_tracker import TipTracker


class LiquidHandlerBackend(MachineBackend, metaclass=ABCMeta):
Expand All @@ -36,17 +37,34 @@ class LiquidHandlerBackend(MachineBackend, metaclass=ABCMeta):
def __init__(self):
self.setup_finished = False
self._deck: Optional[Deck] = None
self._head: Optional[Dict[int, TipTracker]] = None
self._head96: Optional[Dict[int, TipTracker]] = None

def set_deck(self, deck: Deck):
"""Set the deck for the robot. Called automatically by `LiquidHandler.setup` or can be called
manually if interacting with the backend directly. A deck must be set before setup."""
self._deck = deck

def set_heads(self, head: Dict[int, TipTracker], head96: Optional[Dict[int, TipTracker]] = None):
"""Set the tip tracker for the robot. Called automatically by `LiquidHandler.setup` or can be
called manually if interacting with the backend directly. A head must be set before setup."""
self._head = head
self._head96 = head96

@property
def deck(self) -> Deck:
assert self._deck is not None, "Deck not set"
return self._deck

@property
def head(self) -> Dict[int, TipTracker]:
assert self._head is not None, "Head not set"
return self._head

@property
def head96(self) -> Optional[Dict[int, TipTracker]]:
return self._head96

async def setup(self):
"""Set up the robot. This method should be called before any other method is called."""
assert self._deck is not None, "Deck not set"
Expand Down
1 change: 1 addition & 0 deletions pylabrobot/liquid_handling/liquid_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ async def setup(self, **backend_kwargs):
raise RuntimeError("The setup has already finished. See `LiquidHandler.stop`.")

self.backend.set_deck(self.deck)
self.backend.set_heads(head=self.head, head96=self.head96)
await super().setup(**backend_kwargs)

self.head = {c: TipTracker(thing=f"Channel {c}") for c in range(self.backend.num_channels)}
Expand Down

0 comments on commit 54482cb

Please sign in to comment.