nidaqlib.channels¶
nidaqlib.channels ¶
Channel specifications — :class:ChannelSpec and concrete subclasses.
AnalogInputVoltage
dataclass
¶
AnalogInputVoltage(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
min_val=-10.0,
max_val=10.0,
terminal_config=None,
custom_scale_name=None,
)
Bases: ChannelSpec
Voltage analog-input channel.
Maps to Task.ai_channels.add_ai_voltage_chan on the NI side.
Attributes:
| Name | Type | Description |
|---|---|---|
min_val |
float
|
Lower limit of the expected input range, in volts. |
max_val |
float
|
Upper limit of the expected input range, in volts. The NI driver uses the (min, max) range to select the most appropriate on-board gain. |
terminal_config |
TerminalConfiguration | None
|
Terminal configuration (RSE / NRSE / DIFF /
PSEUDO_DIFF). |
custom_scale_name |
str | None
|
Optional name of a pre-configured custom scale
registered in MAX. When set, |
__post_init__ ¶
Validate the voltage range.
Source code in src/nidaqlib/channels/analog_input.py
AnalogOutputVoltage
dataclass
¶
AnalogOutputVoltage(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
min_val=-10.0,
max_val=10.0,
safe_min=None,
safe_max=None,
requires_confirm=True,
terminal_config=None,
custom_scale_name=None,
)
Bases: ChannelSpec
Voltage analog-output channel.
Maps to Task.ao_channels.add_ao_voltage_chan on the NI side. Writes
are gated through :meth:DaqSession.write, which rejects out-of-range
values against safe_min / safe_max and requires
confirm=True whenever any target channel sets
requires_confirm (design doc §17.1).
Attributes:
| Name | Type | Description |
|---|---|---|
min_val |
float
|
Lower bound of the device output range, in volts. |
max_val |
float
|
Upper bound of the device output range, in volts. NI uses
|
safe_min |
float | None
|
Optional lower-end safety clamp for application writes.
|
safe_max |
float | None
|
Optional upper-end safety clamp. |
requires_confirm |
bool
|
When |
terminal_config |
TerminalConfiguration | None
|
Terminal configuration (RSE / DIFF / ...). |
custom_scale_name |
str | None
|
Optional name of a pre-configured custom scale
registered in MAX. When set, |
effective_safe_max
property
¶
Resolved upper clamp — falls back to :attr:max_val.
effective_safe_min
property
¶
Resolved lower clamp — falls back to :attr:min_val.
__post_init__ ¶
Validate the output and safety ranges.
Source code in src/nidaqlib/channels/analog_output.py
ChannelSpec
dataclass
¶
Application-facing description of one DAQ channel.
Attributes:
| Name | Type | Description |
|---|---|---|
physical_channel |
str
|
NI physical channel identifier, e.g. |
name |
str | None
|
Optional friendly name; defaults to the physical channel. |
unit |
str | None
|
Optional engineering unit string ( |
metadata |
Mapping[str, str | int | float | bool]
|
Free-form scalar metadata propagated into emitted records. |
kind
class-attribute
¶
Discriminator used by :meth:from_dict. Concrete subclasses override.
__post_init__ ¶
Validate and freeze common channel metadata.
Source code in src/nidaqlib/channels/base.py
from_dict
classmethod
¶
Deserialise from a dict produced by :meth:to_dict.
On the base class, this dispatches to the registered subclass for the
kind discriminator. On a concrete subclass, this validates that
kind matches and constructs the dataclass directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, Any]
|
Mapping carrying the |
required |
Raises:
| Type | Description |
|---|---|
NIDaqValidationError
|
|
Source code in src/nidaqlib/channels/base.py
to_dict ¶
Serialise to a JSON/TOML-friendly dict, including kind.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dict carrying |
dict[str, Any]
|
copied to plain |
Source code in src/nidaqlib/channels/base.py
CounterEdgeCountInput
dataclass
¶
CounterEdgeCountInput(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
edge=Edge.RISING,
initial_count=0,
count_up=True,
)
Bases: ChannelSpec
Edge-count counter-input channel.
Maps to Task.ci_channels.add_ci_count_edges_chan on the NI side.
Useful for encoders, totalisers, or anything that needs raw edge
accumulation.
Attributes:
| Name | Type | Description |
|---|---|---|
edge |
Edge
|
Edge that increments / decrements the counter. Rising by default. |
initial_count |
int
|
Starting value of the counter. Defaults to 0. |
count_up |
bool
|
When |
__post_init__ ¶
from_dict
classmethod
¶
Deserialise, restoring :class:Edge from its string value.
Source code in src/nidaqlib/channels/counter_input.py
to_dict ¶
Serialise; encode :class:Edge to its string value.
CounterFrequencyInput
dataclass
¶
CounterFrequencyInput(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
min_val,
max_val,
edge=Edge.RISING,
)
Bases: ChannelSpec
Frequency-measurement counter-input channel.
Maps to Task.ci_channels.add_ci_freq_chan on the NI side. NI uses
(min_val, max_val) to choose timebases that resolve frequencies in
the expected range.
Attributes:
| Name | Type | Description |
|---|---|---|
min_val |
float
|
Lower bound of the expected frequency, in Hz. |
max_val |
float
|
Upper bound of the expected frequency, in Hz. |
edge |
Edge
|
Edge of the input signal that increments the counter. Rising by default. |
__post_init__ ¶
Validate the expected frequency range.
Source code in src/nidaqlib/channels/counter_input.py
from_dict
classmethod
¶
Deserialise, restoring :class:Edge from its string value.
Source code in src/nidaqlib/channels/counter_input.py
to_dict ¶
CounterPeriodInput
dataclass
¶
CounterPeriodInput(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
min_val,
max_val,
edge=Edge.RISING,
)
Bases: ChannelSpec
Period-measurement counter-input channel.
Maps to Task.ci_channels.add_ci_period_chan on the NI side.
Attributes:
| Name | Type | Description |
|---|---|---|
min_val |
float
|
Lower bound of the expected period, in seconds. |
max_val |
float
|
Upper bound of the expected period, in seconds. |
edge |
Edge
|
Starting edge of the period measurement. Rising by default. |
__post_init__ ¶
Validate the expected period range.
Source code in src/nidaqlib/channels/counter_input.py
from_dict
classmethod
¶
Deserialise, restoring :class:Edge from its string value.
Source code in src/nidaqlib/channels/counter_input.py
to_dict ¶
Serialise; encode :class:Edge to its string value.
CounterPulseFrequency
dataclass
¶
CounterPulseFrequency(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
frequency,
duty_cycle=0.5,
initial_delay=0.0,
idle_high=False,
requires_confirm=True,
)
Bases: ChannelSpec
Pulse-train counter output specified by frequency + duty cycle.
Maps to Task.co_channels.add_co_pulse_chan_freq on the NI side.
Attributes:
| Name | Type | Description |
|---|---|---|
frequency |
float
|
Pulse-train frequency, in Hz. |
duty_cycle |
float
|
Fractional duty cycle in |
initial_delay |
float
|
Optional delay before the first pulse, in seconds. Defaults to 0. |
idle_high |
bool
|
When |
requires_confirm |
bool
|
When |
__post_init__ ¶
Validate pulse-train parameters.
Source code in src/nidaqlib/channels/counter_output.py
CounterPulseTicks
dataclass
¶
CounterPulseTicks(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
source_terminal,
high_ticks,
low_ticks,
initial_delay=0,
idle_high=False,
requires_confirm=True,
)
Bases: ChannelSpec
Pulse-train counter output specified by high / low tick counts.
Maps to Task.co_channels.add_co_pulse_chan_ticks on the NI side.
The tick reference is given by source_terminal.
Attributes:
| Name | Type | Description |
|---|---|---|
source_terminal |
str
|
NI terminal supplying the tick clock (e.g.
|
high_ticks |
int
|
Number of source ticks in the high state. |
low_ticks |
int
|
Number of source ticks in the low state. |
initial_delay |
int
|
Optional initial-delay tick count. |
idle_high |
bool
|
When |
requires_confirm |
bool
|
Defaults to |
__post_init__ ¶
Validate pulse tick parameters.
Source code in src/nidaqlib/channels/counter_output.py
CounterPulseTime
dataclass
¶
CounterPulseTime(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
high_time,
low_time,
initial_delay=0.0,
idle_high=False,
requires_confirm=True,
)
Bases: ChannelSpec
Pulse-train counter output specified by high / low durations in seconds.
Maps to Task.co_channels.add_co_pulse_chan_time on the NI side.
Attributes:
| Name | Type | Description |
|---|---|---|
high_time |
float
|
High-state duration, in seconds. |
low_time |
float
|
Low-state duration, in seconds. |
initial_delay |
float
|
Optional delay before the first pulse, in seconds. |
idle_high |
bool
|
When |
requires_confirm |
bool
|
Defaults to |
__post_init__ ¶
Validate pulse timing parameters.
Source code in src/nidaqlib/channels/counter_output.py
DigitalInput
dataclass
¶
DigitalInput(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
line_grouping_per_line=True,
)
Bases: ChannelSpec
Digital-input line or port.
Maps to Task.di_channels.add_di_chan on the NI side. physical_channel
accepts NI's line / port grammar (Dev1/port0/line0,
Dev1/port0:7, ...).
Attributes:
| Name | Type | Description |
|---|---|---|
line_grouping_per_line |
bool
|
When |
DigitalOutput
dataclass
¶
DigitalOutput(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
requires_confirm=True,
line_grouping_per_line=True,
)
Bases: ChannelSpec
Digital-output line or port.
Maps to Task.do_channels.add_do_chan on the NI side. Writes are gated
through :meth:DaqSession.write, which requires confirm=True
whenever any target channel sets requires_confirm (design doc §17.1).
Attributes:
| Name | Type | Description |
|---|---|---|
requires_confirm |
bool
|
When |
line_grouping_per_line |
bool
|
When |
ThermocoupleInput
dataclass
¶
ThermocoupleInput(
*,
physical_channel,
name=None,
unit=None,
metadata=_empty_metadata(),
thermocouple_type,
min_val,
max_val,
cjc_source=None,
cjc_val=None,
units=_default_temperature_units(),
)
Bases: ChannelSpec
Thermocouple analog-input channel.
Maps to Task.ai_channels.add_ai_thrmcpl_chan on the NI side. The
enum-typed fields are stored as int values matching
nidaqmx.constants so that to_dict/from_dict round-trips through
JSON without dragging NI's enum machinery into the serialisation layer.
Attributes:
| Name | Type | Description |
|---|---|---|
thermocouple_type |
ThermocoupleType
|
One of |
min_val |
float
|
Lower limit of the expected temperature, in |
max_val |
float
|
Upper limit of the expected temperature, in |
cjc_source |
CJCSource | None
|
Cold-junction compensation source. |
cjc_val |
float | None
|
Cold-junction reference temperature, in |
units |
TemperatureUnits
|
Temperature units for |
__post_init__ ¶
Validate the temperature range.
Source code in src/nidaqlib/channels/analog_input.py
from_dict
classmethod
¶
Reconstruct, restoring enum members from their .value ints.
Source code in src/nidaqlib/channels/analog_input.py
to_dict ¶
Serialise via the enums' .value so the payload is JSON-encodable.
nidaqmx.constants enums do not inherit from :class:int, so we
record .value (an int) and reconstruct the enum on
:meth:from_dict.
Source code in src/nidaqlib/channels/analog_input.py
register_channel_kind ¶
Register a concrete :class:ChannelSpec subclass for dispatch.
Used as a decorator on the subclass definition. Idempotent — re-registering
the same kind is a no-op (helps reload-friendliness in notebooks).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type[C]
|
The subclass to register. Must declare a non-empty |
required |
Returns:
| Type | Description |
|---|---|
type[C]
|
|
Raises:
| Type | Description |
|---|---|
NIDaqValidationError
|
|