Ejemplo n.º 1
0
    def __init__(self, joystick=None, joystick_gains=None, **kwds):
        super().__init__(**kwds)

        self.button_timer = QtCore.QTimer(self)
        self.joystick = joystick
        self.joystick_gains = joystick_gains  # XML should be [25.0, 250.0, 2500.0]
        self.old_right_joystick = [0, 0]
        self.old_left_joystick = [0, 0]
        self.stage_functionality = None
        self.to_emit = False

        # The joystick parameters.
        self.parameters = params.StormXMLObject()

        self.parameters.add(
            params.ParameterInt(name="joystick_gain_index",
                                value=0,
                                is_mutable=False,
                                is_saved=False))

        self.parameters.add(
            params.ParameterInt(name="multiplier",
                                value=1,
                                is_mutable=False,
                                is_saved=False))

        self.parameters.add(
            params.ParameterRangeFloat(
                description="Step size in um for hat button press",
                name="hat_step",
                value=1.0,
                min_value=0.0,
                max_value=10.0))

        self.parameters.add(
            params.ParameterRangeFloat(
                description="X button multiplier for joystick and focus lock",
                name="joystick_multiplier_value",
                value=5.0,
                min_value=0.0,
                max_value=50.0))

        self.parameters.add(
            params.ParameterSetString(description="Response mode",
                                      name="joystick_mode",
                                      value="quadratic",
                                      allowed=["linear", "quadratic"]))

        self.parameters.add(
            params.ParameterSetFloat(description="Sign for x motion",
                                     name="joystick_signx",
                                     value=1.0,
                                     allowed=[-1.0, 1.0]))

        self.parameters.add(
            params.ParameterSetFloat(description="Sign for y motion",
                                     name="joystick_signy",
                                     value=1.0,
                                     allowed=[-1.0, 1.0]))

        self.parameters.add(
            params.ParameterRangeFloat(
                description="Focus lock step size in um",
                name="lockt_step",
                value=0.025,
                min_value=0.0,
                max_value=1.0))

        self.parameters.add(
            params.ParameterRangeFloat(
                description="Minimum joystick offset to be non-zero",
                name="min_offset",
                value=0.1,
                min_value=0.0,
                max_value=1.0))

        self.parameters.add(
            params.ParameterSetBoolean(description="Swap x and y axises",
                                       name="xy_swap",
                                       value=False))

        self.joystick.start(self.joystickHandler)

        self.button_timer.setInterval(100)
        self.button_timer.setSingleShot(True)
        self.button_timer.timeout.connect(self.buttonDownHandler)
Ejemplo n.º 2
0
    def __init__(self, config=None, is_master=False, **kwds):
        kwds["config"] = config
        super().__init__(**kwds)
        self.reversed_shutter = config.get("reversed_shutter", False)

        # The camera configuration.
        self.camera_functionality = cameraFunctionality.CameraFunctionality(
            camera_name=self.camera_name,
            have_emccd=True,
            have_preamp=True,
            have_shutter=True,
            have_temperature=True,
            is_master=is_master,
            parameters=self.parameters)
        self.camera_functionality.setEMCCDGain = self.setEMCCDGain
        self.camera_functionality.toggleShutter = self.toggleShutter

        # Load Andor DLL & get the camera.
        andor.loadAndorDLL(
            os.path.join(config.get("andor_path"), config.get("andor_dll")))
        handle = andor.getCameraHandles()[config.get("camera_id")]
        self.camera = andor.AndorCamera(config.get("andor_path"), handle)

        # Dictionary of Andor camera properties we'll support.
        self.andor_props = {
            "adchannel": True,
            "baselineclamp": True,
            "emccd_advanced": True,
            "emccd_gain": True,
            "emgainmode": True,
            "exposure_time": True,
            "extension": True,
            "external_trigger": True,
            "frame_transfer_mode": True,
            "hsspeed": True,
            "isolated_cropmode": True,
            "kinetic_cycle_time": True,
            "low_during_filming": True,
            "off_during_filming": True,
            "preampgain": True,
            "saved": True,
            "temperature": True,
            "vsamplitude": True,
            "vsspeed": True,
            "x_bin": True,
            "x_end": True,
            "x_start": True,
            "y_bin": True,
            "y_end": True,
            "y_start": True
        }

        # Add Andor EMCCD specific parameters.
        self.parameters.setv("max_intensity", self.camera.getMaxIntensity())

        [gain_low, gain_high] = self.camera.getEMGainRange()
        self.parameters.add(
            "emccd_gain",
            params.ParameterRangeInt(description="EMCCD Gain",
                                     name="emccd_gain",
                                     value=gain_low,
                                     min_value=gain_low,
                                     max_value=gain_high,
                                     order=2))

        # Adjust ranges of the size and binning parameters.
        [x_size, y_size] = self.camera.getCameraSize()
        self.parameters.getp("x_end").setMaximum(x_size)
        self.parameters.getp("x_start").setMaximum(x_size)
        self.parameters.getp("y_end").setMaximum(y_size)
        self.parameters.getp("y_start").setMaximum(y_size)

        self.parameters.setv("x_end", x_size)
        self.parameters.setv("y_end", y_size)
        self.parameters.setv("x_chip", x_size)
        self.parameters.setv("y_chip", y_size)

        [x_max_bin, y_max_bin] = self.camera.getMaxBinning()
        self.parameters.getp("x_bin").setMaximum(x_max_bin)
        self.parameters.getp("y_bin").setMaximum(y_max_bin)

        # FIXME: Need to check if camera supports frame transfer mode.
        self.parameters.add(
            params.ParameterSetInt(
                description="Frame transfer mode (0 = off, 1 = on)",
                name="frame_transfer_mode",
                value=1,
                allowed=[0, 1]))

        [mint, maxt] = self.camera.getTemperatureRange()
        self.parameters.add(
            params.ParameterRangeInt(description="Target temperature",
                                     name="temperature",
                                     value=-70,
                                     min_value=mint,
                                     max_value=maxt))

        preamp_gains = self.camera.getPreampGains()
        self.parameters.add(
            params.ParameterSetFloat(description="Pre-amplifier gain",
                                     name="preampgain",
                                     value=preamp_gains[0],
                                     allowed=preamp_gains))

        hs_speeds = self.camera.getHSSpeeds()[0]
        self.parameters.add(
            params.ParameterSetFloat(description="Horizontal shift speed",
                                     name="hsspeed",
                                     value=hs_speeds[0],
                                     allowed=hs_speeds))

        vs_speeds = self.camera.getVSSpeeds()
        self.parameters.add(
            params.ParameterSetFloat(description="Vertical shift speed",
                                     name="vsspeed",
                                     value=vs_speeds[-1],
                                     allowed=vs_speeds))

        #        self.parameters.getp("exposure_time").setMaximum(self.camera.getMaxExposure())

        self.parameters.getp("exposure_time").setOrder(2)
        self.parameters.setv("exposure_time", 0.0)

        self.parameters.add(
            params.ParameterRangeFloat(
                description="Kinetic cycle time (seconds)",
                name="kinetic_cycle_time",
                value=0.0,
                min_value=0.0,
                max_value=100.0))

        ad_channels = list(range(self.camera.getNumberADChannels()))
        self.parameters.add(
            params.ParameterSetInt(
                description="Analog to digital converter channel",
                name="adchannel",
                value=0,
                allowed=ad_channels))

        n_modes = list(range(self.camera.getNumberEMGainModes()))
        self.parameters.add(
            params.ParameterSetInt(description="EMCCD gain mode",
                                   name="emgainmode",
                                   value=0,
                                   allowed=n_modes))

        self.parameters.add(
            params.ParameterSetBoolean(description="Baseline clamp",
                                       name="baselineclamp",
                                       value=True))

        # FIXME: Need to get amplitudes from the camera.
        self.parameters.add(
            params.ParameterSetInt(description="Vertical shift amplitude",
                                   name="vsamplitude",
                                   value=0,
                                   allowed=[0, 1, 2]))

        self.parameters.add(
            params.ParameterSetBoolean(description="Fan off during filming",
                                       name="off_during_filming",
                                       value=False))

        self.parameters.add(
            params.ParameterSetBoolean(description="Fan low during filming",
                                       name="low_during_filming",
                                       value=False))

        self.parameters.add(
            params.ParameterSetBoolean(
                description="Use an external camera trigger",
                name="external_trigger",
                value=False))

        self.parameters.add(
            params.ParameterString(description="Camera head model",
                                   name="head_model",
                                   value=self.camera.getHeadModel(),
                                   is_mutable=False))

        self.parameters.add(
            params.ParameterSetBoolean(description="Isolated crop mode",
                                       name="isolated_cropmode",
                                       value=False))

        self.parameters.add(
            params.ParameterSetBoolean(description="Advanced EMCCD gain mode",
                                       name="emccd_advanced",
                                       value=False))

        self.newParameters(self.parameters, initialization=True)
Ejemplo n.º 3
0
    def __init__(self, config=None, is_master=False, **kwds):
        kwds["config"] = config
        super().__init__(**kwds)

        self.fake_frame = 0
        self.fake_frame_size = [0, 0]
        self.sleep_time = 0

        #
        # The camera functionality. Note the connection to self.parameters
        # which should not be changed to point to some other parameters
        # object when the parameters change. This is enforced by the
        # getCameraConfiguration() method.
        #
        self.camera_functionality = cameraFunctionality.CameraFunctionality(
            camera_name=self.camera_name,
            have_emccd=True,
            have_preamp=True,
            have_shutter=True,
            have_temperature=True,
            is_master=is_master,
            parameters=self.parameters)
        #
        # In general these should be handled by a thread as they may be slow.
        #
        self.camera_functionality.setEMCCDGain = self.setEMCCDGain
        self.camera_functionality.toggleShutter = self.toggleShutter

        #
        # Override defaults with camera specific values.
        #
        self.parameters.set(
            "exposure_time",
            params.ParameterRangeFloat(description="Exposure time (seconds)",
                                       name="exposure_time",
                                       value=0.02,
                                       min_value=0.01,
                                       max_value=10.0))
        self.parameters.setv("max_intensity", 512)

        chip_size = 512
        for pname in ["x_start", "x_end", "y_start", "y_end"]:
            self.parameters.getp(pname).setMaximum(chip_size)

        self.parameters.setv("x_end", chip_size)
        self.parameters.setv("y_end", chip_size)
        self.parameters.setv("x_chip", chip_size)
        self.parameters.setv("y_chip", chip_size)

        #
        # Emulation camera specific parameters.
        #
        self.parameters.add(
            params.ParameterRangeFloat(description="Camera rolling constant",
                                       name="roll",
                                       value=0.1,
                                       min_value=0.0,
                                       max_value=1.0))
        self.parameters.setv("roll", config.get("roll"))

        self.parameters.add(
            params.ParameterRangeInt(description="EMCCD gain",
                                     name="emccd_gain",
                                     value=10,
                                     min_value=2,
                                     max_value=50))

        self.parameters.add(
            params.ParameterSetFloat(description="Pre-amp gain",
                                     name="preampgain",
                                     value=1.0,
                                     allowed=[1.0, 2.0, 5.0]))

        self.parameters.add(
            params.ParameterRangeFloat(description="Target temperature",
                                       name="temperature",
                                       value=-20.0,
                                       min_value=-50.0,
                                       max_value=25.0))

        self.newParameters(self.parameters, initialization=True)
Ejemplo n.º 4
0
    def __init__(self, parameters, joystick, parent=None):
        QtCore.QObject.__init__(self, parent)
        halModule.HalModule.__init__(self, parent)

        self.button_timer = QtCore.QTimer(self)
        self.jstick = joystick
        self.old_right_joystick = [0, 0]
        self.old_left_joystick = [0, 0]
        self.to_emit = False

        # Add joystick specific parameters.
        js_params = parameters.addSubSection("joystick")
        js_params.add(
            "joystick_gain_index",
            params.ParameterInt("",
                                "joystick_gain_index",
                                0,
                                is_mutable=False,
                                is_saved=False))
        js_params.add(
            "multiplier",
            params.ParameterInt("",
                                "multiplier",
                                1,
                                is_mutable=False,
                                is_saved=False))
        js_params.add(
            "hat_step",
            params.ParameterRangeFloat("Step size in um for hat button press",
                                       "hat_step", 1.0, 0.0, 10.0))
        js_params.add("joystick_gain", [25.0, 250.0, 2500.0])
        js_params.add(
            "joystick_multiplier_value",
            params.ParameterRangeFloat(
                "X button multiplier for joystick and focus lock",
                "joystick_multiplier_value", 5.0, 0.0, 50.0))
        js_params.add(
            "joystick_mode",
            params.ParameterSetString("Response mode", "joystick_mode",
                                      "quadratic", ["linear", "quadratic"]))
        js_params.add(
            "joystick_signx",
            params.ParameterSetFloat("Sign for x motion", "joystick_signx",
                                     1.0, [-1.0, 1.0]))
        js_params.add(
            "joystick_signy",
            params.ParameterSetFloat("Sign for y motion", "joystick_signy",
                                     1.0, [-1.0, 1.0]))
        js_params.add(
            "lockt_step",
            params.ParameterRangeFloat("Focus lock step size in um",
                                       "lockt_step", 0.025, 0.0, 1.0))
        js_params.add(
            "min_offset",
            params.ParameterRangeFloat(
                "Minimum joystick offset to be non-zero", "min_offset", 0.1,
                0.0, 1.0))
        js_params.add(
            "xy_swap",
            params.ParameterSetBoolean("Swap x and y axises", "xy_swap",
                                       False))
        self.parameters = js_params

        self.jstick.start(self.joystickHandler)

        self.button_timer.setInterval(100)
        self.button_timer.setSingleShot(True)
        self.button_timer.timeout.connect(self.buttonDownHandler)