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

[Core]: Refactorization of control function address claiming and factory methods #463

Merged
merged 3 commits into from
May 19, 2024

Conversation

GwnDaan
Copy link
Member

@GwnDaan GwnDaan commented Apr 17, 2024

Describe your changes

With the goal in mind of getting rid of the singleton from the network manager, I removed a bit of dependencies of the control functions on the network manager. This should be another step closer to making it easy to flip the network manager around.

What changed:

  • Moved the factory functions to the network manager:
    • InternalControlFunction::create -> CANNetworkManager::create_internal_control_function
    • PartneredControlFunction::create -> CANNetworkManager::create_partnered_control_function
  • Removed the AddressClaimStateMachine class, and instead housed it directly into the InternalControlFunction class. They already had an 1:1 relation, so it basically was nothing more than an extension at this point.

How has this been tested?

Made sure that the unit tests still correctly ran without making functional changes. Only minor thing is the removal of the check that a control function is correctly removed when it's "destroyed". I think that's something to look at later and currently gave more of a headache than it was useful. So I removed that GTEST assert.

Furthermore, I ran the seeder and VT3 object pool examples, they both still work fine. For most of the examples I removed the set preferred address, since according to the standard they have no function specifically defined for the currently configured preferred address:

A CF claiming a preferred address in the range 0 to 127 and 248 to 253 shall perform the function defined for that preferred address and shall specify that function within its NAME.

@GwnDaan GwnDaan requested a review from ad3154 April 17, 2024 19:26
@GwnDaan GwnDaan self-assigned this Apr 17, 2024
@GwnDaan GwnDaan marked this pull request as ready for review April 17, 2024 19:26
@GwnDaan GwnDaan force-pushed the daan/move-cf-factory-functions branch 4 times, most recently from 46e33d2 to 9d8d16a Compare April 17, 2024 19:56
examples/seeder_example/seeder.cpp Outdated Show resolved Hide resolved
isobus/include/isobus/isobus/can_message.hpp Show resolved Hide resolved
isobus/src/can_internal_control_function.cpp Outdated Show resolved Hide resolved
isobus/src/can_network_manager.cpp Outdated Show resolved Hide resolved
@ad3154
Copy link
Member

ad3154 commented Apr 20, 2024

Looks pretty good, I think this will indeed help us move away from the singleton, which is great

GwnDaan added 3 commits May 4, 2024 17:09
…ns to the network manager

The new way of making control functions will be `CANNetworkManager::create_internal_control_function` and `CANNetworkManager::create_partnered_control_function` respectively. For de-activating a control function the function  `CANNetworkManager::deactivate_control_function` should now be used.
Other small improvements:
- removed unused include in seeder example
- added boundary check on the control function table
@GwnDaan GwnDaan force-pushed the daan/move-cf-factory-functions branch from 799f302 to 0d450f9 Compare May 4, 2024 15:09
Copy link

sonarqubecloud bot commented May 4, 2024

@GwnDaan GwnDaan merged commit 830fe91 into main May 19, 2024
10 checks passed
@GwnDaan GwnDaan deleted the daan/move-cf-factory-functions branch May 19, 2024 17:34
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.

2 participants