Provide basic pump data for upload.
This commit is contained in:
parent
e6eee42081
commit
81f3aea42a
2 changed files with 27 additions and 15 deletions
|
@ -426,6 +426,8 @@ public class RuffyScripter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO v2 add remaining info we can extract from the main menu, low battery and low
|
||||||
|
// cartridge warnings, running extended bolus (how does that look if a TBR is active as well?)
|
||||||
private PumpState readPumpState() {
|
private PumpState readPumpState() {
|
||||||
PumpState state = new PumpState();
|
PumpState state = new PumpState();
|
||||||
Menu menu = currentMenu;
|
Menu menu = currentMenu;
|
||||||
|
|
|
@ -519,16 +519,18 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
return OPERATION_NOT_SUPPORTED;
|
return OPERATION_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// Returns the state of the pump as it was received during last pump comms.
|
||||||
// cache as much as possible - every time we interact with the pump it vibrates at the end
|
// TODO v2 add battery, reservoir info when we start reading that and clean up the code
|
||||||
@Override
|
@Override
|
||||||
public JSONObject getJSONStatus() {
|
public JSONObject getJSONStatus() {
|
||||||
/// TODO not doing that just yet
|
if (lastCmdTime.getTime() + 5 * 60 * 1000L < System.currentTimeMillis()) {
|
||||||
if (1 == 1) return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
JSONObject pump = new JSONObject();
|
JSONObject pump = new JSONObject();
|
||||||
JSONObject status = new JSONObject();
|
JSONObject status = new JSONObject();
|
||||||
JSONObject extended = new JSONObject();
|
JSONObject extended = new JSONObject();
|
||||||
try {
|
|
||||||
status.put("status", statusSummary);
|
status.put("status", statusSummary);
|
||||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||||
try {
|
try {
|
||||||
|
@ -537,22 +539,30 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
}
|
}
|
||||||
status.put("timestamp", lastCmdTime);
|
status.put("timestamp", lastCmdTime);
|
||||||
|
|
||||||
PumpState ps = this.pumpState;
|
PumpState ps = pumpState;
|
||||||
if (ps != null) {
|
if (ps != null) {
|
||||||
|
if (ps.tbrActive) {
|
||||||
extended.put("TempBasalAbsoluteRate", ps.tbrRate);
|
extended.put("TempBasalAbsoluteRate", ps.tbrRate);
|
||||||
// TODO best guess at this point ...
|
extended.put("TempBasalPercent", ps.tbrPercent);
|
||||||
extended.put("TempBasalStart", DateUtil.dateAndTimeString(System.currentTimeMillis() - (ps.tbrRemainingDuration - 15 * 60 * 1000)));
|
|
||||||
extended.put("TempBasalRemaining", ps.tbrRemainingDuration);
|
extended.put("TempBasalRemaining", ps.tbrRemainingDuration);
|
||||||
}
|
}
|
||||||
|
if (ps.errorMsg != null) {
|
||||||
|
extended.put("ErrorMessage", ps.errorMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// more info here .... look at dana plugin
|
// more info here .... look at dana plugin
|
||||||
|
|
||||||
pump.put("status", status);
|
pump.put("status", status);
|
||||||
pump.put("extended", extended);
|
pump.put("extended", extended);
|
||||||
pump.put("clock", DateUtil.toISOString(new Date()));
|
pump.put("clock", DateUtil.toISOString(lastCmdTime));
|
||||||
} catch (JSONException e) {
|
|
||||||
}
|
|
||||||
return pump;
|
return pump;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Failed to gather device status for upload", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
Loading…
Reference in a new issue