Introduce AapsOmnipodManager to match OmnipodCommunicationManagerInterface interface
This commit is contained in:
parent
c6d94284d7
commit
5ac0df4b4b
5 changed files with 134 additions and 56 deletions
|
@ -0,0 +1,125 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
|
||||
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;
|
||||
|
||||
public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||
private final OmnipodManager delegate;
|
||||
|
||||
private static AapsOmnipodManager instance;
|
||||
|
||||
// FIXME this is dirty
|
||||
public static AapsOmnipodManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public AapsOmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState) {
|
||||
delegate = new OmnipodManager(communicationService, podState);
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver) {
|
||||
if (PodInitActionType.PairAndPrimeWizardStep.equals(podInitActionType)) {
|
||||
PumpEnactResult result = delegate.pairAndPrime();
|
||||
podInitReceiver.returnInitTaskStatus(podInitActionType, result.success, (result.success ? null : result.comment));
|
||||
return result;
|
||||
} else if(PodInitActionType.FillCannulaWizardStep.equals(podInitActionType)) {
|
||||
// FIXME we need a basal profile here
|
||||
PumpEnactResult result = delegate.insertCannula(null);
|
||||
podInitReceiver.returnInitTaskStatus(podInitActionType, result.success, (result.success ? null : result.comment));
|
||||
return result;
|
||||
}
|
||||
return new PumpEnactResult().success(false).enacted(false).comment("Illegal PodInitActionType: "+ podInitActionType.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult getPodStatus() {
|
||||
return delegate.getPodStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deactivatePod() {
|
||||
return delegate.deactivatePod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setBasalProfile(Profile basalProfile) {
|
||||
return delegate.setBasalProfile(basalProfile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult resetPodStatus() {
|
||||
return delegate.resetPodState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setBolus(Double amount) {
|
||||
return delegate.bolus(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelBolus() {
|
||||
return delegate.cancelBolus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setTemporaryBasal(TempBasalPair tempBasalPair) {
|
||||
return delegate.setTemporaryBasal(tempBasalPair);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTemporaryBasal() {
|
||||
return delegate.cancelTemporaryBasal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult acknowledgeAlerts() {
|
||||
return delegate.acknowledgeAlerts();
|
||||
}
|
||||
|
||||
// TODO should we add this to the OmnipodCommunicationManager interface?
|
||||
public PumpEnactResult getPodInfo(PodInfoType podInfoType) {
|
||||
return delegate.getPodInfo(podInfoType);
|
||||
}
|
||||
|
||||
// TODO should we add this to the OmnipodCommunicationManager interface?
|
||||
public PumpEnactResult suspendDelivery() {
|
||||
return delegate.suspendDelivery();
|
||||
}
|
||||
|
||||
// TODO should we add this to the OmnipodCommunicationManager interface?
|
||||
public PumpEnactResult resumeDelivery() {
|
||||
return delegate.resumeDelivery();
|
||||
}
|
||||
|
||||
// TODO should we add this to the OmnipodCommunicationManager interface?
|
||||
public PumpEnactResult setTime() {
|
||||
return delegate.setTime();
|
||||
}
|
||||
|
||||
public OmnipodCommunicationService getCommunicationService() {
|
||||
return delegate.getCommunicationService();
|
||||
}
|
||||
|
||||
public DateTime getTime() {
|
||||
return delegate.getTime();
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return delegate.isInitialized();
|
||||
}
|
||||
|
||||
public String getPodStateAsString() {
|
||||
return delegate.getPodStateAsString();
|
||||
}
|
||||
}
|
|
@ -32,25 +32,16 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.SetTe
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
|
||||
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.SetupProgress;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalScheduleMapper;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||
public class OmnipodManager {
|
||||
private final OmnipodCommunicationService communicationService;
|
||||
private PodSessionState podState;
|
||||
private static OmnipodManager instance;
|
||||
|
||||
// FIXME this is dirty
|
||||
public static OmnipodManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public OmnipodManager(OmnipodCommunicationService communicationService, PodSessionState podState) {
|
||||
if (communicationService == null) {
|
||||
|
@ -58,10 +49,8 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
}
|
||||
this.communicationService = communicationService;
|
||||
this.podState = podState;
|
||||
instance = this;
|
||||
}
|
||||
|
||||
|
||||
public PumpEnactResult insertCannula(Profile profile) {
|
||||
if (podState == null || podState.getSetupProgress().isBefore(SetupProgress.PRIMING_FINISHED)) {
|
||||
// TODO use string resource
|
||||
|
@ -88,7 +77,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
|
||||
public PumpEnactResult pairAndPrime() {
|
||||
try {
|
||||
if (podState == null) {
|
||||
|
@ -114,7 +102,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelBolus() {
|
||||
if (!isInitialized()) {
|
||||
return createNotInitializedResult();
|
||||
|
@ -131,12 +118,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podIniReceiver) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult getPodStatus() {
|
||||
if (podState == null) {
|
||||
// TODO use string resource
|
||||
|
@ -155,7 +136,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deactivatePod() {
|
||||
if (podState == null) {
|
||||
// TODO use string resource
|
||||
|
@ -174,7 +154,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setBasalProfile(Profile basalProfile) {
|
||||
if (!isInitialized()) {
|
||||
return createNotInitializedResult();
|
||||
|
@ -193,18 +172,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult resetPodStatus() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setBolus(Double amount) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// TODO rename back
|
||||
public PumpEnactResult resetPodState() {
|
||||
podState = null;
|
||||
SP.remove(OmnipodConst.Prefs.PodState);
|
||||
|
@ -212,7 +179,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
// TODO rename back
|
||||
public PumpEnactResult bolus(Double units) {
|
||||
if (!isInitialized()) {
|
||||
return createNotInitializedResult();
|
||||
|
@ -229,7 +195,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setTemporaryBasal(TempBasalPair tempBasalPair) {
|
||||
if (!isInitialized()) {
|
||||
return createNotInitializedResult();
|
||||
|
@ -248,7 +213,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTemporaryBasal() {
|
||||
if (!isInitialized()) {
|
||||
return createNotInitializedResult();
|
||||
|
@ -265,7 +229,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult acknowledgeAlerts() {
|
||||
if (!isInitialized()) {
|
||||
return createNotInitializedResult();
|
||||
|
@ -299,7 +262,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
// TODO should we add this to the OmnipodCommunicationManager interface?
|
||||
public PumpEnactResult suspendDelivery() {
|
||||
if (!isInitialized()) {
|
||||
return createNotInitializedResult();
|
||||
|
@ -316,7 +278,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
// TODO should we add this to the OmnipodCommunicationManager interface?
|
||||
public PumpEnactResult resumeDelivery() {
|
||||
if (!isInitialized()) {
|
||||
return createNotInitializedResult();
|
||||
|
@ -334,7 +295,6 @@ public class OmnipodManager implements OmnipodCommunicationManagerInterface {
|
|||
return new PumpEnactResult().success(true).enacted(true);
|
||||
}
|
||||
|
||||
// TODO should we add this to the OmnipodCommunicationManager interface?
|
||||
public PumpEnactResult setTime() {
|
||||
if (!isInitialized()) {
|
||||
return createNotInitializedResult();
|
||||
|
|
|
@ -109,7 +109,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
||||
|
||||
if (omnipodCommunicationManager == null) {
|
||||
omnipodCommunicationManager = OmnipodManager.getInstance();
|
||||
omnipodCommunicationManager = AapsOmnipodManager.getInstance();
|
||||
}
|
||||
|
||||
omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager);
|
||||
|
|
|
@ -11,14 +11,7 @@ public interface OmnipodCommunicationManagerInterface {
|
|||
/**
|
||||
* Initialize Pod
|
||||
*/
|
||||
PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podIniReceiver);
|
||||
|
||||
// TODO remove
|
||||
//PumpEnactResult pairAndPrime();
|
||||
|
||||
// TODO remove
|
||||
//PumpEnactResult insertCannula(Profile basalProfile);
|
||||
|
||||
PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver);
|
||||
|
||||
/**
|
||||
* Get Pod Status (is pod running, battery left ?, reservoir, etc)
|
||||
|
|
|
@ -23,7 +23,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
|
|||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodManager;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.AapsOmnipodManager;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||
|
@ -112,7 +112,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
}
|
||||
|
||||
private void initializeErosOmnipodManager() {
|
||||
if(OmnipodManager.getInstance() == null) {
|
||||
if(AapsOmnipodManager.getInstance() == null) {
|
||||
PodSessionState podState = null;
|
||||
if (SP.contains(OmnipodConst.Prefs.PodState)) {
|
||||
try {
|
||||
|
@ -123,9 +123,9 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
LOG.error("Could not deserialize Pod state: " + ex.getClass().getSimpleName() + ": " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
omnipodCommunicationManager = new OmnipodManager(new OmnipodCommunicationService(rfspy), podState);
|
||||
omnipodCommunicationManager = new AapsOmnipodManager(new OmnipodCommunicationService(rfspy), podState);
|
||||
} else {
|
||||
omnipodCommunicationManager = OmnipodManager.getInstance();
|
||||
omnipodCommunicationManager = AapsOmnipodManager.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,8 +137,8 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
|
||||
@Override
|
||||
public RileyLinkCommunicationManager getDeviceCommunicationManager() {
|
||||
if(omnipodCommunicationManager instanceof OmnipodManager) { // Eros
|
||||
return ((OmnipodManager) omnipodCommunicationManager).getCommunicationService();
|
||||
if(omnipodCommunicationManager instanceof AapsOmnipodManager) { // Eros
|
||||
return ((AapsOmnipodManager) omnipodCommunicationManager).getCommunicationService();
|
||||
}
|
||||
// FIXME is this correct for Dash?
|
||||
return (RileyLinkCommunicationManager)omnipodCommunicationManager;
|
||||
|
|
Loading…
Reference in a new issue