예제 #1
0
class ARRW60(base.TarableScales):
    """The ARRW60 model of Adventurer scales."""
    ERROR = "error"
    OK = "ok"

    def __init__(self, host, port):
        super(ARRW60, self).__init__()
        self._connection = SocketConnection(host, port, "\r\n")
        self._states = self._states.union(set([ARRW60.OK, ARRW60.ERROR]))

    def _execute(self, cmd):
        result = self._connection.execute(cmd)
        if "OK!" not in result:
            raise ValueError("Bad command or value")

    def _tare(self):
        self._execute("T")

    def _get_weight(self):
        """
        Get weight from the scales. The command does not return until
        a balanced position is found, thus it can time out.
        """
        res = self._connection.execute("P")
        if "Err8.4" in res:
            self._set_state(ARRW60.ERROR)
            raise WeightError("More than maximum weight loaded")
        else:
            if self.state == ARRW60.ERROR or self.state == Device.NA:
                # Clear the error from before or set OK for the first time
                self._set_state(ARRW60.OK)
            # The returned string contains units
            res = q.Quantity(res).to(q.g)

        return float(res.magnitude) * q.counts
예제 #2
0
파일: crio.py 프로젝트: ludovico86/concert
class LinearMotor(Motor):

    """A linear motor that moves in two directions."""

    def __init__(self):
        calibration = LinearCalibration(50000 / q.mm, -1 * q.mm)
        super(LinearMotor, self).__init__(calibration)

        self._connection = SocketConnection(CRIO_HOST, CRIO_PORT)
        self['position'].limiter = lambda x: x >= 0 * q.mm and x <= 2 * q.mm

        self._home()
        self._steps = 0

    def _get_position(self):
        return self._steps

    def _set_position(self, steps):
        self._connection.send('lin %i\r\n' % steps)
        self._connection.recv()
        self._steps = steps

    def _stop(self):
        pass

    def _home(self):
        self._set_position(0)
예제 #3
0
파일: crio.py 프로젝트: ludovico86/concert
    def __init__(self):
        calibration = LinearCalibration(50000 / q.mm, 0 * q.mm)
        super(RotationMotor, self).__init__(calibration)

        self._steps = 0
        self._connection = SocketConnection(CRIO_HOST, CRIO_PORT)
        self['position'].limiter = lambda x: x >= 0 * q.mm and x <= 2 * q.mm
예제 #4
0
파일: crio.py 프로젝트: ludovico86/concert
class LinearMotor(Motor):
    """A linear motor that moves in two directions."""
    def __init__(self):
        calibration = LinearCalibration(50000 / q.mm, -1 * q.mm)
        super(LinearMotor, self).__init__(calibration)

        self._connection = SocketConnection(CRIO_HOST, CRIO_PORT)
        self['position'].limiter = lambda x: x >= 0 * q.mm and x <= 2 * q.mm

        self._home()
        self._steps = 0

    def _get_position(self):
        return self._steps

    def _set_position(self, steps):
        self._connection.send('lin %i\r\n' % steps)
        self._connection.recv()
        self._steps = steps

    def _stop(self):
        pass

    def _home(self):
        self._set_position(0)
예제 #5
0
 def __init__(self, host=DEFAULT_CRIO_HOST, port=DEFAULT_CRIO_PORT_LINEAR):
     super(LinearMotor, self).__init__()
     self._connection = SocketConnection(host, port, '\r\n')
     self._position = 0 * q.mm
     self._to_device_scale = 50000
     self['position'].lower = 0 * q.mm
     self['position'].upper = 2 * q.mm
예제 #6
0
 def __init__(self,
              host=DEFAULT_CRIO_HOST,
              port=DEFAULT_CRIO_PORT_ROTATIONAL):
     super(RotationMotor, self).__init__()
     self._connection = SocketConnection(host, port, '\r\n')
     self._position = 0 * q.deg
     self._velocity = 0 * q.deg / q.s
     self._to_device_scale = 2
예제 #7
0
파일: crio.py 프로젝트: ludovico86/concert
    def __init__(self):
        calibration = LinearCalibration(50000 / q.mm, 0 * q.mm)
        super(RotationMotor, self).__init__(calibration)

        self._steps = 0
        self._connection = SocketConnection(CRIO_HOST, CRIO_PORT)
        self['position'].limiter = lambda x: x >= 0 * q.mm and x <= 2 * q.mm
