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

feat: add rate parameter to component interface #57

Merged
merged 10 commits into from
Oct 19, 2023
Merged

Conversation

domire8
Copy link
Member

@domire8 domire8 commented Oct 19, 2023

Description

This PR solves the issue by adding the rate parameter to the component interface while keeping backwards compatibility with the period parameter.

In order to manage that, the parameter overrides of the node have to be modified before construction. Otherwise, the two parameters couldn't be made read only. It's a little bit hacky because we have no option to log messages or to intercept exceptions in a meaningful way at that point but I think it can work out quite well.

I was also able to confirm the desired behavior with a simple test case.

Review guidelines

Estimated Time of Review: 10 minutes

Checklist before merging:

  • Confirm that the relevant changelog(s) are up-to-date in case of any user-facing changes
  • Update component descriptions

@domire8 domire8 requested a review from eeberhard October 19, 2023 10:13
@domire8 domire8 linked an issue Oct 19, 2023 that may be closed by this pull request
Copy link
Member

@eeberhard eeberhard left a comment

Choose a reason for hiding this comment

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

Looking good!

Copy link
Member

@eeberhard eeberhard left a comment

Choose a reason for hiding this comment

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

For the descriptions, I would prefer to remove the period parameter now rather than have both. Or, to make the transition a bit more gradual, use the internal property for period to hide it from public interfaces.

Copy link
Member

@eeberhard eeberhard left a comment

Choose a reason for hiding this comment

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

Last comment I think, then it's good to go

@@ -8,12 +8,20 @@
"registration": "modulo_components::Component",
"inherits": "",
"parameters": [
{
"display_name": "Rate",
"description": "The frequency in Hertz for all periodic callbacks (this parameter overrides the period parameter)",
Copy link
Member

Choose a reason for hiding this comment

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

actually one last nitpick: since the rate parameter is now the "public" one and period is "internal", it's a bit weird to have this in the public description.

Suggested change
"description": "The frequency in Hertz for all periodic callbacks (this parameter overrides the period parameter)",
"description": "The frequency in Hertz for all periodic callbacks",

"parameter_name": "rate",
"parameter_type": "int",
"default_value": "10"
},
{
"display_name": "Period",
"description": "The time interval in seconds for all periodic callbacks",
Copy link
Member

Choose a reason for hiding this comment

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

Instead, you can put the detailed description here for reference

Suggested change
"description": "The time interval in seconds for all periodic callbacks",
"description": "The time interval in seconds for all periodic callbacks. This parameter is deprecated and will be removed in the next major release. The rate parameter takes precedence and overrides the component period.",

Copy link
Member

@eeberhard eeberhard left a comment

Choose a reason for hiding this comment

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

🔥

@domire8 domire8 merged commit b8e61ce into develop Oct 19, 2023
4 checks passed
@domire8 domire8 deleted the feature/rate branch October 19, 2023 16:53
@github-actions github-actions bot locked and limited conversation to collaborators Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support rate or frequency for components
2 participants