def _write_digital_u_16(
task_handle, write_array, num_samps_per_chan, auto_start, timeout,
data_layout=FillMode.GROUP_BY_CHANNEL):
samps_per_chan_written = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxWriteDigitalU16
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_int, c_bool32,
ctypes.c_double, ctypes.c_int,
wrapped_ndpointer(dtype=numpy.uint16, flags=('C', 'W')),
ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)]
error_code = cfunc(
task_handle, num_samps_per_chan, auto_start, timeout,
data_layout.value, write_array,
ctypes.byref(samps_per_chan_written), None)
check_for_error(error_code)
return samps_per_chan_written.value
python类c_double()的实例源码
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 _write_ctr_ticks(
task_handle, high_tick, low_tick, num_samps_per_chan, auto_start,
timeout, data_layout=FillMode.GROUP_BY_CHANNEL):
num_samps_per_chan_written = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxWriteCtrTicks
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_int, c_bool32,
ctypes.c_double, ctypes.c_int,
wrapped_ndpointer(dtype=numpy.uint32, flags=('C', 'W')),
wrapped_ndpointer(dtype=numpy.uint32, flags=('C', 'W')),
ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)]
error_code = cfunc(
task_handle, num_samps_per_chan, auto_start, timeout,
data_layout.value, high_tick, low_tick,
ctypes.byref(num_samps_per_chan_written), None)
check_for_error(error_code)
return num_samps_per_chan_written.value
def ao_manual_control_amplitude(self):
"""
float: Indicates the current value of the front panel amplitude
control for the physical channel in volts.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetPhysicalChanAOManualControlAmplitude)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def ao_manual_control_freq(self):
"""
float: Indicates the current value of the front panel frequency
control for the physical channel in hertz.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetPhysicalChanAOManualControlFreq
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def ao_power_amp_gain(self):
"""
float: Indicates the calibrated gain of the channel.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetAOPowerAmpGain
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def ao_power_amp_offset(self):
"""
float: Indicates the calibrated offset of the channel in volts.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetAOPowerAmpOffset
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def timeout(self):
"""
float: Specifies in seconds the amount of time until the
watchdog timer expires. A value of -1 means the internal
timer never expires. Set this input to -1 if you use an
Expiration Trigger to expire the watchdog task.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetWatchdogTimeout
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def ai_max_multi_chan_rate(self):
"""
float: Indicates the maximum sampling rate for an analog input
task from this device. To find the maximum rate for the
task, take the minimum of **ai_max_single_chan_rate** or the
indicated sampling rate of this device divided by the number
of channels to acquire data from (including cold-junction
compensation and autozero channels).
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetDevAIMaxMultiChanRate
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def ai_min_rate(self):
"""
float: Indicates the minimum rate for an analog input task on
this device. NI-DAQmx returns a warning or error if you
attempt to sample at a slower rate.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetDevAIMinRate
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def ao_max_rate(self):
"""
float: Indicates the maximum analog output rate of the device.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetDevAOMaxRate
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def ao_min_rate(self):
"""
float: Indicates the minimum analog output rate of the device.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetDevAOMinRate
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def ci_max_timebase(self):
"""
float: Indicates in hertz the maximum counter timebase
frequency.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetDevCIMaxTimebase
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def co_max_timebase(self):
"""
float: Indicates in hertz the maximum counter timebase
frequency.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetDevCOMaxTimebase
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def do_max_rate(self):
"""
float: Indicates the maximum digital output rate of the device.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetDevDOMaxRate
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return val.value
def wait_until_done(self, timeout=10.0):
"""
Waits for the measurement or generation to complete.
Use this method to ensure that the specified operation is complete
before you stop the task.
Args:
timeout (Optional[float]): Specifies the maximum amount of time in
seconds to wait for the measurement or generation to complete.
This method returns an error if the time elapses. The
default is 10. If you set timeout (sec) to
nidaqmx.WAIT_INFINITELY, the method waits indefinitely. If you
set timeout (sec) to 0, the method checks once and returns
an error if the measurement or generation is not done.
"""
cfunc = lib_importer.windll.DAQmxWaitUntilTaskDone
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [lib_importer.task_handle, ctypes.c_double]
error_code = cfunc(self._handle, timeout)
check_for_error(error_code)
def anlg_lvl_dig_fltr_min_pulse_width(self):
"""
float: Specifies in seconds the minimum pulse width the filter
recognizes.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetAnlgLvlPauseTrigDigFltrMinPulseWidth)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def anlg_lvl_lvl(self):
"""
float: Specifies the threshold at which to pause the task.
Specify this value in the units of the measurement or
generation. Use **anlg_lvl_when** to specify whether the
task pauses above or below this threshold.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetAnlgLvlPauseTrigLvl
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def anlg_win_dig_fltr_min_pulse_width(self):
"""
float: Specifies in seconds the minimum pulse width the filter
recognizes.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetAnlgWinPauseTrigDigFltrMinPulseWidth)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def anlg_win_dig_fltr_timebase_rate(self):
"""
float: Specifies in hertz the rate of the digital filter
timebase. NI-DAQmx uses this value to compute settings for
the filter.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetAnlgWinPauseTrigDigFltrTimebaseRate)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def dig_lvl_dig_fltr_min_pulse_width(self):
"""
float: Specifies in seconds the minimum pulse width the filter
recognizes.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetDigLvlPauseTrigDigFltrMinPulseWidth)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def dig_lvl_dig_fltr_timebase_rate(self):
"""
float: Specifies in hertz the rate of the pulse width filter
timebase. NI-DAQmx uses this value to compute settings for
the filter.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetDigLvlPauseTrigDigFltrTimebaseRate)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def dig_edge_dig_fltr_timebase_rate(self):
"""
float: Specifies in hertz the rate of the pulse width filter
timebase. NI-DAQmx uses this value to compute settings for
the filter.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetDigEdgeArmStartTrigDigFltrTimebaseRate)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def anlg_edge_dig_fltr_min_pulse_width(self):
"""
float: Specifies in seconds the minimum pulse width thefilter
recognizes.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetAnlgEdgeRefTrigDigFltrMinPulseWidth)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def anlg_edge_lvl(self):
"""
float: Specifies in the units of the measurement the threshold
at which the Reference Trigger occurs. Use
**anlg_edge_slope** to specify on which slope to trigger at
this threshold.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetAnlgEdgeRefTrigLvl
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def anlg_win_dig_fltr_min_pulse_width(self):
"""
float: Specifies in seconds the minimum pulse width the filter
recognizes.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetAnlgWinRefTrigDigFltrMinPulseWidth)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def anlg_win_dig_fltr_timebase_rate(self):
"""
float: Specifies in hertz the rate of the digital filter
timebase. NI-DAQmx uses this value to compute settings for
the filter.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetAnlgWinRefTrigDigFltrTimebaseRate)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def delay(self):
"""
float: Specifies in seconds the time to wait after the device
receives the Reference Trigger before switching from
pretrigger to posttrigger samples.
"""
val = ctypes.c_double()
cfunc = lib_importer.windll.DAQmxGetRefTrigDelay
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def dig_edge_dig_fltr_min_pulse_width(self):
"""
float: Specifies in seconds the minimum pulse width the filter
recognizes.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetDigEdgeRefTrigDigFltrMinPulseWidth)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value
def anlg_edge_dig_fltr_min_pulse_width(self):
"""
float: Specifies in seconds the minimum pulse width the filter
recognizes.
"""
val = ctypes.c_double()
cfunc = (lib_importer.windll.
DAQmxGetAnlgEdgeStartTrigDigFltrMinPulseWidth)
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle,
ctypes.POINTER(ctypes.c_double)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return val.value