Support for TDDs
This commit is contained in:
parent
5a192d82d0
commit
1d2cd4b9cf
4 changed files with 18 additions and 8 deletions
Binary file not shown.
|
@ -193,8 +193,8 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
|||
|
||||
@Override
|
||||
public PumpEnactResult loadTDDs() {
|
||||
//TODO: read TDDs and store to DB
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,10 @@ import android.content.Intent;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import android.database.DatabaseUtils;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.db.TDD;
|
||||
import sugar.free.sightparser.handling.HistoryBroadcast;
|
||||
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache.updatePumpSerialNumber;
|
||||
|
@ -109,4 +113,12 @@ class HistoryIntentAdapter {
|
|||
log("ERROR, UNKNWON BOLUS TYPE: " + bolus_type);
|
||||
}
|
||||
}
|
||||
|
||||
void processDailyTotalIntent(Intent intent) {
|
||||
Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_TOTAL_DATE);
|
||||
double basal = intent.getDoubleExtra(HistoryBroadcast.EXTRA_BASAL_TOTAL, 0D);
|
||||
double bolus = intent.getDoubleExtra(HistoryBroadcast.EXTRA_BOLUS_TOTAL, 0D);
|
||||
TDD tdd = new TDD(date.getTime(), bolus, basal, bolus + basal);
|
||||
MainApp.getDbHelper().createOrUpdateTDD(tdd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,7 @@ import info.nightscout.androidaps.R;
|
|||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.BUSY;
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.SYNCED;
|
||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver.Status.SYNCING;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_BOLUS_DELIVERED;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_BOLUS_PROGRAMMED;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_END_OF_TBR;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_PUMP_STATUS_CHANGED;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_STILL_SYNCING;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_SYNC_FINISHED;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.ACTION_SYNC_STARTED;
|
||||
import static sugar.free.sightparser.handling.HistoryBroadcast.*;
|
||||
|
||||
/**
|
||||
* Created by jamorham on 27/01/2018.
|
||||
|
@ -45,6 +39,7 @@ public class HistoryReceiver {
|
|||
filter.addAction(ACTION_BOLUS_PROGRAMMED);
|
||||
filter.addAction(ACTION_BOLUS_DELIVERED);
|
||||
filter.addAction(ACTION_END_OF_TBR);
|
||||
filter.addAction(ACTION_DAILY_TOTAL);
|
||||
filter.addAction(ACTION_SYNC_STARTED);
|
||||
filter.addAction(ACTION_STILL_SYNCING);
|
||||
filter.addAction(ACTION_SYNC_FINISHED);
|
||||
|
@ -95,6 +90,9 @@ public class HistoryReceiver {
|
|||
case ACTION_END_OF_TBR:
|
||||
intentAdapter.processTBRIntent(intent);
|
||||
break;
|
||||
case ACTION_DAILY_TOTAL:
|
||||
intentAdapter.processDailyTotalIntent(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue