コード例 #1
0
 def _make_digital_out_table(self, digitals, times):
     """Collect digital output data and create the output array"""
     if not digitals:
         return None
     n_timepoints = 1 if self.static_DO else len(times)
     # List of output bits by port number:
     bits_by_port = {}
     # table names and dtypes by port number:
     columns = {}
     for connection, output in digitals.items():
         port, line = split_conn_DO(connection)
         port_str = 'port%d' % port
         if port not in bits_by_port:
             # Make a list of the right size for the number of lines
             # on the port, or the number of bits in the smallest integer
             # type that is equal to or larger than the number of lines.
             nlines = self.ports[port_str]["num_lines"]
             int_type = _smallest_int_type(nlines)
             int_type_nbits = 8 * int_type().nbytes
             columns[port] = (port_str, int_type)
             bits_by_port[port] = [0] * int_type_nbits
         bits_by_port[port][line] = output.raw_output
     dtypes = [columns[port] for port in sorted(columns)]
     digital_out_table = np.empty(n_timepoints, dtype=dtypes)
     for port, bits in bits_by_port.items():
         # Pack the bits from each port into an integer:
         port_str, dtype = columns[port]
         values = bitfield(bits, dtype=dtype)
         # Put them into the table:
         digital_out_table[port_str] = np.array(values)
     return digital_out_table
コード例 #2
0
 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 convert_bools_to_bytes(self, digitals):
     """converts digital outputs to an array of bitfields stored
     as self.digital_dtype"""
     outputarray = [0] * self.n_digitals
     for output in digitals:
         port, line = output.connection.replace('port',
                                                '').replace('line',
                                                            '').split('/')
         port, line = int(port), int(line)
         outputarray[self.n_lines * port + line] = output.raw_output
     bits = bitfield(outputarray, dtype=self.digital_dtype)
     return bits
 def convert_bools_to_bytes(self,digitals):
     """converts digital outputs to an array of bitfields stored
     as self.dtype_DO"""
     outputarray = [0]*self.num_DO
     for output in digitals:
         port, line = output.connection.replace('port','').replace('line','').split('/')
         port, line  = int(port),int(line)
         if port > 0:
             raise LabscriptError('Ports > 0 on NI Boards not implemented. Please use port 0, or file a feature request at redmine.physics.monash.edu.au/labscript.')
         outputarray[line] = output.raw_output
     bits = bitfield(outputarray,dtype=self.dtype_DO)
     return bits
コード例 #5
0
ファイル: adwin.py プロジェクト: specialforcea/labscriptsuite
 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)