Skip to content

Commit

Permalink
Cleanup: renamed SensorData* to Aggregator*.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisguse committed Nov 15, 2023
1 parent d47fa27 commit ce21fe3
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@
import de.dennisguse.opentracks.io.file.TrackFileFormat;
import de.dennisguse.opentracks.io.file.exporter.TrackExporter;
import de.dennisguse.opentracks.sensors.AltitudeSumManager;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataCyclingCadence;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataCyclingDistanceSpeed;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataCyclingPower;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataHeartRate;
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingDistanceSpeed;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingPower;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataSet;
import de.dennisguse.opentracks.services.TrackRecordingService;
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
Expand All @@ -71,7 +72,7 @@
/**
* Export a track to {@link TrackFileFormat} and verify that the import is identical.
* <p>
* Note: those tests are affected by {@link de.dennisguse.opentracks.sensors.sensorData.SensorData}.isRecent().
* Note: those tests are affected by {@link Aggregator}.isRecent().
* If the test device is too slow (like in a CI) these are likely to fail as the sensor data will be omitted from actual.
*/
@RunWith(AndroidJUnit4.class)
Expand Down Expand Up @@ -549,22 +550,22 @@ private void mockBLESensorData(TrackPointCreator trackPointCreator, Float speed,

SensorDataSet sensorDataSet = new SensorDataSet();

sensorDataSet.cyclingPower = Mockito.mock(SensorDataCyclingPower.class);
sensorDataSet.cyclingPower = Mockito.mock(AggregatorCyclingPower.class);
Mockito.when( sensorDataSet.cyclingPower.hasValue()).thenReturn(true);
Mockito.when(sensorDataSet.cyclingPower.getValue()).thenReturn(Power.of(power));

sensorDataSet.heartRate = Mockito.mock(SensorDataHeartRate.class);
sensorDataSet.heartRate = Mockito.mock(AggregatorHeartRate.class);
Mockito.when(sensorDataSet.heartRate.getValue()).thenReturn(HeartRate.of(heartRate));

SensorDataCyclingCadence cyclingCadence = Mockito.mock(SensorDataCyclingCadence.class);
AggregatorCyclingCadence cyclingCadence = Mockito.mock(AggregatorCyclingCadence.class);
Mockito.when(cyclingCadence.hasValue()).thenReturn(true);
Mockito.when(cyclingCadence.getValue()).thenReturn(Cadence.of(cadence));
sensorDataSet.cyclingCadence = cyclingCadence;

if (distance != null && speed != null) {
SensorDataCyclingDistanceSpeed distanceSpeed = Mockito.mock(SensorDataCyclingDistanceSpeed.class);
AggregatorCyclingDistanceSpeed distanceSpeed = Mockito.mock(AggregatorCyclingDistanceSpeed.class);
Mockito.when(distanceSpeed.hasValue()).thenReturn(true);
Mockito.when(distanceSpeed.getValue()).thenReturn(new SensorDataCyclingDistanceSpeed.Data(null, distance, Speed.of(speed)));
Mockito.when(distanceSpeed.getValue()).thenReturn(new AggregatorCyclingDistanceSpeed.Data(null, distance, Speed.of(speed)));
sensorDataSet.cyclingDistanceSpeed = distanceSpeed;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SensorDataCyclingTest {

@Test
public void compute_cadence_1() {
SensorDataCyclingCadence current = new SensorDataCyclingCadence("", "");
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");

// when
current.add(new Raw<>(new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
Expand All @@ -32,7 +32,7 @@ public void compute_cadence_1() {

@Test
public void compute_cadence_2() {
SensorDataCyclingCadence current = new SensorDataCyclingCadence("", "");
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");

// when
current.add(new Raw<>(new BluetoothHandlerCyclingCadence.CrankData(1, 6184)));
Expand All @@ -44,7 +44,7 @@ public void compute_cadence_2() {

@Test
public void compute_cadence_sameCount() {
SensorDataCyclingCadence current = new SensorDataCyclingCadence("", "");
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");

// when
current.add(new Raw<>(new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
Expand All @@ -57,7 +57,7 @@ public void compute_cadence_sameCount() {

@Test
public void compute_cadence_sameTime() {
SensorDataCyclingCadence current = new SensorDataCyclingCadence("", "");
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");

// when
current.add(new Raw<>(new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
Expand All @@ -69,7 +69,7 @@ public void compute_cadence_sameTime() {

@Test
public void compute_cadence_rollOverTime() {
SensorDataCyclingCadence current = new SensorDataCyclingCadence("", "");
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");

// when
current.add(new Raw<>(new BluetoothHandlerCyclingCadence.CrankData(1, UintUtils.UINT16_MAX - 1024)));
Expand All @@ -82,7 +82,7 @@ public void compute_cadence_rollOverTime() {
@Test
@Deprecated
public void compute_cadence_rollOverCount() {
SensorDataCyclingCadence current = new SensorDataCyclingCadence("", "");
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");

// when
current.add(new Raw<>(new BluetoothHandlerCyclingCadence.CrankData(UintUtils.UINT32_MAX - 1, 1024)));
Expand All @@ -96,7 +96,7 @@ public void compute_cadence_rollOverCount() {

@Test
public void compute_speed() {
SensorDataCyclingDistanceSpeed current = new SensorDataCyclingDistanceSpeed("", "");
AggregatorCyclingDistanceSpeed current = new AggregatorCyclingDistanceSpeed("", "");
current.setWheelCircumference(Distance.ofMM(2150));

// when
Expand All @@ -111,7 +111,7 @@ public void compute_speed() {
@Test
@Deprecated
public void compute_speed_rollOverCount() {
SensorDataCyclingDistanceSpeed current = new SensorDataCyclingDistanceSpeed("", "");
AggregatorCyclingDistanceSpeed current = new AggregatorCyclingDistanceSpeed("", "");
current.setWheelCircumference(Distance.ofMM(2000));

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
import de.dennisguse.opentracks.sensors.AltitudeSumManager;
import de.dennisguse.opentracks.sensors.BluetoothHandlerRunningSpeedAndCadence;
import de.dennisguse.opentracks.sensors.SensorManager;
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.sensors.sensorData.SensorDataHeartRate;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataRunning;
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
import de.dennisguse.opentracks.settings.PreferencesUtils;
import de.dennisguse.opentracks.stats.TrackStatistics;
Expand Down Expand Up @@ -255,7 +255,7 @@ public void testRecording_blesensor_only_no_distance() {
Track.Id trackId = service.startNewTrack();
trackPointCreator.getSensorManager().setAltitudeSumManager(altitudeSumManager);
SensorManager sensorManager = trackPointCreator.getSensorManager();
sensorManager.sensorDataSet.add(new SensorDataHeartRate("", ""));
sensorManager.sensorDataSet.add(new AggregatorHeartRate("", ""));
// when
String sensor1 = "2020-02-02T02:02:03Z";
trackPointCreator.setClock(sensor1);
Expand Down Expand Up @@ -592,7 +592,7 @@ public void testRecording_gpsAndSensor_gpsIdleMoving_sensorMoving() {
Track.Id trackId = service.startNewTrack();
trackPointCreator.getSensorManager().setAltitudeSumManager(altitudeSumManager);
SensorManager sensorManager = trackPointCreator.getSensorManager();
sensorManager.sensorDataSet.add(new SensorDataRunning("", ""));
sensorManager.sensorDataSet.add(new AggregatorRunning("", ""));

// when
String sensor1 = "2020-02-02T02:02:03Z";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.UUID;

import de.dennisguse.opentracks.data.models.AtmosphericPressure;
import de.dennisguse.opentracks.sensors.sensorData.SensorData;
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;

public class BluetoothHandlerBarometricPressure implements SensorHandlerInterface {
Expand All @@ -22,7 +22,7 @@ public List<ServiceMeasurementUUID> getServices() {
}

@Override
public SensorData<?, ?> createEmptySensorData(String address) {
public Aggregator<?, ?> createEmptySensorData(String address) {
return null; //TODO
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import java.util.List;

import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingCadence;
import de.dennisguse.opentracks.sensors.sensorData.Raw;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataCyclingCadence;
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;

public class BluetoothHandlerCyclingCadence implements SensorHandlerInterface {
Expand All @@ -24,8 +24,8 @@ public List<ServiceMeasurementUUID> getServices() {
}

@Override
public SensorDataCyclingCadence createEmptySensorData(String address) {
return new SensorDataCyclingCadence(address);
public AggregatorCyclingCadence createEmptySensorData(String address) {
return new AggregatorCyclingCadence(address);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import java.util.List;
import java.util.UUID;

import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingDistanceSpeed;
import de.dennisguse.opentracks.sensors.sensorData.Raw;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataCyclingDistanceSpeed;
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;

public class BluetoothHandlerCyclingDistanceSpeed implements SensorHandlerInterface {
Expand All @@ -26,8 +26,8 @@ public List<ServiceMeasurementUUID> getServices() {
}

@Override
public SensorDataCyclingDistanceSpeed createEmptySensorData(String address) {
return new SensorDataCyclingDistanceSpeed(address);
public AggregatorCyclingDistanceSpeed createEmptySensorData(String address) {
return new AggregatorCyclingDistanceSpeed(address);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import java.util.UUID;

import de.dennisguse.opentracks.data.models.Power;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorCyclingPower;
import de.dennisguse.opentracks.sensors.sensorData.Raw;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataCyclingPower;
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;

public class BluetoothHandlerManagerCyclingPower implements SensorHandlerInterface {
Expand All @@ -26,8 +26,8 @@ public List<ServiceMeasurementUUID> getServices() {
}

@Override
public SensorDataCyclingPower createEmptySensorData(String address) {
return new SensorDataCyclingPower(address);
public AggregatorCyclingPower createEmptySensorData(String address) {
return new AggregatorCyclingPower(address);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import java.util.UUID;

import de.dennisguse.opentracks.data.models.HeartRate;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorHeartRate;
import de.dennisguse.opentracks.sensors.sensorData.Raw;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataHeartRate;
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;

public class BluetoothHandlerManagerHeartRate implements SensorHandlerInterface {
Expand All @@ -36,8 +36,8 @@ public List<ServiceMeasurementUUID> getServices() {
}

@Override
public SensorDataHeartRate createEmptySensorData(String address) {
return new SensorDataHeartRate(address);
public AggregatorHeartRate createEmptySensorData(String address) {
return new AggregatorHeartRate(address);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import de.dennisguse.opentracks.data.models.Cadence;
import de.dennisguse.opentracks.data.models.Distance;
import de.dennisguse.opentracks.data.models.Speed;
import de.dennisguse.opentracks.sensors.sensorData.AggregatorRunning;
import de.dennisguse.opentracks.sensors.sensorData.Raw;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataRunning;
import de.dennisguse.opentracks.sensors.sensorData.SensorHandlerInterface;

public class BluetoothHandlerRunningSpeedAndCadence implements SensorHandlerInterface {
Expand All @@ -29,8 +29,8 @@ public List<ServiceMeasurementUUID> getServices() {
}

@Override
public SensorDataRunning createEmptySensorData(String address) {
return new SensorDataRunning(address);
public AggregatorRunning createEmptySensorData(String address) {
return new AggregatorRunning(address);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import androidx.annotation.VisibleForTesting;

import de.dennisguse.opentracks.data.models.TrackPoint;
import de.dennisguse.opentracks.sensors.sensorData.Aggregator;
import de.dennisguse.opentracks.sensors.sensorData.Raw;
import de.dennisguse.opentracks.sensors.sensorData.SensorData;
import de.dennisguse.opentracks.sensors.sensorData.SensorDataSet;
import de.dennisguse.opentracks.services.handlers.GPSManager;
import de.dennisguse.opentracks.services.handlers.TrackPointCreator;
Expand All @@ -28,7 +28,7 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
private final SensorDataChangedObserver listener = new SensorDataChangedObserver() {

@Override
public void onConnect(SensorData<?, ?> sensorData) {
public void onConnect(Aggregator<?, ?> sensorData) {
sensorDataSet.add(sensorData);
observer.onChange(new SensorDataSet(sensorDataSet));
}
Expand All @@ -40,7 +40,7 @@ public void onChange(Raw<?> sensorData) {
}

@Override
public void onDisconnect(SensorData<?, ?> sensorData) {
public void onDisconnect(Aggregator<?, ?> sensorData) {
sensorDataSet.remove(sensorData);
observer.onChange(new SensorDataSet(sensorDataSet));
}
Expand Down Expand Up @@ -128,9 +128,9 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, @Null

public interface SensorDataChangedObserver {

void onConnect(SensorData<?, ?> sensorData);
void onConnect(Aggregator<?, ?> sensorData);
void onChange(Raw<?> sensorData);

void onDisconnect(SensorData<?, ?> sensorData);
void onDisconnect(Aggregator<?, ?> sensorData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import de.dennisguse.opentracks.sensors.BluetoothRemoteSensorManager;

public abstract class SensorData<Input extends Record, Output> {
public abstract class Aggregator<Input extends Record, Output> {

protected Raw<Input> previous;

Expand All @@ -15,11 +15,11 @@ public abstract class SensorData<Input extends Record, Output> {
private final String sensorAddress;
private final String sensorName;

SensorData(String sensorAddress) {
Aggregator(String sensorAddress) {
this(sensorAddress, null);
}

SensorData(String sensorAddress, String sensorName) {
Aggregator(String sensorAddress, String sensorName) {
this.sensorAddress = sensorAddress;
this.sensorName = sensorName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingCadence;
import de.dennisguse.opentracks.sensors.UintUtils;

public class SensorDataCyclingCadence extends SensorData<BluetoothHandlerCyclingCadence.CrankData, Cadence> {
public class AggregatorCyclingCadence extends Aggregator<BluetoothHandlerCyclingCadence.CrankData, Cadence> {

private final String TAG = SensorDataCyclingCadence.class.getSimpleName();
private final String TAG = AggregatorCyclingCadence.class.getSimpleName();

public SensorDataCyclingCadence(String sensorAddress) {
public AggregatorCyclingCadence(String sensorAddress) {
super(sensorAddress);
}

public SensorDataCyclingCadence(String sensorAddress, String sensorName) {
public AggregatorCyclingCadence(String sensorAddress, String sensorName) {
super(sensorAddress, sensorName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
import de.dennisguse.opentracks.sensors.BluetoothHandlerCyclingDistanceSpeed;
import de.dennisguse.opentracks.sensors.UintUtils;

public class SensorDataCyclingDistanceSpeed extends SensorData<BluetoothHandlerCyclingDistanceSpeed.WheelData, SensorDataCyclingDistanceSpeed.Data> {
public class AggregatorCyclingDistanceSpeed extends Aggregator<BluetoothHandlerCyclingDistanceSpeed.WheelData, AggregatorCyclingDistanceSpeed.Data> {

private final String TAG = SensorDataCyclingDistanceSpeed.class.getSimpleName();
private final String TAG = AggregatorCyclingDistanceSpeed.class.getSimpleName();

private Distance wheelCircumference;

public SensorDataCyclingDistanceSpeed(String sensorAddress) {
public AggregatorCyclingDistanceSpeed(String sensorAddress) {
super(sensorAddress);
}

public SensorDataCyclingDistanceSpeed(String sensorAddress, String sensorName) {
public AggregatorCyclingDistanceSpeed(String sensorAddress, String sensorName) {
super(sensorAddress, sensorName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import de.dennisguse.opentracks.data.models.Power;

public class SensorDataCyclingPower extends SensorData<Power, Power> {
public class AggregatorCyclingPower extends Aggregator<Power, Power> {

public SensorDataCyclingPower(String address) {
public AggregatorCyclingPower(String address) {
super(address);
}

public SensorDataCyclingPower(String name, String address) {
public AggregatorCyclingPower(String name, String address) {
super(name, address);
}

Expand Down
Loading

0 comments on commit ce21fe3

Please sign in to comment.