Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enabled support for DAQmxSelfCal #460

Merged
merged 13 commits into from
Dec 19, 2023
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ All notable changes to this project will be documented in this file.
## 0.9.0

* ### Merged Pull Requests
* ...
* [460: enabled support for DAQmxSelfCal](https://github.com/ni/nidaqmx-python/pull/460)
* ### Major Changes
* `nidaqmx.errors.DaqNotFoundError`, `nidaqmx.errors.DaqNotSupportedError`, and
`nidaqmx.errors.DaqFunctionNotSupportedError` are now public exceptions.
Expand Down
4 changes: 4 additions & 0 deletions generated/nidaqmx/_base_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,10 @@ def save_scale(self, scale_name, save_as, author, options):
def save_task(self, task, save_as, author, options):
raise NotImplementedError

@abc.abstractmethod
def self_cal(self, device_name):
raise NotImplementedError
zhindes marked this conversation as resolved.
Show resolved Hide resolved

@abc.abstractmethod
def self_test_device(self, device_name):
raise NotImplementedError
Expand Down
5 changes: 5 additions & 0 deletions generated/nidaqmx/_grpc_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2758,6 +2758,11 @@ def save_task(self, task, save_as, author, options):
task=task, save_as=save_as, author=author,
options_raw=options))

def self_cal(self, device_name):
response = self._invoke(
self._client.SelfCal,
grpc_types.SelfCalRequest(device_name=device_name))

def self_test_device(self, device_name):
response = self._invoke(
self._client.SelfTestDevice,
Expand Down
12 changes: 12 additions & 0 deletions generated/nidaqmx/_library_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4632,6 +4632,18 @@ def save_task(self, task, save_as, author, options):
task, save_as, author, options)
self.check_for_error(error_code)

def self_cal(self, device_name):
zhindes marked this conversation as resolved.
Show resolved Hide resolved
cfunc = lib_importer.windll.DAQmxSelfCal
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
ctypes_byte_str]

error_code = cfunc(
device_name)
self.check_for_error(error_code)

def self_test_device(self, device_name):
cfunc = lib_importer.windll.DAQmxSelfTestDevice
if cfunc.argtypes is None:
Expand Down
12 changes: 12 additions & 0 deletions generated/nidaqmx/system/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,18 @@ def reset_device(self):
self._interpreter.reset_device(
self._name)

def self_cal(self):
"""
Measures the onboard reference voltage of the device and adjusts
the self-calibration constants to account for any errors caused
by short-term fluctuations in the operating environment. When
you self-calibrate a device, no external signal connections are
necessary.
"""

self._interpreter.self_cal(
self._name)

