Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues causing errors in test cases using real devices #321

Merged
merged 12 commits into from
May 5, 2023
Merged
153 changes: 67 additions & 86 deletions generated/nidaqmx/_library_interpreter.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions generated/nidaqmx/_task_modules/in_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,8 @@ def read(self, number_of_samples_per_channel=READ_ALL_AVAILABLE):
numpy_array = numpy.zeros(number_of_samples, dtype=dtype)

_, samples_read, _ = self._interpreter.read_raw(
self._handle, numpy_array, num_samps_per_chan,
self.timeout)
self._handle, num_samps_per_chan,
self.timeout, numpy_array)

if samples_read != number_of_samples:
return numpy_array[:samples_read]
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/stream_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ def read_one_sample_multi_line(self, data, timeout=10):
self._verify_array_digital_lines(data, False, True)

_, samps_per_chan_read, num_bytes_per_samp = self._interpreter.read_digital_lines(
self._handle, data, 1, timeout, FillMode.GROUP_BY_CHANNEL.value)
self._handle, 1, timeout, FillMode.GROUP_BY_CHANNEL.value, data)

def read_one_sample_one_line(self, timeout=10):
"""
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/stream_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ def write_one_sample_port_uint32(self, data, timeout=10):
AUTO_START_UNSET else True)

return self._interpreter.write_digital_scalar_u32(
self._handle, auto_start, timeout, FillMode.GROUP_BY_CHANNEL.value, data)
self._handle, auto_start, timeout, data)


class DigitalMultiChannelWriter(ChannelWriterBase):
Expand Down
6 changes: 3 additions & 3 deletions generated/nidaqmx/system/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def get_digital_power_up_states(self, device_name):
for d, p in zip(device.do_lines, states):
power_up_states.append(
DOPowerUpState(physical_channel=d.name,
power_up_state=PowerUpStates(p.value)))
power_up_state=PowerUpStates(p)))

return power_up_states

Expand Down Expand Up @@ -346,7 +346,7 @@ def get_digital_pull_up_pull_down_states(self, device_name):
power_up_states.append(
DOResistorPowerUpState(
physical_channel=d.name,
power_up_state=ResistorState(p.value)))
power_up_state=ResistorState(p)))

return power_up_states

Expand Down Expand Up @@ -451,7 +451,7 @@ def get_analog_power_up_states(self, device_name):
power_up_states.append(
AOPowerUpState(
physical_channel=a.name,
power_up_state=p.value,
power_up_state=p,
channel_type=AOPowerUpOutputBehavior(c.value)))

return power_up_states
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/metadata/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18564,7 +18564,7 @@
'type': 'int32'
},
{
'ctypes_data_type': 'numpy.uint8',
'ctypes_data_type': 'numpy.bool',
'direction': 'out',
'has_explicit_buffer_size': True,
'is_list': True,
Expand Down Expand Up @@ -24148,7 +24148,7 @@
'type': 'int32'
},
{
'ctypes_data_type': 'numpy.uint8',
'ctypes_data_type': 'numpy.bool',
'direction': 'in',
'is_list': True,
'is_optional_in_python': False,
Expand Down
90 changes: 45 additions & 45 deletions src/codegen/metadata/functions_addon.py
Original file line number Diff line number Diff line change
@@ -1,137 +1,137 @@
functions_override_metadata = {
'ReadAnalogF64': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadAnalogScalarF64': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadBinaryI16': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadBinaryI32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadBinaryU16': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadBinaryU32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCounterF64': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCounterF64Ex': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCounterScalarF64': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCounterScalarU32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCounterU32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCounterU32Ex': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCtrFreq': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCtrFreqScalar': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCtrTicks': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCtrTicksScalar': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCtrTime': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadCtrTimeScalar': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadDigitalLines': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadDigitalScalarU32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadDigitalU16': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadDigitalU32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadDigitalU8': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadPowerScalarF64': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'WriteAnalogF64': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteAnalogScalarF64': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteBinaryI16': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteBinaryI32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteBinaryU16': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteBinaryU32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteCtrFreq': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteCtrFreqScalar': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteCtrTicks': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteCtrTicksScalar': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteCtrTime': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteCtrTimeScalar': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteDigitalLines': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteDigitalScalarU32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteDigitalU16': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteDigitalU32': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'WriteDigitalU8': {
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
},
'ReadPowerBinaryI16':{
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadPowerF64':{
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'ReadRaw':{
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Read',
},
'WriteRaw':{
'python_codegen_method': 'CustomCode_Read_Write',
'python_codegen_method': 'CustomCode_Write',
}
}
4 changes: 2 additions & 2 deletions src/codegen/templates/_task_modules/in_stream.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ ${property_template.script_property(attribute)}\
numpy_array = numpy.zeros(number_of_samples, dtype=dtype)

_, samples_read, _ = self._interpreter.read_raw(
self._handle, numpy_array, num_samps_per_chan,
self.timeout)
self._handle, num_samps_per_chan,
self.timeout, numpy_array)

if samples_read != number_of_samples:
return numpy_array[:samples_read]
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/templates/system/system.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ ${function_template.script_function(function_object)}
for d, p in zip(device.do_lines, states):
power_up_states.append(
DOPowerUpState(physical_channel=d.name,
power_up_state=PowerUpStates(p.value)))
power_up_state=PowerUpStates(p)))

return power_up_states

Expand Down Expand Up @@ -286,7 +286,7 @@ ${function_template.script_function(function_object)}
power_up_states.append(
DOResistorPowerUpState(
physical_channel=d.name,
power_up_state=ResistorState(p.value)))
power_up_state=ResistorState(p)))

return power_up_states

Expand Down Expand Up @@ -391,7 +391,7 @@ ${function_template.script_function(function_object)}
power_up_states.append(
AOPowerUpState(
physical_channel=a.name,
power_up_state=p.value,
power_up_state=p,
channel_type=AOPowerUpOutputBehavior(c.value)))

return power_up_states
Expand Down
10 changes: 8 additions & 2 deletions src/codegen/utilities/function_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ def get_instantiation_lines(function_parameters):
def get_arguments_type(functions_metadata):
"""Gets the 'type' of parameters."""
argtypes = []
is_read_write_function = functions_metadata.python_codegen_method == "CustomCode_Read_Write"
is_read_write_function = functions_metadata.python_codegen_method in (
"CustomCode_Read",
"CustomCode_Write",
)

if is_read_write_function:
argtypes.append("lib_importer.task_handle")
Expand Down Expand Up @@ -185,8 +188,11 @@ def get_arguments_type(functions_metadata):

def to_param_argtype(parameter):
"""Formats argument types."""
flags = "'C','W'" if parameter.direction == "out" else "'C'"
if parameter.is_list:
return f"wrapped_ndpointer(dtype={parameter.ctypes_data_type}, flags=('C','W'))"
if parameter.ctypes_data_type == "numpy.bool":
return f"wrapped_ndpointer(dtype=bool, flags=({flags}))"
return f"wrapped_ndpointer(dtype={parameter.ctypes_data_type}, flags=({flags}))"
else:
if parameter.ctypes_data_type == "ctypes.TaskHandle":
return "lib_importer.task_handle"
Expand Down
9 changes: 7 additions & 2 deletions src/codegen/utilities/interpreter_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,17 @@ def has_parameter_with_ivi_dance_size_mechanism(func):

def is_custom_read_write_function(func):
"""Returns True if the function is a read or write function."""
return func.python_codegen_method == "CustomCode_Read_Write"
return func.python_codegen_method in ("CustomCode_Read", "CustomCode_Write")


def is_custom_read_function(func):
"""Returns True if the function is a read function."""
return func.python_codegen_method == "CustomCode_Read_Write" and "read_" in func.function_name
return func.python_codegen_method == "CustomCode_Read"


def is_custom_write_function(func):
"""Returns True if the function is a write function."""
return func.python_codegen_method == "CustomCode_Write"


def get_interpreter_output_params(func):
Expand Down
2 changes: 1 addition & 1 deletion src/handwritten/stream_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1867,7 +1867,7 @@ def read_one_sample_multi_line(self, data, timeout=10):
self._verify_array_digital_lines(data, False, True)

_, samps_per_chan_read, num_bytes_per_samp = self._interpreter.read_digital_lines(
self._handle, data, 1, timeout, FillMode.GROUP_BY_CHANNEL.value)
self._handle, 1, timeout, FillMode.GROUP_BY_CHANNEL.value, data)

def read_one_sample_one_line(self, timeout=10):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/handwritten/stream_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ def write_one_sample_port_uint32(self, data, timeout=10):
AUTO_START_UNSET else True)

return self._interpreter.write_digital_scalar_u32(
self._handle, auto_start, timeout, FillMode.GROUP_BY_CHANNEL.value, data)
self._handle, auto_start, timeout, data)


class DigitalMultiChannelWriter(ChannelWriterBase):
Expand Down