Skip to content

Commit 0d31404

Browse files
committed
add attrs
1 parent 30d8dd1 commit 0d31404

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

pylabrobot/liquid_handling/backends/backend.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from abc import ABCMeta, abstractmethod
4-
from typing import List, Optional, Union
4+
from typing import Dict, List, Optional, Union
55

66
from pylabrobot.liquid_handling.standard import (
77
Aspiration,
@@ -20,6 +20,7 @@
2020
)
2121
from pylabrobot.machines.backends import MachineBackend
2222
from pylabrobot.resources import Deck, Resource
23+
from pylabrobot.resources.tip_tracker import TipTracker
2324

2425

2526
class LiquidHandlerBackend(MachineBackend, metaclass=ABCMeta):
@@ -36,17 +37,34 @@ class LiquidHandlerBackend(MachineBackend, metaclass=ABCMeta):
3637
def __init__(self):
3738
self.setup_finished = False
3839
self._deck: Optional[Deck] = None
40+
self._head: Optional[Dict[int, TipTracker]] = None
41+
self._head96: Optional[Dict[int, TipTracker]] = None
3942

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

48+
def set_heads(self, head: Dict[int, TipTracker], head96: Optional[Dict[int, TipTracker]] = None):
49+
"""Set the tip tracker for the robot. Called automatically by `LiquidHandler.setup` or can be
50+
called manually if interacting with the backend directly. A head must be set before setup."""
51+
self._head = head
52+
self._head96 = head96
53+
4554
@property
4655
def deck(self) -> Deck:
4756
assert self._deck is not None, "Deck not set"
4857
return self._deck
4958

59+
@property
60+
def head(self) -> Dict[int, TipTracker]:
61+
assert self._head is not None, "Head not set"
62+
return self._head
63+
64+
@property
65+
def head96(self) -> Optional[Dict[int, TipTracker]]:
66+
return self._head96
67+
5068
async def setup(self):
5169
"""Set up the robot. This method should be called before any other method is called."""
5270
assert self._deck is not None, "Deck not set"

pylabrobot/liquid_handling/liquid_handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ async def setup(self, **backend_kwargs):
162162
raise RuntimeError("The setup has already finished. See `LiquidHandler.stop`.")
163163

164164
self.backend.set_deck(self.deck)
165+
self.backend.set_heads(head=self.head, head96=self.head96)
165166
await super().setup(**backend_kwargs)
166167

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

0 commit comments

Comments
 (0)