@Test public void matchesKnownGood() { FilteredBroadcastMessenger<TaggedTelemetryEvent> bus = new FilteredBroadcastMessenger<TaggedTelemetryEvent>(); class PowerListener implements BroadcastListener<TaggedTelemetryEvent> { BigDecimal power; public void receiveMessage(TaggedTelemetryEvent telemetryEvent) { if (telemetryEvent instanceof TorquePowerUpdate) { TorquePowerUpdate up = (TorquePowerUpdate) telemetryEvent; power = up.getPower(); } } }; PowerListener powerListener = new PowerListener(); bus.addListener(TaggedTelemetryEvent.class, powerListener); BigDecimal speed = new BigDecimal(10.0); BigDecimal period = WHEEL_CIRCUM.multiply(new BigDecimal(Math.pow(10, -3))).divide(speed, 20, BigDecimal.ROUND_HALF_UP); int power = 200; int rotationsDelta = 10; int eventsDelta = 1; final byte[] data1 = new byte[8]; final byte[] data2 = new byte[8]; new TorqueData.TorqueDataPayload() .encode(data1); new TorqueData.TorqueDataPayload() .setEvents(eventsDelta) .updateTorqueSumFromPower(power, period) .setRotations(rotationsDelta) .encode(data2); TorqueData p1 = new TorqueData(data1); TorqueData p2 = new TorqueData(data2); TorqueDecoder<TorqueDecodable> dec = new TorqueDecoder<>(bus); dec.update(p1); dec.update(p2); assertEquals(new BigDecimal(power).setScale(0, RoundingMode.HALF_UP), powerListener.power.setScale(0, RoundingMode.HALF_UP)); }
public void update(T next) { counterBasedDecoder.update(next); }
TorqueDecoder implements Decoder<T> { public void update(T next) { counterBasedDecoder.update(next); } }
TorqueDecoder implements Decoder<T> { public void update(T next) { counterBasedDecoder.update(next); } TorqueDecoder(FilteredBroadcastMessenger<TaggedTelemetryEvent> updateHub); }
TorqueDecoder implements Decoder<T> { public void update(T next) { counterBasedDecoder.update(next); } TorqueDecoder(FilteredBroadcastMessenger<TaggedTelemetryEvent> updateHub); void reset(); void update(T next); void invalidate(); }
TorqueDecoder implements Decoder<T> { public void update(T next) { counterBasedDecoder.update(next); } TorqueDecoder(FilteredBroadcastMessenger<TaggedTelemetryEvent> updateHub); void reset(); void update(T next); void invalidate();  }