-
Notifications
You must be signed in to change notification settings - Fork 188
Closed
Description
When you call add_di_chan or add_do_chan with name_to_assign_to_lines!="" and line_grouping==CHAN_FOR_ALL_LINES, two things happen:
- The channel collection passes name_to_assign_to_lines to the DAQmx C API, which honors the user's requested channel name.
- The channel collection ignores name_to_assign_to_lines when returning a channel object for the newly created channel. Instead, it uses the physical channel names (lines). This works when accessing line-based DI/DO properties but not channel-based DI/DO properties.
Example:
import nidaqmx
from nidaqmx.constants import LineGrouping
with nidaqmx.Task() as task:
chan = task.di_channels.add_di_chan("Dev1/port0/line0:7", line_grouping=LineGrouping.CHAN_PER_LINE)
print("CHAN_PER_LINE, no name:", chan.name, repr(task.di_channels.channel_names))
with nidaqmx.Task() as task:
chan = task.di_channels.add_di_chan("Dev1/port0/line0:7", "MyChan", line_grouping=LineGrouping.CHAN_PER_LINE)
print("CHAN_PER_LINE, MyChan", chan.name, repr(task.di_channels.channel_names))
with nidaqmx.Task() as task:
chan = task.di_channels.add_di_chan("Dev1/port0/line0:7", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES)
print("CHAN_FOR_ALL_LINES, no name", chan.name, repr(task.di_channels.channel_names))
with nidaqmx.Task() as task:
chan = task.di_channels.add_di_chan("Dev1/port0/line0:7", "MyChan", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES)
print("CHAN_FOR_ALL_LINES, MyChan:", chan.name, repr(task.di_channels.channel_names))Output:
CHAN_PER_LINE, no name: Dev1/port0/line0:7 ['Dev1/port0/line0', 'Dev1/port0/line1', 'Dev1/port0/line2', 'Dev1/port0/line3', 'Dev1/port0/line4', 'Dev1/port0/line5', 'Dev1/port0/line6', 'Dev1/port0/line7']
CHAN_PER_LINE, MyChan MyChan0:7 ['MyChan0', 'MyChan1', 'MyChan2', 'MyChan3', 'MyChan4', 'MyChan5', 'MyChan6', 'MyChan7']
CHAN_FOR_ALL_LINES, no name Dev1/port0/line0... ['Dev1/port0/line0...']
CHAN_FOR_ALL_LINES, MyChan: Dev1/port0/line0:7 ['MyChan']
Expected output: last line should be
CHAN_FOR_ALL_LINES, MyChan: MyChan ['MyChan']
zhindes
Metadata
Metadata
Assignees
Labels
No labels