diff --git a/generated/nidaqmx/system/device.py b/generated/nidaqmx/system/device.py index e7bd300ff..35bb1e183 100644 --- a/generated/nidaqmx/system/device.py +++ b/generated/nidaqmx/system/device.py @@ -136,7 +136,7 @@ def do_ports(self): @property def ext_cal_last_date_and_time(self): """ - Indicates the last date and time that the device underwent an + datetime: Indicates the last date and time that the device underwent an external calibration. """ @@ -153,7 +153,7 @@ def ext_cal_last_date_and_time(self): @property def self_cal_last_date_and_time(self): """ - Indicates the last date and time that the device underwent a + datetime: Indicates the last date and time that the device underwent a self-calibration. """ diff --git a/src/codegen/metadata/functions.py b/src/codegen/metadata/functions.py index 7e2d2c859..20e8d7175 100644 --- a/src/codegen/metadata/functions.py +++ b/src/codegen/metadata/functions.py @@ -12964,6 +12964,11 @@ 'GetCalInfoAttributeBool': { 'calling_convention': 'Cdecl', 'cname': 'DAQmxGetCalInfoAttribute', + 'handle_parameter': { + 'ctypes_data_type': 'ctypes.c_char_p', + 'cvi_name': 'deviceName', + 'python_accessor': 'self._name' + }, 'parameters': [ { 'ctypes_data_type': 'ctypes.c_char_p', @@ -12995,6 +13000,11 @@ 'GetCalInfoAttributeDouble': { 'calling_convention': 'Cdecl', 'cname': 'DAQmxGetCalInfoAttribute', + 'handle_parameter': { + 'ctypes_data_type': 'ctypes.c_char_p', + 'cvi_name': 'deviceName', + 'python_accessor': 'self._name' + }, 'parameters': [ { 'ctypes_data_type': 'ctypes.c_char_p', @@ -13026,6 +13036,11 @@ 'GetCalInfoAttributeString': { 'calling_convention': 'Cdecl', 'cname': 'DAQmxGetCalInfoAttribute', + 'handle_parameter': { + 'ctypes_data_type': 'ctypes.c_char_p', + 'cvi_name': 'deviceName', + 'python_accessor': 'self._name' + }, 'parameters': [ { 'ctypes_data_type': 'ctypes.c_char_p', @@ -13068,6 +13083,11 @@ 'GetCalInfoAttributeUInt32': { 'calling_convention': 'Cdecl', 'cname': 'DAQmxGetCalInfoAttribute', + 'handle_parameter': { + 'ctypes_data_type': 'ctypes.c_char_p', + 'cvi_name': 'deviceName', + 'python_accessor': 'self._name' + }, 'parameters': [ { 'ctypes_data_type': 'ctypes.c_char_p', @@ -20795,6 +20815,11 @@ 'SetCalInfoAttributeBool': { 'calling_convention': 'Cdecl', 'cname': 'DAQmxSetCalInfoAttribute', + 'handle_parameter': { + 'ctypes_data_type': 'ctypes.c_char_p', + 'cvi_name': 'deviceName', + 'python_accessor': 'self._name' + }, 'parameters': [ { 'ctypes_data_type': 'ctypes.c_char_p', @@ -20826,6 +20851,11 @@ 'SetCalInfoAttributeDouble': { 'calling_convention': 'Cdecl', 'cname': 'DAQmxSetCalInfoAttribute', + 'handle_parameter': { + 'ctypes_data_type': 'ctypes.c_char_p', + 'cvi_name': 'deviceName', + 'python_accessor': 'self._name' + }, 'parameters': [ { 'ctypes_data_type': 'ctypes.c_char_p', @@ -20857,6 +20887,11 @@ 'SetCalInfoAttributeString': { 'calling_convention': 'Cdecl', 'cname': 'DAQmxSetCalInfoAttribute', + 'handle_parameter': { + 'ctypes_data_type': 'ctypes.c_char_p', + 'cvi_name': 'deviceName', + 'python_accessor': 'self._name' + }, 'parameters': [ { 'ctypes_data_type': 'ctypes.c_char_p', @@ -20888,6 +20923,11 @@ 'SetCalInfoAttributeUInt32': { 'calling_convention': 'Cdecl', 'cname': 'DAQmxSetCalInfoAttribute', + 'handle_parameter': { + 'ctypes_data_type': 'ctypes.c_char_p', + 'cvi_name': 'deviceName', + 'python_accessor': 'self._name' + }, 'parameters': [ { 'ctypes_data_type': 'ctypes.c_char_p', diff --git a/src/codegen/templates/system/device.py.mako b/src/codegen/templates/system/device.py.mako index f44331a60..97e2313e1 100644 --- a/src/codegen/templates/system/device.py.mako +++ b/src/codegen/templates/system/device.py.mako @@ -145,7 +145,7 @@ class Device: @property def ext_cal_last_date_and_time(self): """ - Indicates the last date and time that the device underwent an + datetime: Indicates the last date and time that the device underwent an external calibration. """ @@ -162,7 +162,7 @@ class Device: @property def self_cal_last_date_and_time(self): """ - Indicates the last date and time that the device underwent a + datetime: Indicates the last date and time that the device underwent a self-calibration. """ diff --git a/tests/component/system/test_device.py b/tests/component/system/test_device.py index 9abdf8feb..e76df6f1c 100644 --- a/tests/component/system/test_device.py +++ b/tests/component/system/test_device.py @@ -35,9 +35,9 @@ 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() +def test___restore_last_ext_cal_const___no_errors(sim_x_series_device: Device) -> None: + sim_x_series_device.restore_last_ext_cal_const() -def test___restore_last_ext_cal_const___no_errors(any_x_series_device: Device) -> None: - any_x_series_device.restore_last_ext_cal_const() +def test___self_cal___no_errors(sim_x_series_device: Device) -> None: + sim_x_series_device.self_cal() diff --git a/tests/component/system/test_device_properties.py b/tests/component/system/test_device_properties.py index d8d54fabe..97c8d45cc 100644 --- a/tests/component/system/test_device_properties.py +++ b/tests/component/system/test_device_properties.py @@ -1,5 +1,6 @@ import pytest +from datetime import datetime from nidaqmx import DaqError from nidaqmx.constants import BusType, TriggerUsage from nidaqmx.error_codes import DAQmxErrors @@ -114,68 +115,93 @@ def test___module___get_chassis___shared_interpreter(device: Device): assert chassis._interpreter is device._interpreter -def test___ext_cal_last_date_and_time___no_errors(any_x_series_device: Device) -> None: - last_date_and_time = any_x_series_device.ext_cal_last_date_and_time +def test___ext_cal_last_date_and_time___no_errors(real_x_series_device: Device) -> None: + last_date_and_time = real_x_series_device.ext_cal_last_date_and_time - assert last_date_and_time is not None + assert type(last_date_and_time) == datetime + assert last_date_and_time.year > 2009 + assert last_date_and_time.month >= 1 + assert last_date_and_time.day > 0 + assert last_date_and_time.hour >= 0 + assert last_date_and_time.minute >= 0 -def test___self_cal_last_date_and_time___no_errors(any_x_series_device: Device) -> None: - last_date_and_time = any_x_series_device.self_cal_last_date_and_time +def test___self_cal_last_date_and_time___no_errors(real_x_series_device: Device) -> None: + last_date_and_time = real_x_series_device.self_cal_last_date_and_time - assert last_date_and_time is not None + assert type(last_date_and_time) == datetime + assert last_date_and_time.year > 2009 + assert last_date_and_time.month >= 1 + assert last_date_and_time.day > 0 + assert last_date_and_time.hour >= 0 + assert last_date_and_time.minute >= 0 -def test___device_supports_cal___no_errors(any_x_series_device: Device) -> None: - is_cal_supported = any_x_series_device.device_supports_cal +def test___device_supports_cal___no_errors(real_x_series_device: Device) -> None: + is_cal_supported = real_x_series_device.device_supports_cal assert is_cal_supported is True -def test___cal_acc_connection_count___no_errors(any_x_series_device: Device) -> None: - test_value = 99 +def test___cal_acc_connection_count__raises_attr_not_supported(any_x_series_device: Device) -> None: + with pytest.raises(DaqError) as exc_info: + _ = any_x_series_device.cal_acc_connection_count - try: - current_acc_connection_count = any_x_series_device.cal_acc_connection_count + assert exc_info.value.error_code == DAQmxErrors.ATTR_NOT_SUPPORTED - any_x_series_device.cal_acc_connection_count = test_value - assert test_value == any_x_series_device.cal_acc_connection_count - any_x_series_device.cal_acc_connection_count = current_acc_connection_count +def test___cal_recommended_acc_connection_count_limit___raises_attr_not_supported( + any_x_series_device: Device, +) -> None: + with pytest.raises(DaqError) as exc_info: + _ = any_x_series_device.cal_recommended_acc_connection_count_limit - except DaqError as e: - if e.error_code != DAQmxErrors.ATTR_NOT_SUPPORTED: - raise + assert exc_info.value.error_code == DAQmxErrors.ATTR_NOT_SUPPORTED -def test___cal_dev_temp___no_errors(any_x_series_device: Device) -> None: - temperature = any_x_series_device.cal_dev_temp +@pytest.fixture() +def get_cal_user_defined_info(real_x_series_device: Device): + user_defined_info = real_x_series_device.cal_user_defined_info - assert 0.0 != temperature +def test___set_cal_user_defined_info___no_errors(real_x_series_device: Device) -> None: + user_defined_info = real_x_series_device.cal_user_defined_info + info_max_size = real_x_series_device.cal_user_defined_info_max_size + test_value = "my test value"[:info_max_size] + real_x_series_device.cal_user_defined_info = test_value + value = real_x_series_device.cal_user_defined_info -def test___cal_recommended_acc_connection_count_limit___no_errors( - any_x_series_device: Device, -) -> None: - try: - acc_connection_count_limit = any_x_series_device.cal_recommended_acc_connection_count_limit - print(f"current_acc_connection_count_limit: {acc_connection_count_limit}") + assert info_max_size == len(value) + assert value in test_value - assert 0.0 != acc_connection_count_limit + real_x_series_device.cal_user_defined_info = user_defined_info - except DaqError as e: - if e.error_code != DAQmxErrors.ATTR_NOT_SUPPORTED: - raise +def test___cal_dev_temp___no_errors(sim_x_series_device: Device) -> None: + temperature = sim_x_series_device.cal_dev_temp -def test___cal_user_defined_info___no_errors(any_x_series_device: Device) -> None: - test_value = "my test value" - user_defined_info = any_x_series_device.cal_user_defined_info - info_max_size = any_x_series_device.cal_user_defined_info_max_size + assert 0.0 == temperature - any_x_series_device.cal_user_defined_info = test_value - value = any_x_series_device.cal_user_defined_info - assert info_max_size == len(value) - assert value in test_value - any_x_series_device.cal_user_defined_info = user_defined_info +def test___ext_cal_last_temp___no_errors(sim_x_series_device: Device) -> None: + temperature = sim_x_series_device.ext_cal_last_temp + + assert 0.0 == temperature + + +def test___ext_cal_recommended_interval___no_errors(sim_x_series_device: Device) -> None: + interval = sim_x_series_device.ext_cal_recommended_interval + + assert 24 == interval + + +def test___self_cal_last_temp___no_errors(sim_x_series_device: Device) -> None: + temperature = sim_x_series_device.self_cal_last_temp + + assert 0.0 == temperature + + +def test___self_cal_supported___no_errors(any_x_series_device: Device) -> None: + is_cal_supported = any_x_series_device.self_cal_supported + + assert is_cal_supported is True