nirfmxnr 26.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. nirfmxnr/__init__.py +106 -0
  2. nirfmxnr/acp.py +31 -0
  3. nirfmxnr/acp_component_carrier_configuration.py +100 -0
  4. nirfmxnr/acp_component_carrier_results.py +212 -0
  5. nirfmxnr/acp_configuration.py +3992 -0
  6. nirfmxnr/acp_results.py +687 -0
  7. nirfmxnr/attributes.py +6782 -0
  8. nirfmxnr/chp.py +31 -0
  9. nirfmxnr/chp_component_carrier_configuration.py +65 -0
  10. nirfmxnr/chp_component_carrier_results.py +204 -0
  11. nirfmxnr/chp_configuration.py +2138 -0
  12. nirfmxnr/chp_results.py +251 -0
  13. nirfmxnr/component_carrier.py +9536 -0
  14. nirfmxnr/enums.py +2189 -0
  15. nirfmxnr/errors.py +96 -0
  16. nirfmxnr/examples/nirfmxnr_acp_single_carrier.py +190 -0
  17. nirfmxnr/examples/nirfmxnr_chp_single_carrier.py +149 -0
  18. nirfmxnr/examples/nirfmxnr_modacc_single_carrier.py +228 -0
  19. nirfmxnr/examples/nirfmxnr_sem_single_carrier.py +212 -0
  20. nirfmxnr/examples/nirfmxnr_ul_pvt_single_carrier_grpc.py +266 -0
  21. nirfmxnr/grpc_session_options.py +64 -0
  22. nirfmxnr/internal/_custom_types.py +13 -0
  23. nirfmxnr/internal/_grpc_stub_interpreter.py +2392 -0
  24. nirfmxnr/internal/_helper.py +341 -0
  25. nirfmxnr/internal/_library.py +5130 -0
  26. nirfmxnr/internal/_library_interpreter.py +5339 -0
  27. nirfmxnr/internal/_library_singleton.py +53 -0
  28. nirfmxnr/internal/nidevice_pb2.py +37 -0
  29. nirfmxnr/internal/nidevice_pb2_grpc.py +3 -0
  30. nirfmxnr/internal/nirfmxnr_pb2.py +1198 -0
  31. nirfmxnr/internal/nirfmxnr_pb2_grpc.py +11913 -0
  32. nirfmxnr/internal/session_pb2.py +33 -0
  33. nirfmxnr/internal/session_pb2_grpc.py +3 -0
  34. nirfmxnr/modacc.py +31 -0
  35. nirfmxnr/modacc_configuration.py +4574 -0
  36. nirfmxnr/modacc_results.py +5647 -0
  37. nirfmxnr/nr.py +6193 -0
  38. nirfmxnr/obw.py +31 -0
  39. nirfmxnr/obw_configuration.py +1631 -0
  40. nirfmxnr/obw_results.py +286 -0
  41. nirfmxnr/pvt.py +31 -0
  42. nirfmxnr/pvt_configuration.py +1089 -0
  43. nirfmxnr/pvt_results.py +616 -0
  44. nirfmxnr/sem.py +31 -0
  45. nirfmxnr/sem_component_carrier_configuration.py +283 -0
  46. nirfmxnr/sem_component_carrier_results.py +292 -0
  47. nirfmxnr/sem_configuration.py +3351 -0
  48. nirfmxnr/sem_results.py +1751 -0
  49. nirfmxnr/txp.py +31 -0
  50. nirfmxnr/txp_configuration.py +564 -0
  51. nirfmxnr/txp_results.py +209 -0
  52. nirfmxnr-26.0.0.dist-info/METADATA +210 -0
  53. nirfmxnr-26.0.0.dist-info/RECORD +55 -0
  54. nirfmxnr-26.0.0.dist-info/WHEEL +4 -0
  55. nirfmxnr-26.0.0.dist-info/licenses/LICENSE +30 -0
nirfmxnr/__init__.py ADDED
@@ -0,0 +1,106 @@
1
+ """nirfmxnr package."""
2
+
3
+ __version__ = "26.0.0"
4
+
5
+ from nirfmxnr.attributes import * # noqa: F403
6
+ from nirfmxnr.enums import * # noqa: F403
7
+ from nirfmxnr.grpc_session_options import * # noqa: F403
8
+ from nirfmxnr.nr import NR, _NRSignalConfiguration
9
+
10
+
11
+ def get_diagnostic_information():
12
+ """Get diagnostic information about the system state that is suitable for printing or logging.
13
+ returns: dict
14
+ note: Python bitness may be incorrect when running in a virtual environment.
15
+ """
16
+ import importlib.metadata
17
+ import os
18
+ import platform
19
+ import struct
20
+ import sys
21
+
22
+ def is_python_64bit():
23
+ return struct.calcsize("P") == 8
24
+
25
+ def is_os_64bit():
26
+ return platform.machine().endswith("64")
27
+
28
+ def is_venv():
29
+ return "VIRTUAL_ENV" in os.environ
30
+
31
+ info = {} # type: ignore
32
+ info["os"] = {}
33
+ info["python"] = {}
34
+ info["driver"] = {}
35
+ info["module"] = {}
36
+ if platform.system() == "Windows":
37
+ try:
38
+ import winreg as winreg
39
+ except ImportError:
40
+ import _winreg as winreg # type: ignore
41
+
42
+ os_name = "Windows"
43
+ try:
44
+ driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\RFmx\NR\C Runtime Support") # type: ignore
45
+ driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] # type: ignore
46
+ except WindowsError: # type: ignore
47
+ driver_version = "Unknown"
48
+ else:
49
+ raise SystemError("Unsupported platform: {}".format(platform.system()))
50
+
51
+ if sys.version_info[1] >= 10:
52
+ installed_packages_names = [
53
+ name
54
+ for name_list in importlib.metadata.packages_distributions().values()
55
+ for name in name_list
56
+ ]
57
+ installed_packages_names = set(installed_packages_names) # type: ignore
58
+ installed_packages_list = [
59
+ {"name": name, "version": importlib.metadata.distribution(name).version}
60
+ for name in sorted(installed_packages_names)
61
+ ]
62
+ else:
63
+ import pkg_resources
64
+
65
+ installed_packages = pkg_resources.working_set
66
+ installed_packages_list = [
67
+ {
68
+ "name": i.key,
69
+ "version": i.version,
70
+ }
71
+ for i in installed_packages
72
+ ]
73
+
74
+ info["os"]["name"] = os_name
75
+ info["os"]["version"] = platform.version()
76
+ info["os"]["bits"] = "64" if is_os_64bit() else "32" # type: ignore
77
+ info["driver"]["name"] = "RFmx NR"
78
+ info["driver"]["version"] = driver_version
79
+ info["module"]["name"] = "nirfmxnr"
80
+ info["module"]["version"] = "26.0.0"
81
+ info["python"]["version"] = sys.version
82
+ info["python"]["bits"] = "64" if is_python_64bit() else "32" # type: ignore
83
+ info["python"]["is_venv"] = is_venv() # type: ignore
84
+ info["python"]["packages"] = installed_packages_list
85
+
86
+ return info
87
+
88
+
89
+ def print_diagnostic_information():
90
+ """Print diagnostic information in a format suitable for issue report.
91
+ note: Python bitness may be incorrect when running in a virtual environment.
92
+ """
93
+ info = get_diagnostic_information() # type: ignore
94
+
95
+ row_format = " {:<10"
96
+ for type in ["OS", "Driver", "Module", "Python"]:
97
+ typename = type.lower()
98
+ print(type + ":")
99
+ for item in info[typename]:
100
+ if item != "packages":
101
+ print(row_format.format(item.title() + ":", info[typename][item]))
102
+ print(" Installed Packages:")
103
+ for p in info["python"]["packages"]:
104
+ print((" " * 8) + p["name"] + "==" + p["version"])
105
+
106
+ return info
nirfmxnr/acp.py ADDED
@@ -0,0 +1,31 @@
1
+ """Represents the Acp measurement."""
2
+
3
+ import functools
4
+
5
+ import nirfmxnr.acp_configuration as configuration
6
+ import nirfmxnr.acp_results as results
7
+
8
+
9
+ def _raise_if_disposed(f):
10
+ """From https://stackoverflow.com/questions/5929107/decorators-with-parameters."""
11
+
12
+ @functools.wraps(f)
13
+ def aux(*xs, **kws):
14
+ meas_obj = xs[0] # parameter 0 is 'self' which is the measurement object
15
+ if meas_obj._signal_obj.is_disposed:
16
+ raise Exception("Cannot access a disposed NR signal configuration")
17
+ return f(*xs, **kws)
18
+
19
+ return aux
20
+
21
+
22
+ class Acp(object):
23
+ """Represents the Acp measurement."""
24
+
25
+ def __init__(self, signal_obj):
26
+ """Represents the Acp measurement."""
27
+ self._signal_obj = signal_obj
28
+ self._session_function_lock = signal_obj._session_function_lock
29
+ self._interpreter = signal_obj._interpreter
30
+ self.configuration = configuration.AcpConfiguration(signal_obj) # type: ignore
31
+ self.results = results.AcpResults(signal_obj) # type: ignore
@@ -0,0 +1,100 @@
1
+ """"""
2
+
3
+ import functools
4
+
5
+ import nirfmxnr.attributes as attributes
6
+ import nirfmxnr.internal._helper as _helper
7
+
8
+
9
+ def _raise_if_disposed(f):
10
+ """From https://stackoverflow.com/questions/5929107/decorators-with-parameters."""
11
+
12
+ @functools.wraps(f)
13
+ def aux(*xs, **kws):
14
+ meas_obj = xs[0] # parameter 0 is 'self' which is the measurement object
15
+ if meas_obj._signal_obj.is_disposed:
16
+ raise Exception("Cannot access a disposed NR signal configuration")
17
+ return f(*xs, **kws)
18
+
19
+ return aux
20
+
21
+
22
+ class AcpComponentCarrierConfiguration(object):
23
+ """"""
24
+
25
+ def __init__(self, signal_obj):
26
+ """"""
27
+ self._signal_obj = signal_obj
28
+ self._session_function_lock = signal_obj._session_function_lock
29
+ self._interpreter = signal_obj._interpreter
30
+
31
+ @_raise_if_disposed
32
+ def get_integration_bandwidth(self, selector_string):
33
+ r"""Gets the integration bandwidth of the component carrier (CC). This value is expressed in Hz.
34
+
35
+ Use "carrier<*k*>" or "subblock<*n*>" or "subblock<*n*>/carrier<*k*>" as the `Selector String
36
+ <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ to read this result.
37
+
38
+ The default value is 9 MHz.
39
+
40
+ Args:
41
+ selector_string (string):
42
+ Pass an empty string.
43
+
44
+ Returns:
45
+ Tuple (attr_val, error_code):
46
+
47
+ attr_val (float):
48
+ Specifies the integration bandwidth of the component carrier (CC). This value is expressed in Hz.
49
+
50
+ error_code (int):
51
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
52
+ """
53
+ try:
54
+ self._session_function_lock.enter_read_lock()
55
+ updated_selector_string = _helper.validate_and_update_selector_string(
56
+ selector_string, self._signal_obj
57
+ )
58
+ attr_val, error_code = self._interpreter.get_attribute_f64(
59
+ updated_selector_string,
60
+ attributes.AttributeID.ACP_COMPONENT_CARRIER_INTEGRATION_BANDWIDTH.value,
61
+ )
62
+ finally:
63
+ self._session_function_lock.exit_read_lock()
64
+
65
+ return attr_val, error_code
66
+
67
+ @_raise_if_disposed
68
+ def set_integration_bandwidth(self, selector_string, value):
69
+ r"""Sets the integration bandwidth of the component carrier (CC). This value is expressed in Hz.
70
+
71
+ Use "carrier<*k*>" or "subblock<*n*>" or "subblock<*n*>/carrier<*k*>" as the `Selector String
72
+ <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ to read this result.
73
+
74
+ The default value is 9 MHz.
75
+
76
+ Args:
77
+ selector_string (string):
78
+ Pass an empty string.
79
+
80
+ value (float):
81
+ Specifies the integration bandwidth of the component carrier (CC). This value is expressed in Hz.
82
+
83
+ Returns:
84
+ int:
85
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
86
+ """
87
+ try:
88
+ self._session_function_lock.enter_read_lock()
89
+ updated_selector_string = _helper.validate_and_update_selector_string(
90
+ selector_string, self._signal_obj
91
+ )
92
+ error_code = self._interpreter.set_attribute_f64(
93
+ updated_selector_string,
94
+ attributes.AttributeID.ACP_COMPONENT_CARRIER_INTEGRATION_BANDWIDTH.value,
95
+ value,
96
+ )
97
+ finally:
98
+ self._session_function_lock.exit_read_lock()
99
+
100
+ return error_code
@@ -0,0 +1,212 @@
1
+ """"""
2
+
3
+ import functools
4
+
5
+ import nirfmxnr.attributes as attributes
6
+ import nirfmxnr.errors as errors
7
+ import nirfmxnr.internal._helper as _helper
8
+
9
+
10
+ def _raise_if_disposed(f):
11
+ """From https://stackoverflow.com/questions/5929107/decorators-with-parameters."""
12
+
13
+ @functools.wraps(f)
14
+ def aux(*xs, **kws):
15
+ meas_obj = xs[0] # parameter 0 is 'self' which is the measurement object
16
+ if meas_obj._signal_obj.is_disposed:
17
+ raise Exception("Cannot access a disposed NR signal configuration")
18
+ return f(*xs, **kws)
19
+
20
+ return aux
21
+
22
+
23
+ class AcpComponentCarrierResults(object):
24
+ """"""
25
+
26
+ def __init__(self, signal_obj):
27
+ """"""
28
+ self._signal_obj = signal_obj
29
+ self._session_function_lock = signal_obj._session_function_lock
30
+ self._interpreter = signal_obj._interpreter
31
+
32
+ @_raise_if_disposed
33
+ def get_absolute_power(self, selector_string):
34
+ r"""Gets the power measured over the integration bandwidth of the component carrier. The carrier power is reported in
35
+ dBm when you set the :py:attr:`~nirfmxnr.attributes.AttributeID.ACP_POWER_UNITS` attribute to **dBm**, and in dBm/Hz
36
+ when you set the ACP Pwr Units attribute to **dBm/Hz**.
37
+
38
+ Use "carrier<*k*>" or "subblock<*n*>" or "subblock<*n*>/carrier<*k*>" as the `Selector String
39
+ <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ to read this result.
40
+
41
+ Args:
42
+ selector_string (string):
43
+ Pass an empty string.
44
+
45
+ Returns:
46
+ Tuple (attr_val, error_code):
47
+
48
+ attr_val (float):
49
+ Returns the power measured over the integration bandwidth of the component carrier. The carrier power is reported in
50
+ dBm when you set the :py:attr:`~nirfmxnr.attributes.AttributeID.ACP_POWER_UNITS` attribute to **dBm**, and in dBm/Hz
51
+ when you set the ACP Pwr Units attribute to **dBm/Hz**.
52
+
53
+ error_code (int):
54
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
55
+ """
56
+ try:
57
+ self._session_function_lock.enter_read_lock()
58
+ updated_selector_string = _helper.validate_and_update_selector_string(
59
+ selector_string, self._signal_obj
60
+ )
61
+ attr_val, error_code = self._interpreter.get_attribute_f64(
62
+ updated_selector_string,
63
+ attributes.AttributeID.ACP_RESULTS_COMPONENT_CARRIER_ABSOLUTE_POWER.value,
64
+ )
65
+ finally:
66
+ self._session_function_lock.exit_read_lock()
67
+
68
+ return attr_val, error_code
69
+
70
+ @_raise_if_disposed
71
+ def get_relative_power(self, selector_string):
72
+ r"""Gets the component carrier power relative to its subblock power. This value is expressed in dB.
73
+
74
+ Use "carrier<*k*>" or "subblock<*n*>" or "subblock<*n*>/carrier<*k*>" as the `Selector String
75
+ <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ to read this result.
76
+
77
+ Args:
78
+ selector_string (string):
79
+ Pass an empty string.
80
+
81
+ Returns:
82
+ Tuple (attr_val, error_code):
83
+
84
+ attr_val (float):
85
+ Returns the component carrier power relative to its subblock power. This value is expressed in dB.
86
+
87
+ error_code (int):
88
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
89
+ """
90
+ try:
91
+ self._session_function_lock.enter_read_lock()
92
+ updated_selector_string = _helper.validate_and_update_selector_string(
93
+ selector_string, self._signal_obj
94
+ )
95
+ attr_val, error_code = self._interpreter.get_attribute_f64(
96
+ updated_selector_string,
97
+ attributes.AttributeID.ACP_RESULTS_COMPONENT_CARRIER_RELATIVE_POWER.value,
98
+ )
99
+ finally:
100
+ self._session_function_lock.exit_read_lock()
101
+
102
+ return attr_val, error_code
103
+
104
+ @_raise_if_disposed
105
+ def fetch_measurement_array(self, selector_string, timeout):
106
+ r"""Returns an array of the absolute and relative powers measured in the component carriers.
107
+
108
+ Use "subblock<*n*>" as the selector string to read results from this method.
109
+
110
+ Args:
111
+ selector_string (string):
112
+ This parameter specifies a `Selector String
113
+ <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result
114
+ name, and subblock number.
115
+
116
+ Example:
117
+
118
+ "subblock0"
119
+
120
+ "result::r1/subblock0"
121
+
122
+ You can use the :py:meth:`build_subblock_string` method to build the selector string.
123
+
124
+ timeout (float):
125
+ This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set
126
+ this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the
127
+ method waits until the measurement is complete. The default value is 10.
128
+
129
+ Returns:
130
+ Tuple (absolute_power, relative_power, error_code):
131
+
132
+ absolute_power (float):
133
+ This parameter returns an array of the power measured over the integration bandwidth of the component carrier. This
134
+ value is expressed in dBm. The carrier power is reported in dBm when you set the
135
+ :py:attr:`~nirfmxnr.attributes.AttributeID.ACP_POWER_UNITS` attribute to **dBm**, and in dBm/Hz when you set the ACP
136
+ Pwr Units attribute to **dBm/Hz**.
137
+
138
+ relative_power (float):
139
+ This parameter returns an array of the component carrier power relative to its subblock power. This value is expressed
140
+ in dB.
141
+
142
+ error_code (int):
143
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
144
+ """
145
+ try:
146
+ self._session_function_lock.enter_read_lock()
147
+ _helper.validate_not_none(selector_string, "selector_string")
148
+ updated_selector_string = _helper.validate_and_update_selector_string(
149
+ selector_string, self._signal_obj
150
+ )
151
+ absolute_power, relative_power, error_code = (
152
+ self._interpreter.acp_fetch_measurement_array(updated_selector_string, timeout)
153
+ )
154
+ finally:
155
+ self._session_function_lock.exit_read_lock()
156
+
157
+ return absolute_power, relative_power, error_code
158
+
159
+ @_raise_if_disposed
160
+ def fetch_measurement(self, selector_string, timeout):
161
+ r"""Returns the absolute and relative powers measured in the component carriers.
162
+
163
+ Use "carrier<*k*>" or "subblock<*n*>" or "subblock<*n*>/carrier<*k*>" as the selector string to read results
164
+ from this method.
165
+
166
+ Args:
167
+ selector_string (string):
168
+ This parameter specifies a `Selector String
169
+ <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ comprising of result
170
+ name, subblock number, and carrier number.
171
+
172
+ Example:
173
+
174
+ "subblock0/carrier0"
175
+
176
+ "result::r1/subblock0/carrier0"
177
+
178
+ You can use the :py:meth:`build_carrier_string` method to build the selector string.
179
+
180
+ timeout (float):
181
+ This parameter specifies the timeout for fetching the specified measurement. This value is expressed in seconds. Set
182
+ this value to an appropriate time, longer than expected for fetching the measurement. A value of -1 specifies that the
183
+ method waits until the measurement is complete. The default value is 10.
184
+
185
+ Returns:
186
+ Tuple (absolute_power, relative_power, error_code):
187
+
188
+ absolute_power (float):
189
+ This parameter returns the power measured over the integration bandwidth of the component carrier. This value is
190
+ expressed in dBm. The carrier power is reported in dBm when you set the
191
+ :py:attr:`~nirfmxnr.attributes.AttributeID.ACP_POWER_UNITS` attribute to **dBm**, and in dBm/Hz when you set the ACP
192
+ Pwr Units attribute to **dBm/Hz**.
193
+
194
+ relative_power (float):
195
+ This parameter returns the component carrier power relative to its subblock power. This value is expressed in dB.
196
+
197
+ error_code (int):
198
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
199
+ """
200
+ try:
201
+ self._session_function_lock.enter_read_lock()
202
+ _helper.validate_not_none(selector_string, "selector_string")
203
+ updated_selector_string = _helper.validate_and_update_selector_string(
204
+ selector_string, self._signal_obj
205
+ )
206
+ absolute_power, relative_power, error_code = self._interpreter.acp_fetch_measurement(
207
+ updated_selector_string, timeout
208
+ )
209
+ finally:
210
+ self._session_function_lock.exit_read_lock()
211
+
212
+ return absolute_power, relative_power, error_code