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.
This PR is built upon #255 ; once that PR is finished this branch will be rebased (and also a better commits history will be made).
Reasoning:
Currently many of the io classes rely heavily on the
EventPublisher. Realistically these devices should be simpler-- they either consume a value from an observable or create a value and emit it as an observable. Using anEventPublisherin each io device means that all of our tests become more complicated as we need to make a mockEventPublisherfor each device test...Further, the
Rovclass is responsible for handling the start/stop state of io devices. As we make more groups of items which run together (ie sensors on a different timer than thrusters), the granularity becomes harder to achieve.Overview:
This PR intends to address these issues by creating a
TaskManagerclass which can control how consumers accept values, how suppliers emit values, and when these tasks are active.TaskManagercan:The two major methods in
TaskManagerare:The first method polls a
Supplierfor a value and passes it to aConsumerwhen theTaskManageris active. The second method is similar however, it polls an Observable and when theTaskManageris active, and when theTaskManageris stopped it passes theinitialvalue to theConsumer. These methods return an instance of theTaskManagerto enable method chaining which makes it pretty easy to instantiate and manage a device at the same time. Here's an example from theRovctor:Notes:
TestEventPublisher.javawhere emitting objects casted as an interface would not result in the child class being recorded on theTestEventPublisher. eg:emit((SpeedValue)new PortAftSpeedValue())would causevaluesOfType(PortAftSpeedValue.class)not to trigger. This is now fixed.CpuInformationno longer causes non raspberry pi machines to crashwriteZeromethods in io classes such asMotorandThrusterhave been removed.TaskManagersupplies an initial values to the devices using the standard method.