- fully daggerized omnipod
This commit is contained in:
parent
4d39cbba95
commit
48572d64fc
|
@ -21,7 +21,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks
|
|||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.WakeAndTuneTask;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.utils.Round;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
|
@ -34,16 +33,14 @@ public abstract class RileyLinkCommunicationManager {
|
|||
|
||||
@Inject protected AAPSLogger aapsLogger;
|
||||
@Inject protected SP sp;
|
||||
|
||||
//@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||
@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||
@Inject ServiceTaskExecutor serviceTaskExecutor;
|
||||
@Inject protected RileyLinkServiceData rileyLinkServiceData;
|
||||
@Inject protected ServiceTaskExecutor serviceTaskExecutor;
|
||||
|
||||
|
||||
private final int SCAN_TIMEOUT = 1500;
|
||||
private final int ALLOWED_PUMP_UNREACHABLE = 10 * 60 * 1000; // 10 minutes
|
||||
|
||||
protected final HasAndroidInjector injector;
|
||||
public final HasAndroidInjector injector;
|
||||
protected final RFSpy rfspy;
|
||||
protected int receiverDeviceAwakeForMinutes = 1; // override this in constructor of specific implementation
|
||||
protected String receiverDeviceID; // String representation of receiver device (ex. Pump (xxxxxx) or Pod (yyyyyy))
|
||||
|
|
|
@ -14,12 +14,9 @@ import info.nightscout.androidaps.events.EventPreferenceChange
|
|||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||
|
@ -35,9 +32,14 @@ import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefres
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.Round
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.WarnColors
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
@ -57,25 +59,18 @@ class OmnipodFragment : DaggerFragment() {
|
|||
@Inject lateinit var omnipodPumpPlugin: OmnipodPumpPlugin
|
||||
@Inject lateinit var warnColors: WarnColors
|
||||
@Inject lateinit var omnipodPumpStatus: OmnipodPumpStatus
|
||||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var omnipodUtil: OmnipodUtil
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
private val loopHandler = Handler()
|
||||
private lateinit var refreshLoop: Runnable
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//private val LOG = LoggerFactory.getLogger(L.PUMP)
|
||||
//private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
//private var podAvailable = false
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
refreshLoop = Runnable {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
|
@ -139,12 +134,6 @@ class OmnipodFragment : DaggerFragment() {
|
|||
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
|
||||
displayNotConfiguredDialog()
|
||||
} else {
|
||||
// val readPulseLog = AapsOmnipodManager.getInstance().readPulseLog()
|
||||
//
|
||||
// OKDialog.show(MainApp.instance().applicationContext, resourceHelper.gs(R.string.action),
|
||||
// "Pulse Log:\n" + readPulseLog.toString(), null)
|
||||
//
|
||||
|
||||
omnipod_pod_debug.isEnabled = false
|
||||
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.GetPodPulseLog);
|
||||
commandQueue.readStatus("Clicked Refresh", object : Callback() {
|
||||
|
@ -152,7 +141,6 @@ class OmnipodFragment : DaggerFragment() {
|
|||
activity?.runOnUiThread { omnipod_pod_debug.isEnabled = true }
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,37 +155,34 @@ class OmnipodFragment : DaggerFragment() {
|
|||
super.onResume()
|
||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
disposable += rxBus
|
||||
.toObservable(EventOmnipodRefreshButtonState::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ omnipod_refresh.isEnabled = it.newState }, { fabricPrivacy.logException(it) })
|
||||
.toObservable(EventOmnipodRefreshButtonState::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ omnipod_refresh.isEnabled = it.newState }, { fabricPrivacy.logException(it) })
|
||||
disposable += rxBus
|
||||
.toObservable(EventOmnipodDeviceStatusChange::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
if (L.isEnabled(L.PUMP))
|
||||
aapsLogger.info(LTag.PUMP,"onStatusEvent(EventOmnipodDeviceStatusChange): {}", it)
|
||||
setDeviceStatus()
|
||||
}, { fabricPrivacy.logException(it) })
|
||||
.toObservable(EventOmnipodDeviceStatusChange::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
aapsLogger.info(LTag.PUMP, "onStatusEvent(EventOmnipodDeviceStatusChange): {}", it)
|
||||
setDeviceStatus()
|
||||
}, { fabricPrivacy.logException(it) })
|
||||
disposable += rxBus
|
||||
.toObservable(EventOmnipodPumpValuesChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ updateGUI() }, { fabricPrivacy.logException(it) })
|
||||
.toObservable(EventOmnipodPumpValuesChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ updateGUI() }, { fabricPrivacy.logException(it) })
|
||||
disposable += rxBus
|
||||
.toObservable(EventOmnipodAcknowledgeAlertsChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ updateAcknowledgeAlerts() }, { fabricPrivacy.logException(it) })
|
||||
.toObservable(EventOmnipodAcknowledgeAlertsChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ updateAcknowledgeAlerts() }, { fabricPrivacy.logException(it) })
|
||||
disposable += rxBus
|
||||
.toObservable(EventPreferenceChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event ->
|
||||
setVisibilityOfPodDebugButton()
|
||||
}, { fabricPrivacy.logException(it) })
|
||||
|
||||
.toObservable(EventPreferenceChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event ->
|
||||
setVisibilityOfPodDebugButton()
|
||||
}, { fabricPrivacy.logException(it) })
|
||||
}
|
||||
|
||||
|
||||
fun setVisibilityOfPodDebugButton() {
|
||||
val isEnabled = SP.getBoolean(OmnipodConst.Prefs.PodDebuggingOptionsEnabled, false)
|
||||
val isEnabled = sp.getBoolean(OmnipodConst.Prefs.PodDebuggingOptionsEnabled, false)
|
||||
|
||||
if (isEnabled)
|
||||
omnipod_pod_debug.visibility = View.VISIBLE
|
||||
|
@ -205,7 +190,6 @@ class OmnipodFragment : DaggerFragment() {
|
|||
omnipod_pod_debug.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
||||
private fun displayNotConfiguredDialog() {
|
||||
context?.let {
|
||||
OKDialog.show(it, resourceHelper.gs(R.string.combo_warning),
|
||||
|
@ -219,41 +203,38 @@ class OmnipodFragment : DaggerFragment() {
|
|||
loopHandler.removeCallbacks(refreshLoop)
|
||||
}
|
||||
|
||||
|
||||
@Synchronized
|
||||
private fun setDeviceStatus() {
|
||||
//val omnipodPumpStatus: OmnipodPumpStatus = OmnipodUtil.getPumpStatus()
|
||||
// omnipodPumpStatus.rileyLinkServiceState = checkStatusSet(omnipodPumpStatus.rileyLinkServiceState,
|
||||
// RileyLinkUtil.getServiceState()) as RileyLinkServiceState?
|
||||
|
||||
|
||||
|
||||
aapsLogger.info(LTag.PUMP,"setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus)
|
||||
aapsLogger.info(LTag.PUMP, "setDeviceStatus: [pumpStatus={}]", omnipodPumpStatus)
|
||||
|
||||
val resourceId = omnipodPumpStatus.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
|
||||
val rileyLinkError = omnipodPumpPlugin.rileyLinkService?.error
|
||||
|
||||
omnipod_rl_status.text =
|
||||
when {
|
||||
omnipodPumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
||||
omnipodPumpStatus.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
||||
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
||||
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||
}
|
||||
when {
|
||||
omnipodPumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> resourceHelper.gs(resourceId)
|
||||
omnipodPumpStatus.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + resourceHelper.gs(resourceId)
|
||||
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||
omnipodPumpStatus.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + resourceHelper.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
||||
else -> "{fa-bluetooth-b} " + resourceHelper.gs(resourceId)
|
||||
}
|
||||
omnipod_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
||||
|
||||
// omnipodPumpStatus.rileyLinkError = checkStatusSet(omnipodPumpStatus.rileyLinkError,
|
||||
// RileyLinkUtil.getError()) as RileyLinkError?
|
||||
|
||||
omnipod_errors.text =
|
||||
omnipodPumpStatus.rileyLinkError?.let {
|
||||
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
|
||||
} ?: "-"
|
||||
omnipodPumpStatus.rileyLinkError?.let {
|
||||
resourceHelper.gs(it.getResourceId(RileyLinkTargetDevice.Omnipod))
|
||||
} ?: "-"
|
||||
|
||||
val driverState = OmnipodUtil.getDriverState();
|
||||
val driverState = omnipodUtil.getDriverState();
|
||||
|
||||
aapsLogger.info(LTag.PUMP,"getDriverState: [driverState={}]", driverState)
|
||||
aapsLogger.info(LTag.PUMP, "getDriverState: [driverState={}]", driverState)
|
||||
|
||||
if (driverState == OmnipodDriverState.NotInitalized) {
|
||||
omnipod_pod_address.text = resourceHelper.gs(R.string.omnipod_pod_name_no_info)
|
||||
|
@ -273,7 +254,7 @@ class OmnipodFragment : DaggerFragment() {
|
|||
omnipod_pod_status.text = omnipodPumpStatus.podSessionState.getSetupProgress().name
|
||||
omnipodPumpStatus.podAvailable = false
|
||||
omnipodPumpStatus.podNumber == omnipodPumpStatus.podSessionState.address.toString()
|
||||
}else {
|
||||
} else {
|
||||
omnipodPumpStatus.podLotNumber = "" + omnipodPumpStatus.podSessionState.lot
|
||||
omnipodPumpStatus.podAvailable = true
|
||||
omnipod_pod_address.text = omnipodPumpStatus.podSessionState.address.toString()
|
||||
|
@ -287,14 +268,15 @@ class OmnipodFragment : DaggerFragment() {
|
|||
|
||||
when (podDeviceState) {
|
||||
null,
|
||||
PodDeviceState.Sleeping -> omnipod_pod_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
|
||||
PodDeviceState.Sleeping -> omnipod_pod_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
|
||||
PodDeviceState.NeverContacted,
|
||||
PodDeviceState.WakingUp,
|
||||
PodDeviceState.PumpUnreachable,
|
||||
PodDeviceState.ErrorWhenCommunicating,
|
||||
PodDeviceState.TimeoutWhenCommunicating,
|
||||
PodDeviceState.InvalidConfiguration -> omnipod_pod_status.text = " " + resourceHelper.gs(podDeviceState.resourceId)
|
||||
PodDeviceState.Active -> {
|
||||
|
||||
PodDeviceState.Active -> {
|
||||
|
||||
omnipod_pod_status.text = "Active";
|
||||
// val cmd = OmnipodUtil.getCurrentCommand()
|
||||
|
@ -314,13 +296,12 @@ class OmnipodFragment : DaggerFragment() {
|
|||
// }
|
||||
// }
|
||||
}
|
||||
else -> aapsLogger.warn(LTag.PUMP,"Unknown pump state: " + omnipodPumpStatus.podDeviceState)
|
||||
|
||||
else -> aapsLogger.warn(LTag.PUMP, "Unknown pump state: " + omnipodPumpStatus.podDeviceState)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// pumpStatus.pumpDeviceState = checkStatusSet(pumpStatus.pumpDeviceState,
|
||||
// OmnipodUtil.getPumpDeviceState()) as PumpDeviceState?
|
||||
//
|
||||
|
@ -363,7 +344,6 @@ class OmnipodFragment : DaggerFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private fun checkStatusSet(object1: Any?, object2: Any?): Any? {
|
||||
return if (object1 == null) {
|
||||
object2
|
||||
|
@ -381,8 +361,8 @@ class OmnipodFragment : DaggerFragment() {
|
|||
//val omnipodPumpStatus = OmnipodUtil.getPumpStatus()
|
||||
var pumpType = omnipodPumpStatus.pumpType
|
||||
|
||||
if (pumpType==null) {
|
||||
aapsLogger.warn(LTag.PUMP,"PumpType was not set, reseting to Omnipod.")
|
||||
if (pumpType == null) {
|
||||
aapsLogger.warn(LTag.PUMP, "PumpType was not set, reseting to Omnipod.")
|
||||
pumpType = PumpType.Insulet_Omnipod;
|
||||
}
|
||||
|
||||
|
@ -403,13 +383,13 @@ class OmnipodFragment : DaggerFragment() {
|
|||
} else if (min < 1440) {
|
||||
val h = (min / 60).toInt()
|
||||
omnipod_lastconnection.text = (resourceHelper.gq(R.plurals.objective_hours, h, h) + " "
|
||||
+ resourceHelper.gs(R.string.ago))
|
||||
+ resourceHelper.gs(R.string.ago))
|
||||
} else {
|
||||
val h = (min / 60).toInt()
|
||||
val d = h / 24
|
||||
// h = h - (d * 24);
|
||||
omnipod_lastconnection.text = (resourceHelper.gq(R.plurals.objective_days, d, d) + " "
|
||||
+ resourceHelper.gs(R.string.ago))
|
||||
+ resourceHelper.gs(R.string.ago))
|
||||
}
|
||||
//omnipod_lastconnection.setTextColor(Color.RED)
|
||||
}
|
||||
|
@ -443,7 +423,7 @@ class OmnipodFragment : DaggerFragment() {
|
|||
omnipod_basabasalrate.text = resourceHelper.gs(R.string.pump_basebasalrate, pumpType.determineCorrectBasalSize(plugin.baseBasalRate))
|
||||
|
||||
omnipod_tempbasal.text = activePlugin.activeTreatments
|
||||
.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: ""
|
||||
.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: ""
|
||||
|
||||
// reservoir
|
||||
if (Round.isSame(omnipodPumpStatus.reservoirRemainingUnits, 75.0)) {
|
||||
|
@ -470,11 +450,9 @@ class OmnipodFragment : DaggerFragment() {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private fun updateAcknowledgeAlerts() {
|
||||
omnipod_pod_active_alerts_ack.isEnabled = omnipodPumpStatus.ackAlertsAvailable
|
||||
omnipod_pod_active_alerts.text = omnipodPumpStatus.ackAlertsText
|
||||
omnipod_pod_active_alerts_ack.isEnabled = omnipodPumpStatus.ackAlertsAvailable
|
||||
omnipod_pod_active_alerts.text = omnipodPumpStatus.ackAlertsText
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ import android.os.SystemClock;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -39,7 +39,6 @@ import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
|||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||
|
@ -54,7 +53,6 @@ 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.defs.RileyLinkPumpDevice;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ResetRileyLinkConfigurationTask;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
||||
|
@ -76,7 +74,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodS
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
|
||||
import info.nightscout.androidaps.utils.Round;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
@ -91,8 +89,7 @@ import io.reactivex.schedulers.Schedulers;
|
|||
@Singleton
|
||||
public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPumpPluginInterface, RileyLinkPumpDevice {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
// TODO Dagger (maybe done)
|
||||
private static OmnipodPumpPlugin plugin = null;
|
||||
private RileyLinkServiceData rileyLinkServiceData;
|
||||
private ServiceTaskExecutor serviceTaskExecutor;
|
||||
|
@ -100,6 +97,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
private OmnipodUtil omnipodUtil;
|
||||
protected OmnipodPumpStatus omnipodPumpStatus = null;
|
||||
protected OmnipodUIComm omnipodUIComm;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
|
||||
|
@ -170,7 +168,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
// // TODO ccc
|
||||
|
||||
|
||||
|
||||
serviceConnection = new ServiceConnection() {
|
||||
|
||||
@Override
|
||||
|
@ -199,7 +196,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
}
|
||||
|
||||
|
||||
|
||||
// if (OmnipodPumpPlugin.this.omnipodPumpStatus != null) {
|
||||
//
|
||||
// aapsLogger.debug(LTag.PUMP, "Starting OmniPod-RileyLink service");
|
||||
|
@ -346,9 +342,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
}
|
||||
|
||||
private void doPodCheck() {
|
||||
|
||||
if (System.currentTimeMillis() > this.nextPodCheck) {
|
||||
if (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) {
|
||||
if (omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_NoPod) {
|
||||
Notification notification = new Notification(Notification.OMNIPOD_POD_NOT_ATTACHED, resourceHelper.gs(R.string.omnipod_error_pod_not_attached), Notification.NORMAL);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
} else {
|
||||
|
@ -522,7 +517,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||
i.putExtra("soundid", 0);
|
||||
i.putExtra("status", "Pulse Log (copied to clipboard):\n" + result.toString());
|
||||
i.putExtra("title", MainApp.gs(R.string.combo_warning));
|
||||
i.putExtra("title", resourceHelper.gs(R.string.combo_warning));
|
||||
i.putExtra("clipboardContent", result.toString());
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
|
@ -573,9 +568,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
// TODO read pod status
|
||||
aapsLogger.error(LTag.PUMP, "getPodPumpStatus() NOT IMPLEMENTED");
|
||||
|
||||
//addPodStatusRequest(OmnipodStatusRequest.GetPodState);
|
||||
|
||||
//getPodPumpStatusObject().driverState = OmnipodDriverState.Initalized_PodAvailable;
|
||||
//driverState = OmnipodDriverState.Initalized_PodAvailable;
|
||||
OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAttached);
|
||||
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodAttached);
|
||||
// we would probably need to read Basal Profile here too
|
||||
}
|
||||
|
||||
|
@ -627,7 +624,8 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
aapsLogger.info(LTag.PUMP, "PodSessionState-SP: loaded from SharedPreferences: " + podState);
|
||||
|
||||
if (podState != null) {
|
||||
podSessionState = OmnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class);
|
||||
podSessionState = omnipodUtil.getGsonInstance().fromJson(podState, PodSessionState.class);
|
||||
podSessionState.injectDaggerClass(injector);
|
||||
omnipodUtil.setPodSessionState(podSessionState);
|
||||
}
|
||||
}
|
||||
|
@ -645,8 +643,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
|
||||
} else {
|
||||
aapsLogger.debug(LTag.PUMP, "No PodSessionState found. Pod probably not running.");
|
||||
//podPumpStatus.driverState = OmnipodDriverState.Initalized_NoPod;
|
||||
OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod);
|
||||
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod);
|
||||
}
|
||||
|
||||
finishAction("Omnipod Pump");
|
||||
|
@ -681,8 +678,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
|
||||
@Override
|
||||
public long lastDataTime() {
|
||||
getPodPumpStatusObject();
|
||||
|
||||
if (omnipodPumpStatus.lastConnection != 0) {
|
||||
return omnipodPumpStatus.lastConnection;
|
||||
}
|
||||
|
@ -705,7 +700,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
|
||||
@Override
|
||||
public double getReservoirLevel() {
|
||||
return getPodPumpStatusObject().reservoirRemainingUnits;
|
||||
return omnipodPumpStatus.reservoirRemainingUnits;
|
||||
}
|
||||
|
||||
|
||||
|
@ -715,21 +710,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
}
|
||||
|
||||
|
||||
protected OmnipodPumpStatus getPodPumpStatusObject() {
|
||||
if (omnipodPumpStatus == null) {
|
||||
// FIXME I don't know why this happens
|
||||
|
||||
aapsLogger.warn(LTag.PUMP, "!!!! Reset Pump Status Local");
|
||||
// pumpStatusLocal = OmnipodUtil.getPumpStatus();
|
||||
// if (omnipodCommunicationManager != null) {
|
||||
// omnipodCommunicationManager.setPumpStatus(pumpStatusLocal);
|
||||
// }
|
||||
}
|
||||
|
||||
return omnipodPumpStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void triggerUIChange() {
|
||||
rxBus.send(new EventOmnipodPumpValuesChanged());
|
||||
|
@ -810,25 +790,20 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile,
|
||||
boolean enforceNew) {
|
||||
|
||||
getPodPumpStatusObject();
|
||||
|
||||
setRefreshButtonEnabled(false);
|
||||
|
||||
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "setTempBasalAbsolute: rate: {}, duration={}", absoluteRate, durationInMinutes);
|
||||
|
||||
// read current TBR
|
||||
TempBasalPair tbrCurrent = readTBR();
|
||||
|
||||
if (tbrCurrent != null) {
|
||||
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "setTempBasalAbsolute: Current Basal: duration: {} min, rate={}",
|
||||
tbrCurrent.getDurationMinutes(), tbrCurrent.getInsulinRate());
|
||||
}
|
||||
|
||||
if (tbrCurrent != null && !enforceNew) {
|
||||
if (OmnipodUtil.isSame(tbrCurrent.getInsulinRate(), absoluteRate)) {
|
||||
|
||||
if (Round.isSame(tbrCurrent.getInsulinRate(), absoluteRate)) {
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "setTempBasalAbsolute - No enforceNew and same rate. Exiting.");
|
||||
finishAction("TBR");
|
||||
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
||||
|
@ -864,7 +839,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
|
||||
PumpEnactResult result = responseTask.getResult();
|
||||
|
||||
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "setTempBasalAbsolute - setTBR. Response: " + result.success);
|
||||
|
||||
if (result.success) {
|
||||
|
@ -920,7 +894,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
finishAction("TBR");
|
||||
|
||||
if (result.success) {
|
||||
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "cancelTempBasal - Cancel TBR successful.");
|
||||
|
||||
TemporaryBasal tempBasal = new TemporaryBasal() //
|
||||
|
@ -930,21 +903,22 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
|
||||
activePlugin.getActiveTreatments().addToHistoryTempBasal(tempBasal);
|
||||
} else {
|
||||
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "cancelTempBasal - Cancel TBR failed.");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String serialNumber() {
|
||||
return getPodPumpStatusObject().podNumber;
|
||||
return StringUtils.isNotBlank(omnipodPumpStatus.podNumber) ?
|
||||
omnipodPumpStatus.podNumber : "None";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
||||
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "setNewBasalProfile");
|
||||
|
||||
// this shouldn't be needed, but let's do check if profile setting we are setting is same as current one
|
||||
|
@ -952,7 +926,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
return new PumpEnactResult(getInjector()) //
|
||||
.success(true) //
|
||||
.enacted(false) //
|
||||
.comment(MainApp.gs(R.string.medtronic_cmd_basal_profile_not_set_is_same));
|
||||
.comment(resourceHelper.gs(R.string.medtronic_cmd_basal_profile_not_set_is_same));
|
||||
}
|
||||
|
||||
setRefreshButtonEnabled(false);
|
||||
|
@ -962,16 +936,19 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
|
||||
PumpEnactResult result = responseTask.getResult();
|
||||
|
||||
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "Basal Profile was set: " + result.success);
|
||||
|
||||
if (result.success) {
|
||||
this.currentProfile = profile;
|
||||
|
||||
Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.gs(R.string.profile_set_ok), Notification.INFO, 60);
|
||||
Notification notification = new Notification(Notification.PROFILE_SET_OK,
|
||||
resourceHelper.gs(R.string.profile_set_ok),
|
||||
Notification.INFO, 60);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
} else {
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE,
|
||||
resourceHelper.gs(R.string.failedupdatebasalprofile),
|
||||
Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
}
|
||||
|
||||
|
@ -997,13 +974,11 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
}
|
||||
|
||||
return this.customActions;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void executeCustomAction(CustomActionType customActionType) {
|
||||
|
||||
OmnipodCustomActionType mcat = (OmnipodCustomActionType) customActionType;
|
||||
|
||||
switch (mcat) {
|
||||
|
@ -1016,15 +991,13 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||
|
||||
aapsLogger.warn(LTag.PUMP, getLogPrefix() + "Time, Date and/or TimeZone changed. [changeType=" + timeChangeType.name() + ", eventHandlingEnabled=" + omnipodPumpStatus.timeChangeEventEnabled + "]");
|
||||
|
||||
if (OmnipodUtil.getDriverState() == OmnipodDriverState.Initalized_PodAttached) {
|
||||
if (omnipodUtil.getDriverState() == OmnipodDriverState.Initalized_PodAttached) {
|
||||
if (omnipodPumpStatus.timeChangeEventEnabled) {
|
||||
aapsLogger.info(LTag.PUMP, getLogPrefix() + "Time,and/or TimeZone changed event received and will be consumed by driver.");
|
||||
this.hasTimeDateOrTimeZoneChanged = true;
|
||||
|
@ -1034,8 +1007,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
|
||||
@Override
|
||||
public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
|
||||
getPodPumpStatusObject();
|
||||
|
||||
if (omnipodPumpStatus.lastConnection != 0 || omnipodPumpStatus.lastErrorConnection != 0) {
|
||||
if (omnipodPumpStatus.lastConnection + unreachableTimeoutMilliseconds < System.currentTimeMillis()) {
|
||||
if (omnipodPumpStatus.lastErrorConnection > omnipodPumpStatus.lastConnection) {
|
||||
|
@ -1048,7 +1019,6 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
|
|||
// This happens when we simply didn't need to send any commands to the pump
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.comm;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,7 +7,6 @@ import javax.inject.Inject;
|
|||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||
|
@ -23,14 +19,17 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.Rile
|
|||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTaskExecutor;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicConverter;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.MedtronicPumpHistoryDecoder;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.OmnipodAction;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommunicationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalPacketTypeException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalResponseException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceOutOfSyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceResyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NotEnoughDataException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodReturnedErrorResponseException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodPacket;
|
||||
|
@ -44,30 +43,20 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.MessageBlockType;
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PacketType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommunicationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalPacketTypeException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalResponseException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceOutOfSyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceResyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NotEnoughDataException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodReturnedErrorResponseException;
|
||||
|
||||
/**
|
||||
* Created by andy on 6/29/18.
|
||||
*/
|
||||
public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
||||
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject public AAPSLogger aapsLogger;
|
||||
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
||||
@Inject OmnipodPumpPlugin omnipodPumpPlugin;
|
||||
@Inject RileyLinkServiceData rileyLinkServiceData;
|
||||
@Inject ServiceTaskExecutor serviceTaskExecutor;
|
||||
|
||||
//private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
||||
public OmnipodCommunicationManager(HasAndroidInjector injector, RFSpy rfspy) {
|
||||
super(injector, rfspy);
|
||||
omnipodPumpStatus.previousConnection = sp.getLong(
|
||||
|
@ -140,9 +129,8 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
|||
|
||||
public synchronized <T extends MessageBlock> T exchangeMessages(Class<T> responseClass, PodState podState, OmnipodMessage message, Integer addressOverride, Integer ackAddressOverride, boolean automaticallyResyncNonce) {
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Exchanging OmnipodMessage [responseClass={}, podState={}, message={}, addressOverride={}, ackAddressOverride={}, automaticallyResyncNonce={}]: {}", //
|
||||
responseClass.getSimpleName(), podState, message, addressOverride, ackAddressOverride, automaticallyResyncNonce, message);
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Exchanging OmnipodMessage [responseClass={}, podState={}, message={}, addressOverride={}, ackAddressOverride={}, automaticallyResyncNonce={}]: {}", //
|
||||
responseClass.getSimpleName(), podState, message, addressOverride, ackAddressOverride, automaticallyResyncNonce, message);
|
||||
|
||||
for (int i = 0; 2 > i; i++) {
|
||||
|
||||
|
@ -235,8 +223,7 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
|||
// so it's impossible for the pod to have received the message
|
||||
newException.setCertainFailure(!lastPacket);
|
||||
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Caught exception in transportMessages. Set certainFailure to {} because encodedMessage.length={}", newException.isCertainFailure(), encodedMessage.length);
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Caught exception in transportMessages. Set certainFailure to {} because encodedMessage.length={}", newException.isCertainFailure(), encodedMessage.length);
|
||||
|
||||
throw newException;
|
||||
}
|
||||
|
@ -281,7 +268,7 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
|||
throw new NotEnoughDataException(receivedMessageData);
|
||||
} else if (messageBlocks.size() > 1) {
|
||||
// BS: don't expect this to happen
|
||||
aapsLogger.error(LTag.PUMPCOMM,"Received more than one message block: {}", messageBlocks.toString());
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "Received more than one message block: {}", messageBlocks.toString());
|
||||
}
|
||||
|
||||
return messageBlocks.get(0);
|
||||
|
@ -308,10 +295,10 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
|||
if (RileyLinkBLEError.Timeout.equals(ex.getErrorCode())) {
|
||||
quiet = true;
|
||||
} else {
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Ignoring exception in ackUntilQuiet", ex);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Ignoring exception in ackUntilQuiet", ex);
|
||||
}
|
||||
} catch (OmnipodException ex) {
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Ignoring exception in ackUntilQuiet", ex);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Ignoring exception in ackUntilQuiet", ex);
|
||||
} catch (Exception ex) {
|
||||
throw new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex);
|
||||
}
|
||||
|
@ -335,7 +322,7 @@ public class OmnipodCommunicationManager extends RileyLinkCommunicationManager {
|
|||
try {
|
||||
response = sendAndListen(packet, responseTimeoutMilliseconds, repeatCount, 9, preambleExtensionMilliseconds, OmnipodPacket.class);
|
||||
} catch (RileyLinkCommunicationException | OmnipodException ex) {
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Ignoring exception in exchangePackets", ex);
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Ignoring exception in exchangePackets", ex);
|
||||
} catch (Exception ex) {
|
||||
throw new CommunicationException(CommunicationException.Type.UNEXPECTED_EXCEPTION, ex);
|
||||
}
|
||||
|
|
|
@ -3,18 +3,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm;
|
|||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.Duration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AcknowledgeAlertsAction;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AssignAddressAction;
|
||||
|
@ -30,6 +24,11 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.SetBasalSched
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.SetTempBasalAction;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.InsertCannulaService;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PrimeService;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommunicationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalDeliveryStatusException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceOutOfSyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.CancelDeliveryCommand;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
|
||||
|
@ -42,14 +41,8 @@ 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.defs.state.PodSessionState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodStateChangedHandler;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommunicationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalDeliveryStatusException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceOutOfSyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.Flowable;
|
||||
|
@ -61,8 +54,6 @@ import io.reactivex.subjects.SingleSubject;
|
|||
public class OmnipodManager {
|
||||
private static final int ACTION_VERIFICATION_TRIES = 3;
|
||||
|
||||
//private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
protected final OmnipodCommunicationManager communicationService;
|
||||
private final PodStateChangedHandler podStateChangedHandler;
|
||||
protected PodSessionState podState;
|
||||
|
@ -70,19 +61,23 @@ public class OmnipodManager {
|
|||
private ActiveBolusData activeBolusData;
|
||||
private final Object bolusDataMutex = new Object();
|
||||
|
||||
private HasAndroidInjector injector;
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject SP sp;
|
||||
//private HasAndroidInjector injector;
|
||||
AAPSLogger aapsLogger;
|
||||
SP sp;
|
||||
|
||||
public OmnipodManager(HasAndroidInjector injector,
|
||||
public OmnipodManager(//HasAndroidInjector injector,
|
||||
AAPSLogger aapsLogger,
|
||||
SP sp,
|
||||
OmnipodCommunicationManager communicationService,
|
||||
PodSessionState podState,
|
||||
PodStateChangedHandler podStateChangedHandler) {
|
||||
this.injector = injector;
|
||||
this.injector.androidInjector().inject(this);
|
||||
// this.injector = injector;
|
||||
// this.injector.androidInjector().inject(this);
|
||||
if (communicationService == null) {
|
||||
throw new IllegalArgumentException("Communication service cannot be null");
|
||||
}
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.sp = sp;
|
||||
this.communicationService = communicationService;
|
||||
if (podState != null) {
|
||||
podState.setStateChangedHandler(podStateChangedHandler);
|
||||
|
@ -91,11 +86,11 @@ public class OmnipodManager {
|
|||
this.podStateChangedHandler = podStateChangedHandler;
|
||||
}
|
||||
|
||||
public OmnipodManager(HasAndroidInjector injector,
|
||||
OmnipodCommunicationManager communicationService,
|
||||
PodSessionState podState) {
|
||||
this(injector, communicationService, podState, null);
|
||||
}
|
||||
// public OmnipodManager(HasAndroidInjector injector,
|
||||
// OmnipodCommunicationManager communicationService,
|
||||
// PodSessionState podState) {
|
||||
// this(injector, communicationService, podState, null);
|
||||
// }
|
||||
|
||||
public synchronized Single<SetupActionResult> pairAndPrime() {
|
||||
logStartingCommandExecution("pairAndPrime");
|
||||
|
@ -121,7 +116,7 @@ public class OmnipodManager {
|
|||
|
||||
return Single.timer(delayInSeconds, TimeUnit.SECONDS) //
|
||||
.map(o -> verifySetupAction(statusResponse ->
|
||||
PrimeAction.updatePrimingStatus(podState, statusResponse), SetupProgress.PRIMING_FINISHED)) //
|
||||
PrimeAction.updatePrimingStatus(podState, statusResponse, aapsLogger), SetupProgress.PRIMING_FINISHED)) //
|
||||
.observeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
|
@ -144,7 +139,7 @@ public class OmnipodManager {
|
|||
|
||||
return Single.timer(delayInSeconds, TimeUnit.SECONDS) //
|
||||
.map(o -> verifySetupAction(statusResponse ->
|
||||
InsertCannulaAction.updateCannulaInsertionStatus(podState, statusResponse), SetupProgress.COMPLETED)) //
|
||||
InsertCannulaAction.updateCannulaInsertionStatus(podState, statusResponse, aapsLogger), SetupProgress.COMPLETED)) //
|
||||
.observeOn(Schedulers.io());
|
||||
}
|
||||
|
||||
|
@ -254,9 +249,7 @@ public class OmnipodManager {
|
|||
try {
|
||||
return executeAndVerify(() -> {
|
||||
StatusResponse statusResponse = communicationService.executeAction(new CancelDeliveryAction(podState, deliveryTypes, acknowledgementBeep));
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.info(LTag.PUMPCOMM,"Status response after cancel delivery[types={}]: {}", deliveryTypes.toString(), statusResponse.toString());
|
||||
}
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "Status response after cancel delivery[types={}]: {}", deliveryTypes.toString(), statusResponse.toString());
|
||||
return statusResponse;
|
||||
});
|
||||
} finally {
|
||||
|
@ -282,9 +275,7 @@ public class OmnipodManager {
|
|||
}
|
||||
|
||||
// Catch uncertain exceptions as we still want to report bolus progress indication
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.error(LTag.PUMPCOMM,"Caught exception[certainFailure=false] in bolus", ex);
|
||||
}
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "Caught exception[certainFailure=false] in bolus", ex);
|
||||
commandDeliveryStatus = CommandDeliveryStatus.UNCERTAIN_FAILURE;
|
||||
} finally {
|
||||
logCommandExecutionFinished("bolus");
|
||||
|
@ -335,14 +326,10 @@ public class OmnipodManager {
|
|||
// Substract units not delivered in case of a Pod failure
|
||||
unitsNotDelivered = ex.getFaultEvent().getInsulinNotDelivered();
|
||||
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Caught PodFaultException in bolus completion verification", ex);
|
||||
}
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Caught PodFaultException in bolus completion verification", ex);
|
||||
break;
|
||||
} catch (Exception ex) {
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Ignoring exception in bolus completion verification", ex);
|
||||
}
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Ignoring exception in bolus completion verification", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,23 +433,19 @@ public class OmnipodManager {
|
|||
|
||||
// Try to get pulse log for diagnostics
|
||||
// FIXME replace by storing to file
|
||||
if (isLoggingEnabled()) {
|
||||
try {
|
||||
PodInfoResponse podInfoResponse = communicationService.executeAction(new GetPodInfoAction(podState, PodInfoType.RECENT_PULSE_LOG));
|
||||
PodInfoRecentPulseLog pulseLogInfo = podInfoResponse.getPodInfo();
|
||||
aapsLogger.info(LTag.PUMPCOMM,"Retrieved pulse log from the pod: {}", pulseLogInfo.toString());
|
||||
} catch (Exception ex) {
|
||||
aapsLogger.warn(LTag.PUMPCOMM,"Failed to retrieve pulse log from the pod", ex);
|
||||
}
|
||||
try {
|
||||
PodInfoResponse podInfoResponse = communicationService.executeAction(new GetPodInfoAction(podState, PodInfoType.RECENT_PULSE_LOG));
|
||||
PodInfoRecentPulseLog pulseLogInfo = podInfoResponse.getPodInfo();
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "Retrieved pulse log from the pod: {}", pulseLogInfo.toString());
|
||||
} catch (Exception ex) {
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Failed to retrieve pulse log from the pod", ex);
|
||||
}
|
||||
|
||||
try {
|
||||
// Always send acknowledgement beeps here. Matches the PDM's behavior
|
||||
communicationService.executeAction(new DeactivatePodAction(podState, true));
|
||||
} catch (PodFaultException ex) {
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.info(LTag.PUMPCOMM,"Ignoring PodFaultException in deactivatePod", ex);
|
||||
}
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "Ignoring PodFaultException in deactivatePod", ex);
|
||||
} finally {
|
||||
logCommandExecutionFinished("deactivatePod");
|
||||
}
|
||||
|
@ -471,9 +454,7 @@ public class OmnipodManager {
|
|||
}
|
||||
|
||||
public void resetPodState(boolean forcedByUser) {
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.warn(LTag.PUMPCOMM,"resetPodState has been called. forcedByUser={}", forcedByUser);
|
||||
}
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "resetPodState has been called. forcedByUser={}", forcedByUser);
|
||||
podState = null;
|
||||
sp.remove(OmnipodConst.Prefs.PodState);
|
||||
}
|
||||
|
@ -514,23 +495,18 @@ public class OmnipodManager {
|
|||
if (isCertainFailure(originalException)) {
|
||||
throw originalException;
|
||||
} else {
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.warn(LTag.PUMPCOMM,"Caught exception in executeAndVerify. Verifying command by using cancel none command to verify nonce", originalException);
|
||||
}
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "Caught exception in executeAndVerify. Verifying command by using cancel none command to verify nonce", originalException);
|
||||
|
||||
try {
|
||||
logStartingCommandExecution("verifyCommand");
|
||||
StatusResponse statusResponse = communicationService.sendCommand(StatusResponse.class, podState,
|
||||
new CancelDeliveryCommand(podState.getCurrentNonce(), BeepType.NO_BEEP, DeliveryType.NONE), false);
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.info(LTag.PUMPCOMM,"Command status resolved to SUCCESS. Status response after cancelDelivery[types=DeliveryType.NONE]: {}", statusResponse);
|
||||
}
|
||||
aapsLogger.info(LTag.PUMPBTCOMM, "Command status resolved to SUCCESS. Status response after cancelDelivery[types=DeliveryType.NONE]: {}", statusResponse);
|
||||
|
||||
return statusResponse;
|
||||
} catch (NonceOutOfSyncException verificationException) {
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.error(LTag.PUMPCOMM,"Command resolved to FAILURE (CERTAIN_FAILURE)", verificationException);
|
||||
}
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "Command resolved to FAILURE (CERTAIN_FAILURE)", verificationException);
|
||||
|
||||
if (originalException instanceof OmnipodException) {
|
||||
((OmnipodException) originalException).setCertainFailure(true);
|
||||
throw originalException;
|
||||
|
@ -540,9 +516,7 @@ public class OmnipodManager {
|
|||
throw newException;
|
||||
}
|
||||
} catch (Exception verificationException) {
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.error(LTag.PUMPCOMM,"Command unresolved (UNCERTAIN_FAILURE)", verificationException);
|
||||
}
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "Command unresolved (UNCERTAIN_FAILURE)", verificationException);
|
||||
throw originalException;
|
||||
} finally {
|
||||
logCommandExecutionFinished("verifyCommand");
|
||||
|
@ -581,20 +555,11 @@ public class OmnipodManager {
|
|||
}
|
||||
|
||||
private void logStartingCommandExecution(String action) {
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Starting command execution for action: " + action);
|
||||
}
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Starting command execution for action: " + action);
|
||||
}
|
||||
|
||||
private void logCommandExecutionFinished(String action) {
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Command execution finished for action: " + action);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO remove this
|
||||
private boolean isLoggingEnabled() {
|
||||
return true;
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Command execution finished for action: " + action);
|
||||
}
|
||||
|
||||
private static Duration calculateBolusDuration(double units, double deliveryRate) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class AssignAddressAction implements OmnipodAction<PodSessionState> {
|
|||
|
||||
PodSessionState podState = new PodSessionState(timeZone, address, assignAddressResponse.getPiVersion(),
|
||||
assignAddressResponse.getPmVersion(), assignAddressResponse.getLot(), assignAddressResponse.getTid(),
|
||||
setupState.getPacketNumber(), 0x00); // At this point, for an unknown reason, the pod starts counting messages from 0 again
|
||||
setupState.getPacketNumber(), 0x00, communicationService.injector); // At this point, for an unknown reason, the pod starts counting messages from 0 again
|
||||
|
||||
podState.setStateChangedHandler(podStateChangedHandler);
|
||||
return podState;
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.InsertCannulaService;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.ActionInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||
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.defs.state.PodSessionState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.ActionInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||
|
||||
public class InsertCannulaAction implements OmnipodAction<StatusResponse> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(InsertCannulaAction.class);
|
||||
|
||||
private final PodSessionState podState;
|
||||
private final InsertCannulaService service;
|
||||
|
@ -34,12 +32,10 @@ public class InsertCannulaAction implements OmnipodAction<StatusResponse> {
|
|||
this.initialBasalSchedule = initialBasalSchedule;
|
||||
}
|
||||
|
||||
public static void updateCannulaInsertionStatus(PodSessionState podState, StatusResponse statusResponse) {
|
||||
public static void updateCannulaInsertionStatus(PodSessionState podState, StatusResponse statusResponse, AAPSLogger aapsLogger) {
|
||||
if (podState.getSetupProgress().equals(SetupProgress.CANNULA_INSERTING) &&
|
||||
statusResponse.getPodProgressStatus().isReadyForDelivery()) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Updating SetupProgress from CANNULA_INSERTING to COMPLETED");
|
||||
}
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Updating SetupProgress from CANNULA_INSERTING to COMPLETED");
|
||||
podState.setSetupProgress(SetupProgress.COMPLETED);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +62,7 @@ public class InsertCannulaAction implements OmnipodAction<StatusResponse> {
|
|||
} else if (podState.getSetupProgress().equals(SetupProgress.CANNULA_INSERTING)) {
|
||||
// Check status
|
||||
StatusResponse statusResponse = communicationService.executeAction(new GetStatusAction(podState));
|
||||
updateCannulaInsertionStatus(podState, statusResponse);
|
||||
updateCannulaInsertionStatus(podState, statusResponse, communicationService.aapsLogger);
|
||||
return statusResponse;
|
||||
} else {
|
||||
throw new IllegalSetupProgressException(null, podState.getSetupProgress());
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.comm.action;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.service.PrimeService;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.ActionInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.ActionInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||
|
||||
public class PrimeAction implements OmnipodAction<StatusResponse> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PrimeAction.class);
|
||||
|
||||
private final PrimeService service;
|
||||
private final PodSessionState podState;
|
||||
|
@ -29,11 +27,9 @@ public class PrimeAction implements OmnipodAction<StatusResponse> {
|
|||
this.podState = podState;
|
||||
}
|
||||
|
||||
public static void updatePrimingStatus(PodSessionState podState, StatusResponse statusResponse) {
|
||||
public static void updatePrimingStatus(PodSessionState podState, StatusResponse statusResponse, AAPSLogger aapsLogger) {
|
||||
if (podState.getSetupProgress().equals(SetupProgress.PRIMING) && statusResponse.getPodProgressStatus().equals(PodProgressStatus.READY_FOR_BASAL_SCHEDULE)) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Updating SetupProgress from PRIMING to PRIMING_FINISHED");
|
||||
}
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Updating SetupProgress from PRIMING to PRIMING_FINISHED");
|
||||
podState.setSetupProgress(SetupProgress.PRIMING_FINISHED);
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +52,7 @@ public class PrimeAction implements OmnipodAction<StatusResponse> {
|
|||
} else if (podState.getSetupProgress().equals(SetupProgress.PRIMING)) {
|
||||
// Check status
|
||||
StatusResponse statusResponse = communicationService.executeAction(new GetStatusAction(podState));
|
||||
updatePrimingStatus(podState, statusResponse);
|
||||
updatePrimingStatus(podState, statusResponse, communicationService.aapsLogger);
|
||||
return statusResponse;
|
||||
} else {
|
||||
throw new IllegalSetupProgressException(null, podState.getSetupProgress());
|
||||
|
|
|
@ -5,13 +5,15 @@ import com.google.gson.Gson;
|
|||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.Duration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultEvent;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet;
|
||||
|
@ -26,10 +28,14 @@ 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;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
|
||||
public class PodSessionState extends PodState {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject SP sp;
|
||||
@Inject OmnipodUtil omnipodUtil;
|
||||
|
||||
private final Map<AlertSlot, AlertType> configuredAlerts;
|
||||
private transient PodStateChangedHandler stateChangedHandler;
|
||||
|
@ -50,8 +56,9 @@ public class PodSessionState extends PodState {
|
|||
private DeliveryStatus lastDeliveryStatus;
|
||||
|
||||
public PodSessionState(DateTimeZone timeZone, int address, FirmwareVersion piVersion,
|
||||
FirmwareVersion pmVersion, int lot, int tid, int packetNumber, int messageNumber) {
|
||||
FirmwareVersion pmVersion, int lot, int tid, int packetNumber, int messageNumber, HasAndroidInjector injector) {
|
||||
super(address, messageNumber, packetNumber);
|
||||
injectDaggerClass(injector);
|
||||
if (timeZone == null) {
|
||||
throw new IllegalArgumentException("Time zone can not be null");
|
||||
}
|
||||
|
@ -70,6 +77,10 @@ public class PodSessionState extends PodState {
|
|||
handleUpdates();
|
||||
}
|
||||
|
||||
public void injectDaggerClass(HasAndroidInjector injector) {
|
||||
injector.androidInjector().inject(this);
|
||||
}
|
||||
|
||||
public void setStateChangedHandler(PodStateChangedHandler handler) {
|
||||
// FIXME this is an ugly workaround for not being able to serialize the PodStateChangedHandler
|
||||
if (stateChangedHandler != null) {
|
||||
|
@ -241,7 +252,7 @@ public class PodSessionState extends PodState {
|
|||
|
||||
boolean newSuspendedState = statusResponse.getDeliveryStatus() == DeliveryStatus.SUSPENDED;
|
||||
if (suspended != newSuspendedState) {
|
||||
LOG.info("Updating pod suspended state in updateFromStatusResponse. newSuspendedState={}, statusResponse={}", newSuspendedState, statusResponse.toString());
|
||||
aapsLogger.info(LTag.PUMPCOMM, "Updating pod suspended state in updateFromStatusResponse. newSuspendedState={}, statusResponse={}", newSuspendedState, statusResponse.toString());
|
||||
suspended = newSuspendedState;
|
||||
}
|
||||
activeAlerts = statusResponse.getAlerts();
|
||||
|
@ -251,10 +262,10 @@ public class PodSessionState extends PodState {
|
|||
}
|
||||
|
||||
private void handleUpdates() {
|
||||
Gson gson = OmnipodUtil.getGsonInstance();
|
||||
Gson gson = omnipodUtil.getGsonInstance();
|
||||
String gsonValue = gson.toJson(this);
|
||||
LOG.info("PodSessionState-SP: Saved Session State to SharedPreferences: " + gsonValue);
|
||||
SP.putString(OmnipodConst.Prefs.PodState, gsonValue);
|
||||
aapsLogger.info(LTag.PUMPCOMM, "PodSessionState-SP: Saved Session State to SharedPreferences: " + gsonValue);
|
||||
sp.putString(OmnipodConst.Prefs.PodState, gsonValue);
|
||||
if (stateChangedHandler != null) {
|
||||
stateChangedHandler.handle(this);
|
||||
}
|
||||
|
|
|
@ -13,8 +13,7 @@ import android.widget.TextView;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
@ -22,26 +21,32 @@ import java.util.Collections;
|
|||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ProfileUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistory;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
|
||||
public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject OmnipodUtil omnipodUtil;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
|
||||
Spinner historyTypeSpinner;
|
||||
TextView statusView;
|
||||
RecyclerView recyclerView;
|
||||
LinearLayoutManager llm;
|
||||
private Spinner historyTypeSpinner;
|
||||
private TextView statusView;
|
||||
private RecyclerView recyclerView;
|
||||
private LinearLayoutManager linearLayoutManager;
|
||||
|
||||
static TypeList showingType = null;
|
||||
static PumpHistoryEntryGroup selectedGroup = PumpHistoryEntryGroup.All;
|
||||
|
@ -73,7 +78,7 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
|||
|
||||
this.filteredHistoryList.clear();
|
||||
|
||||
LOG.debug("Items on full list: {}", fullHistoryList.size());
|
||||
aapsLogger.debug(LTag.PUMP, "Items on full list: {}", fullHistoryList.size());
|
||||
|
||||
if (group == PumpHistoryEntryGroup.All) {
|
||||
this.filteredHistoryList.addAll(fullHistoryList);
|
||||
|
@ -90,7 +95,7 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
|||
this.recyclerViewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
LOG.debug("Items on filtered list: {}", filteredHistoryList.size());
|
||||
aapsLogger.debug(LTag.PUMP, "Items on filtered list: {}", filteredHistoryList.size());
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,13 +133,13 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.omnipod_pod_history_activity);
|
||||
|
||||
historyTypeSpinner = (Spinner) findViewById(R.id.omnipod_historytype);
|
||||
statusView = (TextView) findViewById(R.id.omnipod_historystatus);
|
||||
recyclerView = (RecyclerView) findViewById(R.id.omnipod_history_recyclerview);
|
||||
|
||||
historyTypeSpinner = findViewById(R.id.omnipod_historytype);
|
||||
statusView = findViewById(R.id.omnipod_historystatus);
|
||||
recyclerView = findViewById(R.id.omnipod_history_recyclerview);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
llm = new LinearLayoutManager(this);
|
||||
recyclerView.setLayoutManager(llm);
|
||||
|
||||
linearLayoutManager = new LinearLayoutManager(this);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
|
||||
prepareData();
|
||||
|
||||
|
@ -188,41 +193,34 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
|||
PumpHistoryEntryGroup entryGroup;
|
||||
String name;
|
||||
|
||||
|
||||
TypeList(PumpHistoryEntryGroup entryGroup) {
|
||||
this.entryGroup = entryGroup;
|
||||
this.name = entryGroup.getTranslated();
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder> {
|
||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder> {
|
||||
|
||||
List<PodHistory> historyList;
|
||||
|
||||
|
||||
RecyclerViewAdapter(List<PodHistory> historyList) {
|
||||
this.historyList = historyList;
|
||||
}
|
||||
|
||||
|
||||
public void setHistoryList(List<PodHistory> historyList) {
|
||||
// this.historyList.clear();
|
||||
// this.historyList.addAll(historyList);
|
||||
|
||||
this.historyList = historyList;
|
||||
|
||||
Collections.sort(this.historyList);
|
||||
|
||||
// this.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.omnipod_pod_history_item, //
|
||||
|
@ -232,7 +230,7 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
|||
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(HistoryViewHolder holder, int position) {
|
||||
public void onBindViewHolder(@NotNull HistoryViewHolder holder, int position) {
|
||||
PodHistory record = historyList.get(position);
|
||||
|
||||
if (record != null) {
|
||||
|
@ -250,8 +248,8 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
|||
switch (historyEntry.getPodDbEntryType()) {
|
||||
|
||||
case SetTemporaryBasal: {
|
||||
TempBasalPair tempBasalPair = OmnipodUtil.getGsonInstance().fromJson(historyEntry.getData(), TempBasalPair.class);
|
||||
valueView.setText(MainApp.gs(R.string.omnipod_cmd_tbr_value, tempBasalPair.getInsulinRate(), tempBasalPair.getDurationMinutes()));
|
||||
TempBasalPair tempBasalPair = omnipodUtil.getGsonInstance().fromJson(historyEntry.getData(), TempBasalPair.class);
|
||||
valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_tbr_value, tempBasalPair.getInsulinRate(), tempBasalPair.getDurationMinutes()));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -266,9 +264,9 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
|||
case SetBolus: {
|
||||
if (historyEntry.getData().contains(";")) {
|
||||
String[] splitVal = historyEntry.getData().split(";");
|
||||
valueView.setText(MainApp.gs(R.string.omnipod_cmd_bolus_value_with_carbs, Double.valueOf(splitVal[0]), Double.valueOf(splitVal[1])));
|
||||
valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_bolus_value_with_carbs, Double.valueOf(splitVal[0]), Double.valueOf(splitVal[1])));
|
||||
} else {
|
||||
valueView.setText(MainApp.gs(R.string.omnipod_cmd_bolus_value, Double.valueOf(historyEntry.getData())));
|
||||
valueView.setText(resourceHelper.gs(R.string.omnipod_cmd_bolus_value, Double.valueOf(historyEntry.getData())));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -299,19 +297,15 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
|||
}
|
||||
|
||||
private void setProfileValue(String data, TextView valueView) {
|
||||
LOG.debug("Profile json:\n" + data);
|
||||
aapsLogger.debug(LTag.PUMP, "Profile json:\n" + data);
|
||||
|
||||
try {
|
||||
Profile.ProfileValue[] profileValuesArray = OmnipodUtil.getGsonInstance().fromJson(data, Profile.ProfileValue[].class);
|
||||
|
||||
//profile = new Profile(new JSONObject(data), Constants.MGDL);
|
||||
Profile.ProfileValue[] profileValuesArray = omnipodUtil.getGsonInstance().fromJson(data, Profile.ProfileValue[].class);
|
||||
valueView.setText(ProfileUtil.getBasalProfilesDisplayable(profileValuesArray, PumpType.Insulet_Omnipod));
|
||||
} catch (Exception e) {
|
||||
LOG.error("Problem parsing Profile json. Ex: {}, Data:\n{}", e.getMessage(), data);
|
||||
aapsLogger.error(LTag.PUMP, "Problem parsing Profile json. Ex: {}, Data:\n{}", e.getMessage(), data);
|
||||
valueView.setText("");
|
||||
}
|
||||
//Profile profile = OmnipodUtil.getGsonInstance().fromJson(data, Profile.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,7 +321,7 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
|
|||
}
|
||||
|
||||
|
||||
static class HistoryViewHolder extends RecyclerView.ViewHolder {
|
||||
class HistoryViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView timeView;
|
||||
TextView typeView;
|
||||
|
|
|
@ -6,17 +6,14 @@ import com.atech.android.library.wizardpager.WizardPagerActivity
|
|||
import com.atech.android.library.wizardpager.WizardPagerContext
|
||||
import com.atech.android.library.wizardpager.data.WizardPagerSettings
|
||||
import com.atech.android.library.wizardpager.defs.WizardStepsWayType
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodActionType
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.model.FullInitPodWizardModel
|
||||
|
@ -45,6 +42,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||
@Inject lateinit var omnipodUtil: OmnipodUtil
|
||||
@Inject lateinit var injector: HasAndroidInjector
|
||||
|
||||
private var initPodChanged = false
|
||||
private var podSessionFullyInitalized = false
|
||||
|
@ -68,13 +66,11 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
initPodChanged = true
|
||||
}
|
||||
|
||||
|
||||
initpod_pod_history.setOnClickListener {
|
||||
showPodHistory()
|
||||
}
|
||||
|
||||
refreshButtons();
|
||||
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -89,7 +85,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
fun initPodAction() {
|
||||
|
||||
val pagerSettings = WizardPagerSettings()
|
||||
var refreshAction = InitPodRefreshAction(this, PodActionType.InitPod)
|
||||
var refreshAction = InitPodRefreshAction(injector, this, PodActionType.InitPod)
|
||||
|
||||
pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext)
|
||||
pagerSettings.setFinishStringResourceId(R.string.close)
|
||||
|
@ -117,7 +113,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
|
||||
fun removePodAction() {
|
||||
val pagerSettings = WizardPagerSettings()
|
||||
var refreshAction = InitPodRefreshAction(this, PodActionType.RemovePod)
|
||||
var refreshAction = InitPodRefreshAction(injector, this, PodActionType.RemovePod)
|
||||
|
||||
pagerSettings.setWizardStepsWayType(WizardStepsWayType.CancelNext)
|
||||
pagerSettings.setFinishStringResourceId(R.string.close)
|
||||
|
@ -142,7 +138,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
OKDialog.showConfirmation(this,
|
||||
resourceHelper.gs(R.string.omnipod_cmd_reset_pod_desc), Thread {
|
||||
AapsOmnipodManager.getInstance().resetPodStatus()
|
||||
OmnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod)
|
||||
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_NoPod)
|
||||
refreshButtons()
|
||||
})
|
||||
}
|
||||
|
@ -163,7 +159,7 @@ class PodManagementActivity : NoSplashAppCompatActivity() {
|
|||
initpod_remove_pod.isEnabled = isPodSessionActive
|
||||
initpod_reset_pod.isEnabled = isPodSessionActive
|
||||
|
||||
if (OmnipodUtil.getDriverState() == OmnipodDriverState.NotInitalized) {
|
||||
if (omnipodUtil.getDriverState() == OmnipodDriverState.NotInitalized) {
|
||||
// if rileylink is not running we disable all operations
|
||||
initpod_init_pod.isEnabled = false
|
||||
initpod_remove_pod.isEnabled = false
|
||||
|
|
|
@ -5,13 +5,15 @@ import com.atech.android.library.wizardpager.defs.action.FinishActionInterface;
|
|||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.SetupProgress;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity;
|
||||
|
@ -19,20 +21,23 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.defs.PodAc
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
|
||||
/**
|
||||
* Created by andy on 12/11/2019
|
||||
*/
|
||||
public class InitPodRefreshAction extends AbstractCancelAction implements FinishActionInterface {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
private PodManagementActivity podManagementActivity;
|
||||
private PodActionType actionType;
|
||||
|
||||
OmnipodUtil omnipodUtil;
|
||||
@Inject OmnipodUtil omnipodUtil;
|
||||
@Inject AAPSLogger aapsLogger;
|
||||
@Inject SP sp;
|
||||
|
||||
public InitPodRefreshAction(PodManagementActivity podManagementActivity, PodActionType actionType) {
|
||||
public InitPodRefreshAction(HasAndroidInjector injector, PodManagementActivity podManagementActivity, PodActionType actionType) {
|
||||
injector.androidInjector().inject(this);
|
||||
this.podManagementActivity = podManagementActivity;
|
||||
this.actionType = actionType;
|
||||
}
|
||||
|
@ -52,7 +57,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (actionType==PodActionType.InitPod) {
|
||||
if (actionType == PodActionType.InitPod) {
|
||||
if (omnipodUtil.getPodSessionState().getSetupProgress().isBefore(SetupProgress.COMPLETED)) {
|
||||
omnipodUtil.setDriverState(OmnipodDriverState.Initalized_PodInitializing);
|
||||
} else {
|
||||
|
@ -71,7 +76,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
|
|||
return;
|
||||
try {
|
||||
JSONObject data = new JSONObject();
|
||||
String enteredBy = SP.getString("careportal_enteredby", "");
|
||||
String enteredBy = sp.getString("careportal_enteredby", "");
|
||||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||
data.put("created_at", DateUtil.toISOString(date));
|
||||
data.put("eventType", event);
|
||||
|
@ -83,7 +88,7 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
|
|||
MainApp.getDbHelper().createOrUpdate(careportalEvent);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
} catch (JSONException e) {
|
||||
LOG.error("Unhandled exception when uploading SiteChange event.", e);
|
||||
aapsLogger.error(LTag.PUMPCOMM, "Unhandled exception when uploading SiteChange event.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,37 +3,22 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dialogs.wizard.pages;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.ListFragment;
|
||||
|
||||
import com.tech.freak.wizardpager.model.ModelCallbacks;
|
||||
import com.tech.freak.wizardpager.model.Page;
|
||||
import com.tech.freak.wizardpager.model.ReviewItem;
|
||||
import com.tech.freak.wizardpager.ui.PageFragmentCallbacks;
|
||||
import com.tech.freak.wizardpager.ui.ReviewFragment;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.support.DaggerFragment;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FirmwareVersion;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
|
||||
|
@ -113,7 +98,7 @@ public class PodInfoFragment extends DaggerFragment {
|
|||
// 1
|
||||
// );
|
||||
|
||||
if (podSessionState==null)
|
||||
if (podSessionState == null)
|
||||
return false;
|
||||
|
||||
mCurrentReviewItems = new ArrayList<>();
|
||||
|
@ -152,20 +137,17 @@ public class PodInfoFragment extends DaggerFragment {
|
|||
|
||||
private ArrayList<ReviewItem> dataSet;
|
||||
Context mContext;
|
||||
private int lastPosition = -1;
|
||||
|
||||
// View lookup cache
|
||||
|
||||
|
||||
public PodInfoAdapter(ArrayList<ReviewItem> data, Context context) {
|
||||
super(context, com.tech.freak.wizardpager.R.layout.list_item_review, data);
|
||||
this.dataSet = data;
|
||||
this.mContext=context;
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private int lastPosition = -1;
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
// Get the data item for this position
|
||||
|
@ -183,25 +165,20 @@ public class PodInfoFragment extends DaggerFragment {
|
|||
viewHolder.txtName = (TextView) convertView.findViewById(android.R.id.text1);
|
||||
viewHolder.txtType = (TextView) convertView.findViewById(android.R.id.text2);
|
||||
|
||||
|
||||
result=convertView;
|
||||
result = convertView;
|
||||
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
result=convertView;
|
||||
result = convertView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
viewHolder.txtName.setText(dataModel.getTitle());
|
||||
viewHolder.txtType.setText(dataModel.getDisplayValue());
|
||||
|
||||
|
||||
// Return the completed view to render on screen
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ViewHolder {
|
||||
|
@ -209,6 +186,4 @@ public class PodInfoFragment extends DaggerFragment {
|
|||
TextView txtType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,23 +1,14 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.driver;
|
||||
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||
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.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||
|
@ -28,9 +19,8 @@ import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDe
|
|||
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;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
/**
|
||||
* Created by andy on 4.8.2019
|
||||
|
@ -38,9 +28,8 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
|||
@Singleton
|
||||
public class OmnipodPumpStatus extends PumpStatus {
|
||||
|
||||
//private static Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
private final ResourceHelper resourceHelper;
|
||||
private final info.nightscout.androidaps.utils.sharedPreferences.SP sp;
|
||||
private final SP sp;
|
||||
private final RileyLinkUtil rileyLinkUtil;
|
||||
private final RxBusWrapper rxBus;
|
||||
|
||||
|
@ -60,9 +49,7 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
public PodSessionState podSessionState;
|
||||
public PumpType pumpType;
|
||||
|
||||
private boolean rileyLinkAddressChanged = false;
|
||||
private String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||
|
||||
public String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||
|
||||
public String podNumber;
|
||||
public PodDeviceState podDeviceState = PodDeviceState.NeverContacted;
|
||||
|
@ -108,8 +95,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getErrorInfo() {
|
||||
//verifyConfiguration();
|
||||
|
||||
|
@ -117,7 +102,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
}
|
||||
|
||||
|
||||
|
||||
// public boolean setNotInPreInit() {
|
||||
// this.inPreInit = false;
|
||||
//
|
||||
|
@ -133,10 +117,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
}
|
||||
|
||||
|
||||
private boolean isLogEnabled() {
|
||||
return L.isEnabled(L.PUMP);
|
||||
}
|
||||
|
||||
public TempBasalPair getTemporaryBasal() {
|
||||
|
||||
TempBasalPair tbr = new TempBasalPair();
|
||||
|
@ -162,7 +142,6 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
", tempBasalAmount=" + tempBasalAmount +
|
||||
", tempBasalLength=" + tempBasalLength +
|
||||
", podSessionState=" + podSessionState +
|
||||
", rileyLinkAddressChanged=" + rileyLinkAddressChanged +
|
||||
", regexMac='" + regexMac + '\'' +
|
||||
", podNumber='" + podNumber + '\'' +
|
||||
", podDeviceState=" + podDeviceState +
|
||||
|
|
|
@ -26,7 +26,6 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
|||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||
|
@ -40,6 +39,21 @@ import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationManager;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodManager;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.SetupActionResult;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.ActionInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommandInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommunicationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CrcMismatchException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalDeliveryStatusException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalPacketTypeException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalPodProgressException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalResponseException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.MessageDecodingException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceOutOfSyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceResyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NotEnoughDataException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodReturnedErrorResponseException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoRecentPulseLog;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
|
||||
|
@ -58,40 +72,25 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistory;
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.db.PodHistoryEntryType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodAcknowledgeAlertsChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.ActionInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommandInitializationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CommunicationException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.CrcMismatchException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalDeliveryStatusException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalPacketTypeException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalPodProgressException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalResponseException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.MessageDecodingException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceOutOfSyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NonceResyncException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.NotEnoughDataException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.exception.OmnipodException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodFaultException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.PodReturnedErrorResponseException;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface {
|
||||
|
||||
private OmnipodUtil omnipodUtil;
|
||||
AAPSLogger aapsLogger;
|
||||
RxBusWrapper rxBus;
|
||||
ResourceHelper resourceHelper;
|
||||
HasAndroidInjector injector;
|
||||
ActivePluginProvider activePlugin;
|
||||
private AAPSLogger aapsLogger;
|
||||
private RxBusWrapper rxBus;
|
||||
private ResourceHelper resourceHelper;
|
||||
private HasAndroidInjector injector;
|
||||
private ActivePluginProvider activePlugin;
|
||||
private OmnipodPumpStatus pumpStatus;
|
||||
|
||||
//private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
private final OmnipodManager delegate;
|
||||
|
||||
private static AapsOmnipodManager instance;
|
||||
private OmnipodPumpStatus pumpStatus;
|
||||
|
||||
private Date lastBolusTime;
|
||||
private Double lastBolusUnits;
|
||||
|
@ -106,6 +105,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
OmnipodUtil omnipodUtil,
|
||||
AAPSLogger aapsLogger,
|
||||
RxBusWrapper rxBus,
|
||||
SP sp,
|
||||
ResourceHelper resourceHelper,
|
||||
HasAndroidInjector injector,
|
||||
ActivePluginProvider activePlugin) {
|
||||
|
@ -117,7 +117,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
this.activePlugin = activePlugin;
|
||||
this.pumpStatus = _pumpStatus;
|
||||
|
||||
delegate = new OmnipodManager(communicationService, podState, podSessionState -> {
|
||||
delegate = new OmnipodManager(aapsLogger, sp, communicationService, podState, podSessionState -> {
|
||||
// Handle pod state changes
|
||||
omnipodUtil.setPodSessionState(podSessionState);
|
||||
updatePumpStatus(podSessionState);
|
||||
|
@ -454,7 +454,6 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
@Override
|
||||
public void setPumpStatus(OmnipodPumpStatus pumpStatus) {
|
||||
this.pumpStatus = pumpStatus;
|
||||
//this.getCommunicationService().setPumpStatus(pumpStatus);
|
||||
updatePumpStatus(delegate.getPodState());
|
||||
}
|
||||
|
||||
|
@ -547,9 +546,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
//TreatmentsPlugin plugin = TreatmentsPlugin.getPlugin();
|
||||
TreatmentsInterface plugin = activePlugin.getActiveTreatments();
|
||||
if (plugin.isTempBasalInProgress()) {
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.debug(LTag.PUMP,"Reporting implicitly cancelled TBR to Treatments plugin");
|
||||
}
|
||||
aapsLogger.debug(LTag.PUMP, "Reporting implicitly cancelled TBR to Treatments plugin");
|
||||
|
||||
long time = System.currentTimeMillis() - 1000;
|
||||
|
||||
|
@ -583,7 +580,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
if (data instanceof String) {
|
||||
podHistory.setData((String) data);
|
||||
} else {
|
||||
podHistory.setData(OmnipodUtil.getGsonInstance().toJson(data));
|
||||
podHistory.setData(omnipodUtil.getGsonInstance().toJson(data));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,18 +596,16 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
private void handleSetupActionResult(PodInitActionType podInitActionType, PodInitReceiver podInitReceiver, SetupActionResult res, long time, Profile profile) {
|
||||
String comment = null;
|
||||
switch (res.getResultType()) {
|
||||
case FAILURE:
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.error(LTag.PUMP,"Setup action failed: illegal setup progress: {}", res.getSetupProgress());
|
||||
}
|
||||
case FAILURE: {
|
||||
aapsLogger.error(LTag.PUMP, "Setup action failed: illegal setup progress: {}", res.getSetupProgress());
|
||||
comment = getStringResource(R.string.omnipod_driver_error_invalid_progress_state, res.getSetupProgress());
|
||||
break;
|
||||
case VERIFICATION_FAILURE:
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.error(LTag.PUMP,"Setup action verification failed: caught exception", res.getException());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VERIFICATION_FAILURE: {
|
||||
aapsLogger.error(LTag.PUMP, "Setup action verification failed: caught exception", res.getException());
|
||||
comment = getStringResource(R.string.omnipod_driver_error_setup_action_verification_failed);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (podInitActionType == PodInitActionType.PairAndPrimeWizardStep) {
|
||||
|
@ -657,14 +652,10 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
// Shouldn't be reachable
|
||||
comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName());
|
||||
}
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.error(LTag.PUMP,String.format("Caught OmnipodException[certainFailure=%s] from OmnipodManager (user-friendly error message: %s)", ((OmnipodException) ex).isCertainFailure(), comment), ex);
|
||||
}
|
||||
aapsLogger.error(LTag.PUMP, String.format("Caught OmnipodException[certainFailure=%s] from OmnipodManager (user-friendly error message: %s)", ((OmnipodException) ex).isCertainFailure(), comment), ex);
|
||||
} else {
|
||||
comment = getStringResource(R.string.omnipod_driver_error_unexpected_exception_type, ex.getClass().getName());
|
||||
if (isLoggingEnabled()) {
|
||||
aapsLogger.error(LTag.PUMP,String.format("Caught unexpected exception type[certainFailure=false] from OmnipodManager (user-friendly error message: %s)", comment), ex);
|
||||
}
|
||||
aapsLogger.error(LTag.PUMP, String.format("Caught unexpected exception type[certainFailure=false] from OmnipodManager (user-friendly error message: %s)", comment), ex);
|
||||
}
|
||||
|
||||
return comment;
|
||||
|
@ -744,11 +735,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
|||
}
|
||||
|
||||
private String getStringResource(int id, Object... args) {
|
||||
return MainApp.gs(id, args);
|
||||
}
|
||||
|
||||
private boolean isLoggingEnabled() {
|
||||
return L.isEnabled(L.PUMP);
|
||||
return resourceHelper.gs(id, args);
|
||||
}
|
||||
|
||||
static BasalSchedule mapProfileToBasalSchedule(Profile profile) {
|
||||
|
|
|
@ -3,12 +3,8 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.db;
|
|||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.db.DbObjectBase;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||
|
||||
/**
|
||||
|
@ -17,8 +13,6 @@ import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
|||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_POD_HISTORY)
|
||||
public class PodHistory implements DbObjectBase, Comparable<PodHistory> {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(L.DATABASE);
|
||||
|
||||
@DatabaseField(id = true)
|
||||
public long date;
|
||||
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUIPostprocessor;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
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.OmnipodCommunicationManagerInterface;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
|
||||
/**
|
||||
|
@ -22,8 +12,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
|||
*/
|
||||
public class OmnipodUIComm {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
private final HasAndroidInjector injector;
|
||||
private final AAPSLogger aapsLogger;
|
||||
private final OmnipodUtil omnipodUtil;
|
||||
|
@ -31,10 +19,6 @@ public class OmnipodUIComm {
|
|||
private final OmnipodUIPostprocessor omnipodUIPostprocessor;
|
||||
|
||||
|
||||
//OmnipodCommunicationManagerInterface ocmInstance = null;
|
||||
//OmnipodUIPostprocessor uiPostprocessor; // = new OmnipodUIPostprocessor();
|
||||
|
||||
|
||||
public OmnipodUIComm(
|
||||
HasAndroidInjector injector,
|
||||
AAPSLogger aapsLogger,
|
||||
|
@ -50,22 +34,9 @@ public class OmnipodUIComm {
|
|||
}
|
||||
|
||||
|
||||
private OmnipodCommunicationManagerInterface getCommunicationManager() {
|
||||
return omnipodCommunicationManager;
|
||||
}
|
||||
|
||||
// public OmnipodUIComm(OmnipodCommunicationManagerInterface communicationManager, OmnipodPumpPluginInterface plugin, OmnipodPumpStatus status) {
|
||||
// ocmInstance = communicationManager;
|
||||
// uiPostprocessor = new OmnipodUIPostprocessor(plugin, status);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public OmnipodUITask executeCommand(OmnipodCommandType commandType, Object... parameters) {
|
||||
|
||||
if (isLogEnabled())
|
||||
LOG.warn("Execute Command: " + commandType.name());
|
||||
aapsLogger.warn(LTag.PUMP, "Execute Command: " + commandType.name());
|
||||
|
||||
OmnipodUITask task = new OmnipodUITask(injector, commandType, parameters);
|
||||
|
||||
|
@ -79,7 +50,7 @@ public class OmnipodUIComm {
|
|||
// LOG.warn("@@@ End Thread");
|
||||
// });
|
||||
|
||||
task.execute(getCommunicationManager());
|
||||
task.execute(this.omnipodCommunicationManager);
|
||||
|
||||
// for (int i = 0; i < getMaxWaitTime(commandType); i++) {
|
||||
// synchronized (task) {
|
||||
|
@ -99,8 +70,8 @@ public class OmnipodUIComm {
|
|||
// }
|
||||
// }
|
||||
|
||||
if (!task.isReceived() && isLogEnabled()) {
|
||||
LOG.warn("Reply not received for " + commandType);
|
||||
if (!task.isReceived()) {
|
||||
aapsLogger.warn(LTag.PUMP, "Reply not received for " + commandType);
|
||||
}
|
||||
|
||||
task.postProcess(omnipodUIPostprocessor);
|
||||
|
@ -109,9 +80,4 @@ public class OmnipodUIComm {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private boolean isLogEnabled() {
|
||||
return L.isEnabled(L.PUMP);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,12 +8,8 @@ import java.util.Date;
|
|||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCustomActionType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodResponseType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||
|
||||
/**
|
||||
|
@ -22,6 +18,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
|||
|
||||
public class OmnipodUIPostprocessor {
|
||||
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
private OmnipodPumpStatus pumpStatus;
|
||||
|
@ -43,11 +40,11 @@ public class OmnipodUIPostprocessor {
|
|||
switch (uiTask.commandType) {
|
||||
|
||||
case SetBolus: {
|
||||
if (uiTask.returnData!=null) {
|
||||
if (uiTask.returnData != null) {
|
||||
|
||||
PumpEnactResult result = uiTask.returnData;
|
||||
|
||||
DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo)uiTask.getObjectFromParameters(0);
|
||||
DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo) uiTask.getObjectFromParameters(0);
|
||||
|
||||
if (result.success) {
|
||||
boolean isSmb = detailedBolusInfo.isSMB;
|
||||
|
@ -58,7 +55,8 @@ public class OmnipodUIPostprocessor {
|
|||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CancelTemporaryBasal: {
|
||||
pumpStatus.tempBasalStart = 0;
|
||||
|
@ -100,9 +98,6 @@ public class OmnipodUIPostprocessor {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.ui;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
|
@ -10,13 +7,9 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
|
|||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommandType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState;
|
||||
|
@ -40,8 +33,6 @@ public class OmnipodUITask {
|
|||
@Inject OmnipodUtil omnipodUtil;
|
||||
|
||||
private final HasAndroidInjector injector;
|
||||
|
||||
//private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
public OmnipodCommandType commandType;
|
||||
public PumpEnactResult returnData;
|
||||
|
@ -68,8 +59,8 @@ public class OmnipodUITask {
|
|||
|
||||
public void execute(OmnipodCommunicationManagerInterface communicationManager) {
|
||||
|
||||
|
||||
aapsLogger.debug(LTag.PUMP,"OmnipodUITask: @@@ In execute. {}", commandType);
|
||||
|
||||
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ In execute. {}", commandType);
|
||||
|
||||
switch (commandType) {
|
||||
|
||||
|
@ -111,8 +102,8 @@ public class OmnipodUITask {
|
|||
responseType = PodResponseType.Acknowledgment;
|
||||
break;
|
||||
} catch (Exception ex) {
|
||||
{
|
||||
aapsLogger.warn(LTag.PUMP,"Failed to retrieve pulse log", ex);
|
||||
{
|
||||
aapsLogger.warn(LTag.PUMP, "Failed to retrieve pulse log", ex);
|
||||
}
|
||||
returnDataObject = null;
|
||||
responseType = PodResponseType.Error;
|
||||
|
@ -149,7 +140,7 @@ public class OmnipodUITask {
|
|||
break;
|
||||
|
||||
default: {
|
||||
aapsLogger.warn(LTag.PUMP,"This commandType is not supported (yet) - {}.", commandType);
|
||||
aapsLogger.warn(LTag.PUMP, "This commandType is not supported (yet) - {}.", commandType);
|
||||
responseType = PodResponseType.Error;
|
||||
}
|
||||
|
||||
|
@ -203,15 +194,15 @@ public class OmnipodUITask {
|
|||
public void postProcess(OmnipodUIPostprocessor postprocessor) {
|
||||
|
||||
EventOmnipodDeviceStatusChange statusChange;
|
||||
|
||||
aapsLogger.debug(LTag.PUMP,"OmnipodUITask: @@@ postProcess. {}", commandType);
|
||||
aapsLogger.debug(LTag.PUMP,"OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
||||
|
||||
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ postProcess. {}", commandType);
|
||||
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
||||
|
||||
if (responseType == PodResponseType.Data || responseType == PodResponseType.Acknowledgment) {
|
||||
postprocessor.postProcessData(this);
|
||||
}
|
||||
|
||||
aapsLogger.debug(LTag.PUMP,"OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
||||
aapsLogger.debug(LTag.PUMP, "OmnipodUITask: @@@ postProcess. responseType={}", responseType);
|
||||
|
||||
if (responseType == PodResponseType.Invalid) {
|
||||
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
||||
|
@ -242,11 +233,6 @@ public class OmnipodUITask {
|
|||
}
|
||||
|
||||
|
||||
private boolean isLogEnabled() {
|
||||
return L.isEnabled(L.PUMP);
|
||||
}
|
||||
|
||||
|
||||
public PodResponseType getResponseType() {
|
||||
return this.responseType;
|
||||
}
|
||||
|
|
|
@ -10,27 +10,19 @@ import com.google.gson.Gson;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkCommunicationManager;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RFSpy;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkEncodingType;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkService;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.ui.MedtronicUIPostprocessor;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||
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.state.PodSessionState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.comm.AapsOmnipodManager;
|
||||
|
@ -48,12 +40,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
@Inject OmnipodPumpStatus omnipodPumpStatus;
|
||||
@Inject OmnipodUtil omnipodUtil;
|
||||
|
||||
//@Inject MedtronicPumpPlugin medtronicPumpPlugin;
|
||||
//@Inject MedtronicUtil medtronicUtil;
|
||||
//@Inject MedtronicUIPostprocessor medtronicUIPostprocessor;
|
||||
//@Inject MedtronicPumpStatus medtronicPumpStatus;
|
||||
|
||||
|
||||
private static RileyLinkOmnipodService instance;
|
||||
|
||||
private OmnipodCommunicationManager omnipodCommunicationManager;
|
||||
|
@ -77,7 +63,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
aapsLogger.warn(LTag.PUMPCOMM,"onConfigurationChanged");
|
||||
aapsLogger.warn(LTag.PUMPCOMM, "onConfigurationChanged");
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
|
@ -99,7 +85,6 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
*/
|
||||
public void initRileyLinkServiceData() {
|
||||
|
||||
// TODO
|
||||
rileyLinkServiceData.targetDevice = RileyLinkTargetDevice.Omnipod;
|
||||
|
||||
// get most recently used RileyLink address
|
||||
|
@ -111,22 +96,23 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
|
||||
initializeErosOmnipodManager();
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"RileyLinkOmnipodService newly constructed");
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkOmnipodService newly constructed");
|
||||
//omnipodPumpStatus = (OmnipodPumpStatus) omnipodPumpPlugin.getPumpStatusData();
|
||||
}
|
||||
|
||||
private void initializeErosOmnipodManager() {
|
||||
if (AapsOmnipodManager.getInstance() == null) {
|
||||
PodSessionState podState = null;
|
||||
if (sp.contains(OmnipodConst.Prefs.PodState)) {
|
||||
if (sp.contains(OmnipodConst.Prefs.PodState) && omnipodUtil.getPodSessionState() == null) {
|
||||
try {
|
||||
Gson gson = OmnipodUtil.getGsonInstance();
|
||||
Gson gson = omnipodUtil.getGsonInstance();
|
||||
String storedPodState = sp.getString(OmnipodConst.Prefs.PodState, null);
|
||||
aapsLogger.info(LTag.PUMPCOMM,"PodSessionState-SP: loaded from SharedPreferences: " + storedPodState);
|
||||
aapsLogger.info(LTag.PUMPCOMM, "PodSessionState-SP: loaded from SharedPreferences: " + storedPodState);
|
||||
podState = gson.fromJson(storedPodState, PodSessionState.class);
|
||||
podState.injectDaggerClass(injector);
|
||||
omnipodUtil.setPodSessionState(podState);
|
||||
} catch (Exception ex) {
|
||||
aapsLogger.error(LTag.PUMPCOMM,"Could not deserialize Pod state", ex);
|
||||
aapsLogger.error(LTag.PUMPCOMM, "Could not deserialize Pod state", ex);
|
||||
}
|
||||
}
|
||||
OmnipodCommunicationManager omnipodCommunicationService = new OmnipodCommunicationManager(injector, rfspy);
|
||||
|
@ -134,7 +120,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
this.omnipodCommunicationManager = omnipodCommunicationService;
|
||||
|
||||
this.aapsOmnipodManager = new AapsOmnipodManager(omnipodCommunicationService, podState, omnipodPumpStatus,
|
||||
omnipodUtil, aapsLogger, rxBus, resourceHelper, injector, activePlugin);
|
||||
omnipodUtil, aapsLogger, rxBus, sp, resourceHelper, injector, activePlugin);
|
||||
} else {
|
||||
aapsOmnipodManager = AapsOmnipodManager.getInstance();
|
||||
}
|
||||
|
@ -148,16 +134,12 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
|
||||
@Override
|
||||
public RileyLinkCommunicationManager getDeviceCommunicationManager() {
|
||||
// if (omnipodCommunicationManager instanceof AapsOmnipodManager) { // Eros
|
||||
// return ((AapsOmnipodManager) omnipodCommunicationManager).getCommunicationService();
|
||||
// }
|
||||
// // FIXME is this correct for Dash?
|
||||
return omnipodCommunicationManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPumpDeviceState(PumpDeviceState pumpDeviceState) {
|
||||
|
||||
this.omnipodPumpStatus.setPumpDeviceState(pumpDeviceState);
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,25 +176,20 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean verifyConfiguration() {
|
||||
try {
|
||||
//String regexSN = "[0-9]{6}";
|
||||
String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||
|
||||
omnipodPumpStatus.errorDescription = "-";
|
||||
|
||||
String rileyLinkAddress = info.nightscout.androidaps.utils.SP.getString(RileyLinkConst.Prefs.RileyLinkAddress, null);
|
||||
String rileyLinkAddress = sp.getString(RileyLinkConst.Prefs.RileyLinkAddress, null);
|
||||
|
||||
if (rileyLinkAddress == null) {
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"RileyLink address invalid: null");
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLink address invalid: null");
|
||||
omnipodPumpStatus.errorDescription = resourceHelper.gs(R.string.medtronic_error_rileylink_address_invalid);
|
||||
return false;
|
||||
} else {
|
||||
if (!rileyLinkAddress.matches(regexMac)) {
|
||||
if (!rileyLinkAddress.matches(omnipodPumpStatus.regexMac)) {
|
||||
omnipodPumpStatus.errorDescription = resourceHelper.gs(R.string.medtronic_error_rileylink_address_invalid);
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"RileyLink address invalid: {}", rileyLinkAddress);
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLink address invalid: {}", rileyLinkAddress);
|
||||
} else {
|
||||
if (!rileyLinkAddress.equals(this.omnipodPumpStatus.rileyLinkAddress)) {
|
||||
this.omnipodPumpStatus.rileyLinkAddress = rileyLinkAddress;
|
||||
|
@ -228,7 +205,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
this.omnipodPumpStatus.podDebuggingOptionsEnabled = sp.getBoolean(OmnipodConst.Prefs.PodDebuggingOptionsEnabled, false);
|
||||
this.omnipodPumpStatus.timeChangeEventEnabled = sp.getBoolean(OmnipodConst.Prefs.TimeChangeEventEnabled, true);
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM,"Beeps [basal={}, bolus={}, SMB={}, TBR={}]", this.omnipodPumpStatus.beepBasalEnabled, this.omnipodPumpStatus.beepBolusEnabled, this.omnipodPumpStatus.beepSMBEnabled, this.omnipodPumpStatus.beepTBREnabled);
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Beeps [basal={}, bolus={}, SMB={}, TBR={}]", this.omnipodPumpStatus.beepBasalEnabled, this.omnipodPumpStatus.beepBolusEnabled, this.omnipodPumpStatus.beepSMBEnabled, this.omnipodPumpStatus.beepTBREnabled);
|
||||
|
||||
reconfigureService();
|
||||
|
||||
|
@ -236,7 +213,7 @@ public class RileyLinkOmnipodService extends RileyLinkService {
|
|||
|
||||
} catch (Exception ex) {
|
||||
this.omnipodPumpStatus.errorDescription = ex.getMessage();
|
||||
aapsLogger.error(LTag.PUMPCOMM,"Error on Verification: " + ex.getMessage(), ex);
|
||||
aapsLogger.error(LTag.PUMPCOMM, "Error on Verification: " + ex.getMessage(), ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
|
||||
|
||||
public class LogReceiver implements PodInitReceiver {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(LogReceiver.class);
|
||||
|
||||
@Override
|
||||
public void returnInitTaskStatus(PodInitActionType podInitActionType, boolean isSuccess, String errorMessage) {
|
||||
|
||||
if (errorMessage != null) {
|
||||
LOG.error(podInitActionType.name() + " - Success: " + isSuccess + ", Error Message: " + errorMessage);
|
||||
} else {
|
||||
if (isSuccess) {
|
||||
LOG.info(podInitActionType.name() + " - Success: " + isSuccess);
|
||||
} else {
|
||||
LOG.error(podInitActionType.name() + " - NOT Succesful");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,182 +8,108 @@ import com.google.gson.JsonDeserializer;
|
|||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.format.ISODateTimeFormat;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
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.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||
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.OmnipodPodType;
|
||||
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.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.events.EventOmnipodDeviceStatusChange;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod_dash.OmnipodDashPumpPlugin;
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
|
||||
|
||||
/**
|
||||
* Created by andy on 4/8/19.
|
||||
*/
|
||||
// FIXME
|
||||
@Singleton
|
||||
public class OmnipodUtil {
|
||||
|
||||
//@Inject RxBusWrapper rxBus;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
||||
private static boolean lowLevelDebug = true;
|
||||
private static RileyLinkOmnipodService omnipodService;
|
||||
//private static OmnipodPumpStatus omnipodPumpStatus;
|
||||
private static OmnipodCommandType currentCommand;
|
||||
private static Gson gsonInstance = createGson();
|
||||
//private static PodSessionState podSessionState;
|
||||
//private static PodDeviceState podDeviceState;
|
||||
//private static OmnipodPumpPluginInterface omnipodPumpPlugin;
|
||||
private static OmnipodPodType omnipodPodType;
|
||||
private static OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
||||
//private static PumpType pumpType;
|
||||
|
||||
private final AAPSLogger aapsLogger;
|
||||
private final RxBusWrapper rxBus;
|
||||
private final RileyLinkUtil rileyLinkUtil;
|
||||
private final OmnipodPumpStatus omnipodPumpStatus;
|
||||
private final ActivePluginProvider activePlugins;
|
||||
|
||||
|
||||
private boolean lowLevelDebug = true;
|
||||
private OmnipodCommandType currentCommand;
|
||||
private Gson gsonInstance = createGson();
|
||||
//private static PodSessionState podSessionState;
|
||||
//private static PodDeviceState podDeviceState;
|
||||
private OmnipodPodType omnipodPodType;
|
||||
private OmnipodDriverState driverState = OmnipodDriverState.NotInitalized;
|
||||
|
||||
|
||||
@Inject
|
||||
public OmnipodUtil(
|
||||
AAPSLogger aapsLogger,
|
||||
RxBusWrapper rxBus,
|
||||
RileyLinkUtil rileyLinkUtil,
|
||||
OmnipodPumpStatus omnipodPumpStatus
|
||||
OmnipodPumpStatus omnipodPumpStatus,
|
||||
ActivePluginProvider activePlugins
|
||||
) {
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.rxBus = rxBus;
|
||||
this.rileyLinkUtil = rileyLinkUtil;
|
||||
this.omnipodPumpStatus = omnipodPumpStatus;
|
||||
}
|
||||
|
||||
public static int makeUnsignedShort(int b2, int b1) {
|
||||
int k = (b2 & 0xff) << 8 | b1 & 0xff;
|
||||
return k;
|
||||
}
|
||||
|
||||
public static byte[] getByteArrayFromUnsignedShort(int shortValue, boolean returnFixedSize) {
|
||||
byte highByte = (byte) (shortValue >> 8 & 0xFF);
|
||||
byte lowByte = (byte) (shortValue & 0xFF);
|
||||
|
||||
if (highByte > 0) {
|
||||
return createByteArray(highByte, lowByte);
|
||||
} else {
|
||||
return returnFixedSize ? createByteArray(highByte, lowByte) : createByteArray(lowByte);
|
||||
}
|
||||
|
||||
this.activePlugins = activePlugins;
|
||||
}
|
||||
|
||||
|
||||
public static byte[] createByteArray(byte... data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public static byte[] createByteArray(List<Byte> data) {
|
||||
|
||||
byte[] array = new byte[data.size()];
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
array[i] = data.get(i);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isLowLevelDebug() {
|
||||
public boolean isLowLevelDebug() {
|
||||
return lowLevelDebug;
|
||||
}
|
||||
|
||||
|
||||
public static void setLowLevelDebug(boolean lowLevelDebug) {
|
||||
OmnipodUtil.lowLevelDebug = lowLevelDebug;
|
||||
public void setLowLevelDebug(boolean lowLevelDebug) {
|
||||
this.lowLevelDebug = lowLevelDebug;
|
||||
}
|
||||
|
||||
|
||||
// public static OmnipodCommunicationManagerInterface getOmnipodCommunicationManager() {
|
||||
// return (OmnipodCommunicationManagerInterface) RileyLinkUtil.rileyLinkCommunicationManager;
|
||||
// }
|
||||
|
||||
|
||||
// public static RileyLinkOmnipodService getOmnipodService() {
|
||||
// return OmnipodUtil.omnipodService;
|
||||
// }
|
||||
|
||||
|
||||
public static void setOmnipodService(RileyLinkOmnipodService medtronicService) {
|
||||
OmnipodUtil.omnipodService = medtronicService;
|
||||
}
|
||||
|
||||
public static OmnipodCommandType getCurrentCommand() {
|
||||
return OmnipodUtil.currentCommand;
|
||||
public OmnipodCommandType getCurrentCommand() {
|
||||
return currentCommand;
|
||||
}
|
||||
|
||||
|
||||
// FIXME
|
||||
public void setCurrentCommand(OmnipodCommandType currentCommand) {
|
||||
OmnipodUtil.currentCommand = currentCommand;
|
||||
this.currentCommand = currentCommand;
|
||||
|
||||
if (currentCommand != null)
|
||||
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(currentCommand));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isSame(Double d1, Double d2) {
|
||||
double diff = d1 - d2;
|
||||
|
||||
return (Math.abs(diff) <= 0.000001);
|
||||
}
|
||||
|
||||
|
||||
public static void displayNotConfiguredDialog(Context context) {
|
||||
OKDialog.showConfirmation(context, MainApp.gs(R.string.combo_warning),
|
||||
MainApp.gs(R.string.omnipod_error_operation_not_possible_no_configuration), (Runnable)null);
|
||||
}
|
||||
//
|
||||
// public static OmnipodPumpStatus getPumpStatus() {
|
||||
// return omnipodPumpStatus;
|
||||
// }
|
||||
|
||||
public static OmnipodDriverState getDriverState() {
|
||||
return OmnipodUtil.driverState;
|
||||
MainApp.gs(R.string.omnipod_error_operation_not_possible_no_configuration), (Runnable) null);
|
||||
}
|
||||
|
||||
public static void setDriverState(OmnipodDriverState state) {
|
||||
if (OmnipodUtil.driverState == state)
|
||||
|
||||
public OmnipodDriverState getDriverState() {
|
||||
return driverState;
|
||||
}
|
||||
|
||||
|
||||
public void setDriverState(OmnipodDriverState state) {
|
||||
if (driverState == state)
|
||||
return;
|
||||
|
||||
OmnipodUtil.driverState = state;
|
||||
driverState = state;
|
||||
omnipodPumpStatus.driverState = state;
|
||||
|
||||
// TODO maybe remove
|
||||
// if (OmnipodUtil.omnipodPumpStatus != null) {
|
||||
|
@ -195,11 +121,8 @@ public class OmnipodUtil {
|
|||
// }
|
||||
}
|
||||
|
||||
// public static void setPumpStatus(OmnipodPumpStatus omnipodPumpStatus) {
|
||||
// OmnipodUtil.omnipodPumpStatus = omnipodPumpStatus;
|
||||
// }
|
||||
|
||||
private static Gson createGson() {
|
||||
private Gson createGson() {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder()
|
||||
.registerTypeAdapter(DateTime.class, (JsonSerializer<DateTime>) (dateTime, typeOfSrc, context) ->
|
||||
new JsonPrimitive(ISODateTimeFormat.dateTime().print(dateTime)))
|
||||
|
@ -213,6 +136,7 @@ public class OmnipodUtil {
|
|||
return gsonBuilder.create();
|
||||
}
|
||||
|
||||
|
||||
public void setPodSessionState(PodSessionState podSessionState) {
|
||||
omnipodPumpStatus.podSessionState = podSessionState;
|
||||
rxBus.send(new EventOmnipodDeviceStatusChange(podSessionState));
|
||||
|
@ -224,26 +148,16 @@ public class OmnipodUtil {
|
|||
}
|
||||
|
||||
|
||||
// @NotNull
|
||||
// public static OmnipodPumpPluginInterface getPlugin() {
|
||||
// return OmnipodUtil.omnipodPumpPlugin;
|
||||
// }
|
||||
|
||||
|
||||
// @NotNull
|
||||
// public static void setPlugin(OmnipodPumpPluginInterface pumpPlugin) {
|
||||
// OmnipodUtil.omnipodPumpPlugin = pumpPlugin;
|
||||
// }
|
||||
|
||||
|
||||
public static void setOmnipodPodType(OmnipodPodType omnipodPodType) {
|
||||
OmnipodUtil.omnipodPodType = omnipodPodType;
|
||||
public void setOmnipodPodType(OmnipodPodType omnipodPodType) {
|
||||
this.omnipodPodType = omnipodPodType;
|
||||
}
|
||||
|
||||
public static OmnipodPodType getOmnipodPodType() {
|
||||
return omnipodPodType;
|
||||
|
||||
public OmnipodPodType getOmnipodPodType() {
|
||||
return this.omnipodPodType;
|
||||
}
|
||||
|
||||
|
||||
public PodDeviceState getPodDeviceState() {
|
||||
return omnipodPumpStatus.podDeviceState;
|
||||
}
|
||||
|
@ -253,29 +167,29 @@ public class OmnipodUtil {
|
|||
return omnipodPumpStatus.podSessionState;
|
||||
}
|
||||
|
||||
// public static boolean isOmnipodEros() {
|
||||
// return OmnipodPumpPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||
// }
|
||||
//
|
||||
// public static boolean isOmnipodDash() {
|
||||
// return OmnipodDashPumpPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||
// }
|
||||
|
||||
public boolean isOmnipodEros() {
|
||||
return this.activePlugins.getActivePump().model() == PumpType.Insulet_Omnipod;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOmnipodDash() {
|
||||
return this.activePlugins.getActivePump().model() == PumpType.Insulet_Omnipod_Dash;
|
||||
}
|
||||
|
||||
|
||||
public void setPumpType(PumpType pumpType_) {
|
||||
omnipodPumpStatus.pumpType = pumpType_;
|
||||
}
|
||||
|
||||
|
||||
public PumpType getPumpType() {
|
||||
return omnipodPumpStatus.pumpType;
|
||||
}
|
||||
|
||||
public static Gson getGsonInstance() {
|
||||
return gsonInstance;
|
||||
|
||||
public Gson getGsonInstance() {
|
||||
return this.gsonInstance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,12 +27,10 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
|||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodFragment;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.OmnipodPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.ui.OmnipodUIComm;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodPumpPluginInterface;
|
||||
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.RileyLinkOmnipodService;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod_dash.comm.OmnipodDashCommunicationManager;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
|
@ -44,8 +42,10 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|||
*
|
||||
* @author Andy Rozman (andy.rozman@gmail.com)
|
||||
*/
|
||||
// FIXME this is just placeholder for now, but this should use most of OmnipodPumpPlugin implementation
|
||||
public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodPumpPluginInterface {
|
||||
|
||||
// TODO Dagger
|
||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
protected static OmnipodDashPumpPlugin plugin = null;
|
||||
|
@ -68,14 +68,14 @@ public class OmnipodDashPumpPlugin extends OmnipodPumpPlugin implements OmnipodP
|
|||
|
||||
@Inject
|
||||
public OmnipodDashPumpPlugin(HasAndroidInjector injector,
|
||||
AAPSLogger aapsLogger,
|
||||
RxBusWrapper rxBus,
|
||||
Context context,
|
||||
ResourceHelper resourceHelper,
|
||||
ActivePluginProvider activePlugin,
|
||||
SP sp,
|
||||
CommandQueueProvider commandQueue,
|
||||
FabricPrivacy fabricPrivacy) {
|
||||
AAPSLogger aapsLogger,
|
||||
RxBusWrapper rxBus,
|
||||
Context context,
|
||||
ResourceHelper resourceHelper,
|
||||
ActivePluginProvider activePlugin,
|
||||
SP sp,
|
||||
CommandQueueProvider commandQueue,
|
||||
FabricPrivacy fabricPrivacy) {
|
||||
super(new PluginDescription() //
|
||||
.mainType(PluginType.PUMP) //
|
||||
.fragmentClass(OmnipodFragment.class.getName()) //
|
||||
|
|
|
@ -10,7 +10,6 @@ import info.nightscout.androidaps.data.Profile;
|
|||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
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.message.response.podinfo.PodInfoRecentPulseLog;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
|
||||
|
@ -18,8 +17,6 @@ import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitReceiver;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by andy on 4.8.2019
|
||||
|
@ -27,6 +24,8 @@ import info.nightscout.androidaps.utils.SP;
|
|||
// TODO refactor to use dagger, just commented out errors
|
||||
public class OmnipodDashCommunicationManager implements OmnipodCommunicationManagerInterface {
|
||||
|
||||
// TODO Dagger
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
||||
private static OmnipodDashCommunicationManager omnipodCommunicationManager;
|
||||
|
|
|
@ -14,7 +14,10 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|||
public class OmnipodDashPumpStatus extends OmnipodPumpStatus {
|
||||
|
||||
@Inject
|
||||
public OmnipodDashPumpStatus(ResourceHelper resourceHelper, SP sp, RxBusWrapper rxBus, RileyLinkUtil rileyLinkUtil) {
|
||||
public OmnipodDashPumpStatus(ResourceHelper resourceHelper,
|
||||
SP sp,
|
||||
RxBusWrapper rxBus,
|
||||
RileyLinkUtil rileyLinkUtil) {
|
||||
super(resourceHelper, sp, rxBus, rileyLinkUtil);
|
||||
this.pumpType = PumpType.Insulet_Omnipod_Dash;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue