DataMediaton for transferring data between a source and a consumer #262
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
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
DataMediationclass which can control when consumers accept values.DataMediationcan:The two major methods in
DataMediationare:The first method polls a
Supplierfor a value and passes it to aConsumer. The second method is similar however, it polls an Observable. When theDataMediationis idle it passes theidlevalue to theConsumer. Here's an example for mediating when the thrusters get updated: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.DataMediationsupplies an initial values to the devices using the standard method.