def addParameters(parameters): """ Add parameters specific to finding sum. """ p = parameters.addSubSection(FindSumMixin.fsm_pname) p.add( params.ParameterRangeFloat( description="Step size for find sum search.", name="step_size", value=1.0, min_value=0.1, max_value=10.0))
def __init__(self, parameters=None, **kwds): kwds["parameters"] = parameters super().__init__(**kwds) self.clm_counter = 0 self.clm_max_zvals = 0 self.clm_pname = "calibrate" self.clm_zvals = [] self.name = "Calibrate" # Add calibration specific parameters. p = self.parameters.addSubSection(self.clm_pname) p.add( params.ParameterRangeInt( description="Frames to pause between steps.", name="frames_to_pause", value=2, min_value=1, max_value=100)) p.add( params.ParameterRangeInt( description="Frames before to pause at start.", name="deadtime", value=20, min_value=1, max_value=100)) p.add( params.ParameterRangeFloat( description="Distance +- z to move in nanometers.", name="range", value=600, min_value=100, max_value=5000)) p.add( params.ParameterRangeFloat( description="Step size in z in nanometers.", name="step_size", value=10, min_value=1, max_value=100))
def __init__(self, parameters = None, **kwds): kwds["parameters"] = parameters super().__init__(**kwds) self.name = "Optimal" self.olm_bracket_step = None self.olm_counter = 0 self.olm_fvalues = None self.olm_mode = "none" self.olm_pname = "optimal_mode" self.olm_quality_threshold = 0 self.olm_relative_z = None self.olm_scan_hold = None self.olm_scan_step = None self.olm_scan_state = "na" self.olm_zvalues = None # Add optimal lock specific parameters. p = self.parameters.addSubSection(self.olm_pname) p.add(params.ParameterRangeFloat(description = "Distance +- z in nanometers", name = "bracket_step", value = 1000.0, min_value = 10.0, max_value = 10000.0)) p.add(params.ParameterRangeFloat(description = "Minimum 'quality' signal", name = "quality_threshold", value = 0.0, min_value = 0.0, max_value = 1000.0)) p.add(params.ParameterRangeFloat(description = "Step size in z in nanometers", name = "scan_step", value = 100.0, min_value = 10.0, max_value = 1000.0)) p.add(params.ParameterRangeInt(description = "Frames to pause between steps", name = "scan_hold", value = 10, min_value = 1, max_value = 100))
def __init__(self, module_params = None, qt_settings = None, **kwds): super().__init__(**kwds) self.analyzers = [] self.basename = None self.feed_names = [] self.number_fn_requested = 0 self.pixel_size = 0.1 self.shutters_info = None configuration = module_params.get("configuration") self.spot_counter = findSpots.SpotCounter(max_threads = configuration.get("max_threads"), max_size = configuration.get("max_size")) self.view = SpotCounterView(module_name = self.module_name, configuration = configuration) self.view.halDialogInit(qt_settings, module_params.get("setup_name") + " spot counter") # Spot counter parameters. self.parameters = params.StormXMLObject() self.parameters.add(params.ParameterRangeInt(description = "Maximum counts for the spotcounter graph", name = "max_spots", value = 500, min_value = 0, max_value = 1000, is_mutable = False, is_saved = False)) self.parameters.add(params.ParameterRangeFloat(description = "Scale bar length in nm", name = "scale_bar_len", value = 2000, min_value = 100, max_value = 10000)) self.parameters.add(params.ParameterRangeInt(description = "Spot detection threshold (camera counts)", name = "threshold", value = 250, min_value = 1, max_value = 10000)) self.parameters.add(params.ParameterString(description = "Which camera to display.", name = "which_camera", value = "", is_mutable = False, is_saved = False))
def __init__(self, module_params=None, qt_settings=None, **kwds): super().__init__(**kwds) self.film_settings = None self.hardware_timing_functionality = None self.configuration = module_params.get("configuration") self.parameters = params.StormXMLObject() # # FIXME: The range would be better set by what the cameras allow # based on their current configuration. # self.parameters.add( params.ParameterRangeFloat( description="Frames per second", name="fps", value=self.configuration.get("fps", 0.1), min_value=self.configuration.get("fps_min", 0.001), max_value=self.configuration.get("fps_max", 10000.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)
def __init__(self, **kwds): super().__init__(**kwds) self.directory = "" self.parameters = params.StormXMLObject() self.stage_functionality = None # Add stage UI parameters. self.parameters.add( params.ParameterRangeFloat(description="Large step size (microns)", name="large_step_size", value=200.0, min_value=1.0, max_value=1000.0)) self.parameters.add( params.ParameterRangeFloat(description="Small step size (microns)", name="small_step_size", value=10.0, min_value=1.0, max_value=100.0)) # UI setup. self.ui = stageUi.Ui_Dialog() self.ui.setupUi(self) # Configure all the stage movement buttons. icon_path = os.path.join(os.path.dirname(__file__), "../icons/") self.motion_buttons = [ MotionButton(button=self.ui.leftSButton, icon=os.path.join(icon_path, "1leftarrow-128.png"), button_type="small", xval=1, yval=0), MotionButton(button=self.ui.leftLButton, icon=os.path.join(icon_path, "2leftarrow-128.png"), button_type="large", xval=1, yval=0), MotionButton(button=self.ui.rightSButton, icon=os.path.join(icon_path, "1rightarrow-128.png"), button_type="small", xval=-1, yval=0), MotionButton(button=self.ui.rightLButton, icon=os.path.join(icon_path, "2rightarrow-128.png"), button_type="large", xval=-1, yval=0), MotionButton(button=self.ui.upSButton, icon=os.path.join(icon_path, "1uparrow-128.png"), button_type="small", xval=0, yval=1), MotionButton(button=self.ui.upLButton, icon=os.path.join(icon_path, "2uparrow-128.png"), button_type="large", xval=0, yval=1), MotionButton(button=self.ui.downSButton, icon=os.path.join(icon_path, "1downarrow-128.png"), button_type="small", xval=0, yval=-1), MotionButton(button=self.ui.downLButton, icon=os.path.join(icon_path, "2downarrow-128.png"), button_type="large", xval=0, yval=-1) ] for button in self.motion_buttons: button.motionClicked.connect(self.handleMotionClicked) # Connect the rest of the UI elements. self.ui.addButton.clicked.connect(self.handleAddButton) self.ui.clearButton.clicked.connect(self.handleClearButton) self.ui.goButton.clicked.connect(self.handleGoButton) self.ui.homeButton.clicked.connect(self.handleHomeButton) self.ui.loadButton.clicked.connect(self.handleLoadButton) self.ui.saveButton.clicked.connect(self.handleSaveButton) self.ui.saveComboBox.activated.connect(self.handleSaveComboBox) self.ui.zeroButton.clicked.connect(self.handleZeroButton) self.newParameters(self.parameters) # Disable UI until we get a stage functionality. self.setEnabled(False)
def __init__(self, hardware, parameters, parent): QtCore.QThread.__init__(self, parent) halModule.HalModule.__init__(self) self.click_step = 1.0 self.click_timer = QtCore.QTimer(self) self.click_x = 0.0 self.click_y = 0.0 self.client_sock = False self.connected = False self.default_image = QtGui.QImage("bt_image.png") self.drag_gain = 1.0 self.drag_multiplier = 100.0 self.drag_x = 0.0 self.drag_y = 0.0 self.filming = False self.image_is_new = True self.images_sent = 0 self.is_down = False self.is_drag = False self.lock_jump_size = 0.025 self.messages = [] self.mutex = QtCore.QMutex() self.send_pictures = hardware.get("send_pictures") self.show_camera = True self.start_time = 0 self.which_camera = "camera1" parameters.add( "bluetooth.z_step", params.ParameterRangeFloat("Z step size in um", "z_step", 0.025, 0.0, 1.0)) # Set current image to default. self.current_image = self.default_image # Setup bluetooth socket. have_bluetooth = True try: self.server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) self.server_sock.bind(("", bluetooth.PORT_ANY)) self.server_sock.listen(1) port = self.server_sock.getsockname()[1] hdebug.logText( "Bluetooth: Listening on RFCOMM channel {0:d}".format(port)) uuid = "3e1f9ea8-9c11-11e3-b248-425861b86ab6" bluetooth.advertise_service( self.server_sock, "halServer", service_id=uuid, service_classes=[uuid, bluetooth.SERIAL_PORT_CLASS], profiles=[bluetooth.SERIAL_PORT_PROFILE], ) except: print traceback.format_exc() hdebug.logText("Failed to start Bluetooth") have_bluetooth = False if have_bluetooth: # Setup timer. self.click_timer.setInterval(200) self.click_timer.timeout.connect(self.handleClickTimer) self.click_timer.setSingleShot(True) # Connect signals. self.newData.connect(self.handleNewData) self.start(QtCore.QThread.NormalPriority)
def __init__(self, config=None, is_master=False, **kwds): kwds["config"] = config super().__init__(**kwds) self.is_master = is_master # The camera functionality. self.camera_functionality = cameraFunctionality.CameraFunctionality( camera_name=self.camera_name, is_master=self.is_master, parameters=self.parameters) # Initialize library. spinnaker.pySpinInitialize(verbose=False) # Get the camera & set some defaults. self.camera = spinnaker.getCamera(config.get("camera_id")) # Set FLIR-specific camera properties to control relationship between # exposure time and frame rate: This dictionary will allow extension in the future if needed self.exposure_control = {"CameraControlExposure": True} # Extract preset values if provided if config.has("presets"): # Extract preset values presets = config.get("presets") print("Configuring preset values of spinnaker camera: " + str(config.get("camera_id"))) # Loop over values and set them for p_name in presets.getAttrs(): if self.camera.hasProperty( p_name ): # Confirm the camera has the property and warn if not p_value = presets.get(p_name) self.camera.setProperty(p_name, p_value) # Set value set_value = self.camera.getProperty( p_name).getValue() # Check set print(" " + str(p_name) + ": " + str(p_value) + " (" + str(set_value) + ")") else: if p_name not in self.exposure_control.keys(): print("!!!! preset " + str(p_name) + " is not a valid parameter for this camera") # Set the exposure-frame-rate-control parameters self.exposure_control["CameraControlExposure"] = presets.get( "CameraControlExposure", True) print("Set exposure control properties:") for key in self.exposure_control.keys(): print(" " + str(key) + ": " + str(self.exposure_control[key])) else: print("No presets provided for spinnaker camera: " + str(config.get("camera_id"))) # Verify that we have turned off some of these 'features'. ## REMOVED THIS BLOCK AS IT IS CAMERA SPECIFIC #for feature in ["pgrDefectPixelCorrectionEnable", # "BlackLevelClampingEnable", # "SharpnessEnabled", # "GammaEnabled"]: # if self.camera.hasProperty(feature): # assert not self.camera.getProperty(feature).getValue() # Configure 'master' cameras to not use triggering. # self.camera.getProperty("TriggerMode") if self.is_master: self.camera.setProperty("TriggerMode", "Off") # This line is connected to the DAQ. self.camera.setProperty("LineSelector", "Line1") self.camera.setProperty("LineSource", "ExposureActive") # This line is connected to the other cameras. self.camera.setProperty("LineSelector", "Line2") self.camera.setProperty("LineMode", "Output") self.camera.setProperty("LineSource", "ExposureActive") # Configure 'slave' cameras to use triggering. # We are following: http://www.ptgrey.com/KB/11052 # # "Configuring Synchronized Capture with Multiple Cameras" # # Also, we connected the master camera to the DAQ card # using it's OPTO-OUT connection. # else: self.camera.setProperty("TriggerMode", "On") self.camera.setProperty("TriggerSource", "Line3") self.camera.setProperty("TriggerOverlap", "ReadOut") self.camera.setProperty( "TriggerActivation", config.get("trigger_activation", "FallingEdge")) # # Dictionary of Point Grey specific camera parameters. # # All cameras can set these. self.pgrey_props = { "BlackLevel": True, "Gain": True, "Height": True, "OffsetX": True, "OffsetY": True, "Width": True } # Only master cameras can set "AcquisitionFrameRate". if self.is_master: self.pgrey_props["AcquisitionFrameRate"] = True # # FIXME: We're using a made up max_value for this parameter because it is # the default parameter. If we use the real range then any # parameters that are added later could have their frame rate # changed in an unexpected way. Unfortunately this also means that # if the user goes above the real maximum on this parameter then # the software will crash. # self.parameters.add( params.ParameterRangeFloat( description="Acquisition frame rate (FPS)", name="AcquisitionFrameRate", value=10.0, max_value=5000, min_value=self.camera.getProperty( "AcquisitionFrameRate").getMinimum())) # Slave cameras can set "ExposureTime". # # FIXME? If this is too large then the slave will be taking images # at a different rate than master. Maybe this should be # limited? Automatically set based on "master" frame rate? # else: self.pgrey_props["ExposureTime"] = True self.parameters.add( params.ParameterRangeFloat(description="Exposure time (us)", name="ExposureTime", value=99800.0, max_value=self.camera.getProperty( "ExposureTime").getMaximum(), min_value=self.camera.getProperty( "ExposureTime").getMinimum())) # Load properties as required by the spinnaker Python wrapper. for pname in self.pgrey_props: self.camera.getProperty(pname) max_intensity = 2**12 self.parameters.setv("max_intensity", max_intensity) # Set chip size and HAL parameter ranges. x_chip = self.camera.getProperty("WidthMax").getValue() self.parameters.setv("x_chip", x_chip) for pname in ["x_end", "x_start"]: self.parameters.getp(pname).setMaximum(x_chip) y_chip = self.camera.getProperty("HeightMax").getValue() self.parameters.setv("y_chip", y_chip) for pname in ["y_end", "y_start"]: self.parameters.getp(pname).setMaximum(y_chip) # # Reset X, Y offsets. We do this here because otherwise the # initial ranges of these parameters will be incorrect and the # only way to fix them is using the parameters editor. # self.camera.setProperty("OffsetX", 0) self.camera.setProperty("OffsetY", 0) self.parameters.add( params.ParameterRangeFloat( description="Black level", name="BlackLevel", value=1.0, max_value=self.camera.getProperty("BlackLevel").getMaximum(), min_value=self.camera.getProperty("BlackLevel").getMinimum())) self.parameters.add( params.ParameterRangeFloat( description="Gain", name="Gain", value=10.0, max_value=self.camera.getProperty("Gain").getMaximum(), min_value=self.camera.getProperty("Gain").getMinimum())) self.parameters.add( params.ParameterRangeInt(description="AOI height", name="Height", value=y_chip, max_value=y_chip, min_value=4)) self.parameters.add( params.ParameterRangeInt(description="AOI x offset", name="OffsetX", value=0, max_value=x_chip - 4, min_value=0)) self.parameters.add( params.ParameterRangeInt(description="AOI y offset", name="OffsetY", value=0, max_value=y_chip - 4, min_value=0)) self.parameters.add( params.ParameterRangeInt(description="AOI width", name="Width", value=x_chip, max_value=x_chip, min_value=4)) # 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)
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)
def __init__(self, config=None, is_master=False, **kwds): kwds["config"] = config super().__init__(**kwds) self.is_master = is_master # The camera functionality. self.camera_functionality = cameraFunctionality.CameraFunctionality( camera_name=self.camera_name, is_master=self.is_master, parameters=self.parameters) # Initialize library. spinnaker.pySpinInitialize(verbose=False) # Get the camera & set some defaults. self.camera = spinnaker.getCamera(config.get("camera_id")) # In order to turn off pixel defect correction the camera has # to be in video mode 0. self.camera.setProperty("VideoMode", "Mode0") self.camera.setProperty("pgrDefectPixelCorrectionEnable", False) # Set pixel format. #self.camera.setProperty("PixelFormat", "Mono12Packed") #self.camera.setProperty("PixelFormat", "Mono12p") self.camera.setProperty("PixelFormat", "Mono16") self.camera.setProperty("VideoMode", config.get("video_mode")) # We don't want any of these 'features'. self.camera.setProperty("AcquisitionFrameRateAuto", "Off") self.camera.setProperty("ExposureAuto", "Off") self.camera.setProperty("GainAuto", "Off") if self.camera.hasProperty("pgrExposureCompensationAuto"): self.camera.setProperty("pgrExposureCompensationAuto", "Off") if self.camera.hasProperty("BlackLevelClampingEnable"): self.camera.setProperty("BlackLevelClampingEnable", False) if self.camera.hasProperty("SharpnessEnabled"): self.camera.setProperty("SharpnessEnabled", False) if self.camera.hasProperty("GammaEnabled"): self.camera.setProperty("GammaEnabled", False) # # No idea what this means in the context of a black and white # camera. We try and turn it off but that seems to be much # harder to do than one would hope. # self.camera.setProperty("OnBoardColorProcessEnabled", False) # Verify that we have turned off some of these 'features'. for feature in [ "pgrDefectPixelCorrectionEnable", "BlackLevelClampingEnable", "SharpnessEnabled", "GammaEnabled" ]: if self.camera.hasProperty(feature): assert not self.camera.getProperty(feature).getValue() # Configure 'master' cameras to not use triggering. # self.camera.getProperty("TriggerMode") if self.is_master: self.camera.setProperty("TriggerMode", "Off") # This line is connected to the DAQ. self.camera.setProperty("LineSelector", "Line1") self.camera.setProperty("LineSource", "ExposureActive") # This line is connected to the other cameras. self.camera.setProperty("LineSelector", "Line2") self.camera.setProperty("LineMode", "Output") self.camera.setProperty("LineSource", "ExposureActive") # Configure 'slave' cameras to use triggering. # # We are following: http://www.ptgrey.com/KB/11052 # "Configuring Synchronized Capture with Multiple Cameras" # # Also, we connected the master camera to the DAQ card # using it's OPTO-OUT connection. # else: self.camera.setProperty("TriggerMode", "On") self.camera.setProperty("TriggerSource", "Line3") self.camera.setProperty("TriggerOverlap", "ReadOut") self.camera.setProperty( "TriggerActivation", config.get("trigger_activation", "FallingEdge")) # # Dictionary of Point Grey specific camera parameters. # # All cameras can set these. self.pgrey_props = { "BlackLevel": True, "Gain": True, "Height": True, "OffsetX": True, "OffsetY": True, "Width": True } # Only master cameras can set "AcquisitionFrameRate". if self.is_master: self.pgrey_props["AcquisitionFrameRate"] = True # # FIXME: We're using a made up max_value for this parameter because it is # the default parameter. If we use the real range then any # parameters that are added later could have their frame rate # changed in an unexpected way. Unfortunately this also means that # if the user goes above the real maximum on this parameter then # the software will crash. # self.parameters.add( params.ParameterRangeFloat( description="Acquisition frame rate (FPS)", name="AcquisitionFrameRate", value=10.0, max_value=500.0, min_value=self.camera.getProperty( "AcquisitionFrameRate").getMinimum())) # Slave cameras can set "ExposureTime". # # FIXME? If this is too large then the slave will be taking images # at a different rate than master. Maybe this should be # limited? Automatically set based on "master" frame rate? # else: self.pgrey_props["ExposureTime"] = True self.parameters.add( params.ParameterRangeFloat(description="Exposure time (us)", name="ExposureTime", value=99800.0, max_value=self.camera.getProperty( "ExposureTime").getMaximum(), min_value=self.camera.getProperty( "ExposureTime").getMinimum())) # Load properties as required by the spinnaker Python wrapper. for pname in self.pgrey_props: self.camera.getProperty(pname) max_intensity = 2**12 self.parameters.setv("max_intensity", max_intensity) # Set chip size and HAL parameter ranges. x_chip = self.camera.getProperty("WidthMax").getValue() self.parameters.setv("x_chip", x_chip) for pname in ["x_end", "x_start"]: self.parameters.getp(pname).setMaximum(x_chip) y_chip = self.camera.getProperty("HeightMax").getValue() self.parameters.setv("y_chip", y_chip) for pname in ["y_end", "y_start"]: self.parameters.getp(pname).setMaximum(y_chip) # # Reset X, Y offsets. We do this here because otherwise the # initial ranges of these parameters will be incorrect and the # only way to fix them is using the parameters editor. # self.camera.setProperty("OffsetX", 0) self.camera.setProperty("OffsetY", 0) self.parameters.add( params.ParameterRangeFloat( description="Black level", name="BlackLevel", value=1.0, max_value=self.camera.getProperty("BlackLevel").getMaximum(), min_value=self.camera.getProperty("BlackLevel").getMinimum())) self.parameters.add( params.ParameterRangeFloat( description="Gain", name="Gain", value=10.0, max_value=self.camera.getProperty("Gain").getMaximum(), min_value=self.camera.getProperty("Gain").getMinimum())) self.parameters.add( params.ParameterRangeInt(description="AOI height", name="Height", value=y_chip, max_value=y_chip, min_value=4)) self.parameters.add( params.ParameterRangeInt(description="AOI x offset", name="OffsetX", value=0, max_value=x_chip - 4, min_value=0)) self.parameters.add( params.ParameterRangeInt(description="AOI y offset", name="OffsetY", value=0, max_value=y_chip - 4, min_value=0)) self.parameters.add( params.ParameterRangeInt(description="AOI width", name="Width", value=x_chip, max_value=x_chip, min_value=4)) # 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)
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)
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)
def __init__(self, config = None, **kwds): super().__init__(**kwds) self.cfv_fn = None self.click_step = 1.0 self.click_timer = QtCore.QTimer(self) self.click_x = 0.0 self.click_y = 0.0 self.client_sock = False self.connected = False self.default_image = QtGui.QImage("bt_image.png") self.drag_gain = 1.0 self.drag_x = 0.0 self.drag_y = 0.0 self.filming = False self.image_is_new = True self.images_sent = 0 self.is_down = False self.is_drag = False self.messages = [] self.mutex = QtCore.QMutex() self.offset_min = None self.offset_max = None self.parameters = params.StormXMLObject() self.qpd_fn = None self.running = False self.send_pictures = config.get("send_pictures") self.show_camera = True self.stage_fn = None self.start_time = 0 self.sum_min = None self.sum_max = None self.parameters.add(params.ParameterRangeFloat(description = "Drag multiplier", name = "d_mult", value = 100.0, min_value = 0.1, max_value = 1000.0)) self.parameters.add(params.ParameterRangeFloat(description = "Z step size in um", name = "z_step", value = 0.1, min_value = 0.0, max_value = 5.0)) # Set current image to default. self.current_image = self.default_image # Setup bluetooth socket. have_bluetooth = True try: self.server_sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM) self.server_sock.bind(("",bluetooth.PORT_ANY)) self.server_sock.listen(1) port = self.server_sock.getsockname()[1] print("Bluetooth: Listening on RFCOMM channel {0:d}".format(port)) uuid = "3e1f9ea8-9c11-11e3-b248-425861b86ab6" bluetooth.advertise_service(self.server_sock, "halServer", service_id = uuid, service_classes = [uuid, bluetooth.SERIAL_PORT_CLASS], profiles = [bluetooth.SERIAL_PORT_PROFILE]) except bluetooth.btcommon.BluetoothError: print(traceback.format_exc()) print("Failed to start Bluetooth") have_bluetooth = False if have_bluetooth: # Setup timer. self.click_timer.setInterval(200) self.click_timer.timeout.connect(self.handleClickTimer) self.click_timer.setSingleShot(True) # Connect signals. self.newMessage.connect(self.handleNewMessage) self.start(QtCore.QThread.NormalPriority)
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)