diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/AapsOmnipodManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/AapsOmnipodManager.java index 09f5c74668..725f871a9a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/AapsOmnipodManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/AapsOmnipodManager.java @@ -28,18 +28,18 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface } @Override - public PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver) { + public PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, Profile profile) { 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)) { + } else if (PodInitActionType.FillCannulaSetBasalProfileWizardStep.equals(podInitActionType)) { // FIXME we need a basal profile here - PumpEnactResult result = delegate.insertCannula(null); + PumpEnactResult result = delegate.insertCannula(profile); podInitReceiver.returnInitTaskStatus(podInitActionType, result.success, (result.success ? null : result.comment)); return result; } - return new PumpEnactResult().success(false).enacted(false).comment("Illegal PodInitActionType: "+ podInitActionType.name()); + return new PumpEnactResult().success(false).enacted(false).comment("Illegal PodInitActionType: " + podInitActionType.name()); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java index 88f928d10e..f48d7e006d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/OmnipodPumpPlugin.java @@ -51,11 +51,13 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionT import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPodType; 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.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState; 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.service.OmnipodPumpStatus; import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService; +import info.nightscout.androidaps.plugins.pump.omnipod.util.LogReceiver; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; @@ -763,8 +765,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump private CustomAction customActionResetRLConfig = new CustomAction( R.string.medtronic_custom_action_reset_rileylink, OmnipodCustomActionType.ResetRileyLinkConfiguration, true); - protected CustomAction customActionInitPod = new CustomAction( - R.string.omnipod_cmd_init_pod, OmnipodCustomActionType.InitPod, true); + protected CustomAction customActionPairAndPrime = new CustomAction( + R.string.omnipod_cmd_init_pod, OmnipodCustomActionType.PairAndPrime, true); + + protected CustomAction customActionFillCanullaSetBasalProfile = new CustomAction( + R.string.omnipod_cmd_init_pod, OmnipodCustomActionType.FillCanulaSetBasalProfile, false); protected CustomAction customActionDeactivatePod = new CustomAction( R.string.omnipod_cmd_deactivate_pod, OmnipodCustomActionType.DeactivatePod, false); @@ -779,7 +784,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump if (customActions == null) { this.customActions = Arrays.asList( customActionResetRLConfig, // - customActionInitPod, // + customActionPairAndPrime, // + customActionFillCanullaSetBasalProfile, // customActionDeactivatePod, // customActionResetPod); } @@ -787,6 +793,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump return this.customActions; } + + LogReceiver logReceiver = new LogReceiver(); + // TODO we need to brainstorm how we want to do this -- Andy @Override public void executeCustomAction(CustomActionType customActionType) { @@ -800,8 +809,13 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump } break; - case InitPod: { - omnipodUIComm.executeCommand(OmnipodCommandType.InitPod); + case PairAndPrime: { + omnipodUIComm.executeCommand(OmnipodCommandType.PairAndPrimePod, PodInitActionType.PairAndPrimeWizardStep, logReceiver); + } + break; + + case FillCanulaSetBasalProfile: { + omnipodUIComm.executeCommand(OmnipodCommandType.FillCanulaAndSetBasalProfile, PodInitActionType.FillCannulaSetBasalProfileWizardStep, this.currentProfile, logReceiver); } break; @@ -835,11 +849,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump switch (customAction) { - case InitPod: { - this.customActionInitPod.setEnabled(isEnabled); + case PairAndPrime: { + this.customActionPairAndPrime.setEnabled(isEnabled); } break; + case FillCanulaSetBasalProfile: { + this.customActionFillCanullaSetBasalProfile.setEnabled(isEnabled); + } + break; + + case DeactivatePod: { this.customActionDeactivatePod.setEnabled(isEnabled); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/ui/OmnipodUIPostprocessor.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/ui/OmnipodUIPostprocessor.java index 03d3a21504..e7d3810806 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/ui/OmnipodUIPostprocessor.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/ui/OmnipodUIPostprocessor.java @@ -33,15 +33,26 @@ public class OmnipodUIPostprocessor { switch (uiTask.commandType) { - case InitPod: { - omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.InitPod, false); + case PairAndPrimePod: { + if (uiTask.returnData.success) { + omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.PairAndPrime, false); + omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.FillCanulaSetBasalProfile, true); + } + omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.DeactivatePod, true); + } + break; + + case FillCanulaAndSetBasalProfile: { + if (uiTask.returnData.success) { + omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.FillCanulaSetBasalProfile, false); + } omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.DeactivatePod, true); } break; case DeactivatePod: case ResetPodStatus: { - omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.InitPod, true); + omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.PairAndPrime, true); omnipodPumpPlugin.setEnableCustomAction(OmnipodCustomActionType.DeactivatePod, false); } break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/ui/OmnipodUITask.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/ui/OmnipodUITask.java index 3aa2b3d4c7..d8fe0a685f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/ui/OmnipodUITask.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/comm/ui/OmnipodUITask.java @@ -56,8 +56,13 @@ public class OmnipodUITask { // } // break; - case InitPod: - returnData = communicationManager.initPod((PodInitActionType) parameters[0], (PodInitReceiver) parameters[1]); + case PairAndPrimePod: + returnData = communicationManager.initPod((PodInitActionType) parameters[0], (PodInitReceiver) parameters[1], null); +// TODO returnData = communicationManager.pairAndPrime(); + break; + + case FillCanulaAndSetBasalProfile: + returnData = communicationManager.initPod((PodInitActionType) parameters[0], (PodInitReceiver) parameters[1], (Profile) parameters[2]); // TODO returnData = communicationManager.pairAndPrime(); break; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommandType.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommandType.java index 75963932d8..ec7c34bad1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommandType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommandType.java @@ -5,7 +5,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs; */ public enum OmnipodCommandType { - InitPod, // + PairAndPrimePod, // + FillCanulaAndSetBasalProfile, // + //InitPod, // DeactivatePod, // SetBasalProfile, // SetBolus, // diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommunicationManagerInterface.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommunicationManagerInterface.java index 8780b69b17..4c5aa050ce 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommunicationManagerInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCommunicationManagerInterface.java @@ -11,7 +11,7 @@ public interface OmnipodCommunicationManagerInterface { /** * Initialize Pod */ - PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver); + PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, Profile profile); /** * Get Pod Status (is pod running, battery left ?, reservoir, etc) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCustomActionType.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCustomActionType.java index bc75946c48..edf7181f18 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCustomActionType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/OmnipodCustomActionType.java @@ -9,7 +9,9 @@ import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType; public enum OmnipodCustomActionType implements CustomActionType { ResetRileyLinkConfiguration(), // - InitPod(), // + PairAndPrime(), // + FillCanulaSetBasalProfile(), // + //InitPod(), // DeactivatePod(), // ResetPodStatus(), // ; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitActionType.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitActionType.java index 8b7b21148c..283b52cf64 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitActionType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/defs/PodInitActionType.java @@ -10,9 +10,9 @@ public enum PodInitActionType { PairPod(PairAndPrimeWizardStep), // PrimePod(PairAndPrimeWizardStep), // - FillCannulaWizardStep, - FillCannula(FillCannulaWizardStep), - SetBasalProfile(FillCannulaWizardStep); + FillCannulaSetBasalProfileWizardStep, + FillCannula(FillCannulaSetBasalProfileWizardStep), + SetBasalProfile(FillCannulaSetBasalProfileWizardStep); private PodInitActionType[] parent; @@ -41,7 +41,7 @@ public enum PodInitActionType { if (podType == OmnipodPodType.Eros) { outList.add(PodInitActionType.PairAndPrimeWizardStep); - outList.add(PodInitActionType.FillCannulaWizardStep); + outList.add(PodInitActionType.FillCannulaSetBasalProfileWizardStep); } else { // TODO we might have different wizard steps, with different handling for Dash } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/LogReceiver.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/LogReceiver.java new file mode 100644 index 0000000000..71e19a2efa --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/util/LogReceiver.java @@ -0,0 +1,26 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.util; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; +import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver; + +public class LogReceiver implements PodInitReceiver { + + private static final Logger LOG = LoggerFactory.getLogger(LogReceiver.class); + + @Override + public void returnInitTaskStatus(PodInitActionType podInitActionType, boolean isSuccess, String errorMessage) { + + if (errorMessage != null) { + LOG.error(podInitActionType.name() + " - Success: " + isSuccess + ", Error Message: " + errorMessage); + } else { + if (isSuccess) { + LOG.info(podInitActionType.name() + " - Success: " + isSuccess); + } else { + LOG.error(podInitActionType.name() + " - NOT Succesful"); + } + } + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/OmnipodDashPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/OmnipodDashPumpPlugin.java index ad4a6ddd54..bbfe552458 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/OmnipodDashPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/OmnipodDashPumpPlugin.java @@ -271,7 +271,8 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodP if (customActions == null) { this.customActions = Arrays.asList( - customActionInitPod, // + customActionPairAndPrime, // + customActionFillCanullaSetBasalProfile, // customActionDeactivatePod, // customActionResetPod); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java index f07aa097bb..d6b4be1d8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod_dash/comm/OmnipodDashCommunicationManager.java @@ -65,7 +65,7 @@ public class OmnipodDashCommunicationManager implements OmnipodCommunicationMana @Override - public PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver) { + public PumpEnactResult initPod(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, Profile profile) { return null; }