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

Refactoring RF channel state machine #177

Merged
merged 11 commits into from
Jan 31, 2022
Merged

Refactoring RF channel state machine #177

merged 11 commits into from
Jan 31, 2022

Conversation

ryan-summers
Copy link
Member

This PR refactors the RF channel state machine to use smlang.

This PR fixes #171

@ryan-summers
Copy link
Member Author

@jordens Hold off on review for this one. There's some improvements I'd like to implement first to simplify the design.

@ryan-summers
Copy link
Member Author

Hmm... After playing around with the code for a while, a significant refactor of the statemachine to utilize the guards and actions provided by smlang would require us to turn the RfChannel code on it's head, as the statemachine object would own the RfChannel object instead of the other way around (as is currently implemented).

@jordens
Copy link
Member

jordens commented Jan 28, 2022

Sounds like it may be worth it.
Maybe just impl StateMachineContext for RfChannel and the let the channel be the context?

@ryan-summers
Copy link
Member Author

Yeah, the main problem is that anything that was previously interacting with RfChannel now has to instead use the state_machine.context_mut().<code> instead, and I'm trying to figure out a nice way to avoid a ton of boilerplate.

@jordens
Copy link
Member

jordens commented Jan 28, 2022

Don't most callers go through this single code path anyway?

pub fn map<F, R>(&mut self, channel: Channel, func: F) -> Result<R, Error>

Copy link
Member

@jordens jordens left a comment

Choose a reason for hiding this comment

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

Looks very good to me. Let's merge now and handle remaining and arising issues later and through #178

@jordens jordens mentioned this pull request Jan 30, 2022
@ryan-summers
Copy link
Member Author

Bench testing and button mashing indicates the statemachine is operating as I would expect it to, and I do not see a discernible difference from previous behavior.

@ryan-summers ryan-summers merged commit fd5a9db into develop Jan 31, 2022
@ryan-summers ryan-summers deleted the feature/smlang branch January 31, 2022 10:42
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.

Refactor RfChannel StateMachine to use smlang
2 participants