diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e9c26e77..e9d243df2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1692,6 +1692,10 @@ - Added - Changed - Fixed the return type of `get_all_script_names` and `get_all_named_waveform_names` to remove the size parameter and return a list of strings instead of a comma-separated string + - Changed the parameter name for waveform name from `name` to `waveform_name` in `clear_arb_waveform` and `select_arb_waveform` to be consistent with other waveform methods + - Changed the name of `get_self_calibration_last_date_and_time` to `get_self_cal_last_date_and_time` to be consistent with other MI drivers + - Added default value for `module` parameter in `get_self_cal_last_date_and_time` and `get_self_calibration_temperature` methods to align with documentation and allow duck-typing + - Updated `self_test` to not have any parameters, aligning with other MI drivers - Removed - Methods and properties applicable only to hardware which are not supported anymore - Methods diff --git a/docs/nirfsg/class.rst b/docs/nirfsg/class.rst index 82fb19703..8481576a1 100644 --- a/docs/nirfsg/class.rst +++ b/docs/nirfsg/class.rst @@ -361,7 +361,7 @@ clear_arb_waveform .. py:currentmodule:: nirfsg.Session - .. py:method:: clear_arb_waveform(name) + .. py:method:: clear_arb_waveform(waveform_name) Deletes a specified waveform from the pool of currently defined waveforms. @@ -373,7 +373,7 @@ clear_arb_waveform - :param name: + :param waveform_name: Name of the stored waveform to delete. @@ -381,7 +381,7 @@ clear_arb_waveform - :type name: str + :type waveform_name: str clear_self_calibrate_range -------------------------- @@ -1342,12 +1342,12 @@ get_max_settable_power -get_self_calibration_last_date_and_time ---------------------------------------- +get_self_cal_last_date_and_time +------------------------------- .. py:currentmodule:: nirfsg.Session - .. py:method:: get_self_calibration_last_date_and_time(module) + .. py:method:: get_self_cal_last_date_and_time(module=nirfsg.Module.PRIMARY_MODULE) Returns the date and time of the last successful self-calibration. @@ -1386,7 +1386,7 @@ get_self_calibration_temperature .. py:currentmodule:: nirfsg.Session - .. py:method:: get_self_calibration_temperature(module) + .. py:method:: get_self_calibration_temperature(module=nirfsg.Module.PRIMARY_MODULE) Returns the temperature, in degrees Celsius, of the device at the last successful self-calibration. @@ -2069,7 +2069,7 @@ select_arb_waveform .. py:currentmodule:: nirfsg.Session - .. py:method:: select_arb_waveform(name) + .. py:method:: select_arb_waveform(waveform_name) Specifies the waveform that is generated upon a call to the :py:meth:`nirfsg.Session._initiate` method when the generation_mode property is set to :py:data:`~nirfsg.GenerationMode.ARB_WAVEFORM`. @@ -2087,7 +2087,7 @@ select_arb_waveform - :param name: + :param waveform_name: Specifies the name of the stored waveform to generate. This is a case-insensitive alphanumeric string that does not use reserved words. NI-RFSG sets the :py:attr:`nirfsg.Session.arb_selected_waveform` property to this value. @@ -2095,7 +2095,7 @@ select_arb_waveform - :type name: str + :type waveform_name: str self_cal -------- @@ -2216,7 +2216,7 @@ self_test .. py:currentmodule:: nirfsg.Session - .. py:method:: self_test(self_test_message) + .. py:method:: self_test() Performs a self-test on the NI-RFSG device and returns the test results. @@ -2230,35 +2230,13 @@ self_test `Device Warm-Up `_ - - - - - :param self_test_message: - - - Returns the self-test response string from the NI-RFSG device. For an explanation of the string contents, refer to the **status** parameter of this method. - - You must pass a ViChar array with at least 256 bytes. - - - - - :type self_test_message: str - - :rtype: int - :return: - - - This parameter contains the value returned from the NI-RFSG device self test. - - +----------------+------------------+ - | Self-Test Code | Description | - +================+==================+ - | 0 | Self test passed | - +----------------+------------------+ - | 1 | Self test failed | - +----------------+------------------+ + +----------------+------------------+ + | Self-Test Code | Description | + +================+==================+ + | 0 | Passed self-test | + +----------------+------------------+ + | 1 | Self-test failed | + +----------------+------------------+ diff --git a/generated/nirfsg/nirfsg/_library.py b/generated/nirfsg/nirfsg/_library.py index d62f5cc90..b808c7f40 100644 --- a/generated/nirfsg/nirfsg/_library.py +++ b/generated/nirfsg/nirfsg/_library.py @@ -81,7 +81,6 @@ def __init__(self, ctypes_library): self.niRFSG_SelectArbWaveform_cfunc = None self.niRFSG_SelfCal_cfunc = None self.niRFSG_SelfCalibrateRange_cfunc = None - self.niRFSG_SelfTest_cfunc = None self.niRFSG_SendSoftwareEdgeTrigger_cfunc = None self.niRFSG_SetArbWaveformNextWritePosition_cfunc = None self.niRFSG_SetAttributeViBoolean_cfunc = None @@ -101,6 +100,7 @@ def __init__(self, ctypes_library): self.niRFSG_WriteScript_cfunc = None self.niRFSG_close_cfunc = None self.niRFSG_reset_cfunc = None + self.niRFSG_self_test_cfunc = None def _get_library_function(self, name): try: @@ -165,13 +165,13 @@ def niRFSG_ClearAllArbWaveforms(self, vi): # noqa: N802 self.niRFSG_ClearAllArbWaveforms_cfunc.restype = ViStatus # noqa: F405 return self.niRFSG_ClearAllArbWaveforms_cfunc(vi) - def niRFSG_ClearArbWaveform(self, vi, name): # noqa: N802 + def niRFSG_ClearArbWaveform(self, vi, waveform_name): # noqa: N802 with self._func_lock: if self.niRFSG_ClearArbWaveform_cfunc is None: self.niRFSG_ClearArbWaveform_cfunc = self._get_library_function('niRFSG_ClearArbWaveform') self.niRFSG_ClearArbWaveform_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar)] # noqa: F405 self.niRFSG_ClearArbWaveform_cfunc.restype = ViStatus # noqa: F405 - return self.niRFSG_ClearArbWaveform_cfunc(vi, name) + return self.niRFSG_ClearArbWaveform_cfunc(vi, waveform_name) def niRFSG_ClearSelfCalibrateRange(self, vi): # noqa: N802 with self._func_lock: @@ -573,13 +573,13 @@ def niRFSG_SaveConfigurationsToFile(self, vi, channel_name, file_path): # noqa: self.niRFSG_SaveConfigurationsToFile_cfunc.restype = ViStatus # noqa: F405 return self.niRFSG_SaveConfigurationsToFile_cfunc(vi, channel_name, file_path) - def niRFSG_SelectArbWaveform(self, vi, name): # noqa: N802 + def niRFSG_SelectArbWaveform(self, vi, waveform_name): # noqa: N802 with self._func_lock: if self.niRFSG_SelectArbWaveform_cfunc is None: self.niRFSG_SelectArbWaveform_cfunc = self._get_library_function('niRFSG_SelectArbWaveform') self.niRFSG_SelectArbWaveform_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar)] # noqa: F405 self.niRFSG_SelectArbWaveform_cfunc.restype = ViStatus # noqa: F405 - return self.niRFSG_SelectArbWaveform_cfunc(vi, name) + return self.niRFSG_SelectArbWaveform_cfunc(vi, waveform_name) def niRFSG_SelfCal(self, vi): # noqa: N802 with self._func_lock: @@ -597,14 +597,6 @@ def niRFSG_SelfCalibrateRange(self, vi, steps_to_omit, min_frequency, max_freque self.niRFSG_SelfCalibrateRange_cfunc.restype = ViStatus # noqa: F405 return self.niRFSG_SelfCalibrateRange_cfunc(vi, steps_to_omit, min_frequency, max_frequency, min_power_level, max_power_level) - def niRFSG_SelfTest(self, vi, self_test_result, self_test_message): # noqa: N802 - with self._func_lock: - if self.niRFSG_SelfTest_cfunc is None: - self.niRFSG_SelfTest_cfunc = self._get_library_function('niRFSG_SelfTest') - self.niRFSG_SelfTest_cfunc.argtypes = [ViSession, ctypes.POINTER(ViInt16), ctypes.POINTER(ViChar)] # noqa: F405 - self.niRFSG_SelfTest_cfunc.restype = ViStatus # noqa: F405 - return self.niRFSG_SelfTest_cfunc(vi, self_test_result, self_test_message) - def niRFSG_SendSoftwareEdgeTrigger(self, vi, trigger, trigger_identifier): # noqa: N802 with self._func_lock: if self.niRFSG_SendSoftwareEdgeTrigger_cfunc is None: @@ -756,3 +748,11 @@ def niRFSG_reset(self, vi): # noqa: N802 self.niRFSG_reset_cfunc.argtypes = [ViSession] # noqa: F405 self.niRFSG_reset_cfunc.restype = ViStatus # noqa: F405 return self.niRFSG_reset_cfunc(vi) + + def niRFSG_self_test(self, vi, self_test_result, self_test_message): # noqa: N802 + with self._func_lock: + if self.niRFSG_self_test_cfunc is None: + self.niRFSG_self_test_cfunc = self._get_library_function('niRFSG_self_test') + self.niRFSG_self_test_cfunc.argtypes = [ViSession, ctypes.POINTER(ViInt16), ctypes.POINTER(ViChar)] # noqa: F405 + self.niRFSG_self_test_cfunc.restype = ViStatus # noqa: F405 + return self.niRFSG_self_test_cfunc(vi, self_test_result, self_test_message) diff --git a/generated/nirfsg/nirfsg/_library_interpreter.py b/generated/nirfsg/nirfsg/_library_interpreter.py index f875c618a..3bdcd7145 100644 --- a/generated/nirfsg/nirfsg/_library_interpreter.py +++ b/generated/nirfsg/nirfsg/_library_interpreter.py @@ -141,10 +141,10 @@ def clear_all_arb_waveforms(self): # noqa: N802 errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return - def clear_arb_waveform(self, name): # noqa: N802 + def clear_arb_waveform(self, waveform_name): # noqa: N802 vi_ctype = _visatype.ViSession(self._vi) # case S110 - name_ctype = ctypes.create_string_buffer(name.encode(self._encoding)) # case C020 - error_code = self._library.niRFSG_ClearArbWaveform(vi_ctype, name_ctype) + waveform_name_ctype = ctypes.create_string_buffer(waveform_name.encode(self._encoding)) # case C020 + error_code = self._library.niRFSG_ClearArbWaveform(vi_ctype, waveform_name_ctype) errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return @@ -601,10 +601,10 @@ def save_configurations_to_file(self, channel_name, file_path): # noqa: N802 errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return - def select_arb_waveform(self, name): # noqa: N802 + def select_arb_waveform(self, waveform_name): # noqa: N802 vi_ctype = _visatype.ViSession(self._vi) # case S110 - name_ctype = ctypes.create_string_buffer(name.encode(self._encoding)) # case C020 - error_code = self._library.niRFSG_SelectArbWaveform(vi_ctype, name_ctype) + waveform_name_ctype = ctypes.create_string_buffer(waveform_name.encode(self._encoding)) # case C020 + error_code = self._library.niRFSG_SelectArbWaveform(vi_ctype, waveform_name_ctype) errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return @@ -625,14 +625,6 @@ def self_calibrate_range(self, steps_to_omit, min_frequency, max_frequency, min_ errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return - def self_test(self, self_test_message): # noqa: N802 - vi_ctype = _visatype.ViSession(self._vi) # case S110 - self_test_result_ctype = _visatype.ViInt16() # case S220 - self_test_message_ctype = ctypes.create_string_buffer(self_test_message.encode(self._encoding)) # case C020 - error_code = self._library.niRFSG_SelfTest(vi_ctype, None if self_test_result_ctype is None else (ctypes.pointer(self_test_result_ctype)), self_test_message_ctype) - errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) - return int(self_test_result_ctype.value) - def send_software_edge_trigger(self, trigger, trigger_identifier): # noqa: N802 vi_ctype = _visatype.ViSession(self._vi) # case S110 trigger_ctype = _visatype.ViInt32(trigger.value) # case S130 @@ -791,3 +783,11 @@ def reset(self): # noqa: N802 error_code = self._library.niRFSG_reset(vi_ctype) errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) return + + def self_test(self): # noqa: N802 + vi_ctype = _visatype.ViSession(self._vi) # case S110 + self_test_result_ctype = _visatype.ViInt16() # case S220 + self_test_message_ctype = (_visatype.ViChar * 256)() # case C070 + error_code = self._library.niRFSG_self_test(vi_ctype, None if self_test_result_ctype is None else (ctypes.pointer(self_test_result_ctype)), self_test_message_ctype) + errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False) + return int(self_test_result_ctype.value), self_test_message_ctype.value.decode(self._encoding) diff --git a/generated/nirfsg/nirfsg/session.py b/generated/nirfsg/nirfsg/session.py index 5ba85ac21..2a3223476 100644 --- a/generated/nirfsg/nirfsg/session.py +++ b/generated/nirfsg/nirfsg/session.py @@ -5942,7 +5942,7 @@ def clear_all_arb_waveforms(self): self._interpreter.clear_all_arb_waveforms() @ivi_synchronized - def clear_arb_waveform(self, name): + def clear_arb_waveform(self, waveform_name): r'''clear_arb_waveform Deletes a specified waveform from the pool of currently defined waveforms. @@ -5952,10 +5952,10 @@ def clear_arb_waveform(self, name): **Supported Devices** : PXIe-5644/5645/5646, PXI-5670/5671, PXIe-5672/5673/5673E, PXIe-5820/5830/5831/5832/5840/5841/5842/5860 Args: - name (str): Name of the stored waveform to delete. + waveform_name (str): Name of the stored waveform to delete. ''' - self._interpreter.clear_arb_waveform(name) + self._interpreter.clear_arb_waveform(waveform_name) @ivi_synchronized def clear_self_calibrate_range(self): @@ -6528,8 +6528,8 @@ def get_external_calibration_last_date_and_time(self): return hightime.datetime(year, month, day, hour, minute, second) @ivi_synchronized - def get_self_calibration_last_date_and_time(self, module): - '''get_self_calibration_last_date_and_time + def get_self_cal_last_date_and_time(self, module=enums.Module.PRIMARY_MODULE): + '''get_self_cal_last_date_and_time Returns the date and time of the last successful self-calibration. @@ -6605,7 +6605,7 @@ def _get_self_calibration_date_and_time(self, module): return year, month, day, hour, minute, second @ivi_synchronized - def get_self_calibration_temperature(self, module): + def get_self_calibration_temperature(self, module=enums.Module.PRIMARY_MODULE): r'''get_self_calibration_temperature Returns the temperature, in degrees Celsius, of the device at the last successful self-calibration. @@ -6991,7 +6991,7 @@ def reset_with_options(self, steps_to_omit): self._interpreter.reset_with_options(steps_to_omit) @ivi_synchronized - def select_arb_waveform(self, name): + def select_arb_waveform(self, waveform_name): r'''select_arb_waveform Specifies the waveform that is generated upon a call to the _initiate method when the generation_mode property is set to GenerationMode.ARB_WAVEFORM. @@ -7008,10 +7008,10 @@ def select_arb_waveform(self, name): One or more of the referenced properties are not in the Python API for this driver. Args: - name (str): Specifies the name of the stored waveform to generate. This is a case-insensitive alphanumeric string that does not use reserved words. NI-RFSG sets the arb_selected_waveform property to this value. + waveform_name (str): Specifies the name of the stored waveform to generate. This is a case-insensitive alphanumeric string that does not use reserved words. NI-RFSG sets the arb_selected_waveform property to this value. ''' - self._interpreter.select_arb_waveform(name) + self._interpreter.select_arb_waveform(waveform_name) @ivi_synchronized def self_cal(self): @@ -7087,43 +7087,6 @@ def self_calibrate_range(self, steps_to_omit, min_frequency, max_frequency, min_ raise TypeError('Parameter steps_to_omit must be of type ' + str(enums.SelfCalibrateRangeStepsToOmit)) self._interpreter.self_calibrate_range(steps_to_omit, min_frequency, max_frequency, min_power_level, max_power_level) - @ivi_synchronized - def self_test(self, self_test_message): - r'''self_test - - Performs a self-test on the NI-RFSG device and returns the test results. - - This method performs a simple series of tests to ensure that the NI-RFSG device is powered up and responding. - - This method does not affect external I/O connections or connections between devices. Complete functional testing and calibration are not performed by this method. The NI-RFSG device must be in the Configuration state before you call this method. - - **Supported Devices** : PXI-5610, PXIe-5611, PXI/PXIe-5650/5651/5652, PXIe-5653/5654/5654 with PXIe-5696, PXI-5670/5671, PXIe-5672/5673/5673E, PXIe-5820/5830/5831/5832/5840/5841/5842/5860 - - **Related Topics** - - `Device Warm-Up `_ - - Args: - self_test_message (str): Returns the self-test response string from the NI-RFSG device. For an explanation of the string contents, refer to the **status** parameter of this method. - - You must pass a ViChar array with at least 256 bytes. - - - Returns: - self_test_result (int): This parameter contains the value returned from the NI-RFSG device self test. - - +----------------+------------------+ - | Self-Test Code | Description | - +================+==================+ - | 0 | Self test passed | - +----------------+------------------+ - | 1 | Self test failed | - +----------------+------------------+ - - ''' - self_test_result = self._interpreter.self_test(self_test_message) - return self_test_result - @ivi_synchronized def set_arb_waveform_next_write_position(self, waveform_name, relative_to, offset): r'''set_arb_waveform_next_write_position @@ -7374,6 +7337,35 @@ def _close(self): ''' self._interpreter.close() + @ivi_synchronized + def self_test(self): + '''self_test + + Performs a self-test on the NI-RFSG device and returns the test results. + + This method performs a simple series of tests to ensure that the NI-RFSG device is powered up and responding. + + This method does not affect external I/O connections or connections between devices. Complete functional testing and calibration are not performed by this method. The NI-RFSG device must be in the Configuration state before you call this method. + + **Supported Devices** : PXI-5610, PXIe-5611, PXI/PXIe-5650/5651/5652, PXIe-5653/5654/5654 with PXIe-5696, PXI-5670/5671, PXIe-5672/5673/5673E, PXIe-5820/5830/5831/5832/5840/5841/5842/5860 + + **Related Topics** + + `Device Warm-Up `_ + + +----------------+------------------+ + | Self-Test Code | Description | + +================+==================+ + | 0 | Passed self-test | + +----------------+------------------+ + | 1 | Self-test failed | + +----------------+------------------+ + ''' + code, msg = self._self_test() + if code: + raise errors.SelfTestError(code, msg) + return None + @ivi_synchronized def reset(self): r'''reset @@ -7391,3 +7383,38 @@ def reset(self): Note: This method resets all configured routes for the PXIe-5644/5645/5646 and PXIe-5820/5830/5831/5832/5840/5841/5842/5860 in NI-RFSA and NI-RFSG. ''' self._interpreter.reset() + + @ivi_synchronized + def _self_test(self): + r'''_self_test + + Performs a self-test on the NI-RFSG device and returns the test results. + + This method performs a simple series of tests to ensure that the NI-RFSG device is powered up and responding. + + This method does not affect external I/O connections or connections between devices. Complete functional testing and calibration are not performed by this method. The NI-RFSG device must be in the Configuration state before you call this method. + + **Supported Devices** : PXI-5610, PXIe-5611, PXI/PXIe-5650/5651/5652, PXIe-5653/5654/5654 with PXIe-5696, PXI-5670/5671, PXIe-5672/5673/5673E, PXIe-5820/5830/5831/5832/5840/5841/5842/5860 + + **Related Topics** + + `Device Warm-Up `_ + + Returns: + self_test_result (int): This parameter contains the value returned from the NI-RFSG device self test. + + +----------------+------------------+ + | Self-Test Code | Description | + +================+==================+ + | 0 | Self test passed | + +----------------+------------------+ + | 1 | Self test failed | + +----------------+------------------+ + + self_test_message (str): Returns the self-test response string from the NI-RFSG device. For an explanation of the string contents, refer to the **status** parameter of this method. + + You must pass a ViChar array with at least 256 bytes. + + ''' + self_test_result, self_test_message = self._interpreter.self_test() + return self_test_result, self_test_message diff --git a/generated/nirfsg/nirfsg/unit_tests/_mock_helper.py b/generated/nirfsg/nirfsg/unit_tests/_mock_helper.py index fa6277b7d..ccd4d9dd7 100644 --- a/generated/nirfsg/nirfsg/unit_tests/_mock_helper.py +++ b/generated/nirfsg/nirfsg/unit_tests/_mock_helper.py @@ -184,9 +184,6 @@ def __init__(self): self._defaults['SelfCal']['return'] = 0 self._defaults['SelfCalibrateRange'] = {} self._defaults['SelfCalibrateRange']['return'] = 0 - self._defaults['SelfTest'] = {} - self._defaults['SelfTest']['return'] = 0 - self._defaults['SelfTest']['selfTestResult'] = None self._defaults['SendSoftwareEdgeTrigger'] = {} self._defaults['SendSoftwareEdgeTrigger']['return'] = 0 self._defaults['SetArbWaveformNextWritePosition'] = {} @@ -226,6 +223,10 @@ def __init__(self): self._defaults['close']['return'] = 0 self._defaults['reset'] = {} self._defaults['reset']['return'] = 0 + self._defaults['self_test'] = {} + self._defaults['self_test']['return'] = 0 + self._defaults['self_test']['selfTestResult'] = None + self._defaults['self_test']['selfTestMessage'] = None def __getitem__(self, func): return self._defaults[func] @@ -283,7 +284,7 @@ def niRFSG_ClearAllArbWaveforms(self, vi): # noqa: N802 return self._defaults['ClearAllArbWaveforms']['return'] return self._defaults['ClearAllArbWaveforms']['return'] - def niRFSG_ClearArbWaveform(self, vi, name): # noqa: N802 + def niRFSG_ClearArbWaveform(self, vi, waveform_name): # noqa: N802 if self._defaults['ClearArbWaveform']['return'] != 0: return self._defaults['ClearArbWaveform']['return'] return self._defaults['ClearArbWaveform']['return'] @@ -782,7 +783,7 @@ def niRFSG_SaveConfigurationsToFile(self, vi, channel_name, file_path): # noqa: return self._defaults['SaveConfigurationsToFile']['return'] return self._defaults['SaveConfigurationsToFile']['return'] - def niRFSG_SelectArbWaveform(self, vi, name): # noqa: N802 + def niRFSG_SelectArbWaveform(self, vi, waveform_name): # noqa: N802 if self._defaults['SelectArbWaveform']['return'] != 0: return self._defaults['SelectArbWaveform']['return'] return self._defaults['SelectArbWaveform']['return'] @@ -797,16 +798,6 @@ def niRFSG_SelfCalibrateRange(self, vi, steps_to_omit, min_frequency, max_freque return self._defaults['SelfCalibrateRange']['return'] return self._defaults['SelfCalibrateRange']['return'] - def niRFSG_SelfTest(self, vi, self_test_result, self_test_message): # noqa: N802 - if self._defaults['SelfTest']['return'] != 0: - return self._defaults['SelfTest']['return'] - # self_test_result - if self._defaults['SelfTest']['selfTestResult'] is None: - raise MockFunctionCallError("niRFSG_SelfTest", param='selfTestResult') - if self_test_result is not None: - self_test_result.contents.value = self._defaults['SelfTest']['selfTestResult'] - return self._defaults['SelfTest']['return'] - def niRFSG_SendSoftwareEdgeTrigger(self, vi, trigger, trigger_identifier): # noqa: N802 if self._defaults['SendSoftwareEdgeTrigger']['return'] != 0: return self._defaults['SendSoftwareEdgeTrigger']['return'] @@ -907,6 +898,25 @@ def niRFSG_reset(self, vi): # noqa: N802 return self._defaults['reset']['return'] return self._defaults['reset']['return'] + def niRFSG_self_test(self, vi, self_test_result, self_test_message): # noqa: N802 + if self._defaults['self_test']['return'] != 0: + return self._defaults['self_test']['return'] + # self_test_result + if self._defaults['self_test']['selfTestResult'] is None: + raise MockFunctionCallError("niRFSG_self_test", param='selfTestResult') + if self_test_result is not None: + self_test_result.contents.value = self._defaults['self_test']['selfTestResult'] + # self_test_message + if self._defaults['self_test']['selfTestMessage'] is None: + raise MockFunctionCallError("niRFSG_self_test", param='selfTestMessage') + test_value = self._defaults['self_test']['selfTestMessage'] + if type(test_value) is str: + test_value = test_value.encode('ascii') + assert len(self_test_message) >= len(test_value) + for i in range(len(test_value)): + self_test_message[i] = test_value[i] + return self._defaults['self_test']['return'] + # Helper function to setup Mock object with default side effects and return values def set_side_effects_and_return_values(self, mock_library): mock_library.niRFSG_Abort.side_effect = MockFunctionCallError("niRFSG_Abort") @@ -1031,8 +1041,6 @@ def set_side_effects_and_return_values(self, mock_library): mock_library.niRFSG_SelfCal.return_value = 0 mock_library.niRFSG_SelfCalibrateRange.side_effect = MockFunctionCallError("niRFSG_SelfCalibrateRange") mock_library.niRFSG_SelfCalibrateRange.return_value = 0 - mock_library.niRFSG_SelfTest.side_effect = MockFunctionCallError("niRFSG_SelfTest") - mock_library.niRFSG_SelfTest.return_value = 0 mock_library.niRFSG_SendSoftwareEdgeTrigger.side_effect = MockFunctionCallError("niRFSG_SendSoftwareEdgeTrigger") mock_library.niRFSG_SendSoftwareEdgeTrigger.return_value = 0 mock_library.niRFSG_SetArbWaveformNextWritePosition.side_effect = MockFunctionCallError("niRFSG_SetArbWaveformNextWritePosition") @@ -1071,3 +1079,5 @@ def set_side_effects_and_return_values(self, mock_library): mock_library.niRFSG_close.return_value = 0 mock_library.niRFSG_reset.side_effect = MockFunctionCallError("niRFSG_reset") mock_library.niRFSG_reset.return_value = 0 + mock_library.niRFSG_self_test.side_effect = MockFunctionCallError("niRFSG_self_test") + mock_library.niRFSG_self_test.return_value = 0 diff --git a/src/nirfsg/metadata/functions.py b/src/nirfsg/metadata/functions.py index f20b5a18c..fe6d0e5db 100644 --- a/src/nirfsg/metadata/functions.py +++ b/src/nirfsg/metadata/functions.py @@ -359,7 +359,7 @@ 'documentation': { 'description': 'Name of the stored waveform to delete.' }, - 'name': 'name', + 'name': 'waveformName', 'type': 'ViConstString', 'use_array': False, 'use_in_python_api': True @@ -2333,6 +2333,7 @@ 'description': 'Specifies from which stand-alone module to retrieve the last successful self-calibration date and time.' }, 'enum': 'Module', + 'default_value': 'Module.PRIMARY_MODULE', 'grpc_enum': None, 'name': 'module', 'type': 'ViInt32' @@ -2348,7 +2349,7 @@ 'type': 'hightime.datetime' } ], - 'python_name': 'get_self_calibration_last_date_and_time', + 'python_name': 'get_self_cal_last_date_and_time', 'real_datetime_call': 'GetSelfCalibrationDateAndTime', 'returns': 'ViStatus' }, @@ -2536,6 +2537,7 @@ ] }, 'enum': 'Module', + 'default_value': 'Module.PRIMARY_MODULE', 'name': 'module', 'type': 'ViInt32', 'use_array': False, @@ -3544,7 +3546,7 @@ 'documentation': { 'description': 'Specifies the name of the stored waveform to generate. This is a case-insensitive alphanumeric string that does not use reserved words. NI-RFSG sets the NIRFSG_ATTR_ARB_SELECTED_WAVEFORM attribute to this value.' }, - 'name': 'name', + 'name': 'waveformName', 'type': 'ViConstString', 'use_array': False, 'use_in_python_api': True @@ -3700,8 +3702,8 @@ ], 'returns': 'ViStatus' }, - 'SelfTest': { - 'codegen_method': 'public', + 'self_test': { + 'codegen_method': 'private', 'documentation': { 'description': '\nPerforms a self-test on the NI-RFSG device and returns the test results.\n\nThis function performs a simple series of tests to ensure that the NI-RFSG device is powered up and responding.\n\nThis function does not affect external I/O connections or connections between devices. Complete functional testing and calibration are not performed by this function. The NI-RFSG device must be in the Configuration state before you call this function.\n\n**Supported Devices** : PXI-5610, PXIe-5611, PXI/PXIe-5650/5651/5652, PXIe-5653/5654/5654 with PXIe-5696, PXI-5670/5671, PXIe-5672/5673/5673E, PXIe-5820/5830/5831/5832/5840/5841/5842/5860\n\n**Related Topics**\n\n`Device Warm-Up `_' }, @@ -3738,7 +3740,7 @@ 'type': 'ViInt16' }, { - 'direction': 'in', + 'direction': 'out', 'documentation': { 'description': 'Returns the self-test response string from the NI-RFSG device. For an explanation of the string contents, refer to the **status** parameter of this function.\n\nYou must pass a ViChar array with at least 256 bytes.' }, @@ -3752,6 +3754,48 @@ ], 'returns': 'ViStatus' }, + 'fancy_self_test': { + 'codegen_method': 'python-only', + 'documentation': { + 'description': '\nPerforms a self-test on the NI-RFSG device and returns the test results.\n\nThis function performs a simple series of tests to ensure that the NI-RFSG device is powered up and responding.\n\nThis function does not affect external I/O connections or connections between devices. Complete functional testing and calibration are not performed by this function. The NI-RFSG device must be in the Configuration state before you call this function.\n\n**Supported Devices** : PXI-5610, PXIe-5611, PXI/PXIe-5650/5651/5652, PXIe-5653/5654/5654 with PXIe-5696, PXI-5670/5671, PXIe-5672/5673/5673E, PXIe-5820/5830/5831/5832/5840/5841/5842/5860\n\n**Related Topics**\n\n`Device Warm-Up `_', + 'table_body': [ + [ + '0', + 'Passed self-test' + ], + [ + '1', + 'Self-test failed' + ] + ], + 'table_header': [ + 'Self-Test Code', + 'Description' + ] + }, + 'grpc_name': 'FancySelfTest', + 'included_in_proto': True, + 'method_templates': [ + { + 'documentation_filename': 'default_method', + 'library_interpreter_filename': 'none', + 'method_python_name_suffix': '', + 'session_filename': 'fancy_self_test' + } + ], + 'parameters': [ + { + 'direction': 'in', + 'documentation': { + 'description': 'Identifies your instrument session. The ViSession handle is obtained from the nirfsg_Init function or the nirfsg_InitWithOptions function and identifies a particular instrument session.' + }, + 'name': 'vi', + 'type': 'ViSession' + } + ], + 'python_name': 'self_test', + 'returns': 'ViStatus' + }, 'SendSoftwareEdgeTrigger': { 'codegen_method': 'public', 'documentation': { diff --git a/src/nirfsg/system_tests/test_system_nirfsg.py b/src/nirfsg/system_tests/test_system_nirfsg.py index 858529c75..7017ecfc3 100644 --- a/src/nirfsg/system_tests/test_system_nirfsg.py +++ b/src/nirfsg/system_tests/test_system_nirfsg.py @@ -118,6 +118,10 @@ def test_reset_with_options(self, rfsg_device_session): waveform_exists = rfsg_device_session.check_if_waveform_exists('mywaveform') assert waveform_exists is False + def test_self_test(self, rfsg_device_session): + # We should not get an assert if self_test passes + rfsg_device_session.self_test() + @pytest.mark.skipif(use_simulated_session is False, reason="Takes long time in real device") def test_self_cal(self, rfsg_device_session): rfsg_device_session.self_cal() @@ -136,8 +140,8 @@ def test_get_external_calibration_last_date_and_time(self, rfsg_device_session): assert isinstance(dt, hightime.datetime) @pytest.mark.skipif(use_simulated_session is True, reason="Bad date returned by driver for simulated device") - def test_get_self_calibration_last_date_and_time(self, rfsg_device_session): - dt = rfsg_device_session.get_self_calibration_last_date_and_time(nirfsg.Module.PRIMARY_MODULE) + def test_get_self_cal_last_date_and_time(self, rfsg_device_session): + dt = rfsg_device_session.get_self_cal_last_date_and_time(nirfsg.Module.PRIMARY_MODULE) assert isinstance(dt, hightime.datetime) def test_get_terminal_name(self, rfsg_device_session):