(self, number_of_samples_per_channel=NUM_SAMPLES_UNSET,
             timeout=10.0)
return data.tolist()
Reads samples from the task or virtual channels you specify.

        This read method is dynamic, and is capable of inferring an appropriate
        return type based on these factors:
        - The channel type of the task.
        - The number of channels to read.
        - The number of samples per channel.

        The data type of the samples returned is independently determined by
        the channel type of the task.

        For digital input measurements, the data type of the samples returned
        is determined by the line grouping format of the digital lines.
        If the line grouping format is set to "one channel for all lines", the
        data type of the samples returned is int. If the line grouping
        format is set to "one channel per line", the data type of the samples
        returned is boolean.

        If you do not set the number of samples per channel, this method
        assumes one sample was requested. This method then returns either a
        scalar (1 channel to read) or a list (N channels to read).

        If you set the number of samples per channel to ANY value (even 1),
        this method assumes multiple samples were requested. This method then
        returns either a list (1 channel to read) or a list of lists (N
        channels to read).

        Args:
            number_of_samples_per_channel (Optional[int]): Specifies the
                number of samples to read. If this input is not set,
                assumes samples to read is 1. Conversely, if this input
                is set, assumes there are multiple samples to read.

                If you set this input to nidaqmx.constants.
                READ_ALL_AVAILABLE, NI-DAQmx determines how many samples
                to read based on if the task acquires samples
                continuously or acquires a finite number of samples.

                If the task acquires samples continuously and you set
                this input to nidaqmx.constants.READ_ALL_AVAILABLE, this
                method reads all the samples currently available in the
                buffer.

                If the task acquires a finite number of samples and you
                set this input to nidaqmx.constants.READ_ALL_AVAILABLE,
                the method waits for the task to acquire all requested
                samples, then reads those samples. If you set the
                "read_all_avail_samp" property to True, the method reads
                the samples currently available in the buffer and does
                not wait for the task to acquire all requested samples.
            timeout (Optional[float]): Specifies the amount of time in
                seconds to wait for samples to become available. If the
                time elapses, the method returns an error and any
                samples read before the timeout elapsed. The default
                timeout is 10 seconds. If you set timeout to
                nidaqmx.constants.WAIT_INFINITELY, the method waits
                indefinitely. If you set timeout to 0, the method tries
                once to read the requested samples and returns an error
                if it is unable to.
        Returns:
            dynamic:

            The samples requested in the form of a scalar, a list, or a
            list of lists. See method docstring for more info.

            NI-DAQmx scales the data to the units of the measurement,
            including any custom scaling you apply to the channels. Use a
            DAQmx Create Channel method to specify these units.

        Example:
            >>> task = Task()
            >>> task.ai_channels.add_voltage_channel('Dev1/ai0:3')
            >>> data = task.read()
            >>> type(data)
            <type 'list'>
            >>> type(data[0])
            <type 'float'>
