EventManager API update and Button API update#74
Merged
Conversation
* Updated Event Manager API to work with std::vector<uint8_t> instead of std::string for better interoperability (fewer copies) with serialization library. * Fixed bug in EventManager subscriber callback which was only dequing one element of data each time it woke from notify, even though there could be multiple data elements in the queue. * Refactored tuple typedef and use into a struct for cleaner code. * Added dequeue mutex protection around dequeue insertion for publish
* Removed event manager and serialization from button component and class, in favor of simply calling a callback function * Updated button example to use the new callback API but to include event manager example for button subscription / data distribution example since many systems may have multiple comonents that are interested in button presses. Uses new event manager API as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Motivation and Context
Fixes a bug in the
EventManagerclass which I found when testing theButtonclass where if multiple events got published/queued before the subscriber could dequeue and process them, then the subscriber would always be one event off in time / would not receive the last event.Updates the
EventManagerclass to usestd::vector<uint8_t>for data for more direct interoperability with theserialization/alpacalibrary which can only serialize into vectors or similar containers (notstd::string). Since theEventManageris designed to be used with custom data types (structs and other containers), this seems like a logical choice. The example still shows an example of passing std::strings through events though in case people want to do that.Finally, updates the
Buttonimplementation and API to remove the dependency on theEventManagerandserializationcomponents since that seemed to be out of the scope of that class explicitly. Now theButtontakes a callback function that it calls with the associated event structure instead. To showcase the use of this with the event manager as it was originally intended (to be able to easily distribute events throughout the system) the event manager / serialization code was moved in to the button example.How has this been tested?
event_managerexamplebuttonexampleScreenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):
EventManager Example
Button Example
Types of changes
Checklist:
Software
.github/workflows/build.ymlfile to add my new test to the automated cloud build github action.