Skip to content

Commit

Permalink
Update niscope metadata for nimi-python 1.4.4 release (#1935)
Browse files Browse the repository at this point in the history
* update niscope metadata

* update niscope.proto

* Enable cal time tests for TestGrpc

* update fetch_array_measurement to utilize meas_wfm_size in GrpcStubInterpreter

* Update system tests for meas_wfm_size change

* rearrange niscope system tests in more sensible manner

* Revert "Enable cal time tests for TestGrpc"

This reverts commit f19782c.

* Let GrpcStubInterpreter get _actual_meas_wfm_size without an extra grpc call

* Update changelog with description of fetch_array_measurement change.

* Delete unnecessary templates

* Update wording for description of fix in CHANGELOG.md
  • Loading branch information
ni-jfitzger authored Apr 13, 2023
1 parent a902d5e commit d68b01a
Show file tree
Hide file tree
Showing 14 changed files with 310 additions and 322 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ All notable changes to this project will be documented in this file.
* ### `niscope` (NI-SCOPE)
* #### Added
* #### Changed
* Fix [#1941](https://github.com/ni/nimi-python/issues/1941): When calling niscope.Session.fetch_array_measurement in a MeasurementLink measurement plugin, meas_wfm_size cannot be set.
* Requires NI gRPC Device Server 2023 Q2 or later. Older versions do not support this parameter and return all available samples.
* #### Removed
* ### `niswitch` (NI-SWITCH)
* #### Added
Expand Down
2 changes: 1 addition & 1 deletion generated/niscope/niscope/_grpc_stub_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def fetch_into_numpy(self, channel_list, timeout, num_samples): # noqa: N802
def fetch_array_measurement(self, channel_list, timeout, array_meas_function, measurement_waveform_size): # noqa: N802
response = self._invoke(
self._client.FetchArrayMeasurement,
grpc_types.FetchArrayMeasurementRequest(vi=self._vi, channel_list=channel_list, timeout=timeout, array_meas_function_raw=array_meas_function.value),
grpc_types.FetchArrayMeasurementRequest(vi=self._vi, channel_list=channel_list, timeout=timeout, array_meas_function_raw=array_meas_function.value, meas_wfm_size=measurement_waveform_size),
)
return response.meas_wfm, [waveform_info.WaveformInfo(x) for x in response.wfm_info]

Expand Down
468 changes: 234 additions & 234 deletions generated/niscope/niscope/niscope_pb2.py

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions generated/niscope/niscope/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2221,12 +2221,10 @@ def fetch_array_measurement(self, array_meas_function, meas_wfm_size=None, relat
self._fetch_num_records = -1 if num_records is None else num_records
self._fetch_meas_num_samples = -1 if meas_num_samples is None else meas_num_samples

# For GrpcStubInterpreter, the server will automatically get _actual_meas_wfm_size, if needed.
if isinstance(self._interpreter, _library_interpreter.LibraryInterpreter):
if meas_wfm_size is None:
meas_wfm_size = self._actual_meas_wfm_size(array_meas_function)
else:
if meas_wfm_size is not None:
raise ValueError('The argument "meas_wfm_size" must be None when using gRPC.')

meas_wfm, wfm_info = self._fetch_array_measurement(array_meas_function, meas_wfm_size, timeout)

Expand Down
2 changes: 1 addition & 1 deletion src/niscope/metadata/attributes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# This file is generated from NI-SCOPE API metadata version 23.0.0d95
# This file is generated from NI-SCOPE API metadata version 23.1.0f21
attributes = {
1050005: {
'access': 'read-write',
Expand Down
4 changes: 2 additions & 2 deletions src/niscope/metadata/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# This file is generated from NI-SCOPE API metadata version 23.0.0d95
# This file is generated from NI-SCOPE API metadata version 23.1.0f21
config = {
'api_version': '23.0.0d95',
'api_version': '23.1.0f21',
'c_function_prefix': 'niScope_',
'close_function': 'close',
'context_manager_name': {
Expand Down
18 changes: 9 additions & 9 deletions src/niscope/metadata/enums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# This file is generated from NI-SCOPE API metadata version 23.0.0d95
# This file is generated from NI-SCOPE API metadata version 23.1.0f21
enums = {
'5900AccessoryInAScopeSessionValues': {
'values': [
Expand Down Expand Up @@ -342,17 +342,17 @@
},
'AttributeRetrievalModes': {
'values': [
{
'name': 'NISCOPE_VAL_ATTRIBUTE_RETRIEVAL_MODE_COERCED',
'value': 0
},
{
'name': 'NISCOPE_VAL_ATTRIBUTE_RETRIEVAL_MODE_DEFAULT',
'value': 2
},
{
'name': 'NISCOPE_VAL_ATTRIBUTE_RETRIEVAL_MODE_DESIRED',
'value': 1
},
{
'name': 'NISCOPE_VAL_ATTRIBUTE_RETRIEVAL_MODE_COERCED',
'value': 0
}
]
},
Expand Down Expand Up @@ -1020,15 +1020,15 @@
'name': 'NISCOPE_VAL_READY_FOR_REF_EVENT',
'value': 10
},
{
'name': 'NISCOPE_VAL_REF_CLOCK',
'value': 100
},
{
'name': 'NISCOPE_VAL_5V_OUT',
'python_name': 'FIVE_V_OUT',
'value': 13
},
{
'name': 'NISCOPE_VAL_REF_CLOCK',
'value': 100
},
{
'name': 'NISCOPE_VAL_SAMPLE_CLOCK',
'value': 101
Expand Down
2 changes: 1 addition & 1 deletion src/niscope/metadata/functions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# This file is generated from NI-SCOPE API metadata version 23.0.0d95
# This file is generated from NI-SCOPE API metadata version 23.1.0f21
functions = {
'Abort': {
'documentation': {
Expand Down
11 changes: 11 additions & 0 deletions src/niscope/metadata/functions_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
# Changes to the metadata should be made here, because functions.py is generated thus any changes get overwritten.

functions_override_metadata = {
# TODO (ni-jfitzger): delete this override once functions.py lists "default_method" for library_interpreter_filename. See https://github.com/ni/nimi-python/issues/1938
'FetchArrayMeasurement': {
'method_templates': [
{
'documentation_filename': 'default_method',
'library_interpreter_filename': 'default_method',
'method_python_name_suffix': '',
'session_filename': 'default_method'
}
]
}
}

functions_additional_fetch_array_measurement = {
Expand Down
4 changes: 2 additions & 2 deletions src/niscope/metadata/niscope.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

//---------------------------------------------------------------------
// This file is generated from NI-SCOPE API metadata version 23.0.0d95
// This file is generated from NI-SCOPE API metadata version 23.3.0d127
//---------------------------------------------------------------------
// Proto file for the NI-SCOPE Metadata
//---------------------------------------------------------------------
Expand Down Expand Up @@ -1439,6 +1439,7 @@ message FetchArrayMeasurementRequest {
ArrayMeasurement array_meas_function = 4;
sint32 array_meas_function_raw = 5;
}
optional sint32 meas_wfm_size = 6;
}

message FetchArrayMeasurementResponse {
Expand Down Expand Up @@ -1952,4 +1953,3 @@ message SetAttributeViStringRequest {
message SetAttributeViStringResponse {
int32 status = 1;
}

102 changes: 45 additions & 57 deletions src/niscope/system_tests/test_system_niscope.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,32 +118,41 @@ def test_fetch_defaults(self, multi_instrument_session):
for i in range(len(waveforms)):
assert len(waveforms[i].samples) == test_record_length

def test_fetch_measurement_stats(self, multi_instrument_session):
@pytest.fixture(params=[(1000, 1000), (2000, 2000), (3000, 2000)], ids=["less_than_actual", "equal_to_actual", "greater_than_actual"])
def measurement_wfm_length(self, request):
MeasWfmLength = collections.namedtuple('MeasurementWaveformLength', ['passed_in', 'expected'])
return MeasWfmLength(passed_in=request.param[0], expected=request.param[1])

def test_fetch_array_measurement(self, multi_instrument_session, measurement_wfm_length):
test_voltage = 1.0
test_record_length = 1000
test_num_channels = 2
test_num_records = 3
test_meas_wfm_length = measurement_wfm_length.passed_in
test_array_meas_function = niscope.ArrayMeasurement.ARRAY_GAIN
test_starting_record_number = 2
test_num_records_to_acquire = 5
test_num_records_to_fetch = test_num_records_to_acquire - test_starting_record_number
multi_instrument_session.configure_vertical(test_voltage, niscope.VerticalCoupling.AC)
multi_instrument_session.configure_horizontal_timing(50000000, test_record_length, 50.0, test_num_records_to_acquire, True)

with multi_instrument_session.initiate():
measurement_stats = multi_instrument_session.channels[test_channels].fetch_measurement_stats(
scalar_meas_function=niscope.enums.ScalarMeasurement.NO_MEASUREMENT,
waveforms = multi_instrument_session.channels[test_channels].fetch_array_measurement(
array_meas_function=test_array_meas_function,
meas_wfm_size=test_meas_wfm_length,
relative_to=niscope.FetchRelativeTo.PRETRIGGER,
offset=5,
record_number=test_starting_record_number,
num_records=test_num_records_to_fetch,
meas_num_samples=2000,
timeout=hightime.timedelta(seconds=4))

assert len(measurement_stats) == test_num_channels * test_num_records
assert len(waveforms) == test_num_channels * test_num_records_to_fetch
expected_channels = test_channels.split(',') * test_num_records_to_fetch
expected_records = [2, 2, 3, 3, 4, 4]
for i in range(len(measurement_stats)):
assert measurement_stats[i].result == 0.0
assert measurement_stats[i].channel == expected_channels[i]
assert measurement_stats[i].record == expected_records[i]
for i in range(len(waveforms)):
assert len(waveforms[i].samples) == measurement_wfm_length.expected
assert waveforms[i].channel == expected_channels[i]
assert waveforms[i].record == expected_records[i]

def test_fetch_array_measurement_defaults(self, multi_instrument_session):
test_voltage = 1.0
Expand All @@ -163,6 +172,33 @@ def test_fetch_array_measurement_defaults(self, multi_instrument_session):
for i in range(len(waveforms)):
assert len(waveforms[i].samples) == test_record_length

def test_fetch_measurement_stats(self, multi_instrument_session):
test_voltage = 1.0
test_record_length = 1000
test_num_channels = 2
test_num_records = 3
test_starting_record_number = 2
test_num_records_to_acquire = 5
test_num_records_to_fetch = test_num_records_to_acquire - test_starting_record_number
multi_instrument_session.configure_vertical(test_voltage, niscope.VerticalCoupling.AC)
multi_instrument_session.configure_horizontal_timing(50000000, test_record_length, 50.0, test_num_records_to_acquire, True)
with multi_instrument_session.initiate():
measurement_stats = multi_instrument_session.channels[test_channels].fetch_measurement_stats(
scalar_meas_function=niscope.enums.ScalarMeasurement.NO_MEASUREMENT,
relative_to=niscope.FetchRelativeTo.PRETRIGGER,
offset=5,
record_number=test_starting_record_number,
num_records=test_num_records_to_fetch,
timeout=hightime.timedelta(seconds=4))

assert len(measurement_stats) == test_num_channels * test_num_records
expected_channels = test_channels.split(',') * test_num_records_to_fetch
expected_records = [2, 2, 3, 3, 4, 4]
for i in range(len(measurement_stats)):
assert measurement_stats[i].result == 0.0
assert measurement_stats[i].channel == expected_channels[i]
assert measurement_stats[i].record == expected_records[i]

def test_fetch_measurement_stats_defaults(self, multi_instrument_session):
test_voltage = 1.0
test_record_length = 1000
Expand Down Expand Up @@ -466,42 +502,6 @@ def test_configure_ref_levels(self, single_instrument_session):
single_instrument_session._configure_ref_levels()
assert 90.0 == single_instrument_session.meas_chan_high_ref_level

@pytest.fixture(params=[(1000, 1000), (2000, 2000), (3000, 2000)], ids=["less_than_actual", "equal_to_actual", "greater_than_actual"])
def measurement_wfm_length(self, request):
MeasWfmLength = collections.namedtuple('MeasurementWaveformLength', ['passed_in', 'expected'])
return MeasWfmLength(passed_in=request.param[0], expected=request.param[1])

def test_fetch_array_measurement(self, multi_instrument_session, measurement_wfm_length):
test_voltage = 1.0
test_record_length = 1000
test_num_channels = 2
test_meas_wfm_length = measurement_wfm_length.passed_in
test_array_meas_function = niscope.ArrayMeasurement.ARRAY_GAIN
test_starting_record_number = 2
test_num_records_to_acquire = 5
test_num_records_to_fetch = test_num_records_to_acquire - test_starting_record_number
multi_instrument_session.configure_vertical(test_voltage, niscope.VerticalCoupling.AC)
multi_instrument_session.configure_horizontal_timing(50000000, test_record_length, 50.0, test_num_records_to_acquire, True)

with multi_instrument_session.initiate():
waveforms = multi_instrument_session.channels[test_channels].fetch_array_measurement(
array_meas_function=test_array_meas_function,
meas_wfm_size=test_meas_wfm_length,
relative_to=niscope.FetchRelativeTo.PRETRIGGER,
offset=5,
record_number=test_starting_record_number,
num_records=test_num_records_to_fetch,
meas_num_samples=2000,
timeout=hightime.timedelta(seconds=4))

assert len(waveforms) == test_num_channels * test_num_records_to_fetch
expected_channels = test_channels.split(',') * test_num_records_to_fetch
expected_records = [2, 2, 3, 3, 4, 4]
for i in range(len(waveforms)):
assert len(waveforms[i].samples) == measurement_wfm_length.expected
assert waveforms[i].channel == expected_channels[i]
assert waveforms[i].record == expected_records[i]

def test_reset_with_defaults(self, single_instrument_session):
default_meas_time_histogram_high_time = single_instrument_session.meas_time_histogram_high_time
assert default_meas_time_histogram_high_time == hightime.timedelta(microseconds=500)
Expand Down Expand Up @@ -535,15 +535,3 @@ def test_reset_with_defaults(self, single_instrument_session):
single_instrument_session.reset_with_defaults()
assert exc_info.value.args[0] == 'reset_with_defaults is not supported over gRPC'
assert str(exc_info.value) == 'reset_with_defaults is not supported over gRPC'

def test_fetch_array_measurement_with_meas_wfm_size_value_error(self, multi_instrument_session):
test_array_meas_function = niscope.ArrayMeasurement.ARRAY_GAIN
test_meas_wfm_length = 2000
with pytest.raises(ValueError) as exc_info:
with multi_instrument_session.initiate():
multi_instrument_session.fetch_array_measurement(
array_meas_function=test_array_meas_function,
meas_wfm_size=test_meas_wfm_length)

assert exc_info.value.args[0] == 'The argument "meas_wfm_size" must be None when using gRPC.'
assert str(exc_info.value) == 'The argument "meas_wfm_size" must be None when using gRPC.'

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
self._fetch_num_records = -1 if num_records is None else num_records
self._fetch_meas_num_samples = -1 if meas_num_samples is None else meas_num_samples

# For GrpcStubInterpreter, the server will automatically get _actual_meas_wfm_size, if needed.
if isinstance(self._interpreter, _library_interpreter.LibraryInterpreter):
if meas_wfm_size is None:
meas_wfm_size = self._actual_meas_wfm_size(array_meas_function)
else:
if meas_wfm_size is not None:
raise ValueError('The argument "meas_wfm_size" must be None when using gRPC.')

meas_wfm, wfm_info = self._${f['python_name']}(array_meas_function, meas_wfm_size, timeout)

Expand Down

0 comments on commit d68b01a

Please sign in to comment.