diff --git a/CHANGELOG.md b/CHANGELOG.md index a126fc6a3..387e8aba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,11 @@ All notable changes to this project will be documented in this file. * #### Removed * ### `nidmm` (NI-DMM) * #### Added + * New methods for getting calibration information. - [#1462](https://github.com/ni/nimi-python/issues/1462) + * `get_ext_cal_last_date_and_time` + * `get_ext_cal_last_temp` + * `get_self_cal_last_date_and_time` + * `get_self_cal_last_temp` * #### Changed * #### Removed * ### `nifgen` (NI-FGEN) diff --git a/docs/nidmm/class.rst b/docs/nidmm/class.rst index ddda7dcbd..1746af6fe 100644 --- a/docs/nidmm/class.rst +++ b/docs/nidmm/class.rst @@ -1209,6 +1209,52 @@ get_dev_temp +get_ext_cal_last_date_and_time +------------------------------ + + .. py:currentmodule:: nidmm.Session + + .. py:method:: get_ext_cal_last_date_and_time() + + Returns the date and time of the last external calibration performed. + + + + + + :rtype: hightime.datetime + :return: + + + Indicates date and time of the last external calibration. + + + + + +get_ext_cal_last_temp +--------------------- + + .. py:currentmodule:: nidmm.Session + + .. py:method:: get_ext_cal_last_temp() + + Returns the **Temperature** during the last external calibration procedure. + + + + + + :rtype: float + :return: + + + Returns the **temperature** during the last external calibration. + + + + + get_ext_cal_recommended_interval -------------------------------- @@ -1236,45 +1282,47 @@ get_ext_cal_recommended_interval -get_last_cal_temp ------------------ +get_self_cal_last_date_and_time +------------------------------- .. py:currentmodule:: nidmm.Session - .. py:method:: get_last_cal_temp(cal_type) + .. py:method:: get_self_cal_last_date_and_time() - Returns the **Temperature** during the last calibration procedure. + Returns the date and time of the last self calibration performed. - .. note:: The NI 4050 and NI 4060 are not supported. + :rtype: hightime.datetime + :return: - :param cal_type: + Indicates date and time of the last self calibration. - Specifies the type of calibration performed (external or - self-calibration). + - +-----------------------------------------------------+---+----------------------+ - | :py:data:`~nidmm.NIDMM_VAL_INTERNAL_AREA` (default) | 0 | Self-Calibration | - +-----------------------------------------------------+---+----------------------+ - | :py:data:`~nidmm.NIDMM_VAL_EXTERNAL_AREA` | 1 | External Calibration | - +-----------------------------------------------------+---+----------------------+ - .. note:: The NI 4065 does not support self-calibration. - .. note:: One or more of the referenced values are not in the Python API for this driver. Enums that only define values, or represent True/False, have been removed. +get_self_cal_last_temp +---------------------- + + .. py:currentmodule:: nidmm.Session + + .. py:method:: get_self_cal_last_temp() + + Returns the **Temperature** during the last self calibration procedure. + + - :type cal_type: int :rtype: float :return: - Returns the **temperature** during the last calibration. + Returns the **temperature** during the last self calibration. diff --git a/generated/nidmm/nidmm/session.py b/generated/nidmm/nidmm/session.py index 0fc3c823a..9fb86624e 100644 --- a/generated/nidmm/nidmm/session.py +++ b/generated/nidmm/nidmm/session.py @@ -1791,6 +1791,60 @@ def export_attribute_configuration_file(self, file_path): errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return + @ivi_synchronized + def get_ext_cal_last_date_and_time(self): + '''get_ext_cal_last_date_and_time + + Returns the date and time of the last external calibration performed. + + Returns: + last_cal_datetime (hightime.datetime): Indicates date and time of the last external calibration. + + ''' + + month, day, year, hour, minute = self._get_cal_date_and_time(1) + return hightime.datetime(year, month, day, hour, minute) + + @ivi_synchronized + def get_ext_cal_last_temp(self): + '''get_ext_cal_last_temp + + Returns the **Temperature** during the last external calibration procedure. + + Returns: + temperature (float): Returns the **temperature** during the last external calibration. + + ''' + + return self._get_last_cal_temp(1) + + @ivi_synchronized + def get_self_cal_last_date_and_time(self): + '''get_self_cal_last_date_and_time + + Returns the date and time of the last self calibration performed. + + Returns: + last_cal_datetime (hightime.datetime): Indicates date and time of the last self calibration. + + ''' + + month, day, year, hour, minute = self._get_cal_date_and_time(0) + return hightime.datetime(year, month, day, hour, minute) + + @ivi_synchronized + def get_self_cal_last_temp(self): + '''get_self_cal_last_temp + + Returns the **Temperature** during the last self calibration procedure. + + Returns: + temperature (float): Returns the **temperature** during the last self calibration. + + ''' + + return self._get_last_cal_temp(0) + @ivi_synchronized def fetch(self, maximum_time=hightime.timedelta(milliseconds=-1)): r'''fetch @@ -2101,8 +2155,8 @@ def get_cal_date_and_time(self, cal_type): return hightime.datetime(year, month, day, hour, minute) @ivi_synchronized - def get_last_cal_temp(self, cal_type): - r'''get_last_cal_temp + def _get_last_cal_temp(self, cal_type): + r'''_get_last_cal_temp Returns the **Temperature** during the last calibration procedure. diff --git a/src/nidmm/metadata/functions.py b/src/nidmm/metadata/functions.py index c075730ef..6ee11988d 100644 --- a/src/nidmm/metadata/functions.py +++ b/src/nidmm/metadata/functions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# This file is generated from NI-DMM API metadata version 19.6.0d7 +# This file is generated from NI-DMM API metadata version 20.5.0d5 functions = { 'Abort': { 'documentation': { @@ -1209,6 +1209,7 @@ 'returns': 'ViStatus' }, 'GetLastCalTemp': { + 'codegen_method': 'private', 'documentation': { 'description': 'Returns the **Temperature** during the last calibration procedure.', 'note': 'The NI 4050 and NI 4060 are not supported.' diff --git a/src/nidmm/metadata/functions_addon.py b/src/nidmm/metadata/functions_addon.py index 926a0303b..508b06a97 100644 --- a/src/nidmm/metadata/functions_addon.py +++ b/src/nidmm/metadata/functions_addon.py @@ -4,4 +4,146 @@ functions_override_metadata = { } +functions_additional_get_ext_cal_last_temp = { + 'FancyGetExtCalLastTemp': { + 'codegen_method': 'python-only', + 'python_name': 'get_ext_cal_last_temp', + 'documentation': { + 'description': 'Returns the **Temperature** during the last external calibration procedure.', + }, + 'method_templates': [ + { + 'documentation_filename': 'default_method', + 'method_python_name_suffix': '', + 'session_filename': 'fancy_get_cal_last_temp' + } + ], + 'parameters': [ + { + 'direction': 'in', + 'documentation': { + 'description': '\nIdentifies a particular instrument session. You obtain the **vi**\nparameter from niDMM_init or niDMM_InitWithOptions. The default is\nNone.\n' + }, + 'name': 'vi', + 'type': 'ViSession' + }, + { + 'direction': 'out', + 'documentation': { + 'description': 'Returns the **temperature** during the last external calibration.' + }, + 'name': 'temperature', + 'type': 'ViReal64' + } + ], + 'returns': 'ViStatus' + } +} + +functions_additional_get_self_cal_last_temp = { + 'FancyGetSelfCalLastTemp': { + 'codegen_method': 'python-only', + 'python_name': 'get_self_cal_last_temp', + 'documentation': { + 'description': 'Returns the **Temperature** during the last self calibration procedure.', + }, + 'method_templates': [ + { + 'documentation_filename': 'default_method', + 'method_python_name_suffix': '', + 'session_filename': 'fancy_get_cal_last_temp' + } + ], + 'parameters': [ + { + 'direction': 'in', + 'documentation': { + 'description': '\nIdentifies a particular instrument session. You obtain the **vi**\nparameter from niDMM_init or niDMM_InitWithOptions. The default is\nNone.\n' + }, + 'name': 'vi', + 'type': 'ViSession' + }, + { + 'direction': 'out', + 'documentation': { + 'description': 'Returns the **temperature** during the last self calibration.' + }, + 'name': 'temperature', + 'type': 'ViReal64' + } + ], + 'returns': 'ViStatus' + } +} +functions_additional_get_ext_cal_last_date_and_time = { + 'FancyGetExtCalLastDateAndTime': { + 'codegen_method': 'python-only', + 'python_name': 'get_ext_cal_last_date_and_time', + 'documentation': { + 'description': 'Returns the date and time of the last external calibration performed.', + }, + 'method_templates': [ + { + 'documentation_filename': 'default_method', + 'method_python_name_suffix': '', + 'session_filename': 'fancy_get_cal_last_date_and_time' + } + ], + 'parameters': [ + { + 'direction': 'in', + 'documentation': { + 'description': 'Identifies a particular instrument session. You obtain the **vi** parameter from niDMM_init or niDMM_InitWithOptions. The default is None.' + }, + 'name': 'vi', + 'type': 'ViSession' + }, + { + 'direction': 'out', + 'documentation': { + 'description': 'Indicates date and time of the last external calibration.' + }, + 'name': 'last_cal_datetime', + 'type': 'hightime.datetime' + } + ], + 'returns': 'ViStatus' + } +} + +functions_additional_get_self_cal_last_date_and_time = { + 'FancyGetSelfCalLastDateAndTime': { + 'codegen_method': 'python-only', + 'python_name': 'get_self_cal_last_date_and_time', + 'documentation': { + 'description': 'Returns the date and time of the last self calibration performed.', + }, + 'method_templates': [ + { + 'documentation_filename': 'default_method', + 'method_python_name_suffix': '', + 'session_filename': 'fancy_get_cal_last_date_and_time' + } + ], + 'parameters': [ + { + 'direction': 'in', + 'documentation': { + 'description': 'Identifies a particular instrument session. You obtain the **vi** parameter from niDMM_init or niDMM_InitWithOptions. The default is None.' + }, + 'name': 'vi', + 'type': 'ViSession' + }, + { + 'direction': 'out', + 'documentation': { + 'description': 'Indicates date and time of the last self calibration.' + }, + 'name': 'last_cal_datetime', + 'type': 'hightime.datetime' + } + ], + 'returns': 'ViStatus' + } +} diff --git a/src/nidmm/system_tests/test_system_nidmm.py b/src/nidmm/system_tests/test_system_nidmm.py index c76b93863..eef319230 100644 --- a/src/nidmm/system_tests/test_system_nidmm.py +++ b/src/nidmm/system_tests/test_system_nidmm.py @@ -150,7 +150,7 @@ def test_get_auto_range_value(session): assert auto_range_value_property == 300 # simulated device auto_range_value to maximum 300 -def test_get_cal_date_time(session): +def test_get_cal_last_date_time(session): last_cal = session.get_cal_date_and_time(0) assert last_cal.month == 3 assert last_cal.day == 1 @@ -159,8 +159,31 @@ def test_get_cal_date_time(session): assert last_cal.minute == 0 # cal_date_and_time should be 03/01/1940:00:00 for simulated 408x devices; 407x and 4065 returns 00/00/0000:00:00 -def test_get_last_cal_temperature(session): - last_cal_temp = session.get_last_cal_temp(0) +def test_get_ext_cal_last_date_and_time(session): + last_cal = session.get_ext_cal_last_date_and_time() + assert last_cal.month == 3 + assert last_cal.day == 1 + assert last_cal.year == 1940 + assert last_cal.hour == 0 + assert last_cal.minute == 0 # cal_date_and_time should be 03/01/1940:00:00 for simulated 408x devices; 407x and 4065 returns 00/00/0000:00:00 + + +def test_get_self_cal_last_date_and_time(session): + last_cal = session.get_self_cal_last_date_and_time() + assert last_cal.month == 3 + assert last_cal.day == 1 + assert last_cal.year == 1940 + assert last_cal.hour == 0 + assert last_cal.minute == 0 # cal_date_and_time should be 03/01/1940:00:00 for simulated 408x devices; 407x and 4065 returns 00/00/0000:00:00 + + +def test_get_ext_cal_last_temp(session): + last_cal_temp = session.get_ext_cal_last_temp() + assert last_cal_temp == 25 # last_cal_temp should be 25 for simulated 408x devices; 407x and 4065 returns 0 + + +def test_get_self_cal_last_temp(session): + last_cal_temp = session.get_self_cal_last_temp() assert last_cal_temp == 25 # last_cal_temp should be 25 for simulated 408x devices; 407x and 4065 returns 0 diff --git a/src/nidmm/templates/session.py/fancy_get_cal_last_date_and_time.py.mako b/src/nidmm/templates/session.py/fancy_get_cal_last_date_and_time.py.mako new file mode 100644 index 000000000..9b630fe28 --- /dev/null +++ b/src/nidmm/templates/session.py/fancy_get_cal_last_date_and_time.py.mako @@ -0,0 +1,20 @@ +<%page args="f, config, method_template"/>\ +<% + '''Forwards to get_cal_date_and_time, with calibration type pre-selected.''' + import build.helper as helper + SELF = 0 + EXTERNAL = 1 + if f['python_name'] == "get_self_cal_last_date_and_time": + calibration_type = SELF + else: # f['python_name'] == "get_ext_cal_last_date_and_time" + calibration_type = EXTERNAL +%>\ + def ${f['python_name']}(${helper.get_params_snippet(f, helper.ParameterUsageOptions.SESSION_METHOD_DECLARATION)}): + '''${f['python_name']} + + ${helper.get_function_docstring(f, False, config, indent=8)} + ''' + + month, day, year, hour, minute = self._get_cal_date_and_time(${calibration_type}) + return hightime.datetime(year, month, day, hour, minute) + diff --git a/src/nidmm/templates/session.py/fancy_get_cal_last_temp.py.mako b/src/nidmm/templates/session.py/fancy_get_cal_last_temp.py.mako new file mode 100644 index 000000000..a459f77da --- /dev/null +++ b/src/nidmm/templates/session.py/fancy_get_cal_last_temp.py.mako @@ -0,0 +1,19 @@ +<%page args="f, config, method_template"/>\ +<% + '''Forwards to get_last_cal_temp, with calibration type pre-selected.''' + import build.helper as helper + SELF = 0 + EXTERNAL = 1 + if f['python_name'] == "get_self_cal_last_temp": + calibration_type = SELF + else: # f['python_name'] == "get_ext_cal_last_temp" + calibration_type = EXTERNAL +%>\ + def ${f['python_name']}(${helper.get_params_snippet(f, helper.ParameterUsageOptions.SESSION_METHOD_DECLARATION)}): + '''${f['python_name']} + + ${helper.get_function_docstring(f, False, config, indent=8)} + ''' + + return self._get_last_cal_temp(${calibration_type}) +