Esempio n. 1
0
class PixOrbShutter(AbstractPixOrbHardware, ShutterPlugin):
    def _init(self):
        Logger().trace("PixOrbShutter._init()")
        AbstractPixOrbHardware._init(self)
        ShutterPlugin._init(self)
        self._hardware = PixOrbHardware()

    def _defineConfig(self):
        AbstractPixOrbHardware._defineConfig(self)
        ShutterPlugin._defineConfig(self)

    def init(self):
        Logger().trace("PixOrbAxis.init()")
        self._hardware.setAxis(AXIS_TABLE[self.capacity])
        #self._hardware.setBreakAxis(BREAK_TABLE[self.capacity])
        AbstractHardwarePlugin.init(self)
        self.configure()

    def _triggerOnShutter(self):
        """ Set the shutter on.
        """
        self._hardware.setOutput(True)

    def _triggerOffShutter(self):
        """ Set the shutter off.
        """
        self._hardware.setOutput(False)

    def shutdown(self):
        Logger().trace("PixOrbShutter.shutdown()")
        self._triggerOffShutter()
        ShutterPlugin.shutdown(self)
Esempio n. 2
0
 def _init(self):
     Logger().trace("PixOrbShutter._init()")
     AbstractPixOrbHardware._init(self)
     ShutterPlugin._init(self)
     self._hardware = PixOrbHardware()
Esempio n. 3
0
 def _init(self):
     Logger().trace("PixOrbAxis._init()")
     AbstractPixOrbHardware._init(self)
     AbstractAxisPlugin._init(self)
     self._hardware = PixOrbHardware()
Esempio n. 4
0
class PixOrbAxis(AbstractPixOrbHardware, AbstractAxisPlugin):
    def _init(self):
        Logger().trace("PixOrbAxis._init()")
        AbstractPixOrbHardware._init(self)
        AbstractAxisPlugin._init(self)
        self._hardware = PixOrbHardware()

    def _defineConfig(self):
        AbstractAxisPlugin._defineConfig(self)
        AbstractHardwarePlugin._defineConfig(self)
        self._addConfigKey('_speedIndex', 'SPEED_INDEX', default=DEFAULT_SPEED_INDEX)
        self._addConfigKey('_axisWithBreak', 'AXIS_WITH_BREAK', default=DEFAULT_AXIS_WITH_BREAK)
        self._addConfigKey('_axisAccuracy', 'AXIS_ACCURACY', default=DEFAULT_AXIS_ACCURACY)

    def init(self):
        Logger().trace("PixOrbAxis.init()")
        self._hardware.setAxis(AXIS_TABLE[self.capacity])
        self._hardware.setBreakAxis(BREAK_TABLE[self.capacity])
        AbstractHardwarePlugin.init(self)
        self.configure()

    def shutdown(self):
        Logger().trace("PixOrbAxis.shutdown()")
        self.stop()
        AbstractAxisPlugin.shutdown(self)

    def configure(self):
        Logger().trace("PixOrbAxis.configure()")
        AbstractAxisPlugin.configure(self)
        self._hardware.configure(self._config['SPEED_INDEX'])

    def read(self):
        position = self._hardware.read()

        # Reverse direction on yaw axis
        if self.capacity == 'yawAxis':
            position *= -1

        position -= self._offset

        return position

    def drive(self, position, useOffset=True, wait=True):
        Logger().debug("PixOrbAxis.drive(): '%s' drive to %.1f" % (self.capacity, position))

        currentPos = self.read()
        if abs(position - currentPos) <= self._config['AXIS_ACCURACY'] or not useOffset:
            return

        self._checkLimits(position)

        if useOffset:
            position += self._offset

        # Reverse direction on yaw axis
        if self.capacity == 'yawAxis':
            position *= -1

        if self._config['AXIS_WITH_BREAK']:
            self._hardware.releaseBreak()
        self._hardware.configure(self._config['SPEED_INDEX'])
        self._hardware.drive(position)

        # Wait end of movement
        if wait:
            self.waitEndOfDrive()

    def waitEndOfDrive(self):
        #self._wait()
        while self.isMoving():
            time.sleep(config.SPY_REFRESH_DELAY / 1000.)
        self.waitStop()

    def startJog(self, dir_):

        # Reverse direction on yaw axis
        if self.capacity == 'yawAxis':
            if dir_ == '+':
                dir_ = '-'
            else:
                dir_ = '+'

        if self._config['AXIS_WITH_BREAK']:
            self._hardware.releaseBreak()
        self._hardware.configure(MANUAL_SPEED_TABLE[self._manualSpeed])
        self._hardware.startJog(dir_, MANUAL_SPEED_TABLE[self._manualSpeed])

    def stop(self):
        self._hardware.stop()
        self.waitStop()

    def waitStop(self):
        if self._config['AXIS_WITH_BREAK']:
            self._hardware.activateBreak()

    def isMoving(self):
        status = self._hardware.getStatus()
        if status != '0':
            return True
        else:
            return False