예제 #8
0
파일: crio.py 프로젝트: ufo-kit/concert
 def __init__(self, host=DEFAULT_CRIO_HOST, port=DEFAULT_CRIO_PORT_LINEAR):
     super(LinearMotor, self).__init__()
     self._connection = SocketConnection(host, port, '\r\n')
     self._position = 0 * q.mm
     self._to_device_scale = 50000
     self['position'].lower = 0 * q.mm
     self['position'].upper = 2 * q.mm
예제 #9
0
class LinearMotor(base.LinearMotor):
    """A linear motor that moves in two directions."""
    def __init__(self, host=DEFAULT_CRIO_HOST, port=DEFAULT_CRIO_PORT_LINEAR):
        super(LinearMotor, self).__init__()
        self._connection = SocketConnection(host, port, '\r\n')
        self._position = 0 * q.mm
        self._to_device_scale = 50000
        self['position'].lower = 0 * q.mm
        self['position'].upper = 2 * q.mm

    def _get_position(self):
        return self._position / self._to_device_scale

    def _set_position(self, position):
        self._position = position.to(q.mm) * self._to_device_scale
        self._connection.execute('lin {} 5000'.format(int(self._position)))

    def _stop(self):
        self._connection.execute('mod stop')
예제 #10
0
파일: crio.py 프로젝트: ludovico86/concert
class RotationMotor(Motor):
    """A rotational motor."""
    def __init__(self):
        calibration = LinearCalibration(50000 / q.mm, 0 * q.mm)
        super(RotationMotor, self).__init__(calibration)

        self._steps = 0
        self._connection = SocketConnection(CRIO_HOST, CRIO_PORT)
        self['position'].limiter = lambda x: x >= 0 * q.mm and x <= 2 * q.mm

    def _get_position(self):
        return self._steps

    def _set_position(self, steps):
        self._steps = steps
        self._connection.send('rot %i\r\n' % steps)
        self._connection.recv()

    def _stop(self):
        pass
예제 #11
0
파일: crio.py 프로젝트: ufo-kit/concert
class LinearMotor(base.LinearMotor):

    """A linear motor that moves in two directions."""

    def __init__(self, host=DEFAULT_CRIO_HOST, port=DEFAULT_CRIO_PORT_LINEAR):
        super(LinearMotor, self).__init__()
        self._connection = SocketConnection(host, port, '\r\n')
        self._position = 0 * q.mm
        self._to_device_scale = 50000
        self['position'].lower = 0 * q.mm
        self['position'].upper = 2 * q.mm

    def _get_position(self):
        return self._position / self._to_device_scale

    def _set_position(self, position):
        self._position = position.to(q.mm) * self._to_device_scale
        self._connection.execute('lin {} 5000'.format(int(self._position)))

    def _stop(self):
        self._connection.execute('mod stop')
예제 #12
0
파일: crio.py 프로젝트: ufo-kit/concert
class RotationMotor(base.ContinuousRotationMotor):

    """A rotational motor."""

    def __init__(self, host=DEFAULT_CRIO_HOST, port=DEFAULT_CRIO_PORT_ROTATIONAL):
        super(RotationMotor, self).__init__()
        self._connection = SocketConnection(host, port, '\r\n')
        self._position = 0 * q.deg
        self._velocity = 0 * q.deg / q.s
        self._to_device_scale = 2

    def _in_hard_limit(self):
        return False

    def _in_velocity_hard_limit(self):
        return False

    def _get_position(self):
        return self._position / self._to_device_scale

    def _set_position(self, position):
        self._position = position * self._to_device_scale
        self._connection.execute('rot {} 500'.format(int(self._position)))

    def _get_velocity(self):
        return 0 * q.deg / q.s

    def _set_velocity(self, velocity):
        self._velocity = velocity * self._to_device_scale
        self._connection.execute('mod {}'.format(int(self._velocity)))

    def _stop(self):
        self._connection.execute('mod stop')
