diff --git a/generated/nidaqmx/_base_interpreter.py b/generated/nidaqmx/_base_interpreter.py index 3cd86894..04858e17 100644 --- a/generated/nidaqmx/_base_interpreter.py +++ b/generated/nidaqmx/_base_interpreter.py @@ -147,6 +147,10 @@ def cfg_samp_clk_timing( samps_per_chan): raise NotImplementedError + @abc.abstractmethod + def cfg_time_start_trig(self, task, when, timescale): + raise NotImplementedError + @abc.abstractmethod def cfg_watchdog_ao_expir_states( self, task, channel_names, expir_state_array, output_type_array): diff --git a/generated/nidaqmx/_grpc_interpreter.py b/generated/nidaqmx/_grpc_interpreter.py index 1ef808a8..75ef29fe 100644 --- a/generated/nidaqmx/_grpc_interpreter.py +++ b/generated/nidaqmx/_grpc_interpreter.py @@ -17,6 +17,7 @@ from nidaqmx._stubs import nidaqmx_pb2_grpc as nidaqmx_grpc from nidaqmx._stubs import session_pb2 as session_grpc_types from nidaqmx.error_codes import DAQmxErrors +from nidaqmx._grpc_time import convert_time_to_timestamp _logger = logging.getLogger(__name__) @@ -378,6 +379,13 @@ def cfg_samp_clk_timing( active_edge_raw=active_edge, sample_mode_raw=sample_mode, samps_per_chan=samps_per_chan)) + def cfg_time_start_trig(self, task, when, timescale): + response = self._invoke( + self._client.CfgTimeStartTrig, + grpc_types.CfgTimeStartTrigRequest( + task=task, when=convert_time_to_timestamp(when), + timescale_raw=timescale)) + def cfg_watchdog_ao_expir_states( self, task, channel_names, expir_state_array, output_type_array): response = self._invoke( diff --git a/generated/nidaqmx/_library_interpreter.py b/generated/nidaqmx/_library_interpreter.py index aa4cc075..80b99fd6 100644 --- a/generated/nidaqmx/_library_interpreter.py +++ b/generated/nidaqmx/_library_interpreter.py @@ -12,6 +12,7 @@ from nidaqmx._lib import lib_importer, ctypes_byte_str, c_bool32, wrapped_ndpointer from nidaqmx.error_codes import DAQmxErrors, DAQmxWarnings from nidaqmx.errors import DaqError, DaqReadError, DaqWarning, DaqWriteError +from nidaqmx._lib_time import AbsoluteTime _logger = logging.getLogger(__name__) @@ -390,6 +391,19 @@ def cfg_samp_clk_timing( task, source, rate, active_edge, sample_mode, samps_per_chan) self.check_for_error(error_code) + def cfg_time_start_trig(self, task, when, timescale): + cfunc = lib_importer.windll.DAQmxCfgTimeStartTrig + if cfunc.argtypes is None: + with cfunc.arglock: + if cfunc.argtypes is None: + cfunc.argtypes = [ + lib_importer.task_handle, _lib_time.AbsoluteTime, + ctypes.c_int] + + error_code = cfunc( + task, AbsoluteTime.from_datetime(when), timescale) + self.check_for_error(error_code) + def cfg_watchdog_ao_expir_states( self, task, channel_names, expir_state_array, output_type_array): cfunc = lib_importer.windll.DAQmxCfgWatchdogAOExpirStates diff --git a/generated/nidaqmx/_task_modules/triggering/start_trigger.py b/generated/nidaqmx/_task_modules/triggering/start_trigger.py index e6ad6485..2af953e5 100644 --- a/generated/nidaqmx/_task_modules/triggering/start_trigger.py +++ b/generated/nidaqmx/_task_modules/triggering/start_trigger.py @@ -6,6 +6,7 @@ from nidaqmx.constants import ( Coupling, DigitalPatternCondition, DigitalWidthUnits, Edge, Slope, Timescale, TriggerType, WindowTriggerCondition1) +from datetime import datetime class StartTrigger: @@ -1037,6 +1038,19 @@ def cfg_dig_pattern_start_trig( self._interpreter.cfg_dig_pattern_start_trig( self._handle, trigger_source, trigger_pattern, trigger_when.value) + def cfg_time_start_trig(self, when, timescale=Timescale.USE_HOST): + """ + New Start Trigger + + Args: + when (datetime): Specifies when to trigger. + timescale (Optional[nidaqmx.constants.Timescale]): Specifies + the start trigger timestamp time scale. + """ + + self._interpreter.cfg_time_start_trig( + self._handle, when, timescale.value) + def disable_start_trig(self): """ Configures the task to start acquiring or generating samples diff --git a/src/codegen/metadata/functions.py b/src/codegen/metadata/functions.py index 6b4e4713..80f5d13a 100644 --- a/src/codegen/metadata/functions.py +++ b/src/codegen/metadata/functions.py @@ -1413,6 +1413,11 @@ }, 'CfgTimeStartTrig': { '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', @@ -1429,9 +1434,9 @@ 'direction': 'in', 'is_optional_in_python': False, 'name': 'when', - 'python_data_type': 'DateTime', + 'python_data_type': 'datetime', 'python_description': 'Specifies when to trigger.', - 'python_type_annotation': 'nidaqmx.constants.DateTime', + 'python_type_annotation': 'datetime', 'type': 'CVIAbsoluteTime' }, { @@ -1447,7 +1452,7 @@ 'type': 'int32' } ], - 'python_codegen_method': 'no', + 'python_class_name': 'StartTrigger', 'python_description': 'New Start Trigger', 'returns': 'int32' }, diff --git a/src/codegen/templates/_grpc_interpreter.py.mako b/src/codegen/templates/_grpc_interpreter.py.mako index fc940b04..ac0be5ed 100644 --- a/src/codegen/templates/_grpc_interpreter.py.mako +++ b/src/codegen/templates/_grpc_interpreter.py.mako @@ -33,6 +33,7 @@ from nidaqmx._stubs import nidaqmx_pb2 as grpc_types from nidaqmx._stubs import nidaqmx_pb2_grpc as nidaqmx_grpc from nidaqmx._stubs import session_pb2 as session_grpc_types from nidaqmx.error_codes import DAQmxErrors +from nidaqmx._grpc_time import convert_time_to_timestamp _logger = logging.getLogger(__name__) diff --git a/src/codegen/templates/_library_interpreter.py.mako b/src/codegen/templates/_library_interpreter.py.mako index d0ba335f..f5346554 100644 --- a/src/codegen/templates/_library_interpreter.py.mako +++ b/src/codegen/templates/_library_interpreter.py.mako @@ -28,6 +28,7 @@ from nidaqmx._base_interpreter import BaseEventHandler, BaseInterpreter from nidaqmx._lib import lib_importer, ctypes_byte_str, c_bool32, wrapped_ndpointer from nidaqmx.error_codes import DAQmxErrors, DAQmxWarnings from nidaqmx.errors import DaqError, DaqReadError, DaqWarning, DaqWriteError +from nidaqmx._lib_time import AbsoluteTime _logger = logging.getLogger(__name__) diff --git a/src/codegen/templates/_task_modules/triggering/start_trigger.py.mako b/src/codegen/templates/_task_modules/triggering/start_trigger.py.mako index 3288f13e..d073c45e 100644 --- a/src/codegen/templates/_task_modules/triggering/start_trigger.py.mako +++ b/src/codegen/templates/_task_modules/triggering/start_trigger.py.mako @@ -18,6 +18,7 @@ from nidaqmx.system.physical_channel import _PhysicalChannelAlternateConstructor from nidaqmx.constants import ( ${', '.join([c for c in enums_used]) | wrap(4, 4)}) %endif +from datetime import datetime class StartTrigger: diff --git a/src/codegen/templates/library_interpreter/default_c_function_call.py.mako b/src/codegen/templates/library_interpreter/default_c_function_call.py.mako index 5e05525e..d16c6be0 100644 --- a/src/codegen/templates/library_interpreter/default_c_function_call.py.mako +++ b/src/codegen/templates/library_interpreter/default_c_function_call.py.mako @@ -26,4 +26,4 @@ self.check_for_error(error_code) %else: self.check_for_error(error_code, ${samps_per_chan_param}.value) -%endif +%endif \ No newline at end of file diff --git a/src/codegen/utilities/function_helpers.py b/src/codegen/utilities/function_helpers.py index d3966955..30dbc00c 100644 --- a/src/codegen/utilities/function_helpers.py +++ b/src/codegen/utilities/function_helpers.py @@ -196,6 +196,8 @@ def to_param_argtype(parameter): else: if parameter.ctypes_data_type == "ctypes.TaskHandle": return "lib_importer.task_handle" + elif parameter.python_data_type == "datetime": + return "_lib_time.AbsoluteTime" elif parameter.direction == "in": # If is string input parameter, use separate custom # argtype to convert from unicode to bytes. diff --git a/src/codegen/utilities/interpreter_helpers.py b/src/codegen/utilities/interpreter_helpers.py index 42902d50..83b04aff 100644 --- a/src/codegen/utilities/interpreter_helpers.py +++ b/src/codegen/utilities/interpreter_helpers.py @@ -54,7 +54,6 @@ "SetRealTimeAttributeUInt32", "WaitForNextSampleClock", # Time triggers - "CfgTimeStartTrig", "GetArmStartTrigTimestampVal", "GetArmStartTrigTrigWhen", "GetFirstSampClkWhen", @@ -179,6 +178,8 @@ def generate_interpreter_function_call_args(function_metadata): and function_metadata.attribute_function_type == AttributeFunctionType.SET ): function_call_args.append(type_cast_attribute_set_function_parameter(param)) + elif param.type == "CVIAbsoluteTime": + function_call_args.append(f"AbsoluteTime.from_datetime({param.parameter_name})") else: function_call_args.append(param.parameter_name) @@ -354,6 +355,8 @@ def get_grpc_interpreter_call_params(func, params): has_read_array_parameter = True elif param.is_grpc_enum or (param.is_enum and not param.is_list): grpc_params.append(f"{name}_raw={param.parameter_name}") + elif param.type == "CVIAbsoluteTime": + grpc_params.append(f"{name}=convert_time_to_timestamp({param.parameter_name})") else: if is_write_bytes_param(param): grpc_params.append(f"{name}={param.parameter_name}.tobytes()")