Search in sources :

Example 11 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.

the class LeFunService method megaStatus.

// Mega Status
public static List<StatusItem> megaStatus() {
    final List<StatusItem> l = new ArrayList<>();
    final Inst II = Inst.get(LeFunService.class.getSimpleName());
    l.add(new StatusItem("Model", LeFun.getModel()));
    l.add(new StatusItem("Mac address", LeFun.getMac()));
    l.add(new StatusItem("Connected", II.isConnected ? gs(R.string.yes) : gs(R.string.no)));
    if (II.wakeup_time != 0) {
        final long till = msTill(II.wakeup_time);
        if (till > 0)
            l.add(new StatusItem("Wake Up", niceTimeScalar(till)));
    }
    // if (II.retry_time != 0) {
    // l.add(new StatusItem("Retry", niceTimeScalar(msTill(II.retry_time))));
    // }
    l.add(new StatusItem("State", II.state));
    final int qsize = II.getQueueSize();
    if (qsize > 0) {
        l.add(new StatusItem("Queue", qsize + " items"));
    }
    return l;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) ArrayList(java.util.ArrayList)

Example 12 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.

the class MedtrumCollectionService method megaStatus.

// Mega Status
public static List<StatusItem> megaStatus() {
    if (lastAnnex == null) {
        lastAnnex = com.eveningoutpost.dexdrip.cgm.medtrum.Medtrum.getLastAdvertAnnex();
    // add some advert only marker
    }
    final List<StatusItem> l = new ArrayList<>();
    l.add(new StatusItem("Phone Service State", lastState));
    if (!JoH.emptyString(lastErrorState)) {
        l.add(new StatusItem("Error", lastErrorState, BAD));
    }
    if (lastAnnex != null) {
        l.add(new StatusItem("Battery", lastAnnex.getBatteryPercent() + "%"));
        if (lastAnnex.charging) {
            l.add(new StatusItem("Charging", lastAnnex.charged ? "Charged" : "On charge"));
        }
        l.add(new StatusItem("Sensor State", lastAnnex.getState().getDescription(), lastAnnex.getState() == Ok ? GOOD : NORMAL));
        if (lastAnnex.getState() == SensorState.WarmingUp1) {
            l.add(new StatusItem("Warm up", "Initial warm up", StatusItem.Highlight.NOTICE));
        } else if (lastAnnex.getState() == SensorState.WarmingUp2) {
            final long warmupMinsLeft = ((2 * HOUR_IN_MS) - lastAnnex.getSensorAgeInMs()) / Constants.MINUTE_IN_MS;
            if (warmupMinsLeft > -1 && warmupMinsLeft < 121) {
                l.add(new StatusItem("Warmup left", warmupMinsLeft + " mins", StatusItem.Highlight.NOTICE));
            }
        }
        if (lastAnnex.getSensorAgeInMs() > 0) {
            l.add(new StatusItem("Sensor Age", lastAnnex.getNiceSensorAge()));
        }
        if (lastAnnex.sensorGood) {
            l.add(new StatusItem("Sensor", "Good", GOOD));
        // } else {
        // if (lastAnnex.getState() == Ok) {
        // l.add(new StatusItem("Sensor", "Ok", StatusItem.Highlight.NORMAL));
        // }
        }
        if (lastAnnex.sensorError) {
            l.add(new StatusItem("Sensor Error", "Error", BAD));
        }
        if (lastAnnex.sensorFail) {
            l.add(new StatusItem("Sensor Fail", "FAILED", CRITICAL));
        }
        if (lastAnnex.calibrationErrorA) {
            l.add(new StatusItem("Calibration Error", "Error A", BAD));
        }
        if (lastAnnex.calibrationErrorB) {
            l.add(new StatusItem("Calibration Error", "Error B", BAD));
        }
        final Pair<Long, Integer> calibration = Medtrum.getCalibration();
        if (calibration != null) {
            l.add(new StatusItem("Blood test", BgGraphBuilder.unitized_string_with_units_static(calibration.second) + " @ " + JoH.hourMinuteString(calibration.first), StatusItem.Highlight.NOTICE));
        }
        if (serial != 0) {
            final int version = Medtrum.getVersion(serial);
            l.add(new StatusItem("Serial", "" + serial));
            if (version > 0) {
                final String versionString = "v" + (JoH.qs(version / 100d, 2));
                l.add(new StatusItem("Firmware", versionString));
            }
        }
        if (lastAnnex.getState() == Ok || lastAnnex.getState() == SensorState.NotCalibrated) {
            l.add(new StatusItem("Slope", JoH.qs(lastAnnex.calibrationSlope / 1000d, 3) + " (" + JoH.qs(1d / (lastAnnex.calibrationSlope / 1000d), 2) + ")"));
            l.add(new StatusItem("Intercept", lastAnnex.calibrationIntercept));
            l.add(new StatusItem("Raw Data", lastAnnex.sensorRaw));
        }
        if (lastAnnex.getState() == Ok) {
            l.add(new StatusItem("Last Glucose", BgGraphBuilder.unitized_string_with_units_static(lastAnnex.calculatedGlucose()) + (lastAnnex.recent() ? "" : " @ " + JoH.niceTimeScalarShort(JoH.msSince(lastAnnex.created))), lastAnnex.recent() ? NORMAL : StatusItem.Highlight.NOTICE));
        }
        if (retry_time != 0) {
            l.add(new StatusItem("Wake up in", JoH.niceTimeScalar(msTill(retry_time))));
        }
        if (failover_time != 0) {
            l.add(new StatusItem("System check in", JoH.niceTimeScalar(msTill(failover_time))));
        }
        if (Home.get_engineering_mode()) {
            l.add(new StatusItem("Brain State", state.getString()));
            l.add(new StatusItem("Last Interaction", JoH.niceTimeScalar(msSince(lastInteractionTime))));
            l.add(new StatusItem("Last Wake Up", JoH.niceTimeScalar(msSince(last_wake_up_time))));
        }
    } else {
        l.add(new StatusItem("Status Information", "Nothing Yet", StatusItem.Highlight.NOTICE));
    }
    return l;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) SuppressLint(android.annotation.SuppressLint)

Example 13 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.

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;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) ArrayList(java.util.ArrayList) UUID(java.util.UUID)

Example 14 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.

the class ShareFollowService method megaStatus.

/**
 * MegaStatus for Nightscout Follower
 */
public static List<StatusItem> megaStatus() {
    final BgReading lastBg = BgReading.lastNoSenssor();
    // 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";
    StatusItem.Highlight ageOfLastBgPollHighlight = StatusItem.Highlight.NORMAL;
    if (bgReceiveDelay > 0) {
        ageOfBgLastPoll = JoH.niceTimeScalar(bgReceiveDelay);
        if (bgReceiveDelay > SAMPLE_PERIOD / 2) {
            ageOfLastBgPollHighlight = StatusItem.Highlight.BAD;
        }
        if (bgReceiveDelay > SAMPLE_PERIOD * 2) {
            ageOfLastBgPollHighlight = StatusItem.Highlight.CRITICAL;
        }
    }
    // Status for time since latest BG
    String ageLastBg = "n/a";
    StatusItem.Highlight bgAgeHighlight = StatusItem.Highlight.NORMAL;
    if (lastBg != null) {
        long age = JoH.msSince(lastBg.timestamp);
        ageLastBg = JoH.niceTimeScalar(age);
        if (age > SAMPLE_PERIOD + hightlightGrace) {
            bgAgeHighlight = StatusItem.Highlight.BAD;
        }
    }
    List<StatusItem> megaStatus = new ArrayList<>();
    megaStatus.add(new StatusItem("Latest BG", ageLastBg + (lastBg != null ? " ago" : ""), bgAgeHighlight));
    megaStatus.add(new StatusItem("BG receive delay", ageOfBgLastPoll, ageOfLastBgPollHighlight));
    megaStatus.add(new StatusItem());
    megaStatus.add(new StatusItem("Last poll", lastPoll > 0 ? JoH.niceTimeScalar(JoH.msSince(lastPoll)) + " ago" : "n/a"));
    megaStatus.add(new StatusItem("Last wakeup", last_wakeup > 0 ? JoH.niceTimeScalar(JoH.msSince(last_wakeup)) + " ago" : "n/a"));
    megaStatus.add(new StatusItem("Next poll in", JoH.niceTimeScalar(wakeup_time - JoH.tsl())));
    if (lastBg != null) {
        megaStatus.add(new StatusItem("Last BG time", JoH.dateTimeText(lastBg.timestamp)));
    }
    megaStatus.add(new StatusItem("Next poll time", JoH.dateTimeText(wakeup_time)));
    megaStatus.add(new StatusItem());
    megaStatus.add(new StatusItem("Buggy Samsung", JoH.buggy_samsung ? gs(R.string.yes) : gs(R.string.no)));
    return megaStatus;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) ArrayList(java.util.ArrayList) BgReading(com.eveningoutpost.dexdrip.Models.BgReading) JoH.emptyString(com.eveningoutpost.dexdrip.Models.JoH.emptyString) SpannableString(android.text.SpannableString)

Example 15 with StatusItem

use of com.eveningoutpost.dexdrip.UtilityModels.StatusItem in project xDrip-plus by jamorham.

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;
}
Also used : StatusItem(com.eveningoutpost.dexdrip.UtilityModels.StatusItem) Highlight(com.eveningoutpost.dexdrip.UtilityModels.StatusItem.Highlight) ArrayList(java.util.ArrayList) BgReading(com.eveningoutpost.dexdrip.Models.BgReading) SpannableString(android.text.SpannableString)

Aggregations

StatusItem (com.eveningoutpost.dexdrip.UtilityModels.StatusItem)34 ArrayList (java.util.ArrayList)34 SpannableString (android.text.SpannableString)8 SuppressLint (android.annotation.SuppressLint)6 JoH.emptyString (com.eveningoutpost.dexdrip.Models.JoH.emptyString)6 BatteryInfoRxMessage (com.eveningoutpost.dexdrip.G5Model.BatteryInfoRxMessage)4 VersionRequestRxMessage (com.eveningoutpost.dexdrip.G5Model.VersionRequestRxMessage)4 BgReading (com.eveningoutpost.dexdrip.Models.BgReading)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 AlertDialog (android.app.AlertDialog)2 BluetoothDevice (android.bluetooth.BluetoothDevice)2 BluetoothManager (android.bluetooth.BluetoothManager)2 DialogInterface (android.content.DialogInterface)2 VersionRequest1RxMessage (com.eveningoutpost.dexdrip.G5Model.VersionRequest1RxMessage)2 VersionRequest2RxMessage (com.eveningoutpost.dexdrip.G5Model.VersionRequest2RxMessage)2 ActiveBluetoothDevice (com.eveningoutpost.dexdrip.Models.ActiveBluetoothDevice)2 Sensor (com.eveningoutpost.dexdrip.Models.Sensor)2 Highlight (com.eveningoutpost.dexdrip.UtilityModels.StatusItem.Highlight)2 KeyStore (com.eveningoutpost.dexdrip.store.KeyStore)2