Beispiel #1
0
def launch(**kwargs):
    """ Connects to TP Link HS103 Smart Plug

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :device_id: (int) Location of Smart plug (e.g. Powermeter Front Smart Plug)
    """

    logger=kwargs['logger']
    config = load_device_config('tp_link_hs103', kwargs['config'])
    smart_plug = Driver(
        logger=kwargs['logger'],
        channels=config['channels']
    )

    # Instantiate Server
    smart_plug_service = Service()
    smart_plug_service.assign_module(module=smart_plug)
    smart_plug_service.assign_logger(logger=kwargs['logger'])
    smart_plug_server = GenericServer(
        service=smart_plug_service,
        host=get_ip(),
        port=kwargs['port']
    )
    smart_plug_server.start()
Beispiel #2
0
def launch(**kwargs):
    """ Connects to ANC3000 and instantiates server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    device_config = load_device_config('anc300',
                                       kwargs['config'],
                                       logger=kwargs['logger'])
    telnet_config = device_config['telnet_config']

    anc300 = ANC300(host=telnet_config['host'],
                    port=telnet_config['port'],
                    query_delay=device_config['query_delay'],
                    passwd=telnet_config['passwd'],
                    limits=device_config['limits'],
                    logger=kwargs['logger'])

    anc300_service = Service()
    anc300_service.assign_module(module=anc300)
    anc300_service.assign_logger(logger=kwargs['logger'])
    anc300_server = GenericServer(service=anc300_service,
                                  host=get_ip(),
                                  port=kwargs['port'])
    anc300_server.start()
Beispiel #3
0
def launch(**kwargs):
    """ Connects to NI-daqMX card and launches server
    Identical to nidaqmx, except uses "device_ai" in the config file as the device name

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    # Instantiate driver
    logger = kwargs['logger']
    config = kwargs['config']
    config = load_device_config('agc_100', config, logger=kwargs['logger'])

    port_name = config['device_id']
    agc = AGC_100(port=port_name, logger=logger)

    agc_service = Service()
    agc_service.assign_module(module=agc)
    agc_service.assign_logger(logger=logger)
    agc__server = GenericServer(
        service=agc_service,
        host=get_ip(),
        port=kwargs['port']
    )

    agc__server.start()
Beispiel #4
0
def launch(**kwargs):
    """ Connects to a NI DAQ as staticline

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    staticline_logger = kwargs['logger']

    # Instantiate HDAWG driver.
    hd = zi_hdawg.Driver(dev_id, logger=staticline_logger)

    aom = staticline.Driver(
        name='AOM',
        logger=staticline_logger,
        hardware_module=hd,
        DIO_bit=30,
    )

    # Instantiate Server
    # Staticline server
    staticline_service = Service()
    staticline_service.assign_module(module=aom)
    staticline_service.assign_logger(logger=staticline_logger)
    staticline_service_server = GenericServer(service=staticline_service,
                                              host=get_ip(),
                                              port=kwargs['port'])

    staticline_service_server.start()
Beispiel #5
0
def launch(**kwargs):
    """ Connects to Tektronix TDS2004C oscilloscope and launches server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    # Instantiate driver
    tektronix_logger = kwargs['logger']
    tektronix_driver = tektronix_tds2004C.Driver(
        gpib_address=kwargs['device_id'],
        logger=tektronix_logger
    )
    

    # Instantiate server
    tektronix_service = Service()
    tektronix_service.assign_module(module=tektronix_driver)
    tektronix_service.assign_logger(logger=tektronix_logger)
    tektronix_server = GenericServer(
        service=tektronix_service,
        host=get_ip(),
        port=kwargs['port']
    )

    tektronix_server.start()
Beispiel #6
0
def launch(**kwargs):
    """ Connects to NI-daqMX card and launches server
    Identical to nidaqmx, except uses "device_ai" in the config file as the device name

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    # Instantiate driver
    logger = kwargs['logger']
    config = kwargs['config']
    config = load_device_config('fw102c', config, logger=kwargs['logger'])

    device_name = config['device_name']
    port_name = config['device_id']
    filters = config['filters']
    filters = {f'{i+1}': f'{filters[i]} OD' for i in range(len(filters))}
    filterwheel = FW102CFilterWheel(port_name=port_name,
                                    device_name=device_name,
                                    filters=filters,
                                    logger=logger)

    filterwheel_service = Service()
    filterwheel_service.assign_module(module=filterwheel)
    filterwheel_service.assign_logger(logger=logger)
    filterwheel_service_server = GenericServer(service=filterwheel_service,
                                               host=get_ip(),
                                               port=kwargs['port'])

    filterwheel_service_server.start()
def launch(**kwargs):
    """ Connects to a NI DAQ as staticline

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    staticline_logger = kwargs['logger']
    daq = nidaqmx.Driver(device_name=NI_DEVICE_NAME, logger=staticline_logger)

    test_staticline = staticline.Driver(
        name='Green Imaging Laser',
        logger=kwargs['logger'],
        hardware_module=daq,
        ao_output='ao2',
        down_voltage=0,
        up_voltage=3.3,
    )

    # Instantiate Server
    # Staticline server
    staticline_service = Service()
    staticline_service.assign_module(module=test_staticline)
    staticline_service.assign_logger(logger=staticline_logger)
    staticline_service_server = GenericServer(service=staticline_service,
                                              host=get_ip(),
                                              port=kwargs['port'])

    staticline_service_server.start()
