Fix zero-temp for pump stopped periods
This commit is contained in:
parent
7a4d721c29
commit
4a11723a61
2 changed files with 8 additions and 8 deletions
|
@ -1739,7 +1739,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return getDaoInsightPumpID().queryBuilder()
|
return getDaoInsightPumpID().queryBuilder()
|
||||||
.orderBy("timestamp", false)
|
.orderBy("timestamp", false)
|
||||||
.where().eq("pumpSerial", pumpSerial)
|
.where().eq("pumpSerial", pumpSerial)
|
||||||
.and().eq("eventType", "PumpStopped")
|
.and().in("eventType", "PumpStopped", "PumpPaused")
|
||||||
.and().lt("timestamp", before)
|
.and().lt("timestamp", before)
|
||||||
.queryForFirst();
|
.queryForFirst();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|
|
@ -305,11 +305,11 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
public void getPumpStatus() {
|
public void getPumpStatus() {
|
||||||
try {
|
try {
|
||||||
tbrOverNotificationBlock = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, TBROverNotificationBlock.class);
|
tbrOverNotificationBlock = ParameterBlockUtil.readParameterBlock(connectionService, Service.CONFIGURATION, TBROverNotificationBlock.class);
|
||||||
fetchStatus();
|
readHistory();
|
||||||
fetchBasalProfile();
|
fetchBasalProfile();
|
||||||
fetchLimitations();
|
fetchLimitations();
|
||||||
updatePumpTimeIfNeeded();
|
updatePumpTimeIfNeeded();
|
||||||
readHistory();
|
fetchStatus();
|
||||||
} catch (AppLayerErrorException e) {
|
} catch (AppLayerErrorException e) {
|
||||||
log.info("Exception while fetching status: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
log.info("Exception while fetching status: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||||
} catch (InsightException e) {
|
} catch (InsightException e) {
|
||||||
|
@ -1121,7 +1121,7 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
Collections.reverse(temporaryBasals);
|
Collections.reverse(temporaryBasals);
|
||||||
for (InsightPumpID pumpID : pumpStartedEvents) {
|
for (InsightPumpID pumpID : pumpStartedEvents) {
|
||||||
InsightPumpID stoppedEvent = MainApp.getDbHelper().getPumpStoppedEvent(pumpID.pumpSerial, pumpID.timestamp);
|
InsightPumpID stoppedEvent = MainApp.getDbHelper().getPumpStoppedEvent(pumpID.pumpSerial, pumpID.timestamp);
|
||||||
if (stoppedEvent == null) continue;
|
if (stoppedEvent == null || stoppedEvent.eventType.equals("PumpPaused")) continue;
|
||||||
long tbrStart = stoppedEvent.timestamp + 10000;
|
long tbrStart = stoppedEvent.timestamp + 10000;
|
||||||
TemporaryBasal temporaryBasal = new TemporaryBasal();
|
TemporaryBasal temporaryBasal = new TemporaryBasal();
|
||||||
temporaryBasal.durationInMinutes = (int) ((pumpID.timestamp - tbrStart) / 60000);
|
temporaryBasal.durationInMinutes = (int) ((pumpID.timestamp - tbrStart) / 60000);
|
||||||
|
@ -1221,22 +1221,22 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
switch (event.getNewValue()) {
|
switch (event.getNewValue()) {
|
||||||
case STARTED:
|
case STARTED:
|
||||||
pumpID.eventType = "PumpStarted";
|
pumpID.eventType = "PumpStarted";
|
||||||
MainApp.getDbHelper().createOrUpdate(pumpID);
|
|
||||||
pumpStartedEvents.add(pumpID);
|
pumpStartedEvents.add(pumpID);
|
||||||
if (SP.getBoolean("insight_log_operating_mode_changes", false))
|
if (SP.getBoolean("insight_log_operating_mode_changes", false))
|
||||||
logNote(timestamp, MainApp.gs(R.string.pump_started));
|
logNote(timestamp, MainApp.gs(R.string.pump_started));
|
||||||
break;
|
break;
|
||||||
case STOPPED:
|
case STOPPED:
|
||||||
|
pumpID.eventType = "PumpStopped";
|
||||||
if (SP.getBoolean("insight_log_operating_mode_changes", false))
|
if (SP.getBoolean("insight_log_operating_mode_changes", false))
|
||||||
pumpID.eventType = "PumpStopped";
|
logNote(timestamp, MainApp.gs(R.string.pump_stopped));
|
||||||
MainApp.getDbHelper().createOrUpdate(pumpID);
|
|
||||||
logNote(timestamp, MainApp.gs(R.string.pump_stopped));
|
|
||||||
break;
|
break;
|
||||||
case PAUSED:
|
case PAUSED:
|
||||||
|
pumpID.eventType = "PumpPaused";
|
||||||
if (SP.getBoolean("insight_log_operating_mode_changes", false))
|
if (SP.getBoolean("insight_log_operating_mode_changes", false))
|
||||||
logNote(timestamp, MainApp.gs(R.string.pump_paused));
|
logNote(timestamp, MainApp.gs(R.string.pump_paused));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
MainApp.getDbHelper().createOrUpdate(pumpID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processStartOfTBREvent(String serial, List<TemporaryBasal> temporaryBasals, StartOfTBREvent event) {
|
private void processStartOfTBREvent(String serial, List<TemporaryBasal> temporaryBasals, StartOfTBREvent event) {
|
||||||
|
|
Loading…
Reference in a new issue