feat(eros-database): add history module

This commit is contained in:
Sam Spycher 2021-10-18 00:06:45 +02:00
parent dc0e519822
commit 289ec5668d
13 changed files with 275 additions and 67 deletions

View file

@ -43,6 +43,7 @@ import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.dash.OmnipodDashPumpPlugin
import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
@ -161,6 +162,12 @@ abstract class PluginsModule {
@IntKey(156)
abstract fun bindOmnipodDashPumpPlugin(plugin: OmnipodDashPumpPlugin): PluginBase
@Binds
@PumpDriver
@IntoMap
@IntKey(135)
abstract fun bindOmnipodErosPumpPlugin(plugin: OmnipodErosPumpPlugin): PluginBase
@Binds
@PumpDriver
@IntoMap

View file

@ -14,4 +14,16 @@ dependencies {
implementation project(':pump-common')
implementation project(':omnipod-common')
implementation project(':rileylink')
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor("androidx.room:room-compiler:$room_version")
// To use Kotlin annotation processing tool (kapt)
kapt("androidx.room:room-compiler:$room_version")
// optional - Kotlin Extensions and Coroutines support for Room
implementation("androidx.room:room-ktx:$room_version")
// optional - RxJava2 support for Room
implementation "androidx.room:room-rxjava2:$room_version"
// optional - Test helpers
testImplementation("androidx.room:room-testing:$room_version")
}

View file

@ -0,0 +1,64 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros.history
import android.content.Context
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import info.nightscout.androidaps.plugins.pump.omnipod.eros.definition.PodHistoryEntryType
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryDatabase
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordDao
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordEntity
import org.junit.After
import org.junit.Assert.assertNotNull
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class ErosHistoryTest {
private lateinit var dao: ErosHistoryRecordDao
private lateinit var database: ErosHistoryDatabase
private lateinit var erosHistory: ErosHistory
@Before
fun setUp() {
val context = ApplicationProvider.getApplicationContext<Context>()
database = Room.inMemoryDatabaseBuilder(
context,
ErosHistoryDatabase::class.java
).build()
dao = database.historyRecordDao()
erosHistory = ErosHistory(dao)
}
@Test
fun testInsertionAndRetrieval() {
var history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L, true);
assert(history.isEmpty())
val type = PodHistoryEntryType.SET_BOLUS.code
val entity = ErosHistoryRecordEntity(1000L, type.toLong())
erosHistory.create(entity)
erosHistory.create(ErosHistoryRecordEntity(3000L, PodHistoryEntryType.CANCEL_BOLUS.code.toLong()))
history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L, true);
assert(!history.isEmpty())
assert(history.size == 2)
assert(type.equals(history.first().podEntryTypeCode))
history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L, false);
assert(!history.isEmpty())
assert(history.size == 2)
assert(type.equals(history.last().podEntryTypeCode))
val returnedEntity = erosHistory.findErosHistoryRecordByPumpId(entity.pumpId)
assertNotNull(returnedEntity)
assert(type.equals(returnedEntity.podEntryTypeCode))
}
@After
fun tearDown() {
database.close()
}
}

View file

@ -20,6 +20,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Supplier;
@ -63,11 +64,11 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandSilenceAlerts;
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandDeactivatePod;
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandHandleTimeChange;
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandPlayTestBeep;
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandResumeDelivery;
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandSilenceAlerts;
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandSuspendDelivery;
import info.nightscout.androidaps.plugins.pump.omnipod.common.queue.command.CommandUpdateAlertConfiguration;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.data.RLHistoryItemOmnipod;
@ -86,6 +87,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.event.EventOmnipodEr
import info.nightscout.androidaps.plugins.pump.omnipod.eros.event.EventOmnipodErosPumpValuesChanged;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.event.EventOmnipodErosTbrChanged;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.event.EventOmnipodErosUncertainTbrRecovered;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.ErosHistory;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodErosManager;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.queue.command.CommandGetPodStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.queue.command.CommandReadPulseLog;
@ -126,6 +128,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
private final ErosPodStateManager podStateManager;
private final RileyLinkServiceData rileyLinkServiceData;
private final AapsOmnipodErosManager aapsOmnipodErosManager;
private final ErosHistory erosHistory;
private final AapsOmnipodUtil aapsOmnipodUtil;
private final RileyLinkUtil rileyLinkUtil;
private final OmnipodAlertUtil omnipodAlertUtil;
@ -171,6 +174,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
ActivePlugin activePlugin,
SP sp,
ErosPodStateManager podStateManager,
ErosHistory erosHistory,
AapsOmnipodErosManager aapsOmnipodErosManager,
CommandQueueProvider commandQueue,
FabricPrivacy fabricPrivacy,
@ -203,6 +207,7 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
this.podStateManager = podStateManager;
this.rileyLinkServiceData = rileyLinkServiceData;
this.aapsOmnipodErosManager = aapsOmnipodErosManager;
this.erosHistory = erosHistory;
this.aapsOmnipodUtil = aapsOmnipodUtil;
this.rileyLinkUtil = rileyLinkUtil;
this.omnipodAlertUtil = omnipodAlertUtil;
@ -650,12 +655,19 @@ public class OmnipodErosPumpPlugin extends PumpPluginBase implements Pump, Riley
return deliverBolus(detailedBolusInfo);
} else {
// no bolus required, carb only treatment
// activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, true);
boolean result = pumpSync.syncCarbsWithTimestamp(
detailedBolusInfo.timestamp,
detailedBolusInfo.carbs,
null,
model(),
serialNumber());
// return new PumpEnactResult(getInjector()).success(true).enacted(true).bolusDelivered(0d)
// .carbsDelivered(detailedBolusInfo.carbs);
// Needs refactor
throw new IllegalStateException("Not implemented");
aapsLogger.debug(LTag.PUMP, String.format(Locale.ENGLISH, "syncCarbsWithTimestamp " +
"[date=%d, carbs=%.2f, pumpSerial=%s] - Result: %b",
detailedBolusInfo.timestamp, detailedBolusInfo.carbs, serialNumber(), result));
return new PumpEnactResult(getInjector()).success(true).enacted(true).bolusDelivered(0d)
.carbsDelivered(detailedBolusInfo.carbs);
}
}

View file

@ -0,0 +1,28 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros.dagger
import android.content.Context
import dagger.Module
import dagger.Provides
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.ErosHistory
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryDatabase
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordDao
import javax.inject.Singleton
@Module
class OmnipodErosHistoryModule {
@Provides
@Singleton
internal fun provideDatabase(context: Context): ErosHistoryDatabase = ErosHistoryDatabase.build(context)
@Provides
@Singleton
internal fun provideHistoryRecordDao(erosHistoryDatabase: ErosHistoryDatabase): ErosHistoryRecordDao =
erosHistoryDatabase.historyRecordDao()
@Provides
@Singleton
internal fun provideErosHistory(dao: ErosHistoryRecordDao) =
ErosHistory(dao)
}

View file

