Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Jul 1, 2023
2 parents ae42ec1 + 65b81ad commit 498962f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ private static void timesliceInsulinWriter(Map<Long, Iob> timeslices, Iob thisio
}

// NEW NEW NEW
public static List<Iob> ioBForGraph_new(int number, long startTime) {
public static List<Iob> ioBForGraph_new(long startTime) {

// Log.d(TAG, "Processing iobforgraph2: main ");
JoH.benchmark_method_start();
Expand Down Expand Up @@ -1291,6 +1291,23 @@ public static List<Iob> ioBForGraph_old(int number, double startTime) {
return responses;
}*/

public static Double getCurrentIoB() {
long now = System.currentTimeMillis();

final List<Iob> iobInfo = Treatments.ioBForGraph_new(now - 1 * Constants.DAY_IN_MS);

if (iobInfo != null) {
for (Iob iob : iobInfo) {
// Find IoB sample close to the current timestamp.
if (iob.timestamp > now - 5 * MINUTE_IN_MS && iob.timestamp < now + 5 * MINUTE_IN_MS) {
return iob.iob;
}
}
}

return null;
}

public String getBestShortText() {
if (!eventType.equals(DEFAULT_EVENT_TYPE)) {
return eventType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2253,15 +2253,22 @@ public void run() {
if (!battery_status.equals("OK"))
l.add(new StatusItem("Transmitter Status", battery_status, BAD));
}
Highlight TX_dys_highlight; // Transmitter Days highlight
Highlight TX_dys_highlight = NORMAL; // Set the default transmitter days highlight to normal
final int TX_dys = DexTimeKeeper.getTransmitterAgeInDays(tx_id); // Transmitter days
if (vr != null && (FirmwareCapability.isTransmitterRawCapable(getTransmitterID())) || TX_dys < 69) {
// Transmitter days < 69 or G5 or old G6 or modified Firefly
TX_dys_highlight = NORMAL;
} else if (TX_dys < 100) { // Unmodified Firefly with 68 < Transmitter days < 100
TX_dys_highlight = NOTICE;
} else { // Unmodified Firefly with transmitter days > 99
TX_dys_highlight = BAD;
if (vr != null) {
if (FirmwareCapability.isTransmitterModified(getTransmitterID())) { // Modified Firefly
if (TX_dys > 179) { // No more starts as transmitter days > 179
TX_dys_highlight = BAD;
} else if (TX_dys > 148) { // Transmitter days approaching 180 - may be time to reset
TX_dys_highlight = NOTICE;
}
} else if (FirmwareCapability.isTransmitterRawIncapable(getTransmitterID())) { // Unmodified Firefly
if (TX_dys > 99) { // No more starts as transmitter days > 99
TX_dys_highlight = BAD;
} else if (TX_dys > 68) { // Transmitter days approaching 100 - may be time to order a new one
TX_dys_highlight = NOTICE;
}
}
}
l.add(new StatusItem("Transmitter Days", parsedBattery.daysEstimate(), TX_dys_highlight));
l.add(new StatusItem("Voltage A", parsedBattery.voltageA(), parsedBattery.voltageAWarning() ? BAD : NORMAL));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ private synchronized void addBgReadingValues(final boolean simple) {
final double relaxed_predicted_bg_limit = initial_predicted_bg * 1.20;
final double cob_insulin_max_draw_value = highMark * 1.20;
// final List<Iob> iobinfo_old = Treatments.ioBForGraph(numValues, (start_time * FUZZER));
final List<Iob> iobinfo = (simulation_enabled) ? Treatments.ioBForGraph_new(MAX_VALUES, (start_time * FUZZER)) : null; // for test
final List<Iob> iobinfo = (simulation_enabled) ? Treatments.ioBForGraph_new(start_time * FUZZER) : null; // for test

long fuzzed_timestamp = (long) end_time; // initial value in case there are no iob records
if (d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.eveningoutpost.dexdrip.models.Calibration;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.models.Treatments;
import com.eveningoutpost.dexdrip.dagger.Injectors;
import com.eveningoutpost.dexdrip.ui.MicroStatus;

Expand Down Expand Up @@ -82,7 +83,8 @@ public WebResponse request(String query) {
}

bgs.put("battery", microStatus.gs("bestBridgeBattery"));
bgs.put("iob", 0); // TODO get iob
Double iob = Treatments.getCurrentIoB();
bgs.put("iob", (iob == null) ? "unknown" : String.format("%.02f", iob));
// TODO output bwp and bwpo

status_array.put(status);
Expand Down

0 comments on commit 498962f

Please sign in to comment.