Remove OmnipodPumpStatus
This commit is contained in:
parent
c52987ab6c
commit
2745aed31a
15 changed files with 237 additions and 483 deletions
|
@ -23,7 +23,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodAcknowledgeAlertsChanged
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
||||||
|
@ -163,10 +162,6 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
.toObservable(EventOmnipodPumpValuesChanged::class.java)
|
.toObservable(EventOmnipodPumpValuesChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ updateOmipodUiElements() }, { fabricPrivacy.logException(it) })
|
.subscribe({ updateOmipodUiElements() }, { fabricPrivacy.logException(it) })
|
||||||
disposables += rxBus
|
|
||||||
.toObservable(EventOmnipodAcknowledgeAlertsChanged::class.java)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe({ updateAcknowledgeAlertsUiElements() }, { fabricPrivacy.logException(it) })
|
|
||||||
disposables += rxBus
|
disposables += rxBus
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
|
|
|
@ -11,13 +11,13 @@ import android.os.SystemClock;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.joda.time.DateTime;
|
||||||
|
import org.joda.time.Duration;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -53,8 +53,6 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNo
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange;
|
import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||||
|
@ -70,7 +68,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionT
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUITask;
|
||||||
|
@ -99,7 +96,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
private final PodStateManager podStateManager;
|
private final PodStateManager podStateManager;
|
||||||
private final RileyLinkServiceData rileyLinkServiceData;
|
private final RileyLinkServiceData rileyLinkServiceData;
|
||||||
private final ServiceTaskExecutor serviceTaskExecutor;
|
private final ServiceTaskExecutor serviceTaskExecutor;
|
||||||
private final OmnipodPumpStatus omnipodPumpStatus;
|
|
||||||
private final AapsOmnipodManager aapsOmnipodManager;
|
private final AapsOmnipodManager aapsOmnipodManager;
|
||||||
private final OmnipodUtil omnipodUtil;
|
private final OmnipodUtil omnipodUtil;
|
||||||
private final AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
|
@ -129,10 +125,9 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
private RileyLinkOmnipodService rileyLinkOmnipodService;
|
private RileyLinkOmnipodService rileyLinkOmnipodService;
|
||||||
private boolean busy = false;
|
private boolean busy = false;
|
||||||
private int timeChangeRetries;
|
private int timeChangeRetries;
|
||||||
private Profile currentProfile;
|
|
||||||
private long nextPodCheck;
|
private long nextPodCheck;
|
||||||
private boolean sentIdToFirebase;
|
private boolean sentIdToFirebase;
|
||||||
private long lastConnectionMillis;
|
private long lastConnectionTimeMillis;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public OmnipodPumpPlugin(
|
public OmnipodPumpPlugin(
|
||||||
|
@ -143,7 +138,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
ActivePluginProvider activePlugin,
|
ActivePluginProvider activePlugin,
|
||||||
SP sp,
|
SP sp,
|
||||||
OmnipodPumpStatus omnipodPumpStatus,
|
|
||||||
PodStateManager podStateManager,
|
PodStateManager podStateManager,
|
||||||
AapsOmnipodManager aapsOmnipodManager,
|
AapsOmnipodManager aapsOmnipodManager,
|
||||||
CommandQueueProvider commandQueue,
|
CommandQueueProvider commandQueue,
|
||||||
|
@ -172,7 +166,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
this.podStateManager = podStateManager;
|
this.podStateManager = podStateManager;
|
||||||
this.rileyLinkServiceData = rileyLinkServiceData;
|
this.rileyLinkServiceData = rileyLinkServiceData;
|
||||||
this.serviceTaskExecutor = serviceTaskExecutor;
|
this.serviceTaskExecutor = serviceTaskExecutor;
|
||||||
this.omnipodPumpStatus = omnipodPumpStatus;
|
|
||||||
this.aapsOmnipodManager = aapsOmnipodManager;
|
this.aapsOmnipodManager = aapsOmnipodManager;
|
||||||
this.omnipodUtil = omnipodUtil;
|
this.omnipodUtil = omnipodUtil;
|
||||||
|
|
||||||
|
@ -222,7 +215,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
// When PodStateManager is created, which causes an IllegalArgumentException for DateTimeZones not being recognized
|
// When PodStateManager is created, which causes an IllegalArgumentException for DateTimeZones not being recognized
|
||||||
podStateManager.loadPodState();
|
podStateManager.loadPodState();
|
||||||
|
|
||||||
lastConnectionMillis = sp.getLong(
|
lastConnectionTimeMillis = sp.getLong(
|
||||||
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
|
||||||
|
|
||||||
Intent intent = new Intent(context, RileyLinkOmnipodService.class);
|
Intent intent = new Intent(context, RileyLinkOmnipodService.class);
|
||||||
|
@ -312,17 +305,37 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpStatus getPumpStatusData() {
|
// TODO is this correct?
|
||||||
return this.omnipodPumpStatus;
|
@Override
|
||||||
}
|
public boolean isInitialized() {
|
||||||
|
return isConnected() && podStateManager.isPodActivationCompleted();
|
||||||
private boolean isServiceSet() {
|
|
||||||
return rileyLinkOmnipodService != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInitialized() {
|
public boolean isConnected() {
|
||||||
return isServiceSet() && isInitialized;
|
return rileyLinkOmnipodService != null && rileyLinkOmnipodService.isInitialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConnecting() {
|
||||||
|
return rileyLinkOmnipodService == null || !rileyLinkOmnipodService.isInitialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isHandshakeInProgress() {
|
||||||
|
if (displayConnectionMessages)
|
||||||
|
aapsLogger.debug(LTag.PUMP, "isHandshakeInProgress [OmnipodPumpPlugin] - default (empty) implementation.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO is this correct?
|
||||||
|
@Override
|
||||||
|
public boolean isBusy() {
|
||||||
|
return busy || rileyLinkOmnipodService == null || !podStateManager.isPodRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void setBusy(boolean busy) {
|
||||||
|
this.busy = busy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -331,16 +344,24 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBusy() {
|
public void finishHandshaking() {
|
||||||
if (isServiceSet()) {
|
if (displayConnectionMessages)
|
||||||
return busy || !podStateManager.isPodRunning();
|
aapsLogger.debug(LTag.PUMP, "finishHandshaking [OmnipodPumpPlugin] - default (empty) implementation.");
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void setBusy(boolean busy) {
|
@Override public void connect(String reason) {
|
||||||
this.busy = busy;
|
if (displayConnectionMessages)
|
||||||
|
aapsLogger.debug(LTag.PUMP, "connect (reason={}) [PumpPluginAbstract] - default (empty) implementation." + reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void disconnect(String reason) {
|
||||||
|
if (displayConnectionMessages)
|
||||||
|
aapsLogger.debug(LTag.PUMP, "disconnect (reason={}) [PumpPluginAbstract] - default (empty) implementation." + reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void stopConnecting() {
|
||||||
|
if (displayConnectionMessages)
|
||||||
|
aapsLogger.debug(LTag.PUMP, "stopConnecting [PumpPluginAbstract] - default (empty) implementation.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -371,7 +392,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
* For getting the last time a command was successfully executed, use PodStateManager.getLastSuccessfulCommunication
|
* For getting the last time a command was successfully executed, use PodStateManager.getLastSuccessfulCommunication
|
||||||
*/
|
*/
|
||||||
@Override public long getLastConnectionTimeMillis() {
|
@Override public long getLastConnectionTimeMillis() {
|
||||||
return omnipodPumpStatus.lastConnection;
|
return lastConnectionTimeMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required by RileyLinkPumpDevice interface.
|
// Required by RileyLinkPumpDevice interface.
|
||||||
|
@ -383,45 +404,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
* For setting the last time a command was successfully executed, use PodStateManager.setLastSuccessfulCommunication
|
* For setting the last time a command was successfully executed, use PodStateManager.setLastSuccessfulCommunication
|
||||||
*/
|
*/
|
||||||
@Override public void setLastCommunicationToNow() {
|
@Override public void setLastCommunicationToNow() {
|
||||||
omnipodPumpStatus.setLastCommunicationToNow();
|
lastConnectionTimeMillis = System.currentTimeMillis();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isConnected() {
|
|
||||||
return isServiceSet() && rileyLinkOmnipodService.isInitialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isConnecting() {
|
|
||||||
return !isServiceSet() || !rileyLinkOmnipodService.isInitialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isHandshakeInProgress() {
|
|
||||||
if (displayConnectionMessages)
|
|
||||||
aapsLogger.debug(LTag.PUMP, "isHandshakeInProgress [OmnipodPumpPlugin] - default (empty) implementation.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void finishHandshaking() {
|
|
||||||
if (displayConnectionMessages)
|
|
||||||
aapsLogger.debug(LTag.PUMP, "finishHandshaking [OmnipodPumpPlugin] - default (empty) implementation.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void connect(String reason) {
|
|
||||||
if (displayConnectionMessages)
|
|
||||||
aapsLogger.debug(LTag.PUMP, "connect (reason={}) [PumpPluginAbstract] - default (empty) implementation." + reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void disconnect(String reason) {
|
|
||||||
if (displayConnectionMessages)
|
|
||||||
aapsLogger.debug(LTag.PUMP, "disconnect (reason={}) [PumpPluginAbstract] - default (empty) implementation." + reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void stopConnecting() {
|
|
||||||
if (displayConnectionMessages)
|
|
||||||
aapsLogger.debug(LTag.PUMP, "stopConnecting [PumpPluginAbstract] - default (empty) implementation.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO seems that this abused to squeeze commands in the queue
|
// TODO seems that this abused to squeeze commands in the queue
|
||||||
|
@ -490,14 +473,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
||||||
// this shouldn't be needed, but let's do check if profile setting we are setting is same as current one
|
|
||||||
if (this.currentProfile != null && this.currentProfile.areProfileBasalPatternsSame(profile)) {
|
|
||||||
return new PumpEnactResult(getInjector()) //
|
|
||||||
.success(true) //
|
|
||||||
.enacted(false) //
|
|
||||||
.comment(resourceHelper.gs(R.string.omnipod_cmd_basal_profile_not_set_is_same));
|
|
||||||
}
|
|
||||||
|
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
OmnipodUITask responseTask = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.SetBasalProfile,
|
OmnipodUITask responseTask = getDeviceCommandExecutor().executeCommand(OmnipodCommandType.SetBasalProfile,
|
||||||
|
@ -508,8 +483,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
aapsLogger.info(LTag.PUMP, "Basal Profile was set: " + result.success);
|
aapsLogger.info(LTag.PUMP, "Basal Profile was set: " + result.success);
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
this.currentProfile = profile;
|
|
||||||
|
|
||||||
Notification notification = new Notification(Notification.PROFILE_SET_OK,
|
Notification notification = new Notification(Notification.PROFILE_SET_OK,
|
||||||
resourceHelper.gs(R.string.profile_set_ok),
|
resourceHelper.gs(R.string.profile_set_ok),
|
||||||
Notification.INFO, 60);
|
Notification.INFO, 60);
|
||||||
|
@ -526,38 +499,42 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isThisProfileSet(Profile profile) {
|
public boolean isThisProfileSet(Profile profile) {
|
||||||
// TODO status was not yet read from pod
|
if (!podStateManager.isPodActivationCompleted()) {
|
||||||
// TODO maybe not possible, need to see how we will handle that
|
return true; // Return true, because otherwise AAPS will try setting a Basal schedule while no Pod is active
|
||||||
if (currentProfile == null) {
|
|
||||||
this.currentProfile = profile;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return podStateManager.getBasalSchedule().equals(AapsOmnipodManager.mapProfileToBasalSchedule(profile));
|
||||||
return (currentProfile.areProfileBasalPatternsSame(profile));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long lastDataTime() {
|
public long lastDataTime() {
|
||||||
return lastConnectionMillis;
|
return lastConnectionTimeMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getBaseBasalRate() {
|
public double getBaseBasalRate() {
|
||||||
if (currentProfile != null) {
|
if (!podStateManager.isPodRunning()) {
|
||||||
int hour = (new GregorianCalendar()).get(Calendar.HOUR_OF_DAY);
|
|
||||||
return currentProfile.getBasalTimeFromMidnight(DateTimeUtil.getTimeInS(hour * 60));
|
|
||||||
} else {
|
|
||||||
return 0.0d;
|
return 0.0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
Duration offset = new Duration(now.withTimeAtStartOfDay(), now);
|
||||||
|
return podStateManager.getBasalSchedule().rateAt(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getReservoirLevel() {
|
public double getReservoirLevel() {
|
||||||
return omnipodPumpStatus.reservoirRemainingUnits;
|
if (!podStateManager.isPodRunning()) {
|
||||||
|
return 0.0d;
|
||||||
|
}
|
||||||
|
Double reservoirLevel = podStateManager.getReservoirLevel();
|
||||||
|
return reservoirLevel == null ? 75.0 : reservoirLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBatteryLevel() {
|
public int getBatteryLevel() {
|
||||||
|
if (!podStateManager.isPodRunning()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 75;
|
return 75;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,21 +582,22 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
// if enforceNew===true current temp basal is canceled and new TBR set (duration is prolonged),
|
// if enforceNew===true current temp basal is canceled and new TBR set (duration is prolonged),
|
||||||
// if false and the same rate is requested enacted=false and success=true is returned and TBR is not changed
|
// if false and the same rate is requested enacted=false and success=true is returned and TBR is not changed
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer
|
||||||
|
durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes);
|
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes);
|
||||||
|
|
||||||
// read current TBR
|
// read current TBR
|
||||||
TempBasalPair tbrCurrent = readTBR();
|
TemporaryBasal tbrCurrent = readTBR();
|
||||||
|
|
||||||
if (tbrCurrent != null) {
|
if (tbrCurrent != null) {
|
||||||
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: Current Basal: duration: {} min, rate={}",
|
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute: Current Basal: duration: {} min, rate={}",
|
||||||
tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate());
|
tbrCurrent.durationInMinutes, tbrCurrent.absoluteRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tbrCurrent != null && !enforceNew) {
|
if (tbrCurrent != null && !enforceNew) {
|
||||||
if (Round.isSame(tbrCurrent.getInsulinRate(), absoluteRate)) {
|
if (Round.isSame(tbrCurrent.absoluteRate, absoluteRate)) {
|
||||||
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - No enforceNew and same rate. Exiting.");
|
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - No enforceNew and same rate. Exiting.");
|
||||||
finishAction("TBR");
|
finishAction("TBR");
|
||||||
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
||||||
|
@ -642,12 +620,14 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull @Override public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
@NotNull @Override public PumpEnactResult setTempBasalPercent(Integer percent, Integer
|
||||||
|
durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalPercent [OmnipodPumpPlugin] - Not implemented.");
|
aapsLogger.debug(LTag.PUMP, "setTempBasalPercent [OmnipodPumpPlugin] - Not implemented.");
|
||||||
return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver);
|
return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull @Override public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
@NotNull @Override public PumpEnactResult setExtendedBolus(Double insulin, Integer
|
||||||
|
durationInMinutes) {
|
||||||
aapsLogger.debug(LTag.PUMP, "setExtendedBolus [OmnipodPumpPlugin] - Not implemented.");
|
aapsLogger.debug(LTag.PUMP, "setExtendedBolus [OmnipodPumpPlugin] - Not implemented.");
|
||||||
return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver);
|
return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver);
|
||||||
}
|
}
|
||||||
|
@ -656,7 +636,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
TempBasalPair tbrCurrent = readTBR();
|
TemporaryBasal tbrCurrent = readTBR();
|
||||||
|
|
||||||
if (tbrCurrent == null) {
|
if (tbrCurrent == null) {
|
||||||
aapsLogger.info(LTag.PUMP, "cancelTempBasal - TBR already canceled.");
|
aapsLogger.info(LTag.PUMP, "cancelTempBasal - TBR already canceled.");
|
||||||
|
@ -688,10 +668,11 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver);
|
return getOperationNotSupportedWithCustomText(info.nightscout.androidaps.core.R.string.pump_operation_not_supported_by_pump_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO improve (i8n and more)
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
public JSONObject getJSONStatus(Profile profile, String profileName, String version) {
|
public JSONObject getJSONStatus(Profile profile, String profileName, String version) {
|
||||||
|
|
||||||
if ((getPumpStatusData().lastConnection + 60 * 60 * 1000L) < System.currentTimeMillis()) {
|
if (!podStateManager.isPodActivationCompleted() || lastConnectionTimeMillis + 60 * 60 * 1000L < System.currentTimeMillis()) {
|
||||||
return new JSONObject();
|
return new JSONObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,15 +681,18 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
JSONObject status = new JSONObject();
|
JSONObject status = new JSONObject();
|
||||||
JSONObject extended = new JSONObject();
|
JSONObject extended = new JSONObject();
|
||||||
try {
|
try {
|
||||||
battery.put("percent", getPumpStatusData().batteryRemaining);
|
status.put("status", podStateManager.isPodRunning() ? "normal" : "error");
|
||||||
status.put("status", getPumpStatusData().pumpStatusType != null ? getPumpStatusData().pumpStatusType.getStatus() : "normal");
|
status.put("timestamp", DateUtil.toISOString(new Date()));
|
||||||
|
|
||||||
|
battery.put("percent", getBatteryLevel());
|
||||||
|
|
||||||
extended.put("Version", version);
|
extended.put("Version", version);
|
||||||
try {
|
try {
|
||||||
extended.put("ActiveProfile", profileName);
|
extended.put("ActiveProfile", profileName);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TemporaryBasal tb = activePlugin.getActiveTreatments().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal tb = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate",
|
extended.put("TempBasalAbsoluteRate",
|
||||||
tb.tempBasalConvertedToAbsolute(System.currentTimeMillis(), profile));
|
tb.tempBasalConvertedToAbsolute(System.currentTimeMillis(), profile));
|
||||||
|
@ -728,10 +712,10 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
pump.put("battery", battery);
|
pump.put("battery", battery);
|
||||||
pump.put("status", status);
|
pump.put("status", status);
|
||||||
pump.put("extended", extended);
|
pump.put("extended", extended);
|
||||||
pump.put("reservoir", getPumpStatusData().reservoirRemainingUnits);
|
pump.put("reservoir", getReservoirLevel());
|
||||||
pump.put("clock", DateUtil.toISOString(new Date()));
|
pump.put("clock", DateUtil.toISOString(new Date()));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
aapsLogger.error("Unhandled exception", e);
|
aapsLogger.error(LTag.PUMP, "Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return pump;
|
return pump;
|
||||||
}
|
}
|
||||||
|
@ -758,15 +742,18 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
// FIXME i18n, null checks: iob, TDD
|
// FIXME i18n, null checks: iob, TDD
|
||||||
@NonNull @Override
|
@NonNull @Override
|
||||||
public String shortStatus(boolean veryShort) {
|
public String shortStatus(boolean veryShort) {
|
||||||
|
if (!podStateManager.isPodActivationCompleted()) {
|
||||||
|
return "No active pod";
|
||||||
|
}
|
||||||
String ret = "";
|
String ret = "";
|
||||||
if (getPumpStatusData().lastConnection != 0) {
|
if (lastConnectionTimeMillis != 0) {
|
||||||
long agoMsec = System.currentTimeMillis() - getPumpStatusData().lastConnection;
|
long agoMsec = System.currentTimeMillis() - lastConnectionTimeMillis;
|
||||||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||||
ret += "LastConn: " + agoMin + " min ago\n";
|
ret += "LastConn: " + agoMin + " min ago\n";
|
||||||
}
|
}
|
||||||
if (getPumpStatusData().lastBolusTime != null && getPumpStatusData().lastBolusTime.getTime() != 0) {
|
if (podStateManager.getLastBolusStartTime() != null) {
|
||||||
ret += "LastBolus: " + DecimalFormatter.to2Decimal(getPumpStatusData().lastBolusAmount) + "U @" + //
|
ret += "LastBolus: " + DecimalFormatter.to2Decimal(podStateManager.getLastBolusAmount()) + "U @" + //
|
||||||
android.text.format.DateFormat.format("HH:mm", getPumpStatusData().lastBolusTime) + "\n";
|
android.text.format.DateFormat.format("HH:mm", podStateManager.getLastBolusStartTime().toDate()) + "\n";
|
||||||
}
|
}
|
||||||
TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = activePlugin.getActiveTreatments().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
|
@ -777,9 +764,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
if (activeExtendedBolus != null) {
|
if (activeExtendedBolus != null) {
|
||||||
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
||||||
}
|
}
|
||||||
ret += "IOB: " + getPumpStatusData().iob + "U\n";
|
ret += "Reserv: " + DecimalFormatter.to0Decimal(getReservoirLevel()) + "U\n";
|
||||||
ret += "Reserv: " + DecimalFormatter.to0Decimal(getPumpStatusData().reservoirRemainingUnits) + "U\n";
|
ret += "Batt: " + getBatteryLevel();
|
||||||
ret += "Batt: " + getPumpStatusData().batteryRemaining + "\n";
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -830,17 +816,18 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
@Override
|
@Override
|
||||||
public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
|
public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
|
||||||
long rileyLinkInitializationTimeout = 3 * 60 * 1000L; // 3 minutes
|
long rileyLinkInitializationTimeout = 3 * 60 * 1000L; // 3 minutes
|
||||||
if (podStateManager.isPodRunning() && podStateManager.getLastSuccessfulCommunication() != null) { // Null check for backwards compatibility
|
if (podStateManager.isPodActivationCompleted() && podStateManager.getLastSuccessfulCommunication() != null) { // Null check for backwards compatibility
|
||||||
if (podStateManager.getLastSuccessfulCommunication().getMillis() + unreachableTimeoutMilliseconds < System.currentTimeMillis()) {
|
if (podStateManager.getLastSuccessfulCommunication().getMillis() + unreachableTimeoutMilliseconds < System.currentTimeMillis()) {
|
||||||
|
// TODO update comment
|
||||||
// We exceeded the alert threshold, and either our last command failed or we cannot reach the RL
|
// We exceeded the alert threshold, and either our last command failed or we cannot reach the RL
|
||||||
// We should show an alert
|
// We should show an alert
|
||||||
return (podStateManager.getLastFailedCommunication() != null && podStateManager.getLastSuccessfulCommunication().isBefore(podStateManager.getLastFailedCommunication())) ||
|
// Don't trigger an alert when we exceeded the thresholds, but the last communication was successful & the RL is reachable
|
||||||
|
// This happens when we simply didn't need to send any commands to the pump
|
||||||
|
return !podStateManager.isPodRunning() ||
|
||||||
|
(podStateManager.getLastFailedCommunication() != null && podStateManager.getLastSuccessfulCommunication().isBefore(podStateManager.getLastFailedCommunication())) ||
|
||||||
rileyLinkServiceData.rileyLinkServiceState.isError() ||
|
rileyLinkServiceData.rileyLinkServiceState.isError() ||
|
||||||
// The below clause is a hack for working around the RL service state forever staying in connecting state on startup if the RL is switched off / unreachable
|
// The below clause is a hack for working around the RL service state forever staying in connecting state on startup if the RL is switched off / unreachable
|
||||||
(rileyLinkServiceData.getRileyLinkServiceState().isConnecting() && rileyLinkServiceData.getLastServiceStateChange() + rileyLinkInitializationTimeout < System.currentTimeMillis());
|
(rileyLinkServiceData.getRileyLinkServiceState().isConnecting() && rileyLinkServiceData.getLastServiceStateChange() + rileyLinkInitializationTimeout < System.currentTimeMillis());
|
||||||
|
|
||||||
// Don't trigger an alert when we exceeded the thresholds, but the last communication was successful & the RL is reachable
|
|
||||||
// This happens when we simply didn't need to send any commands to the pump
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,6 +862,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
rxBus.send(new EventOmnipodRefreshButtonState(enabled));
|
rxBus.send(new EventOmnipodRefreshButtonState(enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME strange
|
||||||
private void initializePump(boolean realInit) {
|
private void initializePump(boolean realInit) {
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
|
@ -937,16 +925,8 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
sp.putLong(statsKey, currentCount);
|
sp.putLong(statsKey, currentCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TempBasalPair readTBR() {
|
protected TemporaryBasal readTBR() {
|
||||||
// TODO we can do it like this or read status from pod ??
|
return activePlugin.getActiveTreatments().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (omnipodPumpStatus.tempBasalEnd < System.currentTimeMillis()) {
|
|
||||||
// TBR done
|
|
||||||
omnipodPumpStatus.clearTemporaryBasal();
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return omnipodPumpStatus.getTemporaryBasal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void finishAction(String overviewKey) {
|
protected void finishAction(String overviewKey) {
|
||||||
|
|
|
@ -2,9 +2,11 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule;
|
||||||
|
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
|
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class BasalSchedule {
|
public class BasalSchedule {
|
||||||
private final List<BasalScheduleEntry> entries;
|
private final List<BasalScheduleEntry> entries;
|
||||||
|
@ -15,7 +17,7 @@ public class BasalSchedule {
|
||||||
} else if (!entries.get(0).getStartTime().isEqual(Duration.ZERO)) {
|
} else if (!entries.get(0).getStartTime().isEqual(Duration.ZERO)) {
|
||||||
throw new IllegalArgumentException("First basal schedule entry should have 0 offset");
|
throw new IllegalArgumentException("First basal schedule entry should have 0 offset");
|
||||||
}
|
}
|
||||||
this.entries = entries;
|
this.entries = new ArrayList<>(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double rateAt(Duration offset) {
|
public double rateAt(Duration offset) {
|
||||||
|
@ -91,6 +93,17 @@ public class BasalSchedule {
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
BasalSchedule that = (BasalSchedule) o;
|
||||||
|
return entries.equals(that.entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int hashCode() {
|
||||||
|
return Objects.hash(entries);
|
||||||
|
}
|
||||||
|
|
||||||
public static class BasalScheduleDurationEntry {
|
public static class BasalScheduleDurationEntry {
|
||||||
private final double rate;
|
private final double rate;
|
||||||
private final Duration duration;
|
private final Duration duration;
|
||||||
|
|
|
@ -2,6 +2,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule;
|
||||||
|
|
||||||
import org.joda.time.Duration;
|
import org.joda.time.Duration;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
|
|
||||||
public class BasalScheduleEntry {
|
public class BasalScheduleEntry {
|
||||||
|
@ -37,4 +39,16 @@ public class BasalScheduleEntry {
|
||||||
", startTime=" + startTime.getStandardSeconds() + "s" +
|
", startTime=" + startTime.getStandardSeconds() + "s" +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
BasalScheduleEntry that = (BasalScheduleEntry) o;
|
||||||
|
return Double.compare(that.rate, rate) == 0 &&
|
||||||
|
Objects.equals(startTime, that.startTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public int hashCode() {
|
||||||
|
return Objects.hash(rate, startTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedu
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmniCRC;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmniCRC;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
|
|
||||||
|
// TODO add nullchecks on some setters
|
||||||
public abstract class PodStateManager {
|
public abstract class PodStateManager {
|
||||||
|
|
||||||
private final AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
|
|
|
@ -1,110 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.driver;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by andy on 4.8.2019
|
|
||||||
*/
|
|
||||||
@Singleton
|
|
||||||
@Deprecated
|
|
||||||
public class OmnipodPumpStatus extends PumpStatus {
|
|
||||||
// TODO remove all fields that can also be obtained via PodStateManager
|
|
||||||
// We can probably get rid of this class altogether
|
|
||||||
|
|
||||||
private final SP sp;
|
|
||||||
|
|
||||||
public boolean inPreInit = true;
|
|
||||||
|
|
||||||
// statuses
|
|
||||||
public double currentBasal = 0;
|
|
||||||
public long tempBasalStart;
|
|
||||||
public long tempBasalEnd;
|
|
||||||
public Double tempBasalAmount = 0.0d;
|
|
||||||
public Integer tempBasalLength;
|
|
||||||
public long tempBasalPumpId;
|
|
||||||
public PumpType pumpType;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public OmnipodPumpStatus(SP sp) {
|
|
||||||
super(PumpType.Insulet_Omnipod);
|
|
||||||
this.sp = sp;
|
|
||||||
initSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initSettings() {
|
|
||||||
this.activeProfileName = "";
|
|
||||||
this.reservoirRemainingUnits = 75d;
|
|
||||||
this.batteryRemaining = 75;
|
|
||||||
this.lastConnection = sp.getLong(OmnipodConst.Statistics.LastGoodPumpCommunicationTime, 0L);
|
|
||||||
this.pumpType = PumpType.Insulet_Omnipod;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getErrorInfo() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearTemporaryBasal() {
|
|
||||||
this.tempBasalStart = 0L;
|
|
||||||
this.tempBasalEnd = 0L;
|
|
||||||
this.tempBasalAmount = 0.0d;
|
|
||||||
this.tempBasalLength = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public TempBasalPair getTemporaryBasal() {
|
|
||||||
TempBasalPair tbr = new TempBasalPair();
|
|
||||||
tbr.setDurationMinutes(tempBasalLength);
|
|
||||||
tbr.setInsulinRate(tempBasalAmount);
|
|
||||||
tbr.setStartTime(tempBasalStart);
|
|
||||||
tbr.setEndTime(tempBasalEnd);
|
|
||||||
|
|
||||||
return tbr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "OmnipodPumpStatus{" +
|
|
||||||
"inPreInit=" + inPreInit +
|
|
||||||
", tempBasalStart=" + tempBasalStart +
|
|
||||||
", tempBasalEnd=" + tempBasalEnd +
|
|
||||||
", tempBasalAmount=" + tempBasalAmount +
|
|
||||||
", tempBasalLength=" + tempBasalLength +
|
|
||||||
", lastDataTime=" + lastDataTime +
|
|
||||||
", lastConnection=" + lastConnection +
|
|
||||||
", previousConnection=" + previousConnection +
|
|
||||||
", lastBolusTime=" + lastBolusTime +
|
|
||||||
", lastBolusAmount=" + lastBolusAmount +
|
|
||||||
", activeProfileName='" + activeProfileName + '\'' +
|
|
||||||
", reservoirRemainingUnits=" + reservoirRemainingUnits +
|
|
||||||
", reservoirFullUnits=" + reservoirFullUnits +
|
|
||||||
", batteryRemaining=" + batteryRemaining +
|
|
||||||
", batteryVoltage=" + batteryVoltage +
|
|
||||||
", iob='" + iob + '\'' +
|
|
||||||
", dailyTotalUnits=" + dailyTotalUnits +
|
|
||||||
", maxDailyTotalUnits='" + maxDailyTotalUnits + '\'' +
|
|
||||||
", validBasalRateProfileSelectedOnPump=" + validBasalRateProfileSelectedOnPump +
|
|
||||||
", pumpType=" + pumpType +
|
|
||||||
", profileStore=" + profileStore +
|
|
||||||
", units='" + units + '\'' +
|
|
||||||
", pumpStatusType=" + pumpStatusType +
|
|
||||||
", basalsByHour=" + Arrays.toString(basalsByHour) +
|
|
||||||
", currentBasal=" + currentBasal +
|
|
||||||
", tempBasalInProgress=" + tempBasalInProgress +
|
|
||||||
", tempBasalRatio=" + tempBasalRatio +
|
|
||||||
", tempBasalRemainMin=" + tempBasalRemainMin +
|
|
||||||
", tempBasalStart=" + tempBasalStart +
|
|
||||||
", pumpType=" + pumpType +
|
|
||||||
"} ";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,7 +35,6 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.R;
|
import info.nightscout.androidaps.plugins.pump.omnipod.R;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
|
||||||
|
@ -68,7 +67,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedule;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedule;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleEntry;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleEntry;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
|
@ -88,7 +86,6 @@ public class AapsOmnipodManager implements IOmnipodManager {
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
private final ActivePluginProvider activePlugin;
|
private final ActivePluginProvider activePlugin;
|
||||||
private final OmnipodPumpStatus pumpStatus;
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final OmnipodManager delegate;
|
private final OmnipodManager delegate;
|
||||||
|
@ -104,7 +101,6 @@ public class AapsOmnipodManager implements IOmnipodManager {
|
||||||
@Inject
|
@Inject
|
||||||
public AapsOmnipodManager(OmnipodCommunicationManager communicationService,
|
public AapsOmnipodManager(OmnipodCommunicationManager communicationService,
|
||||||
PodStateManager podStateManager,
|
PodStateManager podStateManager,
|
||||||
OmnipodPumpStatus pumpStatus,
|
|
||||||
OmnipodUtil omnipodUtil,
|
OmnipodUtil omnipodUtil,
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBus,
|
||||||
|
@ -124,7 +120,6 @@ public class AapsOmnipodManager implements IOmnipodManager {
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
this.activePlugin = activePlugin;
|
this.activePlugin = activePlugin;
|
||||||
this.pumpStatus = pumpStatus;
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.databaseHelper = databaseHelper;
|
this.databaseHelper = databaseHelper;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
|
@ -391,12 +386,6 @@ public class AapsOmnipodManager implements IOmnipodManager {
|
||||||
|
|
||||||
long pumpId = addSuccessToHistory(time, PodHistoryEntryType.SetTemporaryBasal, tempBasalPair);
|
long pumpId = addSuccessToHistory(time, PodHistoryEntryType.SetTemporaryBasal, tempBasalPair);
|
||||||
|
|
||||||
pumpStatus.tempBasalStart = time;
|
|
||||||
pumpStatus.tempBasalAmount = tempBasalPair.getInsulinRate();
|
|
||||||
pumpStatus.tempBasalLength = tempBasalPair.getDurationMinutes();
|
|
||||||
pumpStatus.tempBasalEnd = DateTimeUtil.getTimeInFutureFromMinutes(time, tempBasalPair.getDurationMinutes());
|
|
||||||
pumpStatus.tempBasalPumpId = pumpId;
|
|
||||||
|
|
||||||
TemporaryBasal tempStart = new TemporaryBasal(injector) //
|
TemporaryBasal tempStart = new TemporaryBasal(injector) //
|
||||||
.date(time) //
|
.date(time) //
|
||||||
.duration(tempBasalPair.getDurationMinutes()) //
|
.duration(tempBasalPair.getDurationMinutes()) //
|
||||||
|
@ -558,7 +547,6 @@ public class AapsOmnipodManager implements IOmnipodManager {
|
||||||
TemporaryBasal temporaryBasal = new TemporaryBasal(injector) //
|
TemporaryBasal temporaryBasal = new TemporaryBasal(injector) //
|
||||||
.date(time) //
|
.date(time) //
|
||||||
.duration(0) //
|
.duration(0) //
|
||||||
.pumpId(pumpStatus.tempBasalPumpId)
|
|
||||||
.source(Source.PUMP);
|
.source(Source.PUMP);
|
||||||
|
|
||||||
plugin.addToHistoryTempBasal(temporaryBasal);
|
plugin.addToHistoryTempBasal(temporaryBasal);
|
||||||
|
@ -716,7 +704,7 @@ public class AapsOmnipodManager implements IOmnipodManager {
|
||||||
return resourceHelper.gs(id, args);
|
return resourceHelper.gs(id, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BasalSchedule mapProfileToBasalSchedule(Profile profile) {
|
public static BasalSchedule mapProfileToBasalSchedule(Profile profile) {
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
throw new IllegalArgumentException("Profile can not be null");
|
throw new IllegalArgumentException("Profile can not be null");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,34 +1,26 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm;
|
package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AapsPodStateManager extends PodStateManager {
|
public class AapsPodStateManager extends PodStateManager {
|
||||||
private final AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final OmnipodPumpStatus omnipodPumpStatus;
|
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AapsPodStateManager(AAPSLogger aapsLogger, SP sp, OmnipodPumpStatus omnipodPumpStatus,
|
public AapsPodStateManager(AAPSLogger aapsLogger, SP sp, RxBusWrapper rxBus) {
|
||||||
RxBusWrapper rxBus) {
|
|
||||||
super(aapsLogger);
|
super(aapsLogger);
|
||||||
|
|
||||||
if (aapsLogger == null) {
|
if (aapsLogger == null) {
|
||||||
|
@ -37,16 +29,12 @@ public class AapsPodStateManager extends PodStateManager {
|
||||||
if (sp == null) {
|
if (sp == null) {
|
||||||
throw new IllegalArgumentException("sp can not be null");
|
throw new IllegalArgumentException("sp can not be null");
|
||||||
}
|
}
|
||||||
if (omnipodPumpStatus == null) {
|
|
||||||
throw new IllegalArgumentException("omnipodPumpStatus can not be null");
|
|
||||||
}
|
|
||||||
if (rxBus == null) {
|
if (rxBus == null) {
|
||||||
throw new IllegalArgumentException("rxBus can not be null");
|
throw new IllegalArgumentException("rxBus can not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.omnipodPumpStatus = omnipodPumpStatus;
|
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,44 +50,11 @@ public class AapsPodStateManager extends PodStateManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void notifyPodStateChanged() {
|
protected void notifyPodStateChanged() {
|
||||||
if (!hasPodState()) {
|
aapsLogger.debug(LTag.PUMP, "Pod State changed. Sending events.");
|
||||||
omnipodPumpStatus.lastBolusTime = null;
|
|
||||||
omnipodPumpStatus.lastBolusAmount = null;
|
|
||||||
omnipodPumpStatus.reservoirRemainingUnits = 0.0;
|
|
||||||
// TODO this does not seem to set the pump status to suspended anymore
|
|
||||||
// Also, verify that AAPS is aware that no insulin is delivered anymore at this point
|
|
||||||
omnipodPumpStatus.pumpStatusType = PumpStatusType.Suspended;
|
|
||||||
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
|
||||||
} else {
|
|
||||||
Date lastBolusStartTime = getLastBolusStartTime() == null ? null : getLastBolusStartTime().toDate();
|
|
||||||
Double lastBolusAmount = getLastBolusAmount();
|
|
||||||
|
|
||||||
// Update other info: last bolus, units remaining, suspended
|
|
||||||
boolean suspended = isSuspended() || !isPodRunning();
|
|
||||||
if (Objects.equals(lastBolusStartTime, omnipodPumpStatus.lastBolusTime) //
|
|
||||||
|| !Objects.equals(lastBolusAmount, omnipodPumpStatus.lastBolusAmount) //
|
|
||||||
|| !isReservoirStatusUpToDate(omnipodPumpStatus, getReservoirLevel())
|
|
||||||
|| suspended != PumpStatusType.Suspended.equals(omnipodPumpStatus.pumpStatusType)) {
|
|
||||||
omnipodPumpStatus.lastBolusTime = lastBolusStartTime;
|
|
||||||
omnipodPumpStatus.lastBolusAmount = lastBolusAmount;
|
|
||||||
omnipodPumpStatus.reservoirRemainingUnits = getReservoirLevel() == null ? 75.0 : getReservoirLevel();
|
|
||||||
|
|
||||||
boolean sendRefreshOverviewEvent = suspended != PumpStatusType.Suspended.equals(omnipodPumpStatus.pumpStatusType);
|
|
||||||
// TODO this does not seem to set the pump status to suspended anymore
|
|
||||||
// Also, verify that AAPS is aware that no insulin is delivered anymore at this point
|
|
||||||
omnipodPumpStatus.pumpStatusType = suspended ? PumpStatusType.Suspended : PumpStatusType.Running;
|
|
||||||
|
|
||||||
if (sendRefreshOverviewEvent) {
|
|
||||||
sendEvent(new EventRefreshOverview("Omnipod Pump", false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendEvent(new EventOmnipodPumpValuesChanged());
|
sendEvent(new EventOmnipodPumpValuesChanged());
|
||||||
}
|
// TODO is this necessary?
|
||||||
|
sendEvent(new EventRefreshOverview("Omnipod Pump", true));
|
||||||
private static boolean isReservoirStatusUpToDate(OmnipodPumpStatus pumpStatus, Double unitsRemaining) {
|
|
||||||
double expectedUnitsRemaining = unitsRemaining == null ? 75.0 : unitsRemaining;
|
|
||||||
return Math.abs(expectedUnitsRemaining - pumpStatus.reservoirRemainingUnits) < 0.000001;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendEvent(Event event) {
|
private void sendEvent(Event event) {
|
||||||
|
|
|
@ -15,27 +15,23 @@ public class OmnipodUIComm {
|
||||||
|
|
||||||
private final HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
private final AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
private final OmnipodUIPostprocessor omnipodUIPostprocessor;
|
|
||||||
private final IOmnipodManager omnipodCommunicationManager;
|
private final IOmnipodManager omnipodCommunicationManager;
|
||||||
private RileyLinkUtil rileyLinkUtil;
|
private RileyLinkUtil rileyLinkUtil;
|
||||||
|
|
||||||
public OmnipodUIComm(
|
public OmnipodUIComm(
|
||||||
HasAndroidInjector injector,
|
HasAndroidInjector injector,
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
OmnipodUIPostprocessor omnipodUIPostprocessor,
|
|
||||||
IOmnipodManager omnipodCommunicationManager,
|
IOmnipodManager omnipodCommunicationManager,
|
||||||
RileyLinkUtil rileyLinkUtil
|
RileyLinkUtil rileyLinkUtil
|
||||||
) {
|
) {
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.omnipodUIPostprocessor = omnipodUIPostprocessor;
|
|
||||||
this.omnipodCommunicationManager = omnipodCommunicationManager;
|
this.omnipodCommunicationManager = omnipodCommunicationManager;
|
||||||
this.rileyLinkUtil = rileyLinkUtil;
|
this.rileyLinkUtil = rileyLinkUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public OmnipodUITask executeCommand(OmnipodCommandType commandType, Object... parameters) {
|
public OmnipodUITask executeCommand(OmnipodCommandType commandType, Object... parameters) {
|
||||||
|
|
||||||
aapsLogger.warn(LTag.PUMP, "Execute Command: " + commandType.name());
|
aapsLogger.warn(LTag.PUMP, "Execute Command: " + commandType.name());
|
||||||
|
|
||||||
OmnipodUITask task = new OmnipodUITask(injector, commandType, parameters);
|
OmnipodUITask task = new OmnipodUITask(injector, commandType, parameters);
|
||||||
|
@ -48,10 +44,7 @@ public class OmnipodUIComm {
|
||||||
aapsLogger.warn(LTag.PUMP, "Reply not received for " + commandType);
|
aapsLogger.warn(LTag.PUMP, "Reply not received for " + commandType);
|
||||||
}
|
}
|
||||||
|
|
||||||
task.postProcess(omnipodUIPostprocessor);
|
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by andy on 4.8.2019
|
|
||||||
*/
|
|
||||||
// TODO remove once OmnipodPumpStatus has been removed
|
|
||||||
@Singleton
|
|
||||||
public class OmnipodUIPostprocessor {
|
|
||||||
private final AAPSLogger aapsLogger;
|
|
||||||
private final OmnipodPumpStatus pumpStatus;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public OmnipodUIPostprocessor(AAPSLogger aapsLogger, OmnipodPumpStatus pumpStatus) {
|
|
||||||
this.aapsLogger = aapsLogger;
|
|
||||||
this.pumpStatus = pumpStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is mostly intended for command that return certain statuses (Remaining Insulin, ...), and
|
|
||||||
// where responses won't be directly used
|
|
||||||
public void postProcessData(OmnipodUITask uiTask) {
|
|
||||||
|
|
||||||
switch (uiTask.commandType) {
|
|
||||||
case SetBolus:
|
|
||||||
if (uiTask.returnData != null) {
|
|
||||||
|
|
||||||
PumpEnactResult result = uiTask.returnData;
|
|
||||||
|
|
||||||
DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo) uiTask.getObjectFromParameters(0);
|
|
||||||
|
|
||||||
if (result.success) {
|
|
||||||
boolean isSmb = detailedBolusInfo.isSMB;
|
|
||||||
|
|
||||||
if (!isSmb) {
|
|
||||||
pumpStatus.lastBolusAmount = detailedBolusInfo.insulin;
|
|
||||||
pumpStatus.lastBolusTime = new Date();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CancelTemporaryBasal:
|
|
||||||
pumpStatus.tempBasalStart = 0;
|
|
||||||
pumpStatus.tempBasalEnd = 0;
|
|
||||||
pumpStatus.tempBasalAmount = null;
|
|
||||||
pumpStatus.tempBasalLength = null;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
aapsLogger.debug(LTag.PUMP, "Post-processing not implemented for {}.", uiTask.commandType.name());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,59 +8,36 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.IOmnipodManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.IOmnipodManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodResponseType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodResponseType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 4.8.2019
|
* Created by andy on 4.8.2019
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class OmnipodUITask {
|
public class OmnipodUITask {
|
||||||
|
|
||||||
@Inject RxBusWrapper rxBus;
|
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
|
||||||
@Inject OmnipodUtil omnipodUtil;
|
|
||||||
|
|
||||||
private final HasAndroidInjector injector;
|
|
||||||
|
|
||||||
public OmnipodCommandType commandType;
|
public OmnipodCommandType commandType;
|
||||||
public PumpEnactResult returnData;
|
public PumpEnactResult returnData;
|
||||||
private String errorDescription;
|
|
||||||
private Object[] parameters;
|
private Object[] parameters;
|
||||||
public PodResponseType responseType;
|
public PodResponseType responseType;
|
||||||
public Object returnDataObject;
|
public Object returnDataObject;
|
||||||
|
|
||||||
|
|
||||||
public OmnipodUITask(HasAndroidInjector injector, OmnipodCommandType commandType) {
|
|
||||||
this.injector = injector;
|
|
||||||
this.injector.androidInjector().inject(this);
|
|
||||||
this.commandType = commandType;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public OmnipodUITask(HasAndroidInjector injector, OmnipodCommandType commandType, Object... parameters) {
|
public OmnipodUITask(HasAndroidInjector injector, OmnipodCommandType commandType, Object... parameters) {
|
||||||
this.injector = injector;
|
injector.androidInjector().inject(this);
|
||||||
this.injector.androidInjector().inject(this);
|
|
||||||
this.commandType = commandType;
|
this.commandType = commandType;
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void execute(IOmnipodManager communicationManager) {
|
public void execute(IOmnipodManager communicationManager) {
|
||||||
|
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ In execute. {}", commandType);
|
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ In execute. {}", commandType);
|
||||||
|
|
||||||
switch (commandType) {
|
switch (commandType) {
|
||||||
|
|
||||||
case PairAndPrimePod:
|
case PairAndPrimePod:
|
||||||
returnData = communicationManager.initPod((PodInitActionType) parameters[0], (PodInitReceiver) parameters[1], null);
|
returnData = communicationManager.initPod((PodInitActionType) parameters[0], (PodInitReceiver) parameters[1], null);
|
||||||
break;
|
break;
|
||||||
|
@ -149,75 +126,26 @@ public class OmnipodUITask {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TempBasalPair getTBRSettings() {
|
private TempBasalPair getTBRSettings() {
|
||||||
return new TempBasalPair(getDoubleFromParameters(0), //
|
return new TempBasalPair(getDoubleFromParameters(0), //
|
||||||
false, //
|
false, //
|
||||||
getIntegerFromParameters(1));
|
getIntegerFromParameters(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Float getFloatFromParameters(int index) {
|
|
||||||
return (Float) parameters[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getObjectFromParameters(int index) {
|
|
||||||
return parameters[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Double getDoubleFromParameters(int index) {
|
public Double getDoubleFromParameters(int index) {
|
||||||
return (Double) parameters[index];
|
return (Double) parameters[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getBooleanFromParameters(int index) {
|
|
||||||
return (boolean) parameters[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIntegerFromParameters(int index) {
|
public Integer getIntegerFromParameters(int index) {
|
||||||
return (Integer) parameters[index];
|
return (Integer) parameters[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public <T> T getResult() {
|
public <T> T getResult() {
|
||||||
return (T) returnData;
|
return (T) returnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isReceived() {
|
public boolean isReceived() {
|
||||||
return (returnData != null || errorDescription != null);
|
return returnData != null;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME remove once OmnipodPumpStatus has been removed
|
|
||||||
public void postProcess(OmnipodUIPostprocessor postprocessor) {
|
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ postProcess. {}", commandType);
|
|
||||||
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
|
||||||
|
|
||||||
if (responseType == PodResponseType.Data || responseType == PodResponseType.Acknowledgment) {
|
|
||||||
postprocessor.postProcessData(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
|
||||||
|
|
||||||
if (!responseType.isError()) {
|
|
||||||
omnipodPumpStatus.setLastCommunicationToNow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean hasData() {
|
|
||||||
return (responseType == PodResponseType.Data || responseType == PodResponseType.Acknowledgment);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Object getParameter(int index) {
|
|
||||||
return parameters[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public PodResponseType getResponseType() {
|
|
||||||
return this.responseType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasCommandSuccessful() {
|
public boolean wasCommandSuccessful() {
|
||||||
|
@ -226,6 +154,4 @@ public class OmnipodUITask {
|
||||||
}
|
}
|
||||||
return returnData.success;
|
return returnData.success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.events
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by andy on 04.06.2018.
|
|
||||||
*/
|
|
||||||
// FIXME can be removed, we should just use EventOmnipodPumpValuesChanged
|
|
||||||
class EventOmnipodAcknowledgeAlertsChanged : Event()
|
|
|
@ -24,8 +24,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunication
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIPostprocessor;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +37,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
|
|
||||||
@Inject OmnipodPumpPlugin omnipodPumpPlugin;
|
@Inject OmnipodPumpPlugin omnipodPumpPlugin;
|
||||||
@Inject OmnipodUtil omnipodUtil;
|
@Inject OmnipodUtil omnipodUtil;
|
||||||
@Inject OmnipodUIPostprocessor omnipodUIPostprocessor;
|
|
||||||
@Inject PodStateManager podStateManager;
|
@Inject PodStateManager podStateManager;
|
||||||
@Inject DatabaseHelperInterface databaseHelper;
|
@Inject DatabaseHelperInterface databaseHelper;
|
||||||
@Inject AapsOmnipodManager aapsOmnipodManager;
|
@Inject AapsOmnipodManager aapsOmnipodManager;
|
||||||
|
@ -73,31 +70,18 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
||||||
return RileyLinkEncodingType.Manchester;
|
return RileyLinkEncodingType.Manchester;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* If you have customized RileyLinkServiceData you need to override this
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void initRileyLinkServiceData() {
|
public void initRileyLinkServiceData() {
|
||||||
|
|
||||||
rileyLinkServiceData.targetDevice = RileyLinkTargetDevice.Omnipod;
|
rileyLinkServiceData.targetDevice = RileyLinkTargetDevice.Omnipod;
|
||||||
rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod;
|
rileyLinkServiceData.rileyLinkTargetFrequency = RileyLinkTargetFrequency.Omnipod;
|
||||||
|
|
||||||
// get most recently used RileyLink address
|
|
||||||
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
rileyLinkServiceData.rileylinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, "");
|
||||||
|
|
||||||
rfspy.startReader();
|
rfspy.startReader();
|
||||||
|
|
||||||
initializeErosOmnipodManager();
|
omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, aapsOmnipodManager, rileyLinkUtil);
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkOmnipodService newly constructed");
|
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkOmnipodService newly constructed");
|
||||||
//omnipodPumpStatus = (OmnipodPumpStatus) omnipodPumpPlugin.getPumpStatusData();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeErosOmnipodManager() {
|
|
||||||
if (omnipodUIComm == null) {
|
|
||||||
omnipodUIComm = new OmnipodUIComm(injector, aapsLogger, omnipodUIPostprocessor, aapsOmnipodManager, rileyLinkUtil);
|
|
||||||
}
|
|
||||||
rxBus.send(new EventOmnipodPumpValuesChanged());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public OmnipodUIComm getDeviceCommandExecutor() {
|
public OmnipodUIComm getDeviceCommandExecutor() {
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule;
|
||||||
|
|
||||||
|
import org.joda.time.Duration;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
|
||||||
|
public class BasalScheduleTest {
|
||||||
|
@Test
|
||||||
|
public void testRateAt() {
|
||||||
|
List<BasalScheduleEntry> entries = new ArrayList<>();
|
||||||
|
entries.add(new BasalScheduleEntry(1.0d, Duration.ZERO));
|
||||||
|
entries.add(new BasalScheduleEntry(2.0d, Duration.standardHours(6)));
|
||||||
|
entries.add(new BasalScheduleEntry(3.0d, Duration.standardHours(7)));
|
||||||
|
entries.add(new BasalScheduleEntry(4.0d, Duration.standardHours(20)));
|
||||||
|
BasalSchedule schedule = new BasalSchedule(entries);
|
||||||
|
|
||||||
|
assertEquals(1.0d, schedule.rateAt(Duration.ZERO), 0.00001);
|
||||||
|
assertEquals(1.0d, schedule.rateAt(Duration.standardHours(6).minus(Duration.standardSeconds(1))), 0.00001);
|
||||||
|
assertEquals(2.0d, schedule.rateAt(Duration.standardHours(6)), 0.00001);
|
||||||
|
assertEquals(2.0d, schedule.rateAt(Duration.standardHours(6).plus(Duration.standardMinutes(30))), 0.00001);
|
||||||
|
assertEquals(2.0d, schedule.rateAt(Duration.standardHours(7).minus(Duration.standardSeconds(1))), 0.00001);
|
||||||
|
assertEquals(3.0d, schedule.rateAt(Duration.standardHours(7)), 0.00001);
|
||||||
|
assertEquals(3.0d, schedule.rateAt(Duration.standardHours(19)), 0.00001);
|
||||||
|
assertEquals(3.0d, schedule.rateAt(Duration.standardHours(20).minus(Duration.standardSeconds(1))), 0.00001);
|
||||||
|
assertEquals(4.0d, schedule.rateAt(Duration.standardHours(20)), 0.00001);
|
||||||
|
assertEquals(4.0d, schedule.rateAt(Duration.standardHours(24).minus(Duration.standardSeconds(1))), 0.00001);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEquals() {
|
||||||
|
List<BasalScheduleEntry> entries = new ArrayList<>();
|
||||||
|
entries.add(new BasalScheduleEntry(1.0d, Duration.ZERO));
|
||||||
|
entries.add(new BasalScheduleEntry(2.0d, Duration.standardHours(6)));
|
||||||
|
entries.add(new BasalScheduleEntry(3.0d, Duration.standardHours(7)));
|
||||||
|
entries.add(new BasalScheduleEntry(4.0d, Duration.standardHours(20)));
|
||||||
|
BasalSchedule schedule = new BasalSchedule(entries);
|
||||||
|
|
||||||
|
List<BasalScheduleEntry> otherEntries = new ArrayList<>();
|
||||||
|
otherEntries.add(new BasalScheduleEntry(1.0d, Duration.ZERO));
|
||||||
|
otherEntries.add(new BasalScheduleEntry(2.0d, Duration.standardHours(6)));
|
||||||
|
otherEntries.add(new BasalScheduleEntry(3.0d, Duration.standardHours(7)));
|
||||||
|
otherEntries.add(new BasalScheduleEntry(4.0d, Duration.standardHours(20)));
|
||||||
|
BasalSchedule otherschedule = new BasalSchedule(otherEntries);
|
||||||
|
|
||||||
|
assertEquals(schedule, otherschedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNotEquals() {
|
||||||
|
List<BasalScheduleEntry> entries = new ArrayList<>();
|
||||||
|
entries.add(new BasalScheduleEntry(1.0d, Duration.ZERO));
|
||||||
|
entries.add(new BasalScheduleEntry(2.0d, Duration.standardHours(6)));
|
||||||
|
entries.add(new BasalScheduleEntry(3.0d, Duration.standardHours(7)));
|
||||||
|
entries.add(new BasalScheduleEntry(4.0d, Duration.standardHours(20)));
|
||||||
|
BasalSchedule schedule = new BasalSchedule(entries);
|
||||||
|
|
||||||
|
List<BasalScheduleEntry> otherEntries = new ArrayList<>();
|
||||||
|
otherEntries.add(new BasalScheduleEntry(1.0d, Duration.ZERO));
|
||||||
|
otherEntries.add(new BasalScheduleEntry(2.0d, Duration.standardHours(6)));
|
||||||
|
otherEntries.add(new BasalScheduleEntry(3.0d, Duration.standardHours(7)));
|
||||||
|
otherEntries.add(new BasalScheduleEntry(4.1d, Duration.standardHours(20)));
|
||||||
|
BasalSchedule otherschedule = new BasalSchedule(otherEntries);
|
||||||
|
|
||||||
|
assertNotEquals(schedule, otherschedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNotEquals2() {
|
||||||
|
List<BasalScheduleEntry> entries = new ArrayList<>();
|
||||||
|
entries.add(new BasalScheduleEntry(1.0d, Duration.ZERO));
|
||||||
|
entries.add(new BasalScheduleEntry(2.0d, Duration.standardHours(6)));
|
||||||
|
entries.add(new BasalScheduleEntry(3.0d, Duration.standardHours(7)));
|
||||||
|
entries.add(new BasalScheduleEntry(4.0d, Duration.standardHours(20)));
|
||||||
|
BasalSchedule schedule = new BasalSchedule(entries);
|
||||||
|
|
||||||
|
List<BasalScheduleEntry> otherEntries = new ArrayList<>();
|
||||||
|
otherEntries.add(new BasalScheduleEntry(1.0d, Duration.ZERO));
|
||||||
|
otherEntries.add(new BasalScheduleEntry(2.0d, Duration.standardHours(6)));
|
||||||
|
otherEntries.add(new BasalScheduleEntry(3.0d, Duration.standardHours(7)));
|
||||||
|
BasalSchedule otherschedule = new BasalSchedule(otherEntries);
|
||||||
|
|
||||||
|
assertNotEquals(schedule, otherschedule);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,7 +14,6 @@ import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsPodStateManager;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
|
@ -24,7 +23,6 @@ import static org.junit.Assert.assertEquals;
|
||||||
public class AapsPodStateManagerTest {
|
public class AapsPodStateManagerTest {
|
||||||
@Mock AAPSLogger aapsLogger;
|
@Mock AAPSLogger aapsLogger;
|
||||||
@Mock SP sp;
|
@Mock SP sp;
|
||||||
@Mock OmnipodPumpStatus omnipodPumpStatus;
|
|
||||||
RxBusWrapper rxBus = new RxBusWrapper();
|
RxBusWrapper rxBus = new RxBusWrapper();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -36,7 +34,7 @@ public class AapsPodStateManagerTest {
|
||||||
|
|
||||||
DateTimeUtils.setCurrentMillisFixed(now.getMillis());
|
DateTimeUtils.setCurrentMillisFixed(now.getMillis());
|
||||||
|
|
||||||
AapsPodStateManager podStateManager = new AapsPodStateManager(aapsLogger, sp, omnipodPumpStatus, rxBus);
|
AapsPodStateManager podStateManager = new AapsPodStateManager(aapsLogger, sp, rxBus);
|
||||||
podStateManager.initState(0x0);
|
podStateManager.initState(0x0);
|
||||||
podStateManager.setInitializationParameters(0, 0, new FirmwareVersion(1, 1, 1),
|
podStateManager.setInitializationParameters(0, 0, new FirmwareVersion(1, 1, 1),
|
||||||
new FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS);
|
new FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
|
@ -54,7 +52,7 @@ public class AapsPodStateManagerTest {
|
||||||
|
|
||||||
DateTimeUtils.setCurrentMillisFixed(now.getMillis());
|
DateTimeUtils.setCurrentMillisFixed(now.getMillis());
|
||||||
|
|
||||||
AapsPodStateManager podStateManager = new AapsPodStateManager(aapsLogger, sp, omnipodPumpStatus, rxBus);
|
AapsPodStateManager podStateManager = new AapsPodStateManager(aapsLogger, sp, rxBus);
|
||||||
podStateManager.initState(0x0);
|
podStateManager.initState(0x0);
|
||||||
podStateManager.setInitializationParameters(0, 0, new FirmwareVersion(1, 1, 1),
|
podStateManager.setInitializationParameters(0, 0, new FirmwareVersion(1, 1, 1),
|
||||||
new FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS);
|
new FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
|
@ -77,7 +75,7 @@ public class AapsPodStateManagerTest {
|
||||||
|
|
||||||
DateTimeUtils.setCurrentMillisFixed(now.getMillis());
|
DateTimeUtils.setCurrentMillisFixed(now.getMillis());
|
||||||
|
|
||||||
AapsPodStateManager podStateManager = new AapsPodStateManager(aapsLogger, sp, omnipodPumpStatus, rxBus);
|
AapsPodStateManager podStateManager = new AapsPodStateManager(aapsLogger, sp, rxBus);
|
||||||
podStateManager.initState(0x0);
|
podStateManager.initState(0x0);
|
||||||
podStateManager.setInitializationParameters(0, 0, new FirmwareVersion(1, 1, 1),
|
podStateManager.setInitializationParameters(0, 0, new FirmwareVersion(1, 1, 1),
|
||||||
new FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS);
|
new FirmwareVersion(2, 2, 2), timeZone, PodProgressStatus.ABOVE_FIFTY_UNITS);
|
||||||
|
|
Loading…
Reference in a new issue