Extended Ack Alerts functionality:
- added own event (so we don't refresh whole page), - added ackAcknowledgeText variable - changed refresh (own method, own event listener) - added log for Status change (to monitor what PodState information is displayed on Tab)
This commit is contained in:
parent
4ce5600434
commit
ab7e87fa02
4 changed files with 143 additions and 5 deletions
|
@ -20,12 +20,12 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLin
|
|||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodStatusRequest
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodDeviceState
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.state.PodSessionState
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.dialogs.PodManagementActivity
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodPumpValuesChanged
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefreshButtonState
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodAcknowledgeAlertsChanged
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
|
@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory
|
|||
|
||||
|
||||
class OmnipodFragment : Fragment() {
|
||||
private val log = LoggerFactory.getLogger(L.PUMP)
|
||||
private val LOG = LoggerFactory.getLogger(L.PUMP)
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
private var podAvailable = false
|
||||
|
||||
|
@ -128,16 +128,22 @@ class OmnipodFragment : Fragment() {
|
|||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.info("onStatusEvent(EventOmnipodDeviceStatusChange): {}", it)
|
||||
LOG.info("onStatusEvent(EventOmnipodDeviceStatusChange): {}", it)
|
||||
setDeviceStatus()
|
||||
}, { FabricPrivacy.logException(it) })
|
||||
disposable += RxBus
|
||||
.toObservable(EventOmnipodPumpValuesChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||
disposable += RxBus
|
||||
.toObservable(EventOmnipodAcknowledgeAlertsChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ updateAcknowledgeAlerts(OmnipodUtil.getPumpStatus()) }, { FabricPrivacy.logException(it) })
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
|
@ -170,6 +176,8 @@ class OmnipodFragment : Fragment() {
|
|||
pumpStatus.rileyLinkServiceState = checkStatusSet(pumpStatus.rileyLinkServiceState,
|
||||
RileyLinkUtil.getServiceState()) as RileyLinkServiceState?
|
||||
|
||||
LOG.info("setDeviceStatus: [pumpStatus={}]", pumpStatus)
|
||||
|
||||
val resourceId = pumpStatus.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.Omnipod)
|
||||
val rileyLinkError = RileyLinkUtil.getError()
|
||||
omnipod_rl_status.text =
|
||||
|
@ -239,7 +247,7 @@ class OmnipodFragment : Fragment() {
|
|||
// }
|
||||
// }
|
||||
}
|
||||
else -> log.warn("Unknown pump state: " + pumpStatus.podDeviceState)
|
||||
else -> LOG.warn("Unknown pump state: " + pumpStatus.podDeviceState)
|
||||
}
|
||||
|
||||
|
||||
|
@ -384,9 +392,19 @@ class OmnipodFragment : Fragment() {
|
|||
|
||||
omnipod_errors.text = pumpStatus.errorInfo
|
||||
|
||||
omnipod_pod_active_alerts_ack.isEnabled = pumpStatus.ackAlertsAvailable
|
||||
updateAcknowledgeAlerts(pumpStatus)
|
||||
|
||||
omnipod_refresh.isEnabled = pumpStatus.podAvailable
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun updateAcknowledgeAlerts(pumpStatus: OmnipodPumpStatus) {
|
||||
if (pumpStatus!=null) {
|
||||
omnipod_pod_active_alerts_ack.isEnabled = pumpStatus.ackAlertsAvailable
|
||||
omnipod_pod_active_alerts.text = pumpStatus.ackAlertsText
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import org.joda.time.LocalDateTime;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
|
@ -50,6 +52,7 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
public PodDeviceState podDeviceState = PodDeviceState.NeverContacted;
|
||||
public boolean podAvailable = false;
|
||||
public boolean ackAlertsAvailable = false;
|
||||
public String ackAlertsText = null;
|
||||
|
||||
|
||||
public OmnipodPumpStatus(PumpDescription pumpDescription) {
|
||||
|
@ -162,4 +165,53 @@ public class OmnipodPumpStatus extends PumpStatus {
|
|||
|
||||
return tbr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OmnipodPumpStatus{" +
|
||||
"errorDescription='" + errorDescription + '\'' +
|
||||
", rileyLinkAddress='" + rileyLinkAddress + '\'' +
|
||||
", inPreInit=" + inPreInit +
|
||||
", rileyLinkServiceState=" + rileyLinkServiceState +
|
||||
", rileyLinkError=" + rileyLinkError +
|
||||
", currentBasal=" + currentBasal +
|
||||
", tempBasalStart=" + tempBasalStart +
|
||||
", tempBasalEnd=" + tempBasalEnd +
|
||||
", tempBasalAmount=" + tempBasalAmount +
|
||||
", tempBasalLength=" + tempBasalLength +
|
||||
", podSessionState=" + podSessionState +
|
||||
", rileyLinkAddressChanged=" + rileyLinkAddressChanged +
|
||||
", regexMac='" + regexMac + '\'' +
|
||||
", podNumber='" + podNumber + '\'' +
|
||||
", podDeviceState=" + podDeviceState +
|
||||
", podAvailable=" + podAvailable +
|
||||
", ackAlertsAvailable=" + ackAlertsAvailable +
|
||||
", ackAlertsText='" + ackAlertsText + '\'' +
|
||||
", lastDataTime=" + lastDataTime +
|
||||
", lastConnection=" + lastConnection +
|
||||
", previousConnection=" + previousConnection +
|
||||
", lastBolusTime=" + lastBolusTime +
|
||||
", lastBolusAmount=" + lastBolusAmount +
|
||||
", activeProfileName='" + activeProfileName + '\'' +
|
||||
", reservoirRemainingUnits=" + reservoirRemainingUnits +
|
||||
", reservoirFullUnits=" + reservoirFullUnits +
|
||||
", batteryRemaining=" + batteryRemaining +
|
||||
", batteryVoltage=" + batteryVoltage +
|
||||
", iob='" + iob + '\'' +
|
||||
", dailyTotalUnits=" + dailyTotalUnits +
|
||||
", maxDailyTotalUnits='" + maxDailyTotalUnits + '\'' +
|
||||
", validBasalRateProfileSelectedOnPump=" + validBasalRateProfileSelectedOnPump +
|
||||
", pumpType=" + pumpType +
|
||||
", profileStore=" + profileStore +
|
||||
", units='" + units + '\'' +
|
||||
", pumpStatusType=" + pumpStatusType +
|
||||
", basalsByHour=" + Arrays.toString(basalsByHour) +
|
||||
", currentBasal=" + currentBasal +
|
||||
", tempBasalInProgress=" + tempBasalInProgress +
|
||||
", tempBasalRatio=" + tempBasalRatio +
|
||||
", tempBasalRemainMin=" + tempBasalRemainMin +
|
||||
", tempBasalStart=" + tempBasalStart +
|
||||
", pumpDescription=" + pumpDescription +
|
||||
"} " ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package info.nightscout.androidaps.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.logging.L;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||
|
||||
/**
|
||||
* Created by mike on 20.09.2017.
|
||||
*/
|
||||
|
||||
|
||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TDDS)
|
||||
public class TDD {
|
||||
private static Logger log = LoggerFactory.getLogger(L.DATABASE);
|
||||
|
||||
@DatabaseField(id = true)
|
||||
public long date;
|
||||
|
||||
@DatabaseField
|
||||
public double bolus;
|
||||
|
||||
@DatabaseField
|
||||
public double basal;
|
||||
|
||||
@DatabaseField
|
||||
public double total;
|
||||
|
||||
|
||||
public double getTotal(){
|
||||
return (total > 0d) ? total:(bolus+basal);
|
||||
}
|
||||
|
||||
|
||||
public TDD() { }
|
||||
|
||||
public TDD(long date, double bolus, double basal, double total){
|
||||
this.date = date;
|
||||
this.bolus = bolus;
|
||||
this.basal = basal;
|
||||
this.total = total;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TDD [" +
|
||||
"date=" + date +
|
||||
"date(str)=" + DateTimeUtil.toStringFromTimeInMillis(date) +
|
||||
", bolus=" + bolus +
|
||||
", basal=" + basal +
|
||||
", total=" + total +
|
||||
']';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.events;
|
||||
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
|
||||
/**
|
||||
* Created by andy on 04.06.2018.
|
||||
*/
|
||||
public class EventOmnipodAcknowledgeAlertsChanged extends Event {
|
||||
}
|
Loading…
Reference in a new issue