Skip to content

Commit

Permalink
BUGFIX: parallel_transfer() errors :D
Browse files Browse the repository at this point in the history
  • Loading branch information
Dario Cambie committed Jul 16, 2019
1 parent 7397001 commit 649d74a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pycont/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1628,22 +1628,27 @@ def parallel_transfer(self, pumps_and_volumes_dict: dict, from_valve: str, to_va
self.apply_command_to_pumps(list(pumps_and_volumes_dict.keys()), "wait_until_idle")

# Pump the target volume (or the maximum possible) for each pump
for pump_name, pump_target_volume in pumps_and_volumes_dict:
for pump_name, pump_target_volume in pumps_and_volumes_dict.items():
# Get pump
pump = self.get_pumps(pump_name)
try:
pump = self.pumps[pump_name]
except KeyError:
self.logger.warning(f"Pump specified {pump_name} not found in the controller! (Available: {self.pumps}")
return False

# Find the volume to transfer (maximum pumpable or target, whatever is lower)
volume_to_transfer[pump_name] = min(pump_target_volume, pump.remaining_volume)
pump.pump(volume_in_ml=volume_to_transfer, from_valve=from_valve, speed_in=speed_in, wait=False, secure=secure)
pump.pump(volume_in_ml=volume_to_transfer[pump_name], from_valve=from_valve, speed_in=speed_in, wait=False,
secure=secure)

# Calculate remaining volume
remaining_volume[pump_name] = pump_target_volume - volume_to_transfer[pump_name]

# Wait until all the pumps have pumped to start deliver
self.apply_command_to_pumps(list(pumps_and_volumes_dict.keys()), "wait_until_idle")

for pump_name, volume_to_deliver in remaining_volume:
pump = self.get_pumps(pump_name)
for pump_name, volume_to_deliver in volume_to_transfer.items():
pump = self.pumps[pump_name] # This cannot fail otherwise it would have failed in pumping ;)
pump.deliver(volume_in_ml=volume_to_deliver, wait=False, to_valve=to_valve, speed_out=speed_out)

left_to_pump = {pump: volume for pump, volume in remaining_volume.items() if volume > 0}
Expand Down

0 comments on commit 649d74a

Please sign in to comment.