Skip to content

Commit f78a798

Browse files
Updates to nirfsg method and parameter names and defaults (#2145)
* fixed parameter name and method name for consistency * updated changelog * fixed self test parameter mismatch and included basic test * fixed the self test method name to match the driver method * Fixed grammar in CHANGELOG.md Co-authored-by: Jay Fitzgerald <[email protected]> --------- Co-authored-by: Jay Fitzgerald <[email protected]>
1 parent 8cff730 commit f78a798

File tree

8 files changed

+205
-138
lines changed

8 files changed

+205
-138
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,10 @@
16921692
- Added
16931693
- Changed
16941694
- 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
1695+
- 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
1696+
- 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
1697+
- 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
1698+
- Updated `self_test` to not have any parameters, aligning with other MI drivers
16951699
- Removed
16961700
- Methods and properties applicable only to hardware which are not supported anymore
16971701
- Methods

docs/nirfsg/class.rst

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ clear_arb_waveform
361361

362362
.. py:currentmodule:: nirfsg.Session
363363

364-
.. py:method:: clear_arb_waveform(name)
364+
.. py:method:: clear_arb_waveform(waveform_name)
365365

366366
Deletes a specified waveform from the pool of currently defined waveforms.
367367

@@ -373,15 +373,15 @@ clear_arb_waveform
373373

374374

375375

376-
:param name:
376+
:param waveform_name:
377377

378378

379379
Name of the stored waveform to delete.
380380

381381

382382

383383

384-
:type name: str
384+
:type waveform_name: str
385385

386386
clear_self_calibrate_range
387387
--------------------------
@@ -1342,12 +1342,12 @@ get_max_settable_power
13421342

13431343

13441344

1345-
get_self_calibration_last_date_and_time
1346-
---------------------------------------
1345+
get_self_cal_last_date_and_time
1346+
-------------------------------
13471347

13481348
.. py:currentmodule:: nirfsg.Session
13491349

1350-
.. py:method:: get_self_calibration_last_date_and_time(module)
1350+
.. py:method:: get_self_cal_last_date_and_time(module=nirfsg.Module.PRIMARY_MODULE)
13511351

13521352
Returns the date and time of the last successful self-calibration.
13531353

@@ -1386,7 +1386,7 @@ get_self_calibration_temperature
13861386

13871387
.. py:currentmodule:: nirfsg.Session
13881388

1389-
.. py:method:: get_self_calibration_temperature(module)
1389+
.. py:method:: get_self_calibration_temperature(module=nirfsg.Module.PRIMARY_MODULE)
13901390

13911391
Returns the temperature, in degrees Celsius, of the device at the last successful self-calibration.
13921392

@@ -2069,7 +2069,7 @@ select_arb_waveform
20692069

20702070
.. py:currentmodule:: nirfsg.Session
20712071

2072-
.. py:method:: select_arb_waveform(name)
2072+
.. py:method:: select_arb_waveform(waveform_name)
20732073

20742074
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`.
20752075

@@ -2087,15 +2087,15 @@ select_arb_waveform
20872087

20882088

20892089

2090-
:param name:
2090+
:param waveform_name:
20912091

20922092

20932093
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.
20942094

20952095

20962096

20972097

2098-
:type name: str
2098+
:type waveform_name: str
20992099

21002100
self_cal
21012101
--------
@@ -2216,7 +2216,7 @@ self_test
22162216

22172217
.. py:currentmodule:: nirfsg.Session
22182218

2219-
.. py:method:: self_test(self_test_message)
2219+
.. py:method:: self_test()
22202220

22212221
Performs a self-test on the NI-RFSG device and returns the test results.
22222222

@@ -2230,35 +2230,13 @@ self_test
22302230

22312231
`Device Warm-Up <https://www.ni.com/docs/en-US/bundle/rfsg/page/rfsg/warmup.html>`_
22322232

2233-
2234-
2235-
2236-
2237-
:param self_test_message:
2238-
2239-
2240-
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.
2241-
2242-
You must pass a ViChar array with at least 256 bytes.
2243-
2244-
2245-
2246-
2247-
:type self_test_message: str
2248-
2249-
:rtype: int
2250-
:return:
2251-
2252-
2253-
This parameter contains the value returned from the NI-RFSG device self test.
2254-
2255-
+----------------+------------------+
2256-
| Self-Test Code | Description |
2257-
+================+==================+
2258-
| 0 | Self test passed |
2259-
+----------------+------------------+
2260-
| 1 | Self test failed |
2261-
+----------------+------------------+
2233+
+----------------+------------------+
2234+
| Self-Test Code | Description |
2235+
+================+==================+
2236+
| 0 | Passed self-test |
2237+
+----------------+------------------+
2238+
| 1 | Self-test failed |
2239+
+----------------+------------------+
22622240

22632241

22642242

generated/nirfsg/nirfsg/_library.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def __init__(self, ctypes_library):
8181
self.niRFSG_SelectArbWaveform_cfunc = None
8282
self.niRFSG_SelfCal_cfunc = None
8383
self.niRFSG_SelfCalibrateRange_cfunc = None
84-
self.niRFSG_SelfTest_cfunc = None
8584
self.niRFSG_SendSoftwareEdgeTrigger_cfunc = None
8685
self.niRFSG_SetArbWaveformNextWritePosition_cfunc = None
8786
self.niRFSG_SetAttributeViBoolean_cfunc = None
@@ -101,6 +100,7 @@ def __init__(self, ctypes_library):
101100
self.niRFSG_WriteScript_cfunc = None
102101
self.niRFSG_close_cfunc = None
103102
self.niRFSG_reset_cfunc = None
103+
self.niRFSG_self_test_cfunc = None
104104

105105
def _get_library_function(self, name):
106106
try:
@@ -165,13 +165,13 @@ def niRFSG_ClearAllArbWaveforms(self, vi): # noqa: N802
165165
self.niRFSG_ClearAllArbWaveforms_cfunc.restype = ViStatus # noqa: F405
166166
return self.niRFSG_ClearAllArbWaveforms_cfunc(vi)
167167

168-
def niRFSG_ClearArbWaveform(self, vi, name): # noqa: N802
168+
def niRFSG_ClearArbWaveform(self, vi, waveform_name): # noqa: N802
169169
with self._func_lock:
170170
if self.niRFSG_ClearArbWaveform_cfunc is None:
171171
self.niRFSG_ClearArbWaveform_cfunc = self._get_library_function('niRFSG_ClearArbWaveform')
172172
self.niRFSG_ClearArbWaveform_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar)] # noqa: F405
173173
self.niRFSG_ClearArbWaveform_cfunc.restype = ViStatus # noqa: F405
174-
return self.niRFSG_ClearArbWaveform_cfunc(vi, name)
174+
return self.niRFSG_ClearArbWaveform_cfunc(vi, waveform_name)
175175

