def stopPump(self): if self.dispensing: self.toggle_dispense() else: print_error("Pump is not running", self.stop_on_errors)
def __init__(self, port, **kwargs): ''' Set up a pump object, connect to the pump via serial io and optionally run initial configurations. Input: com: the serial port number that the pump is connected to as an int. **kwargs <optional keyword arguments> stop_on_errors: instruct the error handling to halt the program upon an error if Boolean True defaults to False trigger: set the trigger method 'com' or 'DO' defaults to 'com' pressure_units: the pressure units you would like to set, defaults to whatever is on the pump vacuum_units: the vacuum units you would like to set, defaults to whatever is on the pump pressure: float value of the pressure to set For DO only: A3200: the A3200 instance ''' self.no_pump = False self.debug = False self.pressure_units = None self.vacuum_units = None self.pressure = -1 self.vacuum = -1 self.pump = serial.Serial(port=port, baudrate=115200, parity=serial.PARITY_NONE, bytesize=serial.EIGHTBITS, stopbits=serial.STOPBITS_ONE, timeout=0.125) self.dispensing = False if 'stop_on_errors' in kwargs: self.stop_on_errors = kwargs['stop_on_errors'] else: self.stop_on_errors = False if 'trigger' in kwargs: self.trigger = 'com' #default to com if kwargs['trigger'].lower() is 'do': self.trigger = "DO" try: self.A3200 = kwargs['A3200'] self.trigger_bit = kwargs['bit'] self.trigger_axis = kwargs['axis'] except KeyError: print_error( "DO triggering requires an A3200 instance, axis, and bit number, defaulting to com", self.stop_on_errors) self.trigger = 'com' else: self.trigger = 'com' if 'pressure_units' in kwargs: self.set_pressure_units(kwargs['pressure_units']) else: self.get_pressure_units() if 'vacuum_units' in kwargs: self.set_vacuum_units(kwargs['pressure_units']) else: self.get_vacuum_units() if 'pressure' in kwargs: self.set_pressure(kwargs['pressure']) if 'vacuum' in kwargs: self.set_pressure(kwargs['vacuum'])
def startPump(self): if not self.dispensing: self.toggle_dispense() #self.sleep(self.dispense_delay) else: print_error("Pump is already running", self.stop_on_errors)