Example #1
0
 def _init(self):
     Logger().trace("ClaussShutter._init()")
     AbstractHardwarePlugin._init(self)
     ShutterPlugin._init(self)
     self._hardware = ClaussHardware()
Example #2
0
 def _init(self):
     Logger().trace("ClaussAxis._init()")
     AbstractHardwarePlugin._init(self)
     AbstractAxisPlugin._init(self)
     self._hardware = ClaussHardware()
Example #3
0
class ClaussShutter(AbstractHardwarePlugin, ShutterPlugin):
    def _init(self):
        Logger().trace("ClaussShutter._init()")
        AbstractHardwarePlugin._init(self)
        ShutterPlugin._init(self)
        self._hardware = ClaussHardware()

    def _defineConfig(self):
        AbstractHardwarePlugin._defineConfig(self)
        ShutterPlugin._defineConfig(self)
        self._addConfigKey("_focus", "FOCUS_ENABLE", default=DEFAULT_FOCUS_ENABLE)
        self._addConfigKey("_focus_time", "FOCUS_TIME", default=DEFAULT_FOCUS_TIME)
        self._addConfigKey("_dual", "DUAL_ENABLE", default=DEFAULT_DUAL_ENABLE)
        self._addConfigKey("_dual_time", "DUAL_TIME", default=DEFAULT_DUAL_TIME)

    def _triggerShutter(self, delay):
        """ Trigger the shutter contact.

        Note that FOCUS_ENABLE and DUAL_ENABLE options are exclusive (done via UI)

        @param delay: delay to wait between on/off, in s
        @type delay: float
        """
        Logger().trace("ClaussShutter._triggerShutter()")

        # Autofocus mode enable
        if self._config["FOCUS_ENABLE"]:
            self._triggerAutoFocus()
            time.sleep(self._config["FOCUS_TIME"])

        # Shoot regular camera
        self._triggerOnShutter()
        time.sleep(delay)
        self._triggerOffShutter()

        # Dual camera mode
        if self._config["DUAL_ENABLE"]:
            time.sleep(self._config["DUAL_TIME"])
            Logger().info("ClaussShutter._triggerShutter(): dual camera shoot")
            self._triggerAutoFocus()
            time.sleep(delay)
            self._triggerOffShutter()

        self._LastShootTime = time.time()

    def _triggerAutoFocus(self):
        """ Set the autofocus on.
        """
        self._hardware.setShutter("AF")

    def _triggerOnShutter(self):
        """ Set the shutter on.
        """
        self._hardware.setShutter("ON")

    def _triggerOffShutter(self):
        """ Set the shutter off.
        """
        self._hardware.setShutter("OFF")

    def init(self):
        Logger().trace("ClaussShutter.init()")
        self._hardware.setAxis(AXIS_TABLE[self.capacity]),
        AbstractHardwarePlugin.init(self)

    def shutdown(self):
        Logger().trace("ClaussShutter.shutdown()")
        self._triggerOffShutter()
        AbstractHardwarePlugin.shutdown(self)
        ShutterPlugin.shutdown(self)
Example #4
0
class ClaussAxis(AbstractHardwarePlugin, AbstractAxisPlugin):
    def _init(self):
        Logger().trace("ClaussAxis._init()")
        AbstractHardwarePlugin._init(self)
        AbstractAxisPlugin._init(self)
        self._hardware = ClaussHardware()

    def _defineConfig(self):
        AbstractAxisPlugin._defineConfig(self)
        AbstractHardwarePlugin._defineConfig(self)
        self._addConfigKey("_speedSlow", "SPEED_SLOW", default=DEFAULT_SPEED_SLOW)
        self._addConfigKey("_speedNormal", "SPEED_NORMAL", default=DEFAULT_SPEED_NORMAL)
        self._addConfigKey("_speedFast", "SPEED_FAST", default=DEFAULT_SPEED_FAST)
        self._addConfigKey("_parkPosition", "PARK_POSITION", default=DEFAULT_PARK_POSITION)
        if self.capacity == "yawAxis":
            self._addConfigKey("_parkEnable", "PARK_ENABLE", default=False)
        else:
            self._addConfigKey("_parkEnable", "PARK_ENABLE", default=True)

    def __getSpeed(self):
        """ Return the speed value according to manual speed setting.

        @return: speed
        @rtype float
        """
        if self._manualSpeed == "slow":
            speed = self._config["SPEED_SLOW"]
        elif self._manualSpeed == "normal":
            speed = self._config["SPEED_NORMAL"]
        elif self._manualSpeed == "fast":
            speed = self._config["SPEED_FAST"]

        return speed

    def init(self):
        Logger().trace("ClaussAxis.init()")
        self._hardware.setAxis(AXIS_TABLE[self.capacity]),
        AbstractHardwarePlugin.init(self)

    def shutdown(self):
        Logger().trace("ClaussAxis.shutdown()")
        self.stop()
        if self._config["PARK_ENABLE"]:
            self._hardware.drive(float(self._config["PARK_POSITION"]), self.__getSpeed())
        AbstractHardwarePlugin.shutdown(self)
        AbstractAxisPlugin.shutdown(self)

    def read(self):
        pos = self._hardware.read() - self._offset
        return pos

    def drive(self, pos, useOffset=True, wait=True):
        Logger().debug("ClaussAxis.drive(): '%s' drive to %.1f" % (self.capacity, pos))
        currentPos = self.read()
        # Logger().debug("ClaussAxis.drive(): currentPos=%.1f" % currentPos)

        # checkLimits defined in Papywizard user conf (usually +360 - 360°)
        self._checkLimits(pos)

        if useOffset:
            pos += self._offset
            # Logger().debug("ClaussAxis.drive(): useOffset=True, pos=%.1f, offset=%.1f" % (pos, self._offset))

        # Only move if needed
        if abs(pos - currentPos) > 0.0 or not useOffset:
            # Logger().debug("ClaussAxis.drive(): Do move, pos=%.1f, currentPos=%.1f, useOffset=%s" % (pos, currentPos, useOffset))
            self._hardware.drive(pos, self.__getSpeed())

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

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

    def startJog(self, dir_):

        # Restrict manual moving to high or low limit (user defined)
        if dir_ == "+":
            maxPos = -float(self._config["HIGH_LIMIT"])
        elif dir_ == "-":
            maxPos = float(self._config["LOW_LIMIT"])
        # Logger().debug("ClaussAxis.startJog(): maxPos=%s" % maxPos)
        self._hardware.startJog(dir_, self.__getSpeed(), maxPos)

    def stop(self):
        self.__driveFlag = False
        self._hardware.stop()
        self.waitStop()

    def waitStop(self):
        pass

    def isMoving(self):
        return self._hardware.isMoving()
Example #5
0
 def _init(self):
     Logger().trace("ClaussShutter._init()")
     AbstractHardwarePlugin._init(self)
     ShutterPlugin._init(self)
     self._hardware = ClaussHardware()
Example #6
0
class ClaussShutter(AbstractHardwarePlugin, ShutterPlugin):
    def _init(self):
        Logger().trace("ClaussShutter._init()")
        AbstractHardwarePlugin._init(self)
        ShutterPlugin._init(self)
        self._hardware = ClaussHardware()

    def _defineConfig(self):
        AbstractHardwarePlugin._defineConfig(self)
        ShutterPlugin._defineConfig(self)
        self._addConfigKey('_focus',
                           'FOCUS_ENABLE',
                           default=DEFAULT_FOCUS_ENABLE)
        self._addConfigKey('_focus_time',
                           'FOCUS_TIME',
                           default=DEFAULT_FOCUS_TIME)
        self._addConfigKey('_dual', 'DUAL_ENABLE', default=DEFAULT_DUAL_ENABLE)
        self._addConfigKey('_dual_time',
                           'DUAL_TIME',
                           default=DEFAULT_DUAL_TIME)

    def _triggerShutter(self, delay):
        """ Trigger the shutter contact.

        Note that FOCUS_ENABLE and DUAL_ENABLE options are exclusive (done via UI)

        @param delay: delay to wait between on/off, in s
        @type delay: float
        """
        Logger().trace("ClaussShutter._triggerShutter()")

        # Autofocus mode enable
        if self._config['FOCUS_ENABLE']:
            self._triggerAutoFocus()
            time.sleep(self._config['FOCUS_TIME'])

        # Shoot regular camera
        self._triggerOnShutter()
        time.sleep(delay)
        self._triggerOffShutter()

        # Dual camera mode
        if self._config['DUAL_ENABLE']:
            time.sleep(self._config['DUAL_TIME'])
            Logger().info("ClaussShutter._triggerShutter(): dual camera shoot")
            self._triggerAutoFocus()
            time.sleep(delay)
            self._triggerOffShutter()

        self._LastShootTime = time.time()

    def _triggerAutoFocus(self):
        """ Set the autofocus on.
        """
        self._hardware.setShutter("AF")

    def _triggerOnShutter(self):
        """ Set the shutter on.
        """
        self._hardware.setShutter("ON")

    def _triggerOffShutter(self):
        """ Set the shutter off.
        """
        self._hardware.setShutter("OFF")

    def init(self):
        Logger().trace("ClaussShutter.init()")
        self._hardware.setAxis(AXIS_TABLE[self.capacity]),
        AbstractHardwarePlugin.init(self)

    def shutdown(self):
        Logger().trace("ClaussShutter.shutdown()")
        self._triggerOffShutter()
        AbstractHardwarePlugin.shutdown(self)
        ShutterPlugin.shutdown(self)