176176
def niRFSG_ClearSelfCalibrateRange(self, vi): # noqa: N802
177177
with self._func_lock:
@@ -573,13 +573,13 @@ def niRFSG_SaveConfigurationsToFile(self, vi, channel_name, file_path): # noqa:
573573
self.niRFSG_SaveConfigurationsToFile_cfunc.restype = ViStatus # noqa: F405
574574
return self.niRFSG_SaveConfigurationsToFile_cfunc(vi, channel_name, file_path)
575575

576-
def niRFSG_SelectArbWaveform(self, vi, name): # noqa: N802
576+
def niRFSG_SelectArbWaveform(self, vi, waveform_name): # noqa: N802
577577
with self._func_lock:
578578
if self.niRFSG_SelectArbWaveform_cfunc is None:
579579
self.niRFSG_SelectArbWaveform_cfunc = self._get_library_function('niRFSG_SelectArbWaveform')
580580
self.niRFSG_SelectArbWaveform_cfunc.argtypes = [ViSession, ctypes.POINTER(ViChar)] # noqa: F405
581581
self.niRFSG_SelectArbWaveform_cfunc.restype = ViStatus # noqa: F405
582-
return self.niRFSG_SelectArbWaveform_cfunc(vi, name)
582+
return self.niRFSG_SelectArbWaveform_cfunc(vi, waveform_name)
583583

584584
def niRFSG_SelfCal(self, vi): # noqa: N802
585585
with self._func_lock:
@@ -597,14 +597,6 @@ def niRFSG_SelfCalibrateRange(self, vi, steps_to_omit, min_frequency, max_freque
597597
self.niRFSG_SelfCalibrateRange_cfunc.restype = ViStatus # noqa: F405
598598
return self.niRFSG_SelfCalibrateRange_cfunc(vi, steps_to_omit, min_frequency, max_frequency, min_power_level, max_power_level)
599599

600-
def niRFSG_SelfTest(self, vi, self_test_result, self_test_message): # noqa: N802
601-
with self._func_lock:
602-
if self.niRFSG_SelfTest_cfunc is None:
603-
self.niRFSG_SelfTest_cfunc = self._get_library_function('niRFSG_SelfTest')
604-
self.niRFSG_SelfTest_cfunc.argtypes = [ViSession, ctypes.POINTER(ViInt16), ctypes.POINTER(ViChar)] # noqa: F405
605-
self.niRFSG_SelfTest_cfunc.restype = ViStatus # noqa: F405
606-
return self.niRFSG_SelfTest_cfunc(vi, self_test_result, self_test_message)
607-
608600
def niRFSG_SendSoftwareEdgeTrigger(self, vi, trigger, trigger_identifier): # noqa: N802
609601
with self._func_lock:
610602
if self.niRFSG_SendSoftwareEdgeTrigger_cfunc is None:
@@ -756,3 +748,11 @@ def niRFSG_reset(self, vi): # noqa: N802
756748
self.niRFSG_reset_cfunc.argtypes = [ViSession] # noqa: F405
757749
self.niRFSG_reset_cfunc.restype = ViStatus # noqa: F405
758750
return self.niRFSG_reset_cfunc(vi)
751+
752+
def niRFSG_self_test(self, vi, self_test_result, self_test_message): # noqa: N802
753+
with self._func_lock:
754+
if self.niRFSG_self_test_cfunc is None:
755+
self.niRFSG_self_test_cfunc = self._get_library_function('niRFSG_self_test')
756+
self.niRFSG_self_test_cfunc.argtypes = [ViSession, ctypes.POINTER(ViInt16), ctypes.POINTER(ViChar)] # noqa: F405
757+
self.niRFSG_self_test_cfunc.restype = ViStatus # noqa: F405
758+
return self.niRFSG_self_test_cfunc(vi, self_test_result, self_test_message)

generated/nirfsg/nirfsg/_library_interpreter.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ def clear_all_arb_waveforms(self): # noqa: N802
141141
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
142142
return
143143

144-
def clear_arb_waveform(self, name): # noqa: N802
144+
def clear_arb_waveform(self, waveform_name): # noqa: N802
145145
vi_ctype = _visatype.ViSession(self._vi) # case S110
146-
name_ctype = ctypes.create_string_buffer(name.encode(self._encoding)) # case C020
147-
error_code = self._library.niRFSG_ClearArbWaveform(vi_ctype, name_ctype)
146+
waveform_name_ctype = ctypes.create_string_buffer(waveform_name.encode(self._encoding)) # case C020
147+
error_code = self._library.niRFSG_ClearArbWaveform(vi_ctype, waveform_name_ctype)
148148
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
149149
return
150150

@@ -601,10 +601,10 @@ def save_configurations_to_file(self, channel_name, file_path): # noqa: N802
601601
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
602602
return
603603

604-
def select_arb_waveform(self, name): # noqa: N802
604+
def select_arb_waveform(self, waveform_name): # noqa: N802
605605
vi_ctype = _visatype.ViSession(self._vi) # case S110
606-
name_ctype = ctypes.create_string_buffer(name.encode(self._encoding)) # case C020
607-
error_code = self._library.niRFSG_SelectArbWaveform(vi_ctype, name_ctype)
606+
waveform_name_ctype = ctypes.create_string_buffer(waveform_name.encode(self._encoding)) # case C020
607+
error_code = self._library.niRFSG_SelectArbWaveform(vi_ctype, waveform_name_ctype)
608608
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
609609
return
610610

@@ -625,14 +625,6 @@ def self_calibrate_range(self, steps_to_omit, min_frequency, max_frequency, min_
625625
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
626626
return
627627

628-
def self_test(self, self_test_message): # noqa: N802
629-
vi_ctype = _visatype.ViSession(self._vi) # case S110
630-
self_test_result_ctype = _visatype.ViInt16() # case S220
631-
self_test_message_ctype = ctypes.create_string_buffer(self_test_message.encode(self._encoding)) # case C020
632-
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)
633-
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
634-
return int(self_test_result_ctype.value)
635-
636628
def send_software_edge_trigger(self, trigger, trigger_identifier): # noqa: N802
637629
vi_ctype = _visatype.ViSession(self._vi) # case S110
638630
trigger_ctype = _visatype.ViInt32(trigger.value) # case S130
@@ -791,3 +783,11 @@ def reset(self): # noqa: N802
791783
error_code = self._library.niRFSG_reset(vi_ctype)
792784
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
793785
return
786+
787+
def self_test(self): # noqa: N802
788+
vi_ctype = _visatype.ViSession(self._vi) # case S110
789+
self_test_result_ctype = _visatype.ViInt16() # case S220
790+
self_test_message_ctype = (_visatype.ViChar * 256)() # case C070
791+
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)
792+
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
793+
return int(self_test_result_ctype.value), self_test_message_ctype.value.decode(self._encoding)

0 commit comments

Comments
 (0)