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): """ 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()
def initialize_drivers(self, staticline_clients, logger_client): # Dictionary storing {device name : dict of staticline Drivers} self.staticlines = {} for device_name, device_params in self.config_dict['lines'].items(): # If the device name is duplicated, we ignore this hardware client. if device_name in self.staticlines: self.log.error( f"Device name {device_name} has been matched to multiple hardware clients." "Subsequent matched hardware clients are ignored.") continue # Create a dict to store the staticlines for this device else: self.staticlines[device_name] = dict() hardware_type = device_params['hardware_type'] hardware_config = device_params['config_name'] #Try to find if we have a matching device client in staticline_clients try: hardware_client = find_client(staticline_clients, self.config_dict, hardware_type, hardware_config, logger_client) except NameError: logger_client.error( 'No staticline device found for device name: ' + device_name) # Iterate over all staticlines for that device and create a # driver instance for each line. for staticline_idx in range(len( device_params["staticline_names"])): staticline_name = device_params["staticline_names"][ staticline_idx] # Store the staticline driver under the specified device name self.staticlines[device_name][ staticline_name] = staticline.Driver( name=device_name + "_" + staticline_name, logger=logger_client, hardware_client=hardware_client, hardware_type=hardware_type, config=device_params["staticline_configs"] [staticline_idx]) #If it has an initial default value, set that initially using set_value command if "default" in device_params["staticline_configs"][ staticline_idx]: defaultValue = device_params["staticline_configs"][ staticline_idx]["default"] sl_type = device_params["staticline_configs"][ staticline_idx]['type'] if (sl_type == 'analog'): self.staticlines[device_name][ staticline_name].set_value(defaultValue) elif (sl_type == 'adjustable_digital'): self.staticlines[device_name][ staticline_name].set_dig_value(defaultValue)