Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file.
* ### Resolved Issues
* Fix PEP 660 builds by setting `build-system` to use `poetry-core`
* [579: nidaqmx does not generate numbered virtual channel names correctly](https://github.com/ni/nidaqmx-python/issues/579)
* [692: Cannot set "ai_conv_rate" on NI DAQ 9209 due to missing active device modifier for timing attributes](https://github.com/ni/nidaqmx-python/issues/692)

* ### Major Changes
* Removed the `docs` extra and converted it to a Poetry dependency group.
Expand Down
23 changes: 18 additions & 5 deletions generated/nidaqmx/task/_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ class Timing:
"""
Represents the timing configurations for a DAQmx task.
"""
__slots__ = ('_handle', '_interpreter')
__slots__ = ('_handle', '_interpreter', '_active_devs')

def __init__(self, task_handle, interpreter):
def __init__(self, task_handle, interpreter, active_devs=None):
self._handle = task_handle
self._interpreter = interpreter
self._active_devs = active_devs

def __getitem__(self, dev):
return Timing(self._handle, self._interpreter, active_devs=dev)

@property
def ai_conv_active_edge(self):
Expand Down Expand Up @@ -147,16 +151,25 @@ def ai_conv_rate(self):
input section of multiplexed devices.
"""

val = self._interpreter.get_timing_attribute_double(self._handle, 0x1848)
if self._active_devs:
val = self._interpreter.get_timing_attribute_ex_double(self._handle, self._active_devs, 0x1848)
else:
val = self._interpreter.get_timing_attribute_double(self._handle, 0x1848)
return val

@ai_conv_rate.setter
def ai_conv_rate(self, val):
self._interpreter.set_timing_attribute_double(self._handle, 0x1848, val)
if self._active_devs:
self._interpreter.set_timing_attribute_ex_double(self._handle, self._active_devs, 0x1848, val)
else:
self._interpreter.set_timing_attribute_double(self._handle, 0x1848, val)

@ai_conv_rate.deleter
def ai_conv_rate(self):
self._interpreter.reset_timing_attribute(self._handle, 0x1848)
if self._active_devs:
self._interpreter.reset_timing_attribute_ex(self._handle, self._active_devs, 0x1848)
else:
self._interpreter.reset_timing_attribute(self._handle, 0x1848)

@property
def ai_conv_src(self):
Expand Down
14 changes: 13 additions & 1 deletion src/codegen/templates/property_deleter_template.py.mako
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
<%def name="script_property_deleter(attribute)">\
<%
from codegen.utilities.attribute_helpers import get_generic_attribute_function_name
from codegen.utilities.attribute_helpers import get_generic_attribute_function_name, ACTIVE_DEVS_SUPPORTED_ATTRIBUTES
%>\
@${attribute.name}.deleter
def ${attribute.name}(self):
\
## Script interpreter call.
<%
generic_attribute_func = get_generic_attribute_function_name(attribute)
if attribute.name in ACTIVE_DEVS_SUPPORTED_ATTRIBUTES:
generic_attribute_func_ex = get_generic_attribute_function_name(attribute) + "_ex"
function_call_args = []
for handle_parameter in attribute.handle_parameters:
function_call_args.append(handle_parameter.accessor)
if attribute.python_class_name == "Watchdog":
function_call_args.append("\"\"")
function_call_args.append(hex(attribute.id))
if attribute.name in ACTIVE_DEVS_SUPPORTED_ATTRIBUTES:
function_call_args_ex = function_call_args.copy()
function_call_args_ex.insert(1, "self._active_devs")
%>\
%if attribute.name in ACTIVE_DEVS_SUPPORTED_ATTRIBUTES:
if self._active_devs:
self._interpreter.reset_${generic_attribute_func_ex}(${', '.join(function_call_args_ex)})
else:
self._interpreter.reset_${generic_attribute_func}(${', '.join(function_call_args)})
%else:
self._interpreter.reset_${generic_attribute_func}(${', '.join(function_call_args)})
%endif
</%def>
14 changes: 13 additions & 1 deletion src/codegen/templates/property_getter_template.py.mako
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%def name="script_property_getter(attribute)">\
<%
from codegen.utilities.text_wrappers import docstring_wrap
from codegen.utilities.attribute_helpers import get_generic_attribute_function_name, get_generic_attribute_function_type, ATTRIBUTE_WITH_FILE_PATH_TYPE
from codegen.utilities.attribute_helpers import get_generic_attribute_function_name, get_generic_attribute_function_type, ATTRIBUTE_WITH_FILE_PATH_TYPE, ACTIVE_DEVS_SUPPORTED_ATTRIBUTES
%>\
%if attribute.name in ATTRIBUTE_WITH_FILE_PATH_TYPE:
@property
Expand All @@ -21,6 +21,8 @@
<%
mapped_func_type = get_generic_attribute_function_type(attribute)
generic_attribute_func = get_generic_attribute_function_name(attribute) + "_" + mapped_func_type
if attribute.name in ACTIVE_DEVS_SUPPORTED_ATTRIBUTES:
generic_attribute_func_ex = get_generic_attribute_function_name(attribute) + "_ex" + "_" + mapped_func_type
object_type = attribute.object_type
if attribute.has_alternate_constructor:
object_type = "_" + attribute.object_type + "AlternateConstructor"
Expand All @@ -31,6 +33,9 @@
if attribute.python_class_name == "Watchdog":
function_call_args.append("\"\"")
function_call_args.append(hex(attribute.id))
if attribute.name in ACTIVE_DEVS_SUPPORTED_ATTRIBUTES:
function_call_args_ex = function_call_args.copy()
function_call_args_ex.insert(1, "self._active_devs")
%>
## For read/write string attributes in InStream and OutStream, buffer_size is passed as an argument.
%if attribute.access == "read" or attribute.access == "write":
Expand All @@ -45,7 +50,14 @@
%endif
%endif
\
%if attribute.name in ACTIVE_DEVS_SUPPORTED_ATTRIBUTES:
if self._active_devs:
val = self._interpreter.get_${generic_attribute_func_ex}(${', '.join(function_call_args_ex)})
else:
val = self._interpreter.get_${generic_attribute_func}(${', '.join(function_call_args)})
%else:
val = self._interpreter.get_${generic_attribute_func}(${', '.join(function_call_args)})
%endif
\
## Script return call.
%if attribute.bitfield_enum is not None:
Expand Down
14 changes: 13 additions & 1 deletion src/codegen/templates/property_setter_template.py.mako
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%def name="script_property_setter(attribute)">\
<%
from codegen.utilities.attribute_helpers import get_generic_attribute_function_name, get_generic_attribute_function_type, ATTRIBUTE_WITH_FILE_PATH_TYPE
from codegen.utilities.attribute_helpers import get_generic_attribute_function_name, get_generic_attribute_function_type, ATTRIBUTE_WITH_FILE_PATH_TYPE, ACTIVE_DEVS_SUPPORTED_ATTRIBUTES
%>\
@${attribute.name}.setter
%if attribute.name in ATTRIBUTE_WITH_FILE_PATH_TYPE:
Expand Down Expand Up @@ -34,13 +34,25 @@
<%
mapped_func_type = get_generic_attribute_function_type(attribute)
generic_attribute_func = get_generic_attribute_function_name(attribute) + "_" + mapped_func_type
if attribute.name in ACTIVE_DEVS_SUPPORTED_ATTRIBUTES:
generic_attribute_func_ex = get_generic_attribute_function_name(attribute) + "_ex" + "_" + mapped_func_type
function_call_args = []
for handle_parameter in attribute.handle_parameters:
function_call_args.append(handle_parameter.accessor)
if attribute.python_class_name == "Watchdog":
function_call_args.append("\"\"")
function_call_args.append(hex(attribute.id))
function_call_args.append('val')
if attribute.name in ACTIVE_DEVS_SUPPORTED_ATTRIBUTES:
function_call_args_ex = function_call_args.copy()
function_call_args_ex.insert(1, "self._active_devs")
%>\
%if attribute.name in ACTIVE_DEVS_SUPPORTED_ATTRIBUTES:
if self._active_devs:
self._interpreter.set_${generic_attribute_func_ex}(${', '.join(function_call_args_ex)})
else:
self._interpreter.set_${generic_attribute_func}(${', '.join(function_call_args)})
%else:
self._interpreter.set_${generic_attribute_func}(${', '.join(function_call_args)})
%endif
</%def>
8 changes: 6 additions & 2 deletions src/codegen/templates/task/_timing.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ class Timing:
"""
Represents the timing configurations for a DAQmx task.
"""
__slots__ = ('_handle', '_interpreter')
__slots__ = ('_handle', '_interpreter', '_active_devs')

def __init__(self, task_handle, interpreter):
def __init__(self, task_handle, interpreter, active_devs=None):
self._handle = task_handle
self._interpreter = interpreter
self._active_devs = active_devs

def __getitem__(self, dev):
return Timing(self._handle, self._interpreter, active_devs=dev)

<%namespace name="property_template" file="/property_template.py.mako"/>\
%for attribute in attributes:
Expand Down
4 changes: 4 additions & 0 deletions src/codegen/utilities/attribute_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@

ATTRIBUTE_WITH_FILE_PATH_TYPE = ("logging_file_path",)

ACTIVE_DEVS_SUPPORTED_ATTRIBUTES = [
"ai_conv_rate",
]


def get_attributes(metadata, class_name):
"""Converts the scrapigen metadata into a list of attributes."""
Expand Down