1+ from __future__ import annotations
2+
3+ from typing import Any , Sequence
4+
5+ from nitypes .waveform import DigitalWaveform
6+
7+ from nidaqmx ._feature_toggles import WAVEFORM_SUPPORT , requires_feature
18from nidaqmx .constants import FillMode
29from nidaqmx .stream_writers ._channel_writer_base import (
310 AUTO_START_UNSET ,
@@ -9,7 +16,7 @@ class DigitalMultiChannelWriter(ChannelWriterBase):
916 """Writes samples to one or more digital output channels in an NI-DAQmx task."""
1017
1118 def write_many_sample_port_byte (self , data , timeout = 10.0 ):
12- """Writes one or more 8-bit unsigned integer samples to one or more digital output channels in a task.
19+ """Writes 8-bit unsigned integer samples to one or more digital output channels in a task.
1320
1421 Use this method for devices with up to 8 lines per port.
1522
@@ -47,7 +54,7 @@ def write_many_sample_port_byte(self, data, timeout=10.0):
4754
4855 Specifies the actual number of samples this method
4956 successfully wrote to each channel in the task.
50- """ # noqa: W505 - doc line too long (110 > 100 characters) (auto-generated noqa)
57+ """
5158 self ._verify_array (data , True , True )
5259
5360 auto_start = self ._auto_start if self ._auto_start is not AUTO_START_UNSET else False
@@ -57,7 +64,7 @@ def write_many_sample_port_byte(self, data, timeout=10.0):
5764 )
5865
5966 def write_many_sample_port_uint16 (self , data , timeout = 10.0 ):
60- """Writes one or more 16-bit unsigned integer samples to one or more digital output channels in a task.
67+ """Writes 16-bit unsigned integer samples to one or more digital output channels in a task.
6168
6269 Use this method for devices with up to 16 lines per port.
6370
@@ -95,7 +102,7 @@ def write_many_sample_port_uint16(self, data, timeout=10.0):
95102
96103 Specifies the actual number of samples this method
97104 successfully wrote to each channel in the task.
98- """ # noqa: W505 - doc line too long (111 > 100 characters) (auto-generated noqa)
105+ """
99106 self ._verify_array (data , True , True )
100107
101108 auto_start = self ._auto_start if self ._auto_start is not AUTO_START_UNSET else False
@@ -105,7 +112,7 @@ def write_many_sample_port_uint16(self, data, timeout=10.0):
105112 )
106113
107114 def write_many_sample_port_uint32 (self , data , timeout = 10.0 ):
108- """Writes one or more 32-bit unsigned integer samples to one or more digital output channels in a task.
115+ """Writes 32-bit unsigned integer samples to one or more digital output channels in a task.
109116
110117 Use this method for devices with up to 32 lines per port.
111118
@@ -143,7 +150,7 @@ def write_many_sample_port_uint32(self, data, timeout=10.0):
143150
144151 Specifies the actual number of samples this method
145152 successfully wrote to each channel in the task.
146- """ # noqa: W505 - doc line too long (111 > 100 characters) (auto-generated noqa)
153+ """
147154 self ._verify_array (data , True , True )
148155
149156 auto_start = self ._auto_start if self ._auto_start is not AUTO_START_UNSET else False
@@ -219,7 +226,7 @@ def write_one_sample_one_line(self, data, timeout=10):
219226 )
220227
221228 def write_one_sample_port_byte (self , data , timeout = 10 ):
222- """Writes a single 8-bit unsigned integer sample to one or more digital output channels in a task .
229+ """Writes a single 8-bit unsigned integer sample to one or more digital output channels.
223230
224231 Use this method for devices with up to 8 lines per port.
225232
@@ -242,7 +249,7 @@ def write_one_sample_port_byte(self, data, timeout=10):
242249 once to write the submitted samples. If the method could
243250 not write all the submitted samples, it returns an error
244251 and the number of samples successfully written.
245- """ # noqa: W505 - doc line too long (106 > 100 characters) (auto-generated noqa)
252+ """
246253 self ._verify_array (data , True , False )
247254
248255 auto_start = self ._auto_start if self ._auto_start is not AUTO_START_UNSET else True
@@ -252,7 +259,7 @@ def write_one_sample_port_byte(self, data, timeout=10):
252259 )
253260
254261 def write_one_sample_port_uint16 (self , data , timeout = 10 ):
255- """Writes a single 16-bit unsigned integer sample to one or more digital output channels in a task .
262+ """Writes a single 16-bit unsigned integer sample to one or more digital output channels.
256263
257264 Use this method for devices with up to 16 lines per port.
258265
@@ -275,7 +282,7 @@ def write_one_sample_port_uint16(self, data, timeout=10):
275282 once to write the submitted samples. If the method could
276283 not write all the submitted samples, it returns an error
277284 and the number of samples successfully written.
278- """ # noqa: W505 - doc line too long (107 > 100 characters) (auto-generated noqa)
285+ """
279286 self ._verify_array (data , True , False )
280287
281288 auto_start = self ._auto_start if self ._auto_start is not AUTO_START_UNSET else True
@@ -285,7 +292,7 @@ def write_one_sample_port_uint16(self, data, timeout=10):
285292 )
286293
287294 def write_one_sample_port_uint32 (self , data , timeout = 10 ):
288- """Writes a single 32-bit unsigned integer sample to one or more digital output channels in a task .
295+ """Writes a single 32-bit unsigned integer sample to one or more digital output channels.
289296
290297 Use this method for devices with up to 32 lines per port.
291298
@@ -308,11 +315,51 @@ def write_one_sample_port_uint32(self, data, timeout=10):
308315 once to write the submitted samples. If the method could
309316 not write all the submitted samples, it returns an error
310317 and the number of samples successfully written.
311- """ # noqa: W505 - doc line too long (107 > 100 characters) (auto-generated noqa)
318+ """
312319 self ._verify_array (data , True , False )
313320
314321 auto_start = self ._auto_start if self ._auto_start is not AUTO_START_UNSET else True
315322
316323 return self ._interpreter .write_digital_u32 (
317324 self ._handle , 1 , auto_start , timeout , FillMode .GROUP_BY_CHANNEL .value , data
318325 )
326+
327+ @requires_feature (WAVEFORM_SUPPORT )
328+ def write_waveforms (
329+ self , waveforms : Sequence [DigitalWaveform [Any ]], timeout : float = 10.0
330+ ) -> int :
331+ """Writes waveforms to one or more digital output channels in a task.
332+
333+ If the task uses on-demand timing, this method returns only
334+ after the device generates all samples. On-demand is the default
335+ timing type if you do not use the timing property on the task to
336+ configure a sample timing type. If the task uses any timing type
337+ other than on-demand, this method returns immediately and does
338+ not wait for the device to generate all samples. Your
339+ application must determine if the task is done to ensure that
340+ the device generated all samples.
341+
342+ Args:
343+ waveforms (Sequence[DigitalWaveform[Any]]): Specifies the
344+ waveforms to write to the task.
345+ timeout (Optional[float]): Specifies the amount of time in
346+ seconds to wait for the method to write all samples.
347+ NI-DAQmx performs a timeout check only if the method
348+ must wait before it writes data. This method returns an
349+ error if the time elapses. The default timeout is 10
350+ seconds. If you set timeout to
351+ nidaqmx.constants.WAIT_INFINITELY, the method waits
352+ indefinitely. If you set timeout to 0, the method tries
353+ once to write the submitted samples. If the method could
354+ not write all the submitted samples, it returns an error
355+ and the number of samples successfully written.
356+
357+ Returns:
358+ int: Specifies the actual number of samples per channel this method
359+ successfully wrote.
360+ """
361+ auto_start = self ._auto_start if self ._auto_start is not AUTO_START_UNSET else False
362+
363+ return self ._interpreter .write_digital_waveforms (
364+ self ._handle , waveforms , auto_start , timeout
365+ )
0 commit comments