mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Cleanup: renamed SensorData* to Aggregator*.
This commit is contained in:
+11
-10
@@ -59,10 +59,11 @@ import de.dennisguse.opentracks.data.models.TrackPoint;
|
||||
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;
|
||||
@@ -71,7 +72,7 @@ import de.dennisguse.opentracks.stats.TrackStatistics;
|
||||
/**
|
||||
* 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)
|
||||
@@ -549,22 +550,22 @@ public class ExportImportTest {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -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)));
|
||||
@@ -32,7 +32,7 @@ public class SensorDataCyclingTest {
|
||||
|
||||
@Test
|
||||
public void compute_cadence_2() {
|
||||
SensorDataCyclingCadence current = new SensorDataCyclingCadence("", "");
|
||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||
|
||||
// when
|
||||
current.add(new Raw<>(new BluetoothHandlerCyclingCadence.CrankData(1, 6184)));
|
||||
@@ -44,7 +44,7 @@ public class SensorDataCyclingTest {
|
||||
|
||||
@Test
|
||||
public void compute_cadence_sameCount() {
|
||||
SensorDataCyclingCadence current = new SensorDataCyclingCadence("", "");
|
||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||
|
||||
// when
|
||||
current.add(new Raw<>(new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
|
||||
@@ -57,7 +57,7 @@ public class SensorDataCyclingTest {
|
||||
|
||||
@Test
|
||||
public void compute_cadence_sameTime() {
|
||||
SensorDataCyclingCadence current = new SensorDataCyclingCadence("", "");
|
||||
AggregatorCyclingCadence current = new AggregatorCyclingCadence("", "");
|
||||
|
||||
// when
|
||||
current.add(new Raw<>(new BluetoothHandlerCyclingCadence.CrankData(1, 1024)));
|
||||
@@ -69,7 +69,7 @@ public class SensorDataCyclingTest {
|
||||
|
||||
@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)));
|
||||
@@ -82,7 +82,7 @@ public class SensorDataCyclingTest {
|
||||
@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)));
|
||||
@@ -96,7 +96,7 @@ public class SensorDataCyclingTest {
|
||||
|
||||
@Test
|
||||
public void compute_speed() {
|
||||
SensorDataCyclingDistanceSpeed current = new SensorDataCyclingDistanceSpeed("", "");
|
||||
AggregatorCyclingDistanceSpeed current = new AggregatorCyclingDistanceSpeed("", "");
|
||||
current.setWheelCircumference(Distance.ofMM(2150));
|
||||
|
||||
// when
|
||||
@@ -111,7 +111,7 @@ public class SensorDataCyclingTest {
|
||||
@Test
|
||||
@Deprecated
|
||||
public void compute_speed_rollOverCount() {
|
||||
SensorDataCyclingDistanceSpeed current = new SensorDataCyclingDistanceSpeed("", "");
|
||||
AggregatorCyclingDistanceSpeed current = new AggregatorCyclingDistanceSpeed("", "");
|
||||
current.setWheelCircumference(Distance.ofMM(2000));
|
||||
|
||||
// when
|
||||
|
||||
+4
-4
@@ -37,9 +37,9 @@ import de.dennisguse.opentracks.io.file.importer.TrackPointAssert;
|
||||
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;
|
||||
@@ -255,7 +255,7 @@ public class TrackRecordingServiceRecordingTest {
|
||||
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);
|
||||
@@ -592,7 +592,7 @@ public class TrackRecordingServiceRecordingTest {
|
||||
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";
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ import java.util.List;
|
||||
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 {
|
||||
@@ -22,7 +22,7 @@ public class BluetoothHandlerBarometricPressure implements SensorHandlerInterfac
|
||||
}
|
||||
|
||||
@Override
|
||||
public SensorData<?, ?> createEmptySensorData(String address) {
|
||||
public Aggregator<?, ?> createEmptySensorData(String address) {
|
||||
return null; //TODO
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import android.util.Pair;
|
||||
|
||||
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 {
|
||||
@@ -24,8 +24,8 @@ public class BluetoothHandlerCyclingCadence implements SensorHandlerInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SensorDataCyclingCadence createEmptySensorData(String address) {
|
||||
return new SensorDataCyclingCadence(address);
|
||||
public AggregatorCyclingCadence createEmptySensorData(String address) {
|
||||
return new AggregatorCyclingCadence(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -9,8 +9,8 @@ import androidx.annotation.VisibleForTesting;
|
||||
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 {
|
||||
@@ -26,8 +26,8 @@ public class BluetoothHandlerCyclingDistanceSpeed implements SensorHandlerInterf
|
||||
}
|
||||
|
||||
@Override
|
||||
public SensorDataCyclingDistanceSpeed createEmptySensorData(String address) {
|
||||
return new SensorDataCyclingDistanceSpeed(address);
|
||||
public AggregatorCyclingDistanceSpeed createEmptySensorData(String address) {
|
||||
return new AggregatorCyclingDistanceSpeed(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -9,8 +9,8 @@ import java.util.List;
|
||||
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 {
|
||||
@@ -26,8 +26,8 @@ public class BluetoothHandlerManagerCyclingPower implements SensorHandlerInterfa
|
||||
}
|
||||
|
||||
@Override
|
||||
public SensorDataCyclingPower createEmptySensorData(String address) {
|
||||
return new SensorDataCyclingPower(address);
|
||||
public AggregatorCyclingPower createEmptySensorData(String address) {
|
||||
return new AggregatorCyclingPower(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -9,8 +9,8 @@ import java.util.List;
|
||||
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 {
|
||||
@@ -36,8 +36,8 @@ public class BluetoothHandlerManagerHeartRate implements SensorHandlerInterface
|
||||
}
|
||||
|
||||
@Override
|
||||
public SensorDataHeartRate createEmptySensorData(String address) {
|
||||
return new SensorDataHeartRate(address);
|
||||
public AggregatorHeartRate createEmptySensorData(String address) {
|
||||
return new AggregatorHeartRate(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -11,8 +11,8 @@ import java.util.UUID;
|
||||
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 {
|
||||
@@ -29,8 +29,8 @@ public class BluetoothHandlerRunningSpeedAndCadence implements SensorHandlerInte
|
||||
}
|
||||
|
||||
@Override
|
||||
public SensorDataRunning createEmptySensorData(String address) {
|
||||
return new SensorDataRunning(address);
|
||||
public AggregatorRunning createEmptySensorData(String address) {
|
||||
return new AggregatorRunning(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,8 +9,8 @@ import androidx.annotation.Nullable;
|
||||
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;
|
||||
@@ -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));
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect(SensorData<?, ?> sensorData) {
|
||||
public void onDisconnect(Aggregator<?, ?> sensorData) {
|
||||
sensorDataSet.remove(sensorData);
|
||||
observer.onChange(new SensorDataSet(sensorDataSet));
|
||||
}
|
||||
@@ -128,9 +128,9 @@ public class SensorManager implements SharedPreferences.OnSharedPreferenceChange
|
||||
|
||||
public interface SensorDataChangedObserver {
|
||||
|
||||
void onConnect(SensorData<?, ?> sensorData);
|
||||
void onConnect(Aggregator<?, ?> sensorData);
|
||||
void onChange(Raw<?> sensorData);
|
||||
|
||||
void onDisconnect(SensorData<?, ?> sensorData);
|
||||
void onDisconnect(Aggregator<?, ?> sensorData);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ import java.time.Instant;
|
||||
|
||||
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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
+4
-4
@@ -10,15 +10,15 @@ import de.dennisguse.opentracks.data.models.Cadence;
|
||||
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);
|
||||
}
|
||||
|
||||
+4
-4
@@ -11,17 +11,17 @@ import de.dennisguse.opentracks.data.models.Speed;
|
||||
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);
|
||||
}
|
||||
|
||||
+3
-3
@@ -4,13 +4,13 @@ import androidx.annotation.NonNull;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
+3
-3
@@ -4,13 +4,13 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import de.dennisguse.opentracks.data.models.HeartRate;
|
||||
|
||||
public class SensorDataHeartRate extends SensorData<HeartRate, HeartRate> {
|
||||
public class AggregatorHeartRate extends Aggregator<HeartRate, HeartRate> {
|
||||
|
||||
public SensorDataHeartRate(String address) {
|
||||
public AggregatorHeartRate(String address) {
|
||||
super(address);
|
||||
}
|
||||
|
||||
public SensorDataHeartRate(String name, String address) {
|
||||
public AggregatorHeartRate(String name, String address) {
|
||||
super(name, address);
|
||||
}
|
||||
|
||||
+4
-4
@@ -10,15 +10,15 @@ import de.dennisguse.opentracks.sensors.BluetoothHandlerRunningSpeedAndCadence;
|
||||
/**
|
||||
* Provides cadence in rpm and speed in milliseconds from Bluetooth LE Running Speed and Cadence sensors.
|
||||
*/
|
||||
public final class SensorDataRunning extends SensorData<BluetoothHandlerRunningSpeedAndCadence.Data, SensorDataRunning.Data> {
|
||||
public final class AggregatorRunning extends Aggregator<BluetoothHandlerRunningSpeedAndCadence.Data, AggregatorRunning.Data> {
|
||||
|
||||
private static final String TAG = SensorDataRunning.class.getSimpleName();
|
||||
private static final String TAG = AggregatorRunning.class.getSimpleName();
|
||||
|
||||
public SensorDataRunning(String sensorAddress) {
|
||||
public AggregatorRunning(String sensorAddress) {
|
||||
super(sensorAddress);
|
||||
}
|
||||
|
||||
public SensorDataRunning(String sensorAddress, String sensorName) {
|
||||
public AggregatorRunning(String sensorAddress, String sensorName) {
|
||||
super(sensorAddress, sensorName);
|
||||
}
|
||||
|
||||
@@ -22,19 +22,19 @@ public final class SensorDataSet {
|
||||
private static final String TAG = SensorDataSet.class.getSimpleName();
|
||||
|
||||
@VisibleForTesting
|
||||
public SensorDataHeartRate heartRate;
|
||||
public AggregatorHeartRate heartRate;
|
||||
|
||||
@VisibleForTesting
|
||||
public SensorDataCyclingCadence cyclingCadence;
|
||||
public AggregatorCyclingCadence cyclingCadence;
|
||||
|
||||
@VisibleForTesting
|
||||
public SensorDataCyclingDistanceSpeed cyclingDistanceSpeed;
|
||||
public AggregatorCyclingDistanceSpeed cyclingDistanceSpeed;
|
||||
|
||||
@VisibleForTesting
|
||||
public SensorDataCyclingPower cyclingPower;
|
||||
public AggregatorCyclingPower cyclingPower;
|
||||
|
||||
@VisibleForTesting
|
||||
public SensorDataRunning runningDistanceSpeedCadence;
|
||||
public AggregatorRunning runningDistanceSpeedCadence;
|
||||
|
||||
public SensorDataSet() {
|
||||
}
|
||||
@@ -79,11 +79,11 @@ public final class SensorDataSet {
|
||||
return null;
|
||||
}
|
||||
|
||||
public SensorDataCyclingPower getCyclingPower() {
|
||||
public AggregatorCyclingPower getCyclingPower() {
|
||||
return cyclingPower;
|
||||
}
|
||||
|
||||
public void add(@NonNull SensorData<?, ?> data) {
|
||||
public void add(@NonNull Aggregator<?, ?> data) {
|
||||
set(data, data);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class SensorDataSet {
|
||||
throw new UnsupportedOperationException(data.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
public void remove(@NonNull SensorData<?, ?> type) {
|
||||
public void remove(@NonNull Aggregator<?, ?> type) {
|
||||
set(type, null);
|
||||
}
|
||||
|
||||
@@ -163,24 +163,24 @@ public final class SensorDataSet {
|
||||
if (runningDistanceSpeedCadence != null) runningDistanceSpeedCadence.reset();
|
||||
}
|
||||
|
||||
private void set(@NonNull SensorData<?, ?> type, @Nullable SensorData<?, ?> sensorData) {
|
||||
if (type instanceof SensorDataHeartRate hr) {
|
||||
private void set(@NonNull Aggregator<?, ?> type, @Nullable Aggregator<?, ?> sensorData) {
|
||||
if (type instanceof AggregatorHeartRate hr) {
|
||||
heartRate = hr;
|
||||
return;
|
||||
}
|
||||
if (type instanceof SensorDataCyclingCadence cc) {
|
||||
if (type instanceof AggregatorCyclingCadence cc) {
|
||||
cyclingCadence = cc;
|
||||
return;
|
||||
}
|
||||
if (type instanceof SensorDataCyclingDistanceSpeed ds) {
|
||||
if (type instanceof AggregatorCyclingDistanceSpeed ds) {
|
||||
cyclingDistanceSpeed = ds;
|
||||
return;
|
||||
}
|
||||
if (type instanceof SensorDataCyclingPower cp) {
|
||||
if (type instanceof AggregatorCyclingPower cp) {
|
||||
cyclingPower = cp;
|
||||
return;
|
||||
}
|
||||
if (type instanceof SensorDataRunning rr) {
|
||||
if (type instanceof AggregatorRunning rr) {
|
||||
runningDistanceSpeedCadence = rr;
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ public interface SensorHandlerInterface {
|
||||
|
||||
List<ServiceMeasurementUUID> getServices();
|
||||
|
||||
SensorData<?, ?> createEmptySensorData(String address);
|
||||
Aggregator<?, ?> createEmptySensorData(String address);
|
||||
|
||||
void handlePayload(SensorManager.SensorDataChangedObserver observer, ServiceMeasurementUUID serviceMeasurementUUID, String sensorName, String address, BluetoothGattCharacteristic characteristic);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user