private boolean backFillIfNeeded(final AnnexARx annex, int offset) { if (annex == null) return false; if (!annex.isStateOkForBackFill()) return false; final Pair<Long, Long> backfillTimes = BackfillAssessor.check(); if (backfillTimes != null) { int startTick = TimeKeeper.tickCounterFromTimeStamp(serial, backfillTimes.first); int endTick = TimeKeeper.tickCounterFromTimeStamp(serial, backfillTimes.second); if (endTick >= annex.sensorAge) endTick = annex.sensorAge - 1; if (startTick < 62) startTick = 62; // after warmup only if (endTick < 1) endTick = 1; startTick += offset; if ((startTick != endTick) && (endTick > startTick)) { if (endTick - startTick > MAX_BACKFILL_ENTRIES) { endTick = startTick + MAX_BACKFILL_ENTRIES; // only ask this many at once } UserError.Log.d(TAG, "Ask backfill: start: " + startTick + " end: " + endTick); requestedBackfillSize = endTick - startTick; sendTx(new BackFillTx(startTick, endTick)); return true; } else { UserError.Log.d(TAG, "Not backfilling with start and end tick at: " + startTick + " " + endTick); } } return false; }
private boolean backFillIfNeeded(final AnnexARx annex, int offset) { if (annex == null) return false; if (!annex.isStateOkForBackFill()) return false; final Pair<Long, Long> backfillTimes = BackfillAssessor.check(); if (backfillTimes != null) { int startTick = TimeKeeper.tickCounterFromTimeStamp(serial, backfillTimes.first); int endTick = TimeKeeper.tickCounterFromTimeStamp(serial, backfillTimes.second); if (endTick >= annex.sensorAge) endTick = annex.sensorAge - 1; if (startTick < 62) startTick = 62; // after warmup only if (endTick < 1) endTick = 1; startTick += offset; if ((startTick != endTick) && (endTick > startTick)) { if (endTick - startTick > MAX_BACKFILL_ENTRIES) { endTick = startTick + MAX_BACKFILL_ENTRIES; // only ask this many at once } UserError.Log.d(TAG, "Ask backfill: start: " + startTick + " end: " + endTick); requestedBackfillSize = endTick - startTick; sendTx(new BackFillTx(startTick, endTick)); return true; } else { UserError.Log.d(TAG, "Not backfilling with start and end tick at: " + startTick + " " + endTick); } } return false; }