def launch(**kwargs):
    """ Launches the WLM monitor + lock script """

    logger = kwargs['logger']
    clients = kwargs['clients']

    config = load_script_config(script='laser_stabilizer',
                                config=kwargs['config'],
                                logger=logger)
    for server in config['servers']:

        if 'name' in server:
            if server['name'] == 'input':
                ai_client = find_client(clients=clients,
                                        settings=config,
                                        client_type=server['type'],
                                        client_config=server['config'],
                                        logger=logger)
            if server['name'] == 'output':
                ao_client = find_client(clients=clients,
                                        settings=config,
                                        client_type=server['type'],
                                        client_config=server['config'],
                                        logger=logger)

        if server['type'] == 'zi_hdawg':
            hd = find_client(clients=clients,
                             settings=config,
                             client_type='zi_hdawg',
                             client_config=server['config'],
                             logger=logger)

    if config['check_aom'] == "True":
        check_aom = True
    else:
        check_aom = False

    # Instantiate Monitor script
    laser_stabilizer = LaserStabilizer(config=config,
                                       ao_client=ao_client,
                                       ai_client=ai_client,
                                       hd=hd,
                                       check_aom=check_aom,
                                       logger=logger)

    update_service = Service()
    update_service.assign_module(module=laser_stabilizer)
    update_service.assign_logger(logger=logger)
    update_server, update_port = create_server(update_service,
                                               logger,
                                               host=get_ip())
    logger.update_data(data={'port': update_port})
    laser_stabilizer.gui.set_network_info(port=update_port)
    update_server.start()

    # Run continuously
    # Note that the actual operation inside run() can be paused using the update server
    while True:

        laser_stabilizer.run()
Beispiel #9
0
    def __init__(self,
                 ctr_client: si_tt.Client,
                 ui='count_monitor',
                 logger_client=None,
                 server_port=None,
                 combined_channel=False,
                 config=None):
        """ Constructor for CountMonitor script

        :param ctr_client: instance of hardware client for counter
        :param gui_client: (optional) instance of client of desired output GUI
        :param logger_client: (obj) instance of logger client.
        :param server_port: (int) port number of script server
        :combined_channel: (bool) If true, show additional trace with summed counts.
        """

        self._ctr = ctr_client
        self.log = logger_client
        self.combined_channel = combined_channel
        self._bin_width = None
        self._n_bins = None
        self._ch_list = None
        self._plot_list = None  # List of channels to assign to each plot (e.g. [[1,2], [3,4]])
        self._plots_assigned = [
        ]  # List of plots on the GUI that have been assigned

        if self.combined_channel:
            ui = 'count_monitor_combined'
        else:
            ui = 'count_monitor'

        # Instantiate GUI window
        self.gui = Window(gui_template=ui, host=get_ip(), port=server_port)

        # Setup stylesheet.
        self.gui.apply_stylesheet()

        if self.combined_channel:
            num_plots = 3
        else:
            num_plots = 2

        # Get all GUI widgets
        self.widgets = get_gui_widgets(self.gui,
                                       graph_widget=num_plots,
                                       number_label=8,
                                       event_button=num_plots,
                                       legend_widget=num_plots)

        # Load config
        self.config = {}
        if config is not None:
            self.config = load_script_config(script='monitor_counts',
                                             config=config,
                                             logger=self.logger_client)

        if not 'name' in self.config:
            self.config.update({'name': f'monitor{np.random.randint(1000)}'})
Beispiel #10
0
    def start_logger(self):
        """ Starts the log server """

        self.log_service = LogService()
        if self.LOG_PORT is None and not self.master:
            self.log_server, self.log_port = create_server(self.log_service,
                                                           host=get_ip())
        else:
            try:
                self.log_server = GenericServer(service=self.log_service,
                                                host=get_ip(),
                                                port=self.log_port)
            except ConnectionRefusedError:
                print(
                    f'Failed to insantiate Log Server at port {self.LOG_PORT}')
                raise
        self.log_server.start()

        self.log_service.logger.info('log service succesfully started')
    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)
Beispiel #12
0
def launch(**kwargs):
    """ Connects to SI TT and instantiates server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    if not IMPORT_STATUS:
        msg_str = 'Please make sure Swabian Instruments drivers are installed on this machine.'
        raise ModuleNotFoundError(msg_str)

    TT.setTimeTaggerChannelNumberScheme(TT.TT_CHANNEL_NUMBER_SCHEME_ONE)

    # Connect to the device, otherwise instantiate virtual connection
    try:
        tagger = TT.createTimeTagger()
    except RuntimeError:
        kwargs['logger'].warn('Failed to connect to Swabian Instruments Time Tagger.'
                              ' Instantiating virtual device instead')
        tagger = TT.createTimeTaggerVirtual()

    try:
        config = kwargs['config']
        config = load_device_config('si_tt', config, logger=kwargs['logger'])
    except:
        config = None

    # if config is None:
    #     try:
    #         config = load_device_config('si_tt', logger=kwargs['logger'])
    #     except:
    #         config = {}

    for channel, trig_level in config['triggers'].items():
        tagger.setTriggerLevel(int(channel), float(trig_level))

    cnt_trace_wrap = Wrap(
        tagger=tagger,
        logger=kwargs['logger']
    )

    # Instantiate Server
    cnt_trace_service = Service()
    cnt_trace_service.assign_module(module=cnt_trace_wrap)
    cnt_trace_service.assign_logger(logger=kwargs['logger'])
    cnt_trace_server = GenericServer(
        service=cnt_trace_service,
        host=get_ip(),
        port=kwargs['port']
    )
    cnt_trace_server.start()
Beispiel #13
0
    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()
Beispiel #14
0
def launch(**kwargs):

    config_dict = load_device_config('agilent_83732b', kwargs['config'])
    logger = kwargs['logger']
    ag = Driver(config_dict['device_id'], logger)

    ag_service = Service()
    ag_service.assign_module(module=ag)
    ag_service.assign_logger(logger=kwargs['logger'])
    ag_server = GenericServer(service=ag_service,
                              host=get_ip(),
                              port=kwargs['port'])
    ag_server.start()
    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()
Beispiel #16
0
def launch(**kwargs):
    """ Connects to MCS2 and instantiates server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    mcs2 = MCS2(logger=kwargs['logger'])
    mcs2_service = Service()
    mcs2_service.assign_module(module=mcs2)
    mcs2_service.assign_logger(logger=kwargs['logger'])
    mcs2_server = GenericServer(service=mcs2_service,
                                host=get_ip(),
                                port=kwargs['port'])
    mcs2_server.start()
Beispiel #17
0
def launch(**kwargs):
    """ Launches a dummy hardware driver and instantiates server """

    log = kwargs['logger']
    log.info(f'Launching with config {kwargs["config"]}')
    config = load_device_config(
        os.path.basename(__file__)[:-3], kwargs['config'], log)

    dum = Dummy()
    log.info(f'Created dummy object with configuration parameters {config}')
    dum_service = ServiceBase()
    dum_service.assign_module(module=dum)
    dum_service.assign_logger(logger=log)
    dum_server = GenericServer(service=dum_service,
                               host=get_ip(),
                               port=kwargs['port'])
    dum_server.start()
Beispiel #18
0
def launch(**kwargs):
    """Launches the script."""

    logger = kwargs['logger']
    clients = kwargs['clients']

    try:
        staticline_gui = StaticLineGUIGeneric(
            config=kwargs['config'],
            staticline_clients=clients,
            logger_client=logger,
            host=get_ip(),
            port=kwargs['server_port']
        )
    except KeyError:
        logger.error('Please make sure the module names for required servers and GUIS are correct.')

    staticline_gui.run()
Beispiel #19
0
def launch(**kwargs):
    """ Connects to NI-daqMX card and launches server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    # Instantiate driver
    ni_daqmx_logger = kwargs['logger']
    try:
        ni_driver = nidaqmx_card.Driver(
            device_name=kwargs['device_id'],
            logger=ni_daqmx_logger
        )
    except AttributeError:
        try:
            config = load_config(kwargs['config'])
            ni_driver = nidaqmx_card.Driver(
                device_name=config['device'],
                logger=ni_daqmx_logger
            )
        except AttributeError:
            ni_daqmx_logger.error('Please provide valid config file')
            raise
        except OSError:
            ni_daqmx_logger.error(f'Did not find NI daqMX name {config["device"]}')
            raise
        except KeyError:
            ni_daqmx_logger.error('No device name provided. '
                                'Please make sure proper config file is provided')
            raise

    # Instantiate server
    ni_daqmx_service = Service()
    ni_daqmx_service.assign_module(module=ni_driver)
    ni_daqmx_service.assign_logger(logger=ni_daqmx_logger)
    ni_daqmx_server = GenericServer(
        service=ni_daqmx_service,
        host=get_ip(),
        port=kwargs['port']
    )

    ni_daqmx_server.start()
Beispiel #20
0
def launch(**kwargs):

    # Instantiate driver
    zi_logger = kwargs['logger']

    device_id = load_device_config('zi_hdawg',
                                   kwargs['config'],
                                   logger=kwargs['logger'])['device_id']
    hd = Driver(device_id, zi_logger)

    # Instantiate server
    hd_service = Service()
    hd_service.assign_module(module=hd)
    hd_service.assign_logger(logger=zi_logger)
    hd_server = GenericServer(service=hd_service,
                              host=get_ip(),
                              port=kwargs['port'])

    hd_server.start()
Beispiel #21
0
    def _launch_script_server(self):
        """ Launches a GenericServer attached to this script to enable closing
        """

        if 'script_service' in self.config_dict and self.config_dict[
                'script_service'] == 'True':
            spec = importlib.util.spec_from_file_location(
                self.name, self.config_dict['script'])
            mod = importlib.util.module_from_spec(spec)
            spec.loader.exec_module(mod)
            self.service = mod.Service()
        else:
            self.service = ServiceBase()
        self.service.assign_logger(logger=self.logger)

        self.script_server, self.script_server_port = create_server(
            service=self.service, logger=self.logger, host=get_ip())
        self.script_server.start()

        self.logger.update_data(data=dict(port=self.script_server_port))
Beispiel #22
0
def launch(**kwargs):
    """ Connects to HWC T2220 (microwave source) and instantiates server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Hittite server
    """
    config = kwargs['config']
    config = load_device_config('HMC_T2220', config, logger=kwargs['logger'])
    mw_source = ht.Driver(logger=kwargs['logger'],
                          gpib_address=config['device_id'])

    # Instantiate Server
    mw_service = Service()
    mw_service.assign_module(module=mw_source)
    mw_service.assign_logger(logger=kwargs['logger'])
    mw_server = GenericServer(service=mw_service,
                              host=get_ip(),
                              port=kwargs['port'])
    mw_server.start()
Beispiel #23
0
    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()
Beispiel #24
0
def launch(**kwargs):
    """ Launches the sweeper GUI """

    # logger, loghost, logport, clients, guis, params = unpack_launcher(**kwargs)

    logger = kwargs['logger']
    clients = kwargs['clients']
    config = load_script_config(
        'histogram',
        kwargs['config'],
        logger
    )

    ctr = find_client(
        clients,
        config,
        client_type='si_tt',
        client_config='standard_ctr',
        logger=logger
    )

    # Instantiate Monitor script
    trace = TimeTraceGui(
        ctr=ctr,
        log=logger,
        config=config,
    )

    update_service = Service()
    update_service.assign_module(module=trace)
    update_service.assign_logger(logger=logger)
    update_server, update_port = create_server(update_service, logger, host=get_ip())
    logger.update_data(data={'port': update_port})
    trace.gui.set_network_info(port=update_port)
    update_server.start()

    # Run continuously
    # Note that the actual operation inside run() can be paused using the update server
    while True:

        trace.gui.force_update()
Beispiel #25
0
def launch(**kwargs):
    """ Connects to MPC320 instantiates server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    settings = load_device_config('thorlabs_mpc320',
                                  kwargs['config'],
                                  logger=kwargs['logger'])

    dev_num = settings['device_id']

    pol_paddle = Driver(device_num=int(dev_num), logger=kwargs['logger'])

    pol_paddle_service = Service()
    pol_paddle_service.assign_module(module=pol_paddle)
    pol_paddle_service.assign_logger(logger=kwargs['logger'])
    pol_paddle_service_server = GenericServer(service=pol_paddle_service,
                                              host=get_ip(),
                                              port=kwargs['port'])
    pol_paddle_service_server.start()
Beispiel #26
0
def launch(**kwargs):
    """ Connects to HF WS7 Wavemeter and launches server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    # Instantiate Logger
    wavemeter_logger = kwargs['logger']

    # Instantiate Wavemeter object
    hf_wlm = Driver(logger=wavemeter_logger)

    # Instantiate Server
    wavemeter_service = Service()
    wavemeter_service.assign_module(module=hf_wlm)
    wavemeter_service.assign_logger(logger=wavemeter_logger)
    wavemeter_server = GenericServer(service=wavemeter_service,
                                     host=get_ip(),
                                     port=kwargs['port'])

    wavemeter_server.start()
Beispiel #27
0
def launch(**kwargs):
    """ Connects to DIO breakout and instantiates server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the DIO breakout server
        :config: (str) name of config file to us
    """

    device_config = load_device_config('dio_breakout',
                                       kwargs['config'],
                                       logger=kwargs['logger'])

    # Try to load settings
    if 'resource_name' in device_config:
        addr = device_config['resource_name']
    else:
        addr = device_config['device_id']

    # Try to connect
    try:
        dio = Driver(address=addr, logger=kwargs['logger'])

    # If it fails, prompt the user to enter GPIB address from resource list
    except VisaIOError:
        kwargs['logger'].error(
            f'Failed to connect to device at address {addr}')
        raise

    # Instantiate Service and server
    dio_service = Service()
    dio_service.assign_module(module=dio)
    dio_service.assign_logger(logger=kwargs['logger'])
    dio_server = GenericServer(service=dio_service,
                               host=get_ip(),
                               port=kwargs['port'])
    dio_server.start()
Beispiel #28
0
def launch(**kwargs):
    """ Connects to PM320E and instantiates server

    :param kwargs: (dict) containing relevant kwargs
        :logger: instance of LogClient for logging purposes
        :port: (int) port number for the Cnt Monitor server
    """

    try:
        settings = load_device_config('thorlabs_pm320e',
                                      kwargs['config'],
                                      logger=kwargs['logger'])
    except KeyError:
        kwargs['logger'].warn('No config file was provided')

    try:
        pm = Driver(
            logger=kwargs['logger'],
            gpib_address=settings['device_id'],
        )

    # Handle error of wrong GPIB address by allowing user to select
    # NOTE: this will fail if used from the main script launcher, since script client
    # will automatically try to connect (even though server isn't launched)
    #
    # TLDR: if you want to use launch-control, please fill in GPIB variable with
    # the correct resource string
    except:
        kwargs['logger'].error('Please check GPIB address, could not connect')

    pm_service = Service()
    pm_service.assign_module(module=pm)
    pm_service.assign_logger(logger=kwargs['logger'])
    pm_server = GenericServer(service=pm_service,
                              host=get_ip(),
                              port=kwargs['port'])
    pm_server.start()
Beispiel #29
0
    def __init__(self,
                 pm_client,
                 gui='fiber_coupling',
                 logger=None,
                 calibration=None,
                 name=None,
                 port=None):
        """ Instantiates a monitor for 2-ch power meter with GUI

        :param pm_clients: (client, list of clients) clients of power meter
        :param gui_client: client of monitor GUI
        :param logger: instance of LogClient
        :calibration: (float) Calibration value for power meter.
        :name: (str) Humand-readable name of the power meter.
        """

        self.log = LogHandler(logger)
        self.gui = Window(gui_template=gui, host=get_ip(), port=port)

        self.gui.apply_stylesheet()
        self.wavelength = []
        self.calibration = calibration
        self.name = name
        self.ir_index, self.rr_index = [], []
        self.pm = pm_client
        self.running = False
        self.num_plots = 3

        # Get all GUI widgets
        self.widgets = get_gui_widgets(self.gui,
                                       graph_widget=self.num_plots,
                                       number_widget=4,
                                       label_widget=2,
                                       name_label=1,
                                       combo_widget=2)

        self._initialize_gui()
Beispiel #30
0
def launch(**kwargs):
    """ Connects to toptica laser and launches server

    :param kwargs: (dict) containing relevant kwargs
    """

    # Instantiate driver
    toptica_logger = kwargs['logger']
    config = load_device_config('toptica_dlc_pro', kwargs['config'],
                                toptica_logger)

    dlc = DLC_Pro(host=config['host'],
                  port=int(config['port']),
                  logger=toptica_logger)

    # Instantiate server
    dlc_service = Service()
    dlc_service.assign_module(module=dlc)
    dlc_service.assign_logger(logger=toptica_logger)
    dlc_server = GenericServer(service=dlc_service,
                               host=get_ip(),
                               port=kwargs['port'])

    dlc_server.start()