- reworking pump suspended / initialization of driver problem
This commit is contained in:
parent
d594786cb4
commit
bc6e4be3ad
7 changed files with 76 additions and 15 deletions
|
@ -22,11 +22,12 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyL
|
||||||
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.PodDeviceState
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState
|
||||||
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.OmnipodDriverState
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodAcknowledgeAlertsChanged
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange
|
||||||
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.driver.OmnipodPumpStatus
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodAcknowledgeAlertsChanged
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
@ -214,21 +215,27 @@ class OmnipodFragment : Fragment() {
|
||||||
MainApp.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
|
MainApp.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
|
||||||
} ?: "-"
|
} ?: "-"
|
||||||
|
|
||||||
if (pumpStatus.podSessionState == null) {
|
val driverState = OmnipodUtil.getDriverState();
|
||||||
|
|
||||||
|
if (driverState == OmnipodDriverState.NotInitalized) {
|
||||||
|
omnipod_pod_address.text = MainApp.gs(R.string.omnipod_pod_name_no_info)
|
||||||
|
omnipod_pod_expiry.text = "-"
|
||||||
|
omnipod_pod_status.text = MainApp.gs(R.string.omnipod_pod_not_initalized)
|
||||||
|
pumpStatus.podAvailable = false
|
||||||
|
pumpStatus.podNumber == null
|
||||||
|
} else if (driverState == OmnipodDriverState.Initalized_NoPod) {
|
||||||
omnipod_pod_address.text = MainApp.gs(R.string.omnipod_pod_name_no_info)
|
omnipod_pod_address.text = MainApp.gs(R.string.omnipod_pod_name_no_info)
|
||||||
omnipod_pod_expiry.text = "-"
|
omnipod_pod_expiry.text = "-"
|
||||||
omnipod_pod_status.text = MainApp.gs(R.string.omnipod_pod_no_pod_connected)
|
omnipod_pod_status.text = MainApp.gs(R.string.omnipod_pod_no_pod_connected)
|
||||||
pumpStatus.podAvailable = false
|
pumpStatus.podAvailable = false
|
||||||
pumpStatus.podNumber == null
|
pumpStatus.podNumber == null
|
||||||
} else {
|
} else {
|
||||||
//podAvailable = true
|
|
||||||
pumpStatus.podLotNumber = "" + pumpStatus.podSessionState.lot
|
pumpStatus.podLotNumber = "" + pumpStatus.podSessionState.lot
|
||||||
pumpStatus.podAvailable = true
|
pumpStatus.podAvailable = true
|
||||||
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
|
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
|
||||||
omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString
|
omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString
|
||||||
pumpStatus.podNumber = pumpStatus.podSessionState.address.toString()
|
pumpStatus.podNumber = pumpStatus.podSessionState.address.toString()
|
||||||
|
|
||||||
|
|
||||||
//pumpStatus.podSessionState = checkStatusSet(pumpStatus.podSessionState,
|
//pumpStatus.podSessionState = checkStatusSet(pumpStatus.podSessionState,
|
||||||
// OmnipodUtil.getPodSessionState()) as PodSessionState?
|
// OmnipodUtil.getPodSessionState()) as PodSessionState?
|
||||||
|
|
||||||
|
@ -332,7 +339,7 @@ class OmnipodFragment : Fragment() {
|
||||||
setDeviceStatus()
|
setDeviceStatus()
|
||||||
|
|
||||||
if (pumpStatus.podAvailable) {
|
if (pumpStatus.podAvailable) {
|
||||||
// last connection
|
// last connection
|
||||||
if (pumpStatus.lastConnection != 0L) {
|
if (pumpStatus.lastConnection != 0L) {
|
||||||
val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
||||||
val min = (System.currentTimeMillis() - pumpStatus.lastConnection) / 1000 / 60
|
val min = (System.currentTimeMillis() - pumpStatus.lastConnection) / 1000 / 60
|
||||||
|
@ -415,7 +422,7 @@ class OmnipodFragment : Fragment() {
|
||||||
|
|
||||||
|
|
||||||
private fun updateAcknowledgeAlerts(pumpStatus: OmnipodPumpStatus) {
|
private fun updateAcknowledgeAlerts(pumpStatus: OmnipodPumpStatus) {
|
||||||
if (pumpStatus!=null) {
|
if (pumpStatus != null) {
|
||||||
omnipod_pod_active_alerts_ack.isEnabled = pumpStatus.ackAlertsAvailable
|
omnipod_pod_active_alerts_ack.isEnabled = pumpStatus.ackAlertsAvailable
|
||||||
omnipod_pod_active_alerts.text = pumpStatus.ackAlertsText
|
omnipod_pod_active_alerts.text = pumpStatus.ackAlertsText
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ 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.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.PodSessionState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
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;
|
||||||
|
@ -107,6 +108,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
boolean omnipodServiceRunning = false;
|
boolean omnipodServiceRunning = false;
|
||||||
|
|
||||||
private long nextPodCheck = 0L;
|
private long nextPodCheck = 0L;
|
||||||
|
OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
||||||
|
|
||||||
private OmnipodPumpPlugin() {
|
private OmnipodPumpPlugin() {
|
||||||
|
|
||||||
|
@ -123,7 +125,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
displayConnectionMessages = false;
|
displayConnectionMessages = false;
|
||||||
|
|
||||||
OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
OmnipodUtil.setOmnipodPodType(OmnipodPodType.Eros);
|
||||||
OmnipodUtil.setPlugin(this);
|
|
||||||
|
if (OmnipodUtil.isOmnipodEros()) {
|
||||||
|
OmnipodUtil.setPlugin(this);
|
||||||
|
}
|
||||||
|
|
||||||
serviceConnection = new ServiceConnection() {
|
serviceConnection = new ServiceConnection() {
|
||||||
|
|
||||||
|
@ -371,7 +376,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
if (isLoggingEnabled() && displayConnectionMessages)
|
if (isLoggingEnabled() && displayConnectionMessages)
|
||||||
LOG.debug(getLogPrefix() + "isConnected");
|
LOG.debug(getLogPrefix() + "isConnected");
|
||||||
return isServiceSet() && omnipodService.isInitialized();
|
return isServiceSet() && this.omnipodService.isInitialized() && isInitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,14 +384,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
public boolean isConnecting() {
|
public boolean isConnecting() {
|
||||||
if (isLoggingEnabled() && displayConnectionMessages)
|
if (isLoggingEnabled() && displayConnectionMessages)
|
||||||
LOG.debug(getLogPrefix() + "isConnecting");
|
LOG.debug(getLogPrefix() + "isConnecting");
|
||||||
return !isServiceSet() || !omnipodService.isInitialized();
|
return !isServiceSet() || (!omnipodService.isInitialized() || (!isInitialized));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuspended() {
|
public boolean isSuspended() {
|
||||||
return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
return (driverState == OmnipodDriverState.Initalized_NoPod) ||
|
||||||
(OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended());
|
(OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended());
|
||||||
|
//
|
||||||
|
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
||||||
|
// (OmnipodUtil.getPodSessionState() != null && OmnipodUtil.getPodSessionState().isSuspended());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -464,6 +472,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
// TODO read pod status
|
// TODO read pod status
|
||||||
LOG.error("getPodPumpStatus() NOT IMPLEMENTED");
|
LOG.error("getPodPumpStatus() NOT IMPLEMENTED");
|
||||||
|
|
||||||
|
//getPodPumpStatusObject().driverState = OmnipodDriverState.Initalized_PodAvailable;
|
||||||
|
//driverState = OmnipodDriverState.Initalized_PodAvailable;
|
||||||
|
OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAvailable);
|
||||||
// we would probably need to read Basal Profile here too
|
// we would probably need to read Basal Profile here too
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,6 +489,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDriverState(OmnipodDriverState state) {
|
||||||
|
this.driverState = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void resetStatusState() {
|
public void resetStatusState() {
|
||||||
firstRun = true;
|
firstRun = true;
|
||||||
|
@ -495,6 +511,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info(getLogPrefix() + "initializePump - start");
|
LOG.info(getLogPrefix() + "initializePump - start");
|
||||||
|
|
||||||
|
OmnipodPumpStatus podPumpStatus = getPodPumpStatusObject();
|
||||||
|
|
||||||
setRefreshButtonEnabled(false);
|
setRefreshButtonEnabled(false);
|
||||||
|
|
||||||
|
@ -511,14 +528,13 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (podSessionState != null) {
|
if (podSessionState != null) {
|
||||||
LOG.debug("PodSessionState (saved): " + podSessionState);
|
LOG.debug("PodSessionState (saved): " + podSessionState);
|
||||||
|
|
||||||
// TODO handle if session state too old
|
// TODO handle if session state too old
|
||||||
|
|
||||||
// TODO handle basal
|
// TODO load session
|
||||||
|
|
||||||
// TODO handle time
|
|
||||||
|
|
||||||
if (!isRefresh) {
|
if (!isRefresh) {
|
||||||
pumpState = PumpDriverState.Initialized;
|
pumpState = PumpDriverState.Initialized;
|
||||||
|
@ -531,6 +547,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("No PodSessionState found. Pod probably not running.");
|
LOG.debug("No PodSessionState found. Pod probably not running.");
|
||||||
|
//podPumpStatus.driverState = OmnipodDriverState.Initalized_NoPod;
|
||||||
|
OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
|
||||||
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
|
||||||
|
|
||||||
public interface OmnipodPumpPluginInterface extends PumpInterface {
|
public interface OmnipodPumpPluginInterface extends PumpInterface {
|
||||||
|
|
||||||
void addPodStatusRequest(OmnipodStatusRequest pumpStatusRequest);
|
void addPodStatusRequest(OmnipodStatusRequest pumpStatusRequest);
|
||||||
|
|
||||||
|
void setDriverState(OmnipodDriverState state);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.omnipod.driver;
|
||||||
|
|
||||||
|
public enum OmnipodDriverState {
|
||||||
|
|
||||||
|
NotInitalized,
|
||||||
|
Initalized_NoPod,
|
||||||
|
Initalized_PodAvailable,
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.driver;
|
package info.nightscout.androidaps.plugins.pump.omnipod.driver;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -63,6 +62,8 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
public boolean podDebuggingOptionsEnabled = false;
|
public boolean podDebuggingOptionsEnabled = false;
|
||||||
public String podLotNumber = "???";
|
public String podLotNumber = "???";
|
||||||
|
|
||||||
|
public OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
||||||
|
|
||||||
public OmnipodPumpStatus(PumpDescription pumpDescription) {
|
public OmnipodPumpStatus(PumpDescription pumpDescription) {
|
||||||
super(pumpDescription);
|
super(pumpDescription);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ 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.OmnipodPumpPluginInterface;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
|
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
|
||||||
|
@ -54,6 +55,7 @@ public class OmnipodUtil extends RileyLinkUtil {
|
||||||
//private static PodDeviceState podDeviceState;
|
//private static PodDeviceState podDeviceState;
|
||||||
private static OmnipodPumpPluginInterface omnipodPumpPlugin;
|
private static OmnipodPumpPluginInterface omnipodPumpPlugin;
|
||||||
private static OmnipodPodType omnipodPodType;
|
private static OmnipodPodType omnipodPodType;
|
||||||
|
private static OmnipodDriverState driverState;
|
||||||
|
|
||||||
public static Gson getGsonInstance() {
|
public static Gson getGsonInstance() {
|
||||||
return gsonInstance;
|
return gsonInstance;
|
||||||
|
@ -149,6 +151,26 @@ public class OmnipodUtil extends RileyLinkUtil {
|
||||||
return omnipodPumpStatus;
|
return omnipodPumpStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static OmnipodDriverState getDriverState() {
|
||||||
|
return OmnipodUtil.driverState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDriverState(OmnipodDriverState state) {
|
||||||
|
if (OmnipodUtil.driverState == state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
OmnipodUtil.driverState = state;
|
||||||
|
|
||||||
|
// TODO maybe remove
|
||||||
|
if (OmnipodUtil.omnipodPumpStatus != null) {
|
||||||
|
OmnipodUtil.omnipodPumpStatus.driverState = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OmnipodUtil.omnipodPumpPlugin != null) {
|
||||||
|
OmnipodUtil.omnipodPumpPlugin.setDriverState(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setPumpStatus(OmnipodPumpStatus omnipodPumpStatus) {
|
public static void setPumpStatus(OmnipodPumpStatus omnipodPumpStatus) {
|
||||||
OmnipodUtil.omnipodPumpStatus = omnipodPumpStatus;
|
OmnipodUtil.omnipodPumpStatus = omnipodPumpStatus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1667,6 +1667,7 @@
|
||||||
<string name="omnipod_pod_expiry">Pod Expires</string>
|
<string name="omnipod_pod_expiry">Pod Expires</string>
|
||||||
<string name="omnipod_pod_name_no_info">No info</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_no_pod_connected">No Pod connected</string>
|
||||||
|
<string name="omnipod_pod_not_initalized">Not initialized</string>
|
||||||
<string name="omnipod_pod_active_alerts">Active Pod Alerts</string>
|
<string name="omnipod_pod_active_alerts">Active Pod Alerts</string>
|
||||||
<string name="omnipod_ack_short">Ack Alerts</string>
|
<string name="omnipod_ack_short">Ack Alerts</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue