"""
Datum Labware — 60-Second Alignment & Datum Verification Protocol
SKU: DL-SCINT8-POM | Load Name: datum_8_tuberack_scintillation_20ml_28x61mm

How to use:
1. Import `datum_8_tuberack_scintillation_20ml_28x61mm.json` in the Opentrons App -> Labware -> Import.
2. Place your Datum Labware rack (DL-SCINT8-POM) in Deck Slot C2 (Flex) or Slot 5 (OT-2) with EMPTY, UNCAPPED tubes in A1 and B4.
3. Attach a single-channel pipette with one tip and run this dry verification check.
   The robot pauses for 5 seconds at:
   - A1 top center (Z = tube rim + 2.0 mm)
   - A1 safe bottom clearance (Z = well bottom + 2.0 mm)
   - B4 top center (Z = tube rim + 2.0 mm)
"""
from opentrons import protocol_api

metadata = {
    "protocolName": "Datum Labware Alignment Check — DL-SCINT8-POM",
    "author": "Datum Labware <lena@datumlabware.com>",
    "description": "Dry-run coordinate verification for Datum Labware 8 Well CNC Delrin Rack with 20 mL Scintillation Vial",
}

requirements = {"robotType": "OT-2", "apiLevel": "2.19"}


def run(protocol: protocol_api.ProtocolContext):
    # Change slot to 'C2' and robotType to 'Flex' if running on Opentrons Flex
    rack = protocol.load_labware("datum_8_tuberack_scintillation_20ml_28x61mm", "5")
    pipette = protocol.load_instrument("p300_single_gen2", "right")

    protocol.comment("Verifying Datum Labware DL-SCINT8-POM: moving to A1 top + 2mm")
    pipette.move_to(rack["A1"].top(z=2.0))
    protocol.delay(seconds=5)

    protocol.comment("Moving to A1 bottom + 2mm safe clearance")
    pipette.move_to(rack["A1"].bottom(z=2.0))
    protocol.delay(seconds=5)

    protocol.comment("Moving to opposite diagonal well B4 top + 2mm")
    pipette.move_to(rack["B4"].top(z=2.0))
    protocol.delay(seconds=5)

    protocol.comment("Datum verification complete.")
