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

Auto-generation support for daqmx streaming apis #1123

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Raghav-NI
Copy link

@Raghav-NI Raghav-NI commented Nov 19, 2024

What does this Pull Request accomplish?

This PR adds support for auto-generation of DAQmx streaming APIs.

Why should this Pull Request be merged?

  • Updated metadata for DAQmx functions to include additional information regarding streaming.
  • Added custom_proto.mako which defines protobuf message definitions to encapsulate different data types for DAQmx apis.
  • Modified logic in service_helpers.mako to auto-generate the streaming function bodies.
  • Modified service_helpers.py and common_helpers.py to generate the correct function structure for streaming apis.
  • Removed few unnecessary whitespaces from nifpga_service.cpp.

What testing has been done?

I am able to build the server code without any errors and able to use the client call and call the server with all the new streaming APIs.

generated/nifpga/nifpga_service.cpp Outdated Show resolved Hide resolved
generated/nifpga/nifpga_service.cpp Show resolved Hide resolved
source/codegen/service_helpers.py Outdated Show resolved Hide resolved
source/codegen/service_helpers.py Outdated Show resolved Hide resolved
source/codegen/templates/service_helpers.mako Show resolved Hide resolved
generated/nifpga/nifpga_service.cpp Outdated Show resolved Hide resolved
source/codegen/templates/service_helpers.mako Show resolved Hide resolved
source/codegen/templates/service_helpers.mako Show resolved Hide resolved
generated/nidaqmx/nidaqmx_service.cpp Show resolved Hide resolved
source/codegen/templates/service_helpers.mako Show resolved Hide resolved
source/codegen/templates/service_helpers.mako Show resolved Hide resolved
source/codegen/templates/service_helpers.mako Show resolved Hide resolved
source/codegen/templates/service_helpers.mako Outdated Show resolved Hide resolved
source/codegen/templates/service_helpers.mako Outdated Show resolved Hide resolved
source/codegen/templates/service_helpers.mako Show resolved Hide resolved
source/codegen/service_helpers.py Outdated Show resolved Hide resolved
source/codegen/service_helpers.py Outdated Show resolved Hide resolved
@Raghav-NI Raghav-NI changed the title Auto-generation changes for daqmx streaming apis Auto-generation support for daqmx streaming apis Nov 21, 2024
@Raghav-NI Raghav-NI marked this pull request as ready for review November 21, 2024 13:35
"""Get the list of output streaming parameter that needs to be defined."""
params = []
output_params = [p for p in parameters if common_helpers.is_output_parameter(p)]
for param in output_params:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: the list comprehension for selecting output_params is much cleaner than the loop for selecting streaming params. Using list comprehensions and helper methods makes a big difference:

def is_streaming_param_except_name(param, name_to_avoid_for_some_reason):
   # TODO why avoid name_to_avoid_for_some_reason?
   param.get("is_streaming_type", False) and param["name"] != name_to_avoid_for_some_reason

def get_output_streaming_params_to_define(parameters, streaming_param) -> List[dict]:
    """Get the list of output streaming parameter that needs to be defined."""
    output_params = [p for p in parameters if common_helpers.is_output_parameter(p)]
    return [p for p in output_params if is_streaming_param(p, streaming_param["name"])]

Actually, rewriting this, I realize I don't understand this code. We're avoiding one specific streaming parameter? Why is it not sufficient to look for is_output_parameter and is_streaming_type? Is streaming_param named correctly?

Copy link
Author

Choose a reason for hiding this comment

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

The reason behind avoiding that specific parameter is that it is the 'first' streaming parameter (eg: readarray), here we want to define other params which will be part of the response message for streaming apis. (eg: samp_per_chan_read).
And yes, it should be named as "first_streaming_param" to avoid confusion.

Modified to use list comprehensions and a helper method and renamed the parameter.

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.

4 participants