Exemple #1
0
 def wait_for_stat(self, stat=None):
     if self.DEBUG_ON:
         log.debug("Serial", "Turning on debug mode.")
         log.debug("Serial", "Awaiting stat responses.")
         self.send_command(self.DEBUG_ON)
         self._wait_for_stat = True
         if stat is not None:
             self._stat_command = stat
Exemple #2
0
 def _run(self, index):
     kwargs = copy.deepcopy(self._commands[index])
     command = kwargs.pop('command')
     self._run_in_context_handler(command, **kwargs)
     for h in self._handlers:
         debug("Protocol",
               "{}.{}: {}".format(type(h).__name__, command, kwargs))
         h.before_each()
         method = getattr(h, command)
         method(**kwargs)
         h.after_each()
Exemple #3
0
    def move(self,
             x=None,
             y=None,
             z=None,
             speed=None,
             absolute=True,
             **kwargs):

        if speed:
            code = self.MOVE
        else:
            code = self.RAPID_MOVE

        if absolute:
            self.send_command(self.ABSOLUTE_POSITIONING)
        else:
            self.send_command(self.RELATIVE_POSITIONING)

        args = {}
        """
        Add x, y and z back to the kwargs.  They're omitted when we name them
        as explicit keyword arguments, but it's much nicer to be able to pass
        them as anonymous parameters when calling this method.
        """
        if x is not None:
            args['x'] = x
        if y is not None:
            args['y'] = y
        if z is not None:
            args['z'] = z

        for k in kwargs:
            args[k.upper()] = kwargs[k]

        log.debug("MotorDriver", "Moving: {}".format(args))

        self.send_command(code, **args)
Exemple #4
0
 def write_to_serial(self, data, max_tries=10, try_interval=0.2):
     log.debug("Serial", "Write: {}".format(str(data).encode()))
     if self.connection is None:
         log.warn("Serial", "No connection found.")
         return
     if self.connection.isOpen():
         self.connection.write(str(data).encode())
         if self._wait_for_stat is True and self._stat_command:
             waiting = True
             count = 0
             while waiting:
                 count = count + 1
                 out = self.connection.readline().decode().strip()
                 log.debug("Serial", "Read: {}".format(out))
                 if out == self._stat_command:
                     waiting = False
                     log.debug("Serial",
                               "Waited {} lines for stat.".format(count))
                 else:
                     if count == 1 or count % 10 == 0:
                         # Don't log all the time; gets spammy.
                         log.debug(
                             "Serial",
                             "Waiting {} lines for stat ({}).".format(
                                 count, self._stat_command))
         else:
             out = self.connection.readline()
             log.debug("Serial", "Read: {}".format(out))
         return out
     elif max_tries > 0:
         time.sleep(try_interval)
         self.write_to_serial(data,
                              max_tries=max_tries - 1,
                              try_interval=try_interval)
     else:
         log.error("Serial", "Cannot connect to serial port.")
Exemple #5
0
 def connect(self, device=None, port=None):
     self.connection = serial.Serial(port=device or port)
     self.connection.close()
     self.connection.open()
     log.debug("Serial", "Connected to {}".format(device or port))
     self.wait_for_stat()
Exemple #6
0
 def write(self, data):
     if self.isOpen() is False:
         raise IOError("Connection not open.")
     log.debug('GCodeLogger', 'Writing: {}'.format(data))
     self.write_buffer.append(data)
Exemple #7
0
 def move_motors(self, **kwargs):
     debug("MotorHandler", "Moving: {}".format(kwargs))
     self._driver.move(**kwargs)
Exemple #8
0
 def droptip(self):
     debug("PipetteMotor",
           "Droptip on {} axis ({}).".format(self.axis, self.name))
     self.move_axis(self.droptip_depth)
Exemple #9
0
 def blowout(self):
     debug("PipetteMotor",
           "Blowout on {} axis ({}).".format(self.axis, self.name))
     self.move_axis(self.pipette.blowout_depth)
Exemple #10
0
 def plunge(self, volume):
     debug(
         "PipetteMotor", "Plunging {} axis ({}) to volume of {}µl.".format(
             self.axis, self.name, volume))
     depth = self.pipette.plunge_depth(volume)
     self.move_axis(depth)
Exemple #11
0
 def reset(self):
     debug("PipetteMotor",
           "Resetting {} axis ({}).".format(self.axis, self.name))
     self.move_axis(0)