From 0ec9657f262e17ea1dd0adb4f38eae60dbd7111e Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Mon, 5 Apr 2021 14:13:22 -0500 Subject: [PATCH 01/14] Ignore files generated during system test execution --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 573a1d5ca..a3e2b24e2 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ commands.log .vscode/settings.json .pytest_cache/ + +system_tests.zip +system_tests/ni-nimi-python-* From 634382f5bd702e39f23a7bfb1369193290327a76 Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Mon, 5 Apr 2021 14:20:47 -0500 Subject: [PATCH 02/14] Add get_channel_names test --- .../system_tests/test_system_nidcpower.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/nidcpower/system_tests/test_system_nidcpower.py b/src/nidcpower/system_tests/test_system_nidcpower.py index a90ca9f22..ae865b914 100644 --- a/src/nidcpower/system_tests/test_system_nidcpower.py +++ b/src/nidcpower/system_tests/test_system_nidcpower.py @@ -4,6 +4,8 @@ import pytest import tempfile +instruments = ['PXI1Slot2', 'PXI1Slot5'] + @pytest.fixture(scope='function') def session(): @@ -11,6 +13,12 @@ def session(): yield simulated_session +@pytest.fixture(scope='function') +def multi_instrument_session(): + 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: @@ -31,9 +39,13 @@ def test_self_cal(session): session.self_cal() -def test_get_channel_name(session): - name = session.get_channel_name(1) - 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)] + 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): From 7edf571d297668b4c016e9b4a0d07471a19b9c0f Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Wed, 7 Apr 2021 16:01:52 -0500 Subject: [PATCH 03/14] get_channel_names implementation (plus some additional metadata changes that hadn't yet been codegen'd) --- docs/nidcpower/class.rst | 647 ++++++++++++++++-- docs/nidcpower/enums.rst | 95 +++ generated/nidcpower/nidcpower/_library.py | 27 + generated/nidcpower/nidcpower/enums.py | 39 ++ generated/nidcpower/nidcpower/session.py | 403 +++++++++-- .../nidcpower/unit_tests/_mock_helper.py | 39 ++ src/nidcpower/metadata/attributes.py | 122 +++- src/nidcpower/metadata/enums.py | 69 +- src/nidcpower/metadata/functions.py | 247 ++++++- 9 files changed, 1585 insertions(+), 103 deletions(-) diff --git a/docs/nidcpower/class.rst b/docs/nidcpower/class.rst index 15cf288eb..9c5b913c6 100644 --- a/docs/nidcpower/class.rst +++ b/docs/nidcpower/class.rst @@ -155,6 +155,55 @@ abort +clear_latched_output_cutoff_state +--------------------------------- + + .. py:currentmodule:: nidcpower.Session + + .. py:method:: clear_latched_output_cutoff_state(output_cutoff_reason) + + Clears the state of an output cutoff that was engaged. + To clear the state for all output cutoff reasons, use :py:data:`~nidcpower.OutputCutoffReason.ALL`. + + + + + .. 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 output_cutoff_reason: + + + Specifies the reasons for which to clear the output cutoff state. + + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.ALL` | Clears all output cutoff conditions | + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.VOLTAGE_OUTPUT_HIGH` | Clears cutoffs caused when the output exceeded the high cutoff limit for voltage output | + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.VOLTAGE_OUTPUT_LOW` | Clears cutoffs caused when the output fell below the low cutoff limit for voltage output | + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.CURRENT_MEASURE_HIGH` | Clears cutoffs caused when the measured current exceeded the high cutoff limit for current output | + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.CURRENT_MEASURE_LOW` | Clears cutoffs caused when the measured current fell below the low cutoff limit for current output | + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_VOLTAGE_CHANGE` | Clears cutoffs caused when the voltage slew rate increased beyond the positive change cutoff for voltage output | + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_VOLTAGE_CHANGE` | Clears cutoffs caused when the voltage slew rate decreased beyond the negative change cutoff for voltage output | + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_CURRENT_CHANGE` | Clears cutoffs caused when the current slew rate increased beyond the positive change cutoff for current output | + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_CURRENT_CHANGE` | Clears cutoffs caused when the voltage slew rate decreased beyond the negative change cutoff for current output | + +----------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + + .. 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. + + + :type output_cutoff_reason: :py:data:`nidcpower.OutputCutoffReason` + close ----- @@ -261,11 +310,11 @@ configure_aperture_time Specifies the units for **apertureTime**. **Defined Values**: - +------------------------------------------------------------------+------------------------------+ - | :py:data:`~nidcpower.ApertureTimeUnits.SECONDS` (1028) | Specifies seconds. | - +------------------------------------------------------------------+------------------------------+ - | :py:data:`~nidcpower.ApertureTimeUnits.POWER_LINE_CYCLES` (1029) | Specifies Power Line Cycles. | - +------------------------------------------------------------------+------------------------------+ + +-----------------------------------------------------------+------------------------------+ + | :py:data:`~nidcpower.ApertureTimeUnits.SECONDS` | Specifies seconds. | + +-----------------------------------------------------------+------------------------------+ + | :py:data:`~nidcpower.ApertureTimeUnits.POWER_LINE_CYCLES` | Specifies Power Line Cycles. | + +-----------------------------------------------------------+------------------------------+ :type units: :py:data:`nidcpower.ApertureTimeUnits` @@ -791,6 +840,50 @@ get_channel_name +get_channel_names +----------------- + + .. py:currentmodule:: nidcpower.Session + + .. py:method:: get_channel_names(index) + + Returns a comma-separated list of channel names from a string index list. + + + + + .. 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 index: + + + 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 index: basic sequence types or str or int + + :rtype: list of str + :return: + + + The returned channel name(s) at the specified index. + + + + + get_ext_cal_last_date_and_time ------------------------------ @@ -1157,11 +1250,11 @@ measure Specifies whether a voltage or current value is measured. **Defined Values**: - +----------------------------------------------------+------------------------------+ - | :py:data:`~nidcpower.MeasurementTypes.VOLTAGE` (1) | The device measures voltage. | - +----------------------------------------------------+------------------------------+ - | :py:data:`~nidcpower.MeasurementTypes.CURRENT` (0) | The device measures current. | - +----------------------------------------------------+------------------------------+ + +------------------------------------------------+------------------------------+ + | :py:data:`~nidcpower.MeasurementTypes.VOLTAGE` | The device measures voltage. | + +------------------------------------------------+------------------------------+ + | :py:data:`~nidcpower.MeasurementTypes.CURRENT` | The device measures current. | + +------------------------------------------------+------------------------------+ :type measurement_type: :py:data:`nidcpower.MeasurementTypes` @@ -1270,6 +1363,73 @@ query_in_compliance +query_latched_output_cutoff_state +--------------------------------- + + .. py:currentmodule:: nidcpower.Session + + .. py:method:: query_latched_output_cutoff_state(output_cutoff_reason) + + Discovers if an output cutoff limit was exceeded for the specified reason. When an output cutoff is engaged, the output of the channel(s) is disconnected. + If a limit was exceeded, the state is latched until you clear it with the :py:meth:`nidcpower.Session.clear_latched_output_cutoff_state` method or the :py:meth:`nidcpower.Session.ResetWithChannels` method. + + outputCutoffReason specifies the conditions for which an output is disconnected. + + + + .. note:: One or more of the referenced methods are not in the Python API for this driver. + + + .. 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 output_cutoff_reason: + + + Specifies which output cutoff conditions to query. + + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.ALL` | Any output cutoff condition was met | + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.VOLTAGE_OUTPUT_HIGH` | The output exceeded the high cutoff limit for voltage output | + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.VOLTAGE_OUTPUT_LOW` | The output fell below the low cutoff limit for voltage output | + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.CURRENT_MEASURE_HIGH` | The measured current exceeded the high cutoff limit for current output | + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputCutoffReason.CURRENT_MEASURE_LOW` | The measured current fell below the low cutoff limit for current output | + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_VOLTAGE_CHANGE` | The voltage slew rate increased beyond the positive change cutoff for voltage output | + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_VOLTAGE_CHANGE` | The voltage slew rate decreased beyond the negative change cutoff for voltage output | + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_CURRENT_CHANGE` | The current slew rate increased beyond the positive change cutoff for current output | + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_CURRENT_CHANGE` | The current slew rate decreased beyond the negative change cutoff for current output | + +----------------------------------------------------------------------------------+--------------------------------------------------------------------------------------+ + + .. 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. + + + :type output_cutoff_reason: :py:data:`nidcpower.OutputCutoffReason` + + :rtype: bool + :return: + + + Specifies whether an output cutoff has engaged. + + +-------+------------------------------------------------------------------------------+ + | True | An output cutoff has engaged for the conditions in **output cutoff reason**. | + +-------+------------------------------------------------------------------------------+ + | False | No output cutoff has engaged. | + +-------+------------------------------------------------------------------------------+ + + + query_max_current_limit ----------------------- @@ -1422,11 +1582,11 @@ query_output_state Specifies the output state of the output channel that is being queried. **Defined Values**: - +------------------------------------------------+-------------------------------------------------------------------+ - | :py:data:`~nidcpower.OutputStates.VOLTAGE` (0) | The device maintains a constant voltage by adjusting the current. | - +------------------------------------------------+-------------------------------------------------------------------+ - | :py:data:`~nidcpower.OutputStates.CURRENT` (1) | The device maintains a constant current by adjusting the voltage. | - +------------------------------------------------+-------------------------------------------------------------------+ + +--------------------------------------------+-------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputStates.VOLTAGE` | The device maintains a constant voltage by adjusting the current. | + +--------------------------------------------+-------------------------------------------------------------------+ + | :py:data:`~nidcpower.OutputStates.CURRENT` | The device maintains a constant current by adjusting the voltage. | + +--------------------------------------------+-------------------------------------------------------------------+ :type output_state: :py:data:`nidcpower.OutputStates` @@ -1630,19 +1790,19 @@ send_software_edge_trigger Specifies which trigger to assert. **Defined Values:** - +---------------------------------------------------------------------+---------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_START_TRIGGER` (1034) | Asserts the Start trigger. | - +---------------------------------------------------------------------+---------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_SOURCE_TRIGGER` (1035) | Asserts the Source trigger. | - +---------------------------------------------------------------------+---------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_MEASURE_TRIGGER` (1036) | Asserts the Measure trigger. | - +---------------------------------------------------------------------+---------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_SEQUENCE_ADVANCE_TRIGGER` (1037) | Asserts the Sequence Advance trigger. | - +---------------------------------------------------------------------+---------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_PULSE_TRIGGER` (1053) | Asserts the Pulse trigger. | - +---------------------------------------------------------------------+---------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_SHUTDOWN_TRIGGER` (1118) | Asserts the Shutdown trigger. | - +---------------------------------------------------------------------+---------------------------------------+ + +--------------------------------------------------------------+---------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_START_TRIGGER` | Asserts the Start trigger. | + +--------------------------------------------------------------+---------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_SOURCE_TRIGGER` | Asserts the Source trigger. | + +--------------------------------------------------------------+---------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_MEASURE_TRIGGER` | Asserts the Measure trigger. | + +--------------------------------------------------------------+---------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_SEQUENCE_ADVANCE_TRIGGER` | Asserts the Sequence Advance trigger. | + +--------------------------------------------------------------+---------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_PULSE_TRIGGER` | Asserts the Pulse trigger. | + +--------------------------------------------------------------+---------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_SHUTDOWN_TRIGGER` | Asserts the Shutdown trigger. | + +--------------------------------------------------------------+---------------------------------------+ .. 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. @@ -1755,19 +1915,19 @@ wait_for_event Specifies which event to wait for. **Defined Values:** - +------------------------------------------------------------------------------+--------------------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_SOURCE_COMPLETE_EVENT` (1030) | Waits for the Source Complete event. | - +------------------------------------------------------------------------------+--------------------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_MEASURE_COMPLETE_EVENT` (1031) | Waits for the Measure Complete event. | - +------------------------------------------------------------------------------+--------------------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_SEQUENCE_ITERATION_COMPLETE_EVENT` (1032) | Waits for the Sequence Iteration Complete event. | - +------------------------------------------------------------------------------+--------------------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_SEQUENCE_ENGINE_DONE_EVENT` (1033) | Waits for the Sequence Engine Done event. | - +------------------------------------------------------------------------------+--------------------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_PULSE_COMPLETE_EVENT` (1051 ) | Waits for the Pulse Complete event. | - +------------------------------------------------------------------------------+--------------------------------------------------+ - | :py:data:`~nidcpower.NIDCPOWER_VAL_READY_FOR_PULSE_TRIGGER_EVENT` (1052) | Waits for the Ready for Pulse Trigger event. | - +------------------------------------------------------------------------------+--------------------------------------------------+ + +-----------------------------------------------------------------------+--------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_SOURCE_COMPLETE_EVENT` | Waits for the Source Complete event. | + +-----------------------------------------------------------------------+--------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_MEASURE_COMPLETE_EVENT` | Waits for the Measure Complete event. | + +-----------------------------------------------------------------------+--------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_SEQUENCE_ITERATION_COMPLETE_EVENT` | Waits for the Sequence Iteration Complete event. | + +-----------------------------------------------------------------------+--------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_SEQUENCE_ENGINE_DONE_EVENT` | Waits for the Sequence Engine Done event. | + +-----------------------------------------------------------------------+--------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_PULSE_COMPLETE_EVENT` | Waits for the Pulse Complete event. | + +-----------------------------------------------------------------------+--------------------------------------------------+ + | :py:data:`~nidcpower.NIDCPOWER_VAL_READY_FOR_PULSE_TRIGGER_EVENT` | Waits for the Ready for Pulse Trigger event. | + +-----------------------------------------------------------------------+--------------------------------------------------+ .. 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. @@ -4203,6 +4363,411 @@ output_connected - LabVIEW Property: **Source:Output Connected** - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CONNECTED** +output_cutoff_current_change_limit_high +--------------------------------------- + + .. py:attribute:: output_cutoff_current_change_limit_high + + Specifies a limit for positive current slew rate, in amps per microsecond, for output cutoff. + If the current increases at a rate that exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the :py:meth:`nidcpower.Session.query_latched_output_cutoff_state` method with :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_CURRENT_CHANGE` as the output cutoff reason. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. + + .. 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. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | float | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Current Change Limit High** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_CURRENT_CHANGE_LIMIT_HIGH** + +output_cutoff_current_change_limit_low +-------------------------------------- + + .. py:attribute:: output_cutoff_current_change_limit_low + + Specifies a limit for negative current slew rate, in amps per microsecond, for output cutoff. + If the current decreases at a rate that exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the :py:meth:`nidcpower.Session.query_latched_output_cutoff_state` method with :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_CURRENT_CHANGE` as the output cutoff reason. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. + + .. 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. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | float | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Current Change Limit Low** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_CURRENT_CHANGE_LIMIT_LOW** + +output_cutoff_current_measure_limit_high +---------------------------------------- + + .. py:attribute:: output_cutoff_current_measure_limit_high + + Specifies a high limit current value, in amps, for output cutoff. + If the measured current exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the :py:meth:`nidcpower.Session.query_latched_output_cutoff_state` method with :py:data:`~nidcpower.OutputCutoffReason.CURRENT_MEASURE_HIGH` as the output cutoff reason. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | float | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Current Measure Limit High** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_CURRENT_MEASURE_LIMIT_HIGH** + +output_cutoff_current_measure_limit_low +--------------------------------------- + + .. py:attribute:: output_cutoff_current_measure_limit_low + + Specifies a low limit current value, in amps, for output cutoff. + If the measured current falls below this limit, the output is disconnected. + + To find out whether an output has fallen below this limit, call the :py:meth:`nidcpower.Session.query_latched_output_cutoff_state` method with :py:data:`~nidcpower.OutputCutoffReason.CURRENT_MEASURE_LOW` as the output cutoff reason. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | float | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Current Measure Limit Low** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_CURRENT_MEASURE_LIMIT_LOW** + +output_cutoff_current_overrange_enabled +--------------------------------------- + + .. py:attribute:: output_cutoff_current_overrange_enabled + + Enables or disables current overrange functionality for output cutoff. If enabled, the output is disconnected when the measured current saturates the current range. + + To find out whether an output has exceeded this limit, call the :py:meth:`nidcpower.Session.query_latched_output_cutoff_state` method with :py:data:`~nidcpower.OutputCutoffReason.VOLTAGE_OUTPUT_HIGH` as the output cutoff reason. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | bool | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Current Overrange Enabled** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_CURRENT_OVERRANGE_ENABLED** + +output_cutoff_enabled +--------------------- + + .. py:attribute:: output_cutoff_enabled + + Enables or disables output cutoff functionality. If enabled, you can define output cutoffs that, if exceeded, cause the output of the specified channel(s) to be disconnected. + When this property is disabled, all other output cutoff properties are ignored. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. Instruments that do not support this property behave as if this property were set to False. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | bool | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Enabled** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_ENABLED** + +output_cutoff_voltage_change_limit_high +--------------------------------------- + + .. py:attribute:: output_cutoff_voltage_change_limit_high + + Specifies a limit for positive voltage slew rate, in volts per microsecond, for output cutoff. + If the voltage increases at a rate that exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the :py:meth:`nidcpower.Session.query_latched_output_cutoff_state` with :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_VOLTAGE_CHANGE` as the output cutoff reason. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. + + .. 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. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | float | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Voltage Change Limit High** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_VOLTAGE_CHANGE_LIMIT_HIGH** + +output_cutoff_voltage_change_limit_low +-------------------------------------- + + .. py:attribute:: output_cutoff_voltage_change_limit_low + + Specifies a limit for negative voltage slew rate, in volts per microsecond, for output cutoff. + If the voltage decreases at a rate that exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the :py:meth:`nidcpower.Session.query_latched_output_cutoff_state` with :py:data:`~nidcpower.NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_VOLTAGE_CHANGE` as the output cutoff reason. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. + + .. 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. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | float | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Voltage Change Limit Low** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_VOLTAGE_CHANGE_LIMIT_LOW** + +output_cutoff_voltage_output_limit_high +--------------------------------------- + + .. py:attribute:: output_cutoff_voltage_output_limit_high + + Specifies a high limit voltage value, in volts, for output cutoff. + If the voltage output exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the :py:meth:`nidcpower.Session.query_latched_output_cutoff_state` method with :py:data:`~nidcpower.OutputCutoffReason.VOLTAGE_OUTPUT_HIGH` as the output cutoff reason. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | float | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Voltage Output Limit High** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_VOLTAGE_OUTPUT_LIMIT_HIGH** + +output_cutoff_voltage_output_limit_low +-------------------------------------- + + .. py:attribute:: output_cutoff_voltage_output_limit_low + + Specifies a low limit voltage value, in volts, for output cutoff. + If the voltage output falls below this limit, the output is disconnected. + + To find out whether an output has fallen below this limit, call the :py:meth:`nidcpower.Session.query_latched_output_cutoff_state` method with :py:data:`~nidcpower.OutputCutoffReason.VOLTAGE_OUTPUT_LOW` as the output cutoff reason. + + + + .. note:: Refer to Supported Properties by Device for information about supported devices. + + + .. tip:: This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + + The following table lists the characteristics of this property. + + +----------------+------------+ + | Characteristic | Value | + +================+============+ + | Datatype | float | + +----------------+------------+ + | Permissions | read-write | + +----------------+------------+ + | Channel Based | Yes | + +----------------+------------+ + | Resettable | No | + +----------------+------------+ + + .. tip:: + This property corresponds to the following LabVIEW Property or C Attribute: + + - LabVIEW Property: **Source:Output Cutoff:Voltage Output Limit Low** + - C Attribute: **NIDCPOWER_ATTR_OUTPUT_CUTOFF_VOLTAGE_OUTPUT_LIMIT_LOW** + output_enabled -------------- diff --git a/docs/nidcpower/enums.rst b/docs/nidcpower/enums.rst index 319df039a..40f58db8f 100644 --- a/docs/nidcpower/enums.rst +++ b/docs/nidcpower/enums.rst @@ -345,6 +345,101 @@ OutputCapacitance +OutputCutoffReason +------------------ + +.. py:class:: OutputCutoffReason + + .. py:attribute:: OutputCutoffReason.ALL + + + + Queries any output cutoff condition; clears all output cutoff conditions. + + + + + + .. py:attribute:: OutputCutoffReason.VOLTAGE_OUTPUT_HIGH + + + + Queries or clears cutoff conditions when the output exceeded the high cutoff limit for voltage output. + + + + + + .. py:attribute:: OutputCutoffReason.VOLTAGE_OUTPUT_LOW + + + + Queries or clears cutoff conditions when the output fell below the low cutoff limit for voltage output. + + + + + + .. py:attribute:: OutputCutoffReason.CURRENT_MEASURE_HIGH + + + + Queries or clears cutoff conditions when the measured current exceeded the high cutoff limit for current output. + + + + + + .. py:attribute:: OutputCutoffReason.CURRENT_MEASURE_LOW + + + + Queries or clears cutoff conditions when the measured current fell below the low cutoff limit for current output. + + + + + + .. py:attribute:: OutputCutoffReason.VOLTAGE_CHANGE_HIGH + + + + Queries or clears cutoff conditions when the voltage slew rate increased beyond the positive change cutoff for voltage output. + + + + + + .. py:attribute:: OutputCutoffReason.VOLTAGE_CHANGE_LOW + + + + Queries or clears cutoff conditions when the voltage slew rate decreased beyond the negative change cutoff for voltage output. + + + + + + .. py:attribute:: OutputCutoffReason.CURRENT_CHANGE_HIGH + + + + Queries or clears cutoff conditions when the current slew rate increased beyond the positive change cutoff for current output. + + + + + + .. py:attribute:: OutputCutoffReason.CURRENT_CHANGE_LOW + + + + Queries or clears cutoff conditions when the current slew rate decreased beyond the negative change cutoff for current output. + + + + + OutputFunction -------------- diff --git a/generated/nidcpower/nidcpower/_library.py b/generated/nidcpower/nidcpower/_library.py index 5fb69c9e7..770a54c92 100644 --- a/generated/nidcpower/nidcpower/_library.py +++ b/generated/nidcpower/nidcpower/_library.py @@ -20,6 +20,7 @@ def __init__(self, ctypes_library): # We cache the cfunc object from the ctypes.CDLL object self.niDCPower_Abort_cfunc = None self.niDCPower_CalSelfCalibrate_cfunc = None + self.niDCPower_ClearLatchedOutputCutoffState_cfunc = None self.niDCPower_Commit_cfunc = None self.niDCPower_ConfigureApertureTime_cfunc = None self.niDCPower_CreateAdvancedSequence_cfunc = None @@ -35,6 +36,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 @@ -50,6 +52,7 @@ def __init__(self, ctypes_library): self.niDCPower_MeasureMultiple_cfunc = None self.niDCPower_ParseChannelCount_cfunc = None self.niDCPower_QueryInCompliance_cfunc = None + self.niDCPower_QueryLatchedOutputCutoffState_cfunc = None self.niDCPower_QueryMaxCurrentLimit_cfunc = None self.niDCPower_QueryMaxVoltageLevel_cfunc = None self.niDCPower_QueryMinCurrentLimit_cfunc = None @@ -87,6 +90,14 @@ def niDCPower_CalSelfCalibrate(self, vi, channel_name): # noqa: N802 self.niDCPower_CalSelfCalibrate_cfunc.restype = ViStatus # noqa: F405 return self.niDCPower_CalSelfCalibrate_cfunc(vi, channel_name) + def niDCPower_ClearLatchedOutputCutoffState(self, vi, channel_name, output_cutoff_reason): # noqa: N802 + with self._func_lock: + if self.niDCPower_ClearLatchedOutputCutoffState_cfunc is None: + self.niDCPower_ClearLatchedOutputCutoffState_cfunc = self._library.niDCPower_ClearLatchedOutputCutoffState + self.niDCPower_ClearLatchedOutputCutoffState_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar), ViInt32] # noqa: F405 + self.niDCPower_ClearLatchedOutputCutoffState_cfunc.restype = ViStatus # noqa: F405 + return self.niDCPower_ClearLatchedOutputCutoffState_cfunc(vi, channel_name, output_cutoff_reason) + def niDCPower_Commit(self, vi): # noqa: N802 with self._func_lock: if self.niDCPower_Commit_cfunc is None: @@ -207,6 +218,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, index, buffer_size, channel_name): # noqa: N802 + with self._func_lock: + if self.niDCPower_GetChannelNameFromString_cfunc is None: + self.niDCPower_GetChannelNameFromString_cfunc = self._library.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, index, buffer_size, channel_name) + def niDCPower_GetError(self, vi, code, buffer_size, description): # noqa: N802 with self._func_lock: if self.niDCPower_GetError_cfunc is None: @@ -327,6 +346,14 @@ def niDCPower_QueryInCompliance(self, vi, channel_name, in_compliance): # noqa: self.niDCPower_QueryInCompliance_cfunc.restype = ViStatus # noqa: F405 return self.niDCPower_QueryInCompliance_cfunc(vi, channel_name, in_compliance) + def niDCPower_QueryLatchedOutputCutoffState(self, vi, channel_name, output_cutoff_reason, output_cutoff_state): # noqa: N802 + with self._func_lock: + if self.niDCPower_QueryLatchedOutputCutoffState_cfunc is None: + self.niDCPower_QueryLatchedOutputCutoffState_cfunc = self._library.niDCPower_QueryLatchedOutputCutoffState + self.niDCPower_QueryLatchedOutputCutoffState_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar), ViInt32, ctypes.POINTER(ViBoolean)] # noqa: F405 + self.niDCPower_QueryLatchedOutputCutoffState_cfunc.restype = ViStatus # noqa: F405 + return self.niDCPower_QueryLatchedOutputCutoffState_cfunc(vi, channel_name, output_cutoff_reason, output_cutoff_state) + def niDCPower_QueryMaxCurrentLimit(self, vi, channel_name, voltage_level, max_current_limit): # noqa: N802 with self._func_lock: if self.niDCPower_QueryMaxCurrentLimit_cfunc is None: diff --git a/generated/nidcpower/nidcpower/enums.py b/generated/nidcpower/nidcpower/enums.py index b710e6877..ef5089b9e 100644 --- a/generated/nidcpower/nidcpower/enums.py +++ b/generated/nidcpower/nidcpower/enums.py @@ -147,6 +147,45 @@ class OutputCapacitance(Enum): ''' +class OutputCutoffReason(Enum): + ALL = -1 + r''' + Queries any output cutoff condition; clears all output cutoff conditions. + ''' + VOLTAGE_OUTPUT_HIGH = 1 + r''' + Queries or clears cutoff conditions when the output exceeded the high cutoff limit for voltage output. + ''' + VOLTAGE_OUTPUT_LOW = 2 + r''' + Queries or clears cutoff conditions when the output fell below the low cutoff limit for voltage output. + ''' + CURRENT_MEASURE_HIGH = 4 + r''' + Queries or clears cutoff conditions when the measured current exceeded the high cutoff limit for current output. + ''' + CURRENT_MEASURE_LOW = 8 + r''' + Queries or clears cutoff conditions when the measured current fell below the low cutoff limit for current output. + ''' + VOLTAGE_CHANGE_HIGH = 16 + r''' + Queries or clears cutoff conditions when the voltage slew rate increased beyond the positive change cutoff for voltage output. + ''' + VOLTAGE_CHANGE_LOW = 32 + r''' + Queries or clears cutoff conditions when the voltage slew rate decreased beyond the negative change cutoff for voltage output. + ''' + CURRENT_CHANGE_HIGH = 64 + r''' + Queries or clears cutoff conditions when the current slew rate increased beyond the positive change cutoff for current output. + ''' + CURRENT_CHANGE_LOW = 128 + r''' + Queries or clears cutoff conditions when the current slew rate decreased beyond the negative change cutoff for current output. + ''' + + class OutputFunction(Enum): DC_VOLTAGE = 1006 r''' diff --git a/generated/nidcpower/nidcpower/session.py b/generated/nidcpower/nidcpower/session.py index 986c09b22..9ba787a5e 100644 --- a/generated/nidcpower/nidcpower/session.py +++ b/generated/nidcpower/nidcpower/session.py @@ -1061,6 +1061,175 @@ class _SessionBase(object): Note: Only disconnect the output when disconnecting is necessary for your application. For example, a battery connected + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_current_change_limit_high = _attributes.AttributeViReal64(1150295) + '''Type: float + + Specifies a limit for positive current slew rate, in amps per microsecond, for output cutoff. + If the current increases at a rate that exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the query_latched_output_cutoff_state method with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_CURRENT_CHANGE as the output cutoff reason. + + Note: Refer to Supported Properties by Device for information about supported devices. + + 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. + + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_current_change_limit_low = _attributes.AttributeViReal64(1150239) + '''Type: float + + Specifies a limit for negative current slew rate, in amps per microsecond, for output cutoff. + If the current decreases at a rate that exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the query_latched_output_cutoff_state method with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_CURRENT_CHANGE as the output cutoff reason. + + Note: Refer to Supported Properties by Device for information about supported devices. + + 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. + + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_current_measure_limit_high = _attributes.AttributeViReal64(1150237) + '''Type: float + + Specifies a high limit current value, in amps, for output cutoff. + If the measured current exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the query_latched_output_cutoff_state method with OutputCutoffReason.CURRENT_MEASURE_HIGH as the output cutoff reason. + + Note: Refer to Supported Properties by Device for information about supported devices. + + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_current_measure_limit_low = _attributes.AttributeViReal64(1150293) + '''Type: float + + Specifies a low limit current value, in amps, for output cutoff. + If the measured current falls below this limit, the output is disconnected. + + To find out whether an output has fallen below this limit, call the query_latched_output_cutoff_state method with OutputCutoffReason.CURRENT_MEASURE_LOW as the output cutoff reason. + + Note: Refer to Supported Properties by Device for information about supported devices. + + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_current_overrange_enabled = _attributes.AttributeViBoolean(1150240) + '''Type: bool + + Enables or disables current overrange functionality for output cutoff. If enabled, the output is disconnected when the measured current saturates the current range. + + To find out whether an output has exceeded this limit, call the query_latched_output_cutoff_state method with OutputCutoffReason.VOLTAGE_OUTPUT_HIGH as the output cutoff reason. + + Note: Refer to Supported Properties by Device for information about supported devices. + + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_enabled = _attributes.AttributeViBoolean(1150235) + '''Type: bool + + Enables or disables output cutoff functionality. If enabled, you can define output cutoffs that, if exceeded, cause the output of the specified channel(s) to be disconnected. + When this property is disabled, all other output cutoff properties are ignored. + + Note: Refer to Supported Properties by Device for information about supported devices. Instruments that do not support this property behave as if this property were set to False. + + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_voltage_change_limit_high = _attributes.AttributeViReal64(1150294) + '''Type: float + + Specifies a limit for positive voltage slew rate, in volts per microsecond, for output cutoff. + If the voltage increases at a rate that exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the query_latched_output_cutoff_state with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_VOLTAGE_CHANGE as the output cutoff reason. + + Note: Refer to Supported Properties by Device for information about supported devices. + + 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. + + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_voltage_change_limit_low = _attributes.AttributeViReal64(1150238) + '''Type: float + + Specifies a limit for negative voltage slew rate, in volts per microsecond, for output cutoff. + If the voltage decreases at a rate that exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the query_latched_output_cutoff_state with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_VOLTAGE_CHANGE as the output cutoff reason. + + Note: Refer to Supported Properties by Device for information about supported devices. + + 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. + + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_voltage_output_limit_high = _attributes.AttributeViReal64(1150236) + '''Type: float + + Specifies a high limit voltage value, in volts, for output cutoff. + If the voltage output exceeds this limit, the output is disconnected. + + To find out whether an output has exceeded this limit, call the query_latched_output_cutoff_state method with OutputCutoffReason.VOLTAGE_OUTPUT_HIGH as the output cutoff reason. + + Note: Refer to Supported Properties by Device for information about supported devices. + + Tip: + This property can use repeated capabilities. If set or get directly on the + nidcpower.Session object, then the set/get 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 set/get value on the result. + ''' + output_cutoff_voltage_output_limit_low = _attributes.AttributeViReal64(1150292) + '''Type: float + + Specifies a low limit voltage value, in volts, for output cutoff. + If the voltage output falls below this limit, the output is disconnected. + + To find out whether an output has fallen below this limit, call the query_latched_output_cutoff_state method with OutputCutoffReason.VOLTAGE_OUTPUT_LOW as the output cutoff reason. + + Note: Refer to Supported Properties by Device for information about supported devices. + Tip: This property can use repeated capabilities. If set or get directly on the nidcpower.Session object, then the set/get will use all repeated capabilities in the session. @@ -2645,6 +2814,55 @@ def self_cal(self): errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return + @ivi_synchronized + def clear_latched_output_cutoff_state(self, output_cutoff_reason): + r'''clear_latched_output_cutoff_state + + Clears the state of an output cutoff that was engaged. + To clear the state for all output cutoff reasons, use OutputCutoffReason.ALL. + + 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: + output_cutoff_reason (enums.OutputCutoffReason): Specifies the reasons for which to clear the output cutoff state. + + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | OutputCutoffReason.ALL | Clears all output cutoff conditions | + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | OutputCutoffReason.VOLTAGE_OUTPUT_HIGH | Clears cutoffs caused when the output exceeded the high cutoff limit for voltage output | + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | OutputCutoffReason.VOLTAGE_OUTPUT_LOW | Clears cutoffs caused when the output fell below the low cutoff limit for voltage output | + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | OutputCutoffReason.CURRENT_MEASURE_HIGH | Clears cutoffs caused when the measured current exceeded the high cutoff limit for current output | + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | OutputCutoffReason.CURRENT_MEASURE_LOW | Clears cutoffs caused when the measured current fell below the low cutoff limit for current output | + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_VOLTAGE_CHANGE | Clears cutoffs caused when the voltage slew rate increased beyond the positive change cutoff for voltage output | + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_VOLTAGE_CHANGE | Clears cutoffs caused when the voltage slew rate decreased beyond the negative change cutoff for voltage output | + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_CURRENT_CHANGE | Clears cutoffs caused when the current slew rate increased beyond the positive change cutoff for current output | + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + | NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_CURRENT_CHANGE | Clears cutoffs caused when the voltage slew rate decreased beyond the negative change cutoff for current output | + +------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------+ + + 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. + + ''' + if type(output_cutoff_reason) is not enums.OutputCutoffReason: + raise TypeError('Parameter output_cutoff_reason must be of type ' + str(enums.OutputCutoffReason)) + vi_ctype = _visatype.ViSession(self._vi) # case S110 + channel_name_ctype = ctypes.create_string_buffer(self._repeated_capability.encode(self._encoding)) # case C010 + output_cutoff_reason_ctype = _visatype.ViInt32(output_cutoff_reason.value) # case S130 + error_code = self._library.niDCPower_ClearLatchedOutputCutoffState(vi_ctype, channel_name_ctype, output_cutoff_reason_ctype) + errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) + return + @ivi_synchronized def configure_aperture_time(self, aperture_time, units=enums.ApertureTimeUnits.SECONDS): r'''configure_aperture_time @@ -2684,11 +2902,11 @@ def configure_aperture_time(self, aperture_time, units=enums.ApertureTimeUnits.S units (enums.ApertureTimeUnits): Specifies the units for **apertureTime**. **Defined Values**: - +--------------------------------------------+------------------------------+ - | ApertureTimeUnits.SECONDS (1028) | Specifies seconds. | - +--------------------------------------------+------------------------------+ - | ApertureTimeUnits.POWER_LINE_CYCLES (1029) | Specifies Power Line Cycles. | - +--------------------------------------------+------------------------------+ + +-------------------------------------+------------------------------+ + | ApertureTimeUnits.SECONDS | Specifies seconds. | + +-------------------------------------+------------------------------+ + | ApertureTimeUnits.POWER_LINE_CYCLES | Specifies Power Line Cycles. | + +-------------------------------------+------------------------------+ ''' if type(units) is not enums.ApertureTimeUnits: @@ -3141,6 +3359,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, index): + r'''get_channel_names + + Returns a comma-separated list of channel names from a string index list. + + 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: + index (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: + channel_name (list of str): The returned channel name(s) at the specified index. + + ''' + vi_ctype = _visatype.ViSession(self._vi) # case S110 + index_ctype = ctypes.create_string_buffer(_converters.convert_repeated_capabilities_without_prefix(index).encode(self._encoding)) # case C040 + buffer_size_ctype = _visatype.ViInt32() # case S170 + channel_name_ctype = None # case C050 + error_code = self._library.niDCPower_GetChannelNameFromString(vi_ctype, index_ctype, buffer_size_ctype, channel_name_ctype) + errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False) + buffer_size_ctype = _visatype.ViInt32(error_code) # case S180 + channel_name_ctype = (_visatype.ViChar * buffer_size_ctype.value)() # case C060 + error_code = self._library.niDCPower_GetChannelNameFromString(vi_ctype, index_ctype, buffer_size_ctype, channel_name_ctype) + errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) + return _converters.convert_comma_separated_string_to_list(channel_name_ctype.value.decode(self._encoding)) + def _get_error(self): r'''_get_error @@ -3256,11 +3512,11 @@ def measure(self, measurement_type): measurement_type (enums.MeasurementTypes): Specifies whether a voltage or current value is measured. **Defined Values**: - +------------------------------+------------------------------+ - | MeasurementTypes.VOLTAGE (1) | The device measures voltage. | - +------------------------------+------------------------------+ - | MeasurementTypes.CURRENT (0) | The device measures current. | - +------------------------------+------------------------------+ + +--------------------------+------------------------------+ + | MeasurementTypes.VOLTAGE | The device measures voltage. | + +--------------------------+------------------------------+ + | MeasurementTypes.CURRENT | The device measures current. | + +--------------------------+------------------------------+ Returns: @@ -3386,6 +3642,71 @@ def query_in_compliance(self): errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return bool(in_compliance_ctype.value) + @ivi_synchronized + def query_latched_output_cutoff_state(self, output_cutoff_reason): + r'''query_latched_output_cutoff_state + + Discovers if an output cutoff limit was exceeded for the specified reason. When an output cutoff is engaged, the output of the channel(s) is disconnected. + If a limit was exceeded, the state is latched until you clear it with the clear_latched_output_cutoff_state method or the ResetWithChannels method. + + outputCutoffReason specifies the conditions for which an output is disconnected. + + Note: + One or more of the referenced methods are not in the Python API for this driver. + + 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: + output_cutoff_reason (enums.OutputCutoffReason): Specifies which output cutoff conditions to query. + + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | OutputCutoffReason.ALL | Any output cutoff condition was met | + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | OutputCutoffReason.VOLTAGE_OUTPUT_HIGH | The output exceeded the high cutoff limit for voltage output | + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | OutputCutoffReason.VOLTAGE_OUTPUT_LOW | The output fell below the low cutoff limit for voltage output | + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | OutputCutoffReason.CURRENT_MEASURE_HIGH | The measured current exceeded the high cutoff limit for current output | + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | OutputCutoffReason.CURRENT_MEASURE_LOW | The measured current fell below the low cutoff limit for current output | + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_VOLTAGE_CHANGE | The voltage slew rate increased beyond the positive change cutoff for voltage output | + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_VOLTAGE_CHANGE | The voltage slew rate decreased beyond the negative change cutoff for voltage output | + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_CURRENT_CHANGE | The current slew rate increased beyond the positive change cutoff for current output | + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + | NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_CURRENT_CHANGE | The current slew rate decreased beyond the negative change cutoff for current output | + +------------------------------------------------------------+--------------------------------------------------------------------------------------+ + + 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. + + + Returns: + output_cutoff_state (bool): Specifies whether an output cutoff has engaged. + + +-------+------------------------------------------------------------------------------+ + | True | An output cutoff has engaged for the conditions in **output cutoff reason**. | + +-------+------------------------------------------------------------------------------+ + | False | No output cutoff has engaged. | + +-------+------------------------------------------------------------------------------+ + + ''' + if type(output_cutoff_reason) is not enums.OutputCutoffReason: + raise TypeError('Parameter output_cutoff_reason must be of type ' + str(enums.OutputCutoffReason)) + vi_ctype = _visatype.ViSession(self._vi) # case S110 + channel_name_ctype = ctypes.create_string_buffer(self._repeated_capability.encode(self._encoding)) # case C010 + output_cutoff_reason_ctype = _visatype.ViInt32(output_cutoff_reason.value) # case S130 + output_cutoff_state_ctype = _visatype.ViBoolean() # case S220 + error_code = self._library.niDCPower_QueryLatchedOutputCutoffState(vi_ctype, channel_name_ctype, output_cutoff_reason_ctype, None if output_cutoff_state_ctype is None else (ctypes.pointer(output_cutoff_state_ctype))) + errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) + return bool(output_cutoff_state_ctype.value) + @ivi_synchronized def query_max_current_limit(self, voltage_level): r'''query_max_current_limit @@ -3500,11 +3821,11 @@ def query_output_state(self, output_state): output_state (enums.OutputStates): Specifies the output state of the output channel that is being queried. **Defined Values**: - +--------------------------+-------------------------------------------------------------------+ - | OutputStates.VOLTAGE (0) | The device maintains a constant voltage by adjusting the current. | - +--------------------------+-------------------------------------------------------------------+ - | OutputStates.CURRENT (1) | The device maintains a constant current by adjusting the voltage. | - +--------------------------+-------------------------------------------------------------------+ + +----------------------+-------------------------------------------------------------------+ + | OutputStates.VOLTAGE | The device maintains a constant voltage by adjusting the current. | + +----------------------+-------------------------------------------------------------------+ + | OutputStates.CURRENT | The device maintains a constant current by adjusting the voltage. | + +----------------------+-------------------------------------------------------------------+ Returns: @@ -5172,19 +5493,19 @@ def send_software_edge_trigger(self, trigger): trigger (enums.SendSoftwareEdgeTriggerType): Specifies which trigger to assert. **Defined Values:** - +-----------------------------------------------+---------------------------------------+ - | NIDCPOWER_VAL_START_TRIGGER (1034) | Asserts the Start trigger. | - +-----------------------------------------------+---------------------------------------+ - | NIDCPOWER_VAL_SOURCE_TRIGGER (1035) | Asserts the Source trigger. | - +-----------------------------------------------+---------------------------------------+ - | NIDCPOWER_VAL_MEASURE_TRIGGER (1036) | Asserts the Measure trigger. | - +-----------------------------------------------+---------------------------------------+ - | NIDCPOWER_VAL_SEQUENCE_ADVANCE_TRIGGER (1037) | Asserts the Sequence Advance trigger. | - +-----------------------------------------------+---------------------------------------+ - | NIDCPOWER_VAL_PULSE_TRIGGER (1053) | Asserts the Pulse trigger. | - +-----------------------------------------------+---------------------------------------+ - | NIDCPOWER_VAL_SHUTDOWN_TRIGGER (1118) | Asserts the Shutdown trigger. | - +-----------------------------------------------+---------------------------------------+ + +----------------------------------------+---------------------------------------+ + | NIDCPOWER_VAL_START_TRIGGER | Asserts the Start trigger. | + +----------------------------------------+---------------------------------------+ + | NIDCPOWER_VAL_SOURCE_TRIGGER | Asserts the Source trigger. | + +----------------------------------------+---------------------------------------+ + | NIDCPOWER_VAL_MEASURE_TRIGGER | Asserts the Measure trigger. | + +----------------------------------------+---------------------------------------+ + | NIDCPOWER_VAL_SEQUENCE_ADVANCE_TRIGGER | Asserts the Sequence Advance trigger. | + +----------------------------------------+---------------------------------------+ + | NIDCPOWER_VAL_PULSE_TRIGGER | Asserts the Pulse trigger. | + +----------------------------------------+---------------------------------------+ + | NIDCPOWER_VAL_SHUTDOWN_TRIGGER | Asserts the Shutdown trigger. | + +----------------------------------------+---------------------------------------+ 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. @@ -5219,19 +5540,19 @@ def wait_for_event(self, event_id, timeout=hightime.timedelta(seconds=10.0)): event_id (enums.Event): Specifies which event to wait for. **Defined Values:** - +--------------------------------------------------------+--------------------------------------------------+ - | NIDCPOWER_VAL_SOURCE_COMPLETE_EVENT (1030) | Waits for the Source Complete event. | - +--------------------------------------------------------+--------------------------------------------------+ - | NIDCPOWER_VAL_MEASURE_COMPLETE_EVENT (1031) | Waits for the Measure Complete event. | - +--------------------------------------------------------+--------------------------------------------------+ - | NIDCPOWER_VAL_SEQUENCE_ITERATION_COMPLETE_EVENT (1032) | Waits for the Sequence Iteration Complete event. | - +--------------------------------------------------------+--------------------------------------------------+ - | NIDCPOWER_VAL_SEQUENCE_ENGINE_DONE_EVENT (1033) | Waits for the Sequence Engine Done event. | - +--------------------------------------------------------+--------------------------------------------------+ - | NIDCPOWER_VAL_PULSE_COMPLETE_EVENT (1051 ) | Waits for the Pulse Complete event. | - +--------------------------------------------------------+--------------------------------------------------+ - | NIDCPOWER_VAL_READY_FOR_PULSE_TRIGGER_EVENT (1052) | Waits for the Ready for Pulse Trigger event. | - +--------------------------------------------------------+--------------------------------------------------+ + +-------------------------------------------------+--------------------------------------------------+ + | NIDCPOWER_VAL_SOURCE_COMPLETE_EVENT | Waits for the Source Complete event. | + +-------------------------------------------------+--------------------------------------------------+ + | NIDCPOWER_VAL_MEASURE_COMPLETE_EVENT | Waits for the Measure Complete event. | + +-------------------------------------------------+--------------------------------------------------+ + | NIDCPOWER_VAL_SEQUENCE_ITERATION_COMPLETE_EVENT | Waits for the Sequence Iteration Complete event. | + +-------------------------------------------------+--------------------------------------------------+ + | NIDCPOWER_VAL_SEQUENCE_ENGINE_DONE_EVENT | Waits for the Sequence Engine Done event. | + +-------------------------------------------------+--------------------------------------------------+ + | NIDCPOWER_VAL_PULSE_COMPLETE_EVENT | Waits for the Pulse Complete event. | + +-------------------------------------------------+--------------------------------------------------+ + | NIDCPOWER_VAL_READY_FOR_PULSE_TRIGGER_EVENT | Waits for the Ready for Pulse Trigger event. | + +-------------------------------------------------+--------------------------------------------------+ 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. diff --git a/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py b/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py index af0fd24ea..2ff13c281 100644 --- a/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py +++ b/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py @@ -20,6 +20,8 @@ def __init__(self): self._defaults['Abort']['return'] = 0 self._defaults['CalSelfCalibrate'] = {} self._defaults['CalSelfCalibrate']['return'] = 0 + self._defaults['ClearLatchedOutputCutoffState'] = {} + self._defaults['ClearLatchedOutputCutoffState']['return'] = 0 self._defaults['Commit'] = {} self._defaults['Commit']['return'] = 0 self._defaults['ConfigureApertureTime'] = {} @@ -61,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 @@ -113,6 +118,9 @@ def __init__(self): self._defaults['QueryInCompliance'] = {} self._defaults['QueryInCompliance']['return'] = 0 self._defaults['QueryInCompliance']['inCompliance'] = None + self._defaults['QueryLatchedOutputCutoffState'] = {} + self._defaults['QueryLatchedOutputCutoffState']['return'] = 0 + self._defaults['QueryLatchedOutputCutoffState']['outputCutoffState'] = None self._defaults['QueryMaxCurrentLimit'] = {} self._defaults['QueryMaxCurrentLimit']['return'] = 0 self._defaults['QueryMaxCurrentLimit']['maxCurrentLimit'] = None @@ -179,6 +187,11 @@ def niDCPower_CalSelfCalibrate(self, vi, channel_name): # noqa: N802 return self._defaults['CalSelfCalibrate']['return'] return self._defaults['CalSelfCalibrate']['return'] + def niDCPower_ClearLatchedOutputCutoffState(self, vi, channel_name, output_cutoff_reason): # noqa: N802 + if self._defaults['ClearLatchedOutputCutoffState']['return'] != 0: + return self._defaults['ClearLatchedOutputCutoffState']['return'] + return self._defaults['ClearLatchedOutputCutoffState']['return'] + def niDCPower_Commit(self, vi): # noqa: N802 if self._defaults['Commit']['return'] != 0: return self._defaults['Commit']['return'] @@ -332,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, index, buffer_size, channel_name): # 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']) + channel_name.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'] @@ -529,6 +552,16 @@ def niDCPower_QueryInCompliance(self, vi, channel_name, in_compliance): # noqa: in_compliance.contents.value = self._defaults['QueryInCompliance']['inCompliance'] return self._defaults['QueryInCompliance']['return'] + def niDCPower_QueryLatchedOutputCutoffState(self, vi, channel_name, output_cutoff_reason, output_cutoff_state): # noqa: N802 + if self._defaults['QueryLatchedOutputCutoffState']['return'] != 0: + return self._defaults['QueryLatchedOutputCutoffState']['return'] + # output_cutoff_state + if self._defaults['QueryLatchedOutputCutoffState']['outputCutoffState'] is None: + raise MockFunctionCallError("niDCPower_QueryLatchedOutputCutoffState", param='outputCutoffState') + if output_cutoff_state is not None: + output_cutoff_state.contents.value = self._defaults['QueryLatchedOutputCutoffState']['outputCutoffState'] + return self._defaults['QueryLatchedOutputCutoffState']['return'] + def niDCPower_QueryMaxCurrentLimit(self, vi, channel_name, voltage_level, max_current_limit): # noqa: N802 if self._defaults['QueryMaxCurrentLimit']['return'] != 0: return self._defaults['QueryMaxCurrentLimit']['return'] @@ -688,6 +721,8 @@ def set_side_effects_and_return_values(self, mock_library): mock_library.niDCPower_Abort.return_value = 0 mock_library.niDCPower_CalSelfCalibrate.side_effect = MockFunctionCallError("niDCPower_CalSelfCalibrate") mock_library.niDCPower_CalSelfCalibrate.return_value = 0 + mock_library.niDCPower_ClearLatchedOutputCutoffState.side_effect = MockFunctionCallError("niDCPower_ClearLatchedOutputCutoffState") + mock_library.niDCPower_ClearLatchedOutputCutoffState.return_value = 0 mock_library.niDCPower_Commit.side_effect = MockFunctionCallError("niDCPower_Commit") mock_library.niDCPower_Commit.return_value = 0 mock_library.niDCPower_ConfigureApertureTime.side_effect = MockFunctionCallError("niDCPower_ConfigureApertureTime") @@ -718,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") @@ -748,6 +785,8 @@ def set_side_effects_and_return_values(self, mock_library): mock_library.niDCPower_ParseChannelCount.return_value = 0 mock_library.niDCPower_QueryInCompliance.side_effect = MockFunctionCallError("niDCPower_QueryInCompliance") mock_library.niDCPower_QueryInCompliance.return_value = 0 + mock_library.niDCPower_QueryLatchedOutputCutoffState.side_effect = MockFunctionCallError("niDCPower_QueryLatchedOutputCutoffState") + mock_library.niDCPower_QueryLatchedOutputCutoffState.return_value = 0 mock_library.niDCPower_QueryMaxCurrentLimit.side_effect = MockFunctionCallError("niDCPower_QueryMaxCurrentLimit") mock_library.niDCPower_QueryMaxCurrentLimit.return_value = 0 mock_library.niDCPower_QueryMaxVoltageLevel.side_effect = MockFunctionCallError("niDCPower_QueryMaxVoltageLevel") diff --git a/src/nidcpower/metadata/attributes.py b/src/nidcpower/metadata/attributes.py index 881b380d4..f2d036698 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 20.7.0d8 +# This file is generated from NI-DCPower API metadata version 21.0.0d38 attributes = { 1050003: { 'access': 'read-write', @@ -1550,6 +1550,78 @@ 'resettable': False, 'type': 'ViInt32' }, + 1150235: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nEnables or disables output cutoff functionality. If enabled, you can define output cutoffs that, if exceeded, cause the output of the specified channel(s) to be disconnected.\nWhen this attribute is disabled, all other output cutoff attributes are ignored.', + 'note': 'Refer to Supported Attributes by Device for information about supported devices. Instruments that do not support this attribute behave as if this attribute were set to VI_FALSE.' + }, + 'lv_property': 'Source:Output Cutoff:Enabled', + 'name': 'OUTPUT_CUTOFF_ENABLED', + 'resettable': False, + 'type': 'ViBoolean' + }, + 1150236: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nSpecifies a high limit voltage value, in volts, for output cutoff.\nIf the voltage output exceeds this limit, the output is disconnected.\n\nTo find out whether an output has exceeded this limit, call the niDCPower_QueryLatchedOutputCutoffState function with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_OUTPUT_HIGH as the output cutoff reason.\n', + 'note': 'Refer to Supported Attributes by Device for information about supported devices.' + }, + 'lv_property': 'Source:Output Cutoff:Voltage Output Limit High', + 'name': 'OUTPUT_CUTOFF_VOLTAGE_OUTPUT_LIMIT_HIGH', + 'resettable': False, + 'type': 'ViReal64' + }, + 1150237: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nSpecifies a high limit current value, in amps, for output cutoff.\nIf the measured current exceeds this limit, the output is disconnected.\n\nTo find out whether an output has exceeded this limit, call the niDCPower_QueryLatchedOutputCutoffState function with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_MEASURE_HIGH as the output cutoff reason.\n', + 'note': 'Refer to Supported Attributes by Device for information about supported devices.' + }, + 'lv_property': 'Source:Output Cutoff:Current Measure Limit High', + 'name': 'OUTPUT_CUTOFF_CURRENT_MEASURE_LIMIT_HIGH', + 'resettable': False, + 'type': 'ViReal64' + }, + 1150238: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nSpecifies a limit for negative voltage slew rate, in volts per microsecond, for output cutoff.\nIf the voltage decreases at a rate that exceeds this limit, the output is disconnected.\n\nTo find out whether an output has exceeded this limit, call the niDCPower_QueryLatchedOutputCutoffState with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_VOLTAGE_CHANGE as the output cutoff reason.\n', + 'note': 'Refer to Supported Attributes by Device for information about supported devices.' + }, + 'lv_property': 'Source:Output Cutoff:Voltage Change Limit Low', + 'name': 'OUTPUT_CUTOFF_VOLTAGE_CHANGE_LIMIT_LOW', + 'resettable': False, + 'type': 'ViReal64' + }, + 1150239: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nSpecifies a limit for negative current slew rate, in amps per microsecond, for output cutoff.\nIf the current decreases at a rate that exceeds this limit, the output is disconnected.\n\nTo find out whether an output has exceeded this limit, call the niDCPower_QueryLatchedOutputCutoffState function with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_CURRENT_CHANGE as the output cutoff reason.\n', + 'note': 'Refer to Supported Attributes by Device for information about supported devices.' + }, + 'lv_property': 'Source:Output Cutoff:Current Change Limit Low', + 'name': 'OUTPUT_CUTOFF_CURRENT_CHANGE_LIMIT_LOW', + 'resettable': False, + 'type': 'ViReal64' + }, + 1150240: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nEnables or disables current overrange functionality for output cutoff. If enabled, the output is disconnected when the measured current saturates the current range.\n\nTo find out whether an output has exceeded this limit, call the niDCPower_QueryLatchedOutputCutoffState function with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_OUTPUT_HIGH as the output cutoff reason.\n', + 'note': 'Refer to Supported Attributes by Device for information about supported devices.' + }, + 'lv_property': 'Source:Output Cutoff:Current Overrange Enabled', + 'name': 'OUTPUT_CUTOFF_CURRENT_OVERRANGE_ENABLED', + 'resettable': False, + 'type': 'ViBoolean' + }, 1150244: { 'access': 'read-write', 'channel_based': True, @@ -1689,6 +1761,54 @@ 'resettable': False, 'type': 'ViString' }, + 1150292: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nSpecifies a low limit voltage value, in volts, for output cutoff.\nIf the voltage output falls below this limit, the output is disconnected.\n\nTo find out whether an output has fallen below this limit, call the niDCPower_QueryLatchedOutputCutoffState function with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_OUTPUT_LOW as the output cutoff reason.\n', + 'note': 'Refer to Supported Attributes by Device for information about supported devices.' + }, + 'lv_property': 'Source:Output Cutoff:Voltage Output Limit Low', + 'name': 'OUTPUT_CUTOFF_VOLTAGE_OUTPUT_LIMIT_LOW', + 'resettable': False, + 'type': 'ViReal64' + }, + 1150293: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nSpecifies a low limit current value, in amps, for output cutoff.\nIf the measured current falls below this limit, the output is disconnected.\n\nTo find out whether an output has fallen below this limit, call the niDCPower_QueryLatchedOutputCutoffState function with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_MEASURE_LOW as the output cutoff reason.\n', + 'note': 'Refer to Supported Attributes by Device for information about supported devices.' + }, + 'lv_property': 'Source:Output Cutoff:Current Measure Limit Low', + 'name': 'OUTPUT_CUTOFF_CURRENT_MEASURE_LIMIT_LOW', + 'resettable': False, + 'type': 'ViReal64' + }, + 1150294: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nSpecifies a limit for positive voltage slew rate, in volts per microsecond, for output cutoff.\nIf the voltage increases at a rate that exceeds this limit, the output is disconnected.\n\nTo find out whether an output has exceeded this limit, call the niDCPower_QueryLatchedOutputCutoffState with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_VOLTAGE_CHANGE as the output cutoff reason.\n', + 'note': 'Refer to Supported Attributes by Device for information about supported devices.' + }, + 'lv_property': 'Source:Output Cutoff:Voltage Change Limit High', + 'name': 'OUTPUT_CUTOFF_VOLTAGE_CHANGE_LIMIT_HIGH', + 'resettable': False, + 'type': 'ViReal64' + }, + 1150295: { + 'access': 'read-write', + 'channel_based': True, + 'documentation': { + 'description': '\nSpecifies a limit for positive current slew rate, in amps per microsecond, for output cutoff.\nIf the current increases at a rate that exceeds this limit, the output is disconnected.\n\nTo find out whether an output has exceeded this limit, call the niDCPower_QueryLatchedOutputCutoffState function with NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_CURRENT_CHANGE as the output cutoff reason.\n', + 'note': 'Refer to Supported Attributes by Device for information about supported devices.' + }, + 'lv_property': 'Source:Output Cutoff:Current Change Limit High', + 'name': 'OUTPUT_CUTOFF_CURRENT_CHANGE_LIMIT_HIGH', + 'resettable': False, + 'type': 'ViReal64' + }, 1250001: { 'access': 'read-write', 'channel_based': True, diff --git a/src/nidcpower/metadata/enums.py b/src/nidcpower/metadata/enums.py index 04ba35357..1ec9015dd 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 20.7.0d8 +# This file is generated from NI-DCPower API metadata version 21.0.0d38 enums = { 'ApertureTimeUnits': { 'values': [ @@ -375,6 +375,73 @@ } ] }, + 'OutputCutoffReason': { + 'values': [ + { + 'documentation': { + 'description': 'Queries any output cutoff condition; clears all output cutoff conditions.' + }, + 'name': 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_ALL', + 'value': -1 + }, + { + 'documentation': { + 'description': 'Queries or clears cutoff conditions when the output exceeded the high cutoff limit for voltage output.' + }, + 'name': 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_OUTPUT_HIGH', + 'value': 1 + }, + { + 'documentation': { + 'description': 'Queries or clears cutoff conditions when the output fell below the low cutoff limit for voltage output.' + }, + 'name': 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_OUTPUT_LOW', + 'value': 2 + }, + { + 'documentation': { + 'description': 'Queries or clears cutoff conditions when the measured current exceeded the high cutoff limit for current output.' + }, + 'name': 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_MEASURE_HIGH', + 'value': 4 + }, + { + 'documentation': { + 'description': 'Queries or clears cutoff conditions when the measured current fell below the low cutoff limit for current output.' + }, + 'name': 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_MEASURE_LOW', + 'value': 8 + }, + { + 'documentation': { + 'description': 'Queries or clears cutoff conditions when the voltage slew rate increased beyond the positive change cutoff for voltage output.' + }, + 'name': 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_CHANGE_HIGH', + 'value': 16 + }, + { + 'documentation': { + 'description': 'Queries or clears cutoff conditions when the voltage slew rate decreased beyond the negative change cutoff for voltage output.' + }, + 'name': 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_CHANGE_LOW', + 'value': 32 + }, + { + 'documentation': { + 'description': 'Queries or clears cutoff conditions when the current slew rate increased beyond the positive change cutoff for current output.' + }, + 'name': 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_CHANGE_HIGH', + 'value': 64 + }, + { + 'documentation': { + 'description': 'Queries or clears cutoff conditions when the current slew rate decreased beyond the negative change cutoff for current output.' + }, + 'name': 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_CHANGE_LOW', + 'value': 128 + } + ] + }, 'OutputFunction': { 'values': [ { diff --git a/src/nidcpower/metadata/functions.py b/src/nidcpower/metadata/functions.py index 3889db228..18d7d3116 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 20.7.0d8 +# This file is generated from NI-DCPower API metadata version 21.0.0d38 functions = { 'Abort': { 'documentation': { @@ -43,6 +43,77 @@ 'python_name': 'self_cal', 'returns': 'ViStatus' }, + 'ClearLatchedOutputCutoffState': { + 'documentation': { + 'description': 'Clears the state of an output cutoff that was engaged.\nTo clear the state for all output cutoff reasons, use NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_ALL.\n' + }, + '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': '\nSpecifies the output channel(s) to which this configuration value\napplies. Specify multiple channels by using a channel list or a channel\nrange. A channel list is a comma (,) separated sequence of channel names\n(for example, 0,2 specifies channels 0 and 2). A channel range is a\nlower bound channel followed by a hyphen (-) or colon (:) followed by an\nupper bound channel (for example, 0-2 specifies channels 0, 1, and 2).\nIn the Running state, multiple output channel configurations are\nperformed sequentially based on the order specified in this parameter.\n' + }, + 'name': 'channelName', + 'type': 'ViConstString' + }, + { + 'direction': 'in', + 'documentation': { + 'description': 'Specifies the reasons for which to clear the output cutoff state.\n', + 'table_body': [ + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_ALL', + 'Clears all output cutoff conditions' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_OUTPUT_HIGH', + 'Clears cutoffs caused when the output exceeded the high cutoff limit for voltage output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_OUTPUT_LOW', + 'Clears cutoffs caused when the output fell below the low cutoff limit for voltage output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_MEASURE_HIGH', + 'Clears cutoffs caused when the measured current exceeded the high cutoff limit for current output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_MEASURE_LOW', + 'Clears cutoffs caused when the measured current fell below the low cutoff limit for current output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_VOLTAGE_CHANGE', + 'Clears cutoffs caused when the voltage slew rate increased beyond the positive change cutoff for voltage output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_VOLTAGE_CHANGE', + 'Clears cutoffs caused when the voltage slew rate decreased beyond the negative change cutoff for voltage output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_CURRENT_CHANGE', + 'Clears cutoffs caused when the current slew rate increased beyond the positive change cutoff for current output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_CURRENT_CHANGE', + 'Clears cutoffs caused when the voltage slew rate decreased beyond the negative change cutoff for current output' + ] + ] + }, + 'enum': 'OutputCutoffReason', + 'name': 'outputCutoffReason', + 'type': 'ViInt32' + } + ], + 'returns': 'ViStatus' + }, 'Commit': { 'documentation': { 'description': '\nApplies previously configured settings to the device. Calling this\nfunction moves the NI-DCPower session from the Uncommitted state into\nthe Committed state. After calling this function, modifying any\nattribute reverts the NI-DCPower session to the Uncommitted state. Use\nthe niDCPower_Initiate function to transition to the Running state.\nRefer to the `Programming\nStates `__ topic in\nthe *NI DC Power Supplies and SMUs Help* for details about the specific\nNI-DCPower software states.\n\n**Related Topics:**\n\n`Programming\nStates `__\n' @@ -96,11 +167,11 @@ 'description': '\nSpecifies the units for **apertureTime**.\n**Defined Values**:\n', 'table_body': [ [ - 'NIDCPOWER_VAL_SECONDS (1028)', + 'NIDCPOWER_VAL_SECONDS', 'Specifies seconds.' ], [ - 'NIDCPOWER_VAL_POWER_LINE_CYCLES (1029)', + 'NIDCPOWER_VAL_POWER_LINE_CYCLES', 'Specifies Power Line Cycles.' ] ] @@ -1352,6 +1423,55 @@ ], 'returns': 'ViStatus' }, + 'GetChannelNameFromString': { + 'documentation': { + 'description': '\nReturns a comma-separated list of channel names from a string index list.' + }, + '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', + '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 returned channel name(s) at the specified index.' + }, + 'name': 'channelName', + 'python_api_converter_name': 'convert_comma_separated_string_to_list', + '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': { @@ -1862,11 +1982,11 @@ 'description': '\nSpecifies whether a voltage or current value is measured.\n**Defined Values**:\n', 'table_body': [ [ - 'NIDCPOWER_VAL_MEASURE_VOLTAGE (1)', + 'NIDCPOWER_VAL_MEASURE_VOLTAGE', 'The device measures voltage.' ], [ - 'NIDCPOWER_VAL_MEASURE_CURRENT (0)', + 'NIDCPOWER_VAL_MEASURE_CURRENT', 'The device measures current.' ] ] @@ -1994,6 +2114,95 @@ ], 'returns': 'ViStatus' }, + 'QueryLatchedOutputCutoffState': { + 'documentation': { + 'description': '\nDiscovers if an output cutoff limit was exceeded for the specified reason. When an output cutoff is engaged, the output of the channel(s) is disconnected.\nIf a limit was exceeded, the state is latched until you clear it with the niDCPower_ClearLatchedOutputCutoffState function or the niDCPower_ResetWithChannels function.\n\noutputCutoffReason specifies the conditions for which an output is disconnected.\n' + }, + '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': '\nSpecifies the output channel(s) to which this configuration value\napplies. Specify multiple channels by using a channel list or a channel\nrange. A channel list is a comma (,) separated sequence of channel names\n(for example, 0,2 specifies channels 0 and 2). A channel range is a\nlower bound channel followed by a hyphen (-) or colon (:) followed by an\nupper bound channel (for example, 0-2 specifies channels 0, 1, and 2).\nIn the Running state, multiple output channel configurations are\nperformed sequentially based on the order specified in this parameter.\n' + }, + 'name': 'channelName', + 'type': 'ViConstString' + }, + { + 'direction': 'in', + 'documentation': { + 'description': 'Specifies which output cutoff conditions to query.\n', + 'table_body': [ + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_ALL', + 'Any output cutoff condition was met' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_OUTPUT_HIGH', + 'The output exceeded the high cutoff limit for voltage output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_VOLTAGE_OUTPUT_LOW', + 'The output fell below the low cutoff limit for voltage output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_MEASURE_HIGH', + 'The measured current exceeded the high cutoff limit for current output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_CURRENT_MEASURE_LOW', + 'The measured current fell below the low cutoff limit for current output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_VOLTAGE_CHANGE', + 'The voltage slew rate increased beyond the positive change cutoff for voltage output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_VOLTAGE_CHANGE', + 'The voltage slew rate decreased beyond the negative change cutoff for voltage output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_POSITIVE_CURRENT_CHANGE', + 'The current slew rate increased beyond the positive change cutoff for current output' + ], + [ + 'NIDCPOWER_VAL_OUTPUT_CUTOFF_REASON_NEGATIVE_CURRENT_CHANGE', + 'The current slew rate decreased beyond the negative change cutoff for current output' + ] + ] + }, + 'enum': 'OutputCutoffReason', + 'name': 'outputCutoffReason', + 'type': 'ViInt32' + }, + { + 'direction': 'out', + 'documentation': { + 'description': 'Specifies whether an output cutoff has engaged.\n', + 'table_body': [ + [ + 'VI_TRUE', + 'An output cutoff has engaged for the conditions in **output cutoff reason**.' + ], + [ + 'VI_FALSE', + 'No output cutoff has engaged.' + ] + ] + }, + 'name': 'outputCutoffState', + 'type': 'ViBoolean' + } + ], + 'returns': 'ViStatus' + }, 'QueryMaxCurrentLimit': { 'documentation': { 'description': '\nQueries the maximum current limit on an output channel if the output\nchannel is set to the specified **voltageLevel**.\n' @@ -2141,11 +2350,11 @@ 'description': '\nSpecifies the output state of the output channel that is being queried.\n**Defined Values**:\n', 'table_body': [ [ - 'NIDCPOWER_VAL_OUTPUT_CONSTANT_VOLTAGE (0)', + 'NIDCPOWER_VAL_OUTPUT_CONSTANT_VOLTAGE', 'The device maintains a constant voltage by adjusting the current.' ], [ - 'NIDCPOWER_VAL_OUTPUT_CONSTANT_CURRENT (1)', + 'NIDCPOWER_VAL_OUTPUT_CONSTANT_CURRENT', 'The device maintains a constant current by adjusting the voltage.' ] ] @@ -2241,27 +2450,27 @@ 'description': '\nSpecifies which trigger to assert.\n**Defined Values:**\n', 'table_body': [ [ - 'NIDCPOWER_VAL_START_TRIGGER (1034)', + 'NIDCPOWER_VAL_START_TRIGGER', 'Asserts the Start trigger.' ], [ - 'NIDCPOWER_VAL_SOURCE_TRIGGER (1035)', + 'NIDCPOWER_VAL_SOURCE_TRIGGER', 'Asserts the Source trigger.' ], [ - 'NIDCPOWER_VAL_MEASURE_TRIGGER (1036)', + 'NIDCPOWER_VAL_MEASURE_TRIGGER', 'Asserts the Measure trigger.' ], [ - 'NIDCPOWER_VAL_SEQUENCE_ADVANCE_TRIGGER (1037)', + 'NIDCPOWER_VAL_SEQUENCE_ADVANCE_TRIGGER', 'Asserts the Sequence Advance trigger.' ], [ - 'NIDCPOWER_VAL_PULSE_TRIGGER (1053)', + 'NIDCPOWER_VAL_PULSE_TRIGGER', 'Asserts the Pulse trigger.' ], [ - 'NIDCPOWER_VAL_SHUTDOWN_TRIGGER (1118)', + 'NIDCPOWER_VAL_SHUTDOWN_TRIGGER', 'Asserts the Shutdown trigger.' ] ] @@ -2594,27 +2803,27 @@ 'description': '\nSpecifies which event to wait for.\n**Defined Values:**\n', 'table_body': [ [ - 'NIDCPOWER_VAL_SOURCE_COMPLETE_EVENT (1030)', + 'NIDCPOWER_VAL_SOURCE_COMPLETE_EVENT', 'Waits for the Source Complete event.' ], [ - 'NIDCPOWER_VAL_MEASURE_COMPLETE_EVENT (1031)', + 'NIDCPOWER_VAL_MEASURE_COMPLETE_EVENT', 'Waits for the Measure Complete event.' ], [ - 'NIDCPOWER_VAL_SEQUENCE_ITERATION_COMPLETE_EVENT (1032)', + 'NIDCPOWER_VAL_SEQUENCE_ITERATION_COMPLETE_EVENT', 'Waits for the Sequence Iteration Complete event.' ], [ - 'NIDCPOWER_VAL_SEQUENCE_ENGINE_DONE_EVENT (1033)', + 'NIDCPOWER_VAL_SEQUENCE_ENGINE_DONE_EVENT', 'Waits for the Sequence Engine Done event.' ], [ - 'NIDCPOWER_VAL_PULSE_COMPLETE_EVENT (1051 )', + 'NIDCPOWER_VAL_PULSE_COMPLETE_EVENT', 'Waits for the Pulse Complete event.' ], [ - 'NIDCPOWER_VAL_READY_FOR_PULSE_TRIGGER_EVENT (1052)', + 'NIDCPOWER_VAL_READY_FOR_PULSE_TRIGGER_EVENT', 'Waits for the Ready for Pulse Trigger event.' ] ] From a9351c48ef5eae050e0aaff2890e5f82f90711ac Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Wed, 7 Apr 2021 17:36:49 -0500 Subject: [PATCH 04/14] Update changelog --- CHANGELOG.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f116ecfa..867f0f538 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* [Unreleased](#unreleased) * [1.3.3](#133---2021-02-26) * [1.3.2](#132---2020-09-18) * [1.3.1](#131---2020-06-08) @@ -25,6 +26,51 @@ All notable changes to this project will be documented in this file. +## Unreleased +* ### ALL + * #### Added + * #### Changed + * #### Removed +* ### `nidcpower` (NI-DCPower) + * #### Added + `get_channel_names` - [#1386](https://github.com/ni/nimi-python/issues/1386) + * #### Changed + * #### Removed + `get_channel_name` and `get_channel_name_from_string` - [#1386](https://github.com/ni/nimi-python/issues/1386) +* ### `nidigital` (NI-Digital Pattern Driver) + * #### Added + * #### Changed + * #### Removed +* ### `nidmm` (NI-DMM) + * #### Added + * #### Changed + * #### Removed +* ### `nifgen` (NI-FGEN) + * #### Added + * #### Changed + * #### Removed +* ### `nimodinst` (NI-ModInst) + * #### Added + * #### Changed + * #### Removed +* ### `niscope` (NI-SCOPE) + * #### Added + * #### Changed + * #### Removed +* ### `niswitch` (NI-SWITCH) + * #### Added + * #### Changed + * #### Removed +* ### `nise` (NI Switch Executive) + * #### Added + * #### Changed + * #### Removed +* ### `nitclk` (NI-TClk) + * #### Added + * #### Changed + * #### Removed + + ## 1.3.3 - 2021-02-26 * ### `nidcpower` (NI-DCPower) * #### Added From ca843cadd76038a69f5a6ee54b3c9d853fbfef83 Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Thu, 22 Apr 2021 10:53:49 -0500 Subject: [PATCH 05/14] Address code review feedback (https://github.com/ni/nimi-python/pull/1578) --- CHANGELOG.md | 3 +-- docs/nidcpower/class.rst | 10 +++++----- generated/nidcpower/nidcpower/_library.py | 6 +++--- generated/nidcpower/nidcpower/session.py | 20 +++++++++---------- .../nidcpower/unit_tests/_mock_helper.py | 4 ++-- src/nidcpower/metadata/attributes.py | 2 +- src/nidcpower/metadata/config.py | 4 ++-- src/nidcpower/metadata/enums.py | 2 +- src/nidcpower/metadata/functions.py | 8 +++++--- .../system_tests/test_system_nidcpower.py | 5 +++++ 10 files changed, 35 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbfb78d6b..5043edcc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ All notable changes to this project will be documented in this file. * #### Removed * ### `nidcpower` (NI-DCPower) * #### Added - * `get_channel_names` - [#1386](https://github.com/ni/nimi-python/issues/1386) + * `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` @@ -51,7 +51,6 @@ All notable changes to this project will be documented in this file. * `query_latched_output_cutoff_state` * #### Changed * #### Removed - * `get_channel_name` and `get_channel_name_from_string` - [#1386](https://github.com/ni/nimi-python/issues/1386) * #### Changed * #### Removed * ### `nidigital` (NI-Digital Pattern Driver) diff --git a/docs/nidcpower/class.rst b/docs/nidcpower/class.rst index 85a4912e9..f0266e7c8 100644 --- a/docs/nidcpower/class.rst +++ b/docs/nidcpower/class.rst @@ -863,9 +863,9 @@ get_channel_names .. py:currentmodule:: nidcpower.Session - .. py:method:: get_channel_names(index) + .. py:method:: get_channel_names(indices) - Returns a comma-separated list of channel names from a string index list. + Returns a list of channel names for given channel indices. @@ -876,7 +876,7 @@ get_channel_names nidcpower.Session repeated capabilities container, and calling this method on the result. - :param index: + :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: @@ -890,13 +890,13 @@ get_channel_names - :type index: basic sequence types or str or int + :type indices: basic sequence types or str or int :rtype: list of str :return: - The returned channel name(s) at the specified index. + The channel name(s) at the specified indices. diff --git a/generated/nidcpower/nidcpower/_library.py b/generated/nidcpower/nidcpower/_library.py index 9a9dd70a1..298ef6d15 100644 --- a/generated/nidcpower/nidcpower/_library.py +++ b/generated/nidcpower/nidcpower/_library.py @@ -226,13 +226,13 @@ 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, index, buffer_size, channel_name): # noqa: N802 + 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._library.niDCPower_GetChannelNameFromString + 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, index, buffer_size, channel_name) + 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: diff --git a/generated/nidcpower/nidcpower/session.py b/generated/nidcpower/nidcpower/session.py index 0deeba2bc..bc32f5224 100644 --- a/generated/nidcpower/nidcpower/session.py +++ b/generated/nidcpower/nidcpower/session.py @@ -3693,10 +3693,10 @@ def _get_attribute_vi_string(self, attribute_id): return attribute_value_ctype.value.decode(self._encoding) @ivi_synchronized - def get_channel_names(self, index): + def get_channel_names(self, indices): r'''get_channel_names - Returns a comma-separated list of channel names from a string index list. + Returns a list of channel names for given channel indices. Tip: This method requires repeated capabilities. If called directly on the @@ -3705,7 +3705,7 @@ def get_channel_names(self, index): nidcpower.Session repeated capabilities container, and calling this method on the result. Args: - index (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: + 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" @@ -3715,20 +3715,20 @@ def get_channel_names(self, index): Returns: - channel_name (list of str): The returned channel name(s) at the specified index. + names (list of str): The channel name(s) at the specified indices. ''' vi_ctype = _visatype.ViSession(self._vi) # case S110 - index_ctype = ctypes.create_string_buffer(_converters.convert_repeated_capabilities_without_prefix(index).encode(self._encoding)) # case C040 + 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 - channel_name_ctype = None # case C050 - error_code = self._library.niDCPower_GetChannelNameFromString(vi_ctype, index_ctype, buffer_size_ctype, channel_name_ctype) + 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 - channel_name_ctype = (_visatype.ViChar * buffer_size_ctype.value)() # case C060 - error_code = self._library.niDCPower_GetChannelNameFromString(vi_ctype, index_ctype, buffer_size_ctype, channel_name_ctype) + 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(channel_name_ctype.value.decode(self._encoding)) + 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 ddd636a23..94a77356f 100644 --- a/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py +++ b/generated/nidcpower/nidcpower/unit_tests/_mock_helper.py @@ -345,14 +345,14 @@ 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, index, buffer_size, channel_name): # noqa: N802 + 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']) - channel_name.value = self._defaults['GetChannelNameFromString']['channelName'].encode('ascii') + names.value = self._defaults['GetChannelNameFromString']['channelName'].encode('ascii') return self._defaults['GetChannelNameFromString']['return'] def niDCPower_GetError(self, vi, code, buffer_size, description): # noqa: N802 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 80e0b6bf2..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': { @@ -1455,7 +1455,7 @@ }, 'GetChannelNameFromString': { 'documentation': { - 'description': '\nReturns a comma-separated list of channel names from a string index list.' + 'description': '\nReturns a list of channel names for given channel indices.' }, 'parameters': [ { @@ -1473,6 +1473,7 @@ }, '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' }, @@ -1487,10 +1488,11 @@ { 'direction': 'out', 'documentation': { - 'description': 'The returned channel name(s) at the specified index.' + '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' diff --git a/src/nidcpower/system_tests/test_system_nidcpower.py b/src/nidcpower/system_tests/test_system_nidcpower.py index ae865b914..df170a2d0 100644 --- a/src/nidcpower/system_tests/test_system_nidcpower.py +++ b/src/nidcpower/system_tests/test_system_nidcpower.py @@ -39,10 +39,15 @@ def test_self_cal(session): session.self_cal() +def test_get_channel_name(session): + name = session.get_channel_name(1) + 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 From c42d8f3269a0ddf4c23497e397af9cdc0373dbc8 Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Thu, 22 Apr 2021 17:02:12 -0500 Subject: [PATCH 06/14] Fix whitespace --- src/nidcpower/system_tests/test_system_nidcpower.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nidcpower/system_tests/test_system_nidcpower.py b/src/nidcpower/system_tests/test_system_nidcpower.py index df170a2d0..9f87e63b0 100644 --- a/src/nidcpower/system_tests/test_system_nidcpower.py +++ b/src/nidcpower/system_tests/test_system_nidcpower.py @@ -43,6 +43,7 @@ def test_get_channel_name(session): name = session.get_channel_name(1) 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 From ae9d1384d685343d2bf8bc8921eaab030ef54565 Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Mon, 26 Apr 2021 16:57:33 -0500 Subject: [PATCH 07/14] Some additional code review feedback from Marcos --- src/nidcpower/system_tests/test_system_nidcpower.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/nidcpower/system_tests/test_system_nidcpower.py b/src/nidcpower/system_tests/test_system_nidcpower.py index 9f87e63b0..bccc5b3b3 100644 --- a/src/nidcpower/system_tests/test_system_nidcpower.py +++ b/src/nidcpower/system_tests/test_system_nidcpower.py @@ -4,9 +4,6 @@ import pytest import tempfile -instruments = ['PXI1Slot2', 'PXI1Slot5'] - - @pytest.fixture(scope='function') def session(): with nidcpower.Session('4162', '', False, 'Simulate=1, DriverSetup=Model:4162; BoardType:PXIe') as simulated_session: @@ -15,6 +12,7 @@ def 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 From ed39b57679e122e4ef638e9657ac21dc7d2866fc Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Tue, 27 Apr 2021 09:52:50 -0500 Subject: [PATCH 08/14] wait for a different PR to update .gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index a3e2b24e2..573a1d5ca 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,3 @@ commands.log .vscode/settings.json .pytest_cache/ - -system_tests.zip -system_tests/ni-nimi-python-* From db779383f0ce06f3a38179758d753ea37e50090b Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Tue, 27 Apr 2021 12:18:23 -0500 Subject: [PATCH 09/14] Restore blank line --- src/nidcpower/system_tests/test_system_nidcpower.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nidcpower/system_tests/test_system_nidcpower.py b/src/nidcpower/system_tests/test_system_nidcpower.py index bccc5b3b3..b80305423 100644 --- a/src/nidcpower/system_tests/test_system_nidcpower.py +++ b/src/nidcpower/system_tests/test_system_nidcpower.py @@ -4,6 +4,7 @@ import pytest import tempfile + @pytest.fixture(scope='function') def session(): with nidcpower.Session('4162', '', False, 'Simulate=1, DriverSetup=Model:4162; BoardType:PXIe') as simulated_session: From 9d353488bf917325d31f3abc89728716bcf30bfe Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Tue, 27 Apr 2021 15:53:40 -0500 Subject: [PATCH 10/14] Take into account python_name parameter overrides when determining repeated capabilities --- build/helper/metadata_add_all.py | 7 ++- docs/nidcpower/class.rst | 5 -- generated/nidcpower/nidcpower/session.py | 70 +++++++++++------------- 3 files changed, 38 insertions(+), 44 deletions(-) diff --git a/build/helper/metadata_add_all.py b/build/helper/metadata_add_all.py index 694b0935d..ac2178778 100644 --- a/build/helper/metadata_add_all.py +++ b/build/helper/metadata_add_all.py @@ -62,6 +62,8 @@ def _add_python_parameter_name(parameter): '''Adds a python_name key/value pair to the parameter metadata''' if 'python_name' not in parameter: parameter['python_name'] = camelcase_to_snakecase(parameter['name']) + else: + parameter['python_name_override'] = True return parameter @@ -271,7 +273,10 @@ def _add_render_in_session_base(f): def _add_is_repeated_capability(parameter): '''Adds a boolean 'is_repeated_capability' to the parameter metadata by inferring it from its name, if not previously populated.''' if 'is_repeated_capability' not in parameter: - if parameter['name'] in _repeated_capability_parameter_names: + param_name = parameter['name'] + if 'python_name_override' in parameter and parameter['python_name_override']: + param_name = parameter['python_name'] + if param_name in _repeated_capability_parameter_names: parameter['is_repeated_capability'] = True parameter['repeated_capability_type'] = 'channels' else: diff --git a/docs/nidcpower/class.rst b/docs/nidcpower/class.rst index f0266e7c8..ff3a73e69 100644 --- a/docs/nidcpower/class.rst +++ b/docs/nidcpower/class.rst @@ -870,11 +870,6 @@ get_channel_names - .. 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: diff --git a/generated/nidcpower/nidcpower/session.py b/generated/nidcpower/nidcpower/session.py index bc32f5224..17c864291 100644 --- a/generated/nidcpower/nidcpower/session.py +++ b/generated/nidcpower/nidcpower/session.py @@ -3692,44 +3692,6 @@ 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 @@ -5223,6 +5185,38 @@ def get_channel_name(self, index): errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return channel_name_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. + + 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)) + @ivi_synchronized def _get_ext_cal_last_date_and_time(self): r'''_get_ext_cal_last_date_and_time From 91531fa3b5bdc50b01d23c3b54a4e09f15f459e2 Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Wed, 28 Apr 2021 18:51:36 -0500 Subject: [PATCH 11/14] Address some additional feedback from Shreyas: 1. always create `python_name_override` and 2. avoid mixing camel-cased and snake-cased parameter names when comparing them --- build/helper/__init__.py | 1 + build/helper/helper.py | 7 +++++++ build/helper/metadata_add_all.py | 20 ++++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/build/helper/__init__.py b/build/helper/__init__.py index 7e39afae2..ae69c0547 100644 --- a/build/helper/__init__.py +++ b/build/helper/__init__.py @@ -32,6 +32,7 @@ from build.helper.helper import get_development_status # noqa: F401 from build.helper.helper import get_numpy_type_for_api_type # noqa: F401 from build.helper.helper import get_python_type_for_api_type # noqa: F401 +from build.helper.helper import snakecase_to_camelcase # noqa: F401 from build.helper.helper import sorted_attrs # noqa: F401 from build.helper.metadata_add_all import add_all_metadata # noqa: F401 diff --git a/build/helper/helper.py b/build/helper/helper.py index 5dbc472d3..d5604ebee 100644 --- a/build/helper/helper.py +++ b/build/helper/helper.py @@ -45,6 +45,13 @@ def camelcase_to_snakecase(camelcase_string): return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() +def snakecase_to_camelcase(snakecase_string): + '''Converts a snake_case string to camelCase''' + # https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case + c1 = ''.join(word.title() for word in snakecase_string.split('_')) + return c1[0].lower() + c1[1:] + + # TODO(marcoskirsch): not being used def function_to_method_name(f): '''Returns an appropriate session method name for a given function''' diff --git a/build/helper/metadata_add_all.py b/build/helper/metadata_add_all.py index ac2178778..7a4724281 100644 --- a/build/helper/metadata_add_all.py +++ b/build/helper/metadata_add_all.py @@ -9,6 +9,7 @@ from .helper import camelcase_to_snakecase from .helper import get_numpy_type_for_api_type from .helper import get_python_type_for_api_type +from .helper import snakecase_to_camelcase from .metadata_filters import filter_codegen_attributes from .metadata_filters import filter_codegen_functions from .metadata_find import find_custom_type @@ -62,6 +63,7 @@ def _add_python_parameter_name(parameter): '''Adds a python_name key/value pair to the parameter metadata''' if 'python_name' not in parameter: parameter['python_name'] = camelcase_to_snakecase(parameter['name']) + parameter['python_name_override'] = False else: parameter['python_name_override'] = True return parameter @@ -273,10 +275,11 @@ def _add_render_in_session_base(f): def _add_is_repeated_capability(parameter): '''Adds a boolean 'is_repeated_capability' to the parameter metadata by inferring it from its name, if not previously populated.''' if 'is_repeated_capability' not in parameter: - param_name = parameter['name'] - if 'python_name_override' in parameter and parameter['python_name_override']: - param_name = parameter['python_name'] - if param_name in _repeated_capability_parameter_names: + if parameter['python_name_override']: + is_rep = snakecase_to_camelcase(parameter['python_name']) in _repeated_capability_parameter_names + else: + is_rep = parameter['name'] in _repeated_capability_parameter_names + if is_rep: parameter['is_repeated_capability'] = True parameter['repeated_capability_type'] = 'channels' else: @@ -835,6 +838,7 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'vi_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'vi', + 'python_name_override': False, }, { 'ctypes_type': 'ViString', @@ -865,6 +869,7 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'channel_name_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'channel_name', + 'python_name_override': False, }, { 'ctypes_type': 'ViInt32', @@ -897,6 +902,7 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'pin_data_buffer_size_ctype', 'use_in_python_api': False, 'python_name_or_default_for_init': 'pin_data_buffer_size', + 'python_name_override': False, }, { 'ctypes_type': 'ViInt32', @@ -929,6 +935,7 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'None if actual_num_pin_data_ctype is None else (ctypes.pointer(actual_num_pin_data_ctype))', 'use_in_python_api': False, 'python_name_or_default_for_init': 'actual_num_pin_data', + 'python_name_override': False, }, { 'ctypes_type': 'ViUInt8', @@ -963,6 +970,7 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'expected_pin_states_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'expected_pin_states', + 'python_name_override': False, }, ], 'python_name': 'make_a_foo', @@ -1005,6 +1013,7 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'vi_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'vi', + 'python_name_override': False, }, { 'direction': 'out', @@ -1037,6 +1046,7 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'status_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'status', + 'python_name_override': False, }, { 'ctypes_type': 'ViInt32', @@ -1069,6 +1079,7 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'data_buffer_size_ctype', 'use_in_python_api': False, 'python_name_or_default_for_init': 'data_buffer_size', + 'python_name_override': False, }, { 'ctypes_type': 'ViUInt32', @@ -1102,6 +1113,7 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'data_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'data', + 'python_name_override': False, }, ], 'documentation': { From e74fc03985afd2cdedd77948dca9f6e2cb18c14c Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Thu, 29 Apr 2021 11:49:15 -0500 Subject: [PATCH 12/14] Add test for python_name override --- build/helper/metadata_add_all.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/build/helper/metadata_add_all.py b/build/helper/metadata_add_all.py index 7a4724281..ddfb1cbc0 100644 --- a/build/helper/metadata_add_all.py +++ b/build/helper/metadata_add_all.py @@ -699,6 +699,7 @@ def _compare_dicts(actual, expected): 'direction': 'in', 'enum': None, 'name': 'channelName', + 'python_name': 'name', 'type': 'ViString', 'documentation': { 'description': 'The channel to call this on.', @@ -801,10 +802,9 @@ def _compare_dicts(actual, expected): 'documentation': { 'description': 'Performs a foo, and performs it well.' }, - 'has_repeated_capability': True, - 'repeated_capability_type': 'channels', + 'has_repeated_capability': False, 'is_error_handling': False, - 'render_in_session_base': True, + 'render_in_session_base': False, 'method_templates': [{'session_filename': '/cool_template', 'documentation_filename': '/cool_template', 'method_python_name_suffix': '', }, ], 'parameters': [ { @@ -842,14 +842,13 @@ def _compare_dicts(actual, expected): }, { 'ctypes_type': 'ViString', - 'ctypes_variable_name': 'channel_name_ctype', + 'ctypes_variable_name': 'name_ctype', 'ctypes_type_library_call': 'ctypes.POINTER(ViChar)', 'direction': 'in', 'documentation': { 'description': 'The channel to call this on.' }, - 'is_repeated_capability': True, - 'repeated_capability_type': 'channels', + 'is_repeated_capability': False, 'is_session_handle': False, 'enum': None, 'numpy': False, @@ -861,15 +860,15 @@ def _compare_dicts(actual, expected): 'use_list': False, 'is_string': True, 'name': 'channelName', - 'python_name': 'channel_name', - 'python_name_with_default': 'channel_name', - 'python_name_with_doc_default': 'channel_name', + 'python_name': 'name', + 'python_name_with_default': 'name', + 'python_name_with_doc_default': 'name', 'size': {'mechanism': 'fixed', 'value': 1}, 'type': 'ViString', - 'library_method_call_snippet': 'channel_name_ctype', + 'library_method_call_snippet': 'name_ctype', 'use_in_python_api': True, - 'python_name_or_default_for_init': 'channel_name', - 'python_name_override': False, + 'python_name_or_default_for_init': 'name', + 'python_name_override': True, }, { 'ctypes_type': 'ViInt32', From a5643dedd0a3ef89a2e94800132e9da1d14d40c9 Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Thu, 29 Apr 2021 12:12:52 -0500 Subject: [PATCH 13/14] Add tests for snake_case / camel_case conversions --- build/helper/helper.py | 47 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/build/helper/helper.py b/build/helper/helper.py index d5604ebee..ac4eafc25 100644 --- a/build/helper/helper.py +++ b/build/helper/helper.py @@ -49,7 +49,9 @@ def snakecase_to_camelcase(snakecase_string): '''Converts a snake_case string to camelCase''' # https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case c1 = ''.join(word.title() for word in snakecase_string.split('_')) - return c1[0].lower() + c1[1:] + if len(c1) > 0: + c1 = c1[0].lower() + c1[1:] + return c1 # TODO(marcoskirsch): not being used @@ -241,3 +243,46 @@ def test_get_development_status(): assert get_development_status(config) == '5 - Production/Stable' +def test_camelcase_to_snakecase(): + camel = 'channelNameList' + expected_snake = 'channel_name_list' + actual_snake = camelcase_to_snakecase(camel) + assert actual_snake == expected_snake + + camel = 'channelName' + expected_snake = 'channel_name' + actual_snake = camelcase_to_snakecase(camel) + assert actual_snake == expected_snake + + camel = 'channel' + expected_snake = 'channel' + actual_snake = camelcase_to_snakecase(camel) + assert actual_snake == expected_snake + + camel = '' + expected_snake = '' + actual_snake = camelcase_to_snakecase(camel) + assert actual_snake == expected_snake + + +def test_snakecase_to_camelcase(): + snake = 'channel_name_list' + expected_camel = 'channelNameList' + actual_camel = snakecase_to_camelcase(snake) + assert actual_camel == expected_camel + + snake = 'channel_name' + expected_camel = 'channelName' + actual_camel = snakecase_to_camelcase(snake) + assert actual_camel == expected_camel + + snake = 'channel' + expected_camel = 'channel' + actual_camel = snakecase_to_camelcase(snake) + assert actual_camel == expected_camel + + snake = '' + expected_camel = '' + actual_camel = snakecase_to_camelcase(snake) + assert actual_camel == expected_camel + From 7f656878e1ea3ae90da70e999b101da145d361bf Mon Sep 17 00:00:00 2001 From: Luis Gomes Date: Thu, 6 May 2021 10:44:52 -0500 Subject: [PATCH 14/14] Revert changes to _add_is_repeated_capability() based on code review feedback. I will fix the incorrect repeated capability for the parameter names later, by adding metadata is_repeated_capability tags to the get_channel_names parameters. --- build/helper/__init__.py | 1 - build/helper/helper.py | 53 ------------------ build/helper/metadata_add_all.py | 40 ++++---------- docs/nidcpower/class.rst | 5 ++ generated/nidcpower/nidcpower/session.py | 70 +++++++++++++----------- 5 files changed, 55 insertions(+), 114 deletions(-) diff --git a/build/helper/__init__.py b/build/helper/__init__.py index ae69c0547..7e39afae2 100644 --- a/build/helper/__init__.py +++ b/build/helper/__init__.py @@ -32,7 +32,6 @@ from build.helper.helper import get_development_status # noqa: F401 from build.helper.helper import get_numpy_type_for_api_type # noqa: F401 from build.helper.helper import get_python_type_for_api_type # noqa: F401 -from build.helper.helper import snakecase_to_camelcase # noqa: F401 from build.helper.helper import sorted_attrs # noqa: F401 from build.helper.metadata_add_all import add_all_metadata # noqa: F401 diff --git a/build/helper/helper.py b/build/helper/helper.py index ac4eafc25..461a4b4b0 100644 --- a/build/helper/helper.py +++ b/build/helper/helper.py @@ -45,15 +45,6 @@ def camelcase_to_snakecase(camelcase_string): return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() -def snakecase_to_camelcase(snakecase_string): - '''Converts a snake_case string to camelCase''' - # https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case - c1 = ''.join(word.title() for word in snakecase_string.split('_')) - if len(c1) > 0: - c1 = c1[0].lower() + c1[1:] - return c1 - - # TODO(marcoskirsch): not being used def function_to_method_name(f): '''Returns an appropriate session method name for a given function''' @@ -242,47 +233,3 @@ def test_get_development_status(): config['module_version'] = '19.9.9' assert get_development_status(config) == '5 - Production/Stable' - -def test_camelcase_to_snakecase(): - camel = 'channelNameList' - expected_snake = 'channel_name_list' - actual_snake = camelcase_to_snakecase(camel) - assert actual_snake == expected_snake - - camel = 'channelName' - expected_snake = 'channel_name' - actual_snake = camelcase_to_snakecase(camel) - assert actual_snake == expected_snake - - camel = 'channel' - expected_snake = 'channel' - actual_snake = camelcase_to_snakecase(camel) - assert actual_snake == expected_snake - - camel = '' - expected_snake = '' - actual_snake = camelcase_to_snakecase(camel) - assert actual_snake == expected_snake - - -def test_snakecase_to_camelcase(): - snake = 'channel_name_list' - expected_camel = 'channelNameList' - actual_camel = snakecase_to_camelcase(snake) - assert actual_camel == expected_camel - - snake = 'channel_name' - expected_camel = 'channelName' - actual_camel = snakecase_to_camelcase(snake) - assert actual_camel == expected_camel - - snake = 'channel' - expected_camel = 'channel' - actual_camel = snakecase_to_camelcase(snake) - assert actual_camel == expected_camel - - snake = '' - expected_camel = '' - actual_camel = snakecase_to_camelcase(snake) - assert actual_camel == expected_camel - diff --git a/build/helper/metadata_add_all.py b/build/helper/metadata_add_all.py index ddfb1cbc0..694b0935d 100644 --- a/build/helper/metadata_add_all.py +++ b/build/helper/metadata_add_all.py @@ -9,7 +9,6 @@ from .helper import camelcase_to_snakecase from .helper import get_numpy_type_for_api_type from .helper import get_python_type_for_api_type -from .helper import snakecase_to_camelcase from .metadata_filters import filter_codegen_attributes from .metadata_filters import filter_codegen_functions from .metadata_find import find_custom_type @@ -63,9 +62,6 @@ def _add_python_parameter_name(parameter): '''Adds a python_name key/value pair to the parameter metadata''' if 'python_name' not in parameter: parameter['python_name'] = camelcase_to_snakecase(parameter['name']) - parameter['python_name_override'] = False - else: - parameter['python_name_override'] = True return parameter @@ -275,11 +271,7 @@ def _add_render_in_session_base(f): def _add_is_repeated_capability(parameter): '''Adds a boolean 'is_repeated_capability' to the parameter metadata by inferring it from its name, if not previously populated.''' if 'is_repeated_capability' not in parameter: - if parameter['python_name_override']: - is_rep = snakecase_to_camelcase(parameter['python_name']) in _repeated_capability_parameter_names - else: - is_rep = parameter['name'] in _repeated_capability_parameter_names - if is_rep: + if parameter['name'] in _repeated_capability_parameter_names: parameter['is_repeated_capability'] = True parameter['repeated_capability_type'] = 'channels' else: @@ -699,7 +691,6 @@ def _compare_dicts(actual, expected): 'direction': 'in', 'enum': None, 'name': 'channelName', - 'python_name': 'name', 'type': 'ViString', 'documentation': { 'description': 'The channel to call this on.', @@ -802,9 +793,10 @@ def _compare_dicts(actual, expected): 'documentation': { 'description': 'Performs a foo, and performs it well.' }, - 'has_repeated_capability': False, + 'has_repeated_capability': True, + 'repeated_capability_type': 'channels', 'is_error_handling': False, - 'render_in_session_base': False, + 'render_in_session_base': True, 'method_templates': [{'session_filename': '/cool_template', 'documentation_filename': '/cool_template', 'method_python_name_suffix': '', }, ], 'parameters': [ { @@ -838,17 +830,17 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'vi_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'vi', - 'python_name_override': False, }, { 'ctypes_type': 'ViString', - 'ctypes_variable_name': 'name_ctype', + 'ctypes_variable_name': 'channel_name_ctype', 'ctypes_type_library_call': 'ctypes.POINTER(ViChar)', 'direction': 'in', 'documentation': { 'description': 'The channel to call this on.' }, - 'is_repeated_capability': False, + 'is_repeated_capability': True, + 'repeated_capability_type': 'channels', 'is_session_handle': False, 'enum': None, 'numpy': False, @@ -860,15 +852,14 @@ def _compare_dicts(actual, expected): 'use_list': False, 'is_string': True, 'name': 'channelName', - 'python_name': 'name', - 'python_name_with_default': 'name', - 'python_name_with_doc_default': 'name', + 'python_name': 'channel_name', + 'python_name_with_default': 'channel_name', + 'python_name_with_doc_default': 'channel_name', 'size': {'mechanism': 'fixed', 'value': 1}, 'type': 'ViString', - 'library_method_call_snippet': 'name_ctype', + 'library_method_call_snippet': 'channel_name_ctype', 'use_in_python_api': True, - 'python_name_or_default_for_init': 'name', - 'python_name_override': True, + 'python_name_or_default_for_init': 'channel_name', }, { 'ctypes_type': 'ViInt32', @@ -901,7 +892,6 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'pin_data_buffer_size_ctype', 'use_in_python_api': False, 'python_name_or_default_for_init': 'pin_data_buffer_size', - 'python_name_override': False, }, { 'ctypes_type': 'ViInt32', @@ -934,7 +924,6 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'None if actual_num_pin_data_ctype is None else (ctypes.pointer(actual_num_pin_data_ctype))', 'use_in_python_api': False, 'python_name_or_default_for_init': 'actual_num_pin_data', - 'python_name_override': False, }, { 'ctypes_type': 'ViUInt8', @@ -969,7 +958,6 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'expected_pin_states_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'expected_pin_states', - 'python_name_override': False, }, ], 'python_name': 'make_a_foo', @@ -1012,7 +1000,6 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'vi_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'vi', - 'python_name_override': False, }, { 'direction': 'out', @@ -1045,7 +1032,6 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'status_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'status', - 'python_name_override': False, }, { 'ctypes_type': 'ViInt32', @@ -1078,7 +1064,6 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'data_buffer_size_ctype', 'use_in_python_api': False, 'python_name_or_default_for_init': 'data_buffer_size', - 'python_name_override': False, }, { 'ctypes_type': 'ViUInt32', @@ -1112,7 +1097,6 @@ def _compare_dicts(actual, expected): 'library_method_call_snippet': 'data_ctype', 'use_in_python_api': True, 'python_name_or_default_for_init': 'data', - 'python_name_override': False, }, ], 'documentation': { diff --git a/docs/nidcpower/class.rst b/docs/nidcpower/class.rst index ff3a73e69..f0266e7c8 100644 --- a/docs/nidcpower/class.rst +++ b/docs/nidcpower/class.rst @@ -870,6 +870,11 @@ get_channel_names + .. 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: diff --git a/generated/nidcpower/nidcpower/session.py b/generated/nidcpower/nidcpower/session.py index 17c864291..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 @@ -5185,38 +5223,6 @@ def get_channel_name(self, index): errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return channel_name_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. - - 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)) - @ivi_synchronized def _get_ext_cal_last_date_and_time(self): r'''_get_ext_cal_last_date_and_time