Example #7
0
 def _init(self):
     Logger().trace("ClaussAxis._init()")
     AbstractHardwarePlugin._init(self)
     AbstractAxisPlugin._init(self)
     self._hardware = ClaussHardware()
Example #8
0
class ClaussAxis(AbstractHardwarePlugin, AbstractAxisPlugin):
    def _init(self):
        Logger().trace("ClaussAxis._init()")
        AbstractHardwarePlugin._init(self)
        AbstractAxisPlugin._init(self)
        self._hardware = ClaussHardware()

    def _defineConfig(self):
        AbstractAxisPlugin._defineConfig(self)
        AbstractHardwarePlugin._defineConfig(self)
        self._addConfigKey('_speedSlow',
                           'SPEED_SLOW',
                           default=DEFAULT_SPEED_SLOW)
        self._addConfigKey('_speedNormal',
                           'SPEED_NORMAL',
                           default=DEFAULT_SPEED_NORMAL)
        self._addConfigKey('_speedFast',
                           'SPEED_FAST',
                           default=DEFAULT_SPEED_FAST)
        self._addConfigKey('_parkPosition',
                           'PARK_POSITION',
                           default=DEFAULT_PARK_POSITION)
        if self.capacity == 'yawAxis':
            self._addConfigKey('_parkEnable', 'PARK_ENABLE', default=False)
        else:
            self._addConfigKey('_parkEnable', 'PARK_ENABLE', default=True)

    def __getSpeed(self):
        """ Return the speed value according to manual speed setting.

        @return: speed
        @rtype float
        """
        if self._manualSpeed == 'slow':
            speed = self._config['SPEED_SLOW']
        elif self._manualSpeed == 'normal':
            speed = self._config['SPEED_NORMAL']
        elif self._manualSpeed == 'fast':
            speed = self._config['SPEED_FAST']

        return speed

    def init(self):
        Logger().trace("ClaussAxis.init()")
        self._hardware.setAxis(AXIS_TABLE[self.capacity]),
        AbstractHardwarePlugin.init(self)

    def shutdown(self):
        Logger().trace("ClaussAxis.shutdown()")
        self.stop()
        if self._config['PARK_ENABLE']:
            self._hardware.drive(float(self._config['PARK_POSITION']),
                                 self.__getSpeed())
        AbstractHardwarePlugin.shutdown(self)
        AbstractAxisPlugin.shutdown(self)

    def read(self):
        pos = self._hardware.read() - self._offset
        return pos

    def drive(self, pos, useOffset=True, wait=True):
        Logger().debug("ClaussAxis.drive(): '%s' drive to %.1f" %
                       (self.capacity, pos))
        currentPos = self.read()
        #Logger().debug("ClaussAxis.drive(): currentPos=%.1f" % currentPos)

        # checkLimits defined in Papywizard user conf (usually +360 - 360°)
        self._checkLimits(pos)

        if useOffset:
            pos += self._offset
            #Logger().debug("ClaussAxis.drive(): useOffset=True, pos=%.1f, offset=%.1f" % (pos, self._offset))

        # Only move if needed
        if abs(pos - currentPos) > 0. or not useOffset:
            #Logger().debug("ClaussAxis.drive(): Do move, pos=%.1f, currentPos=%.1f, useOffset=%s" % (pos, currentPos, useOffset))
            self._hardware.drive(pos, self.__getSpeed())

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

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

    def startJog(self, dir_):

        # Restrict manual moving to high or low limit (user defined)
        if dir_ == '+':
            maxPos = -float(self._config['HIGH_LIMIT'])
        elif dir_ == '-':
            maxPos = float(self._config['LOW_LIMIT'])
        #Logger().debug("ClaussAxis.startJog(): maxPos=%s" % maxPos)
        self._hardware.startJog(dir_, self.__getSpeed(), maxPos)

    def stop(self):
        self.__driveFlag = False
        self._hardware.stop()
        self.waitStop()

    def waitStop(self):
        pass

    def isMoving(self):
        return self._hardware.isMoving()