- changes from omnipod tree
- changed PumpInterface for TimeDateOrTZChangeReceiver changes, and changes on all the pumps (method name and parameters) - some RL changes - added something to profile
This commit is contained in:
parent
3bb3c39db3
commit
973403e944
|
@ -129,7 +129,7 @@ android {
|
|||
targetSdkVersion 28
|
||||
multiDexEnabled true
|
||||
versionCode 1500
|
||||
version "2.6.5-mdt-dev"
|
||||
version "2.6.5-dev"
|
||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
|
||||
|
|
|
@ -186,7 +186,6 @@ public class MainApp extends DaggerApplication {
|
|||
|
||||
filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
filter.addAction(Intent.ACTION_DATE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||
registerReceiver(new TimeDateOrTZChangeReceiver(), filter);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
|||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.MidnightTime;
|
||||
import info.nightscout.androidaps.utils.Round;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
|
||||
public class Profile {
|
||||
|
@ -496,6 +497,18 @@ public class Profile {
|
|||
|
||||
public int timeAsSeconds;
|
||||
public double value;
|
||||
|
||||
|
||||
public boolean equals(Object otherObject) {
|
||||
if (!(otherObject instanceof ProfileValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ProfileValue otherProfileValue = (ProfileValue) otherObject;
|
||||
|
||||
return (timeAsSeconds == otherProfileValue.timeAsSeconds) && Round.isSame(value, otherProfileValue.value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized ProfileValue[] getBasalValues() {
|
||||
|
@ -818,4 +831,26 @@ public class Profile {
|
|||
}
|
||||
return new Profile(injector, o);
|
||||
}
|
||||
|
||||
|
||||
public boolean areProfileBasalPatternsSame(Profile otherProfile) {
|
||||
|
||||
if (!Round.isSame(this.baseBasalSum(), otherProfile.baseBasalSum()))
|
||||
return false;
|
||||
|
||||
ProfileValue[] basalValues = this.getBasalValues();
|
||||
ProfileValue[] otherBasalValues = otherProfile.getBasalValues();
|
||||
|
||||
if (basalValues.length != otherBasalValues.length)
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < basalValues.length; i++) {
|
||||
if (!basalValues[i].equals(otherBasalValues[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public class PumpDescription {
|
|||
public boolean supportsTDDs;
|
||||
public boolean needsManualTDDLoad;
|
||||
|
||||
public boolean hasFixedUnreachableAlert;
|
||||
public boolean hasCustomUnreachableAlertCheck;
|
||||
|
||||
public void resetSettings() {
|
||||
isBolusCapable = true;
|
||||
|
@ -87,6 +89,9 @@ public class PumpDescription {
|
|||
|
||||
supportsTDDs = false;
|
||||
needsManualTDDLoad = true;
|
||||
|
||||
hasFixedUnreachableAlert = false;
|
||||
hasCustomUnreachableAlertCheck = false;
|
||||
}
|
||||
|
||||
public void setPumpDescription(PumpType pumpType) {
|
||||
|
@ -134,6 +139,9 @@ public class PumpDescription {
|
|||
needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad);
|
||||
|
||||
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min);
|
||||
|
||||
hasFixedUnreachableAlert = pumpType.getHasFixedUnreachableAlert();
|
||||
hasCustomUnreachableAlertCheck = pumpType.getHasCustomUnreachableAlertCheck();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
|||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
|
||||
/**
|
||||
* Created by mike on 04.06.2016.
|
||||
|
@ -115,5 +116,10 @@ public interface PumpInterface {
|
|||
* This method will be called when time or Timezone changes, and pump driver can then do a specific action (for
|
||||
* example update clock on pump).
|
||||
*/
|
||||
void timeDateOrTimeZoneChanged();
|
||||
void timezoneOrDSTChanged(TimeChangeType timeChangeType);
|
||||
|
||||
/* Only used for pump types where hasCustomUnreachableAlertCheck=true */
|
||||
default boolean isUnreachableAlertTimeoutExceeded(long alertTimeoutMilliseconds) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ import info.nightscout.androidaps.plugins.treatments.Treatment;
|
|||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.InstanceId;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
|
@ -1404,9 +1405,8 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
}
|
||||
|
||||
@Override
|
||||
public void timeDateOrTimeZoneChanged() {
|
||||
|
||||
public void timezoneOrDSTChanged(TimeChangeType changeType) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.ServiceConnection;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
@ -20,6 +21,7 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
|||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventAppExit;
|
||||
import info.nightscout.androidaps.events.EventCustomActionsChanged;
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider;
|
||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
|
@ -30,6 +32,7 @@ import info.nightscout.androidaps.interfaces.PumpPluginBase;
|
|||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||
|
@ -40,6 +43,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
|||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
|
@ -57,6 +61,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
|||
protected ActivePluginProvider activePlugin;
|
||||
protected Context context;
|
||||
protected FabricPrivacy fabricPrivacy;
|
||||
protected SP sp;
|
||||
|
||||
/*
|
||||
protected static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult().success(false)
|
||||
|
@ -71,6 +76,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
|||
// protected boolean isInitialized = false;
|
||||
protected PumpDriverState pumpState = PumpDriverState.NotInitialized;
|
||||
protected boolean displayConnectionMessages = false;
|
||||
protected PumpType pumpType;
|
||||
|
||||
|
||||
protected PumpPluginAbstract(
|
||||
|
@ -82,6 +88,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
|||
CommandQueueProvider commandQueue,
|
||||
RxBusWrapper rxBus,
|
||||
ActivePluginProvider activePlugin,
|
||||
SP sp,
|
||||
Context context,
|
||||
FabricPrivacy fabricPrivacy
|
||||
) {
|
||||
|
@ -92,8 +99,10 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
|||
this.activePlugin = activePlugin;
|
||||
this.context = context;
|
||||
this.fabricPrivacy = fabricPrivacy;
|
||||
this.sp = sp;
|
||||
|
||||
pumpDescription.setPumpDescription(pumpType);
|
||||
this.pumpType = pumpType;
|
||||
|
||||
}
|
||||
|
||||
|
@ -435,6 +444,37 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
|
|||
|
||||
}
|
||||
|
||||
|
||||
protected void refreshCustomActionsList() {
|
||||
rxBus.send(new EventCustomActionsChanged());
|
||||
}
|
||||
|
||||
|
||||
public ManufacturerType manufacturer() {
|
||||
return pumpType.getManufacturer() ;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PumpType model() {
|
||||
return pumpType;
|
||||
}
|
||||
|
||||
|
||||
public PumpType getPumpType() {
|
||||
return pumpType;
|
||||
}
|
||||
|
||||
|
||||
public void setPumpType(PumpType pumpType) {
|
||||
this.pumpType = pumpType;
|
||||
}
|
||||
|
||||
|
||||
public boolean canHandleDST() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protected abstract PumpEnactResult deliverBolus(DetailedBolusInfo detailedBolusInfo);
|
||||
|
||||
protected abstract void triggerUIChange();
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.joda.time.LocalDateTime;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
||||
|
@ -19,7 +19,9 @@ public abstract class PumpStatus {
|
|||
public LocalDateTime lastDataTime;
|
||||
public long lastConnection = 0L;
|
||||
public long previousConnection = 0L; // here should be stored last connection of previous session (so needs to be
|
||||
// read before lastConnection is modified for first time).
|
||||
// read before lastConnection is modified for first time).
|
||||
|
||||
public long lastErrorConnection = 0L;
|
||||
|
||||
// last bolus
|
||||
public Date lastBolusTime;
|
||||
|
@ -27,10 +29,10 @@ public abstract class PumpStatus {
|
|||
|
||||
// other pump settings
|
||||
public String activeProfileName = "0";
|
||||
public double reservoirRemainingUnits = 0d;
|
||||
public double reservoirRemainingUnits = 0.0d;
|
||||
public int reservoirFullUnits = 0;
|
||||
public int batteryRemaining = 0; // percent, so 0-100
|
||||
public Double batteryVoltage = null;
|
||||
public Double batteryVoltage = null;
|
||||
|
||||
|
||||
// iob
|
||||
|
@ -68,6 +70,10 @@ public abstract class PumpStatus {
|
|||
this.lastConnection = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void setLastFailedCommunicationToNow() {
|
||||
this.lastErrorConnection = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
public abstract String getErrorInfo();
|
||||
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.data;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class TempBasalPair {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
||||
@Expose
|
||||
protected double insulinRate = 0.0d;
|
||||
@Expose
|
||||
protected int durationMinutes = 0;
|
||||
@Expose
|
||||
protected boolean isPercent = false;
|
||||
|
||||
private Long start;
|
||||
private Long end;
|
||||
|
||||
public TempBasalPair() {
|
||||
}
|
||||
|
||||
|
||||
public TempBasalPair(double insulinRate, boolean isPercent, int durationMinutes) {
|
||||
this.insulinRate = insulinRate;
|
||||
this.isPercent = isPercent;
|
||||
this.durationMinutes = durationMinutes;
|
||||
}
|
||||
|
||||
|
||||
public double getInsulinRate() {
|
||||
return insulinRate;
|
||||
}
|
||||
|
||||
|
||||
public void setInsulinRate(double insulinRate) {
|
||||
this.insulinRate = insulinRate;
|
||||
}
|
||||
|
||||
|
||||
public int getDurationMinutes() {
|
||||
return durationMinutes;
|
||||
}
|
||||
|
||||
|
||||
public void setDurationMinutes(int durationMinutes) {
|
||||
this.durationMinutes = durationMinutes;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPercent() {
|
||||
return isPercent;
|
||||
}
|
||||
|
||||
|
||||
public void setIsPercent(boolean yesIsPercent) {
|
||||
this.isPercent = yesIsPercent;
|
||||
}
|
||||
|
||||
public void setStartTime(Long startTime) {
|
||||
this.start = startTime;
|
||||
}
|
||||
|
||||
|
||||
public void setEndTime(Long endTime) {
|
||||
this.end = endTime;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TempBasalPair [" + "Rate=" + insulinRate + ", DurationMinutes=" + durationMinutes + ", IsPercent="
|
||||
+ isPercent + "]";
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ public enum PumpCapability {
|
|||
DanaWithHistoryCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill, StoreCarbInfo, TDD, ManualTDDLoad), //
|
||||
InsightCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill,TDD,BasalRate30min), //
|
||||
MedtronicCapabilities(Bolus, TempBasal, BasalProfileSet, Refill, TDD), //
|
||||
OmnipodCapabilities(Bolus, TempBasal, BasalProfileSet, BasalRate30min), //
|
||||
|
||||
// BasalRates (separately grouped)
|
||||
BasalRate_Duration15minAllowed, //
|
||||
|
@ -69,4 +70,4 @@ public enum PumpCapability {
|
|||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
||||
package info.nightscout.androidaps.plugins.pump.common.defs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -9,7 +9,7 @@ import info.nightscout.androidaps.R;
|
|||
/**
|
||||
* This file was taken from GGC - GNU Gluco Control (ggc.sourceforge.net), application for diabetes
|
||||
* management and modified/extended for AAPS.
|
||||
*
|
||||
* <p>
|
||||
* Author: Andy {andy.rozman@gmail.com}
|
||||
*/
|
||||
|
|
@ -57,7 +57,14 @@ public enum PumpType {
|
|||
new DoseSettings(0.01d, 15, 24 * 60, 0.05d), //
|
||||
PumpTempBasalType.Percent,
|
||||
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.02d, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities), //
|
||||
0.02d, null, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities, false, false), //
|
||||
|
||||
AccuChekSolo("Accu-Chek Solo", ManufacturerType.Roche, "Solo", 0.01d, null, //
|
||||
new DoseSettings(0.01d, 15, 24 * 60, 0.05d), //
|
||||
PumpTempBasalType.Percent,
|
||||
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.02d, null, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities, false, false), //
|
||||
|
||||
|
||||
// Animas
|
||||
AnimasVibe("Animas Vibe", ManufacturerType.Animas, "Vibe", 0.05d, null, // AnimasBolus?
|
||||
|
@ -91,11 +98,17 @@ public enum PumpType {
|
|||
|
||||
|
||||
// Insulet
|
||||
Insulet_Omnipod("Insulet Omnipod", ManufacturerType.Insulet, "Omnipod", 0.05d, null, //
|
||||
Insulet_Omnipod("Insulet Omnipod", ManufacturerType.Insulet, "Omnipod (Eros)", 0.05d, null, //
|
||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||
PumpTempBasalType.Absolute, //
|
||||
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
|
||||
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true, true),
|
||||
|
||||
Insulet_Omnipod_Dash("Insulet Omnipod Dash", ManufacturerType.Insulet, "Omnipod Dash", 0.05d, null, //
|
||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||
PumpTempBasalType.Absolute, //
|
||||
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.05d, null, 0.05d, null, PumpCapability.OmnipodCapabilities, true, true), // TODO just copied OmniPod for now
|
||||
|
||||
// Medtronic
|
||||
Medtronic_512_712("Medtronic 512/712", ManufacturerType.Medtronic, "512/712", 0.1d, null, //
|
||||
|
@ -150,6 +163,8 @@ public enum PumpType {
|
|||
private double baseBasalStep; //
|
||||
private DoseStepSize baseBasalSpecialSteps; //
|
||||
private PumpCapability pumpCapability;
|
||||
private boolean hasFixedUnreachableAlert;
|
||||
private boolean hasCustomUnreachableAlertCheck;
|
||||
|
||||
private PumpType parent;
|
||||
private static Map<String, PumpType> mapByDescription;
|
||||
|
@ -184,17 +199,58 @@ public enum PumpType {
|
|||
parent.model = model;
|
||||
}
|
||||
|
||||
PumpType(String description, ManufacturerType manufacturer, String model, double bolusSize, DoseStepSize specialBolusSize, //
|
||||
PumpType(String description,
|
||||
ManufacturerType manufacturer,
|
||||
String model,
|
||||
double bolusSize,
|
||||
DoseStepSize specialBolusSize, //
|
||||
DoseSettings extendedBolusSettings, //
|
||||
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
||||
double baseBasalMinValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) {
|
||||
PumpTempBasalType pumpTempBasalType,
|
||||
DoseSettings tbrSettings,
|
||||
PumpCapability specialBasalDurations, //
|
||||
double baseBasalMinValue,
|
||||
double baseBasalStep,
|
||||
DoseStepSize baseBasalSpecialSteps,
|
||||
PumpCapability pumpCapability) {
|
||||
this(description, manufacturer, model, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability);
|
||||
}
|
||||
|
||||
PumpType(String description, ManufacturerType manufacturer, String model, double bolusSize, DoseStepSize specialBolusSize, //
|
||||
PumpType(String description,
|
||||
ManufacturerType manufacturer,
|
||||
String model,
|
||||
double bolusSize,
|
||||
DoseStepSize specialBolusSize, //
|
||||
DoseSettings extendedBolusSettings, //
|
||||
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
||||
double baseBasalMinValue, Double baseBasalMaxValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) {
|
||||
PumpTempBasalType pumpTempBasalType,
|
||||
DoseSettings tbrSettings,
|
||||
PumpCapability specialBasalDurations, //
|
||||
double baseBasalMinValue,
|
||||
Double baseBasalMaxValue,
|
||||
double baseBasalStep,
|
||||
DoseStepSize baseBasalSpecialSteps,
|
||||
PumpCapability pumpCapability) {
|
||||
this(description, manufacturer, model, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType,
|
||||
tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep,
|
||||
baseBasalSpecialSteps, pumpCapability, false, false);
|
||||
}
|
||||
|
||||
|
||||
PumpType(String description,
|
||||
ManufacturerType manufacturer,
|
||||
String model,
|
||||
double bolusSize,
|
||||
DoseStepSize specialBolusSize, //
|
||||
DoseSettings extendedBolusSettings, //
|
||||
PumpTempBasalType pumpTempBasalType,
|
||||
DoseSettings tbrSettings,
|
||||
PumpCapability specialBasalDurations, //
|
||||
double baseBasalMinValue,
|
||||
Double baseBasalMaxValue,
|
||||
double baseBasalStep,
|
||||
DoseStepSize baseBasalSpecialSteps, //
|
||||
PumpCapability pumpCapability,
|
||||
boolean hasFixedUnreachableAlert,
|
||||
boolean hasCustomUnreachableAlertCheck) {
|
||||
this.description = description;
|
||||
this.manufacturer = manufacturer;
|
||||
this.model = model;
|
||||
|
@ -209,9 +265,19 @@ public enum PumpType {
|
|||
this.baseBasalStep = baseBasalStep;
|
||||
this.baseBasalSpecialSteps = baseBasalSpecialSteps;
|
||||
this.pumpCapability = pumpCapability;
|
||||
this.hasFixedUnreachableAlert = hasFixedUnreachableAlert;
|
||||
this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck;
|
||||
}
|
||||
|
||||
|
||||
public boolean getHasFixedUnreachableAlert() {
|
||||
return hasFixedUnreachableAlert;
|
||||
}
|
||||
|
||||
public boolean getHasCustomUnreachableAlertCheck() {
|
||||
return hasFixedUnreachableAlert;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||
|
@ -39,7 +37,6 @@ public abstract class RileyLinkCommunicationManager {
|
|||
private static final int ALLOWED_PUMP_UNREACHABLE = 10 * 60 * 1000; // 10 minutes
|
||||
|
||||
protected final RFSpy rfspy;
|
||||
protected final Context context;
|
||||
protected int receiverDeviceAwakeForMinutes = 1; // override this in constructor of specific implementation
|
||||
protected String receiverDeviceID; // String representation of receiver device (ex. Pump (xxxxxx) or Pod (yyyyyy))
|
||||
protected long lastGoodReceiverCommunicationTime = 0;
|
||||
|
@ -52,8 +49,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
private int timeoutCount = 0;
|
||||
|
||||
|
||||
public RileyLinkCommunicationManager(Context context, RFSpy rfspy) {
|
||||
this.context = context;
|
||||
public RileyLinkCommunicationManager(RFSpy rfspy) {
|
||||
this.rfspy = rfspy;
|
||||
this.rileyLinkServiceData = RileyLinkUtil.getRileyLinkServiceData();
|
||||
RileyLinkUtil.setRileyLinkCommunicationManager(this);
|
||||
|
@ -66,7 +62,23 @@ public abstract class RileyLinkCommunicationManager {
|
|||
|
||||
|
||||
// All pump communications go through this function.
|
||||
protected <E extends RLMessage> E sendAndListen(RLMessage msg, int timeout_ms, Class<E> clazz)
|
||||
public <E extends RLMessage> E sendAndListen(RLMessage msg, int timeout_ms, Class<E> clazz)
|
||||
throws RileyLinkCommunicationException {
|
||||
return sendAndListen(msg, timeout_ms, null, clazz);
|
||||
}
|
||||
|
||||
public <E extends RLMessage> E sendAndListen(RLMessage msg, int timeout_ms, Integer extendPreamble_ms, Class<E> clazz)
|
||||
throws RileyLinkCommunicationException {
|
||||
return sendAndListen(msg, timeout_ms, 0, extendPreamble_ms, clazz);
|
||||
}
|
||||
|
||||
// For backward compatibility
|
||||
public <E extends RLMessage> E sendAndListen(RLMessage msg, int timeout_ms, int repeatCount, Integer extendPreamble_ms, Class<E> clazz)
|
||||
throws RileyLinkCommunicationException {
|
||||
return sendAndListen(msg, timeout_ms, repeatCount, 0, extendPreamble_ms, clazz);
|
||||
}
|
||||
|
||||
public <E extends RLMessage> E sendAndListen(RLMessage msg, int timeout_ms, int repeatCount, int retryCount, Integer extendPreamble_ms, Class<E> clazz)
|
||||
throws RileyLinkCommunicationException {
|
||||
|
||||
if (showPumpMessages) {
|
||||
|
@ -74,11 +86,11 @@ public abstract class RileyLinkCommunicationManager {
|
|||
LOG.info("Sent:" + ByteUtil.shortHexString(msg.getTxData()));
|
||||
}
|
||||
|
||||
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(msg.getTxData()), timeout_ms);
|
||||
RFSpyResponse rfSpyResponse = rfspy.transmitThenReceive(new RadioPacket(msg.getTxData()),
|
||||
(byte)0, (byte)repeatCount, (byte)0, (byte)0, timeout_ms, (byte)retryCount, extendPreamble_ms);
|
||||
|
||||
RadioResponse radioResponse = rfSpyResponse.getRadioResponse();
|
||||
|
||||
E response = createResponseMessage(rfSpyResponse.getRadioResponse().getPayload(), clazz);
|
||||
E response = createResponseMessage(radioResponse.getPayload(), clazz);
|
||||
|
||||
if (response.isValid()) {
|
||||
// Mark this as the last time we heard from the pump.
|
||||
|
@ -88,14 +100,16 @@ public abstract class RileyLinkCommunicationManager {
|
|||
rfSpyResponse.wasTimeout(), rfSpyResponse.isUnknownCommand(), rfSpyResponse.isInvalidParam());
|
||||
|
||||
if (rfSpyResponse.wasTimeout()) {
|
||||
timeoutCount++;
|
||||
if (hasTunning()) {
|
||||
timeoutCount++;
|
||||
|
||||
long diff = System.currentTimeMillis() - pumpStatus.lastConnection;
|
||||
long diff = System.currentTimeMillis() - pumpStatus.lastConnection;
|
||||
|
||||
if (diff > ALLOWED_PUMP_UNREACHABLE) {
|
||||
LOG.warn("We reached max time that Pump can be unreachable. Starting Tuning.");
|
||||
ServiceTaskExecutor.startTask(new WakeAndTuneTask());
|
||||
timeoutCount = 0;
|
||||
if (diff > ALLOWED_PUMP_UNREACHABLE) {
|
||||
LOG.warn("We reached max time that Pump can be unreachable. Starting Tuning.");
|
||||
ServiceTaskExecutor.startTask(new WakeAndTuneTask());
|
||||
timeoutCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
throw new RileyLinkCommunicationException(RileyLinkBLEError.Timeout);
|
||||
|
@ -125,6 +139,9 @@ public abstract class RileyLinkCommunicationManager {
|
|||
return rfspy != null ? rfspy.notConnectedCount : 0;
|
||||
}
|
||||
|
||||
public boolean hasTunning() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// FIXME change wakeup
|
||||
|
@ -405,7 +422,9 @@ public abstract class RileyLinkCommunicationManager {
|
|||
lastGoodReceiverCommunicationTime = System.currentTimeMillis();
|
||||
|
||||
SP.putLong(RileyLinkConst.Prefs.LastGoodDeviceCommunicationTime, lastGoodReceiverCommunicationTime);
|
||||
pumpStatus.setLastCommunicationToNow();
|
||||
if(pumpStatus != null) {
|
||||
pumpStatus.setLastCommunicationToNow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -437,4 +456,7 @@ public abstract class RileyLinkCommunicationManager {
|
|||
return L.isEnabled(L.PUMPCOMM);
|
||||
}
|
||||
|
||||
public void setPumpStatus(PumpStatus pumpStatus) {
|
||||
this.pumpStatus = pumpStatus;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
|||
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ThreadUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -116,6 +117,12 @@ public class RFSpy {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isRileyLinkStillAvailable() {
|
||||
RileyLinkFirmwareVersion firmwareVersion = getFirmwareVersion();
|
||||
|
||||
return (firmwareVersion!= RileyLinkFirmwareVersion.UnknownVersion);
|
||||
}
|
||||
|
||||
|
||||
public RileyLinkFirmwareVersion getFirmwareVersion() {
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class RFSpyReader {
|
|||
LOG.trace(ThreadUtil.sig() + "Entering poll at t==" + SystemClock.uptimeMillis() + ", timeout is " + timeout_ms
|
||||
+ " mDataQueue size is " + mDataQueue.size());
|
||||
|
||||
if (mDataQueue.isEmpty())
|
||||
if (mDataQueue.isEmpty()) {
|
||||
try {
|
||||
// block until timeout or data available.
|
||||
// returns null if timeout.
|
||||
|
@ -72,7 +72,7 @@ public class RFSpyReader {
|
|||
if (dataFromQueue != null) {
|
||||
if (isLogEnabled())
|
||||
LOG.debug("Got data [" + ByteUtil.shortHexString(dataFromQueue) + "] at t=="
|
||||
+ SystemClock.uptimeMillis());
|
||||
+ SystemClock.uptimeMillis());
|
||||
} else {
|
||||
if (isLogEnabled())
|
||||
LOG.debug("Got data [null] at t==" + SystemClock.uptimeMillis());
|
||||
|
@ -81,6 +81,8 @@ public class RFSpyReader {
|
|||
} catch (InterruptedException e) {
|
||||
LOG.error("poll: Interrupted waiting for data");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,4 +27,7 @@ public class RileyLinkCommunicationException extends Exception {
|
|||
// this.extendedErrorText = extendedErrorText;
|
||||
}
|
||||
|
||||
public RileyLinkBLEError getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,8 @@ public class RLHistoryItem {
|
|||
public enum RLHistoryItemSource {
|
||||
RileyLink("RileyLink"), //
|
||||
MedtronicPump("Medtronic"), //
|
||||
MedtronicCommand("Medtronic");
|
||||
MedtronicCommand("Medtronic"), //
|
||||
OmnipodCommand("Omnipod");
|
||||
|
||||
private String desc;
|
||||
|
||||
|
@ -112,4 +113,12 @@ public class RLHistoryItem {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Comparator implements java.util.Comparator<RLHistoryItem> {
|
||||
|
||||
@Override
|
||||
public int compare(RLHistoryItem o1, RLHistoryItem o2) {
|
||||
return o2.dateTime.compareTo(o1.dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
@ -12,12 +13,15 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
|
||||
/**
|
||||
* Created by andy on 5/19/18.
|
||||
|
@ -83,6 +87,8 @@ public class RileyLinkStatusHistory extends Fragment implements RefreshableInter
|
|||
public void addItemsAndClean(List<RLHistoryItem> items) {
|
||||
this.historyList.clear();
|
||||
|
||||
Collections.sort(items, new RLHistoryItem.Comparator());
|
||||
|
||||
for (RLHistoryItem item : items) {
|
||||
|
||||
if (!historyList.contains(item) && isValidItem(item)) {
|
||||
|
@ -110,6 +116,7 @@ public class RileyLinkStatusHistory extends Fragment implements RefreshableInter
|
|||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public RecyclerViewAdapter.HistoryViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.rileylink_status_history_item, //
|
||||
|
@ -123,7 +130,7 @@ public class RileyLinkStatusHistory extends Fragment implements RefreshableInter
|
|||
RLHistoryItem item = historyList.get(position);
|
||||
|
||||
if (item != null) {
|
||||
holder.timeView.setText(StringUtil.toDateTimeString(item.getDateTime()));
|
||||
holder.timeView.setText(DateUtil.dateAndTimeAndSecondsString(item.getDateTime().toDateTime().getMillis()));
|
||||
holder.typeView.setText(item.getSource().getDesc());
|
||||
holder.valueView.setText(item.getDescription());
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
//LOG.debug("onCreate");
|
||||
|
||||
RileyLinkUtil.setContext(this.context);
|
||||
RileyLinkUtil.setRileyLinkService(this);
|
||||
|
@ -61,8 +60,6 @@ public abstract class RileyLinkService extends DaggerService {
|
|||
|
||||
bluetoothStateReceiver = new RileyLinkBluetoothStateReceiver();
|
||||
bluetoothStateReceiver.registerBroadcasts(this);
|
||||
|
||||
//LOG.debug("onCreate(): It's ALIVE!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.utils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -28,6 +29,14 @@ public class ByteUtil {
|
|||
return (b < 0) ? b + 256 : b;
|
||||
}
|
||||
|
||||
public static byte[] getBytesFromInt16(int value) {
|
||||
byte[] array = getBytesFromInt(value);
|
||||
return new byte[] {array[2], array[3]};
|
||||
}
|
||||
|
||||
public static byte[] getBytesFromInt(int value) {
|
||||
return ByteBuffer.allocate(4).putInt(value).array();
|
||||
}
|
||||
|
||||
/* For Reference: static void System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length) */
|
||||
|
||||
|
@ -107,6 +116,21 @@ public class ByteUtil {
|
|||
return rval;
|
||||
}
|
||||
|
||||
public static String shortHexStringWithoutSpaces(byte[] byteArray) {
|
||||
String hexString = "";
|
||||
if (byteArray == null) {
|
||||
return hexString;
|
||||
}
|
||||
if (byteArray.length == 0) {
|
||||
return hexString;
|
||||
}
|
||||
for (byte b : byteArray) {
|
||||
hexString = hexString + HEX_DIGITS[(b & 0xF0) >> 4];
|
||||
hexString = hexString + HEX_DIGITS[(b & 0x0F)];
|
||||
}
|
||||
return hexString;
|
||||
}
|
||||
|
||||
public static String shortHexString(List<Byte> list) {
|
||||
|
||||
byte[] abyte0 = getByteArrayFromList(list);
|
||||
|
|
|
@ -120,6 +120,14 @@ public class DateTimeUtil {
|
|||
}
|
||||
|
||||
|
||||
public static long toATechDate(long timeInMillis) {
|
||||
GregorianCalendar gc = new GregorianCalendar();
|
||||
gc.setTimeInMillis(timeInMillis);
|
||||
|
||||
return toATechDate(gc);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isSameDay(LocalDateTime ldt1, LocalDateTime ldt2) {
|
||||
|
||||
return (ldt1.getYear() == ldt2.getYear() && //
|
||||
|
@ -276,4 +284,21 @@ public class DateTimeUtil {
|
|||
}
|
||||
|
||||
|
||||
public static long getTimeInFutureFromMinutes(long startTime, int minutes) {
|
||||
return startTime + getTimeInMs(minutes);
|
||||
}
|
||||
|
||||
public static long getTimeInFutureFromMinutes(int minutes) {
|
||||
return System.currentTimeMillis() + getTimeInMs(minutes);
|
||||
}
|
||||
|
||||
|
||||
public static long getTimeInMs(int minutes) {
|
||||
return getTimeInS(minutes) * 1000L;
|
||||
}
|
||||
|
||||
public static int getTimeInS(int minutes) {
|
||||
return minutes * 60;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.utils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
|
||||
public class ProfileUtil {
|
||||
|
||||
|
||||
public static String getProfileDisplayable(Profile profile, PumpType pumpType) {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for (Profile.ProfileValue basalValue : profile.getBasalValues()) {
|
||||
|
||||
double basalValueValue = pumpType.determineCorrectBasalSize(basalValue.value);
|
||||
|
||||
int hour = basalValue.timeAsSeconds / (60 * 60);
|
||||
|
||||
stringBuilder.append((hour < 10 ? "0" : "") + hour + ":00");
|
||||
|
||||
stringBuilder.append(String.format(Locale.ENGLISH, "%.3f", basalValueValue));
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
if (stringBuilder.length() > 3)
|
||||
return stringBuilder.toString().substring(0, stringBuilder.length() - 2);
|
||||
else
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public static String getBasalProfilesDisplayable(Profile.ProfileValue[] profiles, PumpType pumpType) {
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for (Profile.ProfileValue basalValue : profiles) {
|
||||
|
||||
double basalValueValue = pumpType.determineCorrectBasalSize(basalValue.value);
|
||||
|
||||
int hour = basalValue.timeAsSeconds / (60 * 60);
|
||||
|
||||
stringBuilder.append((hour < 10 ? "0" : "") + hour + ":00");
|
||||
|
||||
stringBuilder.append(String.format(Locale.ENGLISH, "%.3f", basalValueValue));
|
||||
stringBuilder.append(", ");
|
||||
}
|
||||
if (stringBuilder.length() > 3)
|
||||
return stringBuilder.toString().substring(0, stringBuilder.length() - 2);
|
||||
else
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@ import java.text.DecimalFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
|
||||
/**
|
||||
* Created by geoff on 4/28/15.
|
||||
* modified by Andy
|
||||
|
@ -83,7 +85,8 @@ public class StringUtil {
|
|||
|
||||
|
||||
public static String toDateTimeString(LocalDateTime localDateTime) {
|
||||
return localDateTime.toString("dd.MM.yyyy HH:mm:ss");
|
||||
return DateUtil.dateAndTimeAndSecondsString(localDateTime.toDateTime().getMillis());
|
||||
//return localDateTime.toString("dd.MM.yyyy HH:mm:ss");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
|||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.Round;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
|
@ -485,8 +486,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
|||
}
|
||||
|
||||
@Override
|
||||
public void timeDateOrTimeZoneChanged() {
|
||||
|
||||
public void timezoneOrDSTChanged(TimeChangeType timeChangeType) {
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter;
|
|||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.Round;
|
||||
import info.nightscout.androidaps.utils.T;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
@ -826,8 +827,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR
|
|||
}
|
||||
|
||||
@Override
|
||||
public void timeDateOrTimeZoneChanged() {
|
||||
|
||||
public void timezoneOrDSTChanged(TimeChangeType changeType) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -135,6 +135,7 @@ import info.nightscout.androidaps.plugins.pump.insight.utils.ParameterBlockUtil;
|
|||
import info.nightscout.androidaps.plugins.treatments.Treatment;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
|
@ -1684,8 +1685,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void timeDateOrTimeZoneChanged() {
|
||||
|
||||
public void timezoneOrDSTChanged(TimeChangeType changeType) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
|||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.InstanceId;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
|
||||
|
||||
|
@ -289,7 +290,7 @@ public class MDIPlugin extends PumpPluginBase implements PumpInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void timeDateOrTimeZoneChanged() {
|
||||
public void timezoneOrDSTChanged(TimeChangeType changeType) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtro
|
|||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.TimeChangeType;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
||||
|
@ -94,8 +95,6 @@ import static info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUt
|
|||
@Singleton
|
||||
public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInterface {
|
||||
|
||||
private final SP sp;
|
||||
|
||||
protected static MedtronicPumpPlugin plugin = null;
|
||||
private RileyLinkMedtronicService medtronicService;
|
||||
private MedtronicPumpStatus pumpStatusLocal = null;
|
||||
|
@ -135,7 +134,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
.shortName(R.string.medtronic_name_short) //
|
||||
.preferencesId(R.xml.pref_medtronic).description(R.string.description_pump_medtronic), //
|
||||
PumpType.Medtronic_522_722, // we default to most basic model, correct model from config is loaded later
|
||||
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, context, fabricPrivacy
|
||||
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy
|
||||
);
|
||||
this.plugin = this;
|
||||
|
||||
|
@ -1569,17 +1568,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
}
|
||||
|
||||
@Override
|
||||
public void timeDateOrTimeZoneChanged() {
|
||||
public void timezoneOrDSTChanged(TimeChangeType changeType) {
|
||||
|
||||
aapsLogger.warn(LTag.PUMP, getLogPrefix() + "Time, Date and/or TimeZone changed. ");
|
||||
aapsLogger.warn(LTag.PUMP, getLogPrefix() + "Time or TimeZone changed. ");
|
||||
|
||||
this.hasTimeDateOrTimeZoneChanged = true;
|
||||
}
|
||||
|
||||
private void refreshCustomActionsList() {
|
||||
rxBus.send(new EventCustomActionsChanged());
|
||||
}
|
||||
|
||||
|
||||
public void setEnableCustomAction(MedtronicCustomActionType customAction, boolean isEnabled) {
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.comm;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import org.joda.time.LocalDateTime;
|
||||
|
@ -72,8 +71,8 @@ public class MedtronicCommunicationManager extends RileyLinkCommunicationManager
|
|||
private boolean doWakeUpBeforeCommand = true;
|
||||
|
||||
|
||||
public MedtronicCommunicationManager(Context context, RFSpy rfspy) {
|
||||
super(context, rfspy);
|
||||
public MedtronicCommunicationManager(RFSpy rfspy) {
|
||||
super(rfspy);
|
||||
medtronicCommunicationManager = this;
|
||||
this.medtronicConverter = new MedtronicConverter();
|
||||
this.pumpHistoryDecoder = new MedtronicPumpHistoryDecoder();
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.data.dto;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -19,18 +17,10 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
|||
* <p>
|
||||
* Just need a class to keep the pair together, for parcel transport.
|
||||
*/
|
||||
public class TempBasalPair {
|
||||
public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair {
|
||||
|
||||
private static final Logger LOG = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM);
|
||||
|
||||
@Expose
|
||||
private double insulinRate = 0.0d;
|
||||
@Expose
|
||||
private int durationMinutes = 0;
|
||||
@Expose
|
||||
private boolean isPercent = false;
|
||||
|
||||
|
||||
public TempBasalPair() {
|
||||
}
|
||||
|
||||
|
@ -43,6 +33,8 @@ public class TempBasalPair {
|
|||
* @param isPercent
|
||||
*/
|
||||
public TempBasalPair(byte rateByte, int startTimeByte, boolean isPercent) {
|
||||
super();
|
||||
|
||||
int rateInt = ByteUtil.asUINT8(rateByte);
|
||||
|
||||
if (isPercent)
|
||||
|
@ -54,13 +46,6 @@ public class TempBasalPair {
|
|||
}
|
||||
|
||||
|
||||
public TempBasalPair(double insulinRate, boolean isPercent, int durationMinutes) {
|
||||
this.insulinRate = insulinRate;
|
||||
this.isPercent = isPercent;
|
||||
this.durationMinutes = durationMinutes;
|
||||
}
|
||||
|
||||
|
||||
public TempBasalPair(byte[] response) {
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
|
@ -87,33 +72,8 @@ public class TempBasalPair {
|
|||
}
|
||||
|
||||
|
||||
public double getInsulinRate() {
|
||||
return insulinRate;
|
||||
}
|
||||
|
||||
|
||||
public void setInsulinRate(double insulinRate) {
|
||||
this.insulinRate = insulinRate;
|
||||
}
|
||||
|
||||
|
||||
public int getDurationMinutes() {
|
||||
return durationMinutes;
|
||||
}
|
||||
|
||||
|
||||
public void setDurationMinutes(int durationMinutes) {
|
||||
this.durationMinutes = durationMinutes;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPercent() {
|
||||
return isPercent;
|
||||
}
|
||||
|
||||
|
||||
public void setIsPercent(boolean yesIsPercent) {
|
||||
this.isPercent = yesIsPercent;
|
||||
public TempBasalPair(double insulinRate, boolean isPercent, int durationMinutes) {
|
||||
super(insulinRate, isPercent, durationMinutes);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,9 +20,10 @@ import javax.inject.Inject;
|
|||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntryGroup;
|
||||
|
||||
|
||||
public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
|
|||
RileyLinkUtil.setRileyLinkBLE(rileyLinkBLE);
|
||||
|
||||
// init rileyLinkCommunicationManager
|
||||
medtronicCommunicationManager = new MedtronicCommunicationManager(context, rfspy);
|
||||
medtronicCommunicationManager = new MedtronicCommunicationManager(rfspy);
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "RileyLinkMedtronicService newly constructed");
|
||||
MedtronicUtil.setMedtronicService(this);
|
||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
|||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.InstanceId.instanceId
|
||||
import info.nightscout.androidaps.utils.TimeChangeType
|
||||
import info.nightscout.androidaps.utils.extensions.plusAssign
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
|
@ -409,5 +410,6 @@ class VirtualPumpPlugin @Inject constructor(
|
|||
pumpType = pumpTypeNew
|
||||
}
|
||||
|
||||
override fun timeDateOrTimeZoneChanged() {}
|
||||
}
|
||||
override fun timezoneOrDSTChanged(timeChangeType: TimeChangeType?) {}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,25 +2,74 @@ package info.nightscout.androidaps.receivers
|
|||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.google.gson.Gson
|
||||
import dagger.android.DaggerBroadcastReceiver
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.utils.TimeChangeType
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class TimeDateOrTZChangeReceiver : DaggerBroadcastReceiver() {
|
||||
@Inject lateinit var aapsLogger: AAPSLogger
|
||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||
var gson: Gson
|
||||
|
||||
private var isDST = false
|
||||
|
||||
init {
|
||||
isDST = calculateDST()
|
||||
gson = Gson()
|
||||
}
|
||||
|
||||
private fun calculateDST(): Boolean {
|
||||
val timeZone = TimeZone.getDefault()
|
||||
val nowDate = Date()
|
||||
return if (timeZone.useDaylightTime()) {
|
||||
timeZone.inDaylightTime(nowDate)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
super.onReceive(context, intent)
|
||||
val action = intent.action
|
||||
val activePump: PumpInterface = activePlugin.activePump
|
||||
aapsLogger.debug(LTag.PUMP, "Date, Time and/or TimeZone changed.")
|
||||
if (action != null) {
|
||||
aapsLogger.debug(LTag.PUMP, "Date, Time and/or TimeZone changed. Notifying pump driver.")
|
||||
activePump.timeDateOrTimeZoneChanged()
|
||||
if (activePump == null) {
|
||||
aapsLogger.debug(LTag.PUMP,"TimeDateOrTZChangeReceiver::Time and/or TimeZone changed. [action={}]. Pump is null, exiting.", action)
|
||||
return
|
||||
}
|
||||
|
||||
aapsLogger.debug(LTag.PUMP,"TimeDateOrTZChangeReceiver::Date, Time and/or TimeZone changed. [action={}]", action)
|
||||
aapsLogger.debug(LTag.PUMP,"TimeDateOrTZChangeReceiver::Intent::{}", gson.toJson(intent))
|
||||
|
||||
if (action == null) {
|
||||
aapsLogger.error(LTag.PUMP,"TimeDateOrTZChangeReceiver::Action is null. Exiting.")
|
||||
} else if (Intent.ACTION_TIMEZONE_CHANGED == action) {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChange)
|
||||
} else if (Intent.ACTION_TIME_CHANGED == action) {
|
||||
val currentDst = calculateDST()
|
||||
if (currentDst == isDST) {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.ManualTimeChange)
|
||||
} else {
|
||||
if (currentDst) {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Started)
|
||||
} else {
|
||||
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::DST ended. Notifying pump driver.")
|
||||
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Ended)
|
||||
}
|
||||
}
|
||||
isDST = currentDst
|
||||
} else {
|
||||
aapsLogger.error(LTag.PUMP,"TimeDateOrTZChangeReceiver::Unknown action received [name={}]. Exiting.", action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,16 +19,25 @@ public class Round {
|
|||
|
||||
return newCalc;
|
||||
}
|
||||
|
||||
public static Double floorTo(Double x, Double step) {
|
||||
if (x != 0d) {
|
||||
return Math.floor(x / step) * step;
|
||||
}
|
||||
return 0d;
|
||||
}
|
||||
|
||||
public static Double ceilTo(Double x, Double step) {
|
||||
if (x != 0d) {
|
||||
return Math.ceil(x / step) * step;
|
||||
}
|
||||
return 0d;
|
||||
}
|
||||
|
||||
public static boolean isSame(Double d1, Double d2) {
|
||||
double diff = d1 - d2;
|
||||
|
||||
return (Math.abs(diff) <= 0.000001);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package info.nightscout.androidaps.utils;
|
||||
|
||||
public enum TimeChangeType {
|
||||
TimezoneChange,
|
||||
DST_Started,
|
||||
DST_Ended,
|
||||
ManualTimeChange
|
||||
}
|
|
@ -1557,7 +1557,7 @@
|
|||
<string name="rileylink_scanner_scanning">Scanning</string>
|
||||
<string name="rileylink_scanner_scanning_finished">Scanning finished</string>
|
||||
<string name="rileylink_scanner_scanning_error">Scanning error: %1$d</string>
|
||||
|
||||
<string name="common_never">Never</string>
|
||||
|
||||
<!-- RL Status Page -->
|
||||
<string name="rileylink_settings_tab1">Settings</string>
|
||||
|
@ -1710,6 +1710,7 @@
|
|||
<string name="objectives_button_unstart">Clear started</string>
|
||||
<string name="timedetection">Time detection</string>
|
||||
<string name="doyouwantresetstart">Do you want reset objective start? You may lose your progress.</string>
|
||||
<string name="time_or_timezone_change">Time and/or Timezone change on pump</string>
|
||||
<string name="nopumpselected">No pump selected</string>
|
||||
<string name="setupwizard_units_prompt">Select units you want to display values in</string>
|
||||
<string name="key_ns_uploadlocalprofile" translatable="false">ns_uploadlocalprofile</string>
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump;
|
|||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue