- Removing OmnipodManagerAAPS

- new database entry class
This commit is contained in:
Andy Rozman 2019-11-27 22:33:46 +00:00
parent 120243908f
commit 61c67d7390
3 changed files with 9 additions and 123 deletions

View file

@ -37,7 +37,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
} }
public AapsOmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState, OmnipodPumpStatus pumpStatus) { public AapsOmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState, OmnipodPumpStatus pumpStatus) {
delegate = new OmnipodManagerAAPS(communicationService, podState, pumpStatus); delegate = new OmnipodManager(communicationService, podState);
this.pumpStatus = pumpStatus; this.pumpStatus = pumpStatus;
instance = this; instance = this;
} }

View file

@ -1,80 +0,0 @@
package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.DeactivatePodAction;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.OmnipodAction;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
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.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodDbEntry;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodDbEntryType;
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.OmnipodUtil;
import info.nightscout.androidaps.utils.SP;
/**
* Created by andy on 24.11.2019
*/
// TODO this should be used instead of AapsOmnipodManager
public class OmnipodManagerAAPS extends OmnipodManager //implements OmnipodCommunicationManagerInterface
{
public OmnipodManagerAAPS(OmnipodCommunicationService communicationService, PodSessionState podState, OmnipodPumpStatus pumpStatus) {
super(communicationService, podState);
communicationService.setPumpStatus(pumpStatus);
}
public PumpEnactResult deactivatePod(PodInitReceiver podInitReceiver) {
if (podState == null) {
// TODO use string resource
podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, false, "Pod should be paired and primed first");
return new PumpEnactResult().success(false).enacted(false).comment("Pod should be paired and primed first");
}
try {
communicationService.executeAction(new DeactivatePodAction(podState, true));
resetPodStateInternal();
podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, true, null);
} catch (Exception ex) {
// TODO distinguish between certain and uncertain failures
// TODO user friendly error messages (string resources)
podInitReceiver.returnInitTaskStatus(PodInitActionType.DeactivatePodWizardStep, false, "Error communicating with Pod [msg=" + ex.getMessage() + "]");
return new PumpEnactResult().success(false).enacted(false).comment(ex.getMessage());
}
return new PumpEnactResult().success(true).enacted(true);
}
public PumpEnactResult resetPodState() {
resetPodStateInternal();
//addToHistory(System.currentTimeMillis(), PodDbEntryType.ResetPodState, null, null, null, true);
return new PumpEnactResult().success(true).enacted(true);
}
private void resetPodStateInternal() {
podState = null;
SP.remove(OmnipodConst.Prefs.PodState);
OmnipodUtil.setPodSessionState(null);
RxBus.INSTANCE.send(new EventOmnipodPumpValuesChanged());
}
}

View file

@ -9,12 +9,15 @@ public class PodDbEntry implements DbObjectBase {
private long dateTime; private long dateTime;
private PodDbEntryType podDbEntryType; private PodDbEntryType podDbEntryType;
private String shortDescription; private String data;
private String request;
private long dateTimeResponse;
private String response;
private boolean success; private boolean success;
private long pumpId; private long pumpId;
private Boolean successConfirmed;
//private String request;
//private long dateTimeResponse;
//private String response;
public PodDbEntry(PodDbEntryType podDbEntryType) { public PodDbEntry(PodDbEntryType podDbEntryType) {
this.dateTime = System.currentTimeMillis(); this.dateTime = System.currentTimeMillis();
@ -29,15 +32,6 @@ public class PodDbEntry implements DbObjectBase {
generatePumpId(); generatePumpId();
} }
public PodDbEntry(long requestTime, PodDbEntryType podDbEntryType, String shortDescription, String request, Long dateTimeResponse, String response) {
this.dateTime = requestTime;
this.podDbEntryType = podDbEntryType;
this.shortDescription = shortDescription;
this.request = request;
this.dateTimeResponse = dateTimeResponse;
this.response = response;
generatePumpId();
}
public long getDateTime() { public long getDateTime() {
@ -56,29 +50,6 @@ public class PodDbEntry implements DbObjectBase {
this.podDbEntryType = podDbEntryType; this.podDbEntryType = podDbEntryType;
} }
public String getRequest() {
return request;
}
public void setRequest(String request) {
this.request = request;
}
public long getDateTimeResponse() {
return dateTimeResponse;
}
public void setDateTimeResponse(long dateTimeResponse) {
this.dateTimeResponse = dateTimeResponse;
}
public String getResponse() {
return response;
}
public void setResponse(String response) {
this.response = response;
}
@Override @Override
public long getDate() { public long getDate() {
@ -92,13 +63,8 @@ public class PodDbEntry implements DbObjectBase {
private void generatePumpId() { private void generatePumpId() {
// TODO // TODO
// yyyymmddhhMMssxx (time and xx is code of podDbEntryType)
} }
public String getShortDescription() {
return shortDescription;
}
public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
}
} }