Merge branch 'omnipod_eros_bart' of https://github.com/bartsopers/AndroidAPS into omnipod_eros_bart
This commit is contained in:
commit
6387799ba4
|
@ -27,7 +27,7 @@ public abstract class PumpStatus {
|
|||
|
||||
// other pump settings
|
||||
public String activeProfileName = "0";
|
||||
public double reservoirRemainingUnits = 0d;
|
||||
public double reservoirRemainingUnits = 0.0d;
|
||||
public int reservoirFullUnits = 0;
|
||||
public int batteryRemaining = 0; // percent, so 0-100
|
||||
public Double batteryVoltage = null;
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Locale;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
||||
|
@ -22,6 +23,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.Riley
|
|||
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.service.OmnipodPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
|
||||
/**
|
||||
* Created by andy on 5/19/18.
|
||||
|
@ -44,6 +47,7 @@ public class RileyLinkStatusGeneral extends Fragment implements RefreshableInter
|
|||
RileyLinkServiceData rileyLinkServiceData;
|
||||
|
||||
MedtronicPumpStatus medtronicPumpStatus;
|
||||
OmnipodPumpStatus omnipodPumpStatus;
|
||||
boolean first = false;
|
||||
|
||||
|
||||
|
@ -118,7 +122,8 @@ public class RileyLinkStatusGeneral extends Fragment implements RefreshableInter
|
|||
|
||||
}
|
||||
|
||||
// TODO add handling for Omnipod pump status
|
||||
if (MedtronicUtil.isMedtronicPump()) {
|
||||
|
||||
this.medtronicPumpStatus = MedtronicUtil.getPumpStatus();
|
||||
|
||||
if (medtronicPumpStatus != null) {
|
||||
|
@ -127,8 +132,6 @@ public class RileyLinkStatusGeneral extends Fragment implements RefreshableInter
|
|||
this.serialNumber.setText(medtronicPumpStatus.serialNumber);
|
||||
this.pumpFrequency.setText(MainApp.gs(medtronicPumpStatus.pumpFrequency.equals("medtronic_pump_frequency_us_ca") ? R.string.medtronic_pump_frequency_us_ca : R.string.medtronic_pump_frequency_worldwide));
|
||||
|
||||
// TODO extend when Omnipod used
|
||||
|
||||
if (MedtronicUtil.getMedtronicPumpModel() != null)
|
||||
this.connectedDevice.setText("Medtronic " + MedtronicUtil.getMedtronicPumpModel().getPumpModel());
|
||||
else
|
||||
|
@ -142,7 +145,36 @@ public class RileyLinkStatusGeneral extends Fragment implements RefreshableInter
|
|||
this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime(
|
||||
medtronicPumpStatus.lastDataTime)));
|
||||
else
|
||||
this.lastDeviceContact.setText("Never");
|
||||
this.lastDeviceContact.setText(MainApp.gs(R.string.common_never));
|
||||
}
|
||||
} else {
|
||||
|
||||
// TODO add handling for Omnipod Dash pump status
|
||||
this.omnipodPumpStatus = OmnipodUtil.getPumpStatus();
|
||||
|
||||
if (omnipodPumpStatus != null) {
|
||||
this.deviceType.setText(MainApp.gs(RileyLinkTargetDevice.Omnipod.getResourceId()));
|
||||
this.deviceModel.setText(omnipodPumpStatus.pumpType== PumpType.Insulet_Omnipod ? "Eros" : "Dash");
|
||||
this.pumpFrequency.setText(MainApp.gs(R.string.omnipod_frequency));
|
||||
|
||||
if (omnipodPumpStatus.podAvailable) {
|
||||
this.serialNumber.setText(omnipodPumpStatus.podNumber);
|
||||
this.connectedDevice.setText(omnipodPumpStatus.pumpType== PumpType.Insulet_Omnipod ? "Eros Pod" : "Dash Pod");
|
||||
} else {
|
||||
this.connectedDevice.setText("-");
|
||||
}
|
||||
|
||||
if (rileyLinkServiceData.lastGoodFrequency != null)
|
||||
this.lastUsedFrequency.setText(String.format(Locale.ENGLISH, "%.2f MHz",
|
||||
rileyLinkServiceData.lastGoodFrequency));
|
||||
|
||||
if (omnipodPumpStatus.lastConnection != 0)
|
||||
this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime(
|
||||
omnipodPumpStatus.lastDataTime)));
|
||||
else
|
||||
this.lastDeviceContact.setText(MainApp.gs(R.string.common_never));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,11 +8,13 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -42,7 +44,7 @@ public class InitializePumpManagerTask extends ServiceTask {
|
|||
|
||||
double lastGoodFrequency = 0.0d;
|
||||
|
||||
if (RileyLinkUtil.getRileyLinkServiceData().lastGoodFrequency==null) {
|
||||
if (RileyLinkUtil.getRileyLinkServiceData().lastGoodFrequency == null) {
|
||||
|
||||
lastGoodFrequency = SP.getDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, 0.0d);
|
||||
lastGoodFrequency = Math.round(lastGoodFrequency * 1000d) / 1000d;
|
||||
|
@ -56,6 +58,9 @@ public class InitializePumpManagerTask extends ServiceTask {
|
|||
lastGoodFrequency = RileyLinkUtil.getRileyLinkServiceData().lastGoodFrequency;
|
||||
}
|
||||
|
||||
|
||||
if (MedtronicUtil.isMedtronicPump()) {
|
||||
|
||||
if ((lastGoodFrequency > 0.0d)
|
||||
&& RileyLinkUtil.getRileyLinkCommunicationManager().isValidFrequency(lastGoodFrequency)) {
|
||||
|
||||
|
@ -79,5 +84,29 @@ public class InitializePumpManagerTask extends ServiceTask {
|
|||
} else {
|
||||
RileyLinkUtil.sendBroadcastMessage(RileyLinkConst.IPC.MSG_PUMP_tunePump);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!RileyLinkUtil.isSame(lastGoodFrequency, RileyLinkTargetFrequency.Omnipod.getScanFrequencies()[0])) {
|
||||
lastGoodFrequency = RileyLinkTargetFrequency.Omnipod.getScanFrequencies()[0];
|
||||
lastGoodFrequency = Math.round(lastGoodFrequency * 1000d) / 1000d;
|
||||
|
||||
RileyLinkUtil.getRileyLinkServiceData().lastGoodFrequency = lastGoodFrequency;
|
||||
}
|
||||
|
||||
|
||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.RileyLinkReady);
|
||||
RileyLinkUtil.setRileyLinkTargetFrequency(RileyLinkTargetFrequency.Omnipod);
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
LOG.info("Setting radio frequency to {} MHz", lastGoodFrequency);
|
||||
|
||||
RileyLinkUtil.getRileyLinkCommunicationManager().setRadioFrequencyForPump(lastGoodFrequency);
|
||||
|
||||
|
||||
LOG.error("TRYYYYYY TO CONNECT IF AVAILABLE");
|
||||
|
||||
RileyLinkUtil.setServiceState(RileyLinkServiceState.PumpConnectorReady);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,7 +8,6 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.squareup.otto.Subscribe
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange
|
||||
|
@ -47,6 +46,7 @@ import org.slf4j.LoggerFactory
|
|||
class OmnipodFragment : Fragment() {
|
||||
private val log = LoggerFactory.getLogger(L.PUMP)
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
private var podAvailable = false
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
|
@ -69,7 +69,7 @@ class OmnipodFragment : Fragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
omnipod_pod_status.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder))
|
||||
//omnipod_pod_status.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder))
|
||||
|
||||
omnipod_rl_status.text = MainApp.gs(RileyLinkServiceState.NotStarted.getResourceId(RileyLinkTargetDevice.Omnipod))
|
||||
|
||||
|
@ -121,7 +121,6 @@ class OmnipodFragment : Fragment() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
MainApp.bus().register(this)
|
||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
disposable += RxBus
|
||||
.toObservable(EventOmnipodRefreshButtonState::class.java)
|
||||
|
@ -145,29 +144,28 @@ class OmnipodFragment : Fragment() {
|
|||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
MainApp.bus().unregister(this)
|
||||
loopHandler.removeCallbacks(refreshLoop)
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onStatusEvent(c: EventPumpStatusChanged) {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onStatusEvent(s: EventTempBasalChange) {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onStatusEvent(s: EventExtendedBolusChange) {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onStatusEvent(s: EventQueueChanged) {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
}
|
||||
// @Subscribe
|
||||
// fun onStatusEvent(c: EventPumpStatusChanged) {
|
||||
// activity?.runOnUiThread { updateGUI() }
|
||||
// }
|
||||
//
|
||||
// @Subscribe
|
||||
// fun onStatusEvent(s: EventTempBasalChange) {
|
||||
// activity?.runOnUiThread { updateGUI() }
|
||||
// }
|
||||
//
|
||||
// @Subscribe
|
||||
// fun onStatusEvent(s: EventExtendedBolusChange) {
|
||||
// activity?.runOnUiThread { updateGUI() }
|
||||
// }
|
||||
//
|
||||
// @Subscribe
|
||||
// fun onStatusEvent(s: EventQueueChanged) {
|
||||
// activity?.runOnUiThread { updateGUI() }
|
||||
// }
|
||||
|
||||
@Synchronized
|
||||
private fun setDeviceStatus() {
|
||||
|
@ -202,9 +200,11 @@ class OmnipodFragment : Fragment() {
|
|||
if (pumpStatus.podSessionState == null) {
|
||||
omnipod_pod_address.text = MainApp.gs(R.string.omnipod_pod_name_no_info)
|
||||
omnipod_pod_expiry.text = "-"
|
||||
omnipod_pod_status.text = "{fa-bed} "
|
||||
omnipod_pod_status.text = MainApp.gs(R.string.omnipod_pod_no_pod_connected)
|
||||
pumpStatus.podAvailable = false
|
||||
} else {
|
||||
|
||||
podAvailable = true
|
||||
pumpStatus.podAvailable = true
|
||||
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
|
||||
omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString
|
||||
|
||||
|
@ -310,6 +310,7 @@ class OmnipodFragment : Fragment() {
|
|||
|
||||
setDeviceStatus()
|
||||
|
||||
if (podAvailable) {
|
||||
// last connection
|
||||
if (pumpStatus.lastConnection != 0L) {
|
||||
val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
||||
|
@ -342,7 +343,7 @@ class OmnipodFragment : Fragment() {
|
|||
// last bolus
|
||||
val bolus = pumpStatus.lastBolusAmount
|
||||
val bolusTime = pumpStatus.lastBolusTime
|
||||
if (bolus != null && bolusTime != null) {
|
||||
if (bolus != null && bolusTime != null && podAvailable) {
|
||||
val agoMsc = System.currentTimeMillis() - pumpStatus.lastBolusTime.time
|
||||
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
|
||||
val unit = MainApp.gs(R.string.insulin_unit_shortname)
|
||||
|
@ -360,20 +361,35 @@ class OmnipodFragment : Fragment() {
|
|||
}
|
||||
|
||||
// base basal rate
|
||||
omnipod_basabasalrate.text = ("(" + pumpStatus.activeProfileName + ") "
|
||||
+ MainApp.gs(R.string.pump_basebasalrate, plugin.baseBasalRate))
|
||||
|
||||
omnipod_basabasalrate.text = MainApp.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
|
||||
|
||||
omnipod_tempbasal.text = TreatmentsPlugin.getPlugin()
|
||||
.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: ""
|
||||
|
||||
// reservoir
|
||||
if (RileyLinkUtil.isSame(pumpStatus.reservoirRemainingUnits, 0.0)) {
|
||||
if (RileyLinkUtil.isSame(pumpStatus.reservoirRemainingUnits, 75.0)) {
|
||||
omnipod_reservoir.text = MainApp.gs(R.string.omnipod_reservoir_over50)
|
||||
} else {
|
||||
omnipod_reservoir.text = MainApp.gs(R.string.omnipod_reservoir_left, pumpStatus.reservoirRemainingUnits)
|
||||
}
|
||||
SetWarnColor.setColorInverse(omnipod_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
||||
|
||||
} else {
|
||||
omnipod_basabasalrate.text = ""
|
||||
omnipod_reservoir.text = ""
|
||||
omnipod_tempbasal.text = ""
|
||||
omnipod_lastbolus.text = ""
|
||||
omnipod_lastconnection.text = ""
|
||||
omnipod_lastconnection.setTextColor(Color.WHITE)
|
||||
|
||||
}
|
||||
|
||||
omnipod_errors.text = pumpStatus.errorInfo
|
||||
|
||||
omnipod_pod_active_alerts_ack.isEnabled = pumpStatus.ackAlertsAvailable
|
||||
|
||||
omnipod_refresh.isEnabled = pumpStatus.podAvailable
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.DeactivatePod
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.GetPodInfoAction;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.GetStatusAction;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.InsertCannulaAction;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.OmnipodAction;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.PairAction;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.PrimeAction;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.SetBasalScheduleAction;
|
||||
|
@ -345,4 +346,9 @@ public class OmnipodManager {
|
|||
// TODO use string resource
|
||||
return new PumpEnactResult().success(false).enacted(false).comment("Pod should be initialized first");
|
||||
}
|
||||
|
||||
private void addToHistory(long requestTime, OmnipodAction omnipodAction, long responseTime) {
|
||||
// TODO andy
|
||||
}
|
||||
|
||||
}
|
|
@ -43,6 +43,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
|||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.ui.OmnipodUIComm;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.ui.OmnipodUITask;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||
|
@ -51,14 +52,17 @@ 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;
|
||||
import info.nightscout.androidaps.utils.OKDialog;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -109,10 +113,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
||||
|
||||
if (omnipodCommunicationManager == null) {
|
||||
omnipodCommunicationManager = AapsOmnipodManager.getInstance();
|
||||
//omnipodCommunicationManager = AapsOmnipodManager.getInstance();
|
||||
}
|
||||
|
||||
omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager);
|
||||
omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager, this, this.pumpStatusLocal);
|
||||
|
||||
OmnipodUtil.setPlugin(this);
|
||||
|
||||
|
@ -251,7 +255,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
|
||||
if (isServiceSet()) {
|
||||
|
||||
if (isBusy)
|
||||
if (isBusy || !pumpStatusLocal.podAvailable)
|
||||
return true;
|
||||
|
||||
if (busyTimestamps.size() > 0) {
|
||||
|
@ -309,6 +313,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSuspended() {
|
||||
return (pumpStatusLocal!=null && !pumpStatusLocal.podAvailable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPumpStatus() {
|
||||
|
||||
|
@ -419,7 +428,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
public boolean isThisProfileSet(Profile profile) {
|
||||
|
||||
// TODO status was not yet read from pod
|
||||
// TODO maybe not possible, need to see how we will handle that
|
||||
if (currentProfile == null) {
|
||||
this.currentProfile = profile;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -481,6 +492,12 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isFakingTempsByExtendedBoluses() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
protected PumpEnactResult deliverBolus(final DetailedBolusInfo detailedBolusInfo) {
|
||||
|
@ -655,7 +672,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
|
||||
protected void finishAction(String overviewKey) {
|
||||
if (overviewKey != null)
|
||||
MainApp.bus().post(new EventRefreshOverview(overviewKey));
|
||||
RxBus.INSTANCE.send(new EventRefreshOverview(overviewKey));
|
||||
|
||||
triggerUIChange();
|
||||
|
||||
|
@ -763,8 +780,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 +799,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
if (customActions == null) {
|
||||
this.customActions = Arrays.asList(
|
||||
customActionResetRLConfig, //
|
||||
customActionInitPod, //
|
||||
customActionPairAndPrime, //
|
||||
customActionFillCanullaSetBasalProfile, //
|
||||
customActionDeactivatePod, //
|
||||
customActionResetPod);
|
||||
}
|
||||
|
@ -787,6 +808,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 +824,18 @@ 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: {
|
||||
if (this.currentProfile != null) {
|
||||
omnipodUIComm.executeCommand(OmnipodCommandType.FillCanulaAndSetBasalProfile, PodInitActionType.FillCannulaSetBasalProfileWizardStep, logReceiver, this.currentProfile);
|
||||
} else {
|
||||
OKDialog.show(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.combo_warning),
|
||||
MainApp.gs(R.string.omnipod_error_operation_not_possible_no_profile), null);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -835,11 +869,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);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.service.OmnipodPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
|
||||
/**
|
||||
|
@ -16,15 +18,16 @@ public class OmnipodUIComm {
|
|||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
OmnipodCommunicationManagerInterface ocmInstance = null;
|
||||
OmnipodUIPostprocessor uiPostprocessor = new OmnipodUIPostprocessor();
|
||||
OmnipodUIPostprocessor uiPostprocessor; // = new OmnipodUIPostprocessor();
|
||||
|
||||
|
||||
private OmnipodCommunicationManagerInterface getCommunicationManager() {
|
||||
return ocmInstance;
|
||||
}
|
||||
|
||||
public OmnipodUIComm(OmnipodCommunicationManagerInterface communicationManager) {
|
||||
public OmnipodUIComm(OmnipodCommunicationManagerInterface communicationManager, OmnipodPumpPlugin plugin, OmnipodPumpStatus status) {
|
||||
ocmInstance = communicationManager;
|
||||
uiPostprocessor = new OmnipodUIPostprocessor(plugin, status);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,9 +21,11 @@ public class OmnipodUIPostprocessor {
|
|||
OmnipodPumpPlugin omnipodPumpPlugin;
|
||||
|
||||
|
||||
public OmnipodUIPostprocessor() {
|
||||
pumpStatus = OmnipodUtil.getPumpStatus();
|
||||
omnipodPumpPlugin = OmnipodPumpPlugin.getPlugin();
|
||||
public OmnipodUIPostprocessor(OmnipodPumpPlugin plugin, OmnipodPumpStatus pumpStatus) {
|
||||
// pumpStatus = OmnipodUtil.getPumpStatus();
|
||||
// omnipodPumpPlugin = OmnipodPumpPlugin.getPlugin();
|
||||
this.pumpStatus = pumpStatus;
|
||||
this.omnipodPumpPlugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,15 +35,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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -5,7 +5,9 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
|||
*/
|
||||
public enum OmnipodCommandType {
|
||||
|
||||
InitPod, //
|
||||
PairAndPrimePod, //
|
||||
FillCanulaAndSetBasalProfile, //
|
||||
//InitPod, //
|
||||
DeactivatePod, //
|
||||
SetBasalProfile, //
|
||||
SetBolus, //
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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(), //
|
||||
;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
|
||||
public String podNumber;
|
||||
public PodDeviceState podDeviceState = PodDeviceState.NeverContacted;
|
||||
public boolean podAvailable = false;
|
||||
public boolean ackAlertsAvailable = false;
|
||||
|
||||
|
||||
public OmnipodPumpStatus(PumpDescription pumpDescription) {
|
||||
|
@ -63,6 +65,7 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
this.lastConnection = SP.getLong(OmnipodConst.Statistics.LastGoodPumpCommunicationTime, 0L);
|
||||
this.lastDataTime = new LocalDateTime(this.lastConnection);
|
||||
this.pumpType = PumpType.Insulet_Omnipod;
|
||||
this.podAvailable = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -61,7 +61,6 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodP
|
|||
|
||||
|
||||
private OmnipodDashPumpPlugin() {
|
||||
|
||||
super(new PluginDescription() //
|
||||
.mainType(PluginType.PUMP) //
|
||||
.fragmentClass(OmnipodFragment.class.getName()) //
|
||||
|
@ -80,7 +79,7 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodP
|
|||
omnipodCommunicationManager = OmnipodDashCommunicationManager.getInstance();
|
||||
}
|
||||
|
||||
omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager);
|
||||
omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager, this, this.pumpStatusLocal);
|
||||
|
||||
OmnipodUtil.setPlugin(this);
|
||||
|
||||
|
@ -257,7 +256,7 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodP
|
|||
|
||||
|
||||
protected void triggerUIChange() {
|
||||
MainApp.bus().post(new EventOmnipodPumpValuesChanged());
|
||||
RxBus.INSTANCE.send(new EventOmnipodPumpValuesChanged());
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,7 +270,8 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodP
|
|||
|
||||
if (customActions == null) {
|
||||
this.customActions = Arrays.asList(
|
||||
customActionInitPod, //
|
||||
customActionPairAndPrime, //
|
||||
customActionFillCanullaSetBasalProfile, //
|
||||
customActionDeactivatePod, //
|
||||
customActionResetPod);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -206,8 +206,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="5dp"
|
||||
android:text="{fa-bluetooth-b}"
|
||||
android:paddingStart="5dp"
|
||||
android:paddingEnd="5dp"
|
||||
android:text=""
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
|
|
@ -1470,6 +1470,7 @@
|
|||
<string name="rileylink_scanner_scanning">Scanning</string>
|
||||
<string name="rileylink_scanner_scanning_finished">Scanning finished</string>
|
||||
<string name="rileylink_scanner_scanning_error">Scanning error: %1$d</string>
|
||||
<string name="common_never">Never</string>
|
||||
|
||||
|
||||
<!-- RL Status Page -->
|
||||
|
@ -1615,6 +1616,7 @@
|
|||
<string name="common_on">On</string>
|
||||
<string name="common_off">Off</string>
|
||||
|
||||
|
||||
<!-- Omnipod -->
|
||||
|
||||
<!-- Omnipod - Base -->
|
||||
|
@ -1630,12 +1632,17 @@
|
|||
<string name="omnipod_pod_address">Pod Address</string>
|
||||
<string name="omnipod_pod_expiry">Pod Expires</string>
|
||||
<string name="omnipod_pod_name_no_info">No info</string>
|
||||
<string name="omnipod_pod_no_pod_connected">No Pod connected</string>
|
||||
<string name="omnipod_pod_active_alerts">Active Pod Alerts</string>
|
||||
<string name="omnipod_ack_short">Ack Alerts</string>
|
||||
|
||||
<!-- Omnipod - Dialogs -->
|
||||
<string name="omnipod_frequency">Omnipod (433.91 MHz)</string>
|
||||
|
||||
|
||||
<!-- Omnipod - Error -->
|
||||
<string name="omnipod_error_operation_not_possible_no_configuration">Operation is not possible.\n\n You need to configure Omnipod first, before you can use this operation.</string>
|
||||
<string name="omnipod_error_operation_not_possible_no_profile">Operation is not possible.\n\n You need to wait few minutes, until AAPS tries to set profile for first time.</string>
|
||||
|
||||
<!-- Omnipod - Pod Mgmt -->
|
||||
<string name="omnipod_cmd_init_pod">Init Pod</string>
|
||||
|
@ -1669,4 +1676,5 @@
|
|||
<item quantity="one">%1$d minute</item>
|
||||
<item quantity="other">%1$d minutes</item>
|
||||
</plurals>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue