Skip to content

Commit b5ffa43

Browse files
authored
Update the return type of get_all_named_waveform_names and get_all_script_names for nirfsg (#2135)
* Updating the return type of two apis. * Updating the system tests * Updated Change Log
1 parent 3432530 commit b5ffa43

File tree

9 files changed

+70
-77
lines changed

9 files changed

+70
-77
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,7 @@
16911691
#### [nirfsg] Unreleased
16921692
- Added
16931693
- Changed
1694+
- 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
16941695
- Removed
16951696

16961697
#### [nirfsg] 1.0.0 - 2025-08-05

docs/nirfsg/class.rst

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,29 +1574,14 @@ get_all_named_waveform_names
15741574

15751575

15761576

1577-
:rtype: tuple (waveform_names, actual_buffer_size)
1578-
1579-
WHERE
1580-
1581-
waveform_names (str):
1582-
1583-
1584-
Returns a string having waveform names separated by commas.
1585-
1586-
1587-
1588-
1589-
actual_buffer_size (int):
1590-
1577+
:rtype: list of str
1578+
:return:
15911579

1592-
Fetch the number of bytes needed to pass in the :py:attr:`nirfsg.Session.BUFFER_SIZE` parameter.
15931580

1594-
It can be fetch by passing VI_NULL in the :py:attr:`nirfsg.Session.WAVEFORM_NAMES` parameter.
1581+
Returns a list of string having waveform names.
15951582

15961583

15971584

1598-
.. note:: One or more of the referenced properties are not in the Python API for this driver.
1599-
16001585

16011586

16021587
get_all_script_names
@@ -1614,29 +1599,14 @@ get_all_script_names
16141599

16151600

16161601

1617-
:rtype: tuple (script_names, actual_buffer_size)
1618-
1619-
WHERE
1620-
1621-
script_names (str):
1622-
1623-
1624-
Returns a string having script names separated by commas.
1625-
1626-
1627-
1628-
1629-
actual_buffer_size (int):
1630-
1602+
:rtype: list of str
1603+
:return:
16311604

1632-
Fetch the number of bytes needed to pass in the :py:attr:`nirfsg.Session.BUFFER_SIZE` parameter.
16331605

1634-
It can be fetch by passing VI_NULL in the :py:attr:`nirfsg.Session.SCRIPT_NAMES` parameter.
1606+
Returns a list of string having script names.
16351607

16361608

16371609

1638-
.. note:: One or more of the referenced properties are not in the Python API for this driver.
1639-
16401610

16411611

16421612
get_channel_name

generated/nirfsg/nirfsg/_library_interpreter.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,29 +390,29 @@ def error_query(self): # noqa: N802
390390

391391
def get_all_named_waveform_names(self): # noqa: N802
392392
vi_ctype = _visatype.ViSession(self._vi) # case S110
393-
waveform_names_ctype = None # case C050
394-
buffer_size_ctype = _visatype.ViInt32() # case S170
393+
waveform_names_ctype = None # case C090
394+
buffer_size_ctype = _visatype.ViInt32(0) # case S190
395395
actual_buffer_size_ctype = _visatype.ViInt32() # case S220
396396
error_code = self._library.niRFSG_GetAllNamedWaveformNames(vi_ctype, waveform_names_ctype, buffer_size_ctype, None if actual_buffer_size_ctype is None else (ctypes.pointer(actual_buffer_size_ctype)))
397397
errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False)
398-
buffer_size_ctype = _visatype.ViInt32(error_code) # case S180
399-
waveform_names_ctype = (_visatype.ViChar * buffer_size_ctype.value)() # case C060
398+
buffer_size_ctype = _visatype.ViInt32(actual_buffer_size_ctype.value) # case S200
399+
waveform_names_ctype = (_visatype.ViChar * actual_buffer_size_ctype.value)() # case C100
400400
error_code = self._library.niRFSG_GetAllNamedWaveformNames(vi_ctype, waveform_names_ctype, buffer_size_ctype, None if actual_buffer_size_ctype is None else (ctypes.pointer(actual_buffer_size_ctype)))
401401
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
402-
return waveform_names_ctype.value.decode(self._encoding), int(actual_buffer_size_ctype.value)
402+
return waveform_names_ctype.value.decode(self._encoding)
403403

404404
def get_all_script_names(self): # noqa: N802
405405
vi_ctype = _visatype.ViSession(self._vi) # case S110
406-
script_names_ctype = None # case C050
407-
buffer_size_ctype = _visatype.ViInt32() # case S170
406+
script_names_ctype = None # case C090
407+
buffer_size_ctype = _visatype.ViInt32(0) # case S190
408408
actual_buffer_size_ctype = _visatype.ViInt32() # case S220
409409
error_code = self._library.niRFSG_GetAllScriptNames(vi_ctype, script_names_ctype, buffer_size_ctype, None if actual_buffer_size_ctype is None else (ctypes.pointer(actual_buffer_size_ctype)))
410410
errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False)
411-
buffer_size_ctype = _visatype.ViInt32(error_code) # case S180
412-
script_names_ctype = (_visatype.ViChar * buffer_size_ctype.value)() # case C060
411+
buffer_size_ctype = _visatype.ViInt32(actual_buffer_size_ctype.value) # case S200
412+
script_names_ctype = (_visatype.ViChar * actual_buffer_size_ctype.value)() # case C100
413413
error_code = self._library.niRFSG_GetAllScriptNames(vi_ctype, script_names_ctype, buffer_size_ctype, None if actual_buffer_size_ctype is None else (ctypes.pointer(actual_buffer_size_ctype)))
414414
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
415-
return script_names_ctype.value.decode(self._encoding), int(actual_buffer_size_ctype.value)
415+
return script_names_ctype.value.decode(self._encoding)
416416

417417
def get_attribute_vi_boolean(self, channel_name, attribute): # noqa: N802
418418
vi_ctype = _visatype.ViSession(self._vi) # case S110

generated/nirfsg/nirfsg/session.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7278,18 +7278,11 @@ def get_all_named_waveform_names(self):
72787278
**Supported Devices** :PXIe-5830/5831/5840/5841/5842E
72797279

72807280
Returns:
7281-
waveform_names (str): Returns a string having waveform names separated by commas.
7282-
7283-
actual_buffer_size (int): Fetch the number of bytes needed to pass in the BUFFER_SIZE parameter.
7284-
7285-
It can be fetch by passing VI_NULL in the WAVEFORM_NAMES parameter.
7286-
7287-
Note:
7288-
One or more of the referenced properties are not in the Python API for this driver.
7281+
waveform_names (list of str): Returns a list of string having waveform names.
72897282

72907283
'''
7291-
waveform_names, actual_buffer_size = self._interpreter.get_all_named_waveform_names()
7292-
return _converters.convert_comma_separated_string_to_list(waveform_names), actual_buffer_size
7284+
waveform_names = self._interpreter.get_all_named_waveform_names()
7285+
return _converters.convert_comma_separated_string_to_list(waveform_names)
72937286

72947287
@ivi_synchronized
72957288
def get_all_script_names(self):
@@ -7300,18 +7293,11 @@ def get_all_script_names(self):
73007293
**Supported Devices** :PXIe-5830/5831/5840/5841/5842E
73017294

73027295
Returns:
7303-
script_names (str): Returns a string having script names separated by commas.
7304-
7305-
actual_buffer_size (int): Fetch the number of bytes needed to pass in the BUFFER_SIZE parameter.
7306-
7307-
It can be fetch by passing VI_NULL in the SCRIPT_NAMES parameter.
7308-
7309-
Note:
7310-
One or more of the referenced properties are not in the Python API for this driver.
7296+
script_names (list of str): Returns a list of string having script names.
73117297

73127298
'''
7313-
script_names, actual_buffer_size = self._interpreter.get_all_script_names()
7314-
return script_names, actual_buffer_size
7299+
script_names = self._interpreter.get_all_script_names()
7300+
return _converters.convert_comma_separated_string_to_list(script_names)
73157301

73167302
@ivi_synchronized
73177303
def get_channel_name(self, index):

src/nirfsg/metadata/attributes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# This file is generated from NI-RFSG API metadata version 25.8.0d9999
2+
# This file is generated from NI-RFSG API metadata version 25.8.0d197
33
attributes = {
44
1050002: {
55
'access': 'read-write',

src/nirfsg/metadata/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
2-
# This file is generated from NI-RFSG API metadata version 25.8.0d9999
2+
# This file is generated from NI-RFSG API metadata version 25.8.0d197
33
config = {
4-
'api_version': '25.8.0d9999',
4+
'api_version': '25.8.0d197',
55
'c_function_prefix': 'niRFSG_',
66
'close_function': 'close',
77
'context_manager_name': {

src/nirfsg/metadata/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# This file is generated from NI-RFSG API metadata version 25.8.0d9999
2+
# This file is generated from NI-RFSG API metadata version 25.8.0d197
33
enums = {
44
'AllowOutOfSpecificationUserSettings': {
55
'values': [

src/nirfsg/metadata/functions.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# This file is generated from NI-RFSG API metadata version 25.8.0d9999
2+
# This file is generated from NI-RFSG API metadata version 25.8.0d197
33
functions = {
44
'Abort': {
55
'codegen_method': 'public',
@@ -2125,15 +2125,17 @@
21252125
{
21262126
'direction': 'out',
21272127
'documentation': {
2128-
'description': 'Returns a string having waveform names separated by commas.'
2128+
'description': 'Returns a list of string having waveform names.'
21292129
},
21302130
'name': 'waveformNames',
21312131
'python_api_converter_name': 'convert_comma_separated_string_to_list',
21322132
'size': {
2133-
'mechanism': 'ivi-dance',
2134-
'value': 'bufferSize'
2133+
'mechanism': 'ivi-dance-with-a-twist',
2134+
'value': 'bufferSize',
2135+
'value_twist': 'actualBufferSize'
21352136
},
21362137
'type': 'ViChar[]',
2138+
'type_in_documentation': 'list of str',
21372139
'use_array': False,
21382140
'use_in_python_api': True
21392141
},
@@ -2188,14 +2190,17 @@
21882190
{
21892191
'direction': 'out',
21902192
'documentation': {
2191-
'description': 'Returns a string having script names separated by commas.'
2193+
'description': 'Returns a list of string having script names.'
21922194
},
21932195
'name': 'scriptNames',
2196+
'python_api_converter_name': 'convert_comma_separated_string_to_list',
21942197
'size': {
2195-
'mechanism': 'ivi-dance',
2196-
'value': 'bufferSize'
2198+
'mechanism': 'ivi-dance-with-a-twist',
2199+
'value': 'bufferSize',
2200+
'value_twist': 'actualBufferSize'
21972201
},
21982202
'type': 'ViChar[]',
2203+
'type_in_documentation': 'list of str',
21992204
'use_array': False,
22002205
'use_in_python_api': True
22012206
},

src/nirfsg/system_tests/test_system_nirfsg.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,37 @@ def test_wait_until_settled(self, rfsg_device_session):
578578
with rfsg_device_session.initiate():
579579
rfsg_device_session.wait_until_settled(15000)
580580

581+
def test_get_all_named_waveform_names(self, rfsg_device_session):
582+
rfsg_device_session.generation_mode = nirfsg.GenerationMode.ARB_WAVEFORM
583+
waveform_data1 = np.full(1000, 1 + 0j, dtype=np.complex128)
584+
waveform_data2 = np.full(800, 1 + 0j, dtype=np.complex128)
585+
rfsg_device_session.write_arb_waveform('waveform1', waveform_data1, False)
586+
rfsg_device_session.write_arb_waveform('waveform2', waveform_data2, False)
587+
names = rfsg_device_session.get_all_named_waveform_names()
588+
assert 'waveform1' in names
589+
assert 'waveform2' in names
590+
591+
@pytest.mark.skipif(use_simulated_session is True, reason="Scripts not compiled on simulated device")
592+
def test_get_all_script_names(self, rfsg_device_session):
593+
rfsg_device_session.generation_mode = nirfsg.GenerationMode.SCRIPT
594+
waveform_data = np.full(1000, 0.707 + 0.707j, dtype=np.complex64)
595+
rfsg_device_session.write_arb_waveform('mywaveform', waveform_data, False)
596+
script1 = '''script myScript1
597+
repeat forever
598+
generate mywaveform
599+
end repeat
600+
end script'''
601+
script2 = '''script myScript2
602+
repeat forever
603+
generate mywaveform
604+
end repeat
605+
end script'''
606+
rfsg_device_session.write_script(script1)
607+
rfsg_device_session.write_script(script2)
608+
script_names = rfsg_device_session.get_all_script_names()
609+
assert 'myScript1' in script_names
610+
assert 'myScript2' in script_names
611+
581612

582613
class TestLibrary(SystemTests):
583614
@pytest.fixture(scope='class')

0 commit comments

Comments
 (0)