def __init__(self, name, device_no=1, cycle_time = default_cycle_time): self.BLACS_connection = device_no # round cycle time to the nearest multiple of 3.3333ns quantised_cycle_time = round(cycle_time/3.333333333333e-9) cycle_time = quantised_cycle_time*3.333333333333e-9 self.clock_limit = 1./cycle_time self.clock_resolution = cycle_time Device.__init__(self, name, parent_device=None, connection=None) self.trigger_times = [] self.wait_times = [] self.initial_trigger_time = 0
def __init__(self, name, parent_device, card_number): self.clock_limit = parent_device.clock_limit self.clock_resolution = parent_device.clock_resolution # Device must be accessed via the parent ADWin, so we must store # the parent's device_no as well as the card number: self.card_number = card_number self.BLACS_connection = parent_device.BLACS_connection, card_number # We won't call IntermediateDevice.__init__(), as we don't care # about the checks it does for clocking, we don't actually have # a clock: Device.__init__(self, name, parent_device, card_number) self.trigger_times = [] self.wait_times = [] self.initial_trigger_time = 0
def generate_code(self, hdf5_file): outputs = self.get_all_outputs() # We call the following to do the error checking it includes, # but we're not actually interested in the set of change times. # Each card will handle its own timebase issues. ignore = self.collect_change_times(outputs) self.do_checks(outputs) # This causes the cards to have their generate_code() methods # called. They collect up the instructions of their outputs, # and then we will collate them together into one big instruction # table. Device.generate_code(self, hdf5_file) self.collect_card_instructions(hdf5_file) # We don't actually care about these other things that pseudoclock # classes normally do, but they still do some error checking # that we want: change_times = self.collect_change_times(outputs) for output in outputs: output.make_timeseries(change_times) all_times, clock = self.expand_change_times(change_times, outputs)
def generate_code(self, hdf5_file): Device.generate_code(self, hdf5_file) # This group must exist in order for BLACS to know that this # device is part of the experiment: group = hdf5_file.create_group('/devices/%s'%self.name) outputs = self.get_all_outputs() change_times = self.collect_change_times(outputs) for output in outputs: output.make_timeseries(change_times) for time in change_times: outputarray = [0]*self.n_digitals for output in outputs: channel = output.connection # We have to subtract one from the channel number to get # the correct index, as ADWin is one-indexed, curse it. outputarray[channel - 1] = array(output.timeseries) bits = bitfield(outputarray, dtype=self.digital_dtype) self.formatted_instructions = [] for t, value in zip(change_times, bits): formatted_instruction = {'t': t, 'card': self.card_number,'bitfield': value} self.formatted_instructions.append(formatted_instruction)
def generate_code(self, hdf5_file): Device.generate_code(self, hdf5_file) # This group must exist in order for BLACS to know that this # device is part of the experiment: group = hdf5_file.create_group('/devices/%s'%self.name) # OK, let's collect up all the analog instructions! self.formatted_instructions = [] for output in self.get_all_outputs(): for t, instruction in output.instructions.items(): card_number = self.card_number channel_number = output.connection if isinstance(instruction, RampInstruction): duration = instruction.duration if isinstance(instruction, LinearRamp): ramp_type = 0 elif isinstance(instruction, SinRamp): ramp_type = 1 elif isinstance(instruction, CosRamp): ramp_type = 2 elif isinstance(instruction, ExpRamp): ramp_type = 3 else: raise ValueError(instruction) A = instruction.A B = instruction.B C = instruction.C else: # Let's construct a ramp out of the single value instruction: duration = self.clock_resolution ramp_type = 0 A = instruction B = 0 C = instruction formatted_instruction = {'t':t, 'duration': duration, 'card': card_number, 'channel': channel_number, 'ramp_type': ramp_type, 'A': A, 'B': B, 'C': C} self.formatted_instructions.append(formatted_instruction)
def __init__(self, name, host="", port=23, slave=1, **kwargs): # slave=1 is the master controller on the host ip Device.__init__(self, name, None, None, None) self.BLACS_connection = '%s,%d' % (host, slave)
def __init__(self, name, parent_device, connection, freq_limits = None, freq_conv_class = None,freq_conv_params = {}): self.clock_type = parent_device.clock_type Device.__init__(self,name,parent_device,connection) self.frequency = StaticAnalogQuantity(self.name+'_freq',self,'freq',freq_limits,freq_conv_class,freq_conv_params) self.frequency.default_value = 0.5e9 self.gate = StaticDigitalOut(self.name+'_gate',self,'gate')
def add_device(self, device): Device.add_device(self, device) # Minimum frequency is 20MHz: device.frequency.default_value = 20e6
def generate_code(self, hdf5_file): '''Automatically called by compiler to write acquisition instructions to h5 file. Configures counters, analog and digital acquisitions.''' Device.generate_code(self, hdf5_file) trans = {'pulse': 'PUL', 'edge': 'EDG', 'pos': 'P', 'neg': 'N'} acqs = {'ANALOG': [], 'POD1': [], 'POD2': []} for channel in self.child_devices: if channel.acquisitions: # make sure channel is allowed if channel.connection in self.allowed_analog_chan: acqs['ANALOG'].append( (channel.connection, channel.acquisitions[0]['label'])) elif channel.connection in self.allowed_pod1_chan: acqs['POD1'].append( (channel.connection, channel.acquisitions[0]['label'])) elif channel.connection in self.allowed_pod2_chan: acqs['POD2'].append( (channel.connection, channel.acquisitions[0]['label'])) else: raise LabscriptError( '{0:s} is not a valid channel.'.format( channel.connection)) acquisition_table_dtypes = np.dtype({ 'names': ['connection', 'label'], 'formats': ['a256', 'a256'] }) grp = self.init_device_group(hdf5_file) # write tables if non-empty to h5_file for acq_group, acq_chan in acqs.items(): if len(acq_chan): table = np.empty(len(acq_chan), dtype=acquisition_table_dtypes) for i, acq in enumerate(acq_chan): table[i] = acq grp.create_dataset(acq_group + '_ACQUISITIONS', compression=config.compression, data=table) grp[acq_group + '_ACQUISITIONS'].attrs['trigger_time'] = self.trigger_time # now do the counters counts = [] for channel in self.child_devices: if hasattr(channel, 'counts'): for counter in channel.counts: counts.append((channel.connection, trans[counter['type']], trans[counter['polarity']])) counts_table_dtypes = np.dtype({ 'names': ['connection', 'type', 'polarity'], 'formats': ['a256', 'a256', 'a256'] }) counts_table = np.empty(len(counts), dtype=counts_table_dtypes) for i, count in enumerate(counts): counts_table[i] = count if len(counts_table): grp.create_dataset('COUNTERS', compression=config.compression, data=counts_table) grp['COUNTERS'].attrs['trigger_time'] = self.trigger_time
def __init__(self, name, DoSomething = False, **kwargs): if DoSomething is not False: raise LabscriptError('test_device does nothing, but kwarg DoSomething was not passed False') Device.__init(self, name, None, None, **kwargs)
def add_device(self, device): Device.add_device(self, device) # The Novatech doesn't support 0Hz output; set the default frequency of the DDS to 0.1 Hz: device.frequency.default_value = 0.1
def __init__(self, name, parent_device, connection, freq_limits = None, freq_conv_class = None,freq_conv_params = {}): Device.__init__(self,name,parent_device,connection) self.frequency = StaticAnalogQuantity(self.name+'_freq',self,'freq',freq_limits,freq_conv_class,freq_conv_params) self.frequency.default_value = 0.5e9 self.gate = StaticDigitalOut(self.name+'_gate',self,'gate')
def __init__(self, name, com_port): Device.__init__(self, name, None, None) self.BLACS_connection = com_port
def add_device(self, device): Device.add_device(self, device)
def __init__(self, name, host = "", port=23, **kwargs): Device.__init__(self, name, None, None, None) self.BLACS_connection = '%s' %(host)
def __init__(self, name,com_port): Device.__init__(self, name, None, None) self.BLACS_connection = com_port
def add_device(self, output): # TODO: check there are no duplicates, check that connection # string is formatted correctly. Device.add_device(self, output)
def generate_code(self, hdf5_file): self.do_checks() Device.generate_code(self, hdf5_file)