def __init__(self, name, parent, BLACS_connection='dummy_connection', **kwargs): self.BLACS_connection = BLACS_connection IntermediateDevice.__init__(self, name, parent, **kwargs)
def __init__(self, name, parent_device, addr=None, port=7802, **kwargs): IntermediateDevice.__init__(self, name, parent_device, **kwargs) # # Get a device objsect # dev = MOGDevice(addr, port) # # print 'Device info:', dev.ask('info') self.BLACS_connection = '%s,%s' % (addr, str(port))
def __init__(self, name, parent_device, server='192.168.1.100', port=21845): IntermediateDevice.__init__(self, name, parent_device) self.BLACS_connection = '%s:%d' % (server, port)
def __init__(self, name, parent_device, com_port="", baud_rate=115200, default_baud_rate=None, update_mode='synchronous', synchronous_first_line_repeat=False, phase_mode='continuous', **kwargs): IntermediateDevice.__init__(self, name, parent_device, **kwargs) self.BLACS_connection = '%s,%s' % (com_port, str(baud_rate)) if not update_mode in ['synchronous', 'asynchronous']: raise LabscriptError( 'update_mode must be \'synchronous\' or \'asynchronous\'') if not baud_rate in bauds: raise LabscriptError('baud_rate must be one of {0}'.format( list(bauds))) if not default_baud_rate in bauds and default_baud_rate is not None: raise LabscriptError( 'default_baud_rate must be one of {0} or None (to indicate no default)' .format(list(bauds))) if not phase_mode in ['aligned', 'continuous']: raise LabscriptError( 'phase_mode must be \'aligned\' or \'continuous\'') self.update_mode = update_mode self.phase_mode = phase_mode self.synchronous_first_line_repeat = synchronous_first_line_repeat
def __init__(self, name, parent_device, addr=None, port=7802, **kwargs): IntermediateDevice.__init__(self, name, parent_device, **kwargs) # # Get a device objsect # dev = MOGDevice(addr, port) # # print 'Device info:', dev.ask('info') self.BLACS_connection = '%s,%s'%(addr, str(port))
def __init__(self, name, parent_device, com_port): IntermediateDevice.__init__(self, name, parent_device) self.BLACS_connection = com_port p=64 b=1080 a=62 r=805 self._scale = (p*b + a)/r
def __init__(self, name, parent_device, clock_terminal, MAX_name=None, acquisition_rate=0): IntermediateDevice.__init__(self, name, parent_device) self.acquisition_rate = acquisition_rate self.clock_terminal = clock_terminal self.MAX_name = name if MAX_name is None else MAX_name self.BLACS_connection = self.MAX_name
def __init__(self, name, parent_device, clock_terminal=None, MAX_name=None, sample_rate_AI=0, **kwargs): IntermediateDevice.__init__(self, name, parent_device, **kwargs) self.sample_rate_AI = sample_rate_AI self.clock_terminal = clock_terminal self.MAX_name = name if MAX_name is None else MAX_name self.BLACS_connection = self.MAX_name # Now these are just defined at __init__ time self.num_AO = 4 self.num_DO = 32 self.dtype_DO = np.uint32 self.clock_limit = 500e3
def __init__( self, name, parent_device, clock_terminal, BoardNum=0, sync="slave", ): IntermediateDevice.__init__(self, name, parent_device) self.name = name self.clock_terminal = clock_terminal self.BLACS_connection = self.name self.sync = sync self.BoardNum = BoardNum
def __init__(self,name,parent_device,com_port='COM1',FMSignal=None,RFOnOff=None,freq_limits = None,freq_conv_class = None,freq_conv_params = {},amp_limits=None,amp_conv_class = None,amp_conv_params = {},phase_limits=None,phase_conv_class = None,phase_conv_params = {}): #self.clock_type = parent_device.clock_type # Don't see that this is needed anymore IntermediateDevice.__init__(self,name,parent_device) self.BLACS_connection = com_port self.sweep_dt = 2e-6 self.RFSettings = { 'freq': 0, 'amp': 0, 'phase': 0, 'freq_dev':0 ##EE } self.sweep_params = { # 'type': None, 'low': 0, 'high': 1, 'duration': 0, # 'falltime': 0, 'sample_rate': self.sweep_dt } self.sweep = False self.ext_in = False self.frequency = StaticAnalogQuantity(self.name+'_freq',self,'freq',freq_limits,freq_conv_class,freq_conv_params) self.amplitude = StaticAnalogQuantity(self.name+'_amp',self,'amp',amp_limits,amp_conv_class,amp_conv_params) self.phase = StaticAnalogQuantity(self.name+'_phase',self,'phase',phase_limits,phase_conv_class,phase_conv_params) self.FMSignal = {} self.RFOnOff = {} if FMSignal: if 'device' in FMSignal and 'connection' in FMSignal: self.FMSignal = AnalogOut(self.name+'_FMSignal', FMSignal['device'], FMSignal['connection']) else: raise LabscriptError('You must specify the "device" and "connection" for the analog output FMSignal of '+self.name) else: raise LabscriptError('Expected analog output for "FMSignal" control') if RFOnOff: if 'device' in RFOnOff and 'connection' in RFOnOff: self.RFOnOff = DigitalOut(self.name+'_RFOnOff', RFOnOff['device'], RFOnOff['connection']) else: raise LabscriptError('You must specify the "device" and "connection" for the digital output RFOnOff of '+self.name) else: raise LabscriptError('Expected digital output for "RFOnOff" control')
def __init__(self, name, parent_device, com_port="", baud_rate=115200, update_mode='synchronous', **kwargs): IntermediateDevice.__init__(self, name, parent_device, **kwargs) self.BLACS_connection = '%s,%s' % (com_port, str(baud_rate)) if not update_mode in ['synchronous', 'asynchronous']: raise LabscriptError( 'update_mode must be \'synchronous\' or \'asynchronous\'') self.update_mode = update_mode
def __init__(self, name, parent_device, com_port = "", baud_rate=115200, update_mode='synchronous', synchronous_first_line_repeat=False, phase_mode='default', **kwargs): IntermediateDevice.__init__(self, name, parent_device, **kwargs) self.BLACS_connection = '%s,%s'%(com_port, str(baud_rate)) if not update_mode in ['synchronous', 'asynchronous']: raise LabscriptError('update_mode must be \'synchronous\' or \'asynchronous\'') if not phase_mode in ['default', 'aligned', 'continuous']: raise LabscriptError('phase_mode must be \'default\', \'aligned\' or \'continuous\'') self.update_mode = update_mode self.phase_mode = phase_mode self.synchronous_first_line_repeat = synchronous_first_line_repeat
def __init__(self, name, parent_device, com_port = "", baud_rate=115200, default_baud_rate=0, update_mode='synchronous', synchronous_first_line_repeat=False, **kwargs): IntermediateDevice.__init__(self, name, parent_device, **kwargs) self.BLACS_connection = '%s,%s'%(com_port, str(baud_rate)) if not update_mode in ['synchronous', 'asynchronous']: raise LabscriptError('update_mode must be \'synchronous\' or \'asynchronous\'') if not baud_rate in bauds: raise LabscriptError('baud_rate must be one of {0}'.format(bauds.keys())) if not default_baud_rate in bauds and default_baud_rate != 0: raise LabscriptError('default_baud_rate must be one of {0} or 0 (to indicate no default)'.format(bauds.keys())) self.update_mode = update_mode self.synchronous_first_line_repeat = synchronous_first_line_repeat
def __init__(self, name, parent_device, visa_resource="ASRL4::INSTR", **kwargs): IntermediateDevice.__init__(self, name, parent_device, **kwargs) self.BLACS_connection = visa_resource self.wireamps = [] #wireamps is a list of AnalogQuantity objects? for i in range(self.NUM_WIRES): self.wireamps.append(AnalogQuantity("%s_wire%02damp" % (self.name, i), self, 'wire%02damp' % i)) self.groupphases = [] for i in range(self.NUM_WIRE_GROUPS): self.groupphases.append(AnalogQuantity("%s_group%02dphase" % (self.name, i), self, 'group%02dphase' % i)) self.groupfreqs = [] for i in range(self.NUM_WIRE_GROUPS): self.groupfreqs.append(AnalogQuantity("%s_group%02dfreq" % (self.name, i), self, 'group%02dfreq' % i, unit_conversion_class=NovaTechDDS9mFreqConversion)) self.control_bytes = {} self.visa_resource = visa_resource
def __init__(self, name, parent_device, com_port="", baud_rate=19200, update_mode='synchronous', synchronous_first_line_repeat=False, phase_mode='continuous', ext_clk=False, clk_freq=None, clk_mult=None, R_option=False, **kwargs): '''Labscript device class for NovaTech 409B-AC variant DDS. This device has two dynamic channels (0,1) and two static channels (2,3). If an external clock frequency is enabled, and /R option is not being used, clk_freq (in MHz) and clk_mult (int) must also be defined.''' IntermediateDevice.__init__(self, name, parent_device, **kwargs) self.BLACS_connection = '%s,%s' % (com_port, str(baud_rate)) if not update_mode in ['synchronous', 'asynchronous']: raise LabscriptError( 'update_mode must be \'synchronous\' or \'asynchronous\'') if not phase_mode in ['aligned', 'continuous']: raise LabscriptError( 'phase_mode must be \'aligned\' or \'continuous\'') self.update_mode = update_mode self.phase_mode = phase_mode self.synchronous_first_line_repeat = synchronous_first_line_repeat self.ext_clk = ext_clk self.clk_freq = clk_freq self.R_option = R_option self.clk_mult = clk_mult # validate clocking parameters and get frequency scaling factor self.clk_scale = self.clock_check() # save dds reference frequency, defined as clk_freq*clk_mult self.set_property('reference_frequency', self.ref_freq, location='device_properties')
def __init__(self, name, com_port="COM1", mock=False, **kwargs): """Device for controlling a number of Zaber stages connected to a serial port. Add stages as child devices, either by using one of them model-specific classes in this module, or the generic `ZaberStage` class. Args: name (str) device name com_port (str), default: `'COM1'` Serial port for communication, i.e. `'COM1' etc on Windows or `'/dev/USBtty0'` or similar on unix. mock (bool, optional), default: False For testing purpses, simulate a device instead of communicating with actual hardware. **kwargs: Further keyword arguments to be passed to the `__init__` method of the parent class (IntermediateDevice). """ IntermediateDevice.__init__(self, name, None, **kwargs) self.BLACS_connection = com_port
def __init__(self, name, parent_device=None, clock_terminal=None, MAX_name=None, static_AO=None, static_DO=None, clock_mirror_terminal=None, acquisition_rate=None, AI_range=None, AI_range_Diff=None, AI_start_delay=0, AI_start_delay_ticks=None, AI_term='RSE', AI_term_cfg=None, AO_range=None, max_AI_multi_chan_rate=None, max_AI_single_chan_rate=None, max_AO_sample_rate=None, max_DO_sample_rate=None, min_semiperiod_measurement=None, num_AI=0, num_AO=0, num_CI=0, ports=None, supports_buffered_AO=False, supports_buffered_DO=False, supports_semiperiod_measurement=False, supports_simultaneous_AI_sampling=False, **kwargs): """Generic class for NI_DAQmx devices. Generally over-ridden by device-specific subclasses that contain the introspected default values. Args: name (str): name to assign to the created labscript device parent_device (clockline): Parent clockline device that will clock the outputs of this device clock_terminal (str): What input on the DAQ is used for the clockline MAX_name (str): NI-MAX device name static_AO (int, optional): Number of static analog output channels. static_DO (int, optional): Number of static digital output channels. clock_mirror_terminal (str, optional): Channel string of digital output that mirrors the input clock. Useful for daisy-chaning DAQs on the same clockline. acquisiton_rate (float, optional): Default sample rate of inputs. AI_range (iterable, optional): A `[Vmin, Vmax]` pair that sets the analog input voltage range for all analog inputs. AI_range_Diff (iterable, optional): A `[Vmin, Vmax]` pair that sets the analog input voltage range for all analog inputs when using Differential termination. AI_start_delay (float, optional): Time in seconds between start of an analog input task starting and the first sample. AI_start_delay_ticks (int, optional): Time in sample clock periods between start of an analog input task starting and the first sample. To use this method, `AI_start_delay` must be set to `None`. This is necessary for DAQs that employ delta ADCs. AI_term (str, optional): Configures the analog input termination for all analog inputs. Must be supported by the device. Supported options are `'RSE'`, `'NRSE'` `'Diff'`, and '`PseudoDiff'`. AI_term_cfg (dict, optional): Dictionary of analog input channels and their supported terminations. Best to use `get_capabilities.py` to introspect these. AO_range (iterable, optional): A `[Vmin, Vmax]` pair that sets the analog output voltage range for all analog outputs. max_AI_multi_chan_rate (float, optional): Max supported analog input sampling rate when using multiple channels. max_AI_single_chan_rate (float, optional): Max supported analog input sampling rate when only using a single channel. max_AO_sample_rate (float, optional): Max supported analog output sample rate. max_DO_sample_rate (float, optional): Max supported digital output sample rate. min_sermiperiod_measurement (float, optional): Minimum measurable time for a semiperiod measurement. num_AI (int, optional): Number of analog inputs channels. num_AO (int, optional): Number of analog output channels. num_CI (int, optional): Number of counter input channels. ports (dict, optional): Dictionarly of DIO ports, which number of lines and whether port supports buffered output. supports_buffered_AO (bool, optional): True if analog outputs support buffered output supports_buffered_DO (bool, optional): True if digital outputs support buffered output supports_semiperiod_measurement (bool, optional): True if device supports semi-period measurements """ # Default static output setting based on whether the device supports buffered # output: if static_AO is None: static_AO = not supports_buffered_AO if static_DO is None: static_DO = not supports_buffered_DO # Parent is only allowed to be None if output is static: if parent_device is None and not (static_DO and static_AO): msg = """Must specify a parent clockline, unless both static_AO and static_DO are True""" raise LabscriptError(dedent(msg)) # If parent device is not None though, then clock terminal must be specified: if parent_device is not None and clock_terminal is None: msg = """If parent_device is given, then clock_terminal must be specified as well as the terminal to which the parent pseudoclock is connected.""" raise ValueError(dedent(msg)) if acquisition_rate is not None and num_AI == 0: msg = "Cannot set set acquisition rate on device with no analog inputs" raise ValueError(msg) # Acquisition rate cannot be larger than the single channel rate: if acquisition_rate is not None and acquisition_rate > max_AI_single_chan_rate: msg = """acquisition_rate %f is larger than the maximum single-channel rate %f for this device""" raise ValueError( dedent(msg) % (acquisition_rate, max_AI_single_chan_rate)) self.clock_terminal = clock_terminal self.MAX_name = MAX_name if MAX_name is not None else name self.static_AO = static_AO self.static_DO = static_DO self.acquisition_rate = acquisition_rate self.AO_range = AO_range self.max_AI_multi_chan_rate = max_AI_multi_chan_rate self.max_AI_single_chan_rate = max_AI_single_chan_rate self.max_AO_sample_rate = max_AO_sample_rate self.max_DO_sample_rate = max_DO_sample_rate self.min_semiperiod_measurement = min_semiperiod_measurement self.num_AI = num_AI # special handling for AI termination configurations self.AI_term = AI_term if AI_term_cfg == None: # assume legacy configuration if none provided AI_term_cfg = {f'ai{i:d}': ['RSE'] for i in range(num_AI)} # warn user to update their local model specs msg = """Model specifications for {} needs to be updated. Please run the `get_capabilites.py` and `generate_subclasses.py` scripts or define the `AI_Term_Cfg` kwarg for your device. """ warnings.warn(dedent(msg.format(self.description)), FutureWarning) self.AI_chans = [ key for key, val in AI_term_cfg.items() if self.AI_term in val ] if not len(self.AI_chans): msg = """AI termination {0} not supported by this device.""" raise LabscriptError(dedent(msg.format(AI_term))) if AI_term == 'Diff': self.AI_range = AI_range_Diff if AI_start_delay is None: if AI_start_delay_ticks is not None: # Tell blacs_worker to use AI_start_delay_ticks to define delay self.start_delay_ticks = True else: raise LabscriptError( "You have specified `AI_start_delay = None` but have not provided `AI_start_delay_ticks`." ) else: # Tells blacs_worker to use AI_start_delay to define delay self.start_delay_ticks = False self.num_AO = num_AO self.num_CI = num_CI self.ports = ports if ports is not None else {} self.supports_buffered_AO = supports_buffered_AO self.supports_buffered_DO = supports_buffered_DO self.supports_semiperiod_measurement = supports_semiperiod_measurement self.supports_simultaneous_AI_sampling = supports_simultaneous_AI_sampling if self.supports_buffered_DO and self.supports_buffered_AO: self.clock_limit = min(self.max_DO_sample_rate, self.max_AO_sample_rate) elif self.supports_buffered_DO: self.clock_limit = self.max_DO_sample_rate elif self.supports_buffered_AO: self.clock_limit = self.max_AO_sample_rate else: self.clock_limit = None if not (static_AO and static_DO): msg = """Device does not support buffered output, please instantiate it with static_AO=True and static_DO=True""" raise LabscriptError(dedent(msg)) self.wait_monitor_minimum_pulse_width = self.min_semiperiod_measurement self.allowed_children = [] '''Sets the allowed children types based on the capabilites.''' if self.num_AI > 0: self.allowed_children += [AnalogIn] if self.num_AO > 0 and static_AO: self.allowed_children += [StaticAnalogOut] if self.num_AO > 0 and not static_AO: self.allowed_children += [AnalogOut] if self.ports and static_DO: self.allowed_children += [StaticDigitalOut] if self.ports and not static_DO: self.allowed_children += [DigitalOut] if clock_terminal is None and not (static_AO and static_DO): msg = """Clock terminal must be specified unless static_AO and static_DO are both True""" raise LabscriptError(dedent(msg)) self.BLACS_connection = self.MAX_name # Cannot be set with set_passed_properties because of name mangling with the # initial double underscore: self.set_property('__version__', __version__, 'connection_table_properties') # This is called late since it must be called after our clock_limit attribute is # set: IntermediateDevice.__init__(self, name, parent_device, **kwargs)
def __init__(self, name, parent_device, clock_type, com_port): IntermediateDevice.__init__(self, name, parent_device, clock_type) self.BLACS_connection = com_port
def __init__(self, name, parent_device=None, clock_terminal=None, MAX_name=None, static_AO=None, static_DO=None, clock_mirror_terminal=None, acquisition_rate=None, AI_range=None, AI_start_delay=0, AO_range=None, max_AI_multi_chan_rate=None, max_AI_single_chan_rate=None, max_AO_sample_rate=None, max_DO_sample_rate=None, min_semiperiod_measurement=None, num_AI=0, num_AO=0, num_CI=0, ports=None, supports_buffered_AO=False, supports_buffered_DO=False, supports_semiperiod_measurement=False, **kwargs): """Generic class for NI_DAQmx devices.""" # Default static output setting based on whether the device supports buffered # output: if static_AO is None: static_AO = not supports_buffered_AO if static_DO is None: static_DO = not supports_buffered_DO # Parent is only allowed to be None if output is static: if parent_device is None and not (static_DO and static_AO): msg = """Must specify a parent clockline, unless both static_AO and static_DO are True""" raise LabscriptError(dedent(msg)) # If parent device is not None though, then clock terminal must be specified: if parent_device is not None and clock_terminal is None: msg = """If parent_device is given, then clock_terminal must be specified as well as the terminal to which the parent pseudoclock is connected.""" raise ValueError(dedent(msg)) if acquisition_rate is not None and num_AI == 0: msg = "Cannot set set acquisition rate on device with no analog inputs" raise ValueError(msg) # Acquisition rate cannot be larger than the single channel rate: if acquisition_rate is not None and acquisition_rate > max_AI_single_chan_rate: msg = """acquisition_rate %f is larger than the maximum single-channel rate %f for this device""" raise ValueError( dedent(msg) % (acquisition_rate, max_AI_single_chan_rate)) self.clock_terminal = clock_terminal self.MAX_name = MAX_name if MAX_name is not None else name self.static_AO = static_AO self.static_DO = static_DO self.acquisition_rate = acquisition_rate self.AO_range = AO_range self.max_AI_multi_chan_rate = max_AI_multi_chan_rate self.max_AI_single_chan_rate = max_AI_single_chan_rate self.max_AO_sample_rate = max_AO_sample_rate self.max_DO_sample_rate = max_DO_sample_rate self.min_semiperiod_measurement = min_semiperiod_measurement self.num_AI = num_AI self.num_AO = num_AO self.num_CI = num_CI self.ports = ports if ports is not None else {} self.supports_buffered_AO = supports_buffered_AO self.supports_buffered_DO = supports_buffered_DO self.supports_semiperiod_measurement = supports_semiperiod_measurement if self.supports_buffered_DO and self.supports_buffered_AO: self.clock_limit = min(self.max_DO_sample_rate, self.max_AO_sample_rate) elif self.supports_buffered_DO: self.clock_limit = self.max_DO_sample_rate elif self.supports_buffered_AO: self.clock_limit = self.max_AO_sample_rate else: self.clock_limit = None if not (static_AO and static_DO): msg = """Device does not support buffered output, please instantiate it with static_AO=True and static_DO=True""" raise LabscriptError(dedent(msg)) self.wait_monitor_minimum_pulse_width = self.min_semiperiod_measurement # Set allowed children based on capabilities: self.allowed_children = [] if self.num_AI > 0: self.allowed_children += [AnalogIn] if self.num_AO > 0 and static_AO: self.allowed_children += [StaticAnalogOut] if self.num_AO > 0 and not static_AO: self.allowed_children += [AnalogOut] if self.ports and static_DO: self.allowed_children += [StaticDigitalOut] if self.ports and not static_DO: self.allowed_children += [DigitalOut] if clock_terminal is None and not (static_AO and static_DO): msg = """Clock terminal must be specified unless static_AO and static_DO are both True""" raise LabscriptError(dedent(msg)) self.BLACS_connection = self.MAX_name # Cannot be set with set_passed_properties because of name mangling with the # initial double underscore: self.set_property('__version__', __version__, 'connection_table_properties') # This is called late since it must be called after our clock_limit attribute is # set: IntermediateDevice.__init__(self, name, parent_device, **kwargs)