from nidaqmx.constants import FillMode
from nidaqmx.stream_writers._channel_writer_base import (
AUTO_START_UNSET,
ChannelWriterBase,
)
[docs]
class AnalogUnscaledWriter(ChannelWriterBase):
"""Writes unscaled samples to one or more analog output channels in an NI-DAQmx task."""
[docs]
def write_int16(self, data, timeout=10.0):
"""Writes one or more unscaled 16-bit integer samples to one or more analog output channels in a task.
If the task uses on-demand timing, this method returns only
after the device generates all samples. On-demand is the default
timing type if you do not use the timing property on the task to
configure a sample timing type. If the task uses any timing type
other than on-demand, this method returns immediately and does
not wait for the device to generate all samples. Your
application must determine if the task is done to ensure that
the device generated all samples.
Args:
data (numpy.ndarray): Contains a 2D NumPy array of unscaled
16-bit integer samples to write to the task.
Each row corresponds to a channel in the task. Each
column corresponds to a sample to write to each channel.
timeout (Optional[float]): Specifies the amount of time in
seconds to wait for the method to write all samples.
NI-DAQmx performs a timeout check only if the method
must wait before it writes data. This method returns an
error if the time elapses. 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 write the submitted samples. If the method could
not write all the submitted samples, it returns an error
and the number of samples successfully written.
Returns:
int:
Specifies the actual number of samples this method
successfully wrote to each channel in the task.
""" # noqa: W505 - doc line too long (110 > 100 characters) (auto-generated noqa)
self._verify_array(data, True, True)
auto_start = self._auto_start if self._auto_start is not AUTO_START_UNSET else False
return self._interpreter.write_binary_i16(
self._handle, data.shape[1], auto_start, timeout, FillMode.GROUP_BY_CHANNEL.value, data
)
[docs]
def write_int32(self, data, timeout=10.0):
"""Writes one or more unscaled 32-bit integer samples to one or more analog output channels in a task.
If the task uses on-demand timing, this method returns only
after the device generates all samples. On-demand is the default
timing type if you do not use the timing property on the task to
configure a sample timing type. If the task uses any timing type
other than on-demand, this method returns immediately and does
not wait for the device to generate all samples. Your
application must determine if the task is done to ensure that
the device generated all samples.
Args:
data (numpy.ndarray): Contains a 2D NumPy array of unscaled
32-bit integer samples to write to the task.
Each row corresponds to a channel in the task. Each
column corresponds to a sample to write to each channel.
timeout (Optional[float]): Specifies the amount of time in
seconds to wait for the method to write all samples.
NI-DAQmx performs a timeout check only if the method
must wait before it writes data. This method returns an
error if the time elapses. 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 write the submitted samples. If the method could
not write all the submitted samples, it returns an error
and the number of samples successfully written.
Returns:
int:
Specifies the actual number of samples this method
successfully wrote to each channel in the task.
""" # noqa: W505 - doc line too long (110 > 100 characters) (auto-generated noqa)
self._verify_array(data, True, True)
auto_start = self._auto_start if self._auto_start is not AUTO_START_UNSET else False
return self._interpreter.write_binary_i32(
self._handle, data.shape[1], auto_start, timeout, FillMode.GROUP_BY_CHANNEL.value, data
)
[docs]
def write_uint16(self, data, timeout=10.0):
"""Writes one or more unscaled 16-bit unsigned integer samples to one or more analog output channels in a task.
If the task uses on-demand timing, this method returns only
after the device generates all samples. On-demand is the default
timing type if you do not use the timing property on the task to
configure a sample timing type. If the task uses any timing type
other than on-demand, this method returns immediately and does
not wait for the device to generate all samples. Your
application must determine if the task is done to ensure that
the device generated all samples.
Args:
data (numpy.ndarray): Contains a 2D NumPy array of unscaled
16-bit unsigned integer samples to write to the task.
Each row corresponds to a channel in the task. Each
column corresponds to a sample to write to each channel.
timeout (Optional[float]): Specifies the amount of time in
seconds to wait for the method to write all samples.
NI-DAQmx performs a timeout check only if the method
must wait before it writes data. This method returns an
error if the time elapses. 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 write the submitted samples. If the method could
not write all the submitted samples, it returns an error
and the number of samples successfully written.
Returns:
int:
Specifies the actual number of samples this method
successfully wrote to each channel in the task.
""" # noqa: W505 - doc line too long (119 > 100 characters) (auto-generated noqa)
self._verify_array(data, True, True)
auto_start = self._auto_start if self._auto_start is not AUTO_START_UNSET else False
return self._interpreter.write_binary_u16(
self._handle, data.shape[1], auto_start, timeout, FillMode.GROUP_BY_CHANNEL.value, data
)
[docs]
def write_uint32(self, data, timeout=10.0):
"""Writes one or more unscaled 32-bit unsigned integer samples to one or more analog output channels in a task.
If the task uses on-demand timing, this method returns only
after the device generates all samples. On-demand is the default
timing type if you do not use the timing property on the task to
configure a sample timing type. If the task uses any timing type
other than on-demand, this method returns immediately and does
not wait for the device to generate all samples. Your
application must determine if the task is done to ensure that
the device generated all samples.
Args:
data (numpy.ndarray): Contains a 2D NumPy array of unscaled
32-bit unsigned integer samples to write to the task.
Each row corresponds to a channel in the task. Each
column corresponds to a sample to write to each channel.
timeout (Optional[float]): Specifies the amount of time in
seconds to wait for the method to write all samples.
NI-DAQmx performs a timeout check only if the method
must wait before it writes data. This method returns an
error if the time elapses. 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 write the submitted samples. If the method could
not write all the submitted samples, it returns an error
and the number of samples successfully written.
Returns:
int:
Specifies the actual number of samples this method
successfully wrote to each channel in the task.
""" # noqa: W505 - doc line too long (119 > 100 characters) (auto-generated noqa)
self._verify_array(data, True, True)
auto_start = self._auto_start if self._auto_start is not AUTO_START_UNSET else False
return self._interpreter.write_binary_u32(
self._handle, data.shape[1], auto_start, timeout, FillMode.GROUP_BY_CHANNEL.value, data
)