コード例 #1
0
ファイル: aerotech.py プロジェクト: MariaMatveeva/concert
    def __init__(self):
        pos_calib = LinearCalibration(1 / q.deg, 0 * q.deg)
        velo_calib = LinearCalibration(1 / (q.deg / q.sec), 0 * q.deg / q.sec)
        super(Aerorot, self).__init__(pos_calib, velo_calib)

        self["position"].unit = q.deg
        self["velocity"].unit = q.deg / q.sec

        self._connection = Aerotech(Aerorot.HOST, Aerorot.PORT)
        self._connection.execute("ENABLE %s" % (Aerorot.AXIS))
コード例 #2
0
ファイル: aerotech.py プロジェクト: ludovico86/concert
    def reset(self):
        """Reset the controller."""
        # TODO: timeout here?
        linked = False
        self._connection.execute("RESET")

        while not linked:
            try:
                self._connection = Aerotech(HLe.HOST, HLe.PORT)
            except:
                pass
            else:
                linked = True
コード例 #3
0
ファイル: aerotech.py プロジェクト: ludovico86/concert
    def get_positions(self):
        """Get positions stored on the controller's file system."""
        self.program_run(1, "position_readout.bcx")
        positions = []

        conn = Aerotech(HLe.HOST, 8000)

        while True:
            data = conn.execute("NEXT")
            if data == "ERROR":
                msg = "Error reading positions."
                LOG.error(msg)
                raise RuntimeError(msg)
            elif data == "EOF":
                break
            positions.append(float(data))

        return positions
コード例 #4
0
    def __init__(self):
        pos_calib = LinearCalibration(1/q.deg, 0*q.deg)
        velo_calib = LinearCalibration(1/(q.deg/q.sec), 0*q.deg/q.sec)
        super(Aerorot, self).__init__(pos_calib, velo_calib)

        self["position"].unit = q.deg
        self["velocity"].unit = q.deg/q.sec

        self._connection = Aerotech(Aerorot.HOST, Aerorot.PORT)
        self._connection.execute("ENABLE %s" % (Aerorot.AXIS))
コード例 #5
0
ファイル: aerotech.py プロジェクト: MariaMatveeva/concert
class Aerorot(ContinuousMotor):
    HOST = "192.168.18.19"
    PORT = 8001
    AXIS = "X"

    # status constants (bits of the AXISSTATUS output (see HLe docs))
    AXISSTATUS_ENABLED = 0
    AXISSTATUS_HOMED = 1
    AXISSTATUS_IN_POSITION = 2
    AXISSTATUS_MOVE_ACTIVE = 3
    AXISSTATUS_ACCEL_PHASE = 4
    AXISSTATUS_DECEL_PHASE = 5
    AXISSTATUS_POSITION_CAPTURE = 6
    AXISSTATUS_HOMING = 14

    SLEEP_TIME = 0.01

    def __init__(self):
        pos_calib = LinearCalibration(1 / q.deg, 0 * q.deg)
        velo_calib = LinearCalibration(1 / (q.deg / q.sec), 0 * q.deg / q.sec)
        super(Aerorot, self).__init__(pos_calib, velo_calib)

        self["position"].unit = q.deg
        self["velocity"].unit = q.deg / q.sec

        self._connection = Aerotech(Aerorot.HOST, Aerorot.PORT)
        self._connection.execute("ENABLE %s" % (Aerorot.AXIS))

    def __del__(self):
        self._connection.execute("DISABLE %s" % (Aerorot.AXIS))

    def _query_state(self):
        return int(self._connection.execute("AXISSTATUS(%s)" % (Aerorot.AXIS)))

    def _get_position(self):
        return float(self._connection.execute("PFBK(%s)" % (Aerorot.AXIS)))

    def _set_position(self, steps):
        self._connection.execute("MOVEABS %s %f" % (Aerorot.AXIS, steps))

        while not self._query_state() >> Aerorot.AXISSTATUS_IN_POSITION & 1:
            time.sleep(Aerorot.SLEEP_TIME)

    def _get_velocity(self):
        return float(self._connection.execute("VFBK(%s)" % (Aerorot.AXIS)))

    def _set_velocity(self, steps):
        self._connection.execute("FREERUN %s %f" % (Aerorot.AXIS, steps))

        while self._query_state() >> Aerorot.AXISSTATUS_ACCEL_PHASE & 1:
            time.sleep(Aerorot.SLEEP_TIME)

    def _get_state(self):
        res = self._query_state()
        if res >> Aerorot.AXISSTATUS_MOVE_ACTIVE & 1:
            state = Motor.MOVING
        elif res >> Aerorot.AXISSTATUS_IN_POSITION & 1:
            state = Motor.STANDBY
        else:
            state = Motor.NA

        return state

    def _stop(self):
        if self.state == Motor.MOVING:
            self._connection.execute("ABORT %s" % (Aerorot.AXIS))

        while self.state == Motor.MOVING:
            time.sleep(Aerorot.SLEEP_TIME)

    def _home(self):
        self._connection.execute("HOME %s" % (Aerorot.AXIS))

        while self.state == Motor.MOVING:
            time.sleep(Aerorot.SLEEP_TIME)

    def get_digital_in(self, port, bit):
        """Get TTL level on *port* and *bit*."""
        res = self._connection.execute("DIN(%s,%d,%d)" %
                                       (Aerorot.AXIS, port, bit))
        return res == "1"

    def set_digital_out(self, port, bit, value):
        """Set TTL level on *port* and *bit* to *value*"""
        self._connection.execute("DOUT %s, %d, %d:%d" %
                                 (Aerorot.AXIS, port, bit, value))
コード例 #6
0
ファイル: aerotech.py プロジェクト: ludovico86/concert
 def __init__(self):
     self._connection = Aerotech(HLe.HOST, HLe.PORT)
     super(HLe, self).__init__()
     self.ioo = IO(self._connection)
コード例 #7
0
ファイル: aerotech.py プロジェクト: ludovico86/concert
class HLe(Device):

    """Aerotech Ensemble HLe controller."""
    HOST = "192.168.18.19"
    PORT = 8001

    def __init__(self):
        self._connection = Aerotech(HLe.HOST, HLe.PORT)
        super(HLe, self).__init__()
        self.ioo = IO(self._connection)

    def reset(self):
        """Reset the controller."""
        # TODO: timeout here?
        linked = False
        self._connection.execute("RESET")

        while not linked:
            try:
                self._connection = Aerotech(HLe.HOST, HLe.PORT)
            except:
                pass
            else:
                linked = True

    @async
    def get_positions(self):
        """Get positions stored on the controller's file system."""
        self.program_run(1, "position_readout.bcx")
        positions = []

        conn = Aerotech(HLe.HOST, 8000)

        while True:
            data = conn.execute("NEXT")
            if data == "ERROR":
                msg = "Error reading positions."
                LOG.error(msg)
                raise RuntimeError(msg)
            elif data == "EOF":
                break
            positions.append(float(data))

        return positions

    def program_run(self, task, program_name):
        """Execute *program_name* on task number *task*."""
        self._connection.execute("TASKRUN %d, \"%s\"" %
                                 (task, program_name))

    def program_stop(self, task):
        """Stop program execution on task number *task*."""
        self._connection.execute("PROGRAM STOP %d" % (task))

    def get_integer_register(self, register):
        """Get value stored in integer *register* on the controller."""
        self._connection.execute("IGLOBAL(%d)" % (register))

    def set_integer_register(self, register, value):
        """Set *value* stored in integer *register* on the controller."""
        self._connection.execute("IGLOBAL(%d)=%f" % (register, value))

    def get_double_register(self, register):
        """Get value stored in double *register* on the controller."""
        self._connection.execute("DGLOBAL(%d)" % (register))

    def set_double_register(self, register, value):
        """Set *value* stored in double *register* on the controller."""
        self._connection.execute("DGLOBAL(%d)=%f" % (register, value))