예제 #13
0
class RotationMotor(base.ContinuousRotationMotor):
    """A rotational motor."""
    def __init__(self,
                 host=DEFAULT_CRIO_HOST,
                 port=DEFAULT_CRIO_PORT_ROTATIONAL):
        super(RotationMotor, self).__init__()
        self._connection = SocketConnection(host, port, '\r\n')
        self._position = 0 * q.deg
        self._velocity = 0 * q.deg / q.s
        self._to_device_scale = 2

    def _in_hard_limit(self):
        return False

    def _in_velocity_hard_limit(self):
        return False

    def _get_position(self):
        return self._position / self._to_device_scale

    def _set_position(self, position):
        self._position = position * self._to_device_scale
        self._connection.execute('rot {} 500'.format(int(self._position)))

    def _get_velocity(self):
        return 0 * q.deg / q.s

    def _set_velocity(self, velocity):
        self._velocity = velocity * self._to_device_scale
        self._connection.execute('mod {}'.format(int(self._velocity)))

    def _stop(self):
        self._connection.execute('mod stop')
예제 #14
0
파일: crio.py 프로젝트: ludovico86/concert
class RotationMotor(Motor):

    """A rotational motor."""

    def __init__(self):
        calibration = LinearCalibration(50000 / q.mm, 0 * q.mm)
        super(RotationMotor, self).__init__(calibration)

        self._steps = 0
        self._connection = SocketConnection(CRIO_HOST, CRIO_PORT)
        self['position'].limiter = lambda x: x >= 0 * q.mm and x <= 2 * q.mm

    def _get_position(self):
        return self._steps

    def _set_position(self, steps):
        self._steps = steps
        self._connection.send('rot %i\r\n' % steps)
        self._connection.recv()

    def _stop(self):
        pass
예제 #15
0
class ARRW60(base.TarableScales):

    """The ARRW60 model of Adventurer scales."""
    ERROR = "error"
    OK = "ok"

    def __init__(self, host, port):
        super(ARRW60, self).__init__(LinearCalibration(q.counts / q.g,
                                                       0 * q.g))
        self._connection = SocketConnection(host, port, "\r\n")
        self._states = self._states.union(set([ARRW60.OK, ARRW60.ERROR]))

    def _execute(self, cmd):
        result = self._connection.execute(cmd)
        if "OK!" not in result:
            raise ValueError("Bad command or value")

    def _tare(self):
        self._execute("T")

    def _get_weight(self):
        """
        Get weight from the scales. The command does not return until
        a balanced position is found, thus it can time out.
        """
        res = self._connection.execute("P")
        if "Err8.4" in res:
            self._set_state(ARRW60.ERROR)
            raise WeightError("More than maximum weight loaded")
        else:
            if self.state == ARRW60.ERROR or self.state == Device.NA:
                # Clear the error from before or set OK for the first time
                self._set_state(ARRW60.OK)
            # The returned string contains units
            res = q.Quantity(res).to(q.g)

        return float(res.magnitude) * q.counts
예제 #16
0
 def __init__(self, host, port):
     super(ARRW60, self).__init__()
     self._connection = SocketConnection(host, port, "\r\n")
     self._states = self._states.union(set([ARRW60.OK, ARRW60.ERROR]))
예제 #17
0
파일: crio.py 프로젝트: ufo-kit/concert
 def __init__(self, host=DEFAULT_CRIO_HOST, port=DEFAULT_CRIO_PORT_ROTATIONAL):
     super(RotationMotor, self).__init__()
     self._connection = SocketConnection(host, port, '\r\n')
     self._position = 0 * q.deg
     self._velocity = 0 * q.deg / q.s
     self._to_device_scale = 2
예제 #18
0
 def __init__(self, host, port):
     super(ARRW60, self).__init__(LinearCalibration(q.counts / q.g,
                                                    0 * q.g))
     self._connection = SocketConnection(host, port, "\r\n")
     self._states = self._states.union(set([ARRW60.OK, ARRW60.ERROR]))
예제 #19
0
 def __init__(self, host, port):
     super(ARRW60, self).__init__()
     self._connection = SocketConnection(host, port, "\r\n")
     self._states = self._states.union(set([ARRW60.OK, ARRW60.ERROR]))
예제 #20
0
 def __init__(self, host, port):
     super(ARRW60, self).__init__(LinearCalibration(q.counts / q.g,
                                                    0 * q.g))
     self._connection = SocketConnection(host, port, "\r\n")
     self._states = self._states.union(set([ARRW60.OK, ARRW60.ERROR]))