def __init__(self, address=None, logger=None): """Instantiate driver class. :address: Address of the device, e.g. 'ASRL3::INSTR' Can be read out by using rm = pyvisa.ResourceManager() rm.list_resources() :logger: An instance of a LogClient. """ # Instantiate log self.log = LogHandler(logger=logger) self.addr = address self.rm = ResourceManager() try: self.device = self.rm.open_resource(self.addr) self.log.info(f"Successfully connected to {self.device}.") # Configure device grammar self.device.write_termination = ';' except VisaIOError: self.log.error(f"Connection to {self.addr} failed.") raise
def __init__(self, tagger, logger=None): """Instantiate count monitor :param tagger: instance of TimeTagger class :param ch_list: list of channels to count :param logger: instance of LogClient class, optional """ # Log self.log = LogHandler(logger=logger) # Reference to tagger self._tagger = tagger # Log device ID information to demonstrate that connection indeed works serial = self._tagger.getSerial() model = self._tagger.getModel() self.log.info( 'Got reference to Swabian Instruments TimeTagger device \n' 'Serial number: {0}, Model: {1}' ''.format(serial, model)) # Counter instance self._ctr = {} self._channels = {}
def __init__(self, gpib_address, logger): """Instantiate driver class. :gpib_address: GPIB-address of the scope, e.g. 'GPIB0::12::INSTR' Can be read out by using rm = pyvisa.ResourceManager() rm.list_resources() :logger: And instance of a LogClient. """ # Instantiate log. self.log = LogHandler(logger=logger) self.rm = ResourceManager() try: self.device = self.rm.open_resource(gpib_address) device_id = self.device.query('*IDN?') self.log.info(f"Successfully connected to {device_id}.") except VisaIOError: self.log.error(f"Connection to {gpib_address} failed.") # We set a more forgiving timeout of 10s (default: 2s). self.device.timeout = 10000 # Reset to factory settings. self.reset() # Set all attenuations to 1x. for channel in CHANNEL_LIST: self.set_channel_attenuation(channel, 1)
def __init__(self, port_name, device_name, filters, logger=None): """Instantiate Hardware class for FW102c Filterwheel by instantiating a FW102C class :device_name: Readable name of device, e.g. 'Collection Filters' :port_name: Port name over which Filter wheel is connect via USB :filters: A dictionary where the keys are the numbered filter positions and the values are strings describing the filter, e.g. '4 ND' """ # Instantiate log self.log = LogHandler(logger=logger) # Retrieve name and filter options self.device_name = device_name self.filters = filters # Instantiate FW102C self.filter_wheel = FW102C(port=port_name, logger=self.log) if not self.filter_wheel.isOpen: self.log.error("Filterwheel {} connection failed".format( self.device_name)) else: self.log.info("Filterwheel {} connection successfully".format( self.device_name))
class AGC_100: def __init__(self, port, logger=None): """Instantiates serial connection to pressure gauge """ # Instantiate log self.log = LogHandler(logger=logger) ser = serial.Serial(port=port, baudrate=9600, timeout=1, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) self.sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser)) # Log initial pressure. init_pressure = self.get_pressure() self.log.info(f"Successfully reading {init_pressure} mBar.") def get_pressure(self): '''Returns pressure in mBar''' raw_data = self.sio.readline() pressure = float(raw_data.split(",")[1].replace(" mbar", "")) return pressure
def __init__(self, host, port=1998, logger=None, num_lasers=2): """ Instantiates DLC_Pro object :param host: (str) hostname of laser (IP address) :param port: (int) port number, toptica defaults to 1998 :num_lasers: Number of installed lasers :param logger: (LogClient) """ self.host = host self.port = port self.log = LogHandler(logger) self.dlc = None self.laser_nums = range(1, num_lasers + 1) # Check connection try: # Check laser connection self.dlc = Telnet(host=self.host, port=self.port) self.dlc.read_until(b'>', timeout=1) for laser_num in self.laser_nums: self._check_laser_connection(laser_num) except ConnectionRefusedError: self.log.error('Could not connect to Toptica DLC Pro at ' f'IP address: {self.host}, port: {self.port}')
def __init__(self, config, staticline_clients=None, logger_client=None, host=None, port=None): self.log = LogHandler(logger=logger_client) self.config = config self.host = host self.port = port self.config_dict = load_script_config('staticline', config, logger=self.log) self.initialize_drivers(staticline_clients, logger_client)
def __init__(self, device_num, logger): """Instantiate driver class. device_num is numbering of devices connected via USB. Drivrt then finds serial numbers of polarization paddle by Driver, e.g. b'38154354' """ # Instantiate log. self.log = LogHandler(logger=logger) #Loads polarization contorolles DLL and define arguments and result 5types for c function self._polarizationdll = ctypes.cdll.LoadLibrary( 'Thorlabs.MotionControl.Polarizer.dll') self._devmanagerdll = ctypes.cdll.LoadLibrary( 'Thorlabs.MotionControl.DeviceManager.dll') self._configure_functions() #get device list size if self._polarizationdll.TLI_BuildDeviceList() == 0: num_devs = self._polarizationdll.TLI_GetDeviceListSize() #print(f"There are {num_devs} devices connected") #Get devices serial numbers serialNos = ctypes.create_string_buffer( 100) #the way to have a mutable buffer serialNosSize = ctypes.c_ulong(ctypes.sizeof(serialNos)) List = self._polarizationdll.TLI_GetDeviceListByTypeExt( serialNos, serialNosSize, 38) #if List: # print("Failed to get device list") #else: # print("Device list created succesfully") #change these massages to interact with logger self.dev_name = serialNos.value.decode("utf-8") #.strip().split(',') #print(f"Connected to device {self.dev_name}") #get device info including serial number self.device_info = TLI_DeviceInfo() # container for device info self._polarizationdll.TLI_GetDeviceInfo( serialNos[(device_num - 1) * 9:(device_num * 9) - 1], ctypes.byref(self.device_info) ) #when there will be a few devices figure out how to seperate and access each one self.device = serialNos[(device_num - 1) * 9:(device_num * 9) - 1] #print("Description: ", self.device_info.description) #print("Serial No: ", self.device_info.serialNo) #print("Motor Type: ", self.device_info.motorType) #print("USB PID: ", self.device_info.PID) #print("Max Number of Paddles: ", self.device_info.maxPaddles) #establising connection to device self.paddles = [paddle1, paddle3, paddle2] connection = self._polarizationdll.MPC_Open(self.device) if connection == 0: self.log.info(f"Successfully connected to {self.device}.") else: self.log.error( f"Connection to {self.device} failed due to error {connection}." )
def __init__(self, logger=None): """ Instantiate Nanopositioners""" self.log = LogHandler(logger) self.dummy = False try: # Loads Nanopositioners DLL and define arguments and result types for c function self._nanopositionersdll = ctypes.windll.LoadLibrary( 'SmarActCTL.dll') self._configure_functions() #Finds devices connected to controller buffer = ctypes.create_string_buffer( 4096) #the way to have a mutable buffer buffersize = ctypes.c_size_t(ctypes.sizeof( buffer)) #size _t gives c_ulonglong, not as in manual result = self._nanopositionersdll.SA_CTL_FindDevices( None, buffer, buffersize) # Handle errors if result: msg_str = 'No MCS2 devices found' self.log.error(msg_str) #Establishes a connection to a device self.dev_name = buffer.value.decode("utf-8") dhandle = ctypes.c_uint32() connect = self._nanopositionersdll.SA_CTL_Open( dhandle, buffer.value, None) if connect == 0: self.dhandle = dhandle.value self.log.info( f'Connected to device {self.dev_name} with handle {self.dhandle}' ) else: msg_str = f'Failed to connect to device {self.dev_name}' self.log.error(msg_str) # Get channel information channel_buffer = ctypes.c_int32() channel_buffer_size = ctypes.c_size_t( ctypes.sizeof(channel_buffer)) channel_result = self._nanopositionersdll.SA_CTL_GetProperty_i32( self.dhandle, 0, self.PKEY_NUM_CH, channel_buffer, channel_buffer_size) self.num_ch = channel_buffer.value if channel_result == 0 and self.num_ch > 0: self.log.info( f'Found {self.num_ch} channels on {self.dev_name}') else: msg_str = f'Failed to find channels on {self.dev_name}' self.log.error(msg_str) except WindowsError: self.log.warn('Did not find MCS2 DLL, entering dummy mode') self.dummy = True
def __init__(self, ip, port, channel, log_client, wavemeterclient, log_tcp): self.ip = ip self.port = port self.log_tcp = log_tcp self.log = LogHandler(log_client) self.channel = channel self.trans_id = 512193 self.wm = wavemeterclient
def __init__(self, dev_name_str, logger=None): # # Define internal variables # self.log = LogHandler(logger=logger) self.map_dict = dict() self.writn_wfm_set = set() # # "Load" niHSDIO DLL # try: self.dll = ctypes.WinDLL(NI_HSDIO_DLL_PATH) except OSError: msg_str = 'DLL loading failed. \n' \ 'Ensure that niHSDIO DLL path is correct: \n' \ 'it should be specified in pylabnet.hardware.p_gen.ni_hsdio.__init__.py \n' \ 'Current value is: \n' \ '"{}"'.format(NI_HSDIO_DLL_PATH) self.log.error(msg_str=msg_str) raise PGenError(msg_str) # Build C-prototypes (in particular, specify the return # types such that Python reads results correctly) build_c_func_prototypes(self.dll) # # Connect to device # # Create blank session handle self._handle = NITypes.ViSession() # Convert dev_name to the DLL-readable format self._dev_name = NITypes.ViRsrc(dev_name_str.encode('ascii')) self._er_chk( self.dll.niHSDIO_InitGenerationSession( self._dev_name, # ViRsrc resourceName NIConst.VI_TRUE, # ViBoolean IDQuery NIConst.VI_TRUE, # ViBoolean resetDevice NIConst. VI_NULL, # ViConstString optionString - not used, set to VI_NULL ctypes.byref(self._handle) # ViSession * session_handle )) # Log info message serial_str = self._get_attr_str(NIConst.NIHSDIO_ATTR_SERIAL_NUMBER) self.log.info( 'Connected to NI HSDIO card {0}. Serial number: {1}. Session handle: {2}' ''.format(dev_name_str, serial_str, self._handle))
def __init__(self, nanopos_client: smaract_mcs2.Client, attocube_client: attocube_anc300.Client, gui='positioner_control_mixed', log_client=None, config=None, port=None): """ Instantiates the controller :param nanopos_client: (pylabnet.network.client_server.smaract_mcs2.Client) :param gui: name of .ui file ot use :param log_client: (pylabnet.utils.logging.logger.LogClient) :param config: (str) name of config file, optional :param port: (int) port number for update/script server """ self.pos = nanopos_client self.attocube = attocube_client self.log = LogHandler(logger=log_client) self.gui = Window(gui_template=gui, host=get_ip(), port=port) self.gui.apply_stylesheet() self.widgets = get_gui_widgets(self.gui, **self.WIDGET_DICT) self.save_params = generate_widgets( dict(n_steps=self.NUM_CHANNELS, amplitude=self.NUM_CHANNELS, frequency=self.NUM_CHANNELS, velocity=self.NUM_CHANNELS)) # Additional attributes self.prev_amplitude = [50] * self.NUM_CHANNELS self.prev_frequency = [30] * self.NUM_CHANNELS self.prev_velocity = [100] * self.NUM_CHANNELS self.prev_voltage = [50] * self.NUM_CHANNELS self.voltage_override = False self.config = config self.lock_status = [False] * int(self.NUM_CHANNELS / 3) self.released = [False] * self.NUM_CHANNELS self.gui.config_label.setText(self.config) # Configure all button and parameter updates self._setup_gui() # Setup shortcut to use keyboard to step fiber self.press_right = QShortcut(QKeySequence('Right'), self.gui) self.press_left = QShortcut(QKeySequence('Left'), self.gui) self.press_up = QShortcut(QKeySequence('Up'), self.gui) self.press_down = QShortcut(QKeySequence('Down'), self.gui) self.press_up_z = QShortcut(QKeySequence('PgUp'), self.gui) self.press_down_z = QShortcut(QKeySequence('PgDown'), self.gui) self.widgets['keyboard_change_combo'].currentIndexChanged.connect( self._bind_arrow_keys)
def __init__(self, host, port=0, query_delay=0.001, passwd=None, limits=DEFAULT_LIMITS, logger=None): """ Instantiate ANC300 objcet. :param host: IP of telnet connection. :param port: Port of telnet connection. :param query_delay: Delay between queries (ins s). :param passwd: Telnet login password. :param limits: Voltage limit dictionary. :param logger: Log client. """ self.log = LogHandler(logger) self.query_delay = query_delay self.lastcommand = "" self.freq_lim = limits["freq_lim"] self.step_voltage_lim = limits["step_voltage_lim"] # Instantiate Telnet Connection self.connection = Telnet(host, port) # Setup terminations self.read_termination = '\r\n' self.write_termination = self.read_termination # Log into telnet client time.sleep(query_delay) ret = self._read(check_ack=False) self._write(passwd, check_ack=False) time.sleep(self.query_delay) ret = self._read(check_ack=False) authmsg = ret.split(self.read_termination)[1] if authmsg != 'Authorization success': self.log.error(f"Attocube authorization failed '{authmsg}'") else: # Read board serial number board_ver = self._write("getcser") # Check how many exes are available valid_axes, num_axes = self._check_num_channels() self.axes = valid_axes self.num_axes = num_axes self.log.info( f"Connected to {board_ver} with {self.num_axes} available axes." )
def __init__(self, logger=None, client_tuples=None, config=None, config_name=None): self.log = LogHandler(logger) self.dataset = None # Instantiate GUI window self.gui = Window(gui_template='data_taker', host=get_ip()) # Configure list of experiments self.gui.config.setText(config_name) self.config = config self.exp_path = self.config['exp_path'] if self.exp_path is None: self.exp_path = os.getcwd() sys.path.insert(1, self.exp_path) self.update_experiment_list() # Configure list of clients self.clients = {} # Retrieve Clients for client_entry in self.config['servers']: client_type = client_entry['type'] client_config = client_entry['config'] client = find_client(clients=client_tuples, settings=client_config, client_type=client_type, client_config=client_config, logger=self.log) self.clients[f"{client_type}_{client_config}"] = client for client_name, client_obj in self.clients.items(): client_item = QtWidgets.QListWidgetItem(client_name) client_item.setToolTip(str(client_obj)) self.gui.clients.addItem(client_item) # Configure dataset menu for name, obj in inspect.getmembers(datasets): if inspect.isclass(obj) and issubclass(obj, datasets.Dataset): self.gui.dataset.addItem(name) # Configure button clicks self.gui.configure.clicked.connect(self.configure) self.gui.run.clicked.connect(self.run) self.gui.save.clicked.connect(self.save) self.gui.load_config.clicked.connect(self.reload_config) self.gui.showMaximized() self.gui.apply_stylesheet()
def __init__(self, device_name, logger=None, dummy=False): """Instantiate NI DAQ mx card :device_name: (str) Name of NI DAQ mx card, as displayed in the measurement and automation explorer """ # Device name self.dev = device_name # Log self.log = LogHandler(logger=logger) self.dummy = dummy # Try to get info of DAQ device to verify connection try: ni_daq_device = nidaqmx.system.device.Device(name=device_name) self.log.info( "Successfully connected to NI DAQ '{device_name}' (type: {product_type}) \n" "".format( device_name=ni_daq_device.name, product_type=ni_daq_device.product_type ) ) # If failed, provide info about connected DAQs except (nidaqmx.DaqError, OSError): # Log exception message # - get names of all connected NI DAQs try: ni_daqs_names = nidaqmx.system._collections.device_collection.\ DeviceCollection().device_names # - exception message self.log.error( "NI DAQ card {} not found. \n" "There are {} NI DAQs available: \n " " {}" "".format( device_name, len(ni_daqs_names), ni_daqs_names ) ) except: self.log.error('No NI modules found') if self.dummy: self.log.info('Entering dummy mode instead') self.counters = {}
def __init__(self, tagger, click_ch, gate_ch, logger=None): """Instantiate gated counter :param tagger: instance of TimeTagger class :param click_ch: (int|list of int) clicks on all specified channels will be summed into one logical channel :param gate_ch: (int) positive/negative channel number - count while gate is high/low """ # Log self.log = LogHandler(logger=logger) # Reference to tagger self._tagger = tagger # Log device ID information to demonstrate that connection indeed works serial = self._tagger.getSerial() model = self._tagger.getModel() self.log.info( 'Got reference to Swabian Instruments TimeTagger device \n' 'Serial number: {0}, Model: {1}' ''.format(serial, model)) # Gated Counter # reference to the TT.CountBetweenMarkers measurement instance self._ctr = None # number of count bins: # length of returned 1D count array, the expected number of gate pulses, # the size of allocated memory buffer. # must be given as argument of init_ctr() call self._bin_number = 0 # Channel assignments self._click_ch = 0 self._gate_ch = 0 # reference to Combiner object # (if _click_ch is a list - then counts on all channels are summed # into virtual channel - self._combiner.getChannel()) self._combiner = None # apply channel assignment self.set_ch_assignment(click_ch=click_ch, gate_ch=gate_ch) # Module status code # -1 "void" # 0 "idle" # 1 "in_progress" # 2 "finished" self._status = -1 self._set_status(-1)
def __init__(self, pb, sampling_rate, data_dict, x_tol, y_tol, logger): """Initialize the pulseblock checker instance. :pb: (object) Pulseblock object :sampling_rate: Sampling rate of pulse sequence :data_dict: (dictionary) Dictionary containign as keys the trace names according to pulseblock objects, and as values a np.array containing the measured trace in the folllowing form: [x_values, y_values], where x_values and y_values are np.arrays. :x_tol: Allowed deviation in x-diraction of target trace. :y_tol: Allowed deviation in y-direction on target trace. """ # Instantiate log self.log = LogHandler(logger=logger) # Store parameters self.pb = pb self.sampling_rate = sampling_rate self.data_dict = data_dict self.x_tol = x_tol self.y_tol = y_tol self.traces_to_check = data_dict.keys() # Check for keys self._check_key_assignments()
def __init__(self, device_id, logger, dummy=False, api_level=6, reset_dio=False, disable_everything=False, **kwargs): """ Instantiate AWG :logger: instance of LogClient class :device_id: Device id of connceted ZI HDAWG, for example 'dev8060' :api_level: API level of zhins API """ # Instantiate log self.log = LogHandler(logger=logger) # Store dummy flag self.dummy = dummy # Setup HDAWG self._setup_hdawg(device_id, logger, api_level, reset_dio, disable_everything)
def __init__(self, logger=None): """ Instantiate wavemeter :param logger: instance of LogClient class (optional) """ # Log self.log = LogHandler(logger=logger) # Load WLM DLL try: self._wavemeterdll = ctypes.windll.LoadLibrary('wlmData.dll') except: msg_str = 'High-Finesse WS7 Wavemeter is not properly installed on this computer' self.log.error(msg_str) raise WavemeterError(msg_str) # Set all DLL function parameters and return value types self._wavemeterdll.GetWLMVersion.restype = ctypes.c_long self._wavemeterdll.GetWLMVersion.argtype = ctypes.c_long self._wavemeterdll.GetWLMCount.restype = ctypes.c_long self._wavemeterdll.GetWLMCount.argtype = ctypes.c_long self._wavemeterdll.GetWavelengthNum.restype = ctypes.c_double self._wavemeterdll.GetWavelengthNum.argtypes = [ ctypes.c_long, ctypes.c_double ] self._wavemeterdll.GetFrequencyNum.restype = ctypes.c_double self._wavemeterdll.GetFrequencyNum.argtypes = [ ctypes.c_long, ctypes.c_double ] # Check that WLM is running and log details self._is_running = self._wavemeterdll.GetWLMCount(0) if self._is_running > 0: self._wlm_version = self._wavemeterdll.GetWLMVersion(0) self.log.info('Connected to High-Finesse Wavemeter WS-{0}'.format( self._wlm_version)) else: msg_str = 'High-Finesse WS7 Wavemeter software not running.\n' 'Please run the Wavemeter software and try again.' self.log.warn(msg_str)
def __init__(self, port, logger=None): """Instantiates serial connection to pressure gauge """ # Instantiate log self.log = LogHandler(logger=logger) ser = serial.Serial(port=port, baudrate=9600, timeout=1, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) self.sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser)) # Log initial pressure. init_pressure = self.get_pressure() self.log.info(f"Successfully reading {init_pressure} mBar.")
def __init__(self, tagger, click_ch, start_ch, logger=None): """Instantiate gated counter :param tagger: instance of TimeTagger class :param click_ch: (int|list of int) clicks on all specified channels will be summed into one logical channel :param start_ch: (int) start trigger channel number """ # Log self.log = LogHandler(logger=logger) # Reference to tagger self._tagger = tagger # Log device ID information to demonstrate that connection indeed works serial = self._tagger.getSerial() model = self._tagger.getModel() self.log.info( 'Got reference to Swabian Instruments TimeTagger device \n' 'Serial number: {0}, Model: {1}' ''.format(serial, model) ) # Gated Counter # reference to the TT.CountBetweenMarkers measurement instance self._ctr = None # number of count bins: # length of returned 1D count array, the size of allocated memory buffer. # must be given as argument of init_ctr() call self._bin_n = 0 # Channel assignments self._click_ch = 0 self._start_ch = 0 # reference to Combiner object # (if _click_ch is a list - then counts on all channels are summed # into virtual channel - self._combiner.getChannel()) self._combiner = None # apply channel assignment self.set_ch_assignment( click_ch=click_ch, start_ch=start_ch )
def __init__(self, ctr: si_tt.Client, log: LogClient, click_ch=1, start_ch=2, binwidth=1000, n_bins=1000, update_interval=0.5, correlation=False, **kwargs): """ Instantiates TimeTrace measurement :param ctr: (si_tt.Client) client to timetagger hardware :param log: (LogClient) instance of logclient for logging :param **kwargs: additional keyword arguments including :param click_ch: (int) channel receiving clicks :param start_ch: (int) channel for starting histogram :param binwidth: (int) width of bins in ps :param n_bins: (int) total number of bins for histogram :param update_interval: (float) interval in seconds to wait between updates Note, don't go too small (< 100 ms, not precisely tested yet), otherwise we might lag in jupyter notebook :param correlation: (bool) whether or not this is correlation meas TODO: in future, can implement multiple histograms if useful """ self.ctr = ctr self.log = LogHandler(log) # Store histogram parameters self.click_ch = click_ch self.start_ch = start_ch self.binwidth = binwidth self.n_bins = n_bins self.correlation = correlation if self.correlation: self.hist = f'correlation_{np.random.randint(1000)}' else: self.hist = f'histogram_{np.random.randint(1000)}' self.plot = None self.is_paused = False self.up_in = update_interval
def __init__(self, gpib_address, logger): """ Instantiate driver class, connects to device :param gpib_address: GPIB-address of the device, can be found with pyvisa.ResourceManager.list_resources() :param logger: instance of LogClient """ self.log = LogHandler(logger=logger) self.rm = ResourceManager() try: self.device = self.rm.open_resource(gpib_address) self.device.read_termination = '\n' self.device_id = self.device.query('*IDN?') self.log.info(f'Successfully connected to {self.device_id}') except VisaIOError: self.log.error(f'Connection to {gpib_address} failed') raise
def __init__(self, name, logger, hardware_client, hardware_type, config): '''High level staticline class. This class is used in conjunction with hardware modules to send out digital signals ('voltage low' and 'voltage high'). This top level class is hardware agnostic. With the use of a StaticLineHardwareHandler, this class will be associated with the necessary setup functions and output functions of a hardware module. :name:(str) A easily recognizable name for this staticline, ideally referring to the device being controlled by it, e.g. 'Shutter 1'. :logger: (object) An instance of a LogClient. :hardware_client: (object) An instance of a hardware Client. :hardware_type: (str) Name of the hardware to be controlled, naming is determined by the device server name. :config: (dict) Contains parameters needed to setup the hardware as a staticline. ''' self.name = name self.log = LogHandler(logger=logger) # Check that the provided class is a valid StaticLine class if hardware_type not in registered_staticline_modules: self.log.error( f"Setup of staticline using module {hardware_type} failed.\n" f"Compatible modules are: {registered_staticline_modules.keys()}" ) # Acquire the correct handler for the hardware type HardwareHandler = registered_staticline_modules[hardware_type] # Instantiate hardware handler. The hardware_handler will handle any # calls to the staticline functions like up/down. self.hardware_handler = HardwareHandler( name=name, log=self.log, hardware_client=hardware_client, config=config)
def __init__(self, dlc: toptica_dl_pro.Client, gui='toptica_control', logger=None, port=None): """ Initializes toptica specific parameters :param dlc: DLC client for the Toptica laser :param gui: .ui file to use :param logger: LogClient for logging purposes :param port: port number of script server """ self.log = LogHandler(logger) # Setup GUI self.gui = Window(gui_template=gui, host=get_ip(), port=port) self.widgets = get_gui_widgets(gui=self.gui, on_off=2, temperature=2, temperature_actual=2, current=2, current_actual=2, offset=2, amplitude=2, frequency=2, scan=2, update_temp=2, update_current=2, update_params=1) self.dlc = dlc self.offset = 65 self.amplitude = 100 self.scan = [False, False] self.emission = [False, False] # Setup stylesheet. self.gui.apply_stylesheet() self._setup_GUI()
def __init__(self, gui: Window, log: LogClient = None, data=None, x=None, graph=None, name=None, **kwargs): """ Instantiates an empty generic dataset :param gui: (Window) GUI window for data graphing :param log: (LogClient) :param data: initial data to set :param x: x axis :param graph: (pg.PlotWidget) graph to use """ self.log = LogHandler(log) if 'config' in kwargs: self.config = kwargs['config'] else: self.config = {} self.metadata = self.log.get_metadata() if name is None: self.name = self.__class__.__name__ else: self.name = name # Set data registers self.data = data self.x = x self.children = {} self.mapping = {} self.widgets = {} # Configure data visualization self.gui = gui self.visualize(graph, **kwargs) # Property which defines whether dataset is important, i.e. should it be saved in a separate dataset self.is_important = False
def __init__(self, channels, logger=None): """ Initializes connection to all TP Kasa smart plugs in the network. :channels: list of channels accessaable via this smart plug interface """ # Instantiate log. self.log = LogHandler(logger=logger) self.channels = channels # Discover smart plugs. self.found_devices = asyncio.run(Discover.discover()) # Store aliases of found devices. self.found_device_aliases = [ dev.alias for dev in self.found_devices.values() ] self.log.info( f"Discovered {len(self.found_device_aliases)} smart plugs.")
def __init__(self, gpib_address, logger): """Instantiate driver class. :gpib_address: GPIB-address of the device, e.g. 'COM8' Can ba found in the Windows device manager. :logger: And instance of a LogClient. """ # Instantiate log. self.log = LogHandler(logger=logger) self.rm = ResourceManager() try: self.device = self.rm.open_resource(gpib_address) self.device_id = self.device.query('*IDN?') self.log.info(f"Successfully connected to {self.device_id}.") except VisaIOError: self.log.error(f"Connection to {gpib_address} failed.") # Reset to factory settings. self.reset() # Read and store min and max power. self.power_min, self.power_max = [ float( self.device.query(f'pow? {string}') ) for string in ['min', 'max'] ] # Read and store min and max frequency. self.freq_min, self.freq_max = [ float( self.device.query(f'freq? {string}') ) for string in ['min', 'max'] ]
def __init__(self, filterwheel1, filterwheel2, gui='toptica_filterwheels', logger=None, port=None): self.filterwheel1 = filterwheel1 self.filterwheel2 = filterwheel2 self.log = LogHandler(logger) # Setup GUI self.gui = Window(gui_template=gui, host=get_ip(), port=port) # Get Widgets self.widgets = get_gui_widgets(self.gui, comboBox_filter1=1, comboBox_filter2=1, nd_label=1) # Retrieve filter dicts. filters1 = filterwheel1.get_filter_dict() filters2 = filterwheel2.get_filter_dict() # Fill comboboxes. self.widgets['comboBox_filter1'].addItems(filters1.values()) self.widgets['comboBox_filter2'].addItems(filters2.values()) # Get current fitler positions self.current_pos_1 = filterwheel1.get_pos() self.current_pos_2 = filterwheel2.get_pos() # Set comboboxes to current filter positions. self.widgets['comboBox_filter1'].setCurrentIndex( int(self.current_pos_1) - 1) self.widgets['comboBox_filter2'].setCurrentIndex( int(self.current_pos_2) - 1) # Connect change events self.widgets['comboBox_filter1'].currentTextChanged.connect( lambda: self.change_filter(filter_index=1)) self.widgets['comboBox_filter2'].currentTextChanged.connect( lambda: self.change_filter(filter_index=2)) # Update OD reading self.update_od() # Setup stylesheet. self.gui.apply_stylesheet()
def __init__(self, gpib_address=None, logger=None): """Instantiate driver class. :gpib_address: GPIB-address of the scope, e.g. 'GPIB0::12::INSTR' Can be read out by using rm = pyvisa.ResourceManager() rm.list_resources() :logger: An instance of a LogClient. """ # Instantiate log. self.log = LogHandler(logger=logger) self.rm = ResourceManager() try: self.device = self.rm.open_resource(gpib_address) device_id = self.device.query('*IDN?') self.log.info(f"Successfully connected to {device_id}.") # We set a more forgiving timeout of 10s (default: 2s). # self.device.timeout = 10000 except VisaIOError: self.log.error(f"Connection to {gpib_address} failed.")