- added dash package so that I can split the two implementations

- working on omnipod implementation
- changed display fragment
This commit is contained in:
Andy Rozman 2019-08-14 16:22:19 +01:00
parent f81df4fed1
commit 3203ad5cde
17 changed files with 873 additions and 163 deletions

View file

@ -82,9 +82,11 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
@Override
protected void onStart() {
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, getServiceClass());
context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
if (getServiceClass()!=null) {
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, getServiceClass());
context.bindService(intent, serviceConnection, Context.BIND_AUTO_CREATE);
}
serviceRunning = true;
@ -96,8 +98,10 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
@Override
protected void onStop() {
Context context = MainApp.instance().getApplicationContext();
context.unbindService(serviceConnection);
if (serviceConnection!=null) {
Context context = MainApp.instance().getApplicationContext();
context.unbindService(serviceConnection);
}
serviceRunning = false;

View file

@ -97,6 +97,12 @@ public enum PumpType {
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
Insulet_Omnipod_Dash("Insulet Omnipod Dash", ManufacturerType.Insulet, "Omnipod Dash", 0.05d, null, //
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Absolute, //
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
// Medtronic
Medtronic_512_712("Medtronic 512/712", ManufacturerType.Medtronic, "512/712", 0.1d, null, //
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //

View file

@ -22,6 +22,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
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.dialog.RileyLinkStatusActivity
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged
@ -83,17 +85,17 @@ class OmnipodFragment : Fragment() {
}
omnipod_refresh.setOnClickListener {
// if (!OmnipodUtil.getPumpStatus().verifyConfiguration()) {
// OmnipodUtil.displayNotConfiguredDialog(context)
// } else {
// omnipod_refresh.isEnabled = false
// MedtronicPumpPlugin.getPlugin().resetStatusState()
// ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("Clicked refresh", object : Callback() {
// override fun run() {
// activity?.runOnUiThread { omnipod_refresh.isEnabled = true }
// }
// })
// }
if (!OmnipodUtil.getPumpStatus().verifyConfiguration()) {
OmnipodUtil.displayNotConfiguredDialog(context)
} else {
omnipod_refresh.isEnabled = false
OmnipodUtil.getPlugin().resetStatusState()
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("Clicked refresh", object : Callback() {
override fun run() {
activity?.runOnUiThread { omnipod_refresh.isEnabled = true }
}
})
}
}
omnipod_stats.setOnClickListener {
@ -163,7 +165,7 @@ class OmnipodFragment : Fragment() {
pumpStatus.rileyLinkServiceState = checkStatusSet(pumpStatus.rileyLinkServiceState,
RileyLinkUtil.getServiceState()) as RileyLinkServiceState?
val resourceId = pumpStatus.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.MedtronicPump)
val resourceId = pumpStatus.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
val rileyLinkError = RileyLinkUtil.getError()
omnipod_rl_status.text =
when {
@ -182,6 +184,62 @@ class OmnipodFragment : Fragment() {
MainApp.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
} ?: "-"
if (pumpStatus.podNumber==null) {
}
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} "
} else {
omnipod_pod_address.text = pumpStatus.podSessionState.address.toString()
omnipod_pod_expiry.text = pumpStatus.podSessionState.expiryDateAsString
pumpStatus.podDeviceState = checkStatusSet(pumpStatus.podDeviceState,
OmnipodUtil.getPodDeviceState()) as PodDeviceState?
var podDeviceState = pumpStatus.podDeviceState
when (podDeviceState) {
null,
PumpDeviceState.Sleeping -> omnipod_pod_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
PumpDeviceState.NeverContacted,
PumpDeviceState.WakingUp,
PumpDeviceState.PumpUnreachable,
PumpDeviceState.ErrorWhenCommunicating,
PumpDeviceState.TimeoutWhenCommunicating,
PumpDeviceState.InvalidConfiguration -> omnipod_pod_status.text = " " + MainApp.gs(podDeviceState.resourceId)
PumpDeviceState.Active -> {
omnipod_pod_status.text = "Active";
// val cmd = OmnipodUtil.getCurrentCommand()
// if (cmd == null)
// omnipod_pod_status.text = " " + MainApp.gs(pumpStatus.pumpDeviceState.resourceId)
// else {
// log.debug("Command: " + cmd)
// val cmdResourceId = cmd.resourceId
// if (cmd == MedtronicCommandType.GetHistoryData) {
// omnipod_pod_status.text = OmnipodUtil.frameNumber?.let {
// MainApp.gs(cmdResourceId, OmnipodUtil.pageNumber, OmnipodUtil.frameNumber)
// }
// ?: MainApp.gs(R.string.medtronic_cmd_desc_get_history_request, OmnipodUtil.pageNumber)
// } else {
// omnipod_pod_status.text = " " + (cmdResourceId?.let { MainApp.gs(it) }
// ?: cmd.getCommandDescription())
// }
// }
}
else -> log.warn("Unknown pump state: " + pumpStatus.podDeviceState)
}
}
// pumpStatus.pumpDeviceState = checkStatusSet(pumpStatus.pumpDeviceState,
// OmnipodUtil.getPumpDeviceState()) as PumpDeviceState?
//

View file

@ -43,12 +43,13 @@ 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.EventRefreshButtonState;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
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;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
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;
@ -67,22 +68,23 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
protected static OmnipodPumpPlugin plugin = null;
private static OmnipodPumpPlugin plugin = null;
private RileyLinkOmnipodService omnipodService;
private OmnipodPumpStatus pumpStatusLocal = null;
private OmnipodUIComm omnipodUIComm = new OmnipodUIComm();
protected OmnipodPumpStatus pumpStatusLocal = null;
protected OmnipodUIComm omnipodUIComm;
// variables for handling statuses and history
private boolean firstRun = true;
private boolean isRefresh = false;
protected boolean firstRun = true;
protected boolean isRefresh = false;
private boolean isBasalProfileInvalid = false;
private boolean basalProfileChanged = false;
private boolean isInitialized = false;
private OmnipodCommunicationManager omnipodCommunicationManager;
protected OmnipodCommunicationManagerInterface omnipodCommunicationManager;
public static boolean isBusy = false;
private List<Long> busyTimestamps = new ArrayList<>();
private boolean sentIdToFirebase = false;
protected List<Long> busyTimestamps = new ArrayList<>();
protected boolean sentIdToFirebase = false;
private boolean hasTimeDateOrTimeZoneChanged = false;
private Profile currentProfile;
@ -102,6 +104,14 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
displayConnectionMessages = false;
if (omnipodCommunicationManager == null) {
omnipodCommunicationManager = OmnipodCommunicationManager.getInstance();
}
omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager);
OmnipodUtil.setPlugin(this);
serviceConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {
@ -135,6 +145,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
}
protected OmnipodPumpPlugin(PluginDescription pluginDescription, PumpType pumpType) {
super(pluginDescription, pumpType);
}
public static OmnipodPumpPlugin getPlugin() {
if (plugin == null)
plugin = new OmnipodPumpPlugin();
@ -288,17 +303,18 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
if (firstRun) {
initializePump(!isRefresh);
} else {
getPodPumpStatus();
}
// getPodPumpStatus();
//
// if (firstRun) {
// initializePump(!isRefresh);
// } else {
// refreshAnyStatusThatNeedsToBeRefreshed();
// }
//
// MainApp.bus().post(new EventMedtronicPumpValuesChanged());
triggerUIChange();
}
private void getPodPumpStatus() {
// TODO read pod status
LOG.error("getPodPumpStatus() NOT IMPLEMENTED");
// we would probably need to read Basal Profile here too
}
@ -318,34 +334,29 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
if (isLoggingEnabled())
LOG.info(getLogPrefix() + "initializePump - start");
if (omnipodCommunicationManager == null) {
omnipodCommunicationManager = OmnipodCommunicationManager.getInstance();
setRefreshButtonEnabled(false);
String podState = SP.getString(OmnipodConst.Prefs.PodState, null);
if (podState != null) {
PodSessionState podSessionState = OmnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class);
OmnipodUtil.setPodSessionState(podSessionState);
LOG.debug("PodSessionState (saved): " + podSessionState);
// TODO handle if session state too old
// TODO handle basal
// TODO handle time
getPodPumpStatus();
} else {
LOG.debug("No PodSessionState found. Pod probably not running.");
}
// setRefreshButtonEnabled(false);
//
// getPodPumpStatus();
//
// if (isRefresh) {
// if (isPumpNotReachable()) {
// if (isLoggingEnabled())
// LOG.error(getLogPrefix() + "initializePump::Pump unreachable.");
// MedtronicUtil.sendNotification(MedtronicNotificationType.PumpUnreachable);
//
// setRefreshButtonEnabled(true);
//
// return;
// }
//
// MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
// }
//
// this.pumpState = PumpDriverState.Connected;
//
// pumpStatusLocal.setLastCommunicationToNow();
// setRefreshButtonEnabled(true);
// TODO need to read status and BasalProfile if pod inited and pod status and set correct commands enabled
setRefreshButtonEnabled(true);
if (!isRefresh) {
pumpState = PumpDriverState.Initialized;
@ -360,7 +371,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
}
isInitialized = true;
// this.pumpState = PumpDriverState.Initialized;
this.firstRun = false;
}
@ -369,7 +379,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
@Override
public boolean isThisProfileSet(Profile profile) {
// status was not yet read from pod
// TODO status was not yet read from pod
if (currentProfile == null) {
return true;
}
@ -404,19 +414,17 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
@Override
public double getReservoirLevel() {
// TODO
return getPodPumpStatusObject().reservoirRemainingUnits;
}
@Override
public int getBatteryLevel() {
// TODO
return getPodPumpStatusObject().batteryRemaining;
return 75;
}
private OmnipodPumpStatus getPodPumpStatusObject() {
protected OmnipodPumpStatus getPodPumpStatusObject() {
if (pumpStatusLocal == null) {
// FIXME I don't know why this happens
if (isLoggingEnabled())
@ -429,7 +437,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
protected void triggerUIChange() {
MainApp.bus().post(new EventOmnipodPumpValuesChanged());
RxBus.INSTANCE.send(new EventOmnipodPumpValuesChanged());
}
@ -445,7 +453,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.SetBolus,
detailedBolusInfo.insulin);
Boolean response = (Boolean) responseTask.returnData;
Boolean response = responseTask.wasCommandSuccessful();
setRefreshButtonEnabled(true);
@ -454,7 +462,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
// we subtract insulin, exact amount will be visible with next remainingInsulin update.
getPodPumpStatusObject().reservoirRemainingUnits -= detailedBolusInfo.insulin;
if (getPodPumpStatusObject().reservoirRemainingUnits != 0) {
getPodPumpStatusObject().reservoirRemainingUnits -= detailedBolusInfo.insulin;
}
incrementStatistics(detailedBolusInfo.isSMB ? OmnipodConst.Statistics.SMBBoluses
: OmnipodConst.Statistics.StandardBoluses);
@ -484,22 +494,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
}
private PumpEnactResult setNotReachable(boolean isBolus, boolean success) {
setRefreshButtonEnabled(true);
if (success) {
return new PumpEnactResult() //
.success(true) //
.enacted(false);
} else {
return new PumpEnactResult() //
.success(false) //
.enacted(false) //
.comment(MainApp.gs(R.string.medtronic_pump_status_pump_unreachable));
}
}
public void stopBolusDelivering() {
LOG.info(getLogPrefix() + "stopBolusDelivering");
@ -510,7 +504,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.CancelBolus);
Boolean response = (Boolean) responseTask.returnData;
Boolean response = responseTask.wasCommandSuccessful();
setRefreshButtonEnabled(true);
@ -575,7 +569,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
// CANCEL
OmnipodUITask responseTask2 = omnipodUIComm.executeCommand(OmnipodCommandType.CancelTemporaryBasal);
Boolean response = (Boolean) responseTask2.returnData;
Boolean response = responseTask2.wasCommandSuccessful();
;
if (response) {
if (isLoggingEnabled())
@ -595,7 +590,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.SetTemporaryBasal,
absoluteRate, durationInMinutes);
Boolean response = (Boolean) responseTask.returnData;
Boolean response = responseTask.wasCommandSuccessful();
if (isLoggingEnabled())
LOG.info(getLogPrefix() + "setTempBasalAbsolute - setTBR. Response: " + response);
@ -630,7 +625,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
}
private TempBasalPair readTBR() {
protected TempBasalPair readTBR() {
// TODO we can do it like this or read status from pod ??
if (pumpStatusLocal.tempBasalEnd < System.currentTimeMillis()) {
// TBR done
@ -643,7 +638,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
}
private void finishAction(String overviewKey) {
protected void finishAction(String overviewKey) {
if (overviewKey != null)
MainApp.bus().post(new EventRefreshOverview(overviewKey));
@ -653,16 +648,16 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
}
private long getTimeInFutureFromMinutes(int minutes) {
protected long getTimeInFutureFromMinutes(int minutes) {
return System.currentTimeMillis() + getTimeInMs(minutes);
}
private long getTimeInMs(int minutes) {
protected long getTimeInMs(int minutes) {
return getTimeInS(minutes) * 1000L;
}
private int getTimeInS(int minutes) {
protected int getTimeInS(int minutes) {
return minutes * 60;
}
@ -688,7 +683,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
OmnipodUITask responseTask2 = omnipodUIComm.executeCommand(OmnipodCommandType.CancelTemporaryBasal);
Boolean response = (Boolean) responseTask2.returnData;
Boolean response = responseTask2.wasCommandSuccessful();
finishAction("TBR");
@ -738,7 +733,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
OmnipodUITask responseTask = omnipodUIComm.executeCommand(OmnipodCommandType.SetBasalProfile,
profile);
Boolean response = (Boolean) responseTask.returnData;
Boolean response = responseTask.wasCommandSuccessful();
if (isLoggingEnabled())
LOG.info(getLogPrefix() + "Basal Profile was set: " + response);
@ -756,18 +751,18 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
// OPERATIONS not supported by Pump or Plugin
private List<CustomAction> customActions = null;
protected List<CustomAction> customActions = null;
private CustomAction customActionResetRLConfig = new CustomAction(
R.string.medtronic_custom_action_reset_rileylink, OmnipodCustomActionType.ResetRileyLinkConfiguration, true);
private CustomAction customActionInitPod = new CustomAction(
protected CustomAction customActionInitPod = new CustomAction(
R.string.omnipod_cmd_init_pod, OmnipodCustomActionType.InitPod, true);
private CustomAction customActionDeactivatePod = new CustomAction(
protected CustomAction customActionDeactivatePod = new CustomAction(
R.string.omnipod_cmd_deactivate_pod, OmnipodCustomActionType.DeactivatePod, false);
private CustomAction customActionResetPod = new CustomAction(
protected CustomAction customActionResetPod = new CustomAction(
R.string.omnipod_cmd_reset_pod, OmnipodCustomActionType.ResetPodStatus, true);
@ -776,7 +771,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements PumpInterfa
if (customActions == null) {
this.customActions = Arrays.asList(
customActionResetRLConfig);
customActionResetRLConfig, //
customActionInitPod, //
customActionDeactivatePod, //
customActionResetPod);
}
return this.customActions;

View file

@ -14,8 +14,8 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.RLMessage;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RLMessageType;
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodManager;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.PairAction;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.data.PodCommResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.utils.SP;
@ -45,14 +45,11 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager i
private PodSessionState getPodSessionState() {
return null;
}
public static OmnipodCommunicationManager getInstance() {
return omnipodCommunicationManager;
}
@ -102,7 +99,6 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager i
omnipodManager.pairAndPrime();
return null;
}
@ -140,4 +136,9 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager i
return null;
}
@Override
public PodCommResponse acknowledgeAlerts() {
return null;
}
}

View file

@ -10,6 +10,10 @@ public class PodCommResponse {
Object customData;
Object errorResponse;
public boolean isAcknowledged() {
return (acknowledged != null && acknowledged);
}
// some status data if it can be returned (battery, reservoir, etc)
}

View file

@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
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.util.OmnipodUtil;
@ -15,18 +16,18 @@ public class OmnipodUIComm {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
OmnipodCommunicationManager ocmInstance = null;
OmnipodCommunicationManagerInterface ocmInstance = null;
OmnipodUIPostprocessor uiPostprocessor = new OmnipodUIPostprocessor();
private OmnipodCommunicationManager getCommunicationManager() {
if (ocmInstance == null) {
ocmInstance = OmnipodCommunicationManager.getInstance();
}
private OmnipodCommunicationManagerInterface getCommunicationManager() {
return ocmInstance;
}
public OmnipodUIComm(OmnipodCommunicationManagerInterface communicationManager) {
ocmInstance = communicationManager;
}
public synchronized OmnipodUITask executeCommand(OmnipodCommandType commandType, Object... parameters) {

View file

@ -3,17 +3,18 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.ui;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.data.PodCommResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodResponseType;
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.util.OmnipodUtil;
/**
* Created by andy on 4.8.2019
@ -24,7 +25,7 @@ public class OmnipodUITask {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
public OmnipodCommandType commandType;
public Object returnData;
public PodCommResponse returnData;
private String errorDescription;
private Object[] parameters;
private PodResponseType responseType;
@ -41,7 +42,7 @@ public class OmnipodUITask {
}
public void execute(OmnipodCommunicationManager communicationManager) {
public void execute(OmnipodCommunicationManagerInterface communicationManager) {
if (isLogEnabled())
LOG.debug("OmnipodUITask: @@@ In execute. {}", commandType);
@ -100,6 +101,8 @@ public class OmnipodUITask {
}
// TODO response
}
@ -146,19 +149,19 @@ public class OmnipodUITask {
}
if (responseType == PodResponseType.Invalid) {
statusChange = new EventOmnipodDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
"Unsupported command in OmnipodUITask");
MainApp.bus().post(statusChange);
RxBus.INSTANCE.send(statusChange);
} else if (responseType == PodResponseType.Error) {
statusChange = new EventOmnipodDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
errorDescription);
MainApp.bus().post(statusChange);
RxBus.INSTANCE.send(statusChange);
} else {
MainApp.bus().post(new EventMedtronicPumpValuesChanged());
MedtronicUtil.getPumpStatus().setLastCommunicationToNow();
OmnipodUtil.getPumpStatus().setLastCommunicationToNow();
RxBus.INSTANCE.send(new EventOmnipodPumpValuesChanged());
}
MedtronicUtil.setCurrentCommand(null);
OmnipodUtil.setPodDeviceState(PodDeviceState.Sleeping);
}
@ -181,4 +184,12 @@ public class OmnipodUITask {
return this.responseType;
}
public boolean wasCommandSuccessful() {
if (returnData == null) {
return false;
}
return returnData.isAcknowledged();
}
}

View file

@ -1,4 +1,4 @@
package info.nightscout.androidaps.plugins.pump.omnipod.comm;
package info.nightscout.androidaps.plugins.pump.omnipod.defs;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
@ -57,5 +57,10 @@ public interface OmnipodCommunicationManagerInterface {
*/
PodCommResponse cancelTemporaryBasal();
/**
* Acknowledge alerts
*/
PodCommResponse acknowledgeAlerts();
}

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.NonceState;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.schedule.BasalSchedule;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmniCRC;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
@ -202,8 +203,16 @@ public class PodSessionState extends PodState {
private void store() {
Gson gson = OmnipodUtil.getGsonInstance();
SP.putString(OmnipodConst.Prefs.PodState, gson.toJson(this));
OmnipodUtil.setPodSessionState(this);
}
public String getExpiryDateAsString() {
// TODO
return "???";
}
@Override
public String toString() {
return "PodSessionState{" +

View file

@ -3,7 +3,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.events;
import info.nightscout.androidaps.events.Event;
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.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
/**
* Created by andy on 4.8.2019
@ -13,8 +14,9 @@ public class EventOmnipodDeviceStatusChange extends Event {
public RileyLinkServiceState rileyLinkServiceState;
public RileyLinkError rileyLinkError;
public PumpDeviceState pumpDeviceState;
public PodSessionState podSessionState;
public String errorDescription;
public PodDeviceState podDeviceState;
public EventOmnipodDeviceStatusChange(RileyLinkServiceState rileyLinkServiceState) {
@ -28,20 +30,27 @@ public class EventOmnipodDeviceStatusChange extends Event {
}
public EventOmnipodDeviceStatusChange(PumpDeviceState pumpDeviceState) {
this.pumpDeviceState = pumpDeviceState;
public EventOmnipodDeviceStatusChange(PodSessionState podSessionState) {
this.podSessionState = podSessionState;
}
public EventOmnipodDeviceStatusChange(PumpDeviceState pumpDeviceState, String errorDescription) {
this.pumpDeviceState = pumpDeviceState;
public EventOmnipodDeviceStatusChange(String errorDescription) {
this.errorDescription = errorDescription;
}
public EventOmnipodDeviceStatusChange(PodDeviceState podDeviceState, String errorDescription) {
this.podDeviceState = podDeviceState;
this.errorDescription = errorDescription;
}
@Override
public String toString() {
return "EventOmnipodDeviceStatusChange [" + "rileyLinkServiceState=" + rileyLinkServiceState
+ ", rileyLinkError=" + rileyLinkError + ", pumpDeviceState=" + pumpDeviceState + ']';
return "EventOmnipodDeviceStatusChange [" //
+ "rileyLinkServiceState=" + rileyLinkServiceState
+ ", rileyLinkError=" + rileyLinkError //
+ ", podSessionState=" + podSessionState //
+ ", podDeviceState=" + podDeviceState + "]";
}
}

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.pump.omnipod.service;
import org.jetbrains.annotations.Nullable;
import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -14,6 +15,8 @@ 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.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
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.util.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.utils.SP;
@ -37,12 +40,14 @@ public class OmnipodPumpStatus extends PumpStatus {
public long tempBasalEnd;
public Double tempBasalAmount = 0.0d;
public Integer tempBasalLength;
public PodSessionState podSessionState;
private boolean rileyLinkAddressChanged = false;
private String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
public String podNumber;
public PodDeviceState podDeviceState = PodDeviceState.NeverContacted;
public OmnipodPumpStatus(PumpDescription pumpDescription) {

View file

@ -8,6 +8,8 @@ import com.google.gson.JsonDeserializer;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.ISODateTimeFormat;
@ -19,14 +21,15 @@ import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicNotificationType;
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
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.events.EventOmnipodDeviceStatusChange;
import info.nightscout.androidaps.plugins.pump.omnipod.service.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
import info.nightscout.androidaps.utils.OKDialog;
@ -44,6 +47,9 @@ public class OmnipodUtil extends RileyLinkUtil {
private static OmnipodPumpStatus omnipodPumpStatus;
private static OmnipodCommandType currentCommand;
private static Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
private static PodSessionState podSessionState;
private static PodDeviceState podDeviceState;
private static OmnipodPumpPlugin omnipodPumpPlugin;
public static Gson getGsonInstance() {
return gsonInstance;
@ -84,29 +90,6 @@ public class OmnipodUtil extends RileyLinkUtil {
}
public static void sendNotification(MedtronicNotificationType notificationType) {
Notification notification = new Notification( //
notificationType.getNotificationType(), //
MainApp.gs(notificationType.getResourceId()), //
notificationType.getNotificationUrgency());
MainApp.bus().post(new EventNewNotification(notification));
}
public static void sendNotification(MedtronicNotificationType notificationType, Object... parameters) {
Notification notification = new Notification( //
notificationType.getNotificationType(), //
MainApp.gs(notificationType.getResourceId(), parameters), //
notificationType.getNotificationUrgency());
MainApp.bus().post(new EventNewNotification(notification));
}
public static void dismissNotification(MedtronicNotificationType notificationType) {
MainApp.bus().post(new EventDismissNotification(notificationType.getNotificationType()));
}
public static boolean isLowLevelDebug() {
return lowLevelDebug;
}
@ -179,4 +162,33 @@ public class OmnipodUtil extends RileyLinkUtil {
return gsonBuilder.create();
}
public static void setPodSessionState(PodSessionState podSessionState) {
omnipodPumpStatus.podSessionState = podSessionState;
RxBus.INSTANCE.send(new EventOmnipodDeviceStatusChange(podSessionState));
}
@Nullable
public static PodDeviceState getPodDeviceState() {
return null;
}
public static void setPodDeviceState(PodDeviceState podDeviceState) {
OmnipodUtil.podDeviceState = podDeviceState;
}
@NotNull
public static OmnipodPumpPlugin getPlugin() {
return OmnipodUtil.omnipodPumpPlugin;
}
@NotNull
public static void setPlugin(OmnipodPumpPlugin pumpPlugin) {
OmnipodUtil.omnipodPumpPlugin = pumpPlugin;
}
}

View file

@ -0,0 +1,325 @@
package info.nightscout.androidaps.plugins.pump.omnipod_dash;
import android.content.ComponentName;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.os.SystemClock;
import androidx.annotation.NonNull;
import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventRefreshOverview;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.bus.RxBus;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
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.omnipod.OmnipodFragment;
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
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;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
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.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.plugins.pump.omnipod_dash.comm.OmnipodDashCommunicationManager;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.SP;
/**
* Created by andy on 23.04.18.
*
* @author Andy Rozman (andy.rozman@gmail.com)
*/
public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements PumpInterface {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
protected static OmnipodDashPumpPlugin plugin = null;
private RileyLinkOmnipodService omnipodService;
private OmnipodPumpStatus pumpStatusLocal = null;
// variables for handling statuses and history
private boolean firstRun = true;
private boolean isRefresh = false;
private boolean isBasalProfileInvalid = false;
private boolean basalProfileChanged = false;
private boolean isInitialized = false;
public static boolean isBusy = false;
private List<Long> busyTimestamps = new ArrayList<>();
private boolean sentIdToFirebase = false;
private boolean hasTimeDateOrTimeZoneChanged = false;
private Profile currentProfile;
private OmnipodDashPumpPlugin() {
super(new PluginDescription() //
.mainType(PluginType.PUMP) //
.fragmentClass(OmnipodFragment.class.getName()) //
.pluginName(R.string.omnipod_dash_name) //
.shortName(R.string.omnipod_dash_name_short) //
.preferencesId(R.xml.pref_omnipod) //
.description(R.string.description_pump_omnipod_dash), //
PumpType.Insulet_Omnipod_Dash
);
displayConnectionMessages = false;
if (omnipodCommunicationManager == null) {
omnipodCommunicationManager = OmnipodDashCommunicationManager.getInstance();
}
omnipodUIComm = new OmnipodUIComm(omnipodCommunicationManager);
OmnipodUtil.setPlugin(this);
// FIXME
// serviceConnection = new ServiceConnection() {
//
// public void onServiceDisconnected(ComponentName name) {
// if (isLoggingEnabled())
// LOG.debug("RileyLinkOmnipodService is disconnected");
// omnipodService = null;
// }
//
// public void onServiceConnected(ComponentName name, IBinder service) {
// if (isLoggingEnabled())
// LOG.debug("RileyLinkOmnipodService is connected");
// RileyLinkOmnipodService.LocalBinder mLocalBinder = (RileyLinkOmnipodService.LocalBinder) service;
// omnipodService = mLocalBinder.getServiceInstance();
//
// new Thread(() -> {
//
// for (int i = 0; i < 20; i++) {
// SystemClock.sleep(5000);
//
// if (OmnipodUtil.getPumpStatus() != null) {
// if (isLoggingEnabled())
// LOG.debug("Starting OmniPod-RileyLink service");
// if (OmnipodUtil.getPumpStatus().setNotInPreInit()) {
// break;
// }
// }
// }
// }).start();
// }
// };
}
public static OmnipodDashPumpPlugin getPlugin() {
if (plugin == null)
plugin = new OmnipodDashPumpPlugin();
return plugin;
}
private String getLogPrefix() {
return "OmnipodPlugin::";
}
// FIXME
public Class getServiceClass() {
return RileyLinkOmnipodService.class;
}
@Override
public String deviceID() {
return "Omnipod Dash";
}
// Pump Plugin
private boolean isServiceSet() {
return omnipodService != null;
}
@Override
public boolean isInitialized() {
if (isLoggingEnabled() && displayConnectionMessages)
LOG.debug(getLogPrefix() + "isInitialized");
return isServiceSet() && isInitialized;
}
@Override
public boolean isConnected() {
if (isLoggingEnabled() && displayConnectionMessages)
LOG.debug(getLogPrefix() + "isConnected");
return isServiceSet() && omnipodService.isInitialized();
}
@Override
public boolean isConnecting() {
if (isLoggingEnabled() && displayConnectionMessages)
LOG.debug(getLogPrefix() + "isConnecting");
return !isServiceSet() || !omnipodService.isInitialized();
}
@Override
public void getPumpStatus() {
if (firstRun) {
initializePump(!isRefresh);
}
// getPodPumpStatus();
//
// if (firstRun) {
// initializePump(!isRefresh);
// } else {
// refreshAnyStatusThatNeedsToBeRefreshed();
// }
//
// MainApp.bus().post(new EventMedtronicPumpValuesChanged());
}
void resetStatusState() {
firstRun = true;
isRefresh = true;
}
private void setRefreshButtonEnabled(boolean enabled) {
RxBus.INSTANCE.send(new EventOmnipodRefreshButtonState(enabled));
}
private void initializePump(boolean realInit) {
if (isLoggingEnabled())
LOG.info(getLogPrefix() + "initializePump - start");
if (omnipodCommunicationManager == null) {
omnipodCommunicationManager = OmnipodDashCommunicationManager.getInstance();
}
// setRefreshButtonEnabled(false);
//
// getPodPumpStatus();
//
// if (isRefresh) {
// if (isPumpNotReachable()) {
// if (isLoggingEnabled())
// LOG.error(getLogPrefix() + "initializePump::Pump unreachable.");
// MedtronicUtil.sendNotification(MedtronicNotificationType.PumpUnreachable);
//
// setRefreshButtonEnabled(true);
//
// return;
// }
//
// MedtronicUtil.dismissNotification(MedtronicNotificationType.PumpUnreachable);
// }
//
// this.pumpState = PumpDriverState.Connected;
//
// pumpStatusLocal.setLastCommunicationToNow();
// setRefreshButtonEnabled(true);
// TODO need to read status and BasalProfile if pod inited and pod status and set correct commands enabled
if (!isRefresh) {
pumpState = PumpDriverState.Initialized;
}
if (!sentIdToFirebase) {
Bundle params = new Bundle();
params.putString("version", BuildConfig.VERSION);
MainApp.getFirebaseAnalytics().logEvent("OmnipodPumpInit", params);
sentIdToFirebase = true;
}
isInitialized = true;
// this.pumpState = PumpDriverState.Initialized;
this.firstRun = false;
}
protected void triggerUIChange() {
MainApp.bus().post(new EventOmnipodPumpValuesChanged());
}
// OPERATIONS not supported by Pump or Plugin
//private List<CustomAction> customActions = null;
@Override
public List<CustomAction> getCustomActions() {
if (customActions == null) {
this.customActions = Arrays.asList(
customActionInitPod, //
customActionDeactivatePod, //
customActionResetPod);
}
return this.customActions;
}
@Override
public void timeDateOrTimeZoneChanged() {
// if (isLoggingEnabled())
// LOG.warn(getLogPrefix() + "Time, Date and/or TimeZone changed. ");
//
// this.hasTimeDateOrTimeZoneChanged = true;
}
}

View file

@ -0,0 +1,113 @@
package info.nightscout.androidaps.plugins.pump.omnipod_dash.comm;
import android.content.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.data.PodCommResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.utils.SP;
/**
* Created by andy on 4.8.2019
*/
public class OmnipodDashCommunicationManager implements OmnipodCommunicationManagerInterface {
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
private static OmnipodDashCommunicationManager omnipodCommunicationManager;
String errorMessage;
public OmnipodDashCommunicationManager(Context context, RFSpy rfspy) {
omnipodCommunicationManager = this;
OmnipodUtil.getPumpStatus().previousConnection = SP.getLong(
RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, 0L);
}
private PodSessionState getPodSessionState() {
return null;
}
public static OmnipodDashCommunicationManager getInstance() {
return omnipodCommunicationManager;
}
//@Override
protected void configurePumpSpecificSettings() {
//pumpStatus = OmnipodUtil.getPumpStatus();
}
public String getErrorResponse() {
return this.errorMessage;
}
private boolean isLogEnabled() {
return L.isEnabled(L.PUMPCOMM);
}
// This are just skeleton methods, we need to see what we can get returned and act accordingly
public PodCommResponse initPod() {
//omnipodManager.pairAndPrime();
return null;
}
public PodCommResponse getPodStatus() {
return null;
}
public PodCommResponse deactivatePod() {
return null;
}
public PodCommResponse setBasalProfile(Profile profile) {
return null;
}
public PodCommResponse resetPodStatus() {
return null;
}
public PodCommResponse setBolus(Double parameter) {
return null;
}
public PodCommResponse cancelBolus() {
return null;
}
public PodCommResponse setTemporaryBasal(TempBasalPair tbr) {
return null;
}
public PodCommResponse cancelTemporaryBasal() {
return null;
}
@Override
public PodCommResponse acknowledgeAlerts() {
return null;
}
}

View file

@ -99,6 +99,83 @@
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<!-- Pod Address -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/omnipod_pod_address"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/omnipod_pod_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
<!-- Pod Address -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/omnipod_pod_expiry"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/omnipod_pod_expiry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -426,6 +503,52 @@
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:gravity="end"
android:paddingRight="5dp"
android:text="@string/omnipod_pod_active_alerts"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center_horizontal"
android:paddingEnd="2dp"
android:paddingStart="2dp"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/omnipod_pod_active_alerts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:paddingLeft="5dp"
android:textColor="@android:color/white"
android:textSize="14sp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dip"
android:layout_marginBottom="5dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="5dp"
android:background="@color/listdelimiter" />
</LinearLayout>
</ScrollView>
@ -466,6 +589,17 @@
android:paddingRight="0dp"
android:text="@string/omnipod_pod_mgmt" />
<Button
android:id="@+id/omnipod_pod_active_alerts_ack"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/icon_cp_aaps_offline"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/omnipod_ack_short" />
<Button
android:id="@+id/omnipod_stats"
style="@style/ButtonSmallFontStyle"

View file

@ -1674,6 +1674,12 @@
<string name="omnipod_pod_status">Pod Status</string>
<string name="omnipod_reservoir_left">%1$d U left</string>
<string name="omnipod_reservoir_over50">Over 50 U</string>
<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_active_alerts">Active Pod Alerts</string>
<string name="omnipod_ack_short">Ack Alerts</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>
@ -1689,6 +1695,15 @@
<string name="omnipod_namexxx" translatable="false">Omnipod</string>
<!-- Omnipod Dash -->
<!-- Omnipod - Base -->
<string name="omnipod_dash_name" translatable="false">Omnipod Dash</string>
<string name="omnipod_dash_name_short" translatable="false">DASH</string>
<string name="description_pump_omnipod_dash">Pump integration for Omnipod Dash.</string>
<plurals name="objective_days">
<item quantity="one">%1$d day</item>
<item quantity="other">%1$d days</item>