Reads samples from the task or virtual channels you specify.
Reads samples from the task or virtual channels you specify .
def read(self, number_of_samples_per_channel=NUM_SAMPLES_UNSET,
             timeout=10.0):
        """
        Reads samples from the task or virtual channels you specify.

        This read method is dynamic, and is capable of inferring an appropriate
        return type based on these factors:
        - The channel type of the task.
        - The number of channels to read.
        - The number of samples per channel.

        The data type of the samples returned is independently determined by
        the channel type of the task.

        For digital input measurements, the data type of the samples returned
        is determined by the line grouping format of the digital lines.
        If the line grouping format is set to "one channel for all lines", the
        data type of the samples returned is int. If the line grouping
        format is set to "one channel per line", the data type of the samples
        returned is boolean.

        If you do not set the number of samples per channel, this method
        assumes one sample was requested. This method then returns either a
        scalar (1 channel to read) or a list (N channels to read).

        If you set the number of samples per channel to ANY value (even 1),
        this method assumes multiple samples were requested. This method then
        returns either a list (1 channel to read) or a list of lists (N
        channels to read).

        Args:
            number_of_samples_per_channel (Optional[int]): Specifies the
                number of samples to read. If this input is not set,
                assumes samples to read is 1. Conversely, if this input
                is set, assumes there are multiple samples to read.

                If you set this input to nidaqmx.constants.
                READ_ALL_AVAILABLE, NI-DAQmx determines how many samples
                to read based on if the task acquires samples
                continuously or acquires a finite number of samples.

                If the task acquires samples continuously and you set
                this input to nidaqmx.constants.READ_ALL_AVAILABLE, this
                method reads all the samples currently available in the
                buffer.

                If the task acquires a finite number of samples and you
                set this input to nidaqmx.constants.READ_ALL_AVAILABLE,
                the method waits for the task to acquire all requested
                samples, then reads those samples. If you set the
                "read_all_avail_samp" property to True, the method reads
                the samples currently available in the buffer and does
                not wait for the task to acquire all requested samples.
            timeout (Optional[float]): Specifies the amount of time in
                seconds to wait for samples to become available. If the
                time elapses, the method returns an error and any
                samples read before the timeout elapsed. The default
                timeout is 10 seconds. If you set timeout to
                nidaqmx.constants.WAIT_INFINITELY, the method waits
                indefinitely. If you set timeout to 0, the method tries
                once to read the requested samples and returns an error
                if it is unable to.
        Returns:
            dynamic:

            The samples requested in the form of a scalar, a list, or a
            list of lists. See method docstring for more info.

            NI-DAQmx scales the data to the units of the measurement,
            including any custom scaling you apply to the channels. Use a
            DAQmx Create Channel method to specify these units.

        Example:
            >>> task = Task()
            >>> task.ai_channels.add_voltage_channel('Dev1/ai0:3')
            >>> data = task.read()
            >>> type(data)
            <type 'list'>
            >>> type(data[0])
            <type 'float'>
        """
        channels_to_read = self.in_stream.channels_to_read
        number_of_channels = len(channels_to_read.channel_names)
        read_chan_type = channels_to_read.chan_type

        num_samples_not_set = (number_of_samples_per_channel is
                               NUM_SAMPLES_UNSET)

        number_of_samples_per_channel = self._calculate_num_samps_per_chan(
            number_of_samples_per_channel)

        # Determine the array shape and size to create
        if number_of_channels > 1:
            if not num_samples_not_set:
                array_shape = (number_of_channels,
                               number_of_samples_per_channel)
            else:
                array_shape = number_of_channels
        else:
            array_shape = number_of_samples_per_channel

        # Analog Input
        if read_chan_type == ChannelType.ANALOG_INPUT:
            data = numpy.zeros(array_shape, dtype=numpy.float64)
            samples_read = _read_analog_f_64(
                self._handle, data, number_of_samples_per_channel, timeout)

        # Digital Input or Digital Output
        elif (read_chan_type == ChannelType.DIGITAL_INPUT or
                read_chan_type == ChannelType.DIGITAL_OUTPUT):
            if self.in_stream.di_num_booleans_per_chan == 1:
                data = numpy.zeros(array_shape, dtype=numpy.bool)
                samples_read = _read_digital_lines(
                    self._handle, data, number_of_samples_per_channel, timeout
                    ).samps_per_chan_read
            else:
                data = numpy.zeros(array_shape, dtype=numpy.uint32)
                samples_read = _read_digital_u_32(
                    self._handle, data, number_of_samples_per_channel, timeout)

        # Counter Input
        elif read_chan_type == ChannelType.COUNTER_INPUT:
            meas_type = channels_to_read.ci_meas_type

            if meas_type == UsageTypeCI.PULSE_FREQ:
                frequencies = numpy.zeros(array_shape, dtype=numpy.float64)
                duty_cycles = numpy.zeros(array_shape, dtype=numpy.float64)

                samples_read = _read_ctr_freq(
                    self._handle, frequencies, duty_cycles,
                    number_of_samples_per_channel, timeout)

                data = []
                for f, d in zip(frequencies, duty_cycles):
                    data.append(CtrFreq(freq=f, duty_cycle=d))

            elif meas_type == UsageTypeCI.PULSE_TIME:
                high_times = numpy.zeros(array_shape, dtype=numpy.float64)
                low_times = numpy.zeros(array_shape, dtype=numpy.float64)

                samples_read = _read_ctr_time(
                    self._handle, high_times, low_times,
                    number_of_samples_per_channel, timeout)
                data = []
                for h, l in zip(high_times, low_times):
                    data.append(CtrTime(high_time=h, low_time=l))

            elif meas_type == UsageTypeCI.PULSE_TICKS:
                high_ticks = numpy.zeros(array_shape, dtype=numpy.uint32)
                low_ticks = numpy.zeros(array_shape, dtype=numpy.uint32)

                samples_read = _read_ctr_ticks(
                    self._handle, high_ticks, low_ticks,
                    number_of_samples_per_channel, timeout)
                data = []
                for h, l in zip(high_ticks, low_ticks):
                    data.append(CtrTick(high_tick=h, low_tick=l))

            elif meas_type == UsageTypeCI.COUNT_EDGES:
                data = numpy.zeros(array_shape, dtype=numpy.uint32)

                samples_read = _read_counter_u_32_ex(
                    self._handle, data, number_of_samples_per_channel, timeout)

            else:
                data = numpy.zeros(array_shape, dtype=numpy.float64)

                samples_read = _read_counter_f_64_ex(
                    self._handle, data, number_of_samples_per_channel, timeout)
        else:
            raise DaqError(
                'Read failed, because there are no channels in this task from '
                'which data can be read.',
                DAQmxErrors.READ_NO_INPUT_CHANS_IN_TASK.value,
                task_name=self.name)

        if (read_chan_type == ChannelType.COUNTER_INPUT and
                (meas_type == UsageTypeCI.PULSE_FREQ or
                 meas_type == UsageTypeCI.PULSE_TICKS or
                 meas_type == UsageTypeCI.PULSE_TIME)):

            if num_samples_not_set and array_shape == 1:
                return data[0]
            # Counter pulse measurements should not have N channel versions.
            if samples_read != number_of_samples_per_channel:
                return data[:samples_read]
            return data

        if num_samples_not_set and array_shape == 1:
            return data.tolist()[0]

        if samples_read != number_of_samples_per_channel:
            if number_of_channels > 1:
                return data[:,:samples_read].tolist()
            else:
                return data[:samples_read].tolist()

        return data.tolist()
def read ( self , number_of_samples_per_channel = NUM_SAMPLES_UNSET , timeout = 10.0 ) : channels_to_read = self . in_stream . channels_to_read number_of_channels = len ( channels_to_read . channel_names ) read_chan_type = channels_to_read . chan_type num_samples_not_set = ( number_of_samples_per_channel is NUM_SAMPLES_UNSET ) number_of_samples_per_channel = self . _calculate_num_samps_per_chan ( number_of_samples_per_channel ) # Determine the array shape and size to create if number_of_channels > 1 : if not num_samples_not_set : array_shape = ( number_of_channels , number_of_samples_per_channel ) else : array_shape = number_of_channels else : array_shape = number_of_samples_per_channel # Analog Input if read_chan_type == ChannelType . ANALOG_INPUT : data = numpy . zeros ( array_shape , dtype = numpy . float64 ) samples_read = _read_analog_f_64 ( self . _handle , data , number_of_samples_per_channel , timeout ) # Digital Input or Digital Output elif ( read_chan_type == ChannelType . DIGITAL_INPUT or read_chan_type == ChannelType . DIGITAL_OUTPUT ) : if self . in_stream . di_num_booleans_per_chan == 1 : data = numpy . zeros ( array_shape , dtype = numpy . bool ) samples_read = _read_digital_lines ( self . _handle , data , number_of_samples_per_channel , timeout ) . samps_per_chan_read else : data = numpy . zeros ( array_shape , dtype = numpy . uint32 ) samples_read = _read_digital_u_32 ( self . _handle , data , number_of_samples_per_channel , timeout ) # Counter Input elif read_chan_type == ChannelType . COUNTER_INPUT : meas_type = channels_to_read . ci_meas_type if meas_type == UsageTypeCI . PULSE_FREQ : frequencies = numpy . zeros ( array_shape , dtype = numpy . float64 ) duty_cycles = numpy . zeros ( array_shape , dtype = numpy . float64 ) samples_read = _read_ctr_freq ( self . _handle , frequencies , duty_cycles , number_of_samples_per_channel , timeout ) data = [ ] for f , d in zip ( frequencies , duty_cycles ) : data . append ( CtrFreq ( freq = f , duty_cycle = d ) ) elif meas_type == UsageTypeCI . PULSE_TIME : high_times = numpy . zeros ( array_shape , dtype = numpy . float64 ) low_times = numpy . zeros ( array_shape , dtype = numpy . float64 ) samples_read = _read_ctr_time ( self . _handle , high_times , low_times , number_of_samples_per_channel , timeout ) data = [ ] for h , l in zip ( high_times , low_times ) : data . append ( CtrTime ( high_time = h , low_time = l ) ) elif meas_type == UsageTypeCI . PULSE_TICKS : high_ticks = numpy . zeros ( array_shape , dtype = numpy . uint32 ) low_ticks = numpy . zeros ( array_shape , dtype = numpy . uint32 ) samples_read = _read_ctr_ticks ( self . _handle , high_ticks , low_ticks , number_of_samples_per_channel , timeout ) data = [ ] for h , l in zip ( high_ticks , low_ticks ) : data . append ( CtrTick ( high_tick = h , low_tick = l ) ) elif meas_type == UsageTypeCI . COUNT_EDGES : data = numpy . zeros ( array_shape , dtype = numpy . uint32 ) samples_read = _read_counter_u_32_ex ( self . _handle , data , number_of_samples_per_channel , timeout ) else : data = numpy . zeros ( array_shape , dtype = numpy . float64 ) samples_read = _read_counter_f_64_ex ( self . _handle , data , number_of_samples_per_channel , timeout ) else : raise DaqError ( 'Read failed, because there are no channels in this task from ' 'which data can be read.' , DAQmxErrors . READ_NO_INPUT_CHANS_IN_TASK . value , task_name = self . name ) if ( read_chan_type == ChannelType . COUNTER_INPUT and ( meas_type == UsageTypeCI . PULSE_FREQ or meas_type == UsageTypeCI . PULSE_TICKS or meas_type == UsageTypeCI . PULSE_TIME ) ) : if num_samples_not_set and array_shape == 1 : return data [ 0 ] # Counter pulse measurements should not have N channel versions. if samples_read != number_of_samples_per_channel : return data [ : samples_read ] return data if num_samples_not_set and array_shape == 1 : return data . tolist ( ) [ 0 ] if samples_read != number_of_samples_per_channel : if number_of_channels > 1 : return data [ : , : samples_read ] . tolist ( ) else : return data [ : samples_read ] . tolist ( ) return data . tolist ( )