コード例 #8
0
ファイル: aerotech.py プロジェクト: MariaMatveeva/concert
 def __init__(self):
     self._connection = Aerotech(HLe.HOST, HLe.PORT)
     self.logger = logbook.Logger(self.__class__, __name__)
     super(HLe, self).__init__()
     self.io = IO(self._connection)
コード例 #9
0
class Aerorot(ContinuousMotor):
    HOST = "192.168.18.19"
    PORT = 8001
    AXIS = "X"

    # status constants (bits of the AXISSTATUS output (see HLe docs))
    AXISSTATUS_ENABLED = 0
    AXISSTATUS_HOMED = 1
    AXISSTATUS_IN_POSITION = 2
    AXISSTATUS_MOVE_ACTIVE = 3
    AXISSTATUS_ACCEL_PHASE = 4
    AXISSTATUS_DECEL_PHASE = 5
    AXISSTATUS_POSITION_CAPTURE = 6
    AXISSTATUS_HOMING = 14

    SLEEP_TIME = 0.01

    def __init__(self):
        pos_calib = LinearCalibration(1/q.deg, 0*q.deg)
        velo_calib = LinearCalibration(1/(q.deg/q.sec), 0*q.deg/q.sec)
        super(Aerorot, self).__init__(pos_calib, velo_calib)

        self["position"].unit = q.deg
        self["velocity"].unit = q.deg/q.sec

        self._connection = Aerotech(Aerorot.HOST, Aerorot.PORT)
        self._connection.execute("ENABLE %s" % (Aerorot.AXIS))

    def __del__(self):
        self._connection.execute("DISABLE %s" % (Aerorot.AXIS))

    def _query_state(self):
        return int(self._connection.execute("AXISSTATUS(%s)" % (Aerorot.AXIS)))

    def _get_position(self):
        return float(self._connection.execute("PFBK(%s)" % (Aerorot.AXIS)))

    def _set_position(self, steps):
        self._connection.execute("MOVEABS %s %f" % (Aerorot.AXIS, steps))

        while not self._query_state() >> Aerorot.AXISSTATUS_IN_POSITION & 1:
            time.sleep(Aerorot.SLEEP_TIME)

    def _get_velocity(self):
        return float(self._connection.execute("VFBK(%s)" % (Aerorot.AXIS)))

    def _set_velocity(self, steps):
        self._connection.execute("FREERUN %s %f" % (Aerorot.AXIS, steps))

        while self._query_state() >> Aerorot.AXISSTATUS_ACCEL_PHASE & 1:
            time.sleep(Aerorot.SLEEP_TIME)

    def _get_state(self):
        res = self._query_state()
        if res >> Aerorot.AXISSTATUS_MOVE_ACTIVE & 1:
            state = Motor.MOVING
        elif res >> Aerorot.AXISSTATUS_IN_POSITION & 1:
            state = Motor.STANDBY
        else:
            state = Motor.NA

        return state

    def _stop(self):
        if self.state == Motor.MOVING:
            self._connection.execute("ABORT %s" % (Aerorot.AXIS))

        while self.state == Motor.MOVING:
            time.sleep(Aerorot.SLEEP_TIME)

    def _home(self):
        self._connection.execute("HOME %s" % (Aerorot.AXIS))

        while self.state == Motor.MOVING:
            time.sleep(Aerorot.SLEEP_TIME)

    def get_digital_in(self, port, bit):
        """Get TTL level on *port* and *bit*."""
        res = self._connection.execute("DIN(%s,%d,%d)" %
                                       (Aerorot.AXIS, port, bit))
        return res == "1"

    def set_digital_out(self, port, bit, value):
        """Set TTL level on *port* and *bit* to *value*"""
        self._connection.execute("DOUT %s, %d, %d:%d" % (Aerorot.AXIS, port,
                                                         bit, value))
コード例 #10
0
 def __init__(self):
     self._connection = Aerotech(HLe.HOST, HLe.PORT)
     self.logger = logbook.Logger(self.__class__, __name__)
     super(HLe, self).__init__()
     self.io = IO(self._connection)