use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip by NightscoutFoundation.
the class InPenService method megaStatus.
// data for MegaStatus
public static List<StatusItem> megaStatus() {
final List<StatusItem> l = new ArrayList<>();
if (lastError != null) {
l.add(new StatusItem("Last Error", lastError, BAD));
}
if (isStarted()) {
l.add(new StatusItem("Service Running", JoH.niceTimeScalar(msSince(InPenEntry.started_at))));
l.add(new StatusItem("Brain State", lastState));
if (needsAuthentication) {
l.add(new StatusItem("Authentication", "Required", BAD));
}
} else {
l.add(new StatusItem("Service Stopped", "Not running"));
}
if (lastReceivedData != -1) {
l.add(new StatusItem("Last Connected", dateTimeText(lastReceivedData)));
}
if (lastPenData != null) {
l.add(new StatusItem("Last record", lastPenData.brief(), gotAll ? GOOD : NORMAL));
}
if (lastBattery != -1) {
l.add(new StatusItem("Battery", lastBattery + "%"));
}
for (final UUID uuid : INFO_CHARACTERISTICS) {
addStatusForCharacteristic(l, getCharactersticName(uuid.toString()), uuid);
}
if ((currentPenAttachTime != null) && (currentPenTime != null)) {
l.add(new StatusItem("Epoch time", dateTimeText(currentPenTime.getPenEpoch())));
l.add(new StatusItem("Attach time", dateTimeText(currentPenTime.fromPenTime(currentPenAttachTime.getPenTime()))));
}
//
return l;
}
use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip by NightscoutFoundation.
the class NightscoutFollowService method megaStatus.
/**
* MegaStatus for Nightscout Follower
*/
public static List<StatusItem> megaStatus() {
final BgReading lastBg = BgReading.lastNoSenssor();
String lastPollText = "n/a";
if (lastPoll > 0) {
lastPollText = JoH.niceTimeScalar(JoH.msSince(lastPoll));
}
// 30 seconds
long hightlightGrace = Constants.SECOND_IN_MS * 30;
// Status for BG receive delay (time from bg was recorded till received in xdrip)
String ageOfBgLastPoll = "n/a";
Highlight ageOfLastBgPollHighlight = Highlight.NORMAL;
if (bgReceiveDelay > 0) {
ageOfBgLastPoll = JoH.niceTimeScalar(bgReceiveDelay);
if (bgReceiveDelay > SAMPLE_PERIOD / 2) {
ageOfLastBgPollHighlight = Highlight.BAD;
}
if (bgReceiveDelay > SAMPLE_PERIOD * 2) {
ageOfLastBgPollHighlight = Highlight.CRITICAL;
}
}
// Status for time since latest BG
String ageLastBg = "n/a";
Highlight bgAgeHighlight = Highlight.NORMAL;
if (lastBg != null) {
long age = JoH.msSince(lastBg.timestamp);
ageLastBg = JoH.niceTimeScalar(age);
if (age > SAMPLE_PERIOD + hightlightGrace) {
bgAgeHighlight = Highlight.BAD;
}
}
// Status for treatments
String ageLastTreatment = "n/a";
String ageOfTreatmentWhenReceived = "n/a";
if (lastTreatment != null) {
long age = JoH.msSince(lastTreatment.timestamp);
ageLastTreatment = JoH.niceTimeScalar(age);
ageOfTreatmentWhenReceived = JoH.niceTimeScalar(treatmentReceivedDelay);
}
// Build status
List<StatusItem> statuses = new ArrayList<>();
statuses.add(new StatusItem("Latest BG", ageLastBg + (lastBg != null ? " ago" : ""), bgAgeHighlight));
statuses.add(new StatusItem("BG receive delay", ageOfBgLastPoll, ageOfLastBgPollHighlight));
if (NightscoutFollow.treatmentDownloadEnabled()) {
statuses.add(new StatusItem());
statuses.add(new StatusItem("Latest Treatment", ageLastTreatment + (lastTreatment != null ? " ago" : "")));
statuses.add(new StatusItem("Treatment receive delay", ageOfTreatmentWhenReceived));
}
statuses.add(new StatusItem());
statuses.add(new StatusItem("Last poll", lastPollText + (lastPoll > 0 ? " ago" : "")));
statuses.add(new StatusItem("Next poll in", JoH.niceTimeScalar(wakeup_time - JoH.tsl())));
if (lastBg != null) {
statuses.add(new StatusItem("Last BG time", JoH.dateTimeText(lastBg.timestamp)));
}
statuses.add(new StatusItem("Next poll time", JoH.dateTimeText(wakeup_time)));
statuses.add(new StatusItem());
statuses.add(new StatusItem("Buggy Samsung", JoH.buggy_samsung ? gs(R.string.yes) : gs(R.string.no)));
statuses.add(new StatusItem("Download treatments", NightscoutFollow.treatmentDownloadEnabled() ? gs(R.string.yes) : gs(R.string.no)));
if (StringUtils.isNotBlank(lastState)) {
statuses.add(new StatusItem());
statuses.add(new StatusItem("Last state", lastState));
}
return statuses;
}
use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip by NightscoutFoundation.
the class G5CollectionService method megaStatus.
/* public static void setWatchStatus(DataMap dataMap) {
lastStateWatch = dataMap.getString("lastState", "");
static_last_timestamp_watch = dataMap.getLong("timestamp", 0);
}
public static DataMap getWatchStatus() {
DataMap dataMap = new DataMap();
dataMap.putString("lastState", lastState);
dataMap.putLong("timestamp", static_last_timestamp);
return dataMap;
}*/
// data for MegaStatus
public static List<StatusItem> megaStatus() {
final List<StatusItem> l = new ArrayList<>();
l.add(new StatusItem("Phone Service State", lastState));
if (static_last_timestamp > 0) {
l.add(new StatusItem("Phone got Glucose", JoH.niceTimeSince(static_last_timestamp) + " ago"));
}
if (Pref.getBooleanDefaultFalse("wear_sync") && Pref.getBooleanDefaultFalse("enable_wearG5")) {
l.add(new StatusItem("Watch Service State", lastStateWatch));
if (static_last_timestamp_watch > 0) {
l.add(new StatusItem("Watch got Glucose", JoH.niceTimeSince(static_last_timestamp_watch) + " ago"));
}
}
final String tx_id = Pref.getStringDefaultBlank("dex_txid");
l.add(new StatusItem("Transmitter ID", tx_id));
// get firmware details
VersionRequestRxMessage vr = getFirmwareDetails(tx_id);
if ((vr != null) && (vr.firmware_version_string.length() > 0)) {
l.add(new StatusItem("Firmware Version", vr.firmware_version_string));
l.add(new StatusItem("Bluetooth Version", vr.bluetooth_firmware_version_string));
l.add(new StatusItem("Other Version", vr.other_firmware_version));
l.add(new StatusItem("Hardware Version", vr.hardwarev));
// TODO color code
if (vr.asic != 61440)
l.add(new StatusItem("ASIC", vr.asic, StatusItem.Highlight.NOTICE));
}
BatteryInfoRxMessage bt = getBatteryDetails(tx_id);
long last_battery_query = PersistentStore.getLong(G5_BATTERY_FROM_MARKER + tx_id);
if (getBatteryStatusNow) {
l.add(new StatusItem("Battery Status Request Queued", "Will attempt to read battery status on next sensor reading", StatusItem.Highlight.NOTICE, "long-press", new Runnable() {
@Override
public void run() {
getBatteryStatusNow = false;
}
}));
}
if ((bt != null) && (last_battery_query > 0)) {
l.add(new StatusItem("Battery Last queried", JoH.niceTimeSince(last_battery_query) + " " + "ago", StatusItem.Highlight.NORMAL, "long-press", new Runnable() {
@Override
public void run() {
getBatteryStatusNow = true;
}
}));
l.add(new StatusItem("Transmitter Status", TransmitterStatus.getBatteryLevel(vr.status).toString()));
l.add(new StatusItem("Transmitter Days", bt.runtime + ((last_transmitter_timestamp > 0) ? " / " + JoH.qs((double) last_transmitter_timestamp / 86400, 1) : "")));
l.add(new StatusItem("Voltage A", bt.voltagea, bt.voltagea < 300 ? StatusItem.Highlight.BAD : StatusItem.Highlight.NORMAL));
l.add(new StatusItem("Voltage B", bt.voltageb, bt.voltageb < 290 ? StatusItem.Highlight.BAD : StatusItem.Highlight.NORMAL));
l.add(new StatusItem("Resistance", bt.resist, bt.resist > 1400 ? StatusItem.Highlight.BAD : (bt.resist > 1000 ? StatusItem.Highlight.NOTICE : (bt.resist > 750 ? StatusItem.Highlight.NORMAL : StatusItem.Highlight.GOOD))));
l.add(new StatusItem("Temperature", bt.temperature + " \u2103"));
}
return l;
}
use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip by NightscoutFoundation.
the class Ob1G5CollectionService method megaStatus.
// data for MegaStatus
public static List<StatusItem> megaStatus() {
// needed if we have not passed through local INIT state
init_tx_id();
final List<StatusItem> l = new ArrayList<>();
l.add(new StatusItem("Phone Service State", lastState, JoH.msSince(lastStateUpdated) < 300000 ? (lastState.startsWith("Got data") ? Highlight.GOOD : NORMAL) : (isWatchRunning() ? Highlight.GOOD : CRITICAL)));
if (last_scan_started > 0) {
final long scanning_time = JoH.msSince(last_scan_started);
l.add(new StatusItem("Time scanning", JoH.niceTimeScalar(scanning_time), scanning_time > Constants.MINUTE_IN_MS * 5 ? (scanning_time > Constants.MINUTE_IN_MS * 10 ? BAD : NOTICE) : NORMAL));
}
if (lastScanError != null) {
l.add(new StatusItem("Scan Error", lastScanError, BAD));
}
if ((lastSensorStatus != null)) {
l.add(new StatusItem("Sensor Status", lastSensorStatus, lastSensorState != Ok ? NOTICE : NORMAL));
}
if (hardResetTransmitterNow) {
l.add(new StatusItem("Hard Reset", "Attempting - please wait", Highlight.CRITICAL));
}
if (transmitterID != null) {
l.add(new StatusItem("Sensor Device", transmitterID + ((transmitterMAC != null && Home.get_engineering_mode()) ? "\n" + transmitterMAC : "")));
}
if (static_connection_state != null) {
l.add(new StatusItem("Bluetooth Link", static_connection_state));
}
if (static_last_connected > 0) {
l.add(new StatusItem("Last Connected", JoH.niceTimeScalar(JoH.msSince(static_last_connected)) + " ago"));
}
if ((!lastState.startsWith("Service Stopped")) && (!lastState.startsWith("Not running")))
l.add(new StatusItem("Brain State", state.getString() + (error_count > 1 ? " Errors: " + error_count : ""), error_count > 1 ? NOTICE : error_count > 4 ? BAD : NORMAL));
if (lastUsableGlucosePacketTime != 0) {
if (JoH.msSince(lastUsableGlucosePacketTime) < Constants.MINUTE_IN_MS * 15) {
l.add(new StatusItem("G5 Algorithm", "Data Received " + JoH.hourMinuteString(lastUsableGlucosePacketTime), Highlight.GOOD));
}
}
final int queueSize = Ob1G5StateMachine.queueSize();
if (queueSize > 0) {
l.add(new StatusItem("Queue Items", "(" + queueSize + ") " + Ob1G5StateMachine.getFirstQueueItemName()));
}
if (max_wakeup_jitter > 5000) {
l.add(new StatusItem("Slowest Wakeup ", JoH.niceTimeScalar(max_wakeup_jitter), max_wakeup_jitter > Constants.SECOND_IN_MS * 10 ? CRITICAL : NOTICE));
}
if (JoH.buggy_samsung) {
l.add(new StatusItem("Buggy Samsung", "Using workaround", max_wakeup_jitter < TOLERABLE_JITTER ? Highlight.GOOD : BAD));
}
final String tx_id = getTransmitterID();
if (Pref.getBooleanDefaultFalse("wear_sync") && Pref.getBooleanDefaultFalse("enable_wearG5")) {
l.add(new StatusItem("Watch Service State", lastStateWatch));
if (static_last_timestamp_watch > 0) {
l.add(new StatusItem("Watch got Glucose", JoH.niceTimeSince(static_last_timestamp_watch) + " ago"));
}
}
final String sensorCode = getCurrentSensorCode();
if (sensorCode != null) {
if (usingG6()) {
l.add(new StatusItem("Calibration Code", sensorCode));
}
}
l.add(new StatusItem("Preemptive restarts", (Pref.getBooleanDefaultFalse("ob1_g5_preemptive_restart") ? "Enabled" : "Disabled") + (Ob1G5StateMachine.useExtendedTimeTravel() ? " (extended)" : "")));
final VersionRequest1RxMessage vr1 = (VersionRequest1RxMessage) Ob1G5StateMachine.getFirmwareXDetails(tx_id, 1);
final VersionRequest2RxMessage vr2 = (VersionRequest2RxMessage) Ob1G5StateMachine.getFirmwareXDetails(tx_id, 2);
try {
if (vr1 != null) {
l.add(new StatusItem("Firmware Version", vr1.firmware_version_string, FirmwareCapability.isG6Rev2(vr1.firmware_version_string) ? NOTICE : NORMAL));
// l.add(new StatusItem("Build Version", "" + vr1.build_version));
if (vr1.version_code != 3) {
l.add(new StatusItem("Compat Version", "" + vr1.version_code, Highlight.BAD));
}
if (vr1.max_runtime_days != 110 && vr1.max_runtime_days != 112) {
l.add(new StatusItem("Transmitter Life", "" + vr1.max_runtime_days + " " + gs(R.string.days)));
}
}
} catch (Exception e) {
// TODO add message?
}
try {
if (vr2 != null) {
if (vr2.typicalSensorDays != 10 && vr2.typicalSensorDays != 7) {
l.add(new StatusItem("Sensor Period", vr2.typicalSensorDays, Highlight.NOTICE));
}
// l.add(new StatusItem("Feature mask", vr2.featureBits));
}
} catch (Exception e) {
//
}
// firmware hardware details
final VersionRequestRxMessage vr = (VersionRequestRxMessage) Ob1G5StateMachine.getFirmwareXDetails(tx_id, 0);
try {
if ((vr != null) && (vr.firmware_version_string.length() > 0)) {
if (Home.get_engineering_mode()) {
if (vr1 != null && !vr.firmware_version_string.equals(vr1.firmware_version_string)) {
l.add(new StatusItem("2nd Firmware Version", vr.firmware_version_string, FirmwareCapability.isG6Rev2(vr.firmware_version_string) ? NOTICE : NORMAL));
}
if (vr1 != null && !vr.bluetooth_firmware_version_string.equals(vr1.firmware_version_string)) {
l.add(new StatusItem("Bluetooth Version", vr.bluetooth_firmware_version_string));
}
l.add(new StatusItem("Other Version", vr.other_firmware_version));
// l.add(new StatusItem("Hardware Version", vr.hardwarev));
if (vr.asic != 61440 && vr.asic != 16705 && vr.asic != 243 && vr.asic != 74)
l.add(new StatusItem("ASIC", vr.asic, NOTICE));
}
}
} catch (NullPointerException e) {
l.add(new StatusItem("Version", "Information corrupted", BAD));
}
// battery details
final BatteryInfoRxMessage bt = Ob1G5StateMachine.getBatteryDetails(tx_id);
long last_battery_query = PersistentStore.getLong(G5_BATTERY_FROM_MARKER + tx_id);
if (getBatteryStatusNow) {
l.add(new StatusItem("Battery Status Request Queued", "Will attempt to read battery status on next sensor reading", NOTICE, "long-press", new Runnable() {
@Override
public void run() {
getBatteryStatusNow = false;
}
}));
}
if (JoH.quietratelimit("update-g5-battery-warning", 10)) {
updateBatteryWarningLevel();
}
if (vr1 != null && Home.get_engineering_mode()) {
l.add(new StatusItem("Shelf Life", "" + vr1.inactive_days + " / " + vr1.max_inactive_days));
}
final int timekeeperDays = DexTimeKeeper.getTransmitterAgeInDays(tx_id);
if ((bt != null) && (last_battery_query > 0)) {
l.add(new StatusItem("Battery Last queried", JoH.niceTimeSince(last_battery_query) + " " + "ago", NORMAL, "long-press", new Runnable() {
@Override
public void run() {
getBatteryStatusNow = true;
}
}));
if (vr != null) {
final String battery_status = TransmitterStatus.getBatteryLevel(vr.status).toString();
if (!battery_status.equals("OK"))
l.add(new StatusItem("Transmitter Status", battery_status, BAD));
}
// TODO use string builder instead of ternary for days
l.add(new StatusItem("Transmitter Days", ((bt.runtime > -1) ? bt.runtime : "") + ((timekeeperDays > -1) ? ((FirmwareCapability.isTransmitterG6Rev2(tx_id) ? " " : " / ") + timekeeperDays) : "") + ((last_transmitter_timestamp > 0) ? " / " + JoH.qs((double) last_transmitter_timestamp / 86400, 1) : "")));
l.add(new StatusItem("Voltage A", bt.voltagea, bt.voltagea < LOW_BATTERY_WARNING_LEVEL ? BAD : NORMAL));
l.add(new StatusItem("Voltage B", bt.voltageb, bt.voltageb < (LOW_BATTERY_WARNING_LEVEL - 10) ? BAD : NORMAL));
l.add(new StatusItem("Resistance", bt.resist, bt.resist > 1400 ? BAD : (bt.resist > 1000 ? NOTICE : (bt.resist > 750 ? NORMAL : Highlight.GOOD))));
if (vr != null && !FirmwareCapability.isG6Rev2(vr.firmware_version_string)) {
l.add(new StatusItem("Temperature", bt.temperature + " \u2103"));
}
}
return l;
}
use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.
the class RollCall method megaStatus.
// data for MegaStatus
public static List<StatusItem> megaStatus() {
if (indexed == null)
loadIndex();
GcmActivity.requestRollCall();
// TODO sort data
final boolean engineering = Home.get_engineering_mode();
final boolean desert_sync = DesertSync.isEnabled();
final String our_wifi_ssid = desert_sync ? wifiString() : "";
final List<StatusItem> lf = new ArrayList<>();
for (Map.Entry entry : indexed.entrySet()) {
final RollCall rc = (RollCall) entry.getValue();
// TODO refactor with stringbuilder
lf.add(new StatusItem(rc.role + (desert_sync ? rc.getRemoteWifiIndicate(our_wifi_ssid) : "") + (engineering ? ("\n" + JoH.niceTimeSince(rc.last_seen) + " ago") : ""), rc.bestName() + (desert_sync ? rc.getRemoteIpStatus() : "") + (engineering && rc.batteryValid() ? ("\n" + rc.battery + "%") : "") + (engineering && rc.bridgeBatteryValid() ? (" " + rc.bridge_battery + "%") : "")));
}
Collections.sort(lf, new Comparator<StatusItem>() {
public int compare(StatusItem left, StatusItem right) {
// descending sort ignore second line
int val = right.name.replaceFirst("\n.*$", "").compareTo(left.name.replaceFirst("\n.*$", ""));
// ascending sort
if (val == 0)
val = left.value.compareTo(right.value);
return val;
}
});
return new ArrayList<>(lf);
}
Aggregations