Skip to content

Add Active Dev to Timing Class #767

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

charitylxy
Copy link
Collaborator

@charitylxy charitylxy commented Jun 19, 2025

  • This contribution adheres to CONTRIBUTING.md.
  • I've updated CHANGELOG.md if applicable.
  • I've added tests applicable for this pull request

What does this Pull Request accomplish?

Why should this Pull Request be merged?

What testing has been done?

  1. Ran simple program to test some of the attributes:
  • ai_conv_rate attribute with device specified
...
    task.timing["cdaqChassisTesterMod6"].ai_conv_rate = 100
    print (task.timing["cdaqChassisTesterMod6"].ai_conv_rate)
...

# Result: ai_conv_rate gets printed
  • first_samp_timestamp_enable attribute with device specified
...
    dev = Device("nidaqmxMultithreadingTester1")
    print (task.timing[dev].first_samp_timestamp_enable)
...

# Result: Error -201118 displayed
  1. [Pending] Unit Test

@charitylxy charitylxy changed the title Users/charitylxy/ai conv rate ex Add Active Dev to Timing Class Jun 19, 2025
Copy link
Contributor

github-actions bot commented Jun 19, 2025

Test Results

    34 files  +    25      34 suites  +25   56m 30s ⏱️ + 53m 28s
 2 461 tests + 2 251   2 091 ✅ + 1 881    370 💤 +  370  0 ❌ ±0 
43 920 runs  +42 030  37 508 ✅ +35 618  6 412 💤 +6 412  0 ❌ ±0 

Results for commit 845faa9. ± Comparison against base commit 2a45bcc.

♻️ This comment has been updated with latest results.

@charitylxy
Copy link
Collaborator Author

charitylxy commented Jun 19, 2025

@bkeryan I'm not too sure how we should go about specifying _active_devs for unsupported methods. Do we want to allow specifying _active_devs only for ai_conv_rate, and the rest would error out if _active_devs is specified?

@zhindes
Copy link
Collaborator

zhindes commented Jun 19, 2025

@bkeryan I'm not too sure how we should go about specifying _active_devs for unsupported methods. Do we want to allow specifying _active_devs only for ai_conv_rate, and the rest would error out if _active_devs is specified?

Can you try that in LabVIEW with the Property Node - what does it do if you specify one with an attribute that doesn't support it?

Overall, it looks good :) Once we figure out the behavior here, let's add a couple unit tests. Add a simulated cDAQ module that supports this, and then validate whatever the error cases (or not error depending on what we decide) are.

@bkeryan
Copy link
Collaborator

bkeryan commented Jun 19, 2025

@bkeryan I'm not too sure how we should go about specifying _active_devs for unsupported methods. Do we want to allow specifying _active_devs only for ai_conv_rate, and the rest would error out if _active_devs is specified?

Look at NIDAQmx.h and see which timing property get/set/reset functions have an Ex version. Those are the ones that support active devices.

The timing properties that do not have an Ex version do not support active devices in the C API. The Python API should raise an exception rather than silently discard the active devices parameter. DAQmxErrorMStudioOperationDoesNotSupportDeviceContext is an appropriate error code, despite the fact that it has "MStudio" in the constant name: "Operation must be performed on the entire task. It cannot be performed only on specific devices in the task. Do not use the indexer, Item property in Visual Basic, or index operator in C++ to specify device names when performing this operation."

Note that you should still use the generic functions like DAQmxSetTimingAttributeEx, not the attribute-specific functions.

How do you know based on the metadata which properties have active devices? I think you probably need to update scrapigen to look at whether lvFilter includes "Advanced:Timing (Active Device)", and you may need to extend the grpc-device/nidaqmx-python metadata schema to describe this new capability. MSDaqDotNET has a more generic approach that involves looking at which lvFilter groups include any "active property", but I think hardcoding the lvFilter groups is sufficient for this bug fix.

Can you try that in LabVIEW with the Property Node - what does it do if you specify one with an attribute that doesn't support it?

Overall, it looks good :) Once we figure out the behavior here, let's add a couple unit tests. Add a simulated cDAQ module that supports this, and then validate whatever the error cases (or not error depending on what we decide) are.

Normally I am in favor of parity with the LabVIEW API, but the underlying interfaces used by the LabVIEW API allow passing active devices to properties that do not support active devices in the C API.

We ran into this when we updated the .NET API to call the C API, and ended up using a warning instead of an error in some cases. See Timing::ThrowIfHasContext and Timing::WarnIfHasContext in MSDaqDotNET.

@zhindes
Copy link
Collaborator

zhindes commented Jun 19, 2025

The timing properties that do not have an Ex version do not support active devices in the C API. The Python API should raise an exception rather than silently discard the active devices parameter. DAQmxErrorMStudioOperationDoesNotSupportDeviceContext is an appropriate error code, despite the fact that it has "MStudio" in the constant name:

"Operation must be performed on the entire task. It cannot be performed only on specific devices in the task. Do not use the indexer, Item property in Visual Basic, or index operator in C++ to specify device names when performing this operation."

...

Normally I am in favor of parity with the LabVIEW API, but the underlying interfaces used by the LabVIEW API allow passing active devices to properties that do not support active devices in the C API.

That all sounds good to me!

@charitylxy charitylxy marked this pull request as ready for review June 23, 2025 13:29
@charitylxy charitylxy requested a review from bkeryan June 24, 2025 02:14
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.

Still looking for tests!

@charitylxy
Copy link
Collaborator Author

charitylxy commented Jun 27, 2025

Still looking for tests!

@zhindes I'm trying to add a test for the timing boolean property, ai_conv_dig_fltr_enable is the only boolean property that allows active_devs. I've tried with multiple devices, but I kept getting "property not supported" error. Do you know what device supports ai_conv_dig_fltr_enable? Or is there anywhere in our codebase that specifies devices and their supported attributes?

@bkeryan
Copy link
Collaborator

bkeryan commented Jun 27, 2025

Still looking for tests!

@zhindes I'm trying to add a test for the timing boolean property, ai_conv_dig_fltr_enable is the only boolean property that allows active_devs. I've tried with multiple devices, but I kept getting "property not supported" error. Do you know what device supports ai_conv_dig_fltr_enable? Or is there anywhere in our codebase that specifies devices and their supported attributes?

Multiplexed X Series supports AIConvDigFltrEnable but not the active devs version.

Active devs timing was added to allow setting per-module convert rate on C Series modules, like the NI 9205. However, I don't think they support external convert clock, so there is no reason to support digital filtering of the convert clock.

Active devs for this specific property is the intersection of two corner cases, so I don't think you can test it.

Or is there anywhere in our codebase that specifies devices and their supported attributes?

raptor.dds, cseries.dds, tCDAQCartridgeAITimingExpert.attr, tAttributeQueryTest, etc.

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.

Cannot set "ai_conv_rate" on NI DAQ 9209 due to missing active device modifier for timing attributes
3 participants