Merge pull request #176 from AdrianLxM/pumpstatus2

Pumpstatus 2
This commit is contained in:
Milos Kozak 2017-02-13 08:27:16 +01:00 committed by GitHub
commit a1529b3438
7 changed files with 37 additions and 10 deletions

View file

@ -53,4 +53,6 @@ public interface PumpInterface {
String deviceID(); String deviceID();
PumpDescription getPumpDescription(); PumpDescription getPumpDescription();
public String shortStatus(boolean veryShort);
} }

View file

@ -688,6 +688,15 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
} }
@Override
public String shortStatus(boolean veryShort) {
if (activePump != null) {
return activePump.shortStatus(veryShort);
} else {
return "No Pump active!";
}
}
/** /**
* Constraints interface * Constraints interface
**/ **/

View file

@ -839,7 +839,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
} }
// Reply for sms communicator // Reply for sms communicator
public String shortStatus() { public String shortStatus(boolean veryShort) {
String ret = ""; String ret = "";
if (getDanaRPump().lastConnection.getTime() != 0) { if (getDanaRPump().lastConnection.getTime() != 0) {
Long agoMsec = new Date().getTime() - getDanaRPump().lastConnection.getTime(); Long agoMsec = new Date().getTime() - getDanaRPump().lastConnection.getTime();
@ -855,6 +855,9 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (isExtendedBoluslInProgress()) { if (isExtendedBoluslInProgress()) {
ret += "Extended: " + getExtendedBolus().toString() + "\n"; ret += "Extended: " + getExtendedBolus().toString() + "\n";
} }
if (!veryShort){
ret += "TDD: " + DecimalFormatter.to0Decimal(getDanaRPump().dailyTotalUnits) + " / " + getDanaRPump().maxDailyTotalUnits + " U\n";
}
ret += "IOB: " + getDanaRPump().iob + "U\n"; ret += "IOB: " + getDanaRPump().iob + "U\n";
ret += "Reserv: " + DecimalFormatter.to0Decimal(getDanaRPump().reservoirRemainingUnits) + "U\n"; ret += "Reserv: " + DecimalFormatter.to0Decimal(getDanaRPump().reservoirRemainingUnits) + "U\n";
ret += "Batt: " + getDanaRPump().batteryRemaining + "\n"; ret += "Batt: " + getDanaRPump().batteryRemaining + "\n";

View file

@ -839,7 +839,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
} }
// Reply for sms communicator // Reply for sms communicator
public String shortStatus() { public String shortStatus(boolean veryShort) {
String ret = ""; String ret = "";
if (getDanaRPump().lastConnection.getTime() != 0) { if (getDanaRPump().lastConnection.getTime() != 0) {
Long agoMsec = new Date().getTime() - getDanaRPump().lastConnection.getTime(); Long agoMsec = new Date().getTime() - getDanaRPump().lastConnection.getTime();
@ -855,6 +855,9 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
if (isExtendedBoluslInProgress()) { if (isExtendedBoluslInProgress()) {
ret += "Extended: " + getExtendedBolus().toString() + "\n"; ret += "Extended: " + getExtendedBolus().toString() + "\n";
} }
if (!veryShort){
ret += "TDD: " + DecimalFormatter.to0Decimal(getDanaRPump().dailyTotalUnits) + " / " + getDanaRPump().maxDailyTotalUnits + " U\n";
}
ret += "IOB: " + getDanaRPump().iob + "U\n"; ret += "IOB: " + getDanaRPump().iob + "U\n";
ret += "Reserv: " + DecimalFormatter.to0Decimal(getDanaRPump().reservoirRemainingUnits) + "U\n"; ret += "Reserv: " + DecimalFormatter.to0Decimal(getDanaRPump().reservoirRemainingUnits) + "U\n";
ret += "Batt: " + getDanaRPump().batteryRemaining + "\n"; ret += "Batt: " + getDanaRPump().batteryRemaining + "\n";

View file

@ -282,4 +282,9 @@ public class MDIPlugin implements PluginBase, PumpInterface {
return pumpDescription; return pumpDescription;
} }
@Override
public String shortStatus(boolean veryShort) {
return deviceID();
}
} }

View file

@ -307,12 +307,12 @@ public class SmsCommunicatorPlugin implements PluginBase {
case "DANAR": case "DANAR":
DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class); DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
if (danaRPlugin != null && danaRPlugin.isEnabled(PluginBase.PUMP)) { if (danaRPlugin != null && danaRPlugin.isEnabled(PluginBase.PUMP)) {
reply = danaRPlugin.shortStatus(); reply = danaRPlugin.shortStatus(true);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} }
DanaRKoreanPlugin danaRKoreanPlugin = (DanaRKoreanPlugin) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class); DanaRKoreanPlugin danaRKoreanPlugin = (DanaRKoreanPlugin) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
if (danaRKoreanPlugin != null && danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) { if (danaRKoreanPlugin != null && danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) {
reply = danaRKoreanPlugin.shortStatus(); reply = danaRKoreanPlugin.shortStatus(true);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} }
receivedSms.processed = true; receivedSms.processed = true;
@ -396,12 +396,12 @@ public class SmsCommunicatorPlugin implements PluginBase {
PumpEnactResult result = pumpInterface.deliverTreatment(bolusWaitingForConfirmation.bolusRequested, 0, null); PumpEnactResult result = pumpInterface.deliverTreatment(bolusWaitingForConfirmation.bolusRequested, 0, null);
if (result.success) { if (result.success) {
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusdelivered), result.bolusDelivered); reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusdelivered), result.bolusDelivered);
if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true);
lastRemoteBolusTime = new Date(); lastRemoteBolusTime = new Date();
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else { } else {
reply = MainApp.sResources.getString(R.string.smscommunicator_bolusfailed); reply = MainApp.sResources.getString(R.string.smscommunicator_bolusfailed);
if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} }
} }
@ -414,11 +414,11 @@ public class SmsCommunicatorPlugin implements PluginBase {
PumpEnactResult result = pumpInterface.setTempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30); PumpEnactResult result = pumpInterface.setTempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30);
if (result.success) { if (result.success) {
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration); reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else { } else {
reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalfailed); reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalfailed);
if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} }
} }
@ -431,11 +431,11 @@ public class SmsCommunicatorPlugin implements PluginBase {
PumpEnactResult result = pumpInterface.cancelTempBasal(); PumpEnactResult result = pumpInterface.cancelTempBasal();
if (result.success) { if (result.success) {
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled)); reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled));
if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else { } else {
reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed); reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed);
if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
} }
} }

View file

@ -440,4 +440,9 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
return pumpDescription; return pumpDescription;
} }
@Override
public String shortStatus(boolean veryShort) {
return "Virtual Pump";
}
} }