Skip to content

Commit

Permalink
checks for tip in both mix and replace commands
Browse files Browse the repository at this point in the history
  • Loading branch information
abestroka committed Jun 19, 2024
1 parent 24ce0c7 commit 3f0426d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 6 deletions.
1 change: 0 additions & 1 deletion ot2_driver/protopiler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ def check_list_lengths_match(self) -> "Transfer":

class Mix(CommandBase):
"""The mix command, used to mix liquids in a wellplate"""

command: Literal["mix"]
"""The command to execute, should be mix for this class"""
reps: Union[int, List[int]]
Expand Down
61 changes: 56 additions & 5 deletions ot2_driver/protopiler/protopiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,11 +919,37 @@ def _create_commands(self, payload: Optional[Dict]) -> List[str]:
commands.append(temp_change_command)

elif isinstance(command_block, Mix):


if (
isinstance(command_block.location, str)
and isinstance(command_block.reps, int)
and isinstance(command_block.mix_volume, float)
):
pipette_mount = self.resource_manager.determine_pipette(
command_block.mix_volume, False
)
if pipette_mount is None:
raise Exception(
f"No pipette available for {block_name} with volume: {command_block.mix_volume}"
)
#TODO: make more robust
# # check for tip
if not tip_loaded[pipette_mount]:

load_command = pick_tip_template.replace(
"#pipette#", f'pipettes["{pipette_mount}"]'
)
pipette_name = self.resource_manager.mount_to_pipette[
pipette_mount
]

commands.append(load_command)
tip_loaded[pipette_mount] = True




mix_command = mix_template.replace(
"#reps#", str(command_block.reps)
)
Expand Down Expand Up @@ -985,6 +1011,27 @@ def _create_commands(self, payload: Optional[Dict]) -> List[str]:
else:
mix_reps = command_block.reps

pipette_mount = self.resource_manager.determine_pipette(
command_block.mix_volumes[0], False
)

if pipette_mount is None:
raise Exception(
f"No pipette available for {block_name} with volume: {command_block.mix_volume}"
)
# # check for tip
if not tip_loaded[pipette_mount]:

load_command = pick_tip_template.replace(
"#pipette#", f'pipettes["{pipette_mount}"]'
)
pipette_name = self.resource_manager.mount_to_pipette[
pipette_mount
]

commands.append(load_command)
tip_loaded[pipette_mount] = True

for loc, mix_vols, rep in zip(locations, mix_volumes, mix_reps):
mix_command = mix_template.replace("#reps#", str(rep))
mix_command = mix_command.replace("#volume#", str(mix_vols))
Expand All @@ -1007,11 +1054,15 @@ def _create_commands(self, payload: Optional[Dict]) -> List[str]:
elif isinstance(command_block, Replace_Tip):
if not isinstance(command_block.replace_tip, bool):
raise Exception("replace_tip must be bool")
replace_tip_command = return_tip_template.replace(
"#pipette#", f'pipettes["{pipette_mount}"]'
)
commands.append(replace_tip_command)
tip_loaded[pipette_mount] = False
# check if tip on pipette
if tip_loaded[pipette_mount] == False:
print("NO TIP TO REPLACE")
else:
replace_tip_command = return_tip_template.replace(
"#pipette#", f'pipettes["{pipette_mount}"]'
)
commands.append(replace_tip_command)
tip_loaded[pipette_mount] = False

elif isinstance(command_block, Clear_Pipette):
if not isinstance(command_block.clear, bool):
Expand Down

0 comments on commit 3f0426d

Please sign in to comment.