def self_test_device(self):
"""
Performs a brief test of device resources. If a failure occurs,
Expand Down
113 changes: 92 additions & 21 deletions src/codegen/metadata/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12518,13 +12518,23 @@
'calling_convention': 'StdCall',
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
'direction': 'in',
'is_optional_in_python': False,
'name': 'deviceName',
'python_data_type': 'str',
'python_description': '',
'python_type_annotation': 'str',
'type': 'const char[]'
},
{
'ctypes_data_type': 'c_bool32',
'direction': 'out',
'is_optional_in_python': False,
'name': 'calSupported',
'python_data_type': 'bool',
'python_description': '',
'python_type_annotation': 'bool',
'type': 'bool32'
}
],
Expand Down Expand Up @@ -15391,33 +15401,63 @@
'calling_convention': 'StdCall',
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
'direction': 'in',
'is_optional_in_python': False,
'name': 'deviceName',
'python_data_type': 'str',
'python_description': '',
'python_type_annotation': 'str',
'type': 'const char[]'
},
{
'ctypes_data_type': 'ctypes.c_uint',
'direction': 'out',
'is_optional_in_python': False,
'name': 'year',
'python_data_type': 'int',
'python_description': '',
'python_type_annotation': 'int',
'type': 'uInt32'
},
{
'ctypes_data_type': 'ctypes.c_uint',
'direction': 'out',
'is_optional_in_python': False,
'name': 'month',
'python_data_type': 'int',
'python_description': '',
'python_type_annotation': 'int',
'type': 'uInt32'
},
{
'ctypes_data_type': 'ctypes.c_uint',
'direction': 'out',
'is_optional_in_python': False,
'name': 'day',
'python_data_type': 'int',
'python_description': '',
'python_type_annotation': 'int',
'type': 'uInt32'
},
{
'ctypes_data_type': 'ctypes.c_uint',
'direction': 'out',
'is_optional_in_python': False,
'name': 'hour',
'python_data_type': 'int',
'python_description': '',
'python_type_annotation': 'int',
'type': 'uInt32'
},
{
'ctypes_data_type': 'ctypes.c_uint',
'direction': 'out',
'is_optional_in_python': False,
'name': 'minute',
'python_data_type': 'int',
'python_description': '',
'python_type_annotation': 'int',
'type': 'uInt32'
}
],
Expand Down Expand Up @@ -17146,7 +17186,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadAnalogScalarF64': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -17291,7 +17332,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadBinaryI32': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -17385,7 +17427,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadBinaryU16': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -17480,7 +17523,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadBinaryU32': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -17574,7 +17618,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadCounterF64': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -17657,7 +17702,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadCounterF64Ex': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -17751,7 +17797,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadCounterScalarF64': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -17934,7 +17981,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadCounterU32Ex': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -18028,7 +18076,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadCtrFreq': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -18134,7 +18183,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadCtrFreqScalar': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -18298,7 +18348,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadCtrTicksScalar': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -18464,7 +18515,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadCtrTimeScalar': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -18626,7 +18678,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadDigitalScalarU32': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -18771,7 +18824,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadDigitalU32': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -18865,7 +18919,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadDigitalU8': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -18959,7 +19014,8 @@
}
],
'python_codegen_method': 'CustomCode',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadPowerBinaryI16': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -19026,7 +19082,8 @@
}
],
'python_codegen_method': 'no',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadPowerF64': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -19091,7 +19148,8 @@
}
],
'python_codegen_method': 'no',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'ReadPowerScalarF64': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -19243,7 +19301,8 @@
}
],
'python_codegen_method': 'no',
'returns': 'int32'
'returns': 'int32',
'timeout_error': 'DAQmxErrorSamplesNotYetAvailable'
},
'RegisterDoneEvent': {
'calling_convention': 'StdCall',
Expand Down Expand Up @@ -20069,14 +20128,26 @@
},
'SelfCal': {
'calling_convention': 'StdCall',
'handle_parameter': {
'ctypes_data_type': 'ctypes.c_char_p',
'cvi_name': 'deviceName',
'python_accessor': 'self._name'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.c_char_p',
'direction': 'in',
'is_optional_in_python': False,
'name': 'deviceName',
'type': 'const char[]'
'python_data_type': 'str',
'python_description': '',
'python_type_annotation': 'str',
'type': 'const char[]',
'use_in_python_api': False
}
],
'python_codegen_method': 'no',
'python_class_name': 'Device',
'python_description': 'Measures the onboard reference voltage of the device and adjusts the self-calibration constants to account for any errors caused by short-term fluctuations in the operating environment. When you self-calibrate a device, no external signal connections are necessary.',
'returns': 'int32'
},
'SelfTestDevice': {
Expand Down
1 change: 0 additions & 1 deletion src/codegen/utilities/interpreter_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"GetCalInfoAttributeString",
"GetCalInfoAttributeUInt32",
"GetSelfCalLastDateAndTime",
"SelfCal",
"SetCalInfoAttributeBool",
"SetCalInfoAttributeDouble",
"SetCalInfoAttributeString",
Expand Down
4 changes: 4 additions & 0 deletions tests/component/system/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ def test___devices_with_different_names___hash___not_equal(init_kwargs):

def test___self_test_device___no_errors(any_x_series_device: Device) -> None:
any_x_series_device.self_test_device()


def test___self_cal___no_errors(any_x_series_device: Device) -> None:
any_x_series_device.self_cal()
Loading