Skip to content

Commit

Permalink
Adds git_all_pumps() and get_pumps_in_group() to multipump controller
Browse files Browse the repository at this point in the history
Method to get all the pump objects in the controller object or those
belonging to a specific group.
  • Loading branch information
Dario Cambie committed Jun 5, 2019
1 parent baff679 commit 058252f
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions pycont/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,20 +1299,52 @@ def set_pumps_as_attributes(self):

def get_pumps(self, pump_names):
"""
Obtains a list of all pumps.
Obtains a list of all pumps with name in pump_names.
Args:
pump_names (List): A list of the pump names
Returns:
pumps (List): A list of the pump names.
pumps (List): A list of the pump objects.
"""
pumps = []
for pump_name in pump_names:
pumps.append(self.pumps[pump_name])
return pumps

def get_all_pumps(self):
"""
Obtains a list of all pumps.
Returns:
pumps (List): A list of the all the pump objects in the Controller.
"""

return self.pumps

def get_pumps_in_group(self, group_name):
"""
Obtains a list of all pumps with group_name.
Args:
group_name (List): The group name
Returns:
pumps (List): A list of the pump objects in the group. None for non-existing groups.
"""
pumps = []
try:
pump_list = self.groups[group_name]
except KeyError:
return None

for pump_name in pump_list:
pumps.append(self.pumps[pump_name])
return pumps

def apply_command_to_pumps(self, pump_names, command, *args, **kwargs):
"""
Applies a given command to the pumps.
Expand Down Expand Up @@ -1546,7 +1578,7 @@ def transfer(self, pump_names, volume_in_ml, from_valve, to_valve, speed_in=None
secure (bool): Ensures that everything is correct, default set to False.
"""
volume_transfered = 1000000 # some big number 1000L is more than any descent person will try
volume_transfered = 1000000 # some big number 1000L is more than any decent person will try
for pump in self.get_pumps(pump_names):
candidate_volume = min(volume_in_ml, pump.remaining_volume)
volume_transfered = min(candidate_volume, volume_transfered)
Expand Down

0 comments on commit 058252f

Please sign in to comment.