- Partial fix for display of RL status
- Fix IllegalStateException when AssignAddressAction is executed when an address has already been assigned - Improve (not yet used) custom unreachable alert check - Remove hasFixedUnreachableAlert from PumpType - Remove omnipodPumpStatus.podAvailable in favor of PodStateManager - Remove some unused code / comments - Add a bunch of TODOs
This commit is contained in:
parent
4d04353e7b
commit
a0ca8cf9cc
13 changed files with 48 additions and 73 deletions
|
@ -55,7 +55,6 @@ public class PumpDescription {
|
||||||
public boolean supportsTDDs;
|
public boolean supportsTDDs;
|
||||||
public boolean needsManualTDDLoad;
|
public boolean needsManualTDDLoad;
|
||||||
|
|
||||||
public boolean hasFixedUnreachableAlert;
|
|
||||||
public boolean hasCustomUnreachableAlertCheck;
|
public boolean hasCustomUnreachableAlertCheck;
|
||||||
|
|
||||||
public void resetSettings() {
|
public void resetSettings() {
|
||||||
|
@ -90,7 +89,6 @@ public class PumpDescription {
|
||||||
supportsTDDs = false;
|
supportsTDDs = false;
|
||||||
needsManualTDDLoad = true;
|
needsManualTDDLoad = true;
|
||||||
|
|
||||||
hasFixedUnreachableAlert = false;
|
|
||||||
hasCustomUnreachableAlertCheck = false;
|
hasCustomUnreachableAlertCheck = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +138,6 @@ public class PumpDescription {
|
||||||
|
|
||||||
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min);
|
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min);
|
||||||
|
|
||||||
hasFixedUnreachableAlert = pumpType.getHasFixedUnreachableAlert();
|
|
||||||
hasCustomUnreachableAlertCheck = pumpType.getHasCustomUnreachableAlertCheck();
|
hasCustomUnreachableAlertCheck = pumpType.getHasCustomUnreachableAlertCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,13 +102,13 @@ public enum PumpType {
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true, true),
|
0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true),
|
||||||
|
|
||||||
Insulet_Omnipod_Dash("Insulet Omnipod Dash", ManufacturerType.Insulet, "Omnipod Dash", 0.05d, null, //
|
Insulet_Omnipod_Dash("Insulet Omnipod Dash", ManufacturerType.Insulet, "Omnipod Dash", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true, true), // TODO just copied OmniPod for now
|
0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true), // TODO just copied OmniPod for now
|
||||||
|
|
||||||
// Medtronic
|
// Medtronic
|
||||||
Medtronic_512_712("Medtronic 512/712", ManufacturerType.Medtronic, "512/712", 0.1d, null, //
|
Medtronic_512_712("Medtronic 512/712", ManufacturerType.Medtronic, "512/712", 0.1d, null, //
|
||||||
|
@ -163,7 +163,6 @@ public enum PumpType {
|
||||||
private double baseBasalStep; //
|
private double baseBasalStep; //
|
||||||
private DoseStepSize baseBasalSpecialSteps; //
|
private DoseStepSize baseBasalSpecialSteps; //
|
||||||
private PumpCapability pumpCapability;
|
private PumpCapability pumpCapability;
|
||||||
private boolean hasFixedUnreachableAlert;
|
|
||||||
private boolean hasCustomUnreachableAlertCheck;
|
private boolean hasCustomUnreachableAlertCheck;
|
||||||
|
|
||||||
private PumpType parent;
|
private PumpType parent;
|
||||||
|
@ -231,7 +230,7 @@ public enum PumpType {
|
||||||
PumpCapability pumpCapability) {
|
PumpCapability pumpCapability) {
|
||||||
this(description, manufacturer, model, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType,
|
this(description, manufacturer, model, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType,
|
||||||
tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep,
|
tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep,
|
||||||
baseBasalSpecialSteps, pumpCapability, false, false);
|
baseBasalSpecialSteps, pumpCapability, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -249,7 +248,6 @@ public enum PumpType {
|
||||||
double baseBasalStep,
|
double baseBasalStep,
|
||||||
DoseStepSize baseBasalSpecialSteps, //
|
DoseStepSize baseBasalSpecialSteps, //
|
||||||
PumpCapability pumpCapability,
|
PumpCapability pumpCapability,
|
||||||
boolean hasFixedUnreachableAlert,
|
|
||||||
boolean hasCustomUnreachableAlertCheck) {
|
boolean hasCustomUnreachableAlertCheck) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.manufacturer = manufacturer;
|
this.manufacturer = manufacturer;
|
||||||
|
@ -265,17 +263,11 @@ public enum PumpType {
|
||||||
this.baseBasalStep = baseBasalStep;
|
this.baseBasalStep = baseBasalStep;
|
||||||
this.baseBasalSpecialSteps = baseBasalSpecialSteps;
|
this.baseBasalSpecialSteps = baseBasalSpecialSteps;
|
||||||
this.pumpCapability = pumpCapability;
|
this.pumpCapability = pumpCapability;
|
||||||
this.hasFixedUnreachableAlert = hasFixedUnreachableAlert;
|
|
||||||
this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck;
|
this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean getHasFixedUnreachableAlert() {
|
|
||||||
return hasFixedUnreachableAlert;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getHasCustomUnreachableAlertCheck() {
|
public boolean getHasCustomUnreachableAlertCheck() {
|
||||||
return hasFixedUnreachableAlert;
|
return hasCustomUnreachableAlertCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
|
|
|
@ -31,6 +31,8 @@ import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
|
@ -167,10 +169,11 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
|
|
||||||
this.pumpFrequency.setText(resourceHelper.gs(R.string.omnipod_frequency));
|
this.pumpFrequency.setText(resourceHelper.gs(R.string.omnipod_frequency));
|
||||||
|
|
||||||
|
// TODO needs improvement
|
||||||
if (omnipodPumpStatus != null) {
|
if (omnipodPumpStatus != null) {
|
||||||
|
PodStateManager podStateManager = ((OmnipodPumpPlugin) pumpPlugin).getPodStateManager();
|
||||||
if (omnipodPumpStatus.podAvailable) {
|
if (podStateManager.isPaired()) {
|
||||||
this.serialNumber.setText(omnipodPumpStatus.podLotNumber);
|
this.serialNumber.setText(podStateManager.getLot());
|
||||||
this.connectedDevice.setText(omnipodPumpStatus.pumpType == PumpType.Insulet_Omnipod ? "Eros Pod" : "Dash Pod");
|
this.connectedDevice.setText(omnipodPumpStatus.pumpType == PumpType.Insulet_Omnipod ? "Eros Pod" : "Dash Pod");
|
||||||
} else {
|
} else {
|
||||||
this.serialNumber.setText("??");
|
this.serialNumber.setText("??");
|
||||||
|
|
|
@ -218,15 +218,17 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
|
|
||||||
aapsLogger.info(LTag.PUMP, "setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus)
|
aapsLogger.info(LTag.PUMP, "setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus)
|
||||||
|
|
||||||
val resourceId = rileyLinkServiceData.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
|
val rileyLinkServiceState = rileyLinkServiceData.rileyLinkServiceState
|
||||||
|
|
||||||
|
val resourceId = rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
|
||||||
val rileyLinkError = rileyLinkServiceData.rileyLinkError
|
val rileyLinkError = rileyLinkServiceData.rileyLinkError
|
||||||
|
|
||||||
omnipod_rl_status.text =
|
omnipod_rl_status.text =
|
||||||
when {
|
when {
|
||||||
omnipodPumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
||||||
omnipodPumpStatus.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
||||||
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||||
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
||||||
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||||
}
|
}
|
||||||
omnipod_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
omnipod_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
||||||
|
@ -235,7 +237,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
// RileyLinkUtil.getError()) as RileyLinkError?
|
// RileyLinkUtil.getError()) as RileyLinkError?
|
||||||
|
|
||||||
omnipod_errors.text =
|
omnipod_errors.text =
|
||||||
omnipodPumpStatus.rileyLinkError?.let {
|
rileyLinkError?.let {
|
||||||
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
|
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
|
||||||
} ?: "-"
|
} ?: "-"
|
||||||
|
|
||||||
|
@ -258,11 +260,9 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
} else {
|
} else {
|
||||||
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_no_pod_connected)
|
omnipod_pod_status.text = resourceHelper.gs(R.string.omnipod_pod_status_no_pod_connected)
|
||||||
}
|
}
|
||||||
omnipodPumpStatus.podAvailable = false
|
|
||||||
omnipodPumpStatus.podNumber == null
|
omnipodPumpStatus.podNumber == null
|
||||||
} else {
|
} else {
|
||||||
omnipodPumpStatus.podLotNumber = "" + podStateManager.lot
|
omnipodPumpStatus.podLotNumber = "" + podStateManager.lot
|
||||||
omnipodPumpStatus.podAvailable = podStateManager.isSetupCompleted
|
|
||||||
omnipod_pod_address.text = podStateManager.address.toString()
|
omnipod_pod_address.text = podStateManager.address.toString()
|
||||||
omnipod_pod_lot.text = podStateManager.lot.toString()
|
omnipod_pod_lot.text = podStateManager.lot.toString()
|
||||||
omnipod_pod_tid.text = podStateManager.tid.toString()
|
omnipod_pod_tid.text = podStateManager.tid.toString()
|
||||||
|
@ -270,8 +270,6 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
omnipod_pod_expiry.text = podStateManager.expiryDateAsString
|
omnipod_pod_expiry.text = podStateManager.expiryDateAsString
|
||||||
omnipodPumpStatus.podNumber = podStateManager.address.toString()
|
omnipodPumpStatus.podNumber = podStateManager.address.toString()
|
||||||
|
|
||||||
var podDeviceState = omnipodPumpStatus.podDeviceState
|
|
||||||
|
|
||||||
var stateText: String?
|
var stateText: String?
|
||||||
|
|
||||||
if (podStateManager.hasFaultEvent()) {
|
if (podStateManager.hasFaultEvent()) {
|
||||||
|
@ -323,8 +321,9 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
|
|
||||||
setDeviceStatus()
|
setDeviceStatus()
|
||||||
|
|
||||||
if (omnipodPumpStatus.podAvailable) {
|
if (podStateManager.isPaired) {
|
||||||
// last connection
|
// last connection
|
||||||
|
// TODO replace with podStateManager.getLastSuccessfulCommunication
|
||||||
if (omnipodPumpStatus.lastConnection != 0L) {
|
if (omnipodPumpStatus.lastConnection != 0L) {
|
||||||
//val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
//val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
||||||
val min = (System.currentTimeMillis() - omnipodPumpStatus.lastConnection) / 1000 / 60
|
val min = (System.currentTimeMillis() - omnipodPumpStatus.lastConnection) / 1000 / 60
|
||||||
|
@ -355,9 +354,10 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// last bolus
|
// last bolus
|
||||||
|
// TODO replace with podStateManager.getLastBolus
|
||||||
val bolus = omnipodPumpStatus.lastBolusAmount
|
val bolus = omnipodPumpStatus.lastBolusAmount
|
||||||
val bolusTime = omnipodPumpStatus.lastBolusTime
|
val bolusTime = omnipodPumpStatus.lastBolusTime
|
||||||
if (bolus != null && bolusTime != null && omnipodPumpStatus.podAvailable) {
|
if (bolus != null && bolusTime != null) {
|
||||||
val agoMsc = System.currentTimeMillis() - omnipodPumpStatus.lastBolusTime.time
|
val agoMsc = System.currentTimeMillis() - omnipodPumpStatus.lastBolusTime.time
|
||||||
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
|
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
|
||||||
val unit = resourceHelper.gs(R.string.insulin_unit_shortname)
|
val unit = resourceHelper.gs(R.string.insulin_unit_shortname)
|
||||||
|
@ -401,8 +401,7 @@ class OmnipodFragment : DaggerFragment() {
|
||||||
|
|
||||||
updateAcknowledgeAlerts()
|
updateAcknowledgeAlerts()
|
||||||
|
|
||||||
omnipod_refresh.isEnabled = omnipodPumpStatus.podAvailable
|
omnipod_refresh.isEnabled = podStateManager.isPaired
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAcknowledgeAlerts() {
|
private fun updateAcknowledgeAlerts() {
|
||||||
|
|
|
@ -88,9 +88,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface, RileyLinkPumpDevice {
|
public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface, RileyLinkPumpDevice {
|
||||||
|
protected PodStateManager podStateManager;
|
||||||
// TODO Dagger (maybe done)
|
|
||||||
@Inject protected PodStateManager podStateManager;
|
|
||||||
private static OmnipodPumpPlugin plugin = null;
|
private static OmnipodPumpPlugin plugin = null;
|
||||||
private RileyLinkServiceData rileyLinkServiceData;
|
private RileyLinkServiceData rileyLinkServiceData;
|
||||||
private ServiceTaskExecutor serviceTaskExecutor;
|
private ServiceTaskExecutor serviceTaskExecutor;
|
||||||
|
@ -110,6 +108,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
private boolean isInitialized = false;
|
private boolean isInitialized = false;
|
||||||
protected OmnipodCommunicationManagerInterface omnipodCommunicationManager;
|
protected OmnipodCommunicationManagerInterface omnipodCommunicationManager;
|
||||||
|
|
||||||
|
// TODO make non-static just inject the Singleton and use a getter)
|
||||||
public static boolean isBusy = false;
|
public static boolean isBusy = false;
|
||||||
protected List<Long> busyTimestamps = new ArrayList<>();
|
protected List<Long> busyTimestamps = new ArrayList<>();
|
||||||
protected boolean sentIdToFirebase = false;
|
protected boolean sentIdToFirebase = false;
|
||||||
|
@ -135,6 +134,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
SP sp,
|
SP sp,
|
||||||
OmnipodUtil omnipodUtil,
|
OmnipodUtil omnipodUtil,
|
||||||
OmnipodPumpStatus omnipodPumpStatus,
|
OmnipodPumpStatus omnipodPumpStatus,
|
||||||
|
PodStateManager podStateManager,
|
||||||
CommandQueueProvider commandQueue,
|
CommandQueueProvider commandQueue,
|
||||||
FabricPrivacy fabricPrivacy,
|
FabricPrivacy fabricPrivacy,
|
||||||
RileyLinkServiceData rileyLinkServiceData,
|
RileyLinkServiceData rileyLinkServiceData,
|
||||||
|
@ -150,7 +150,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
PumpType.Insulet_Omnipod,
|
PumpType.Insulet_Omnipod,
|
||||||
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy
|
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy
|
||||||
);
|
);
|
||||||
injector.androidInjector().inject(this);
|
this.podStateManager = podStateManager;
|
||||||
this.rileyLinkServiceData = rileyLinkServiceData;
|
this.rileyLinkServiceData = rileyLinkServiceData;
|
||||||
this.serviceTaskExecutor = serviceTaskExecutor;
|
this.serviceTaskExecutor = serviceTaskExecutor;
|
||||||
|
|
||||||
|
@ -182,6 +182,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PodStateManager getPodStateManager() {
|
||||||
|
return podStateManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
|
@ -402,7 +405,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
if (isServiceSet()) {
|
if (isServiceSet()) {
|
||||||
|
|
||||||
if (isBusy || !omnipodPumpStatus.podAvailable)
|
if (isBusy || !podStateManager.isSetupCompleted())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (busyTimestamps.size() > 0) {
|
if (busyTimestamps.size() > 0) {
|
||||||
|
@ -491,19 +494,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuspended() {
|
public boolean isSuspended() {
|
||||||
|
|
||||||
return omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod ||
|
return omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod ||
|
||||||
!podStateManager.isSetupCompleted() || podStateManager.isSuspended();
|
!podStateManager.isSetupCompleted() || podStateManager.isSuspended();
|
||||||
|
|
||||||
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
|
||||||
// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
|
||||||
//
|
|
||||||
// TODO ddd
|
|
||||||
// return (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) ||
|
|
||||||
// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
|
||||||
//
|
|
||||||
// return (pumpStatusLocal != null && !pumpStatusLocal.podAvailable) ||
|
|
||||||
// (omnipodUtil.getPodStateManager().hasState() && OmnipodUtil.getPodStateManager().isSuspended());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1001,9 +993,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
|
public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
|
||||||
if (omnipodPumpStatus.lastConnection != 0 || omnipodPumpStatus.lastErrorConnection != 0) {
|
if (podStateManager.isSetupCompleted() && podStateManager.getLastSuccessfulCommunication() != null) { // Null check for backwards compatibility
|
||||||
if (omnipodPumpStatus.lastConnection + unreachableTimeoutMilliseconds < System.currentTimeMillis()) {
|
if (podStateManager.getLastSuccessfulCommunication().getMillis() + unreachableTimeoutMilliseconds < System.currentTimeMillis()) {
|
||||||
if (omnipodPumpStatus.lastErrorConnection > omnipodPumpStatus.lastConnection) {
|
if (podStateManager.getLastFailedCommunication() != null && podStateManager.getLastSuccessfulCommunication().isBefore(podStateManager.getLastFailedCommunication())) {
|
||||||
// We exceeded the alert threshold, and our last connection failed
|
// We exceeded the alert threshold, and our last connection failed
|
||||||
// We should show an alert
|
// We should show an alert
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -50,6 +50,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
/**
|
/**
|
||||||
* Created by andy on 6/29/18.
|
* Created by andy on 6/29/18.
|
||||||
*/
|
*/
|
||||||
|
// TODO make singleton
|
||||||
public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
||||||
|
|
||||||
@Inject public AAPSLogger aapsLogger;
|
@Inject public AAPSLogger aapsLogger;
|
||||||
|
@ -58,6 +59,7 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
||||||
//@Inject RileyLinkServiceData rileyLinkServiceData;
|
//@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||||
//@Inject ServiceTaskExecutor serviceTaskExecutor;
|
//@Inject ServiceTaskExecutor serviceTaskExecutor;
|
||||||
|
|
||||||
|
@Inject
|
||||||
public OmnipodCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) {
|
public OmnipodCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) {
|
||||||
super(injector, rfspy);
|
super(injector, rfspy);
|
||||||
omnipodPumpStatus.previousConnection = sp.getLong(
|
omnipodPumpStatus.previousConnection = sp.getLong(
|
||||||
|
|
|
@ -7,10 +7,12 @@ import java.util.Random;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalMessageAddressException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalMessageAddressException;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalVersionResponseTypeException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalVersionResponseTypeException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.AssignAddressCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.AssignAddressCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateManager;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
|
|
||||||
|
@ -29,8 +31,8 @@ public class AssignAddressAction implements OmnipodAction<VersionResponse> {
|
||||||
if (!podStateManager.hasState()) {
|
if (!podStateManager.hasState()) {
|
||||||
podStateManager.initState(generateRandomAddress());
|
podStateManager.initState(generateRandomAddress());
|
||||||
}
|
}
|
||||||
if (podStateManager.isPaired()) {
|
if (podStateManager.isPaired() && podStateManager.getSetupProgress().isAfter(SetupProgress.ADDRESS_ASSIGNED)) {
|
||||||
throw new IllegalStateException("podStateManager already has a paired Pod");
|
throw new IllegalSetupProgressException(SetupProgress.ADDRESS_ASSIGNED, podStateManager.getSetupProgress());
|
||||||
}
|
}
|
||||||
|
|
||||||
AssignAddressCommand assignAddress = new AssignAddressCommand(podStateManager.getAddress());
|
AssignAddressCommand assignAddress = new AssignAddressCommand(podStateManager.getAddress());
|
||||||
|
@ -53,7 +55,6 @@ public class AssignAddressAction implements OmnipodAction<VersionResponse> {
|
||||||
return assignAddressResponse;
|
return assignAddressResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static int generateRandomAddress() {
|
private static int generateRandomAddress() {
|
||||||
// Create random address with 20 bits to match PDM, could easily use 24 bits instead
|
// Create random address with 20 bits to match PDM, could easily use 24 bits instead
|
||||||
return 0x1f000000 | (new Random().nextInt() & 0x000fffff);
|
return 0x1f000000 | (new Random().nextInt() & 0x000fffff);
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class SetTempBasalAction implements OmnipodAction<StatusResponse> {
|
||||||
|
|
||||||
OmnipodMessage message = new OmnipodMessage(podStateManager.getAddress(), messageBlocks, podStateManager.getMessageNumber());
|
OmnipodMessage message = new OmnipodMessage(podStateManager.getAddress(), messageBlocks, podStateManager.getMessageNumber());
|
||||||
StatusResponse statusResponse = communicationService.exchangeMessages(StatusResponse.class, podStateManager, message);
|
StatusResponse statusResponse = communicationService.exchangeMessages(StatusResponse.class, podStateManager, message);
|
||||||
podStateManager.setLastTempBasal(new DateTime().minus(OmnipodConst.AVERAGE_TEMP_BASAL_COMMAND_COMMUNICATION_DURATION), rate, duration);
|
podStateManager.setLastTempBasal(DateTime.now().minus(OmnipodConst.AVERAGE_TEMP_BASAL_COMMAND_COMMUNICATION_DURATION), rate, duration);
|
||||||
return statusResponse;
|
return statusResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.R;
|
||||||
* Created by andy on 4.8.2019
|
* Created by andy on 4.8.2019
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// FIXME remove
|
||||||
public enum PodDeviceState {
|
public enum PodDeviceState {
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.omnipod.driver;
|
package info.nightscout.androidaps.plugins.pump.omnipod.driver;
|
||||||
|
|
||||||
|
// TODO replace with method calls on PodStateManager
|
||||||
public enum OmnipodDriverState {
|
public enum OmnipodDriverState {
|
||||||
|
|
||||||
NotInitalized, // when we start
|
NotInitalized, // when we start
|
||||||
|
|
|
@ -26,6 +26,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OmnipodPumpStatus extends PumpStatus {
|
public class OmnipodPumpStatus extends PumpStatus {
|
||||||
|
// TODO remove all fields that can also be obtained via PodStateManager
|
||||||
|
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
|
@ -37,8 +38,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
public boolean inPreInit = true;
|
public boolean inPreInit = true;
|
||||||
|
|
||||||
// statuses
|
// statuses
|
||||||
public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted;
|
|
||||||
public RileyLinkError rileyLinkError;
|
|
||||||
public double currentBasal = 0;
|
public double currentBasal = 0;
|
||||||
public long tempBasalStart;
|
public long tempBasalStart;
|
||||||
public long tempBasalEnd;
|
public long tempBasalEnd;
|
||||||
|
@ -51,9 +50,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
|
|
||||||
public String podNumber;
|
public String podNumber;
|
||||||
public PodDeviceState podDeviceState = PodDeviceState.NeverContacted;
|
public PodDeviceState podDeviceState = PodDeviceState.NeverContacted;
|
||||||
// FIXME replace with method calls on PodStateManager
|
|
||||||
public boolean podAvailable = false;
|
|
||||||
public boolean podAvailibityChecked = false;
|
|
||||||
public boolean ackAlertsAvailable = false;
|
public boolean ackAlertsAvailable = false;
|
||||||
public String ackAlertsText = null;
|
public String ackAlertsText = null;
|
||||||
|
|
||||||
|
@ -88,9 +84,7 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
this.reservoirRemainingUnits = 75d;
|
this.reservoirRemainingUnits = 75d;
|
||||||
this.batteryRemaining = 75;
|
this.batteryRemaining = 75;
|
||||||
this.lastConnection = sp.getLong(OmnipodConst.Statistics.LastGoodPumpCommunicationTime, 0L);
|
this.lastConnection = sp.getLong(OmnipodConst.Statistics.LastGoodPumpCommunicationTime, 0L);
|
||||||
this.lastDataTime = this.lastConnection;
|
|
||||||
this.pumpType = PumpType.Insulet_Omnipod;
|
this.pumpType = PumpType.Insulet_Omnipod;
|
||||||
this.podAvailable = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,8 +127,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
"errorDescription='" + errorDescription + '\'' +
|
"errorDescription='" + errorDescription + '\'' +
|
||||||
", rileyLinkAddress='" + rileyLinkAddress + '\'' +
|
", rileyLinkAddress='" + rileyLinkAddress + '\'' +
|
||||||
", inPreInit=" + inPreInit +
|
", inPreInit=" + inPreInit +
|
||||||
", rileyLinkServiceState=" + rileyLinkServiceState +
|
|
||||||
", rileyLinkError=" + rileyLinkError +
|
|
||||||
", currentBasal=" + currentBasal +
|
", currentBasal=" + currentBasal +
|
||||||
", tempBasalStart=" + tempBasalStart +
|
", tempBasalStart=" + tempBasalStart +
|
||||||
", tempBasalEnd=" + tempBasalEnd +
|
", tempBasalEnd=" + tempBasalEnd +
|
||||||
|
@ -143,7 +135,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
||||||
", regexMac='" + regexMac + '\'' +
|
", regexMac='" + regexMac + '\'' +
|
||||||
", podNumber='" + podNumber + '\'' +
|
", podNumber='" + podNumber + '\'' +
|
||||||
", podDeviceState=" + podDeviceState +
|
", podDeviceState=" + podDeviceState +
|
||||||
", podAvailable=" + podAvailable +
|
|
||||||
", ackAlertsAvailable=" + ackAlertsAvailable +
|
", ackAlertsAvailable=" + ackAlertsAvailable +
|
||||||
", ackAlertsText='" + ackAlertsText + '\'' +
|
", ackAlertsText='" + ackAlertsText + '\'' +
|
||||||
", lastDataTime=" + lastDataTime +
|
", lastDataTime=" + lastDataTime +
|
||||||
|
|
|
@ -72,6 +72,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
|
|
||||||
|
// TODO make singleton
|
||||||
public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface {
|
public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||||
|
|
||||||
private final PodStateManager podStateManager;
|
private final PodStateManager podStateManager;
|
||||||
|
|
|
@ -131,11 +131,6 @@ public class OmnipodUtil {
|
||||||
return gsonBuilder.create();
|
return gsonBuilder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyDeviceStatusChanged() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void setPodDeviceState(PodDeviceState podDeviceState) {
|
public void setPodDeviceState(PodDeviceState podDeviceState) {
|
||||||
omnipodPumpStatus.podDeviceState = podDeviceState;
|
omnipodPumpStatus.podDeviceState = podDeviceState;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue