Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pylabrobot/storage/liconic/liconic_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ async def scan_barcode(self, site: PlateHolder) -> Barcode:
await self._send_command(f"WR DM25 {pos_num}") # plate
await self._send_command(f"WR DM5 {n}") # plate position in carousel
await self._send_command("ST 1910") # move shovel to barcode reading position
await self._wait_ready() # block until the lift reaches the read position

barcode = await self.barcode_scanner.scan()
logger.info(f"Scanned barcode: {barcode.data}")
Expand Down
18 changes: 18 additions & 0 deletions pylabrobot/storage/liconic/liconic_backend_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,24 @@ async def test_initialize(self):
self.backend._wait_ready.assert_awaited()


class TestScanBarcode(unittest.IsolatedAsyncioTestCase):
"""scan_barcode must wait for the z-lift to reach the read position (ST 1910)
before triggering the scan, otherwise the beam fires while the lift is still
travelling and reads a plate it passes en route, not the target."""

def setUp(self):
self.backend = ExperimentalLiconicBackend(model=LiconicType.STX44_IC, port="/dev/null")
self.backend._racks = [liconic_rack_17mm_22("rack1")]
self.backend._send_command = AsyncMock(return_value="OK")
self.backend._wait_ready = AsyncMock()
self.backend.barcode_scanner = AsyncMock()

async def test_scan_barcode_waits_for_lift(self):
await self.backend.scan_barcode(self.backend._racks[0].sites[0])
self.backend._send_command.assert_any_call("ST 1910")
self.backend._wait_ready.assert_awaited()


class TestSerialization(unittest.TestCase):
def test_serialize_roundtrip(self):
backend = ExperimentalLiconicBackend(model=LiconicType.STX44_IC, port="/dev/ttyUSB0")
Expand Down
Loading