Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions generated/nifake/nifake/_grpc_stub_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ def method_with_proto_only_parameter(self, attribute_value): # noqa: N802
grpc_types.MethodWithProtoOnlyParameterRequest(attribute_value=attribute_value),
)

def mixed_ivi_dance_and_len_mechanism(self, input_values): # noqa: N802
response = self._invoke(
self._client.MixedIviDanceAndLenMechanism,
grpc_types.MixedIviDanceAndLenMechanismRequest(vi=self._vi, input_values=input_values),
)
return response.output_array

def multiple_array_types(self, output_array_size, input_array_of_floats, input_array_of_integers): # noqa: N802
response = self._invoke(
self._client.MultipleArrayTypes,
Expand Down
9 changes: 9 additions & 0 deletions generated/nifake/nifake/_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, ctypes_library):
self.niFake_MethodUsingWholeAndFractionalNumbers_cfunc = None
self.niFake_MethodWithGrpcOnlyParam_cfunc = None
self.niFake_MethodWithProtoOnlyParameter_cfunc = None
self.niFake_MixedIviDanceAndLenMechanism_cfunc = None
self.niFake_MultipleArrayTypes_cfunc = None
self.niFake_MultipleArraysDifferentSize_cfunc = None
self.niFake_MultipleArraysSameSize_cfunc = None
Expand Down Expand Up @@ -470,6 +471,14 @@ def niFake_MethodWithProtoOnlyParameter(self, attribute_value): # noqa: N802
self.niFake_MethodWithProtoOnlyParameter_cfunc.restype = ViStatus # noqa: F405
return self.niFake_MethodWithProtoOnlyParameter_cfunc(attribute_value)

def niFake_MixedIviDanceAndLenMechanism(self, vi, input_values, input_values_size, output_size, output_array): # noqa: N802
with self._func_lock:
if self.niFake_MixedIviDanceAndLenMechanism_cfunc is None:
self.niFake_MixedIviDanceAndLenMechanism_cfunc = self._get_library_function('niFake_MixedIviDanceAndLenMechanism')
self.niFake_MixedIviDanceAndLenMechanism_cfunc.argtypes = [ViSession, ctypes.POINTER(ViReal64), ViInt32, ViInt32, ctypes.POINTER(ViInt32)] # noqa: F405
self.niFake_MixedIviDanceAndLenMechanism_cfunc.restype = ViStatus # noqa: F405
return self.niFake_MixedIviDanceAndLenMechanism_cfunc(vi, input_values, input_values_size, output_size, output_array)

def niFake_MultipleArrayTypes(self, vi, output_array_size, output_array, output_array_of_fixed_length, input_array_sizes, input_array_of_floats, input_array_of_integers): # noqa: N802
with self._func_lock:
if self.niFake_MultipleArrayTypes_cfunc is None:
Expand Down
15 changes: 15 additions & 0 deletions generated/nifake/nifake/_library_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,21 @@ def method_with_proto_only_parameter(self, attribute_value): # noqa: N802
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return

def mixed_ivi_dance_and_len_mechanism(self, input_values): # noqa: N802
vi_ctype = _visatype.ViSession(self._vi) # case S110
input_values_ctype = _get_ctypes_pointer_for_buffer(value=input_values, library_type=_visatype.ViReal64) # case B550
input_values_size_ctype = _visatype.ViInt32(0 if input_values is None else len(input_values)) # case S160
output_size_ctype = _visatype.ViInt32() # case S170
output_array_ctype = None # case B580
error_code = self._library.niFake_MixedIviDanceAndLenMechanism(vi_ctype, input_values_ctype, input_values_size_ctype, output_size_ctype, output_array_ctype)
errors.handle_error(self, error_code, ignore_warnings=True, is_error_handling=False)
output_size_ctype = _visatype.ViInt32(error_code) # case S180
output_array_size = output_size_ctype.value # case B590
output_array_ctype = _get_ctypes_pointer_for_buffer(library_type=_visatype.ViInt32, size=output_array_size) # case B590
error_code = self._library.niFake_MixedIviDanceAndLenMechanism(vi_ctype, input_values_ctype, input_values_size_ctype, output_size_ctype, output_array_ctype)
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return [int(output_array_ctype[i]) for i in range(output_size_ctype.value)]

def multiple_array_types(self, output_array_size, input_array_of_floats, input_array_of_integers): # noqa: N802
vi_ctype = _visatype.ViSession(self._vi) # case S110
output_array_size_ctype = _visatype.ViInt32(output_array_size) # case S210
Expand Down
642 changes: 325 additions & 317 deletions generated/nifake/nifake/nifake_pb2.py

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions generated/nifake/nifake/nifake_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ def __init__(self, channel):
request_serializer=nifake__pb2.MultipleArraysSameSizeRequest.SerializeToString,
response_deserializer=nifake__pb2.MultipleArraysSameSizeResponse.FromString,
)
self.MultipleArraysDifferentSize = channel.unary_unary(
'/nifake_grpc.NiFake/MultipleArraysDifferentSize',
request_serializer=nifake__pb2.MultipleArraysDifferentSizeRequest.SerializeToString,
response_deserializer=nifake__pb2.MultipleArraysDifferentSizeResponse.FromString,
)
self.MixedIviDanceAndLenMechanism = channel.unary_unary(
'/nifake_grpc.NiFake/MixedIviDanceAndLenMechanism',
request_serializer=nifake__pb2.MixedIviDanceAndLenMechanismRequest.SerializeToString,
response_deserializer=nifake__pb2.MixedIviDanceAndLenMechanismResponse.FromString,
)
self.OneInputFunction = channel.unary_unary(
'/nifake_grpc.NiFake/OneInputFunction',
request_serializer=nifake__pb2.OneInputFunctionRequest.SerializeToString,
Expand Down Expand Up @@ -660,6 +670,18 @@ def MultipleArraysSameSize(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def MultipleArraysDifferentSize(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def MixedIviDanceAndLenMechanism(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def OneInputFunction(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
Expand Down Expand Up @@ -1219,6 +1241,16 @@ def add_NiFakeServicer_to_server(servicer, server):
request_deserializer=nifake__pb2.MultipleArraysSameSizeRequest.FromString,
response_serializer=nifake__pb2.MultipleArraysSameSizeResponse.SerializeToString,
),
'MultipleArraysDifferentSize': grpc.unary_unary_rpc_method_handler(
servicer.MultipleArraysDifferentSize,
request_deserializer=nifake__pb2.MultipleArraysDifferentSizeRequest.FromString,
response_serializer=nifake__pb2.MultipleArraysDifferentSizeResponse.SerializeToString,
),
'MixedIviDanceAndLenMechanism': grpc.unary_unary_rpc_method_handler(
servicer.MixedIviDanceAndLenMechanism,
request_deserializer=nifake__pb2.MixedIviDanceAndLenMechanismRequest.FromString,
response_serializer=nifake__pb2.MixedIviDanceAndLenMechanismResponse.SerializeToString,
),
'OneInputFunction': grpc.unary_unary_rpc_method_handler(
servicer.OneInputFunction,
request_deserializer=nifake__pb2.OneInputFunctionRequest.FromString,
Expand Down Expand Up @@ -2026,6 +2058,40 @@ def MultipleArraysSameSize(request,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def MultipleArraysDifferentSize(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/nifake_grpc.NiFake/MultipleArraysDifferentSize',
nifake__pb2.MultipleArraysDifferentSizeRequest.SerializeToString,
nifake__pb2.MultipleArraysDifferentSizeResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def MixedIviDanceAndLenMechanism(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/nifake_grpc.NiFake/MixedIviDanceAndLenMechanism',
nifake__pb2.MixedIviDanceAndLenMechanismRequest.SerializeToString,
nifake__pb2.MixedIviDanceAndLenMechanismResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def OneInputFunction(request,
target,
Expand Down
17 changes: 17 additions & 0 deletions generated/nifake/nifake/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,23 @@ def method_with_proto_only_parameter(self, attribute_value):
'''
self._interpreter.method_with_proto_only_parameter(attribute_value)

@ivi_synchronized
def mixed_ivi_dance_and_len_mechanism(self, input_values):
r'''mixed_ivi_dance_and_len_mechanism
Test method with mixed size mechanisms: one len-sized input array and one IVI-dance output array.
Args:
input_values (list of float): Input array of doubles using len size mechanism.
Returns:
output_array (list of int): Output array using IVI-dance size mechanism.
'''
output_array = self._interpreter.mixed_ivi_dance_and_len_mechanism(input_values)
return output_array

@ivi_synchronized
def multiple_array_types(self, output_array_size, input_array_of_floats, input_array_of_integers=None):
r'''multiple_array_types
Expand Down
21 changes: 21 additions & 0 deletions generated/nifake/nifake/unit_tests/_mock_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def __init__(self):
self._defaults['MethodWithGrpcOnlyParam']['return'] = 0
self._defaults['MethodWithProtoOnlyParameter'] = {}
self._defaults['MethodWithProtoOnlyParameter']['return'] = 0
self._defaults['MixedIviDanceAndLenMechanism'] = {}
self._defaults['MixedIviDanceAndLenMechanism']['return'] = 0
self._defaults['MixedIviDanceAndLenMechanism']['outputArray'] = None
self._defaults['MultipleArrayTypes'] = {}
self._defaults['MultipleArrayTypes']['return'] = 0
self._defaults['MultipleArrayTypes']['outputArray'] = None
Expand Down Expand Up @@ -738,6 +741,22 @@ def niFake_MethodWithProtoOnlyParameter(self, attribute_value): # noqa: N802
return self._defaults['MethodWithProtoOnlyParameter']['return']
return self._defaults['MethodWithProtoOnlyParameter']['return']

def niFake_MixedIviDanceAndLenMechanism(self, vi, input_values, input_values_size, output_size, output_array): # noqa: N802
if self._defaults['MixedIviDanceAndLenMechanism']['return'] != 0:
return self._defaults['MixedIviDanceAndLenMechanism']['return']
# output_array
if self._defaults['MixedIviDanceAndLenMechanism']['outputArray'] is None:
raise MockFunctionCallError("niFake_MixedIviDanceAndLenMechanism", param='outputArray')
if output_size.value == 0:
return len(self._defaults['MixedIviDanceAndLenMechanism']['outputArray'])
try:
output_array_ref = output_array.contents
except AttributeError:
output_array_ref = output_array
for i in range(len(self._defaults['MixedIviDanceAndLenMechanism']['outputArray'])):
output_array_ref[i] = self._defaults['MixedIviDanceAndLenMechanism']['outputArray'][i]
return self._defaults['MixedIviDanceAndLenMechanism']['return']

def niFake_MultipleArrayTypes(self, vi, output_array_size, output_array, output_array_of_fixed_length, input_array_sizes, input_array_of_floats, input_array_of_integers): # noqa: N802
if self._defaults['MultipleArrayTypes']['return'] != 0:
return self._defaults['MultipleArrayTypes']['return']
Expand Down Expand Up @@ -1127,6 +1146,8 @@ def set_side_effects_and_return_values(self, mock_library):
mock_library.niFake_MethodWithGrpcOnlyParam.return_value = 0
mock_library.niFake_MethodWithProtoOnlyParameter.side_effect = MockFunctionCallError("niFake_MethodWithProtoOnlyParameter")
mock_library.niFake_MethodWithProtoOnlyParameter.return_value = 0
mock_library.niFake_MixedIviDanceAndLenMechanism.side_effect = MockFunctionCallError("niFake_MixedIviDanceAndLenMechanism")
mock_library.niFake_MixedIviDanceAndLenMechanism.return_value = 0
mock_library.niFake_MultipleArrayTypes.side_effect = MockFunctionCallError("niFake_MultipleArrayTypes")
mock_library.niFake_MultipleArrayTypes.return_value = 0
mock_library.niFake_MultipleArraysDifferentSize.side_effect = MockFunctionCallError("niFake_MultipleArraysDifferentSize")
Expand Down
38 changes: 38 additions & 0 deletions generated/nifake/nifake/unit_tests/test_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,44 @@ def test_multiple_arrays_same_size_none_input(self):
values4=None,
)

def test_multiple_arrays_different_size(self):
library_func = 'MultipleArraysDifferentSize'
response_object = self._set_side_effect(library_func)
values_array = [1.1, 2.2, 3.3]
data_array = [10, 20, 30, 40, 50]
interpreter = self._get_initialized_stub_interpreter()
assert interpreter.multiple_arrays_different_size(values_array, data_array) is None # no outputs
self._assert_call(library_func, response_object).assert_called_once_with(
vi=GRPC_SESSION_OBJECT_FOR_TEST,
values_array=values_array,
data_array=data_array,
)

def test_multiple_arrays_different_size_none_input(self):
library_func = 'MultipleArraysDifferentSize'
response_object = self._set_side_effect(library_func)
values_array = [1.1, 2.2, 3.3]
interpreter = self._get_initialized_stub_interpreter()
assert interpreter.multiple_arrays_different_size(values_array, None) is None # no outputs
self._assert_call(library_func, response_object).assert_called_once_with(
vi=GRPC_SESSION_OBJECT_FOR_TEST,
values_array=values_array,
data_array=None,
)

def test_mixed_ivi_dance_and_len_mechanism(self):
library_func = 'MixedIviDanceAndLenMechanism'
input_values = [1.1, 2.2, 3.3]
expected_output = [4, 5]
response_object = self._set_side_effect(library_func, output_array=expected_output)
interpreter = self._get_initialized_stub_interpreter()
result_array = interpreter.mixed_ivi_dance_and_len_mechanism(input_values)
assert result_array == expected_output
self._assert_call(library_func, response_object).assert_called_once_with(
vi=GRPC_SESSION_OBJECT_FOR_TEST,
input_values=input_values,
)

def test_multiple_arrays_same_size_wrong_size(self):
library_func = 'MultipleArraysSameSize'
# grpc-device server checks this server-side and errors with ::grpc::INVALID_ARGUMENT
Expand Down
22 changes: 22 additions & 0 deletions generated/nifake/nifake/unit_tests/test_library_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,28 @@ def test_multiple_arrays_different_size(self):
_matchers.ViInt32Matcher(len(data_array)),
)

def test_multiple_arrays_different_size_none_input(self):
self.patched_library.niFake_MultipleArraysDifferentSize.side_effect = self.side_effects_helper.niFake_MultipleArraysDifferentSize
values_array = [1.1, 2.2, 3.3]
interpreter = self.get_initialized_library_interpreter()
interpreter.multiple_arrays_different_size(values_array, None)
self.patched_library.niFake_MultipleArraysDifferentSize.assert_called_once_with(
_matchers.ViSessionMatcher(SESSION_NUM_FOR_TEST),
_matchers.ViReal64BufferMatcher(values_array),
_matchers.ViInt32Matcher(len(values_array)),
None,
_matchers.ViInt32Matcher(0),
)

def test_mixed_ivi_dance_and_len_mechanism(self):
self.patched_library.niFake_MixedIviDanceAndLenMechanism.side_effect = self.side_effects_helper.niFake_MixedIviDanceAndLenMechanism
expected_output = [4, 5]
self.side_effects_helper['MixedIviDanceAndLenMechanism']['outputArray'] = expected_output
interpreter = self.get_initialized_library_interpreter()
result_array = interpreter.mixed_ivi_dance_and_len_mechanism([1.1])
assert result_array == expected_output
assert self.patched_library.niFake_MixedIviDanceAndLenMechanism.call_count == 2

def test_parameters_are_multiple_types(self):
self.patched_library.niFake_ParametersAreMultipleTypes.side_effect = self.side_effects_helper.niFake_ParametersAreMultipleTypes
boolean_val = True
Expand Down
7 changes: 7 additions & 0 deletions generated/nifake/nifake/unit_tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,13 @@ def test_multiple_arrays_same_size_wrong_size_4(self):
except ValueError:
pass

def test_multiple_arrays_different_size_none_input(self):
values_array = [1.1, 2.2, 3.3]
self.patched_library_interpreter.multiple_arrays_different_size.side_effect = [None]
with nifake.Session('dev1') as session:
assert session.multiple_arrays_different_size(values_array, None) is None
self.patched_library_interpreter.multiple_arrays_different_size.assert_called_once_with(values_array, None)

def test_get_cal_date_time(self):
month = 12
day = 30
Expand Down
58 changes: 58 additions & 0 deletions src/nifake/metadata/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3184,6 +3184,64 @@
],
'returns': 'ViStatus'
},
'MixedIviDanceAndLenMechanism': {
'codegen_method': 'public',
'documentation': {
'description': 'Test function with mixed size mechanisms: one len-sized input array and one IVI-dance output array.'
},
'included_in_proto': True,
'parameters': [
{
'direction': 'in',
'documentation': {
'description': 'Identifies a particular instrument session.'
},
'name': 'vi',
'type': 'ViSession'
},
{
'direction': 'in',
'documentation': {
'description': 'Input array of doubles using len size mechanism.'
},
'name': 'inputValues',
'size': {
'mechanism': 'len',
'value': 'inputValuesSize'
},
'type': 'ViReal64[]',
},
{
'direction': 'in',
'documentation': {
'description': 'Specifies the number of elements in inputValues.'
},
'name': 'inputValuesSize',
'type': 'ViInt32',
},
{
'direction': 'in',
'documentation': {
'description': 'The number of elements in the output array for IVI dance.'
},
'name': 'outputSize',
'type': 'ViInt32'
},
{
'direction': 'out',
'documentation': {
'description': 'Output array using IVI-dance size mechanism.'
},
'name': 'outputArray',
'size': {
'mechanism': 'ivi-dance',
'value': 'outputSize'
},
'type': 'ViInt32[]'
}
],
'returns': 'ViStatus'
},
'self_test': {
'codegen_method': 'private',
'documentation': {
Expand Down
Loading