Little bit of refactoring.
This commit is contained in:
parent
f0e51c72a6
commit
7a388a5715
7 changed files with 152 additions and 152 deletions
|
@ -1,28 +1,32 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpCommon;
|
package info.nightscout.androidaps.plugins.PumpCommon;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ComboFragment;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverInterface;
|
import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 23.04.18.
|
* Created by andy on 23.04.18.
|
||||||
|
@ -30,26 +34,21 @@ import info.nightscout.androidaps.plugins.PumpCommon.driver.PumpDriverInterface;
|
||||||
|
|
||||||
public abstract class PumpPluginAbstract extends PluginBase implements PumpInterface, ConstraintsInterface {
|
public abstract class PumpPluginAbstract extends PluginBase implements PumpInterface, ConstraintsInterface {
|
||||||
|
|
||||||
// , ProfileInterface
|
private static final Logger LOG = LoggerFactory.getLogger(PumpPluginAbstract.class);
|
||||||
//protected boolean fragmentVisible = false;
|
|
||||||
//protected boolean fragmentEnabled = false;
|
|
||||||
protected boolean pumpServiceRunning = false;
|
protected boolean pumpServiceRunning = false;
|
||||||
//private static final String TAG = "PumpPluginAbstract";
|
|
||||||
//protected PumpStatus pumpStatus;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected static PumpPluginAbstract plugin = null;
|
protected static PumpPluginAbstract plugin = null;
|
||||||
protected PumpDriverInterface pumpDriver;
|
protected PumpDriverInterface pumpDriver;
|
||||||
protected PumpStatus pumpStatus;
|
protected PumpStatus pumpStatus;
|
||||||
|
protected String internalName;
|
||||||
|
|
||||||
|
|
||||||
protected PumpPluginAbstract(PumpDriverInterface pumpDriverInterface, //
|
protected PumpPluginAbstract(PumpDriverInterface pumpDriverInterface, //
|
||||||
String internalName, //
|
String internalName, //
|
||||||
String fragmentClassName, //
|
String fragmentClassName, //
|
||||||
int pluginName, //
|
int pluginName, //
|
||||||
int pluginShortName)
|
int pluginShortName) {
|
||||||
{
|
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.PUMP)
|
.mainType(PluginType.PUMP)
|
||||||
.fragmentClass(fragmentClassName)
|
.fragmentClass(fragmentClassName)
|
||||||
|
@ -59,130 +58,98 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
||||||
|
|
||||||
this.pumpDriver = pumpDriverInterface;
|
this.pumpDriver = pumpDriverInterface;
|
||||||
this.pumpStatus = this.pumpDriver.getPumpStatusData();
|
this.pumpStatus = this.pumpDriver.getPumpStatusData();
|
||||||
|
this.internalName = internalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected String getInternalName() {
|
||||||
|
return this.internalName;
|
||||||
|
}
|
||||||
// @Override
|
|
||||||
// public boolean isVisibleInTabs(int type) {
|
|
||||||
// return type == PUMP && fragmentVisible;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean canBeHidden(int type) {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean showInList(int type) {
|
|
||||||
// return type == PUMP;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void setFragmentVisible(int type, boolean fragmentVisible) {
|
|
||||||
// if (type == PUMP)
|
|
||||||
// this.fragmentVisible = fragmentVisible;
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected abstract String getInternalName();
|
|
||||||
|
|
||||||
protected abstract void startPumpService();
|
protected abstract void startPumpService();
|
||||||
|
|
||||||
protected abstract void stopPumpService();
|
protected abstract void stopPumpService();
|
||||||
|
|
||||||
|
|
||||||
public PumpStatus getPumpStatusData()
|
public PumpStatus getPumpStatusData() {
|
||||||
{
|
|
||||||
return pumpDriver.getPumpStatusData();
|
return pumpDriver.getPumpStatusData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isInitialized()
|
public boolean isInitialized() {
|
||||||
{
|
|
||||||
return pumpDriver.isInitialized();
|
return pumpDriver.isInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuspended(){
|
public boolean isSuspended() {
|
||||||
return pumpDriver.isSuspended();
|
return pumpDriver.isSuspended();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBusy(){
|
public boolean isBusy() {
|
||||||
return pumpDriver.isBusy();
|
return pumpDriver.isBusy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isConnected(){
|
public boolean isConnected() {
|
||||||
return pumpDriver.isConnected();
|
return pumpDriver.isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isConnecting(){
|
public boolean isConnecting() {
|
||||||
return pumpDriver.isConnecting();
|
return pumpDriver.isConnecting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void connect(String reason){
|
public void connect(String reason) {
|
||||||
pumpDriver.connect(reason);
|
pumpDriver.connect(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void disconnect(String reason){
|
public void disconnect(String reason) {
|
||||||
pumpDriver.disconnect(reason);
|
pumpDriver.disconnect(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void stopConnecting(){
|
public void stopConnecting() {
|
||||||
pumpDriver.stopConnecting();
|
pumpDriver.stopConnecting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void getPumpStatus(){
|
public void getPumpStatus() {
|
||||||
pumpDriver.getPumpStatus();
|
pumpDriver.getPumpStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Upload to pump new basal profile
|
// Upload to pump new basal profile
|
||||||
public PumpEnactResult setNewBasalProfile(Profile profile){
|
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
||||||
return pumpDriver.setNewBasalProfile(profile);
|
return pumpDriver.setNewBasalProfile(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isThisProfileSet(Profile profile){
|
public boolean isThisProfileSet(Profile profile) {
|
||||||
return pumpDriver.isThisProfileSet(profile);
|
return pumpDriver.isThisProfileSet(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Date lastDataTime(){
|
public Date lastDataTime() {
|
||||||
return pumpDriver.lastDataTime();
|
return pumpDriver.lastDataTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public double getBaseBasalRate(){
|
public double getBaseBasalRate() {
|
||||||
return pumpDriver.getBaseBasalRate();
|
return pumpDriver.getBaseBasalRate();
|
||||||
} // base basal rate, not temp basal
|
} // base basal rate, not temp basal
|
||||||
|
|
||||||
|
|
||||||
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo){
|
|
||||||
return pumpDriver.deliverTreatment(detailedBolusInfo);
|
return pumpDriver.deliverTreatment(detailedBolusInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void stopBolusDelivering(){
|
public void stopBolusDelivering() {
|
||||||
pumpDriver.stopBolusDelivering();
|
pumpDriver.stopBolusDelivering();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
return pumpDriver.setTempBasalAbsolute(absoluteRate, durationInMinutes, profile, enforceNew);
|
return pumpDriver.setTempBasalAbsolute(absoluteRate, durationInMinutes, profile, enforceNew);
|
||||||
|
@ -194,55 +161,59 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes){
|
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
return pumpDriver.setExtendedBolus(insulin, durationInMinutes);
|
return pumpDriver.setExtendedBolus(insulin, durationInMinutes);
|
||||||
}
|
}
|
||||||
//some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
|
//some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
|
||||||
//when the cancel request is requested by the user (forced), the pump should always do a real cancel
|
//when the cancel request is requested by the user (forced), the pump should always do a real cancel
|
||||||
|
|
||||||
|
|
||||||
public PumpEnactResult cancelTempBasal(boolean enforceNew){
|
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||||
return pumpDriver.cancelTempBasal(enforceNew);
|
return pumpDriver.cancelTempBasal(enforceNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PumpEnactResult cancelExtendedBolus(){
|
public PumpEnactResult cancelExtendedBolus() {
|
||||||
return pumpDriver.cancelExtendedBolus();
|
return pumpDriver.cancelExtendedBolus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status to be passed to NS
|
// Status to be passed to NS
|
||||||
|
|
||||||
|
|
||||||
public JSONObject getJSONStatus(Profile profile, String profileName){
|
// public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||||
return pumpDriver.getJSONStatus( profile, profileName);
|
// return pumpDriver.getJSONStatus(profile, profileName);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public String deviceID(){
|
public String deviceID() {
|
||||||
return pumpDriver.deviceID();
|
return pumpDriver.deviceID();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pump capabilities
|
// Pump capabilities
|
||||||
|
|
||||||
|
|
||||||
public PumpDescription getPumpDescription(){
|
public PumpDescription getPumpDescription() {
|
||||||
return pumpDriver.getPumpDescription();
|
return pumpDriver.getPumpDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Short info for SMS, Wear etc
|
// Short info for SMS, Wear etc
|
||||||
|
|
||||||
|
|
||||||
public String shortStatus(boolean veryShort){
|
public String shortStatus(boolean veryShort) {
|
||||||
return pumpDriver.shortStatus(veryShort);
|
return pumpDriver.shortStatus(veryShort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isFakingTempsByExtendedBoluses() {
|
||||||
public boolean isFakingTempsByExtendedBoluses(){
|
|
||||||
return pumpDriver.isInitialized();
|
return pumpDriver.isInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult loadTDDs() {
|
||||||
|
return this.pumpDriver.loadTDDs();
|
||||||
|
}
|
||||||
|
|
||||||
// Constraints interface
|
// Constraints interface
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
|
@ -300,28 +271,73 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
||||||
// return maxIob;
|
// return maxIob;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject getJSONStatus(Profile profile, String profileName) {
|
||||||
|
//if (!SP.getBoolean("virtualpump_uploadstatus", false)) {
|
||||||
|
// return null;
|
||||||
|
//}
|
||||||
|
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
if ((pumpStatus.lastConnection + 5 * 60 * 1000L) < System.currentTimeMillis()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject pump = new JSONObject();
|
||||||
|
JSONObject battery = new JSONObject();
|
||||||
|
JSONObject status = new JSONObject();
|
||||||
|
JSONObject extended = new JSONObject();
|
||||||
|
try {
|
||||||
|
battery.put("percent", pumpStatus.batteryRemaining);
|
||||||
|
status.put("status", pumpStatus.pumpStatusType != null ? pumpStatus.pumpStatusType.getStatus() : "normal");
|
||||||
|
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||||
|
try {
|
||||||
|
extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
|
if (tb != null) {
|
||||||
|
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(System.currentTimeMillis(), profile));
|
||||||
|
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
|
||||||
|
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtendedBolus eb = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
|
if (eb != null) {
|
||||||
|
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
|
||||||
|
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
|
||||||
|
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
|
||||||
|
}
|
||||||
|
|
||||||
|
status.put("timestamp", DateUtil.toISOString(new Date()));
|
||||||
|
|
||||||
|
pump.put("battery", battery);
|
||||||
|
pump.put("status", status);
|
||||||
|
pump.put("extended", extended);
|
||||||
|
pump.put("reservoir", pumpStatus.reservoirRemainingUnits);
|
||||||
|
pump.put("clock", DateUtil.toISOString(new Date()));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
LOG.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
return pump;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Profile interface
|
// Profile interface
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ProfileStore getProfile()
|
public ProfileStore getProfile() {
|
||||||
{
|
|
||||||
return this.pumpStatus.profileStore;
|
return this.pumpStatus.profileStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUnits()
|
public String getUnits() {
|
||||||
{
|
|
||||||
return this.pumpStatus.units;
|
return this.pumpStatus.units;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProfileName()
|
public String getProfileName() {
|
||||||
{
|
|
||||||
return this.pumpStatus.activeProfileName;
|
return this.pumpStatus.activeProfileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PumpEnactResult loadTDDs() {
|
|
||||||
return this.pumpDriver.loadTDDs();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpStatusType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andy on 4/28/18.
|
* Created by andy on 4/28/18.
|
||||||
|
@ -17,14 +18,16 @@ public abstract class PumpStatus {
|
||||||
public String activeProfileName = "0";
|
public String activeProfileName = "0";
|
||||||
public double reservoirRemainingUnits = 0d;
|
public double reservoirRemainingUnits = 0d;
|
||||||
public String reservoirFullUnits = "???";
|
public String reservoirFullUnits = "???";
|
||||||
public double batteryRemaining = 0d;
|
public int batteryRemaining = 0; // percent, so 0-100
|
||||||
public String iob = "0";
|
public String iob = "0";
|
||||||
protected PumpDescription pumpDescription;
|
protected PumpDescription pumpDescription;
|
||||||
public boolean validBasalRateProfileSelectedOnPump = true;
|
public boolean validBasalRateProfileSelectedOnPump = true;
|
||||||
|
|
||||||
public ProfileStore profileStore;
|
public ProfileStore profileStore;
|
||||||
public String units; // Constants.MGDL or Constants.MMOL
|
public String units; // Constants.MGDL or Constants.MMOL
|
||||||
|
public PumpStatusType pumpStatusType = PumpStatusType.Running;
|
||||||
|
|
||||||
|
// TODO maybe not needed anymore in 2.0
|
||||||
public Double constraintBasalRateAbsolute;
|
public Double constraintBasalRateAbsolute;
|
||||||
public Integer constraintBasalRatePercent;
|
public Integer constraintBasalRatePercent;
|
||||||
public Double constraintBolus;
|
public Double constraintBolus;
|
||||||
|
@ -32,10 +35,7 @@ public abstract class PumpStatus {
|
||||||
public Double constraintMaxIob;
|
public Double constraintMaxIob;
|
||||||
|
|
||||||
|
|
||||||
|
public PumpStatus(PumpDescription pumpDescription) {
|
||||||
|
|
||||||
public PumpStatus(PumpDescription pumpDescription)
|
|
||||||
{
|
|
||||||
this.pumpDescription = pumpDescription;
|
this.pumpDescription = pumpDescription;
|
||||||
|
|
||||||
this.initSettings();
|
this.initSettings();
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package info.nightscout.androidaps.plugins.PumpCommon.defs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by andy on 5/12/18.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public enum PumpStatusType {
|
||||||
|
Running("normal"), //
|
||||||
|
Suspended("suspended") //
|
||||||
|
;
|
||||||
|
|
||||||
|
private String statusString;
|
||||||
|
|
||||||
|
PumpStatusType(String statusString) {
|
||||||
|
this.statusString = statusString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return statusString;
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,7 +33,6 @@ import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
|
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||||
|
@ -81,14 +80,14 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
TextView errorsView;
|
TextView errorsView;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@BindView(R.id.medtronic_queue)
|
@BindView(R.id.medtronic_queue)
|
||||||
TextView queueView;
|
TextView queueView;
|
||||||
|
|
||||||
@BindView(R.id.overview_pumpstatuslayout)
|
@BindView(R.id.overview_pumpstatuslayout)
|
||||||
LinearLayout pumpStatusLayout;
|
LinearLayout pumpStatusLayout;
|
||||||
|
|
||||||
@BindView(R.id.overview_pumpstatus) TextView pumpStatusView;
|
@BindView(R.id.overview_pumpstatus)
|
||||||
|
TextView pumpStatusView;
|
||||||
|
|
||||||
public MedtronicFragment() {
|
public MedtronicFragment() {
|
||||||
}
|
}
|
||||||
|
@ -204,7 +203,7 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
MedtronicPumpPlugin plugin = (MedtronicPumpPlugin)MedtronicPumpPlugin.getPlugin();
|
MedtronicPumpPlugin plugin = (MedtronicPumpPlugin) MedtronicPumpPlugin.getPlugin();
|
||||||
PumpStatus pump = plugin.getPumpStatusData();
|
PumpStatus pump = plugin.getPumpStatusData();
|
||||||
|
|
||||||
if (pump.lastConnection != 0) {
|
if (pump.lastConnection != 0) {
|
||||||
|
@ -213,7 +212,7 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")");
|
lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.sResources.getString(R.string.minago), agoMin) + ")");
|
||||||
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
|
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
|
||||||
}
|
}
|
||||||
if (pump.lastBolusTime!=null && pump.lastBolusTime.getTime() != 0) {
|
if (pump.lastBolusTime != null && pump.lastBolusTime.getTime() != 0) {
|
||||||
Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime.getTime();
|
Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime.getTime();
|
||||||
double agoHours = agoMsec / 60d / 60d / 1000d;
|
double agoHours = agoMsec / 60d / 60d / 1000d;
|
||||||
if (agoHours < 6) // max 6h back
|
if (agoHours < 6) // max 6h back
|
||||||
|
@ -241,10 +240,6 @@ public class MedtronicFragment extends SubscriberFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
reservoirView.setText(DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + " / " + pump.reservoirFullUnits + " U");
|
reservoirView.setText(DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + " / " + pump.reservoirFullUnits + " U");
|
||||||
SetWarnColor.setColorInverse(reservoirView, pump.reservoirRemainingUnits, 50d, 20d);
|
SetWarnColor.setColorInverse(reservoirView, pump.reservoirRemainingUnits, 50d, 20d);
|
||||||
batteryView.setText("{fa-battery-" + (pump.batteryRemaining / 25) + "}");
|
batteryView.setText("{fa-battery-" + (pump.batteryRemaining / 25) + "}");
|
||||||
|
|
|
@ -15,7 +15,7 @@ import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.PumpPluginAbstract;
|
import info.nightscout.androidaps.plugins.PumpCommon.PumpPluginAbstract;
|
||||||
import info.nightscout.androidaps.plugins.PumpMedtronic.medtronic.MedtronicPumpDriver;
|
import info.nightscout.androidaps.plugins.PumpMedtronic.driver.MedtronicPumpDriver;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
|
@ -48,12 +48,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getInternalName() {
|
|
||||||
return "MedtronicPump";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startPumpService() {
|
protected void startPumpService() {
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpMedtronic.medtronic;
|
package info.nightscout.androidaps.plugins.PumpMedtronic.driver;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -10,8 +10,6 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpDriver;
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpDriver;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||||
|
@ -26,18 +24,17 @@ public class MedtronicPumpDriver extends VirtualPumpDriver /*implements PumpInte
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(MedtronicPumpDriver.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MedtronicPumpDriver.class);
|
||||||
MedtronicPumpStatus pumpStatusLocal;
|
MedtronicPumpStatus pumpStatusLocal;
|
||||||
|
|
||||||
public MedtronicPumpDriver()
|
public MedtronicPumpDriver() {
|
||||||
{
|
|
||||||
pumpStatusLocal = new MedtronicPumpStatus(pumpDescription);
|
pumpStatusLocal = new MedtronicPumpStatus(pumpDescription);
|
||||||
pumpStatusLocal.verifyConfiguration();
|
pumpStatusLocal.verifyConfiguration();
|
||||||
|
|
||||||
this.pumpStatusData = pumpStatusLocal;
|
this.pumpStatusData = pumpStatusLocal;
|
||||||
|
|
||||||
if (pumpStatusLocal.pumpType!=null)
|
if (pumpStatusLocal.pumpType != null)
|
||||||
PumpUtil.setPumpDescription(pumpDescription, pumpStatusLocal.pumpType);
|
PumpUtil.setPumpDescription(pumpDescription, pumpStatusLocal.pumpType);
|
||||||
|
|
||||||
if (pumpStatusLocal.maxBasal!=null)
|
if (pumpStatusLocal.maxBasal != null)
|
||||||
pumpDescription.maxTempAbsolute = (pumpStatusLocal.maxBasal!=null) ? pumpStatusLocal.maxBasal : 35.0d;
|
pumpDescription.maxTempAbsolute = (pumpStatusLocal.maxBasal != null) ? pumpStatusLocal.maxBasal : 35.0d;
|
||||||
|
|
||||||
// needs to be changed in configuration, after all functionalities are done
|
// needs to be changed in configuration, after all functionalities are done
|
||||||
pumpDescription.isBolusCapable = true;
|
pumpDescription.isBolusCapable = true;
|
||||||
|
@ -71,8 +68,7 @@ public class MedtronicPumpDriver extends VirtualPumpDriver /*implements PumpInte
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean enforceNew)
|
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||||
{
|
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
// send Cancel Temp Basal
|
// send Cancel Temp Basal
|
||||||
|
@ -104,10 +100,4 @@ public class MedtronicPumpDriver extends VirtualPumpDriver /*implements PumpInte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpMedtronic.medtronic;
|
package info.nightscout.androidaps.plugins.PumpMedtronic.driver;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -11,7 +11,6 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.PumpCommon.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpMedtronic.medtronic.defs.MedtronicPumpType;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,14 +23,6 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
//private static MedtronicPumpStatus medtronicPumpStatus = new MedtronicPumpStatus();
|
//private static MedtronicPumpStatus medtronicPumpStatus = new MedtronicPumpStatus();
|
||||||
private static Logger LOG = LoggerFactory.getLogger(MedtronicPumpStatus.class);
|
private static Logger LOG = LoggerFactory.getLogger(MedtronicPumpStatus.class);
|
||||||
|
|
||||||
//public Date lastDataTime;
|
|
||||||
//public long lastConnection = 0L;
|
|
||||||
//public Date lastBolusTime;
|
|
||||||
//public String activeProfileName = "A";
|
|
||||||
//public double reservoirRemainingUnits = 50d;
|
|
||||||
//public double batteryRemaining = 75d;
|
|
||||||
//public String iob = "0";
|
|
||||||
|
|
||||||
public String errorDescription = null;
|
public String errorDescription = null;
|
||||||
public String serialNumber;
|
public String serialNumber;
|
||||||
public PumpType pumpType = null;
|
public PumpType pumpType = null;
|
||||||
|
@ -45,11 +36,10 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
String regexMac = "([\\da-fA-F]{1,2}(?:\\:|$)){6}";
|
||||||
String regexSN = "[0-9]{6}";
|
String regexSN = "[0-9]{6}";
|
||||||
|
|
||||||
private Map<String,PumpType> medtronicPumpMap = null;
|
private Map<String, PumpType> medtronicPumpMap = null;
|
||||||
|
|
||||||
|
|
||||||
public MedtronicPumpStatus(PumpDescription pumpDescription)
|
public MedtronicPumpStatus(PumpDescription pumpDescription) {
|
||||||
{
|
|
||||||
super(pumpDescription);
|
super(pumpDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,9 +49,9 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
|
|
||||||
this.activeProfileName = "STD";
|
this.activeProfileName = "STD";
|
||||||
this.reservoirRemainingUnits = 75d;
|
this.reservoirRemainingUnits = 75d;
|
||||||
this.batteryRemaining = 75d;
|
this.batteryRemaining = 75;
|
||||||
|
|
||||||
if (this.medtronicPumpMap==null)
|
if (this.medtronicPumpMap == null)
|
||||||
createMedtronicPumpMap();
|
createMedtronicPumpMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,11 +76,10 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void verifyConfiguration()
|
public void verifyConfiguration() {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (this.medtronicPumpMap==null)
|
if (this.medtronicPumpMap == null)
|
||||||
createMedtronicPumpMap();
|
createMedtronicPumpMap();
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,8 +163,7 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
|
|
||||||
maxBolus = Integer.parseInt(value);
|
maxBolus = Integer.parseInt(value);
|
||||||
|
|
||||||
if (maxBolus> 25)
|
if (maxBolus > 25) {
|
||||||
{
|
|
||||||
SP.putString("pref_medtronic_max_bolus", "25");
|
SP.putString("pref_medtronic_max_bolus", "25");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,25 +171,21 @@ public class MedtronicPumpStatus extends PumpStatus {
|
||||||
|
|
||||||
maxBasal = Integer.parseInt(value);
|
maxBasal = Integer.parseInt(value);
|
||||||
|
|
||||||
if (maxBasal> 35)
|
if (maxBasal > 35) {
|
||||||
{
|
|
||||||
SP.putString("pref_medtronic_max_basal", "35");
|
SP.putString("pref_medtronic_max_basal", "35");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
this.errorDescription = ex.getMessage();
|
this.errorDescription = ex.getMessage();
|
||||||
LOG.error("Error on Verification: " + ex.getMessage(), ex);
|
LOG.error("Error on Verification: " + ex.getMessage(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getErrorInfo()
|
public String getErrorInfo() {
|
||||||
{
|
|
||||||
verifyConfiguration();
|
verifyConfiguration();
|
||||||
|
|
||||||
return (this.errorDescription==null) ? "-" : this.errorDescription;
|
return (this.errorDescription == null) ? "-" : this.errorDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue