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_int()的实例源码
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 hshk_event_pulse_polarity(self):
"""
:class:`nidaqmx.constants.Polarity`: Specifies the polarity of
the exported Handshake Event if
**hshk_event_output_behavior** is **ExportActions5.PULSE**.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetExportedHshkEventPulsePolarity
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return Polarity(val.value)
def set_digital_logic_family_power_up_state(
self, device_name, logic_family):
"""
Sets the digital logic family to use when the device powers up.
Args:
device_name (str): Specifies the name as configured in MAX
of the device to which this operation applies.
logic_family (nidaqmx.constants.LogicFamily): Specifies the
logic family set to the device to when it powers up. A
logic family corresponds to voltage thresholds that are
compatible with a group of voltage standards. Refer to
device documentation for information on the logic high
and logic low voltages for these logic families.
"""
cfunc = lib_importer.windll.DAQmxSetDigitalLogicFamilyPowerUpState
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.c_int]
error_code = cfunc(
device_name, logic_family.value)
check_for_error(error_code)
def ai_term_cfgs(self):
"""
List[:class:`nidaqmx.constants.TerminalConfiguration`]:
Indicates the list of terminal configurations supported by
the channel.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetPhysicalChanAITermCfgs
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return enum_bitfield_to_list(
val.value, _TermCfg, TerminalConfiguration)
def ao_term_cfgs(self):
"""
List[:class:`nidaqmx.constants.TerminalConfiguration`]:
Indicates the list of terminal configurations supported by
the channel.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetPhysicalChanAOTermCfgs
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return enum_bitfield_to_list(
val.value, _TermCfg, TerminalConfiguration)
def write_to_teds_from_file(
self, file_path="",
basic_teds_options=WriteBasicTEDSOptions.DO_NOT_WRITE):
"""
Writes data from a virtual TEDS file to the TEDS sensor.
Args:
file_path (Optional[str]): Specifies the filename of a
virtual TEDS file that contains the bitstream to write.
basic_teds_options (Optional[nidaqmx.constants.WriteBasicTEDSOptions]):
Specifies how to handle basic TEDS data in the
bitstream.
"""
cfunc = lib_importer.windll.DAQmxWriteToTEDSFromFile
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes_byte_str, ctypes.c_int]
error_code = cfunc(
self._name, file_path, basic_teds_options.value)
check_for_error(error_code)
def expir_states_ao_type(self):
"""
:class:`nidaqmx.constants.WatchdogAOExpirState`: Specifies the
output type of the analog output physical channels when the
watchdog task expires.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetWatchdogAOOutputType
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes_byte_str,
ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, self._physical_channel, ctypes.byref(val))
check_for_error(error_code)
return WatchdogAOExpirState(val.value)
def expir_states_co_state(self):
"""
:class:`nidaqmx.constants.WatchdogCOExpirState`: Specifies the
state to set the counter output channel terminal when the
watchdog task expires.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetWatchdogCOExpirState
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes_byte_str,
ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, self._physical_channel, ctypes.byref(val))
check_for_error(error_code)
return WatchdogCOExpirState(val.value)
def expir_trig_dig_edge_edge(self):
"""
:class:`nidaqmx.constants.Edge`: Specifies on which edge of a
digital signal to expire the watchdog task.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDigEdgeWatchdogExpirTrigEdge
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return Edge(val.value)
def expir_trig_trig_type(self):
"""
:class:`nidaqmx.constants.TriggerType`: Specifies the type of
trigger to use to expire a watchdog task.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetWatchdogExpirTrigType
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return TriggerType(val.value)
def control(self, action):
"""
Alters the state of a task according to the action you specify.
Args:
action (nidaqmx.constants.TaskMode): Specifies how to alter
the task state.
"""
cfunc = lib_importer.windll.DAQmxTaskControl
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_int]
error_code = cfunc(
self._handle, action.value)
check_for_error(error_code)
def ai_couplings(self):
"""
List[:class:`nidaqmx.constants.Coupling`]: Indicates the
coupling types supported by this device.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDevAICouplings
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return enum_bitfield_to_list(
val.value, _CouplingTypes, Coupling)
def ai_trig_usage(self):
"""
List[:class:`nidaqmx.constants.TriggerUsage`]: Indicates the
triggers supported by this device for an analog input task.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDevAITrigUsage
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return enum_bitfield_to_list(
val.value, _TriggerUsageTypes, TriggerUsage)
def ao_trig_usage(self):
"""
List[:class:`nidaqmx.constants.TriggerUsage`]: Indicates the
triggers supported by this device for analog output tasks.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDevAOTrigUsage
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return enum_bitfield_to_list(
val.value, _TriggerUsageTypes, TriggerUsage)
def bus_type(self):
"""
:class:`nidaqmx.constants.BusType`: Indicates the bus type of
the device.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDevBusType
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return BusType(val.value)
def co_trig_usage(self):
"""
List[:class:`nidaqmx.constants.TriggerUsage`]: Indicates the
triggers supported by this device for counter output tasks.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDevCOTrigUsage
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return enum_bitfield_to_list(
val.value, _TriggerUsageTypes, TriggerUsage)
def di_trig_usage(self):
"""
List[:class:`nidaqmx.constants.TriggerUsage`]: Indicates the
triggers supported by this device for digital input tasks.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDevDITrigUsage
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return enum_bitfield_to_list(
val.value, _TriggerUsageTypes, TriggerUsage)
def do_trig_usage(self):
"""
List[:class:`nidaqmx.constants.TriggerUsage`]: Indicates the
triggers supported by this device for digital output tasks.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDevDOTrigUsage
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return enum_bitfield_to_list(
val.value, _TriggerUsageTypes, TriggerUsage)
def product_category(self):
"""
:class:`nidaqmx.constants.ProductCategory`: Indicates the
product category of the device. This category corresponds to
the category displayed in MAX when creating NI-DAQmx
simulated devices.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDevProductCategory
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._name, ctypes.byref(val))
check_for_error(error_code)
return ProductCategory(val.value)
def control(self, action):
"""
Alters the state of a task according to the action you specify.
Args:
action (nidaqmx.constants.TaskMode): Specifies how to alter
the task state.
"""
cfunc = lib_importer.windll.DAQmxTaskControl
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_int]
error_code = cfunc(
self._handle, action.value)
check_for_error(error_code)
def anlg_lvl_coupling(self):
"""
:class:`nidaqmx.constants.Coupling`: Specifies the coupling for
the source signal of the trigger if the source is a terminal
rather than a virtual channel.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetAnlgLvlPauseTrigCoupling
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return Coupling(val.value)
def anlg_lvl_when(self):
"""
:class:`nidaqmx.constants.ActiveLevel`: Specifies whether the
task pauses above or below the threshold you specify with
**anlg_lvl_lvl**.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetAnlgLvlPauseTrigWhen
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return ActiveLevel(val.value)
def anlg_win_when(self):
"""
:class:`nidaqmx.constants.WindowTriggerCondition2`: Specifies
whether the task pauses while the trigger signal is inside
or outside the window you specify with **anlg_win_btm** and
**anlg_win_top**.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetAnlgWinPauseTrigWhen
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return WindowTriggerCondition2(val.value)
def dig_lvl_when(self):
"""
:class:`nidaqmx.constants.Level`: Specifies whether the task
pauses while the signal is high or low.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDigLvlPauseTrigWhen
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return Level(val.value)
def trig_type(self):
"""
:class:`nidaqmx.constants.TriggerType`: Specifies the type of
trigger to use to pause a task.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetPauseTrigType
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return TriggerType(val.value)
def interlocked_asserted_lvl(self):
"""
:class:`nidaqmx.constants.Level`: Specifies the asserted level
of the Handshake Trigger.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetInterlockedHshkTrigAssertedLvl
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return Level(val.value)
def dig_edge_edge(self):
"""
:class:`nidaqmx.constants.Edge`: Specifies on which edge of a
digital signal to arm the task for a Start Trigger.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetDigEdgeArmStartTrigEdge
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return Edge(val.value)
def trig_type(self):
"""
:class:`nidaqmx.constants.TriggerType`: Specifies the type of
trigger to use to arm the task for a Start Trigger. If you
configure an Arm Start Trigger, the task does not respond to
a Start Trigger until the device receives the Arm Start
Trigger.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetArmStartTrigType
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return TriggerType(val.value)
def anlg_edge_slope(self):
"""
:class:`nidaqmx.constants.Slope`: Specifies on which slope of
the source signal the Reference Trigger occurs.
"""
val = ctypes.c_int()
cfunc = lib_importer.windll.DAQmxGetAnlgEdgeRefTrigSlope
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.POINTER(ctypes.c_int)]
error_code = cfunc(
self._handle, ctypes.byref(val))
check_for_error(error_code)
return Slope(val.value)