diff --git a/ot2_driver/protopiler/config.py b/ot2_driver/protopiler/config.py index 52f9080..f074541 100644 --- a/ot2_driver/protopiler/config.py +++ b/ot2_driver/protopiler/config.py @@ -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]] diff --git a/ot2_driver/protopiler/protopiler.py b/ot2_driver/protopiler/protopiler.py index 0a07598..98b8612 100644 --- a/ot2_driver/protopiler/protopiler.py +++ b/ot2_driver/protopiler/protopiler.py @@ -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) ) @@ -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)) @@ -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):