Skip to content

Commit

Permalink
Add support for WaitForValidTimestamp to nidaqmx-python
Browse files Browse the repository at this point in the history
  • Loading branch information
DeborahOoi96 committed Feb 8, 2024
1 parent 1305bc1 commit 985ac55
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 4 deletions.
4 changes: 4 additions & 0 deletions generated/nidaqmx/_base_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,10 @@ def unregister_signal_event(self, task, signal_id):
def unreserve_network_device(self, device_name):
raise NotImplementedError

@abc.abstractmethod
def wait_for_valid_timestamp(self, task, timestamp_event, timeout):
raise NotImplementedError

@abc.abstractmethod
def wait_until_task_done(self, task, time_to_wait):
raise NotImplementedError
Expand Down
8 changes: 8 additions & 0 deletions generated/nidaqmx/_grpc_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3254,6 +3254,14 @@ def unreserve_network_device(self, device_name):
self._client.UnreserveNetworkDevice,
grpc_types.UnreserveNetworkDeviceRequest(device_name=device_name))

def wait_for_valid_timestamp(self, task, timestamp_event, timeout):
response = self._invoke(
self._client.WaitForValidTimestamp,
grpc_types.WaitForValidTimestampRequest(
task=task, timestamp_event_raw=timestamp_event,
timeout=timeout))
return response.timestamp

def wait_until_task_done(self, task, time_to_wait):
response = self._invoke(
self._client.WaitUntilTaskDone,
Expand Down
17 changes: 17 additions & 0 deletions generated/nidaqmx/_library_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5636,6 +5636,23 @@ def unreserve_network_device(self, device_name):
device_name)
self.check_for_error(error_code)

def wait_for_valid_timestamp(self, task, timestamp_event, timeout):
timestamp = _lib_time.AbsoluteTime()

cfunc = lib_importer.windll.DAQmxWaitForValidTimestamp
if cfunc.argtypes is None:
with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_int32,
ctypes.c_double,
ctypes.POINTER(_lib_time.AbsoluteTime)]

error_code = cfunc(
task, timestamp_event, timeout, ctypes.byref(timestamp))
self.check_for_error(error_code)
return timestamp.value

def wait_until_task_done(self, task, time_to_wait):
cfunc = lib_importer.windll.DAQmxWaitUntilTaskDone
if cfunc.argtypes is None:
Expand Down
12 changes: 9 additions & 3 deletions src/codegen/metadata/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23606,6 +23606,11 @@
},
'WaitForValidTimestamp': {
'calling_convention': 'StdCall',
'handle_parameter': {
'ctypes_data_type': 'lib_importer.task_handle',
'cvi_name': 'taskHandle',
'python_accessor': 'self._handle'
},
'parameters': [
{
'ctypes_data_type': 'ctypes.TaskHandle',
Expand Down Expand Up @@ -23644,13 +23649,14 @@
'direction': 'out',
'is_optional_in_python': False,
'name': 'timestamp',
'python_data_type': 'DateTime',
'python_data_type': 'datetime',
'python_description': 'Specifies the timestamp type to wait on.',
'python_type_annotation': 'nidaqmx.constants.DateTime',
'python_type_annotation': 'datetime',
'type': 'CVIAbsoluteTime'
}
],
'python_codegen_method': 'no',
'python_class_name': 'Task',
'python_codegen_method': 'CustomCode',
'python_description': 'DAQmx Wait for Valid Timestamp',
'returns': 'int32'
},
Expand Down
6 changes: 6 additions & 0 deletions src/codegen/utilities/function_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,17 @@ def to_param_argtype(parameter):
# argtype to convert from unicode to bytes.
if parameter.ctypes_data_type == "ctypes.c_char_p":
return "ctypes_byte_str"
elif parameter.python_data_type == "datetime":
return "_lib_time.AbsoluteTime"
elif parameter.python_data_type == "timestampEvent":
return "ctypes.c_int32"
else:
return parameter.ctypes_data_type or parameter.python_data_type
else:
if parameter.ctypes_data_type == "ctypes.c_char_p":
return parameter.ctypes_data_type
elif parameter.python_data_type == "datetime":
return "ctypes.POINTER(_lib_time.AbsoluteTime)"
else:
return f"ctypes.POINTER({parameter.ctypes_data_type})"

Expand Down
2 changes: 1 addition & 1 deletion src/codegen/utilities/interpreter_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"SetSyncPulseTimeWhen",
"SetTimingAttributeExTimestamp",
"SetTimingAttributeTimestamp",
"WaitForValidTimestamp",
"SetTrigAttributeTimestamp",
# Deprecated, not working
"GetAnalogPowerUpStates",
]
Expand Down

0 comments on commit 985ac55

Please sign in to comment.