remove some deprecated calls
This commit is contained in:
parent
42cfd87a2b
commit
18820441a4
21 changed files with 94 additions and 75 deletions
|
@ -44,6 +44,7 @@ import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
|||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
|
@ -999,7 +1000,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
public void createTempBasalFromJsonIfNotExists(JSONObject trJson) {
|
||||
try {
|
||||
if (trJson.has("originalExtendedAmount")) { // extended bolus uploaded as temp basal
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus()
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus(MainApp.instance())
|
||||
.source(Source.NIGHTSCOUT)
|
||||
.date(trJson.getLong("mills"))
|
||||
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0)
|
||||
|
@ -1014,7 +1015,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
}
|
||||
createOrUpdate(extendedBolus);
|
||||
} else if (trJson.has("isFakedTempBasal")) { // extended bolus end uploaded as temp basal end
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus(MainApp.instance());
|
||||
extendedBolus.source = Source.NIGHTSCOUT;
|
||||
extendedBolus.date = trJson.getLong("mills");
|
||||
extendedBolus.pumpId = trJson.has("pumpId") ? trJson.getLong("pumpId") : 0;
|
||||
|
@ -1029,7 +1030,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
}
|
||||
createOrUpdate(extendedBolus);
|
||||
} else {
|
||||
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||
TemporaryBasal tempBasal = new TemporaryBasal( MainApp.instance())
|
||||
.date(trJson.getLong("mills"))
|
||||
.source(Source.NIGHTSCOUT)
|
||||
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0);
|
||||
|
@ -1288,7 +1289,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
*/
|
||||
|
||||
public void createExtendedBolusFromJsonIfNotExists(JSONObject json) {
|
||||
ExtendedBolus extendedBolus = ExtendedBolus.createFromJson(json);
|
||||
ExtendedBolus extendedBolus = ExtendedBolus.createFromJson(MainApp.instance(), json);
|
||||
if (extendedBolus != null)
|
||||
createOrUpdate(extendedBolus);
|
||||
}
|
||||
|
@ -1480,7 +1481,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
List<CareportalEvent> list = getDaoCareportalEvents().query(preparedQuery);
|
||||
CareportalEvent careportalEvent;
|
||||
if (list.size() == 0) {
|
||||
careportalEvent = new CareportalEvent();
|
||||
careportalEvent = new CareportalEvent(MainApp.instance());
|
||||
careportalEvent.source = Source.NIGHTSCOUT;
|
||||
if (L.isEnabled(L.DATABASE))
|
||||
log.debug("Adding CareportalEvent record to database: " + trJson.toString());
|
||||
|
@ -1708,9 +1709,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
}
|
||||
*/
|
||||
|
||||
public void createProfileSwitchFromJsonIfNotExists(JSONObject trJson) {
|
||||
public void createProfileSwitchFromJsonIfNotExists(ActivePluginProvider activePluginProvider, JSONObject trJson) {
|
||||
try {
|
||||
ProfileSwitch profileSwitch = new ProfileSwitch(MainApp.instance().injector);
|
||||
ProfileSwitch profileSwitch = new ProfileSwitch(MainApp.instance());
|
||||
profileSwitch.date = trJson.getLong("mills");
|
||||
if (trJson.has("duration"))
|
||||
profileSwitch.durationInMinutes = trJson.getInt("duration");
|
||||
|
@ -1725,7 +1726,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
|||
if (trJson.has("profileJson"))
|
||||
profileSwitch.profileJson = trJson.getString("profileJson");
|
||||
else {
|
||||
ProfileInterface profileInterface = PluginStore.Companion.getInstance().getActiveProfileInterface();
|
||||
ProfileInterface profileInterface = activePluginProvider.getActiveProfileInterface();
|
||||
ProfileStore store = profileInterface.getProfile();
|
||||
if (store != null) {
|
||||
Profile profile = store.getSpecificProfile(profileSwitch.profileName);
|
||||
|
|
|
@ -10,18 +10,20 @@ import com.j256.ormlite.field.DatabaseField;
|
|||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.Interval;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.DataPointWithLabelInterface;
|
||||
import info.nightscout.androidaps.plugins.general.overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||
|
@ -38,7 +40,10 @@ import info.nightscout.androidaps.utils.Round;
|
|||
|
||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_EXTENDEDBOLUSES)
|
||||
public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE);
|
||||
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
|
||||
private HasAndroidInjector injector;
|
||||
|
||||
@DatabaseField(id = true)
|
||||
public long date;
|
||||
|
@ -64,10 +69,19 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
|||
@DatabaseField
|
||||
public double dia = Constants.defaultDIA;
|
||||
|
||||
@Deprecated
|
||||
public ExtendedBolus() {
|
||||
injector = MainApp.instance();
|
||||
injector.androidInjector().inject(this);
|
||||
}
|
||||
|
||||
public ExtendedBolus(long date) {
|
||||
public ExtendedBolus(HasAndroidInjector injector) {
|
||||
this.injector = injector;
|
||||
injector.androidInjector().inject(this);
|
||||
}
|
||||
|
||||
public ExtendedBolus(HasAndroidInjector injector, long date) {
|
||||
this(injector);
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
@ -124,8 +138,8 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
|||
pumpId = t.pumpId;
|
||||
}
|
||||
|
||||
public static ExtendedBolus createFromJson(JSONObject json) {
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus()
|
||||
public static ExtendedBolus createFromJson(HasAndroidInjector injector, JSONObject json) {
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus(injector)
|
||||
.source(Source.NIGHTSCOUT)
|
||||
.date(JsonHelper.safeGetLong(json, "mills"))
|
||||
.durationInMinutes(JsonHelper.safeGetInt(json, "duration"))
|
||||
|
@ -219,7 +233,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
|||
|
||||
public IobTotal iobCalc(long time) {
|
||||
IobTotal result = new IobTotal(time);
|
||||
InsulinInterface insulinInterface = PluginStore.Companion.getInstance().getActiveInsulin();
|
||||
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
||||
|
||||
double realDuration = getDurationToTime(time);
|
||||
|
||||
|
@ -251,7 +265,7 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
|||
|
||||
public IobTotal iobCalc(long time, Profile profile, AutosensResult lastAutosensResult, boolean exercise_mode, int half_basal_exercise_target, boolean isTempTarget) {
|
||||
IobTotal result = new IobTotal(time);
|
||||
InsulinInterface insulinInterface = PluginStore.Companion.getInstance().getActiveInsulin();
|
||||
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
||||
|
||||
double realDuration = getDurationToTime(time);
|
||||
double netBasalAmount = 0d;
|
||||
|
|
|
@ -3,8 +3,6 @@ package info.nightscout.androidaps.db;
|
|||
import com.j256.ormlite.field.DatabaseField;
|
||||
import com.j256.ormlite.table.DatabaseTable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -15,17 +13,16 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.Interval;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.PluginStore;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 21.05.2017.
|
||||
|
@ -33,9 +30,12 @@ import info.nightscout.androidaps.utils.SP;
|
|||
|
||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPORARYBASALS)
|
||||
public class TemporaryBasal implements Interval, DbObjectBase {
|
||||
private static Logger log = StacktraceLoggerWrapper.getLogger(L.DATABASE);
|
||||
|
||||
@Inject public AAPSLogger aapsLogger;
|
||||
@Inject public ProfileFunction profileFunction;
|
||||
@Inject public ActivePluginProvider activePlugin;
|
||||
@Inject public SP sp;
|
||||
|
||||
private HasAndroidInjector injector;
|
||||
|
||||
@DatabaseField(id = true)
|
||||
|
@ -246,12 +246,12 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
|||
public IobTotal iobCalc(long time, Profile profile) {
|
||||
|
||||
if (isFakeExtended) {
|
||||
log.error("iobCalc should only be called on Extended boluses separately");
|
||||
aapsLogger.error("iobCalc should only be called on Extended boluses separately");
|
||||
return new IobTotal(time);
|
||||
}
|
||||
|
||||
IobTotal result = new IobTotal(time);
|
||||
InsulinInterface insulinInterface = PluginStore.Companion.getInstance().getActiveInsulin();
|
||||
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
||||
|
||||
int realDuration = getDurationToTime(time);
|
||||
double netBasalAmount = 0d;
|
||||
|
@ -301,12 +301,12 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
|||
public IobTotal iobCalc(long time, Profile profile, AutosensResult lastAutosensResult, boolean exercise_mode, int half_basal_exercise_target, boolean isTempTarget) {
|
||||
|
||||
if (isFakeExtended) {
|
||||
log.error("iobCalc should only be called on Extended boluses separately");
|
||||
aapsLogger.error("iobCalc should only be called on Extended boluses separately");
|
||||
return new IobTotal(time);
|
||||
}
|
||||
|
||||
IobTotal result = new IobTotal(time);
|
||||
InsulinInterface insulinInterface = PluginStore.Companion.getInstance().getActiveInsulin();
|
||||
InsulinInterface insulinInterface = activePlugin.getActiveInsulin();
|
||||
|
||||
double realDuration = getDurationToTime(time);
|
||||
double netBasalAmount = 0d;
|
||||
|
@ -452,7 +452,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
|||
rate = absoluteRate;
|
||||
}
|
||||
|
||||
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)) {
|
||||
if (sp.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && sp.getBoolean(R.string.key_danar_useextended, false)) {
|
||||
Profile profile = profileFunction.getProfile();
|
||||
if (profile != null) {
|
||||
double basal = profile.getBasal();
|
||||
|
@ -483,7 +483,7 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
|||
rate = absoluteRate;
|
||||
}
|
||||
|
||||
if (SP.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && SP.getBoolean(R.string.key_danar_useextended, false)) {
|
||||
if (sp.getBoolean(R.string.key_danar_visualizeextendedaspercentage, false) && sp.getBoolean(R.string.key_danar_useextended, false)) {
|
||||
double basal = profile.getBasal();
|
||||
if (basal != 0) {
|
||||
return Math.round(rate * 100d / basal) + "% ";
|
||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.data.Profile
|
|||
import info.nightscout.androidaps.data.ProfileStore
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.db.CareportalEvent
|
||||
import info.nightscout.androidaps.db.ExtendedBolus
|
||||
import info.nightscout.androidaps.db.ProfileSwitch
|
||||
import info.nightscout.androidaps.db.TemporaryBasal
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||
|
@ -26,6 +27,7 @@ abstract class DataClassesModule {
|
|||
@ContributesAndroidInjector abstract fun profileSwitchInjector(): ProfileSwitch
|
||||
@ContributesAndroidInjector abstract fun temporaryBasalInjector(): TemporaryBasal
|
||||
@ContributesAndroidInjector abstract fun careportalEventInjector(): CareportalEvent
|
||||
@ContributesAndroidInjector abstract fun extendedBolusInjector(): ExtendedBolus
|
||||
|
||||
@ContributesAndroidInjector abstract fun bolusWizardInjector(): BolusWizard
|
||||
@ContributesAndroidInjector abstract fun quickWizardEntryInjector(): QuickWizardEntry
|
||||
|
|
|
@ -12,21 +12,6 @@ class PluginStore @Inject constructor(
|
|||
val aapsLogger: AAPSLogger
|
||||
) : ActivePluginProvider {
|
||||
|
||||
// TODO remove
|
||||
init {
|
||||
pluginStore = this
|
||||
}
|
||||
|
||||
companion object {
|
||||
var pluginStore: PluginStore? = null
|
||||
|
||||
@Deprecated("Use dagger instead")
|
||||
fun getInstance(): PluginStore {
|
||||
checkNotNull(pluginStore) { "Accessing PluginStore before first instantiation" }
|
||||
return pluginStore!!
|
||||
}
|
||||
}
|
||||
|
||||
lateinit var plugins: List<@JvmSuppressWildcards PluginBase>
|
||||
|
||||
private var activeBgSource: BgSourceInterface? = null
|
||||
|
@ -165,8 +150,7 @@ class PluginStore @Inject constructor(
|
|||
* @return
|
||||
</T> */
|
||||
private fun <T> determineActivePlugin(pluginInterface: Class<T>, pluginType: PluginType): T? {
|
||||
val pluginsInCategory: ArrayList<PluginBase>
|
||||
pluginsInCategory = pluginStore!!.getSpecificPluginsListByInterface(pluginInterface)
|
||||
val pluginsInCategory: ArrayList<PluginBase> = getSpecificPluginsListByInterface(pluginInterface)
|
||||
return determineActivePlugin(pluginsInCategory, pluginType)
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class MessageHashTableR @Inject constructor(
|
|||
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
||||
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
||||
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
||||
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||
put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||
put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
||||
put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
||||
// 0x0301 CMD_PUMPINIT_TIME_INFO
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.comm
|
||||
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.db.ExtendedBolus
|
||||
import info.nightscout.androidaps.db.Source
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
|
@ -10,6 +11,7 @@ import info.nightscout.androidaps.utils.DateUtil
|
|||
import kotlin.math.ceil
|
||||
|
||||
class MsgStatusBolusExtended(
|
||||
private val injector: HasAndroidInjector,
|
||||
private val aapsLogger: AAPSLogger,
|
||||
private val danaRPump: DanaRPump,
|
||||
private val activePlugin: ActivePluginProvider
|
||||
|
@ -60,11 +62,11 @@ class MsgStatusBolusExtended(
|
|||
if (extendedBolus != null) {
|
||||
if (danaRPump.isExtendedInProgress) {
|
||||
if (extendedBolus.absoluteRate() != danaRPump.extendedBolusAbsoluteRate) { // Close current extended
|
||||
val exStop = ExtendedBolus(danaRPump.extendedBolusStart - 1000)
|
||||
val exStop = ExtendedBolus(injector, danaRPump.extendedBolusStart - 1000)
|
||||
exStop.source = Source.USER
|
||||
activePlugin.activeTreatments.addToHistoryExtendedBolus(exStop)
|
||||
// Create new
|
||||
val newExtended = ExtendedBolus()
|
||||
val newExtended = ExtendedBolus(injector)
|
||||
.date(danaRPump.extendedBolusStart)
|
||||
.insulin(danaRPump.extendedBolusAmount)
|
||||
.durationInMinutes(danaRPump.extendedBolusMinutes)
|
||||
|
@ -73,13 +75,13 @@ class MsgStatusBolusExtended(
|
|||
}
|
||||
} else {
|
||||
// Close current temp basal
|
||||
val exStop = ExtendedBolus(now)
|
||||
val exStop = ExtendedBolus(injector, now)
|
||||
.source(Source.USER)
|
||||
activePlugin.activeTreatments.addToHistoryExtendedBolus(exStop)
|
||||
}
|
||||
} else {
|
||||
if (danaRPump.isExtendedInProgress) { // Create new
|
||||
val newExtended = ExtendedBolus()
|
||||
val newExtended = ExtendedBolus(injector)
|
||||
.date(danaRPump.extendedBolusStart)
|
||||
.insulin(danaRPump.extendedBolusAmount)
|
||||
.durationInMinutes(danaRPump.extendedBolusMinutes)
|
||||
|
|
|
@ -150,7 +150,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump);
|
||||
MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump);
|
||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
|
||||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin);
|
||||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin);
|
||||
MsgCheckValue checkValue = new MsgCheckValue(aapsLogger, danaRPump, danaRPlugin);
|
||||
|
||||
if (danaRPump.isNewPump()) {
|
||||
|
@ -259,7 +259,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
if (!isConnected()) return false;
|
||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus)));
|
||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin));
|
||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||
return true;
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
if (!isConnected()) return false;
|
||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin));
|
||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class MessageHashTableRKorean @Inject constructor(
|
|||
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
|
||||
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
|
||||
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
|
||||
put(MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||
put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I
|
||||
put(MsgStatusBasic_k(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
|
||||
put(MsgStatus_k(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
|
||||
put(MsgInitConnStatusTime_k(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) // 0x0301 CMD_PUMPINIT_TIME_INFO
|
||||
|
|
|
@ -139,7 +139,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
//MsgStatus_k statusMsg = new MsgStatus_k();
|
||||
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k(aapsLogger, danaRPump);
|
||||
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
|
||||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin);
|
||||
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin);
|
||||
MsgCheckValue_k checkValue = new MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin);
|
||||
|
||||
if (danaRPump.isNewPump()) {
|
||||
|
@ -246,7 +246,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
if (!isConnected()) return false;
|
||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus)));
|
||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF)));
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin));
|
||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||
return true;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
if (!isConnected()) return false;
|
||||
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
|
||||
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin));
|
||||
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin));
|
||||
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ open class DanaRS_Packet_APS_History_Events(
|
|||
val param1 = (intFromBuff(data, 7, 1) shl 8 and 0xFF00) + (intFromBuff(data, 8, 1) and 0xFF)
|
||||
val param2 = (intFromBuff(data, 9, 1) shl 8 and 0xFF00) + (intFromBuff(data, 10, 1) and 0xFF)
|
||||
val temporaryBasal = TemporaryBasal(injector).date(datetime).source(Source.PUMP).pumpId(datetime)
|
||||
val extendedBolus = ExtendedBolus().date(datetime).source(Source.PUMP).pumpId(datetime)
|
||||
val extendedBolus = ExtendedBolus(injector).date(datetime).source(Source.PUMP).pumpId(datetime)
|
||||
val status: String
|
||||
when (recordCode.toInt()) {
|
||||
DanaRPump.TEMPSTART -> {
|
||||
|
|
|
@ -67,7 +67,7 @@ class MsgHistoryEvents_v2 constructor(
|
|||
.date(datetime)
|
||||
.source(Source.PUMP)
|
||||
.pumpId(datetime)
|
||||
val extendedBolus = ExtendedBolus()
|
||||
val extendedBolus = ExtendedBolus(injector)
|
||||
.date(datetime)
|
||||
.source(Source.PUMP)
|
||||
.pumpId(datetime)
|
||||
|
|
|
@ -817,7 +817,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
insightBolusID.timestamp = System.currentTimeMillis();
|
||||
insightBolusID.pumpSerial = connectionService.getPumpSystemIdentification().getSerialNumber();
|
||||
MainApp.getDbHelper().createOrUpdate(insightBolusID);
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus(getInjector());
|
||||
extendedBolus.date = insightBolusID.timestamp;
|
||||
extendedBolus.source = Source.PUMP;
|
||||
extendedBolus.durationInMinutes = durationInMinutes;
|
||||
|
@ -1409,7 +1409,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, true);
|
||||
}
|
||||
if ((event.getBolusType() == BolusType.EXTENDED || event.getBolusType() == BolusType.MULTIWAVE)) {
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus(getInjector());
|
||||
extendedBolus.date = bolusID.timestamp;
|
||||
extendedBolus.source = Source.PUMP;
|
||||
extendedBolus.durationInMinutes = event.getDuration();
|
||||
|
@ -1452,7 +1452,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
MainApp.getDbHelper().delete(extendedBolus);
|
||||
}
|
||||
} else {
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus(getInjector());
|
||||
extendedBolus.date = bolusID.timestamp;
|
||||
extendedBolus.source = Source.PUMP;
|
||||
extendedBolus.durationInMinutes = event.getDuration();
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Map;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.android.HasAndroidInjector;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
|
@ -73,6 +74,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
|||
@Singleton
|
||||
public class MedtronicHistoryData {
|
||||
|
||||
private final HasAndroidInjector injector;
|
||||
private final AAPSLogger aapsLogger;
|
||||
private final SP sp;
|
||||
private final ActivePluginProvider activePlugin;
|
||||
|
@ -100,6 +102,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
@Inject
|
||||
public MedtronicHistoryData(
|
||||
HasAndroidInjector injector,
|
||||
AAPSLogger aapsLogger,
|
||||
SP sp,
|
||||
ActivePluginProvider activePlugin,
|
||||
|
@ -108,6 +111,7 @@ public class MedtronicHistoryData {
|
|||
) {
|
||||
this.allHistory = new ArrayList<>();
|
||||
|
||||
this.injector = injector;
|
||||
this.aapsLogger = aapsLogger;
|
||||
this.sp = sp;
|
||||
this.activePlugin = activePlugin;
|
||||
|
@ -533,7 +537,7 @@ public class MedtronicHistoryData {
|
|||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||
data.put("created_at", DateUtil.toISOString(date));
|
||||
data.put("eventType", event);
|
||||
CareportalEvent careportalEvent = new CareportalEvent();
|
||||
CareportalEvent careportalEvent = new CareportalEvent(injector);
|
||||
careportalEvent.date = date;
|
||||
careportalEvent.source = Source.USER;
|
||||
careportalEvent.eventType = event;
|
||||
|
@ -954,7 +958,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
case Audio:
|
||||
case Extended: {
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus(injector);
|
||||
extendedBolus.date = tryToGetByLocalTime(bolus.atechDateTime);
|
||||
extendedBolus.source = Source.PUMP;
|
||||
extendedBolus.insulin = bolusDTO.getDeliveredAmount();
|
||||
|
@ -1021,7 +1025,7 @@ public class MedtronicHistoryData {
|
|||
String operation = "editTBR";
|
||||
|
||||
if (temporaryBasalDb == null) {
|
||||
temporaryBasalDb = new TemporaryBasal();
|
||||
temporaryBasalDb = new TemporaryBasal(injector);
|
||||
temporaryBasalDb.date = tryToGetByLocalTime(treatment.atechDateTime);
|
||||
|
||||
operation = "addTBR";
|
||||
|
@ -1055,7 +1059,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
if (tempBasal == null) {
|
||||
// add
|
||||
tempBasal = new TemporaryBasal();
|
||||
tempBasal = new TemporaryBasal(injector);
|
||||
tempBasal.date = tryToGetByLocalTime(tempBasalProcess.itemOne.atechDateTime);
|
||||
|
||||
tempBasal.source = Source.PUMP;
|
||||
|
|
|
@ -283,7 +283,7 @@ class VirtualPumpPlugin @Inject constructor(
|
|||
override fun setExtendedBolus(insulin: Double, durationInMinutes: Int): PumpEnactResult {
|
||||
val result = cancelExtendedBolus()
|
||||
if (!result.success) return result
|
||||
val extendedBolus = ExtendedBolus()
|
||||
val extendedBolus = ExtendedBolus(injector)
|
||||
.date(System.currentTimeMillis())
|
||||
.insulin(insulin)
|
||||
.durationInMinutes(durationInMinutes)
|
||||
|
@ -321,7 +321,7 @@ class VirtualPumpPlugin @Inject constructor(
|
|||
override fun cancelExtendedBolus(): PumpEnactResult {
|
||||
val result = PumpEnactResult(injector)
|
||||
if (treatmentsPlugin.isInHistoryExtendedBoluslInProgress) {
|
||||
val exStop = ExtendedBolus(System.currentTimeMillis())
|
||||
val exStop = ExtendedBolus(injector, System.currentTimeMillis())
|
||||
exStop.source = Source.USER
|
||||
treatmentsPlugin.addToHistoryExtendedBolus(exStop)
|
||||
}
|
||||
|
|
|
@ -423,7 +423,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
Profile profile = profileFunction.getProfile(e.date);
|
||||
if (profile == null) continue;
|
||||
if (truncate && e.end() > truncateTime) {
|
||||
ExtendedBolus dummyExt = new ExtendedBolus();
|
||||
ExtendedBolus dummyExt = new ExtendedBolus(getInjector());
|
||||
dummyExt.copyFrom(e);
|
||||
dummyExt.cutEndTo(truncateTime);
|
||||
calc = dummyExt.iobCalc(time);
|
||||
|
@ -498,7 +498,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
Profile profile = profileFunction.getProfile(e.date);
|
||||
if (profile == null) continue;
|
||||
if (e.end() > truncateTime) {
|
||||
ExtendedBolus dummyExt = new ExtendedBolus();
|
||||
ExtendedBolus dummyExt = new ExtendedBolus(getInjector());
|
||||
dummyExt.copyFrom(e);
|
||||
dummyExt.cutEndTo(truncateTime);
|
||||
calc = dummyExt.iobCalc(time, profile, lastAutosensResult, exercise_mode, half_basal_exercise_target, isTempTarget);
|
||||
|
|
|
@ -15,6 +15,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.events.EventNsTreatment;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.BundleLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
|
@ -51,6 +52,7 @@ public class DataService extends DaggerIntentService {
|
|||
@Inject TomatoPlugin tomatoPlugin;
|
||||
@Inject XdripPlugin xdripPlugin;
|
||||
@Inject NSProfilePlugin nsProfilePlugin;
|
||||
@Inject ActivePluginProvider activePlugin;
|
||||
|
||||
public DataService() {
|
||||
super("DataService");
|
||||
|
@ -208,7 +210,7 @@ public class DataService extends DaggerIntentService {
|
|||
} else if (eventType.equals(CareportalEvent.COMBOBOLUS)) {
|
||||
MainApp.getDbHelper().createExtendedBolusFromJsonIfNotExists(json);
|
||||
} else if (eventType.equals(CareportalEvent.PROFILESWITCH)) {
|
||||
MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(json);
|
||||
MainApp.getDbHelper().createProfileSwitchFromJsonIfNotExists(activePlugin, json);
|
||||
} else if (eventType.equals(CareportalEvent.SITECHANGE) ||
|
||||
eventType.equals(CareportalEvent.INSULINCHANGE) ||
|
||||
eventType.equals(CareportalEvent.SENSORCHANGE) ||
|
||||
|
|
|
@ -4,6 +4,7 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.db.TemporaryBasal
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
|
@ -14,11 +15,15 @@ open class DanaRTestBase : TestBase() {
|
|||
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var activePluginProvider: ActivePluginProvider
|
||||
|
||||
val injector = HasAndroidInjector {
|
||||
AndroidInjector {
|
||||
if (it is TemporaryBasal) {
|
||||
it.aapsLogger = aapsLogger
|
||||
it.activePlugin = activePluginProvider
|
||||
it.profileFunction = profileFunction
|
||||
it.sp = sp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class MsgStatusBolusExtendedTest : DanaRTestBase() {
|
|||
@Test
|
||||
fun runTest() {
|
||||
`when`(activePlugin.activeTreatments).thenReturn(treatmentsPlugin)
|
||||
val packet = MsgStatusBolusExtended(aapsLogger, danaRPump, activePlugin)
|
||||
val packet = MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)
|
||||
// test message decoding
|
||||
val array = ByteArray(100)
|
||||
putByteToArray(array, 0, 1)
|
||||
|
|
|
@ -4,7 +4,6 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.db.TemporaryBasal
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.junit.Before
|
||||
|
@ -17,7 +16,10 @@ open class DanaRSTestBase : TestBaseWithProfile() {
|
|||
val injector = HasAndroidInjector {
|
||||
AndroidInjector {
|
||||
if (it is TemporaryBasal) {
|
||||
it.aapsLogger = aapsLogger
|
||||
it.activePlugin = activePluginProvider
|
||||
it.profileFunction = profileFunction
|
||||
it.sp = sp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,10 @@ class TreatmentsPluginTest : TestBaseWithProfile() {
|
|||
val injector = HasAndroidInjector {
|
||||
AndroidInjector {
|
||||
if (it is TemporaryBasal) {
|
||||
it.aapsLogger = aapsLogger
|
||||
it.activePlugin = activePluginProvider
|
||||
it.profileFunction = profileFunction
|
||||
it.sp = sp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue