diff --git a/CHANGELOG.md b/CHANGELOG.md index e38705b3e..5043edcc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,21 +33,24 @@ All notable changes to this project will be documented in this file. * #### Removed * ### `nidcpower` (NI-DCPower) * #### Added + * `get_channel_names` - [#1588](https://github.com/ni/nimi-python/issues/1588) * API parity with NI-DCPower 20.7.0 by adding Output Cutoff functionality. - * Properties added: - * `output_cutoff_current_change_limit_high` - * `output_cutoff_current_change_limit_low` - * `output_cutoff_current_measure_limit_high` - * `output_cutoff_current_measure_limit_low` - * `output_cutoff_current_overrange_enabled` - * `output_cutoff_enabled` - * `output_cutoff_voltage_change_limit_high` - * `output_cutoff_voltage_change_limit_low` - * `output_cutoff_voltage_output_limit_high` - * `output_cutoff_voltage_output_limit_low` - * Methods added: - * `clear_latched_output_cutoff_state` - * `query_latched_output_cutoff_state` + * Properties added: + * `output_cutoff_current_change_limit_high` + * `output_cutoff_current_change_limit_low` + * `output_cutoff_current_measure_limit_high` + * `output_cutoff_current_measure_limit_low` + * `output_cutoff_current_overrange_enabled` + * `output_cutoff_enabled` + * `output_cutoff_voltage_change_limit_high` + * `output_cutoff_voltage_change_limit_low` + * `output_cutoff_voltage_output_limit_high` + * `output_cutoff_voltage_output_limit_low` + * Methods added: + * `clear_latched_output_cutoff_state` + * `query_latched_output_cutoff_state` + * #### Changed + * #### Removed * #### Changed * #### Removed * ### `nidigital` (NI-Digital Pattern Driver) diff --git a/build/helper/helper.py b/build/helper/helper.py index 5dbc472d3..461a4b4b0 100644 --- a/build/helper/helper.py +++ b/build/helper/helper.py @@ -233,4 +233,3 @@ def test_get_development_status(): config['module_version'] = '19.9.9' assert get_development_status(config) == '5 - Production/Stable' - diff --git a/docs/nidcpower/class.rst b/docs/nidcpower/class.rst index 7ceb4538b..f0266e7c8 100644 --- a/docs/nidcpower/class.rst +++ b/docs/nidcpower/class.rst @@ -858,6 +858,50 @@ get_channel_name +get_channel_names +----------------- + + .. py:currentmodule:: nidcpower.Session + + .. py:method:: get_channel_names(indices) + + Returns a list of channel names for given channel indices. + + + + + .. tip:: This method requires repeated capabilities. If called directly on the + nidcpower.Session object, then the method will use all repeated capabilities in the session. + You can specify a subset of repeated capabilities using the Python index notation on an + nidcpower.Session repeated capabilities container, and calling this method on the result. + + + :param indices: + + + Index list for the channels in the session. Valid values are from zero to the total number of channels in the session minus one. The index string can be one of the following formats: + + - A comma-separated list—for example, "0,2,3,1" + - A range using a hyphen—for example, "0-3" + - A range using a colon—for example, "0:3 " + + You can combine comma-separated lists and ranges that use a hyphen or colon. Both out-of-order and repeated indices are supported ("2,3,0," "1,2,2,3"). White space characters, including spaces, tabs, feeds, and carriage returns, are allowed between characters. Ranges can be incrementing or decrementing. + + + + + :type indices: basic sequence types or str or int + + :rtype: list of str + :return: + + + The channel name(s) at the specified indices. + + + + + get_ext_cal_last_date_and_time ------------------------------ diff --git a/generated/nidcpower/nidcpower/_library.py b/generated/nidcpower/nidcpower/_library.py index d3bd86588..298ef6d15 100644 --- a/generated/nidcpower/nidcpower/_library.py +++ b/generated/nidcpower/nidcpower/_library.py @@ -37,6 +37,7 @@ def __init__(self, ctypes_library): self.niDCPower_GetAttributeViReal64_cfunc = None self.niDCPower_GetAttributeViString_cfunc = None self.niDCPower_GetChannelName_cfunc = None + self.niDCPower_GetChannelNameFromString_cfunc = None self.niDCPower_GetError_cfunc = None self.niDCPower_GetExtCalLastDateAndTime_cfunc = None self.niDCPower_GetExtCalLastTemp_cfunc = None @@ -225,6 +226,14 @@ def niDCPower_GetChannelName(self, vi, index, buffer_size, channel_name): # noq self.niDCPower_GetChannelName_cfunc.restype = ViStatus # noqa: F405 return self.niDCPower_GetChannelName_cfunc(vi, index, buffer_size, channel_name) + def niDCPower_GetChannelNameFromString(self, vi, indices, buffer_size, names): # noqa: N802 + with self._func_lock: + if self.niDCPower_GetChannelNameFromString_cfunc is None: + self.niDCPower_GetChannelNameFromString_cfunc = self._get_library_function('niDCPower_GetChannelNameFromString') + self.niDCPower_GetChannelNameFromString_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar), ViInt32, ctypes.POINTER(ViChar)] # noqa: F405 + self.niDCPower_GetChannelNameFromString_cfunc.restype = ViStatus # noqa: F405 + return self.niDCPower_GetChannelNameFromString_cfunc(vi, indices, buffer_size, names) + def niDCPower_GetError(self, vi, code, buffer_size, description): # noqa: N802 with self._func_lock: if self.niDCPower_GetError_cfunc is None: diff --git a/generated/nidcpower/nidcpower/session.py b/generated/nidcpower/nidcpower/session.py index 4158d5ea5..bc32f5224 100644 --- a/generated/nidcpower/nidcpower/session.py +++ b/generated/nidcpower/nidcpower/session.py @@ -3692,6 +3692,44 @@ def _get_attribute_vi_string(self, attribute_id): errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return attribute_value_ctype.value.decode(self._encoding) + @ivi_synchronized + def get_channel_names(self, indices): + r'''get_channel_names + + Returns a list of channel names for given channel indices. + + Tip: + This method requires repeated capabilities. If called directly on the + nidcpower.Session object, then the method will use all repeated capabilities in the session. + You can specify a subset of repeated capabilities using the Python index notation on an + nidcpower.Session repeated capabilities container, and calling this method on the result. + + Args: + indices (basic sequence types or str or int): Index list for the channels in the session. Valid values are from zero to the total number of channels in the session minus one. The index string can be one of the following formats: + + - A comma-separated list—for example, "0,2,3,1" + - A range using a hyphen—for example, "0-3" + - A range using a colon—for example, "0:3 " + + You can combine comma-separated lists and ranges that use a hyphen or colon. Both out-of-order and repeated indices are supported ("2,3,0," "1,2,2,3"). White space characters, including spaces, tabs, feeds, and carriage returns, are allowed between characters. Ranges can be incrementing or decrementing. + + + Returns: + names (list of str): The channel name(s) at the specified indices. + + ''' + vi_ctype = _visatype.ViSession(self._vi) # case S110 + indices_ctype = ctypes.create_string_buffer(_converters.convert_repeated_capabilities_without_prefix(indices).encode(self._encoding)) # case C040 + buffer_size_ctype = _visatype.ViInt32() # case S170 + names_ctype = None # case C050 + error_code = self._library.niDCPower_GetChannelNameFromString(vi_ctype, indices_ctype, buffer_size_ctype, names_ctype) + errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False) + buffer_size_ctype = _visatype.ViInt32(error_code) # case S180 + names_ctype = (_visatype.ViChar * buffer_size_ctype.value)() # case C060 + error_code = self._library.niDCPower_GetChannelNameFromString(vi_ctype, indices_ctype, buffer_size_ctype, names_ctype) + errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) + return _converters.convert_comma_separated_string_to_list(names_ctype.value.decode(self._encoding)) + def _get_error(self): r'''_get_error diff --git a/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py b/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py index 64ede6590..94a77356f 100644 --- a/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py +++ b/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py @@ -63,6 +63,9 @@ def __init__(self): self._defaults['GetChannelName'] = {} self._defaults['GetChannelName']['return'] = 0 self._defaults['GetChannelName']['channelName'] = None + self._defaults['GetChannelNameFromString'] = {} + self._defaults['GetChannelNameFromString']['return'] = 0 + self._defaults['GetChannelNameFromString']['channelName'] = None self._defaults['GetError'] = {} self._defaults['GetError']['return'] = 0 self._defaults['GetError']['code'] = None @@ -342,6 +345,16 @@ def niDCPower_GetChannelName(self, vi, index, buffer_size, channel_name): # noq channel_name.value = self._defaults['GetChannelName']['channelName'].encode('ascii') return self._defaults['GetChannelName']['return'] + def niDCPower_GetChannelNameFromString(self, vi, indices, buffer_size, names): # noqa: N802 + if self._defaults['GetChannelNameFromString']['return'] != 0: + return self._defaults['GetChannelNameFromString']['return'] + if self._defaults['GetChannelNameFromString']['channelName'] is None: + raise MockFunctionCallError("niDCPower_GetChannelNameFromString", param='channelName') + if buffer_size.value == 0: + return len(self._defaults['GetChannelNameFromString']['channelName']) + names.value = self._defaults['GetChannelNameFromString']['channelName'].encode('ascii') + return self._defaults['GetChannelNameFromString']['return'] + def niDCPower_GetError(self, vi, code, buffer_size, description): # noqa: N802 if self._defaults['GetError']['return'] != 0: return self._defaults['GetError']['return'] @@ -740,6 +753,8 @@ def set_side_effects_and_return_values(self, mock_library): mock_library.niDCPower_GetAttributeViString.return_value = 0 mock_library.niDCPower_GetChannelName.side_effect = MockFunctionCallError("niDCPower_GetChannelName") mock_library.niDCPower_GetChannelName.return_value = 0 + mock_library.niDCPower_GetChannelNameFromString.side_effect = MockFunctionCallError("niDCPower_GetChannelNameFromString") + mock_library.niDCPower_GetChannelNameFromString.return_value = 0 mock_library.niDCPower_GetError.side_effect = MockFunctionCallError("niDCPower_GetError") mock_library.niDCPower_GetError.return_value = 0 mock_library.niDCPower_GetExtCalLastDateAndTime.side_effect = MockFunctionCallError("niDCPower_GetExtCalLastDateAndTime") diff --git a/src/nidcpower/metadata/attributes.py b/src/nidcpower/metadata/attributes.py index a3b054f98..d60c13990 100644 --- a/src/nidcpower/metadata/attributes.py +++ b/src/nidcpower/metadata/attributes.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# This file is generated from NI-DCPower API metadata version 21.0.0d52 +# This file is generated from NI-DCPower API metadata version 21.0.0d69 attributes = { 1050003: { 'access': 'read-write', diff --git a/src/nidcpower/metadata/config.py b/src/nidcpower/metadata/config.py index 79afe3724..5291a79f0 100644 --- a/src/nidcpower/metadata/config.py +++ b/src/nidcpower/metadata/config.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -# This file is generated from NI-DCPower API metadata version 21.0.0d52 +# This file is generated from NI-DCPower API metadata version 21.0.0d69 config = { - 'api_version': '21.0.0d52', + 'api_version': '21.0.0d69', 'c_function_prefix': 'niDCPower_', 'close_function': 'close', 'context_manager_name': { diff --git a/src/nidcpower/metadata/enums.py b/src/nidcpower/metadata/enums.py index 089a74f37..f29ec3fc9 100644 --- a/src/nidcpower/metadata/enums.py +++ b/src/nidcpower/metadata/enums.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# This file is generated from NI-DCPower API metadata version 21.0.0d52 +# This file is generated from NI-DCPower API metadata version 21.0.0d69 enums = { 'ApertureTimeUnits': { 'values': [ diff --git a/src/nidcpower/metadata/functions.py b/src/nidcpower/metadata/functions.py index b77a13f07..d4d8663be 100644 --- a/src/nidcpower/metadata/functions.py +++ b/src/nidcpower/metadata/functions.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# This file is generated from NI-DCPower API metadata version 21.0.0d52 +# This file is generated from NI-DCPower API metadata version 21.0.0d69 functions = { 'AbortWithChannels': { 'documentation': { @@ -1453,6 +1453,57 @@ ], 'returns': 'ViStatus' }, + 'GetChannelNameFromString': { + 'documentation': { + 'description': '\nReturns a list of channel names for given channel indices.' + }, + 'parameters': [ + { + 'direction': 'in', + 'documentation': { + 'description': '\nIdentifies a particular instrument session. **vi** is obtained from the\nniDCPower_InitializeWithChannels function.\n' + }, + 'name': 'vi', + 'type': 'ViSession' + }, + { + 'direction': 'in', + 'documentation': { + 'description': '\nIndex list for the channels in the session. Valid values are from zero to the total number of channels in the session minus one. The index string can be one of the following formats:\n\n- A comma-separated list—for example, "0,2,3,1"\n- A range using a hyphen—for example, "0-3"\n- A range using a colon—for example, "0:3 "\n\nYou can combine comma-separated lists and ranges that use a hyphen or colon. Both out-of-order and repeated indices are supported ("2,3,0," "1,2,2,3"). White space characters, including spaces, tabs, feeds, and carriage returns, are allowed between characters. Ranges can be incrementing or decrementing.\n' + }, + 'name': 'index', + 'python_api_converter_name': 'convert_repeated_capabilities_without_prefix', + 'python_name': 'indices', + 'type': 'ViConstString', + 'type_in_documentation': 'basic sequence types or str or int' + }, + { + 'direction': 'in', + 'documentation': { + 'description': '\nThe number of elements in the ViChar array you specify for name.\n' + }, + 'name': 'bufferSize', + 'type': 'ViInt32' + }, + { + 'direction': 'out', + 'documentation': { + 'description': 'The channel name(s) at the specified indices.' + }, + 'name': 'channelName', + 'python_api_converter_name': 'convert_comma_separated_string_to_list', + 'python_name': 'names', + 'size': { + 'mechanism': 'ivi-dance', + 'value': 'bufferSize' + }, + 'type': 'ViChar[]', + 'type_in_documentation': 'list of str' + } + ], + 'python_name': 'get_channel_names', + 'returns': 'ViStatus' + }, 'GetError': { 'codegen_method': 'private', 'documentation': { diff --git a/src/nidcpower/system_tests/test_system_nidcpower.py b/src/nidcpower/system_tests/test_system_nidcpower.py index a90ca9f22..b80305423 100644 --- a/src/nidcpower/system_tests/test_system_nidcpower.py +++ b/src/nidcpower/system_tests/test_system_nidcpower.py @@ -11,6 +11,13 @@ def session(): yield simulated_session +@pytest.fixture(scope='function') +def multi_instrument_session(): + instruments = ['PXI1Slot2', 'PXI1Slot5'] + with nidcpower.Session(resource_name=','.join(instruments), options='Simulate=1, DriverSetup=Model:4162; BoardType:PXIe') as simulated_session: + yield simulated_session + + @pytest.fixture(scope='function') def single_channel_session(): with nidcpower.Session('4162', '0', False, 'Simulate=1, DriverSetup=Model:4162; BoardType:PXIe') as simulated_session: @@ -36,6 +43,16 @@ def test_get_channel_name(session): assert name == '0' +def test_get_channel_names(multi_instrument_session): + # Once we have support for independent channels, we should update this test to include + # the instrument names in the expected channel names -- or possibly add a separate test + # expected_string = ['{0}/{1}'.format(instruments[0], x) for x in range(12)] + # (Tracked on GitHub by #1582) + expected_string = ['{0}'.format(x) for x in range(12)] + channel_indices = ['0-1, 2, 3:4', 5, (6, 7), range(8, 10), slice(10, 12)] + assert multi_instrument_session.get_channel_names(indices=channel_indices) == expected_string + + def test_get_attribute_string(session): model = session.instrument_model assert model == 'NI PXIe-4162'