Ejemplo n.º 1
0
    def __init__(self, configuration = None, **kwds):
        """
        This initializes things and sets up the UI 
        of the power control dialog box.
        """
        super().__init__(**kwds)

        self.channels = False
        self.configuration = configuration
        self.directory = None
        self.exp_channels = None
        self.ilm_functionality = None
        self.linear_channels = None
        self.file_channels = None
        self.parameters = params.StormXMLObject()
        self.timing_functionality = None
        self.use_was_checked = False
        self.which_checked = []

        # Add progression parameters.
        self.parameters.add(params.ParameterSetBoolean(name = "use_progressions",
                                                       value = False,
                                                       is_mutable = False))
        
        self.parameters.add(params.ParameterStringFilename(description = "Progression file name",
                                                           name = "pfile_name",
                                                           value = "",
                                                           use_save_dialog = False))

        # UI setup
        self.ui = progressionUi.Ui_Dialog()
        self.ui.setupUi(self)

        self.ui.loadFileButton.clicked.connect(self.handleLoadFile)
        self.ui.progressionsCheckBox.stateChanged.connect(self.handleProgressionsCheck)
Ejemplo n.º 2
0
def test_parameters_4():

    # Load parameters.
    p1 = params.parameters(test.xmlFilePathAndName("test_parameters.xml"),
                           recurse=True)

    # Create another set of parameters with only 1 item.
    p2 = params.StormXMLObject()
    p2.add(params.ParameterString(name="test_param", value="bar"))
    p2s = p2.addSubSection("camera1")
    p2s.add(params.ParameterSetBoolean(name="flip_horizontal", value=True))
    p2s.add(params.ParameterSetBoolean(name="flip_vertical", value=False))

    # Test copy.
    [p3, ur] = params.copyParameters(p1, p2)

    # Their should be one un-recognized parameter, 'flip_vertical'.
    assert (len(ur) == 1) and (ur[0] == "flip_vertical")

    # 'camera1.flip_horizontal' in p3 should be True.
    assert p3.get("camera1.flip_horizontal")

    # 'test_param' should be 'bar'.
    assert (p3.get("test_param") == "bar")
Ejemplo n.º 3
0
    def __init__(self, module_params=None, qt_settings=None, **kwds):
        super().__init__(**kwds)
        self.locked_out = False
        self.wait_for = []
        self.waiting_on = []

        self.view = parametersBox.ParametersBox(module_params=module_params,
                                                qt_settings=qt_settings)
        self.view.editParameters.connect(self.handleEditParameters)
        self.view.newParameters.connect(self.handleNewParameters)

        p = params.StormXMLObject()
        p.set("parameters_file",
              os.path.join(module_params.get("directory"), "default.xml"))

        #
        # Add parameter to record whether or not these parameters have actually
        # been used (as opposed to just appearing in the list view).
        #
        # They should be initialized since this is what we are starting with..
        #
        p.add(
            params.ParameterSetBoolean(name="initialized",
                                       value=False,
                                       is_mutable=False,
                                       is_saved=False))

        self.view.addParameters(p, is_default=True)

        self.configure_dict = {
            "ui_order": 0,
            "ui_parent": "hal.containerWidget",
            "ui_widget": self.view
        }

        # This message marks the beginning and the end of the parameter change
        # life cycle.
        halMessage.addMessage("changing parameters",
                              validator={
                                  "data": {
                                      "changing": [True, bool]
                                  },
                                  "resp": None
                              })

        # Other modules should respond to this message with their current
        # parameters.
        halMessage.addMessage("current parameters",
                              validator={
                                  "data": None,
                                  "resp": {
                                      "parameters":
                                      [False, params.StormXMLObject]
                                  }
                              })

        # A request from another module for one of the sets of parameters.
        halMessage.addMessage("get parameters",
                              validator={
                                  "data": {
                                      "index or name": [True, (str, int)]
                                  },
                                  "resp": {
                                      "parameters":
                                      [False, params.StormXMLObject],
                                      "found": [True, bool]
                                  }
                              })

        # The current parameters have changed.
        #
        # Data includes a copy of the desired new parameters. Other modules
        # should at least check if the new parameters are okay. They may
        # defer actually re-configuring until they receive the
        # 'updated parameters' message.
        #
        # Other modules that respond should send two response:
        #  1. A response with a copy of their old parameter as "old parameters".
        #  2. A response with their updated parameters as "new parameters".
        #
        # The response is structured this way so that if an error occurs
        # during the parameter update we still have a record of the last
        # good state in "old parameters".
        #
        # Notes:
        #   1. We send a copy of the parameters in the listview, so if the
        #      module wants to it can just use these as the parameters without
        #      copying them again.
        #
        #   2. The 'old parameters' response should be a copy.
        #
        #   3. The 'new parameters' response does not need to be a copy.
        #
        halMessage.addMessage("new parameters",
                              validator={
                                  "data": {
                                      "parameters":
                                      [True, params.StormXMLObject],
                                      "is_edit": [True, bool]
                                  },
                                  "resp": {
                                      "new parameters":
                                      [False, params.StormXMLObject],
                                      "old parameters":
                                      [False, params.StormXMLObject]
                                  }
                              })

        # This comes from other modules that requested "wait for" at startup.
        #
        # Modules may respond with their new parameters here if they did not know
        # the final values for the parameters at 'new parameters'. At this point
        # however the modules cannot complain that the parameters they were given
        # were invalid, this has to be done at 'new parameters'.
        #
        halMessage.addMessage("parameters changed",
                              validator={
                                  "data": {
                                      "new parameters":
                                      [False, params.StormXMLObject]
                                  },
                                  "resp": None
                              })

        # A request from another module to set the current parameters.
        halMessage.addMessage("set parameters",
                              validator={
                                  "data": {
                                      "index or name": [True, (str, int)]
                                  },
                                  "resp": {
                                      "found": [True, bool],
                                      "current": [True, bool]
                                  }
                              })

        # The updated parameters.
        #
        # These are the updated values of parameters of all of the modules.
        # This is sent immediately after all of the modules respond to
        # the 'new parameters' message.
        #
        # The parameter change cycle won't actually complete till all the
        # modules that requested a wait send the "parameters changed" message.
        #
        halMessage.addMessage(
            "updated parameters",
            validator={"data": {
                "parameters": [True, params.StormXMLObject]
            }})
Ejemplo n.º 4
0
    def __init__(self, w1=None, configuration=None, **kwds):
        super().__init__(**kwds)
        self.w1 = w1

        # assert max_speed is not None

        # Create dictionaries for the configuration of the
        # filter wheels and two dichroic mirror sets.
        self.filter_wheel_config = {}
        values = configuration.get("filter_wheel")
        filter_names = values.split(",")
        for pos, filter_name in enumerate(filter_names):
            self.filter_wheel_config[filter_name] = pos + 1

        self.dichroic_mirror_config = {}
        values = configuration.get("dichroic_mirror")
        dichroic_names = values.split(",")
        for pos, dichroic_name in enumerate(dichroic_names):
            self.dichroic_mirror_config[dichroic_name] = pos + 1

        # Create parameters
        self.parameters = params.StormXMLObject()

        self.parameters.add(
            params.ParameterSetBoolean(
                description="Bypass spinning disk for brightfield mode?",
                name="bright_field_bypass",
                value=False))

        self.parameters.add(
            params.ParameterSetBoolean(description="Spin the disk?",
                                       name="spin_disk",
                                       value=True))

        # Disk properties
        self.parameters.add(
            params.ParameterSetString(
                description="Disk pinhole size",
                name="disk",
                value="70-micron pinholes",
                allowed=["70-micron pinholes", "40-micron pinholes"]))

        # Dichroic mirror position
        values = sorted(self.dichroic_mirror_config.keys())
        self.parameters.add(
            params.ParameterSetString(
                description="Dichroic mirror position (1-5)",
                name="dichroic_mirror",
                value=values[0],
                allowed=values))

        # Filter wheel positions
        values = sorted(self.filter_wheel_config.keys())
        self.parameters.add(
            params.ParameterSetString(
                description="Camera 1 Filter Wheel Position (1-8)",
                name="filter_wheel",
                value=values[0],
                allowed=values))

        self.newParameters(self.parameters, initialization=True)
Ejemplo n.º 5
0
    def __init__(self, config = None, is_master = False, **kwds):
        """
        Create an Andor camera control object and initialize
        the camera.
        """
        kwds["config"] = config
        super().__init__(**kwds)
        self.is_master = is_master
        
        # The camera functionality.
        self.camera_functionality = cameraFunctionality.CameraFunctionality(camera_name = self.camera_name,
                                                                            have_temperature = True,
                                                                            is_master = is_master,
                                                                            parameters = self.parameters)
        
        # Load the library and start the camera.
        andor.loadSDK3DLL(config.get("andor_sdk"))
        self.camera = andor.SDK3Camera(config.get("camera_id"))

        # Dictionary of the Andor settings we'll use and their types.
        #
        # FIXME: Maybe the AndorSDK3 module should know the types?
        #
        self.andor_props = {"AOIBinning" : "enum",
                            "AOIHeight" : "int",
                            "AOILeft" : "int",
                            "AOITop" : "int",
                            "AOIWidth" : "int",
                            "CycleMode" : "enum",
                            "ExposureTime" : "float",
                            "FrameCount" : "int",
                            "FrameRate" : "float",
                            "FanSpeed" : "enum",
                            "IOInvert" : "bool",
                            "IOSelector" : "enum",
                            "SensorCooling" : "bool",
                            "SensorHeight" : "int",
                            "SensorTemperature" : "float",
                            "SensorWidth" : "int",
                            "SimplePreAmpGainControl" : "enum",
                            "TemperatureControl" : "enum",
                            "TemperatureStatus" : "enum",
                            "TriggerMode" : "enum"}
        
        self.camera.setProperty("CycleMode", self.andor_props["CycleMode"], "Continuous")

        # Set trigger mode.
        print(">", self.camera_name, "trigger mode set to", config.get("trigger_mode"))
        self.camera.setProperty("TriggerMode", self.andor_props["TriggerMode"], config.get("trigger_mode"))

        # Add Andor SDK3 specific parameters.
        #
        # FIXME: These parameter have different names but the same meaning as the
        #        parameters HAL defines. How to reconcile? It seems best to use
        #        these names as their meaning will be clearly to user.
        #
        max_intensity = 2**16
        self.parameters.setv("max_intensity", max_intensity)

        x_chip = self.camera.getProperty("SensorWidth", self.andor_props["SensorWidth"])
        y_chip = self.camera.getProperty("SensorHeight", self.andor_props["SensorHeight"])
        self.parameters.setv("x_chip", x_chip)
        self.parameters.setv("y_chip", y_chip)

        self.parameters.add(params.ParameterSetString(description = "AOI Binning",
                                                      name = "AOIBinning",
                                                      value = "1x1",
                                                      allowed = ["1x1", "2x2", "3x3", "4x4", "8x8"]))
        
        self.parameters.add(params.ParameterRangeInt(description = "AOI Width",
                                                     name = "AOIWidth",
                                                     value = x_chip,
                                                     min_value = 128,
                                                     max_value = x_chip))
        
        self.parameters.add(params.ParameterRangeInt(description = "AOI Height",
                                                     name = "AOIHeight",
                                                     value = y_chip,
                                                     min_value = 128,
                                                     max_value = y_chip))

        self.parameters.add(params.ParameterRangeInt(description = "AOI Left",
                                                     name = "AOILeft",
                                                     value = 1,
                                                     min_value = 1,
                                                     max_value = x_chip/2))

        self.parameters.add(params.ParameterRangeInt(description = "AOI Top",
                                                     name = "AOITop",
                                                     value = 1,
                                                     min_value = 1,
                                                     max_value = y_chip/2))

        self.parameters.add(params.ParameterSetString(description = "Fan Speed",
                                                      name = "FanSpeed",
                                                      value = "On",
                                                      allowed = ["On", "Off"]))

        self.parameters.add(params.ParameterSetBoolean(description = "Sensor cooling",
                                                       name = "SensorCooling",
                                                       value = True))

        self.parameters.add(params.ParameterSetString(description = "Pre-amp gain control",
                                                      name = "SimplePreAmpGainControl",
                                                      value = "16-bit (low noise & high well capacity)",
                                                      allowed = ["16-bit (low noise & high well capacity)", 
                                                                  "Something else.."]))

        self.parameters.add(params.ParameterRangeFloat(description = "Exposure time (seconds)", 
                                                       name = "ExposureTime", 
                                                       value = 0.1,
                                                       min_value = 0.0,
                                                       max_value = 10.0))

        # FIXME: We never actually set this. Maybe we can't?
        self.parameters.add(params.ParameterRangeFloat(description = "Target temperature", 
                                                       name = "temperature", 
                                                       value = -20.0,
                                                       min_value = -50.0,
                                                       max_value = 25.0))

        # Disable editing of the HAL versions of these parameters.
        for param in ["exposure_time", "x_bin", "x_end", "x_start", "y_end", "y_start", "y_bin"]:
            self.parameters.getp(param).setMutable(False)

        self.newParameters(self.parameters, initialization = True)
Ejemplo n.º 6
0
    def processMessage(self, message):

        if message.isType("configuration"):
            if message.sourceIs("timing"):
                self.control.setTimingFunctionality(
                    message.getData()["properties"]["functionality"])

        elif message.isType("configure1"):
            self.sendMessage(
                halMessage.HalMessage(m_type="add to menu",
                                      data={
                                          "item name": "Focus Lock",
                                          "item data": "focus lock"
                                      }))

            self.sendMessage(
                halMessage.HalMessage(
                    m_type="initial parameters",
                    data={"parameters": self.view.getParameters()}))

        elif message.isType("configure2"):

            # Get functionalities. Do this here because the modules that provide these functionalities
            # will likely need functionalities from other modules. The IR laser for example might
            # need a functionality from a DAQ module.
            self.sendMessage(
                halMessage.HalMessage(m_type="get functionality",
                                      data={
                                          "name":
                                          self.configuration.get("ir_laser"),
                                          "extra data":
                                          "ir_laser"
                                      }))

            self.sendMessage(
                halMessage.HalMessage(m_type="get functionality",
                                      data={
                                          "name":
                                          self.configuration.get("qpd"),
                                          "extra data": "qpd"
                                      }))

            self.sendMessage(
                halMessage.HalMessage(m_type="get functionality",
                                      data={
                                          "name":
                                          self.configuration.get("z_stage"),
                                          "extra data": "z_stage"
                                      }))

        elif message.isType("new parameters"):
            p = message.getData()["parameters"]
            message.addResponse(
                halMessage.HalMessageResponse(
                    source=self.module_name,
                    data={"old parameters": self.view.getParameters().copy()}))
            self.view.newParameters(p.get(self.module_name))
            message.addResponse(
                halMessage.HalMessageResponse(
                    source=self.module_name,
                    data={"new parameters": self.view.getParameters()}))

        elif message.isType("show"):
            if (message.getData()["show"] == "focus lock"):
                self.view.show()

        elif message.isType("start"):
            self.view.start()
            self.control.start()
            if message.getData()["show_gui"]:
                self.view.showIfVisible()

        elif message.isType("start film"):
            self.control.startFilm(message.getData()["film settings"])

        elif message.isType("stop film"):
            self.control.stopFilm()
            message.addResponse(
                halMessage.HalMessageResponse(
                    source=self.module_name,
                    data={"parameters": self.view.getParameters().copy()}))
            lock_good = params.ParameterSetBoolean(
                name="good_lock", value=self.control.isGoodLock())
            lock_mode = params.ParameterString(
                name="lock_mode", value=self.control.getLockModeName())
            lock_sum = params.ParameterFloat(
                name="lock_sum", value=self.control.getQPDSumSignal())
            lock_target = params.ParameterFloat(
                name="lock_target", value=self.control.getLockTarget())
            message.addResponse(
                halMessage.HalMessageResponse(
                    source=self.module_name,
                    data={
                        "acquisition":
                        [lock_good, lock_mode, lock_sum, lock_target]
                    }))

        elif message.isType("tcp message"):

            # See control handles this message.
            handled = self.control.handleTCPMessage(message)

            # If not, check view.
            if not handled:
                handled = self.view.handleTCPMessage(message)

            # Mark if we handled the message.
            if handled:
                message.addResponse(
                    halMessage.HalMessageResponse(source=self.module_name,
                                                  data={"handled": True}))
Ejemplo n.º 7
0
    def __init__(self, w1=None, configuration=None, **kwds):
        super().__init__(**kwds)
        self.w1 = w1

        # Query W1 for it's maximum speed.
        max_speed = self.w1.commandResponse("MS_MAX,?")
        assert max_speed is not None

        # Create dictionaries for the configuration of the
        # filter wheels and two dichroic mirror sets.
        self.filter_wheel_1_config = {}
        values = configuration.get("filter_wheel_1")
        filter_names = values.split(",")
        for pos, filter_name in enumerate(filter_names):
            self.filter_wheel_1_config[filter_name] = pos + 1

        self.filter_wheel_2_config = {}
        values = configuration.get("filter_wheel_2")
        filter_names = values.split(",")
        for pos, filter_name in enumerate(filter_names):
            self.filter_wheel_2_config[filter_name] = pos + 1

        self.dichroic_mirror_config = {}
        values = configuration.get("dichroic_mirror")
        dichroic_names = values.split(",")
        for pos, dichroic_name in enumerate(dichroic_names):
            self.dichroic_mirror_config[dichroic_name] = pos + 1

        self.camera_dichroic_config = {}
        values = configuration.get("camera_dichroic")
        camera_dichroic_names = values.split(",")
        for pos, camera_dichroic in enumerate(camera_dichroic_names):
            self.camera_dichroic_config[camera_dichroic] = pos + 1

        # Create parameters
        self.parameters = params.StormXMLObject()

        self.parameters.add(
            params.ParameterSetBoolean(
                description="Bypass spinning disk for brightfield mode?",
                name="bright_field_bypass",
                value=False))

        self.parameters.add(
            params.ParameterSetBoolean(description="Spin the disk?",
                                       name="spin_disk",
                                       value=True))

        # Disk properties
        self.parameters.add(
            params.ParameterSetString(
                description="Disk pinhole size",
                name="disk",
                value="50-micron pinholes",
                allowed=["50-micron pinholes", "25-micron pinholes"]))

        self.parameters.add(
            params.ParameterRangeInt(description="Disk speed (RPM)",
                                     name="disk_speed",
                                     value=max_speed,
                                     min_value=1,
                                     max_value=max_speed))

        # Dichroic mirror position
        values = sorted(self.dichroic_mirror_config.keys())
        self.parameters.add(
            params.ParameterSetString(description="Dichroic mirror position",
                                      name="dichroic_mirror",
                                      value=values[0],
                                      allowed=values))

        # Filter wheel positions
        values = sorted(self.filter_wheel_1_config.keys())
        self.parameters.add(
            params.ParameterSetString(
                description="Camera 1 Filter Wheel Position (1-10)",
                name="filter_wheel_pos1",
                value=values[0],
                allowed=values))

        values = sorted(self.filter_wheel_2_config.keys())
        self.parameters.add(
            params.ParameterSetString(
                description="Camera 2 Filter Wheel Position (1-10)",
                name="filter_wheel_pos2",
                value=values[0],
                allowed=values))

        # Camera dichroic positions
        values = sorted(self.camera_dichroic_config.keys())
        self.parameters.add(
            params.ParameterSetString(
                description="Camera dichroic mirror position (1-3)",
                name="camera_dichroic_mirror",
                value=values[0],
                allowed=values))

        # Aperature settings
        self.parameters.add(
            params.ParameterRangeInt(
                description="Aperture value (1-10; small to large)",
                name="aperture",
                value=10,
                min_value=1,
                max_value=10))

        self.newParameters(self.parameters, initialization=True)
Ejemplo n.º 8
0
    def createParameters(self, cam_fn, parameters_from_file):
        """
        Create (initial) parameters for the current feed.

        cam_fn - A camera / feed functionality object.
        parameters_from_file - The parameters that were read from the XML file.
        """
        # Check that we are not writing over something that already exists.
        if (self.parameters.has(self.getFeedName())):
            msg = "Display parameters for " + self.getFeedName() + " already exists."
            raise halExceptions.HalException(msg)

        # Create a sub-section for this camera / feed.
        p = self.parameters.addSubSection(self.getFeedName())

        # Add display specific parameters.
        p.add(params.ParameterFloat(name = "center_x",
                                    value = 0.0,
                                    is_mutable = False))

        p.add(params.ParameterFloat(name = "center_y",
                                    value = 0.0,
                                    is_mutable = False))
            
        p.add(params.ParameterSetString(description = "Color table",
                                        name = "colortable",
                                        value = self.color_tables.getColorTableNames()[0],
                                        allowed = self.color_tables.getColorTableNames()))
                        
        p.add(params.ParameterInt(description = "Display maximum",
                                  name = "display_max",
                                  value = 100))

        p.add(params.ParameterInt(description = "Display minimum",
                                  name = "display_min",
                                  value = 0))

        p.add(params.ParameterSetBoolean(name = "initialized",
                                         value = False,
                                         is_mutable = False))

        p.add(params.ParameterInt(name = "max_intensity",
                                  value = 100,
                                  is_mutable = False,
                                  is_saved = False))

        p.add(params.ParameterInt(name = "scale",
                                  value = 0,
                                  is_mutable = False))
            
        p.add(params.ParameterInt(description = "Frame to display when filming with a shutter sequence",
                                  name = "sync",
                                  value = 0))

        # Set parameters with default values from feed/camera functionality
        if cam_fn.hasParameter("colortable"):
            p.setv("colortable", cam_fn.getParameter("colortable"))
        else:
            p.setv("colortable", self.default_colortable)
        p.setv("display_max", cam_fn.getParameter("default_max"))
        p.setv("display_min", cam_fn.getParameter("default_min"))
        p.setv("max_intensity", cam_fn.getParameter("max_intensity"))

        # If they exist, update with the values that we loaded from a file.
        # Also, some parameters files will have 'extra' parameters, typically
        # sub-sections for the different feeds. We skip these here as this
        # will be handled when we change to the feed and call the
        # setCameraFunctionality() method.
        #
        if parameters_from_file is not None:
            for attr in parameters_from_file.getAttrs():
                if p.has(attr):
                    p.setv(attr, parameters_from_file.get(attr))
Ejemplo n.º 9
0
    def __init__(self, camera_name=None, config=None, **kwds):
        """
        camera_name - This is the name of this camera's section in the config XML file.        
        config - These are the values in the parameters section as a StormXMLObject().
        """
        super().__init__(**kwds)

        # This is the hardware module that will actually control the camera.
        self.camera = None

        # Sub-classes should set this to a CameraFunctionality object.
        self.camera_functionality = None

        self.camera_name = camera_name

        # This is a flag for whether or not the camera is in a working state.
        # It might not be if for example the parameters were bad.
        self.camera_working = True

        # The length of a fixed length film.
        self.film_length = None

        # The current frame number, this gets reset by startCamera().
        self.frame_number = 0

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

        # This is how we tell the thread that is handling actually talking
        # to the camera hardware to stop.
        self.running = False

        # This is how we know that the camera thread that is talking to the
        # camera actually started.
        self.thread_started = False

        #
        # These are the minimal parameters that every camera must provide
        # to work with HAL.
        #

        # The exposure time.
        self.parameters.add(
            params.ParameterFloat(description="Exposure time (seconds)",
                                  name="exposure_time",
                                  value=1.0))

        # This is frames per second as reported by the camera. It is used
        # for hardware timed waveforms (if any).
        self.parameters.add(
            params.ParameterFloat(name="fps", value=0, is_mutable=False))

        #
        # Chip size, ROI of the chip and the well depth.
        #
        x_size = 256
        y_size = 256
        self.parameters.add(
            params.ParameterInt(name="x_chip",
                                value=x_size,
                                is_mutable=False,
                                is_saved=False))

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

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

        #
        # Note: These are all expected to be in units of binned pixels. For
        # example if the camera is 512 x 512 and we are binning by 2s then
        # the maximum value of these would 256 x 256.
        #
        self.parameters.add(
            params.ParameterRangeInt(description="AOI X start",
                                     name="x_start",
                                     value=1,
                                     min_value=1,
                                     max_value=x_size))

        self.parameters.add(
            params.ParameterRangeInt(description="AOI X end",
                                     name="x_end",
                                     value=x_size,
                                     min_value=1,
                                     max_value=x_size))

        self.parameters.add(
            params.ParameterRangeInt(description="AOI Y start",
                                     name="y_start",
                                     value=1,
                                     min_value=1,
                                     max_value=y_size))

        self.parameters.add(
            params.ParameterRangeInt(description="AOI Y end",
                                     name="y_end",
                                     value=y_size,
                                     min_value=1,
                                     max_value=y_size))

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

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

        self.parameters.add(
            params.ParameterRangeInt(description="Binning in X",
                                     name="x_bin",
                                     value=1,
                                     min_value=1,
                                     max_value=4))

        self.parameters.add(
            params.ParameterRangeInt(description="Binning in Y",
                                     name="y_bin",
                                     value=1,
                                     min_value=1,
                                     max_value=4))

        # Frame size in bytes.
        self.parameters.add(
            params.ParameterInt(name="bytes_per_frame",
                                value=x_size * y_size * 2,
                                is_mutable=False,
                                is_saved=False))

        #
        # How/if data from this camera is saved.
        #
        self.parameters.add(
            params.ParameterString(
                description="Camera save filename extension",
                name="extension",
                value=""))

        self.parameters.add(
            params.ParameterSetBoolean(
                description="Save data from this camera when filming",
                name="saved",
                value=True))

        self.parameters.set("extension", config.get("extension", ""))
        self.parameters.set("saved", config.get("saved", True))

        #
        # Camera display orientation. Values can only be changed by
        # changing the config.xml file.
        #
        self.parameters.add(
            params.ParameterSetBoolean(name="flip_horizontal",
                                       value=False,
                                       is_mutable=False))

        self.parameters.add(
            params.ParameterSetBoolean(name="flip_vertical",
                                       value=False,
                                       is_mutable=False))

        self.parameters.add(
            params.ParameterSetBoolean(name="transpose",
                                       value=False,
                                       is_mutable=False))

        self.parameters.set("flip_horizontal",
                            config.get("flip_horizontal", False))
        self.parameters.set("flip_vertical",
                            config.get("flip_vertical", False))
        self.parameters.set("transpose", config.get("transpose", False))

        #
        # Camera default display minimum and maximum.
        #
        # These are the values the display will use by default. They can
        # only be changed by changing the config.xml file.
        #
        self.parameters.add(
            params.ParameterInt(name="default_max",
                                value=2000,
                                is_mutable=False))

        self.parameters.add(
            params.ParameterInt(name="default_min",
                                value=100,
                                is_mutable=False))

        self.parameters.set("default_max", config.get("default_max", 2000))
        self.parameters.set("default_min", config.get("default_min", 100))

        self.finished.connect(self.handleFinished)
        self.newData.connect(self.handleNewData)
Ejemplo n.º 10
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.º 11
0
    def __init__(self, parameters = None, **kwds):
        super().__init__(**kwds)
        self.parameters = parameters
        self.will_overwrite = False

        # Add default film parameters.        
        self.parameters.add(params.ParameterSetString(description = "Acquisition mode",
                                                      name = "acq_mode",
                                                      value = "fixed_length",
                                                      allowed = ["run_till_abort", "fixed_length"]))
        
        self.parameters.add(params.ParameterSetBoolean(description = "Automatically increment movie counter between movies",
                                                       name = "auto_increment",
                                                       value = True))
        
        self.parameters.add(params.ParameterSetBoolean(description = "Run shutters during the movie",
                                                       name = "auto_shutters",
                                                       value = True))
        
        self.parameters.add(params.ParameterString(description = "Current movie file name",
                                                   name = "filename",
                                                   value = "movie"))

        formats = imagewriters.availableFileFormats(parameters.get("test_mode", False))
        self.parameters.add(params.ParameterSetString(description = "Movie file type",
                                                      name = "filetype",
                                                      value = formats[0],
                                                      allowed = formats))
        
        self.parameters.add(params.ParameterRangeInt(description = "Movie length in frames",
                                                     name = "frames",
                                                     value = 10,
                                                     min_value = 1,
                                                     max_value = 1000000000))
        
        self.parameters.add(params.ParameterSetBoolean(description = "Sound bell at the end of long movies",
                                                       name = "want_bell",
                                                       value = True))

        # Initial UI configuration.
        self.ui = filmUi.Ui_GroupBox()
        self.ui.setupUi(self)
        
        for extname in self.parameters.getp("extension").getAllowed():
            self.ui.extensionComboBox.addItem(extname)
        
        for typename in self.parameters.getp("filetype").getAllowed():
            self.ui.filetypeComboBox.addItem(typename)

        self.ui.framesText.setText("")
        self.ui.sizeText.setText("")

        self.setDirectory(self.parameters.get("directory"))
        self.setShutters("NA")
        self.newParameters(self.parameters)
        self.updateFilenameLabel()

        # Connect signals
        self.ui.autoIncCheckBox.stateChanged.connect(self.handleAutoInc)
        self.ui.autoShuttersCheckBox.stateChanged.connect(self.handleAutoShutters)
        self.ui.extensionComboBox.currentIndexChanged.connect(self.handleExtension)
        self.ui.filenameEdit.textChanged.connect(self.handleFilename)
        self.ui.filetypeComboBox.currentIndexChanged.connect(self.handleFiletype)
        self.ui.indexSpinBox.valueChanged.connect(self.handleIndex)
        self.ui.lengthSpinBox.valueChanged.connect(self.handleLength)
        self.ui.liveModeCheckBox.stateChanged.connect(self.handleLiveMode)
        self.ui.modeComboBox.currentIndexChanged.connect(self.handleMode)
Ejemplo n.º 12
0
    def __init__(self, parameters = None, **kwds):
        """
        parameters - This is just the 'feed' section of the parameters.
        """
        super().__init__(**kwds)

        self.feeds = {}
        if parameters is None:
            return

        # Create the feeds.
        self.parameters = parameters
        for feed_name in self.parameters.getAttrs():
            file_params = self.parameters.get(feed_name)
            
            # Create default feed parameters.
            max_value = 100000
            feed_params = params.StormXMLObject()

            # Feeds are saved with their name as the extension.
            feed_params.add(params.ParameterString(name = "extension",
                                                   value = feed_name,
                                                   is_mutable = True))
            
            feed_params.add(params.ParameterString(name = "feed_type",
                                                   value = "",
                                                   is_mutable = False))

            feed_params.add(params.ParameterSetBoolean(name = "saved",
                                                       value = False))

            # This is the camera that drives the feed.
            feed_params.add(params.ParameterString(name = "source",
                                                   value = "",
                                                   is_mutable = False))
            
            feed_params.add(params.ParameterRangeInt(description = "AOI X start.",
                                                     name = "x_start",
                                                     value = 1,
                                                     min_value = 1,
                                                     max_value = max_value))

            feed_params.add(params.ParameterRangeInt(description = "AOI X end.",
                                                     name = "x_end",
                                                     value = 1,
                                                     min_value = 1,
                                                     max_value = max_value))

            feed_params.add(params.ParameterRangeInt(description = "AOI Y start.",
                                                     name = "y_start",
                                                     value = 1,
                                                     min_value = 1,
                                                     max_value = max_value))
            
            feed_params.add(params.ParameterRangeInt(description = "AOI Y end.",
                                                     name = "y_end",
                                                     value = 1,
                                                     min_value = 1,
                                                     max_value = max_value))

            # Figure out what type of feed this is.
            fclass = None
            feed_type = file_params.get("feed_type")
            if (feed_type == "average"):
                fclass = FeedFunctionalityAverage
                
                feed_params.add(params.ParameterInt(description = "Number of frames to average.",
                                                    name = "frames_to_average",
                                                    value = 1))
                            
            elif (feed_type == "interval"):
                fclass = FeedFunctionalityInterval

                feed_params.add(params.ParameterInt(description = "Interval cycle length.",
                                                    name = "cycle_length",
                                                    value = 1))
                
                feed_params.add(params.ParameterCustom(description = "Frames to capture.",
                                                       name = "capture_frames",
                                                       value = "1"))

            elif (feed_type == "slice"):
                fclass = FeedFunctionalitySlice
            else:
                raise FeedException("Unknown feed type '" + feed_type + "' in feed '" + feed_name + "'")

            # Update with values from the parameters file. Depending on the parameters
            # file it might include parameters that we don't have and which we silently
            # ignore.
            #
            for attr in file_params.getAttrs():
                if feed_params.has(attr):
                    feed_params.setv(attr, file_params.get(attr))

            # Replace the values in the parameters that were read from a file with these values.
            self.parameters.addSubSection(feed_name, feed_params, overwrite = True)

            camera_name = feed_params.get("source") + "." + feed_name
            self.feeds[camera_name] = fclass(feed_name = feed_name,
                                             camera_name = camera_name,
                                             parameters = feed_params)
Ejemplo n.º 13
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.º 14
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)