finish Dana pumps
This commit is contained in:
parent
07d060c2b5
commit
299d0a9b01
6 changed files with 53 additions and 29 deletions
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.database.AppRepository
|
|||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||
import info.nightscout.androidaps.databinding.MaintenanceFragmentBinding
|
||||
import info.nightscout.androidaps.events.EventNewBG
|
||||
import info.nightscout.androidaps.interfaces.DataSyncSelector
|
||||
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
|
||||
import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
|
@ -36,6 +37,7 @@ class MaintenanceFragment : DaggerFragment() {
|
|||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var databaseHelper: DatabaseHelperInterface
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var dataSyncSelector: DataSyncSelector
|
||||
|
||||
private val compositeDisposable = CompositeDisposable()
|
||||
|
||||
|
@ -65,6 +67,7 @@ class MaintenanceFragment : DaggerFragment() {
|
|||
fromAction {
|
||||
databaseHelper.resetDatabases()
|
||||
repository.clearDatabases()
|
||||
dataSyncSelector.resetToNextFullSync()
|
||||
}
|
||||
.subscribeOn(aapsSchedulers.io)
|
||||
.observeOn(aapsSchedulers.main)
|
||||
|
|
|
@ -71,7 +71,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
|||
PumpSync pumpSync,
|
||||
FabricPrivacy fabricPrivacy
|
||||
) {
|
||||
super(injector, danaPump, resourceHelper, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil);
|
||||
super(injector, danaPump, resourceHelper, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil, pumpSync);
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.context = context;
|
||||
this.resourceHelper = resourceHelper;
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.events.EventAppExit;
|
|||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PumpSync;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
|
@ -69,9 +70,10 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
|||
CommandQueueProvider commandQueue,
|
||||
DetailedBolusInfoStorage detailedBolusInfoStorage,
|
||||
DateUtil dateUtil,
|
||||
FabricPrivacy fabricPrivacy
|
||||
FabricPrivacy fabricPrivacy,
|
||||
PumpSync pumpSync
|
||||
) {
|
||||
super(injector, danaPump, resourceHelper, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil);
|
||||
super(injector, danaPump, resourceHelper, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil, pumpSync);
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.context = context;
|
||||
this.resourceHelper = resourceHelper;
|
||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.danaRv2.comm
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.danar.R
|
||||
import info.nightscout.androidaps.danar.comm.MessageBase
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||
import info.nightscout.androidaps.db.ExtendedBolus
|
||||
import info.nightscout.androidaps.db.Source
|
||||
import info.nightscout.androidaps.db.TemporaryBasal
|
||||
|
@ -91,26 +90,26 @@ class MsgHistoryEvents_v2 constructor(
|
|||
|
||||
info.nightscout.androidaps.dana.DanaPump.BOLUS -> {
|
||||
val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(datetime, param1 / 100.0)
|
||||
?: DetailedBolusInfo()
|
||||
detailedBolusInfo.bolusTimestamp = datetime
|
||||
detailedBolusInfo.pumpType = PumpType.DANA_RV2
|
||||
detailedBolusInfo.pumpSerial = danaPump.serialNumber
|
||||
detailedBolusInfo.bolusPumpId = datetime
|
||||
detailedBolusInfo.insulin = param1 / 100.0
|
||||
val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
|
||||
val newRecord = pumpSync.syncBolusWithPumpId(
|
||||
timestamp = datetime,
|
||||
amount = param1 / 100.0,
|
||||
type = detailedBolusInfo?.bolusType,
|
||||
pumpId = datetime,
|
||||
pumpType = PumpType.DANA_RV2,
|
||||
pumpSerial = danaPump.serialNumber)
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min")
|
||||
status = "BOLUS " + dateUtil.timeString(datetime)
|
||||
}
|
||||
|
||||
info.nightscout.androidaps.dana.DanaPump.DUALBOLUS -> {
|
||||
val detailedBolusInfo = detailedBolusInfoStorage.findDetailedBolusInfo(datetime, param1 / 100.0)
|
||||
?: DetailedBolusInfo()
|
||||
detailedBolusInfo.bolusTimestamp = datetime
|
||||
detailedBolusInfo.pumpType = PumpType.DANA_RV2
|
||||
detailedBolusInfo.pumpSerial = danaPump.serialNumber
|
||||
detailedBolusInfo.bolusPumpId = datetime
|
||||
detailedBolusInfo.insulin = param1 / 100.0
|
||||
val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
|
||||
val newRecord = pumpSync.syncBolusWithPumpId(
|
||||
timestamp = datetime,
|
||||
amount = param1 / 100.0,
|
||||
type = detailedBolusInfo?.bolusType,
|
||||
pumpId = datetime,
|
||||
pumpType = PumpType.DANA_RV2,
|
||||
pumpSerial = danaPump.serialNumber)
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min")
|
||||
status = "DUALBOLUS " + dateUtil.timeString(datetime)
|
||||
}
|
||||
|
@ -155,13 +154,12 @@ class MsgHistoryEvents_v2 constructor(
|
|||
}
|
||||
|
||||
info.nightscout.androidaps.dana.DanaPump.CARBS -> {
|
||||
val emptyCarbsInfo = DetailedBolusInfo()
|
||||
emptyCarbsInfo.carbs = param1.toDouble()
|
||||
emptyCarbsInfo.carbsTimestamp = datetime
|
||||
emptyCarbsInfo.pumpType = PumpType.DANA_RV2
|
||||
emptyCarbsInfo.pumpSerial = danaPump.serialNumber
|
||||
emptyCarbsInfo.carbsPumpId = datetime
|
||||
val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(emptyCarbsInfo, false)
|
||||
val newRecord = pumpSync.syncCarbsWithTimestamp(
|
||||
timestamp = datetime,
|
||||
amount = param1.toDouble(),
|
||||
pumpId = datetime,
|
||||
pumpType = PumpType.DANA_RV2,
|
||||
pumpSerial = danaPump.serialNumber)
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g")
|
||||
status = "CARBS " + dateUtil.timeString(datetime)
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
|||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpPluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpSync;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
|
@ -64,6 +65,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
|||
protected SP sp;
|
||||
protected DateUtil dateUtil;
|
||||
protected AapsSchedulers aapsSchedulers;
|
||||
protected PumpSync pumpSync;
|
||||
|
||||
protected AbstractDanaRPlugin(
|
||||
HasAndroidInjector injector,
|
||||
|
@ -76,7 +78,8 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
|||
RxBusWrapper rxBus,
|
||||
ActivePluginProvider activePlugin,
|
||||
SP sp,
|
||||
DateUtil dateUtil
|
||||
DateUtil dateUtil,
|
||||
PumpSync pumpSync
|
||||
) {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.PUMP)
|
||||
|
@ -95,6 +98,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
|||
this.sp = sp;
|
||||
this.dateUtil = dateUtil;
|
||||
this.aapsSchedulers = aapsSchedulers;
|
||||
this.pumpSync = pumpSync;
|
||||
}
|
||||
|
||||
@Override protected void onStart() {
|
||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
|||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpSync;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
|
@ -34,6 +35,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
|||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.Round;
|
||||
import info.nightscout.androidaps.utils.T;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
@ -63,9 +65,10 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
|||
CommandQueueProvider commandQueue,
|
||||
DanaPump danaPump,
|
||||
DateUtil dateUtil,
|
||||
FabricPrivacy fabricPrivacy
|
||||
FabricPrivacy fabricPrivacy,
|
||||
PumpSync pumpSync
|
||||
) {
|
||||
super(injector, danaPump, resourceHelper, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil);
|
||||
super(injector, danaPump, resourceHelper, constraintChecker, aapsLogger, aapsSchedulers, commandQueue, rxBus, activePlugin, sp, dateUtil, pumpSync);
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.context = context;
|
||||
this.resourceHelper = resourceHelper;
|
||||
|
@ -176,7 +179,21 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
|||
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.getBolusDelivered());
|
||||
detailedBolusInfo.insulin = t.insulin;
|
||||
detailedBolusInfo.timestamp = System.currentTimeMillis();
|
||||
activePlugin.getActiveTreatments().addToHistoryTreatment(detailedBolusInfo, false);
|
||||
if (detailedBolusInfo.insulin > 0)
|
||||
pumpSync.syncBolusWithPumpId(
|
||||
detailedBolusInfo.timestamp,
|
||||
detailedBolusInfo.insulin,
|
||||
detailedBolusInfo.getBolusType(),
|
||||
dateUtil._now(),
|
||||
PumpType.DANA_R,
|
||||
serialNumber());
|
||||
if (detailedBolusInfo.carbs > 0)
|
||||
pumpSync.syncCarbsWithTimestamp(
|
||||
detailedBolusInfo.timestamp + T.mins(detailedBolusInfo.carbTime).msecs(),
|
||||
detailedBolusInfo.carbs,
|
||||
null,
|
||||
PumpType.DANA_R,
|
||||
serialNumber());
|
||||
return result;
|
||||
} else {
|
||||
PumpEnactResult result = new PumpEnactResult(getInjector());
|
||||
|
|
Loading…
Reference in a new issue