Cleanup: moved Raw into Aggregator.

Preparation for refactoring.
This commit is contained in:
Dennis Guse
2026-01-27 17:59:08 +01:00
parent 0f2c5adf26
commit 18ff96733e
17 changed files with 77 additions and 98 deletions
@@ -75,7 +75,6 @@ import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingDistanceSpee
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingPower;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorTemperature;
import de.dennisguse.opentracks.sensors.sensorData.Raw;
import de.dennisguse.opentracks.services.TrackRecordingService;
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
@@ -664,12 +663,12 @@ public class ExportImportTest {
SensorManager sensorManager = trackPointCreator.getSensorManager();
AggregatorCyclingPower cyclingPower = new AggregatorCyclingPower("", "");
cyclingPower.add(new Raw<>(trackPointCreator.createNow(), new BluetoothHandlerCyclingPower.Data(Power.of(power), null)));
cyclingPower.add(trackPointCreator.getNow(), new BluetoothHandlerCyclingPower.Data(Power.of(power), null));
sensorManager.add(cyclingPower);
AggregatorHeartRate avgHeartRate = new AggregatorHeartRate("", "");
avgHeartRate.add(new Raw<>(trackPointCreator.createNow(), HeartRate.of(heartRate)));
avgHeartRate.add(trackPointCreator.getNow(), HeartRate.of(heartRate));
sensorManager.add(avgHeartRate);
AggregatorCyclingCadence cyclingCadence = new AggregatorCyclingCadence("", "") {
@@ -11,7 +11,7 @@ public class AggregatorBarometerTest {
private static void addSensorValue(AggregatorBarometer aggregatorBarometer, float[] values) {
for (float f : values) {
aggregatorBarometer.add(new Raw<>(Instant.MIN, AtmosphericPressure.ofHPA(f)));
aggregatorBarometer.add(Instant.MIN, AtmosphericPressure.ofHPA(f));
}
}
@@ -25,8 +25,8 @@ public class SensorDataCyclingTest {
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
// when
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 2048)));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 2048));
// then
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
@@ -37,8 +37,8 @@ public class SensorDataCyclingTest {
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
// when
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 6184)));
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 8016)));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 6184));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 8016));
// then
assertEquals(33.53, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
@@ -49,8 +49,8 @@ public class SensorDataCyclingTest {
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
// when
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 2048)));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 2048));
// then
assertEquals(Cadence.of(0), current.getAggregatedValue(Instant.MIN));
@@ -62,8 +62,8 @@ public class SensorDataCyclingTest {
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
// when
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 1024)));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, 1024));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 1024));
// then
assertFalse(current.hasReceivedData()); //TODO Cadence should be 0?
@@ -74,8 +74,8 @@ public class SensorDataCyclingTest {
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
// when
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, UintUtils.UINT16_MAX - 1024)));
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 0)));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(1, UintUtils.UINT16_MAX - 1024));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(2, 0));
// then
assertEquals(60, current.getAggregatedValue(Instant.MIN).getRPM(), 0.01);
@@ -87,8 +87,8 @@ public class SensorDataCyclingTest {
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
// when
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(UintUtils.UINT32_MAX - 1, 1024)));
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(0, 2048)));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(UintUtils.UINT32_MAX - 1, 1024));
current.add(Instant.MIN, new BluetoothHandlerCyclingCadence.CrankData(0, 2048));
// then
// TODO See #953
@@ -102,8 +102,8 @@ public class SensorDataCyclingTest {
current.setWheelCircumference(Distance.ofMM(2150));
// when
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(1, 6184)));
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(2, 8016)));
current.add(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(1, 6184));
current.add(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(2, 8016));
// then
assertEquals(2.15, current.getAggregatedValue(Instant.MIN).distance().toM(), 0.01);
@@ -117,8 +117,8 @@ public class SensorDataCyclingTest {
current.setWheelCircumference(Distance.ofMM(2000));
// when
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(UintUtils.UINT32_MAX - 1, 1024)));
current.add(new Raw<>(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(0, 2048)));
current.add(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(UintUtils.UINT32_MAX - 1, 1024));
current.add(Instant.MIN, new BluetoothHandlerCyclingDistanceSpeed.WheelData(0, 2048));
// then
@@ -49,7 +49,6 @@ import de.dennisguse.opentracks.sensors.SensorManager;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorBarometer;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorRunning;
import de.dennisguse.opentracks.sensors.sensorData.Raw;
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
import de.dennisguse.opentracks.settings.PreferencesUtils;
@@ -345,11 +344,11 @@ public class TrackRecordingServiceRecordingTest {
trackPointCreator.setClock(sensor1);
//Should be ignored
sensorManager.onChange(new Raw<HeartRate>(sensor1, HeartRate.of(5)));
sensorManager.onChange(HeartRate.of(5));
String sensor3 = "2020-02-02T02:02:13Z";
trackPointCreator.setClock(sensor3);
sensorManager.onChange(new Raw<HeartRate>(sensor3, HeartRate.of(7)));
sensorManager.onChange(HeartRate.of(7));
String stopTime = "2020-02-02T02:02:15Z";
trackPointCreator.setClock(stopTime);
@@ -817,12 +816,12 @@ public class TrackRecordingServiceRecordingTest {
String sensor1 = "2020-02-02T02:02:03Z";
trackPointCreator.setClock(sensor1);
//Should be ignored
sensorManager.onChange(new Raw<BluetoothHandlerRunningSpeedAndCadence.Data>(sensor1, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(1), Distance.ZERO)));
sensorManager.onChange(new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(1), Distance.ZERO));
// when
String sensor2 = "2020-02-02T02:02:04Z";
trackPointCreator.setClock(sensor2);
sensorManager.onChange(new Raw<BluetoothHandlerRunningSpeedAndCadence.Data>(sensor2, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(2), Distance.of(2))));
sensorManager.onChange(new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(2), Distance.of(2)));
// when
String gps1 = "2020-02-02T02:02:05Z";
@@ -831,13 +830,13 @@ public class TrackRecordingServiceRecordingTest {
// when
String sensor3 = "2020-02-02T02:02:06Z";
trackPointCreator.setClock(sensor3);
sensorManager.onChange(new Raw<BluetoothHandlerRunningSpeedAndCadence.Data>(sensor3, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(3), Distance.of(12))));
sensorManager.onChange(new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(3), Distance.of(12)));
// when
String sensor4 = "2020-02-02T02:02:07Z";
trackPointCreator.setClock(sensor4);
//Should be ignored
sensorManager.onChange(new Raw<BluetoothHandlerRunningSpeedAndCadence.Data>(sensor4, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(4), Distance.of(14))));
sensorManager.onChange(new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(4), Distance.of(14)));
// when
String gps2 = "2020-02-02T02:02:08Z";
@@ -847,7 +846,7 @@ public class TrackRecordingServiceRecordingTest {
String sensor5 = "2020-02-02T02:02:10Z";
trackPointCreator.setClock(sensor5);
//Should be ignored
sensorManager.onChange(new Raw<BluetoothHandlerRunningSpeedAndCadence.Data>(sensor5, new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(5), Distance.of(16))));
sensorManager.onChange(new BluetoothHandlerRunningSpeedAndCadence.Data(Speed.of(5), Cadence.of(5), Distance.of(16)));
// when
String gps3 = "2020-02-02T02:02:12Z";