@ -16,7 +16,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.ui.OmnipodErosOvervi
import info.nightscout.androidaps.plugins.pump.omnipod.eros.ui.wizard.activation.ErosPodActivationWizardActivity
import info.nightscout.androidaps.plugins.pump.omnipod.eros.ui.wizard.deactivation.ErosPodDeactivationWizardActivity
@Module
@Module(includes = [OmnipodErosHistoryModule::class])
@Suppress("unused")
abstract class OmnipodErosModule {

View file

@ -0,0 +1,32 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros.history;
import java.util.List;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordDao;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordEntity;
public class ErosHistory
{
private ErosHistoryRecordDao dao;
public ErosHistory(ErosHistoryRecordDao dao) {
this.dao = dao;
}
public List<ErosHistoryRecordEntity> getAllErosHistoryRecordsFromTimestamp(long timeInMillis, boolean ascending) {
if (ascending){
return dao.allSinceAsc(timeInMillis);
}
else {
return dao.allSinceDesc(timeInMillis);
}
}
public ErosHistoryRecordEntity findErosHistoryRecordByPumpId(long pumpId) {
return dao.byId(pumpId);
}
public void create(ErosHistoryRecordEntity historyRecord){
dao.insert(historyRecord);
}
}

View file

@ -0,0 +1,30 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
@Database(
entities = [ErosHistoryRecordEntity::class],
exportSchema = false,
version = ErosHistoryDatabase.VERSION
)
abstract class ErosHistoryDatabase : RoomDatabase() {
abstract fun historyRecordDao(): ErosHistoryRecordDao
companion object {
const val VERSION = 1
fun build(context: Context) =
Room.databaseBuilder(
context.applicationContext,
ErosHistoryDatabase::class.java,
"omnipod_eros_history_database.db"
)
.fallbackToDestructiveMigration()
.build()
}
}

View file

@ -0,0 +1,23 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
@Dao
interface ErosHistoryRecordDao {
@Query("SELECT * from historyrecords WHERE date <= :since order by date asc")
fun allSinceAsc(since: Long): List<ErosHistoryRecordEntity>
@Query("SELECT * from historyrecords WHERE date <= :since order by date desc")
fun allSinceDesc(since: Long): List<ErosHistoryRecordEntity>
@Query("SELECT * FROM historyrecords WHERE pumpId = :id LIMIT 1")
fun byId(id: Long): ErosHistoryRecordEntity?
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(ErosHistoryRecordEntity: ErosHistoryRecordEntity)
}

View file

@ -1,47 +1,37 @@
package info.nightscout.androidaps.db;
package info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import androidx.room.Entity;
import androidx.room.Index;
import androidx.room.PrimaryKey;
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
/**
* Created by andy on 30.11.2019.
*/
@DatabaseTable(tableName = "PodHistory")
public class OmnipodHistoryRecord implements Comparable<OmnipodHistoryRecord> {
@Entity(tableName = "historyrecords", indices = {@Index("date")})
public class ErosHistoryRecordEntity implements Comparable<ErosHistoryRecordEntity> {
@DatabaseField(id = true)
public long date;
@DatabaseField
private long podEntryTypeCode;
@DatabaseField
private String data;
@DatabaseField
private boolean success;
@DatabaseField
@PrimaryKey
private long pumpId;
@DatabaseField
public long date;
private long podEntryTypeCode;
private String data;
private boolean success;
private String podSerial;
@DatabaseField
private Boolean successConfirmed;
public OmnipodHistoryRecord() {
public ErosHistoryRecordEntity() {
generatePumpId();
}
public OmnipodHistoryRecord(long dateTimeInMillis, long podEntryTypeCode) {
public ErosHistoryRecordEntity(long dateTimeInMillis, long podEntryTypeCode) {
this.date = dateTimeInMillis;
this.podEntryTypeCode = podEntryTypeCode;
generatePumpId();
}
public long getDate() {
return this.date;
}
@ -108,7 +98,7 @@ public class OmnipodHistoryRecord implements Comparable<OmnipodHistoryRecord> {
}
@Override
public int compareTo(OmnipodHistoryRecord otherOne) {
public int compareTo(ErosHistoryRecordEntity otherOne) {
return (int) (otherOne.date - this.date);
}
}

View file

@ -17,7 +17,6 @@ import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.activities.ErrorHelperActivity;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.OmnipodHistoryRecord;
import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.extensions.PumpStateExtensionKt;
@ -71,9 +70,11 @@ import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.exception.Ril
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.exception.RileyLinkTimeoutException;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.exception.RileyLinkUnexpectedException;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.exception.RileyLinkUnreachableException;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.manager.OmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.manager.ErosPodStateManager;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.manager.OmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.event.EventOmnipodErosPumpValuesChanged;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.ErosHistory;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordEntity;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.rileylink.manager.OmnipodRileyLinkCommunicationManager;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.AapsOmnipodUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.util.OmnipodAlertUtil;
@ -87,6 +88,7 @@ import io.reactivex.subjects.SingleSubject;
public class AapsOmnipodErosManager {
private final ErosPodStateManager podStateManager;
private final ErosHistory erosHistory;
private final AapsOmnipodUtil aapsOmnipodUtil;
private final AAPSLogger aapsLogger;
private final RxBus rxBus;
@ -116,6 +118,7 @@ public class AapsOmnipodErosManager {
@Inject
public AapsOmnipodErosManager(OmnipodRileyLinkCommunicationManager communicationService,
ErosPodStateManager podStateManager,
ErosHistory erosHistory,
AapsOmnipodUtil aapsOmnipodUtil,
AAPSLogger aapsLogger,
AapsSchedulers aapsSchedulers,
@ -128,6 +131,7 @@ public class AapsOmnipodErosManager {
PumpSync pumpSync) {
this.podStateManager = podStateManager;
this.erosHistory = erosHistory;
this.aapsOmnipodUtil = aapsOmnipodUtil;
this.aapsLogger = aapsLogger;
this.rxBus = rxBus;
@ -692,19 +696,25 @@ public class AapsOmnipodErosManager {
if (detailedBolusInfo.carbs > 0 && detailedBolusInfo.getCarbsTimestamp() != null) {
// split out a separate carbs record without a pumpId
DetailedBolusInfo carbInfo = new DetailedBolusInfo();
carbInfo.setCarbsTimestamp(detailedBolusInfo.getCarbsTimestamp());
carbInfo.carbs = detailedBolusInfo.carbs;
carbInfo.setPumpType(PumpType.USER);
// activePlugin.getActiveTreatments().addToHistoryTreatment(carbInfo, false);
// Needs refactor
pumpSync.syncCarbsWithTimestamp(
detailedBolusInfo.getCarbsTimestamp(),
detailedBolusInfo.carbs,
null,
PumpType.USER,
serialNumber());
// remove carbs from bolusInfo to not trigger any unwanted code paths in
// TreatmentsPlugin.addToHistoryTreatment() method
detailedBolusInfo.carbs = 0;
}
// activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false);
// Needs refactor
throw new IllegalStateException("Not implemented");
pumpSync.syncBolusWithPumpId(
detailedBolusInfo.timestamp,
detailedBolusInfo.insulin,
detailedBolusInfo.getBolusType(),
detailedBolusInfo.getBolusPumpId(),
detailedBolusInfo.getPumpType(),
serialNumber());
}
public synchronized void createSuspendedFakeTbrIfNotExists() {
@ -743,9 +753,8 @@ public class AapsOmnipodErosManager {
public boolean hasSuspendedFakeTbr() {
PumpSync.PumpState pumpState = pumpSync.expectedPumpState();
if (pumpState.getTemporaryBasal() != null && pumpState.getTemporaryBasal().getPumpId() != null) {
// OmnipodHistoryRecord historyRecord = databaseHelper.findOmnipodHistoryRecordByPumpId(pumpState.getTemporaryBasal().getPumpId());
// return historyRecord != null && PodHistoryEntryType.getByCode(historyRecord.getPodEntryTypeCode()).equals(PodHistoryEntryType.SET_FAKE_SUSPENDED_TEMPORARY_BASAL);
throw new IllegalStateException("Not implemented");
ErosHistoryRecordEntity historyRecord = erosHistory.findErosHistoryRecordByPumpId(pumpState.getTemporaryBasal().getPumpId());
return historyRecord != null && PodHistoryEntryType.getByCode(historyRecord.getPodEntryTypeCode()).equals(PodHistoryEntryType.SET_FAKE_SUSPENDED_TEMPORARY_BASAL);
}
return false;
}
@ -834,22 +843,21 @@ public class AapsOmnipodErosManager {
private long addToHistory(long requestTime, PodHistoryEntryType entryType, Object data,
boolean success) {
OmnipodHistoryRecord omnipodHistoryRecord = new OmnipodHistoryRecord(requestTime, entryType.getCode());
ErosHistoryRecordEntity erosHistoryRecordEntity = new ErosHistoryRecordEntity(requestTime, entryType.getCode());
if (data != null) {
if (data instanceof String) {
omnipodHistoryRecord.setData((String) data);
erosHistoryRecordEntity.setData((String) data);
} else {
omnipodHistoryRecord.setData(aapsOmnipodUtil.getGsonInstance().toJson(data));
erosHistoryRecordEntity.setData(aapsOmnipodUtil.getGsonInstance().toJson(data));
}
}
omnipodHistoryRecord.setSuccess(success);
omnipodHistoryRecord.setPodSerial(podStateManager.hasPodState() ? String.valueOf(podStateManager.getAddress()) : "None");
erosHistoryRecordEntity.setSuccess(success);
erosHistoryRecordEntity.setPodSerial(podStateManager.hasPodState() ? String.valueOf(podStateManager.getAddress()) : "None");
// databaseHelper.createOrUpdate(omnipodHistoryRecord);
// return omnipodHistoryRecord.getPumpId();
throw new IllegalStateException("Not implemented");
erosHistory.create(erosHistoryRecordEntity);
return erosHistoryRecordEntity.getPumpId();
}
private void executeCommand(Runnable runnable) {

View file

@ -23,7 +23,8 @@ import java.util.List;
import javax.inject.Inject;
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
import info.nightscout.androidaps.db.OmnipodHistoryRecord;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.ErosHistory;
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordEntity;
import info.nightscout.androidaps.interfaces.Profile;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
@ -41,6 +42,7 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity {
@Inject AAPSLogger aapsLogger;
@Inject AapsOmnipodUtil aapsOmnipodUtil;
@Inject ResourceHelper resourceHelper;
@Inject ErosHistory erosHistory;
private Spinner historyTypeSpinner;
private TextView statusView;
@ -48,8 +50,8 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity {
private LinearLayoutManager linearLayoutManager;
private static PumpHistoryEntryGroup selectedGroup = PumpHistoryEntryGroup.All;
private final List<OmnipodHistoryRecord> fullHistoryList = new ArrayList<>();
private final List<OmnipodHistoryRecord> filteredHistoryList = new ArrayList<>();
private final List<ErosHistoryRecordEntity> fullHistoryList = new ArrayList<>();
private final List<ErosHistoryRecordEntity> filteredHistoryList = new ArrayList<>();
private RecyclerViewAdapter recyclerViewAdapter;
private boolean manualChange = false;
@ -66,9 +68,7 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity {
GregorianCalendar gc = new GregorianCalendar();
gc.add(Calendar.HOUR_OF_DAY, -24);
// databaseHelper.getAllOmnipodHistoryRecordsFromTimestamp(gc.getTimeInMillis(), false);
// fullHistoryList.addAll(databaseHelper.getAllOmnipodHistoryRecordsFromTimestamp(gc.getTimeInMillis(), true));
throw new IllegalStateException("Not implemented");
fullHistoryList.addAll(erosHistory.getAllErosHistoryRecordsFromTimestamp(gc.getTimeInMillis(), true));
}
@ -81,7 +81,7 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity {
if (group == PumpHistoryEntryGroup.All) {
this.filteredHistoryList.addAll(fullHistoryList);
} else {
for (OmnipodHistoryRecord pumpHistoryEntry : fullHistoryList) {
for (ErosHistoryRecordEntity pumpHistoryEntry : fullHistoryList) {
if (PodHistoryEntryType.getByCode(pumpHistoryEntry.getPodEntryTypeCode()).getGroup() == group) {
this.filteredHistoryList.add(pumpHistoryEntry);
}
@ -204,14 +204,14 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity {
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder> {
List<OmnipodHistoryRecord> historyList;
List<ErosHistoryRecordEntity> historyList;
RecyclerViewAdapter(List<OmnipodHistoryRecord> historyList) {
RecyclerViewAdapter(List<ErosHistoryRecordEntity> historyList) {
this.historyList = historyList;
}
void setHistoryList(List<OmnipodHistoryRecord> historyList) {
void setHistoryList(List<ErosHistoryRecordEntity> historyList) {
this.historyList = historyList;
Collections.sort(this.historyList);
}
@ -228,7 +228,7 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity {
@Override
public void onBindViewHolder(@NonNull HistoryViewHolder holder, int position) {
OmnipodHistoryRecord record = historyList.get(position);
ErosHistoryRecordEntity record = historyList.get(position);
if (record != null) {
holder.timeView.setText(record.getDateTimeString());
@ -238,7 +238,7 @@ public class ErosPodHistoryActivity extends NoSplashAppCompatActivity {
}
private void setValue(OmnipodHistoryRecord historyEntry, TextView valueView) {
private void setValue(ErosHistoryRecordEntity historyEntry, TextView valueView) {
//valueView.setText("");
if (historyEntry.isSuccess()) {

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.plugins.pump.common.defs.TempBasalPair
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.ErosHistory
import info.nightscout.androidaps.plugins.pump.omnipod.eros.manager.AapsOmnipodErosManager
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.rx.TestAapsSchedulers
@ -34,6 +35,7 @@ class OmnipodErosPumpPluginTest : TestBase() {
@Mock lateinit var resourceHelper: ResourceHelper
@Mock(answer = Answers.RETURNS_DEEP_STUBS) lateinit var activePlugin: ActivePlugin
@Mock lateinit var aapsOmnipodErosManager: AapsOmnipodErosManager
@Mock lateinit var erosHistory: ErosHistory
@Mock lateinit var commandQueueProvider: CommandQueueProvider
@Mock lateinit var rileyLinkUtil: RileyLinkUtil
@Mock lateinit var pumpSync: PumpSync
@ -51,7 +53,7 @@ class OmnipodErosPumpPluginTest : TestBase() {
// mock all the things
val plugin = OmnipodErosPumpPlugin(
injector, aapsLogger, TestAapsSchedulers(), rxBusWrapper, null,
resourceHelper, activePlugin, null, null, aapsOmnipodErosManager, commandQueueProvider,
resourceHelper, activePlugin, null, null, erosHistory, aapsOmnipodErosManager, commandQueueProvider,
null, null, null, null,
rileyLinkUtil, null, null, pumpSync
)