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

Autocoded function for invoking all connected input and output ports #3043

Open
Jmb5501 opened this issue Nov 22, 2024 · 2 comments
Open

Autocoded function for invoking all connected input and output ports #3043

Jmb5501 opened this issue Nov 22, 2024 · 2 comments

Comments

@Jmb5501
Copy link

Jmb5501 commented Nov 22, 2024

Affected Component All user-define components

Feature Description

It would be incredibly helpful for developers to have access to an autocoded function in each component's base class that invokes all connected input and output ports. I think the function could look like the following for output ports:

void ComponentBase::invokeAll<port>()
{
    // Loop through all connected output ports and invoke them
    for (unsigned int ii= 0; port < NUM_<port>_OUTPUT_PORTS; ii++)
    {
        if (true == this->isConnected_<port>_OutputPort(ii))
        {
            this-><port>_out(ii);
        }
    }
}

Rationale

This would streamline a developer's code and reduce the amount of copy-pasting of code templates that is needed with the current version of Fprime. This seems like a very simple thing that could be developed.

@thomas-bc
Copy link
Collaborator

thomas-bc commented Nov 22, 2024

Ports may need different arguments so I'm not sure how you would resolve that.

Could you elaborate on your use case?

You can always handcode that invokeAll() helper function and use it at will, configuring yourself which ports get invoked and what parameters to use.

@LeStarch
Copy link
Collaborator

I think this is meant for port arrays, where you might want to broadcast out to all connected ports. e.g.

broadcast_modeChange_out(Mode new_mode) {
    for ....
} 

It is an interesting idea. It does add more autocode, but reduces hand-written code in key circumstances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants