nidaqmx-python
nidaqmx-python copied to clipboard
Expose `task.in_stream.channels_to_read = "temp0:4"` as `task.in_stream["temp0:4"]`
In discussing another NI API, the idea of indexing calls besides configuration came up. I then was considering where it'd even make sense within DAQmx. Reading is one case.
The downside is that the python API is built on top of the C API.
Option 1 for implementing this:
def read(self, ...):
if self._channels_to_read:
backup = task.in_stream.channels_to_read
task.in_stream.channels_to_read = self._channels_to_read
try:
... read ...
except:
task.in_stream.channels_to_read = backup
raise
else:
... read ...
This isn't very thread safe but I don't know if the python API has been focusing on thread safety or not.
Option 2 for implementing this
# In one of the Readers
def __init__(self, ...):
task.in_stream.channels_to_read = channels_to_read
- This doesn't have a good auto-restore once done with the Reader
- This doesn't allow interleaved Readers (should we?)