@Test public void testSumPower() { final double SIM_POWER = 123.0; final long EVENTS = 100; class PowerSumListener implements BroadcastListener<TaggedTelemetryEvent> { BigDecimal powersum = null; long events = 0; long sum = 0; public void receiveMessage(TaggedTelemetryEvent event) { if (!(event instanceof AveragePowerUpdate)) { return; } AveragePowerUpdate casted = (AveragePowerUpdate) event; powersum = casted.getAveragePower(); events = casted.getEvents(); sum = casted.getSumPower(); } } FilteredBroadcastMessenger<TaggedTelemetryEvent> bus = new FilteredBroadcastMessenger<TaggedTelemetryEvent>(); PowerOnlyDecoder<PowerOnlyDecodable> decoder = new PowerOnlyDecoder<>(bus); PowerSumListener listener = new PowerSumListener(); bus.addListener(TaggedTelemetryEvent.class, listener); decoder.update(new PowerOnlyDecodable() { public long getSumPowerDelta(PowerOnlyDecodable old) { return 0; } public long getEventCountDelta(CounterBasedDecodable old) { return 0; } public int getSumPower() { return 0; } public int getEventCount() { return 0; } public boolean isValidDelta(CounterBasedDecodable old) { return true; } public int getInstantPower() { return 0; } public long getTimestamp() { return 0; } }); decoder.update(new PowerOnlyDecodable() { public long getSumPowerDelta(PowerOnlyDecodable old) { return (long) (EVENTS * SIM_POWER); } public long getEventCountDelta(CounterBasedDecodable old) { return EVENTS; } public int getSumPower() { return 0; } public int getEventCount() { return 0; } public boolean isValidDelta(CounterBasedDecodable old) { return true; } public int getInstantPower() { return 0; } public long getTimestamp() { return 1; } }); assertEquals(listener.powersum.doubleValue(), SIM_POWER, 0.1); assertEquals(listener.events, EVENTS); assertEquals(listener.sum, (long) (EVENTS * SIM_POWER)); }
public void update(T next) { counterBasedDecoder.update(next); }
PowerOnlyDecoder implements Decoder<T> { public void update(T next) { counterBasedDecoder.update(next); } }
PowerOnlyDecoder implements Decoder<T> { public void update(T next) { counterBasedDecoder.update(next); } PowerOnlyDecoder(FilteredBroadcastMessenger<TaggedTelemetryEvent> updateHub); }
PowerOnlyDecoder implements Decoder<T> { public void update(T next) { counterBasedDecoder.update(next); } PowerOnlyDecoder(FilteredBroadcastMessenger<TaggedTelemetryEvent> updateHub); void reset(); void update(T next); void invalidate(); }
PowerOnlyDecoder implements Decoder<T> { public void update(T next) { counterBasedDecoder.update(next); } PowerOnlyDecoder(FilteredBroadcastMessenger<TaggedTelemetryEvent> updateHub); void reset(); void update(T next); void invalidate();  }