Skip to content

Commit

Permalink
Merge pull request #2 from nightscout/dev
Browse files Browse the repository at this point in the history
getting latest dev updates from master dev
  • Loading branch information
teleriddler committed Feb 17, 2021
2 parents f7a6d28 + 749bc49 commit 673cb9a
Show file tree
Hide file tree
Showing 26 changed files with 842 additions and 761 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class ActionsFragment : DaggerFragment() {

private fun checkPumpCustomActions() {
val activePump = activePlugin.activePump
val customActions = activePump.customActions ?: return
val customActions = activePump.getCustomActions() ?: return
val currentContext = context ?: return
removePumpCustomActions()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
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.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.queue.commands.CustomCommand;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
Expand Down Expand Up @@ -224,11 +221,7 @@ public boolean isHandshakeInProgress() {
}

@Override
public void finishHandshaking() {
}

@Override
public void connect(String reason) {
public void connect(@NonNull String reason) {
// ruffyscripter establishes a connection as needed.
// ComboPlugin.runCommand performs on connect checks if needed, thus needs info on
// whether a connection is there.
Expand All @@ -240,7 +233,7 @@ public void connect(String reason) {
}

@Override
public void disconnect(String reason) {
public void disconnect(@NonNull String reason) {
getAapsLogger().debug(LTag.PUMP, "Disconnect called with reason: " + reason);
ruffyScripter.disconnect();
}
Expand All @@ -251,7 +244,7 @@ public void stopConnecting() {
}

@NonNull @Override
public synchronized PumpEnactResult setNewBasalProfile(Profile profile) {
public synchronized PumpEnactResult setNewBasalProfile(@NonNull Profile profile) {
if (!isInitialized()) {
// note that this should not happen anymore since the queue is present, which
// issues a READSTATE when starting to issue commands which initializes the pump
Expand Down Expand Up @@ -294,7 +287,7 @@ public synchronized PumpEnactResult setNewBasalProfile(Profile profile) {
}

@Override
public boolean isThisProfileSet(Profile profile) {
public boolean isThisProfileSet(@NonNull Profile profile) {
if (!isInitialized()) {
/* This might be called too soon during boot. Return true to prevent a request
to update the profile. KeepAlive is called every Constants.keepalivems
Expand Down Expand Up @@ -338,7 +331,7 @@ public long lastDataTime() {
* Runs pump initialization if needed and reads the pump state from the main screen.
*/
@Override
public synchronized void getPumpStatus(String reason) {
public synchronized void getPumpStatus(@NonNull String reason) {
getAapsLogger().debug(LTag.PUMP, "getPumpStatus called");
if (!pump.initialized) {
initializePump();
Expand Down Expand Up @@ -720,7 +713,7 @@ public void stopBolusDelivering() {
* the new value (and thus still has the old duration of e.g. 1 min) expires?)
*/
@NonNull @Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean force) {
public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean force) {
getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute called with a rate of " + absoluteRate + " for " + durationInMinutes + " min.");
int unroundedPercentage = Double.valueOf(absoluteRate / getBaseBasalRate() * 100).intValue();
int roundedPercentage = (int) (Math.round(absoluteRate / getBaseBasalRate() * 10) * 10);
Expand All @@ -738,7 +731,7 @@ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer duratio
* is or isn't running at the moment
*/
@NonNull @Override
public PumpEnactResult setTempBasalPercent(Integer percent, final Integer durationInMinutes, Profile profile, boolean forceNew) {
public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean forceNew) {
return setTempBasalPercent(percent, durationInMinutes);
}

Expand Down Expand Up @@ -794,7 +787,7 @@ private PumpEnactResult setTempBasalPercent(Integer percent, final Integer durat
}

@NonNull @Override
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
public PumpEnactResult setExtendedBolus(double insulin, int durationInMinutes) {
return OPERATION_NOT_SUPPORTED;
}

Expand Down Expand Up @@ -853,6 +846,10 @@ public PumpEnactResult cancelTempBasal(boolean enforceNew) {
}
}

@Override public int waitForDisconnectionInSeconds() {
return 0;
}

private interface CommandExecution {
CommandResult execute();
}
Expand Down Expand Up @@ -1388,19 +1385,6 @@ public Constraint<Double> applyMaxIOBConstraints(@NonNull Constraint<Double> max
return maxIob;
}

@Override
public List<CustomAction> getCustomActions() {
return null;
}

@Override
public void executeCustomAction(CustomActionType customActionType) {
}

@Nullable @Override public PumpEnactResult executeCustomCommand(CustomCommand customCommand) {
return null;
}

@Override
public boolean canHandleDST() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.os.Looper;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.json.JSONException;
import org.json.JSONObject;
Expand Down Expand Up @@ -54,8 +53,6 @@
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.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
Expand Down Expand Up @@ -133,7 +130,6 @@
import info.nightscout.androidaps.plugins.pump.insight.utils.ExceptionTranslator;
import info.nightscout.androidaps.plugins.pump.insight.utils.ParameterBlockUtil;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.commands.CustomCommand;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.TimeChangeType;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
Expand Down Expand Up @@ -343,11 +339,6 @@ public boolean isHandshakeInProgress() {
return false;
}

@Override
public void finishHandshaking() {

}

@Override
public void connect(String reason) {
if (connectionService != null && alertService != null)
Expand Down Expand Up @@ -709,7 +700,7 @@ public void stopBolusDelivering() {
}

@NonNull @Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult(getInjector());
if (activeBasalRate == null) return result;
if (activeBasalRate.getActiveBasalRate() == 0) return result;
Expand Down Expand Up @@ -759,7 +750,7 @@ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer duratio
}

@NonNull @Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult(getInjector());
percent = (int) Math.round(((double) percent) / 10d) * 10;
if (percent == 100) return cancelTempBasal(true);
Expand Down Expand Up @@ -798,7 +789,7 @@ public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMi
}

@NonNull @Override
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
public PumpEnactResult setExtendedBolus(double insulin, int durationInMinutes) {
PumpEnactResult result = cancelExtendedBolusOnly();
if (result.success)
result = setExtendedBolusOnly(insulin, durationInMinutes, sp.getBoolean(R.string.key_disable_vibration, false));
Expand Down Expand Up @@ -987,11 +978,11 @@ private void confirmAlert(AlertType alertType) {
}

@NonNull @Override
public JSONObject getJSONStatus(Profile profile, String profileName, String version) {
public JSONObject getJSONStatus(@NonNull Profile profile, @NonNull String profileName, @NonNull String version) {
long now = System.currentTimeMillis();
if (connectionService == null) return null;
if (connectionService == null) return new JSONObject();
if (System.currentTimeMillis() - connectionService.getLastConnected() > (60 * 60 * 1000)) {
return null;
return new JSONObject();
}

final JSONObject pump = new JSONObject();
Expand Down Expand Up @@ -1165,19 +1156,6 @@ public PumpEnactResult loadTDDs() {
return new PumpEnactResult(getInjector()).success(true);
}

@Override
public List<CustomAction> getCustomActions() {
return null;
}

@Override
public void executeCustomAction(CustomActionType customActionType) {
}

@Nullable @Override public PumpEnactResult executeCustomCommand(CustomCommand customCommand) {
return null;
}

private void readHistory() {
try {
PumpTime pumpTime = connectionService.requestMessage(new GetDateTimeMessage()).await().getPumpTime();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package info.nightscout.androidaps.plugins.pump.mdi;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Singleton;

Expand All @@ -24,11 +21,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.actions.defs.CustomAction;
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
import info.nightscout.androidaps.queue.commands.CustomCommand;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil;
Expand All @@ -50,7 +43,6 @@ public class MDIPlugin extends PumpPluginBase implements PumpInterface {
public MDIPlugin(
HasAndroidInjector injector,
AAPSLogger aapsLogger,
RxBusWrapper rxBus,
ResourceHelper resourceHelper,
CommandQueueProvider commandQueue,
TreatmentsPlugin treatmentsPlugin
Expand Down Expand Up @@ -82,8 +74,7 @@ public boolean isFakingTempsByExtendedBoluses() {
@NonNull @Override
public PumpEnactResult loadTDDs() {
//no result, could read DB in the future?
PumpEnactResult result = new PumpEnactResult(getInjector());
return result;
return new PumpEnactResult(getInjector());
}

@Override
Expand Down Expand Up @@ -117,35 +108,35 @@ public boolean isHandshakeInProgress() {
}

@Override
public void finishHandshaking() {
public void connect(@NonNull String reason) {
}

@Override
public void connect(String reason) {
public void disconnect(@NonNull String reason) {
}

@Override
public void disconnect(String reason) {
@Override public int waitForDisconnectionInSeconds() {
return 0;
}

@Override
public void stopConnecting() {
}

@Override
public void getPumpStatus(String reason) {
public void getPumpStatus(@NonNull String reason) {
}

@NonNull @Override
public PumpEnactResult setNewBasalProfile(Profile profile) {
public PumpEnactResult setNewBasalProfile(@NonNull Profile profile) {
// Do nothing here. we are using ConfigBuilderPlugin.getPlugin().getActiveProfile().getProfile();
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success = true;
return result;
}

@Override
public boolean isThisProfileSet(Profile profile) {
public boolean isThisProfileSet(@NonNull Profile profile) {
return false;
}

Expand Down Expand Up @@ -185,7 +176,7 @@ public void stopBolusDelivering() {
}

@NonNull @Override
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
public PumpEnactResult setTempBasalAbsolute(double absoluteRate, int durationInMinutes, @NonNull Profile profile, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success = false;
result.comment = getResourceHelper().gs(R.string.pumperror);
Expand All @@ -194,7 +185,7 @@ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer duratio
}

@NonNull @Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
public PumpEnactResult setTempBasalPercent(int percent, int durationInMinutes, @NonNull Profile profile, boolean enforceNew) {
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success = false;
result.comment = getResourceHelper().gs(R.string.pumperror);
Expand All @@ -203,7 +194,7 @@ public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMi
}

@NonNull @Override
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
public PumpEnactResult setExtendedBolus(double insulin, int durationInMinutes) {
PumpEnactResult result = new PumpEnactResult(getInjector());
result.success = false;
result.comment = getResourceHelper().gs(R.string.pumperror);
Expand All @@ -230,24 +221,22 @@ public PumpEnactResult cancelExtendedBolus() {
}

@NonNull @Override
public JSONObject getJSONStatus(Profile profile, String profileName, String version) {
public JSONObject getJSONStatus(@NonNull Profile profile, @NonNull String profileName, @NonNull String version) {
long now = System.currentTimeMillis();
JSONObject pump = new JSONObject();
JSONObject status = new JSONObject();
JSONObject extended = new JSONObject();
try {
status.put("status", "normal");
extended.put("Version", version);
try {
extended.put("ActiveProfile", profileName);
} catch (Exception e) {
}
extended.put("ActiveProfile", profileName);
status.put("timestamp", DateUtil.toISOString(now));

pump.put("status", status);
pump.put("extended", extended);
pump.put("clock", DateUtil.toISOString(now));
} catch (JSONException e) {
getAapsLogger().error("Exception: ", e);
}
return pump;
}
Expand Down Expand Up @@ -277,26 +266,13 @@ public String shortStatus(boolean veryShort) {
return model().getModel();
}

@Override
public List<CustomAction> getCustomActions() {
return null;
}

@Override
public void executeCustomAction(CustomActionType customActionType) {
}

@Nullable @Override public PumpEnactResult executeCustomCommand(CustomCommand customCommand) {
return null;
}

@Override
public boolean canHandleDST() {
return true;
}

@Override
public void timezoneOrDSTChanged(TimeChangeType changeType) {
public void timezoneOrDSTChanged(@NonNull TimeChangeType changeType) {

}

Expand Down
Loading

0 comments on commit 673cb9a

Please sign in to comment.