def __init__(self, mdt_serial0, mdt_serial1, slm_datafiles, ks_mppm_addr, powermeter_ports, **kwargs): # connect the Thorlabs piezo controllers self.mdt0 = MDT(mdt_serial0) self.mdt1 = MDT(mdt_serial1) self.mdt0.SetAllVoltage(20) self.mdt1.SetAllVoltage(20) self.__current_set_voltages = [20] * 6 self.limit_voltages = self.get_limit_voltages() # connect Holoeye SLM self.slm = slmdisplaysdk.SLMDisplay() self.slm.utilsSLMPreviewShow() self.slm_datafiles = slm_datafiles self.slm_data_handles = self.slm_preload_data_from_file() self.slmErrorCode = slmdisplaysdk.SLMDisplay.ErrorCode self.slmShowFlags = slmdisplaysdk.SLMDisplay.ShowFlags # connect the Keysight multiport powermeter visa_rm = pyvisa.ResourceManager() self.ks_mppm = visa_rm.open_resource(ks_mppm_addr) self.ks_mppm.query('*IDN?') self.ks_mppm.write('*RST') self.ks_mppm.query('*TST?') self.ports_pyindices = np.array(powermeter_ports) - 1 self.nport = len(powermeter_ports) # other parameters self.best_ave_effi = 0 self.best_voltages = [0] * 6 time.sleep(1)
# Shows a 2d matrix of grayscale data with data type float (single) on the SLM. # The gray values have a range from 0 to 1, non-fitting values will be cropped. import time # Import the SLM Display SDK: import detect_heds_module_path from holoeye import slmdisplaysdk # Make some enumerations available locally to avoid too much code: ErrorCode = slmdisplaysdk.SLMDisplay.ErrorCode ShowFlags = slmdisplaysdk.SLMDisplay.ShowFlags # Detect SLMs and open a window on the selected SLM: slm = slmdisplaysdk.SLMDisplay() # Open the SLM preview window (might have an impact on performance): slm.utilsSLMPreviewShow() # Calculate e.g. a vertical blazed grating: blazePeriod = 77 # Reserve memory for the data: dataWidth = slm.width_px dataHeight = slm.height_px data = slmdisplaysdk.createFieldSingle(dataWidth, dataHeight) print("dataWidth = " + str(dataWidth)) print("dataHeight = " + str(dataHeight)) # Calculate the data:
def ini_stage(self, controller=None): """ Initialize the controller and stages (axes) with given parameters. ============== ================================================ ========================================================================================== **Parameters** **Type** **Description** *controller* instance of the specific controller object If defined this hardware will use it and will not initialize its own controller instance ============== ================================================ ========================================================================================== Returns ------- Easydict dictionnary containing keys: * *info* : string displaying various info * *controller*: instance of the controller object in order to control other axes without the need to init the same controller twice * *stage*: instance of the stage (axis or whatever) object * *initialized*: boolean indicating if initialization has been done corretly See Also -------- daq_utils.ThreadCommand """ try: # initialize the stage and its controller status # controller is an object that may be passed to other instances of DAQ_Move_Mock in case # of one controller controlling multiaxes self.status.update( edict(info="", controller=None, initialized=False)) #check whether this stage is controlled by a multiaxe controller (to be defined for each plugin) # if mutliaxes then init the controller here if Master state otherwise use external controller if self.settings.child( 'multiaxes', 'ismultiaxes').value() and self.settings.child( 'multiaxes', 'multi_status').value() == "Slave": if controller is None: raise Exception( 'no controller has been defined externally while this axe is a slave one' ) else: self.controller = controller else: #Master stage self.controller = slmdisplaysdk.SLMDisplay( ) #any object that will control the stages dataWidth = self.controller.width_px dataHeight = self.controller.height_px self.data_uchar = slmdisplaysdk.createFieldUChar( dataWidth, dataHeight) info = "Holoeye" self.status.info = info self.status.controller = self.controller self.status.initialized = True return self.status except Exception as e: self.emit_status( ThreadCommand('Update_Status', [getLineInfo() + str(e), 'log'])) self.status.info = getLineInfo() + str(e) self.status.initialized = False return self.status
def holoeye_slm_detect(): from holoeye import slmdisplaysdk print("Detecting Holoeye SLM devices (Detection window will pop up)") slm = slmdisplaysdk.SLMDisplay() print()
def connect(self): self.slm_device = slmdisplaysdk.SLMDisplay() self.slm_device.open() # For version 2.0.1