我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用ctypes.c_uint()。
def _read_ctr_ticks( task_handle, high_tick, low_tick, num_samps_per_chan, timeout, interleaved=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadCtrTicks if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.uint32, flags=('C', 'W')), wrapped_ndpointer(dtype=numpy.uint32, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, interleaved.value, high_tick, low_tick, numpy.prod(high_tick.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _parse_typedefs(self): """ Determines the ctypes data types of the Task and Cal handles based on the version of the NI-DAQmx driver installed. """ from nidaqmx.system.system import System system = System.local() # If DAQmx 8.8 and lower, TaskHandle is a typedef for uInt32 since # DAQmx didn't support 64-bit applications then. version = system.driver_version if version.major_version <= 8 and version.minor_version <= 8: self._task_handle = ctypes.c_uint else: self._task_handle = ctypes.c_void_p self._cal_handle = ctypes.c_uint
def _major_version(self): """ int: Indicates the major portion of the installed version of NI- DAQmx, such as 7 for version 7.0. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetSysNIDAQMajorVersion if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( ctypes.byref(val)) check_for_error(error_code) return val.value
def _update_version(self): """ int: Indicates the update portion of the installed version of NI-DAQmx, such as 1 for version 9.0.1. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetSysNIDAQUpdateVersion if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( ctypes.byref(val)) check_for_error(error_code) return val.value
def di_port_width(self): """ int: Indicates in bits the width of digital input port. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetPhysicalChanDIPortWidth if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def do_port_width(self): """ int: Indicates in bits the width of digital output port. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetPhysicalChanDOPortWidth if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def teds_mfg_id(self): """ int: Indicates the manufacturer ID of the sensor. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetPhysicalChanTEDSMfgID if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def teds_model_num(self): """ int: Indicates the model number of the sensor. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetPhysicalChanTEDSModelNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def teds_serial_num(self): """ int: Indicates the serial number of the sensor. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetPhysicalChanTEDSSerialNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def teds_version_num(self): """ int: Indicates the version number of the sensor. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetPhysicalChanTEDSVersionNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def ai_lowpass_cutoff_freq_range_vals(self): """ List[float]: Indicates pairs of lowpass cutoff frequency ranges supported by this device. Each pair consists of the low value, followed by the high value. If the device supports a set of discrete lowpass cutoff frequencies, use **ai_lowpass_cutoff_freq_discrete_vals** to determine the supported frequencies. """ cfunc = lib_importer.windll.DAQmxGetDevAILowpassCutoffFreqRangeVals if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, wrapped_ndpointer(dtype=numpy.float64, flags=('C','W')), ctypes.c_uint] temp_size = 0 while True: val = numpy.zeros(temp_size, dtype=numpy.float64) size_or_code = cfunc( self._name, val, temp_size) if is_array_buffer_too_small(size_or_code): # Buffer size must have changed between calls; check again. temp_size = 0 elif size_or_code > 0 and temp_size == 0: # Buffer size obtained, use to retrieve data. temp_size = size_or_code else: break check_for_error(size_or_code) return val.tolist()
def carrier_serial_num(self): """ int: Indicates the serial number of the device carrier. This value is zero if the carrier does not have a serial number. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetCarrierSerialNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def ci_max_size(self): """ int: Indicates in bits the size of the counters on the device. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetDevCIMaxSize if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def co_max_size(self): """ int: Indicates in bits the size of the counters on the device. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetDevCOMaxSize if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def dev_serial_num(self): """ int: Indicates the serial number of the device. This value is zero if the device does not have a serial number. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetDevSerialNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def num_dma_chans(self): """ int: Indicates the number of DMA channels on the device. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetDevNumDMAChans if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def pci_bus_num(self): """ int: Indicates the PCI bus number of the device. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetDevPCIBusNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def pci_dev_num(self): """ int: Indicates the PCI slot number of the device. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetDevPCIDevNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def product_num(self): """ int: Indicates the unique hardware identification number for the device. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetDevProductNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def pxi_chassis_num(self): """ int: Indicates the PXI chassis number of the device, as identified in MAX. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetDevPXIChassisNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def pxi_slot_num(self): """ int: Indicates the PXI slot number of the device. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetDevPXISlotNum if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ ctypes_byte_str, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._name, ctypes.byref(val)) check_for_error(error_code) return val.value
def number_of_channels(self): """ int: Indicates the number of virtual channels in the task. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetTaskNumChans if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def number_of_devices(self): """ int: Indicates the number of devices in the task. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetTaskNumDevices if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def pretrig_samples(self): """ int: Specifies the minimum number of pretrigger samples to acquire from each channel before recognizing the reference trigger. Post-trigger samples per channel are equal to **samp_quant_samp_per_chan** minus the number of pretrigger samples per channel. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetRefTrigPreTrigSamples if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def rdy_for_xfer_event_deassert_cond_custom_threshold(self): """ int: Specifies in samples the threshold below which the Ready for Transfer Event deasserts. This threshold is an amount of space available in the onboard memory of the device. **rdy_for_xfer_event_deassert_cond** must be **DeassertCondition.ONBOARD_MEMORY_CUSTOM_THRESHOLD** to use a custom threshold. """ val = ctypes.c_uint() cfunc = (lib_importer.windll. DAQmxGetExportedRdyForXferEventDeassertCondCustomThreshold) if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def do_num_booleans_per_chan(self): """ int: Indicates the number of Boolean values expected per channel in a sample for line-based writes. This property is determined by the channel in the task with the most digital lines. If a channel has fewer lines than this number, NI- DAQmx ignores the extra Boolean values. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetWriteDigitalLinesBytesPerChan if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def output_buf_size(self): """ int: Specifies the number of samples the output buffer can hold for each channel in the task. Zero indicates to allocate no buffer. Use a buffer size of 0 to perform a hardware-timed operation without using a buffer. Setting this property overrides the automatic output buffer allocation that NI- DAQmx performs. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetBufOutputBufSize if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def output_onbrd_buf_size(self): """ int: Specifies in samples per channel the size of the onboard output buffer of the device. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetBufOutputOnbrdBufSize if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def raw_data_width(self): """ int: Indicates in bytes the required size of a raw sample to write to the task. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetWriteRawDataWidth if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def space_avail(self): """ int: Indicates in samples per channel the amount of available space in the buffer. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetWriteSpaceAvail if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def _read_binary_i_16( task_handle, read_array, num_samps_per_chan, timeout, fill_mode=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadBinaryI16 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.int16, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, fill_mode.value, read_array, numpy.prod(read_array.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_binary_u_16( task_handle, read_array, num_samps_per_chan, timeout, fill_mode=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadBinaryU16 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.uint16, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, fill_mode.value, read_array, numpy.prod(read_array.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_binary_i_32( task_handle, read_array, num_samps_per_chan, timeout, fill_mode=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadBinaryI32 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.int32, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, fill_mode.value, read_array, numpy.prod(read_array.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_binary_u_32( task_handle, read_array, num_samps_per_chan, timeout, fill_mode=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadBinaryU32 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.uint32, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, fill_mode.value, read_array, numpy.prod(read_array.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_digital_u_8( task_handle, read_array, num_samps_per_chan, timeout, fill_mode=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadDigitalU8 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.uint8, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, fill_mode.value, read_array, numpy.prod(read_array.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_digital_u_32( task_handle, read_array, num_samps_per_chan, timeout, fill_mode=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadDigitalU32 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.uint32, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, fill_mode.value, read_array, numpy.prod(read_array.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_digital_scalar_u_32(task_handle, timeout): value = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxReadDigitalScalarU32 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_double, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, timeout, ctypes.byref(value), None) check_for_error(error_code) return value.value
def _read_counter_f_64(task_handle, read_array, num_samps_per_chan, timeout): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadCounterF64 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, wrapped_ndpointer(dtype=numpy.float64, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, read_array, numpy.prod(read_array.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_counter_u_32(task_handle, read_array, num_samps_per_chan, timeout): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadCounterU32 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, wrapped_ndpointer(dtype=numpy.uint32, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, read_array, numpy.prod(read_array.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_counter_u_32_ex( task_handle, read_array, num_samps_per_chan, timeout, fill_mode=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadCounterU32Ex if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.uint32, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, fill_mode.value, read_array, numpy.prod(read_array.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_counter_scalar_u_32(task_handle, timeout): value = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxReadCounterScalarU32 if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_double, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, timeout, ctypes.byref(value), None) check_for_error(error_code) return value.value
def _read_ctr_freq( task_handle, freq, duty_cycle, num_samps_per_chan, timeout, interleaved=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadCtrFreq if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.float64, flags=('C', 'W')), wrapped_ndpointer(dtype=numpy.float64, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, interleaved.value, freq, duty_cycle, numpy.prod(freq.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_ctr_time( task_handle, high_time, low_time, num_samps_per_chan, timeout, interleaved=FillMode.GROUP_BY_CHANNEL): samps_per_chan_read = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadCtrTime if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, ctypes.c_int, wrapped_ndpointer(dtype=numpy.float64, flags=('C', 'W')), wrapped_ndpointer(dtype=numpy.float64, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, interleaved.value, high_time, low_time, numpy.prod(high_time.shape), ctypes.byref(samps_per_chan_read), None) check_for_error(error_code) return samps_per_chan_read.value
def _read_raw(task_handle, read_array, num_samps_per_chan, timeout): samples_read = ctypes.c_int() number_of_bytes_per_sample = ctypes.c_int() cfunc = lib_importer.windll.DAQmxReadRaw if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_int, ctypes.c_double, wrapped_ndpointer(dtype=read_array.dtype, flags=('C', 'W')), ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)] error_code = cfunc( task_handle, num_samps_per_chan, timeout, read_array, read_array.nbytes, ctypes.byref(samples_read), ctypes.byref(number_of_bytes_per_sample), None) check_for_error(error_code) return samples_read.value, number_of_bytes_per_sample.value
def avail_samp_per_chan(self): """ int: Indicates the number of samples available to read per channel. This value is the same for all channels in the task. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetReadAvailSampPerChan if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def common_mode_range_error_chans(self): """ List[str]: Indicates a list of names of any virtual channels in the task for which the device(s) detected a common mode range violation. You must read **common_mode_range_error_chans_exist** before you read this property. Otherwise, you will receive an error. """ cfunc = lib_importer.windll.DAQmxGetReadCommonModeRangeErrorChans if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.c_char_p, ctypes.c_uint] temp_size = 2048 val = ctypes.create_string_buffer(temp_size) error_code = cfunc( self._handle, val, temp_size) check_for_error(error_code) return unflatten_channel_string(val.value.decode('ascii'))
def input_buf_size(self): """ int: Specifies the number of samples the input buffer can hold for each channel in the task. Zero indicates to allocate no buffer. Use a buffer size of 0 to perform a hardware-timed operation without using a buffer. Setting this property overrides the automatic input buffer allocation that NI- DAQmx performs. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetBufInputBufSize if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def input_onbrd_buf_size(self): """ int: Indicates in samples per channel the size of the onboard input buffer of the device. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetBufInputOnbrdBufSize if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def num_chans(self): """ int: Indicates the number of channels that DAQmx Read reads from the task. This value is the number of channels in the task or the number of channels you specify with **channels_to_read**. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetReadNumChans if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value
def raw_data_width(self): """ int: Indicates in bytes the size of a raw sample from the task. """ val = ctypes.c_uint() cfunc = lib_importer.windll.DAQmxGetReadRawDataWidth if cfunc.argtypes is None: with cfunc.arglock: if cfunc.argtypes is None: cfunc.argtypes = [ lib_importer.task_handle, ctypes.POINTER(ctypes.c_uint)] error_code = cfunc( self._handle, ctypes.byref(val)) check_for_error(error_code) return val.value