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

Add Time Trigger API Support for nidaqmx-python #471

Closed
wants to merge 1 commit into from

Conversation

charitylxy
Copy link
Collaborator

What does this Pull Request accomplish?

This PR adds Time Trigger API support for the following functions in nidaqmx-python:
DAQmxCfgTimeStartTrig

Remaining API yet to be added (due to functions missing in daqmxAPISharp.json):
DAQmxCfgAnlgMultiEdgeRefTrig
DAQmxCfgAnlgMultiEdgeStartTrig

Work Item: [DAQmx] Add Time Triggers API support for nidaqmx-python

Why should this Pull Request be merged?

It provide support for Time Trigger in python.

What testing has been done?

  • Ran nidaqmx-python code generator and validated the API was generated correctly
  • TODO: Regression tests for Time Trigger API to be added

@charitylxy charitylxy changed the title add CfgTimeStartTrig Add Time Trigger API Support for nidaqmx-python Jan 19, 2024
Copy link
Collaborator

@zhindes zhindes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the types aren't correct here. Some tests would have found a lot of issues, I think?

New Start Trigger

Args:
when (nidaqmx.constants.DateTime): Specifies when to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right type. I added AbsoluteTime in _lib_time.py that we should accept. We should also accept a datetime and a hightime from the std library.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interpreter interface should only use datetime/hightime, not the ctypes and gRPC specific types.

The interpreter implementations should be responsible for converting datetime/hightime to/from AbsoluteTime/google.protobuf.Timestamp.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, you're right. I'm just remembering everything we talked about when I added AbsoluteTime. AbsoluteTime is the type that the lib_interpreter uses to interface with the CAPI. google.protobuf.Timestamp for the grpc_interpreter. In addition, the top-level API should accept datetime or hightime as well. So just pass them down to the interpreter and each will convert to their respective types.

Copy link
Collaborator

with cfunc.arglock:
if cfunc.argtypes is None:
cfunc.argtypes = [
lib_importer.task_handle, DateTime, ctypes.c_int]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When should be an AbsoluteTime. AbsoluteTime is a ctypes type that should work correctly here, I think.

def cfg_time_start_trig(self, task, when, timescale):
response = self._invoke(
self._client.CfgTimeStartTrig,
grpc_types.CfgTimeStartTrigRequest(task=task, when=when, timescale_raw=timescale))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what type does the grpc lib use for when?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to this config function, several time trigger attributes are missing from start_trigger.py and similar classes. Are these on your radar?

https://www.ni.com/docs/en-US/bundle/ni-daqmx-properties/page/daqmxprop/daqmxtrigger.html

  • Start:Time:When
  • Start:Timestamp:Value
  • Reference:Timestamp:Value
  • More:Arm Start:Time:When
  • More:Arm Start:Timestamp:Value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opps, I might've missed the attributes out, will look into adding those.

@charitylxy charitylxy closed this Feb 8, 2024
@charitylxy charitylxy deleted the users/charitylxy/time-trig branch February 21, 2024 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants