diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java
index 701b226031..86e33d618d 100644
--- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java
+++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java
@@ -27,6 +27,8 @@ public class PumpDescription {
public double tempAbsoluteStep = 0.05d;
public int tempDurationStep = 60;
+ public boolean tempDurationStep15mAllowed = false;
+ public boolean tempDurationStep30mAllowed = false;
public int tempMaxDuration = 12 * 60;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java
index 1232625da9..b1456c97b8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java
@@ -49,6 +49,7 @@ import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.CommandQueue;
import info.nightscout.utils.NSUpload;
import info.nightscout.utils.SP;
+import info.nightscout.utils.ToastUtils;
/**
* Created by mike on 05.08.2016.
@@ -814,4 +815,40 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
}
return null;
}
+
+ public void disconnectPump(int durationInMinutes) {
+ getActiveLoop().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
+ getCommandQueue().tempBasalPercent(0, durationInMinutes, true, new Callback() {
+ @Override
+ public void run() {
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ if (getActivePump().getPumpDescription().isExtendedBolusCapable && isInHistoryExtendedBoluslInProgress()) {
+ getCommandQueue().cancelExtended(new Callback() {
+ @Override
+ public void run() {
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.extendedbolusdeliveryerror));
+ }
+ }
+ });
+ }
+ NSUpload.uploadOpenAPSOffline(durationInMinutes);
+ }
+
+ public void suspendLoop(int durationInMinutes) {
+ getActiveLoop().suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000);
+ getCommandQueue().cancelTempBasal(true, new Callback() {
+ @Override
+ public void run() {
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(durationInMinutes);
+ }
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
index 6332acedf0..773482c20e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java
@@ -383,7 +383,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h));
menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h));
menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h));
- if (pumpDescription.tempDurationStep <= 30)
+ if (pumpDescription.tempDurationStep15mAllowed)
+ menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor15m));
+ if (pumpDescription.tempDurationStep30mAllowed)
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h));
menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h));
@@ -438,7 +440,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
activeloop.setFragmentVisible(PluginBase.LOOP, false);
MainApp.getConfigBuilder().storeSettings();
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
+ MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
@Override
public void run() {
if (!result.success) {
@@ -446,7 +448,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
}
});
- NSUpload.uploadOpenAPSOffline(60); // upload 60 min, we don;t know real duration
+ NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.enableloop))) {
activeloop.setFragmentEnabled(PluginBase.LOOP, true);
@@ -458,7 +460,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
activeloop.suspendTo(0L);
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
+ MainApp.getConfigBuilder().getCommandQueue().cancelTempBasal(true, new Callback() {
@Override
public void run() {
if (!result.success) {
@@ -469,148 +471,40 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
NSUpload.uploadOpenAPSOffline(0);
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 60L * 60 * 1000);
+ MainApp.getConfigBuilder().suspendLoop(60);
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(60);
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
+ MainApp.getConfigBuilder().suspendLoop(120);
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(120);
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
+ MainApp.getConfigBuilder().suspendLoop(180);
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(180);
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 10 * 60L * 60 * 1000);
+ MainApp.getConfigBuilder().suspendLoop(600);
+ updateGUI("suspendmenu");
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor15m))) {
+ MainApp.getConfigBuilder().disconnectPump(15);
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(600);
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
- activeloop.disconnectTo(System.currentTimeMillis() + 30L * 60 * 1000);
+ MainApp.getConfigBuilder().disconnectPump(30);
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 30, true, new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- if (MainApp.getConfigBuilder().getActivePump().getPumpDescription().isExtendedBolusCapable && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
- ConfigBuilderPlugin.getCommandQueue().cancelExtended( new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.extendedbolusdeliveryerror));
- }
- }
- });
- }
- NSUpload.uploadOpenAPSOffline(30);
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
- activeloop.disconnectTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
+ MainApp.getConfigBuilder().disconnectPump(60);
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 60, true, new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- if (MainApp.getConfigBuilder().getActivePump().getPumpDescription().isExtendedBolusCapable && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
- ConfigBuilderPlugin.getCommandQueue().cancelExtended( new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.extendedbolusdeliveryerror));
- }
- }
- });
- }
- NSUpload.uploadOpenAPSOffline(60);
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
- activeloop.disconnectTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
+ MainApp.getConfigBuilder().disconnectPump(120);
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 2 * 60, true, new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- if (MainApp.getConfigBuilder().getActivePump().getPumpDescription().isExtendedBolusCapable && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
- ConfigBuilderPlugin.getCommandQueue().cancelExtended( new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.extendedbolusdeliveryerror));
- }
- }
- });
- }
- NSUpload.uploadOpenAPSOffline(120);
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
- activeloop.disconnectTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
+ MainApp.getConfigBuilder().disconnectPump(180);
updateGUI("suspendmenu");
- ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 3 * 60, true, new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- if (MainApp.getConfigBuilder().getActivePump().getPumpDescription().isExtendedBolusCapable && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
- ConfigBuilderPlugin.getCommandQueue().cancelExtended( new Callback() {
- @Override
- public void run() {
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.extendedbolusdeliveryerror));
- }
- }
- });
- }
- NSUpload.uploadOpenAPSOffline(180);
return true;
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.careportal_profileswitch))) {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
@@ -1288,7 +1182,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// **** Various treatment buttons ****
if (carbsButton != null) {
if (SP.getBoolean(R.string.key_show_carbs_button, true)
- && !ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo ||
+ && !ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo ||
(pump.isInitialized() && !pump.isSuspended())) {
carbsButton.setVisibility(View.VISIBLE);
} else {
@@ -1297,7 +1191,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
if (pump.isInitialized() && !pump.isSuspended()) {
- if (treatmentButton != null){
+ if (treatmentButton != null) {
if (SP.getBoolean(R.string.key_show_treatment_button, false)) {
treatmentButton.setVisibility(View.VISIBLE);
} else {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java
index 943d4ee502..2e6c02458e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MessageBase.java
@@ -23,7 +23,7 @@ import info.nightscout.utils.CRC;
public class MessageBase {
private static Logger log = LoggerFactory.getLogger(MessageBase.class);
- private byte[] buffer = new byte[512];
+ protected byte[] buffer = new byte[512];
private int position = 6;
public boolean received = false;
@@ -34,6 +34,10 @@ public class MessageBase {
this.buffer[5] = (byte) (cmd & 0xFF);
}
+ public void resetBuffer() {
+ position = 6;
+ }
+
public void AddParamByte(byte data) {
this.buffer[this.position++] = data;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java
index d853c9abf1..4727e2650f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/AbstractDanaRExecutionService.java
@@ -78,6 +78,8 @@ public abstract class AbstractDanaRExecutionService extends Service {
public abstract boolean highTempBasal(int percent); // Rv2 only
+ public abstract boolean tempBasalShortDuration(int percent, int durationInMinutes); // Rv2 only
+
public abstract boolean tempBasal(int percent, int durationInHours);
public abstract boolean tempBasalStop();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
index 63215464a8..4bf080f3fb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java
@@ -354,6 +354,11 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
return false;
}
+ @Override
+ public boolean tempBasalShortDuration(int percent, int durationInMinutes) {
+ return false;
+ }
+
public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
index 6d1ccc132d..12d7590a59 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java
@@ -301,6 +301,11 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
return false;
}
+ @Override
+ public boolean tempBasalShortDuration(int percent, int durationInMinutes) {
+ return false;
+ }
+
public boolean updateBasalsInPump(final Profile profile) {
if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.updatingbasalrates)));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
index 2ef65d4337..20e17af20e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java
@@ -181,6 +181,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
pumpDescription.tempPercentStep = 10;
pumpDescription.tempDurationStep = 60;
+ pumpDescription.tempDurationStep15mAllowed = true;
+ pumpDescription.tempDurationStep30mAllowed = true;
pumpDescription.tempMaxDuration = 24 * 60;
@@ -367,7 +369,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
@Override
public boolean isInitialized() {
- return pump.lastConnection > 0 && pump.maxBasal > 0;
+ return pump.lastConnection > 0 && pump.maxBasal > 0;
}
@Override
@@ -618,8 +620,13 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
log.debug("setTempBasalPercent: Correct value already set");
return result;
}
- int durationInHours = Math.max(durationInMinutes / 60, 1);
- boolean connectionOK = danaRSService.tempBasal(percent, durationInHours);
+ boolean connectionOK;
+ if (durationInMinutes == 15 || durationInMinutes == 30) {
+ connectionOK = danaRSService.tempBasalShortDuration(percent, durationInMinutes);
+ } else {
+ int durationInHours = Math.max(durationInMinutes / 60, 1);
+ connectionOK = danaRSService.tempBasal(percent, durationInHours);
+ }
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true;
result.success = true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java
index 06608b5a74..5da3655ceb 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java
@@ -10,33 +10,60 @@ import info.nightscout.androidaps.Config;
public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet {
private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_APS_Basal_Set_Temporary_Basal.class);
- private int temporaryBasalRatio;
- private int temporaryBasalDuration;
+ int temporaryBasalRatio;
+ int temporaryBasalDuration;
public int error;
- public DanaRS_Packet_APS_Basal_Set_Temporary_Basal() {
+ final int PARAM30MIN = 160;
+ final int PARAM15MIN = 150;
+
+ DanaRS_Packet_APS_Basal_Set_Temporary_Basal() {
super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__APS_SET_TEMPORARY_BASAL;
}
public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent) {
this();
+ setParams(percent);
+ }
+ protected void setParams(int percent) {
//HARDCODED LIMITS
if (percent < 0) percent = 0;
if (percent > 500) percent = 500;
temporaryBasalRatio = percent;
if (percent < 100) {
- temporaryBasalDuration = 160;
+ temporaryBasalDuration = PARAM30MIN;
if (Config.logDanaMessageDetail)
log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
} else {
- temporaryBasalDuration = 150;
+ temporaryBasalDuration = PARAM15MIN;
if (Config.logDanaMessageDetail)
log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
}
+ }
+ public DanaRS_Packet_APS_Basal_Set_Temporary_Basal(int percent, boolean fifteenMinutes, boolean thirtyMinutes ) {
+ this();
+ setParams(percent, fifteenMinutes, thirtyMinutes);
+ }
+
+ protected void setParams(int percent, boolean fifteenMinutes, boolean thirtyMinutes) {
+ //HARDCODED LIMITS
+ if (percent < 0) percent = 0;
+ if (percent > 500) percent = 500;
+
+ temporaryBasalRatio = percent;
+ if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200%
+ temporaryBasalDuration = PARAM30MIN;
+ if (Config.logDanaMessageDetail)
+ log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
+ } else {
+ temporaryBasalDuration = PARAM15MIN;
+ if (Config.logDanaMessageDetail)
+ log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
+ }
}
@Override
@@ -55,6 +82,7 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet {
failed = true;
log.error("Set APS temp basal start result: " + result + " FAILED!!!");
} else {
+ failed = false;
if (Config.logDanaMessageDetail)
log.debug("Set APS temp basal start result: " + result);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
index b35704f176..489864ebd1 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java
@@ -318,6 +318,25 @@ public class DanaRSService extends Service {
return true;
}
+ public boolean tempBasalShortDuration(Integer percent, int durationInMinutes) {
+ if (durationInMinutes != 15 && durationInMinutes != 30) {
+ log.error("Wrong duration param");
+ return false;
+ }
+
+ if (danaRPump.isTempBasalInProgress) {
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
+ bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal());
+ SystemClock.sleep(500);
+ }
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
+ bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(percent, durationInMinutes == 15, durationInMinutes == 30));
+ bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State());
+ loadEvents();
+ MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
+ return true;
+ }
+
public boolean tempBasalStop() {
if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
index 4fbf45cd44..817df68855 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java
@@ -63,6 +63,8 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
pumpDescription.tempPercentStep = 10;
pumpDescription.tempDurationStep = 60;
+ pumpDescription.tempDurationStep15mAllowed = true;
+ pumpDescription.tempDurationStep30mAllowed = true;
pumpDescription.tempMaxDuration = 24 * 60;
@@ -275,7 +277,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
}
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
- TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
+ TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
result.enacted = false;
result.success = true;
@@ -289,8 +291,13 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
log.debug("setTempBasalPercent: Correct value already set");
return result;
}
- int durationInHours = Math.max(durationInMinutes / 60, 1);
- boolean connectionOK = sExecutionService.tempBasal(percent, durationInHours);
+ boolean connectionOK;
+ if (durationInMinutes == 15 || durationInMinutes == 30) {
+ connectionOK = sExecutionService.tempBasalShortDuration(percent, durationInMinutes);
+ } else {
+ int durationInHours = Math.max(durationInMinutes / 60, 1);
+ connectionOK = sExecutionService.tempBasal(percent, durationInHours);
+ }
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true;
result.success = true;
@@ -336,7 +343,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
@Override
public PumpEnactResult cancelTempBasal(boolean force) {
PumpEnactResult result = new PumpEnactResult();
- TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
+ TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null) {
sExecutionService.tempBasalStop();
result.enacted = true;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java
index da4db61362..6b6e3045de 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgSetAPSTempBasalStart_v2.java
@@ -9,28 +9,55 @@ import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
public class MsgSetAPSTempBasalStart_v2 extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetAPSTempBasalStart_v2.class);
+ protected final int PARAM30MIN = 160;
+ protected final int PARAM15MIN = 150;
+
public MsgSetAPSTempBasalStart_v2() {
SetCommand(0xE002);
}
public MsgSetAPSTempBasalStart_v2(int percent) {
this();
+ setParams(percent);
+ }
+ protected void setParams(int percent) {
//HARDCODED LIMITS
if (percent < 0) percent = 0;
if (percent > 500) percent = 500;
AddParamInt(percent);
if (percent < 100) {
- AddParamByte((byte) 0xA0); // 160
+ AddParamByte((byte) PARAM30MIN);
if (Config.logDanaMessageDetail)
log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
} else {
- AddParamByte((byte) 0x96); // 150
+ AddParamByte((byte) PARAM15MIN);
if (Config.logDanaMessageDetail)
log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
}
+ }
+ public MsgSetAPSTempBasalStart_v2(int percent, boolean fifteenMinutes, boolean thirtyMinutes) {
+ this();
+ setParams(percent, fifteenMinutes, thirtyMinutes);
+ }
+
+ protected void setParams(int percent, boolean fifteenMinutes, boolean thirtyMinutes) {
+ //HARDCODED LIMITS
+ if (percent < 0) percent = 0;
+ if (percent > 500) percent = 500;
+
+ AddParamInt(percent);
+ if (thirtyMinutes && percent <= 200) { // 30 min is allowed up to 200%
+ AddParamByte((byte) PARAM30MIN);
+ if (Config.logDanaMessageDetail)
+ log.debug("APS Temp basal start percent: " + percent + " duration 30 min");
+ } else {
+ AddParamByte((byte) PARAM15MIN);
+ if (Config.logDanaMessageDetail)
+ log.debug("APS Temp basal start percent: " + percent + " duration 15 min");
+ }
}
public void handleMessage(byte[] bytes) {
@@ -39,6 +66,7 @@ public class MsgSetAPSTempBasalStart_v2 extends MessageBase {
failed = true;
log.debug("Set APS temp basal start result: " + result + " FAILED!!!");
} else {
+ failed = false;
if (Config.logDanaMessageDetail)
log.debug("Set APS temp basal start result: " + result);
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
index 943054d4a2..1eb73a500a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java
@@ -254,6 +254,26 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
return true;
}
+ public boolean tempBasalShortDuration(int percent, int durationInMinutes) {
+ if (durationInMinutes != 15 && durationInMinutes != 30) {
+ log.error("Wrong duration param");
+ return false;
+ }
+
+ if (!isConnected()) return false;
+ if (mDanaRPump.isTempBasalInProgress) {
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.stoppingtempbasal)));
+ mSerialIOThread.sendMessage(new MsgSetTempBasalStop());
+ SystemClock.sleep(500);
+ }
+ MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.settingtempbasal)));
+ mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(percent, durationInMinutes == 15, durationInMinutes == 30));
+ mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2());
+ loadEvents();
+ MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.DISCONNECTING));
+ return true;
+ }
+
public boolean tempBasalStop() {
if (!isConnected()) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPumpPlugin.java
index 3feecfc7a5..fe5f84d66f 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpInsight/InsightPumpPlugin.java
@@ -138,6 +138,8 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
pumpDescription.tempPercentStep = 10;
pumpDescription.tempDurationStep = 15; // 15 minutes up to 24 hours
+ pumpDescription.tempDurationStep15mAllowed = true;
+ pumpDescription.tempDurationStep30mAllowed = true;
pumpDescription.tempMaxDuration = 24 * 60;
pumpDescription.isSetBasalProfileCapable = false; // leave this for now
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
index 51313d7f04..346750fa0a 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java
@@ -89,6 +89,8 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
pumpDescription.tempPercentStep = 10;
pumpDescription.tempDurationStep = 30;
+ pumpDescription.tempDurationStep15mAllowed = true;
+ pumpDescription.tempDurationStep30mAllowed = true;
pumpDescription.tempMaxDuration = 24 * 60;
diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml
index cdb83fc479..ab2b55cb1a 100644
--- a/app/src/main/res/values-bg/strings.xml
+++ b/app/src/main/res/values-bg/strings.xml
@@ -513,6 +513,7 @@
Изключи Loop за 2ч
Изключи Loop за 3ч
Изключи Loop за 10 ч
+ Изключи помпата за 15 мин.
Изключи помпата за 30 мин.
Изключи помпата за 1 ч
Изключи помпата за 2 ч
diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml
index 2574926d61..550da6e376 100644
--- a/app/src/main/res/values-cs/strings.xml
+++ b/app/src/main/res/values-cs/strings.xml
@@ -494,6 +494,7 @@
Odpojit pumpu na 10 h
Odpojit pumpu na 1 h
Odpojit pumpu na 2 h
+ Odpojit pumpu na 15 min
Odpojit pumpu na 30 min
Odpojit pumpu na 3 h
Povolit smyčku
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 585dd68c0b..7609d40847 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -413,6 +413,7 @@
Trenne Pumpe für 10 h
Trenne Pumpe für 1 h
Trenne Pumpe für 2 h
+ Trenne Pumpe für 15 Min.
Trenne Pumpe für 30 Min.
Trenne Pumpe für 3 h
Ignoriere Profilwechsel
diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml
index 6fb11d8a94..fd685edbea 100644
--- a/app/src/main/res/values-el/strings.xml
+++ b/app/src/main/res/values-el/strings.xml
@@ -510,6 +510,7 @@
Κύκλωμα σε παύση για 2h
Κύκλωμα σε παύση για 3h
Κύκλωμα σε παύση για 10h
+ Αποσύνδεση αντλίας για 15 λεπτά
Αποσύνδεση αντλίας για 30 λεπτά
Αποσύνδεση αντλίας για 1h
Αποσύνδεση αντλίας για 2h
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 35ae0bf4a3..cef29139f0 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -525,6 +525,7 @@
Desactivar loop por 2h
Desactivar loop por 3h
Desactivar loop por 10 h
+ Desconectar bomba por 15 min
Desconectar bomba por 30 min
Desconectar bomba por 1 h
Desconectar bomba por 2 h
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index ab80b4e363..564cd42dc9 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -508,6 +508,7 @@
Suspendre Loop pour 2h
Suspendre Loop pour 3h
Suspendre Loop pour 10h
+ Déconnecter la pompe 15min
Déconnecter la pompe 30min
Déconnecter la pompe 1h
Déconnecter la pompe 2h
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 39c1406997..5f4d22246b 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -145,6 +145,7 @@
Sconnetti Micro per 10H
Sconnetti Micro per 1 H
Sconnetti Micro per 2 H
+ Sconnetti Micro per 15min
Sconnetti Micro per 30min
Sconnetti Micro per 3 H
Respingere
diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml
index 9f4b3c301a..1581591e3b 100644
--- a/app/src/main/res/values-ko/strings.xml
+++ b/app/src/main/res/values-ko/strings.xml
@@ -522,6 +522,7 @@
2시간동안 Loop 일시중지
3시간동안 Loop 일시중지
10시간동안 Loop 일시중지
+ 15분동안 펌프 일시중지
30분동안 펌프 일시중지
1시간동안 펌프 일시중지
2시간동안 펌프 일시중지
diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml
index 61d57d95db..2e59556b78 100644
--- a/app/src/main/res/values-nl/strings.xml
+++ b/app/src/main/res/values-nl/strings.xml
@@ -250,6 +250,7 @@
Verbreek verbinding 10u met pomp
Verbreek verbinding 1u met pomp
Verbreek verbinding 2u met pomp
+ Verbreek verbinding 15min met pomp
Verbreek verbinding 30min met pomp
Verbreek verbinding 3u met pomp
NEGEER
diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml
index ae999de5b6..113ce1ebd6 100644
--- a/app/src/main/res/values-ro/strings.xml
+++ b/app/src/main/res/values-ro/strings.xml
@@ -547,6 +547,7 @@
Suspendă bucla pentru 2h
Suspendă bucla pentru 3h
Suspendă bucla pentru 10 h
+ Deconectează pompa pentru 15 min
Deconectează pompa pentru 30 min
Deconectează pompa pentru 1h
Deconectează pompa pentru 2h
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 51662f377b..19be5eebd5 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -179,6 +179,7 @@
отсоединить помпу на 10 час
отсоединить помпу на 1 час
отсоединить помпу на 2 часа
+ отсоединить помпу на 15 мин
отсоединить помпу на 30 мин
отсоединить помпу на 3 часа
отклонить
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index 78e32c5100..7bad0b82c3 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -165,6 +165,7 @@
Frånkopplar
Frånkoppla pump i 10 h
Frånkoppla pump i 2 h
+ Frånkoppla pump i 15 min
Frånkoppla pump i 30 min
Frånkoppla pump i 3 h
TA BORT
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 40479017ff..e4de2b8ced 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -562,6 +562,7 @@
Suspend loop for 2h
Suspend loop for 3h
Suspend loop for 10 h
+ Disconnect pump for 15 min
Disconnect pump for 30 min
Disconnect pump for 1 h
Disconnect pump for 2 h
diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.java
new file mode 100644
index 0000000000..bbacbb485c
--- /dev/null
+++ b/app/src/test/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest.java
@@ -0,0 +1,70 @@
+package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
+
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Created by mike on 20.11.2017.
+ */
+
+public class DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest extends DanaRS_Packet_APS_Basal_Set_Temporary_Basal {
+
+ @Test
+ public void runTest() throws Exception {
+ // under 100% should last 30 min
+ setParams(0);
+ assertEquals(0, temporaryBasalRatio);
+ assertEquals(PARAM30MIN, temporaryBasalDuration);
+ // over 100% should last 15 min
+ setParams(150);
+ assertEquals(150, temporaryBasalRatio);
+ assertEquals(PARAM15MIN, temporaryBasalDuration);
+ // test low hard limit
+ setParams(-1);
+ assertEquals(0, temporaryBasalRatio);
+ assertEquals(PARAM30MIN, temporaryBasalDuration);
+ // test high hard limit
+ setParams(550);
+ assertEquals(500, temporaryBasalRatio);
+ assertEquals(PARAM15MIN, temporaryBasalDuration);
+ // test setting 15 min
+ setParams(50, true, false);
+ assertEquals(50, temporaryBasalRatio);
+ assertEquals(PARAM15MIN, temporaryBasalDuration);
+ // test setting 30 min
+ setParams(50, false, true);
+ assertEquals(50, temporaryBasalRatio);
+ assertEquals(PARAM30MIN, temporaryBasalDuration);
+ // over 200% set always 15 min
+ setParams(250, false, true);
+ assertEquals(250, temporaryBasalRatio);
+ assertEquals(PARAM15MIN, temporaryBasalDuration);
+ // test low hard limit
+ setParams(-1, false, true);
+ assertEquals(0, temporaryBasalRatio);
+ assertEquals(PARAM30MIN, temporaryBasalDuration);
+ // test high hard limit
+ setParams(550, false,true);
+ assertEquals(500, temporaryBasalRatio);
+ assertEquals(PARAM15MIN, temporaryBasalDuration);
+
+ // test message generation
+ setParams(260, true, false);
+ byte[] generatedCode = getRequestParams();
+ assertEquals(3 , generatedCode.length);
+ assertEquals((byte)4 , generatedCode[0]);
+ assertEquals((byte)1 , generatedCode[1]);
+ assertEquals((byte)PARAM15MIN, generatedCode[2]);
+
+ // test message decoding
+ handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
+ assertEquals(false, failed);
+ handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 1});
+ assertEquals(true, failed);
+
+ assertEquals("BASAL__APS_SET_TEMPORARY_BASAL", getFriendlyName());
+ }
+
+}
diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/PumpdanaRv2/comm/MsgSetAPSTempBasalStart_v2Test.java b/app/src/test/java/info/nightscout/androidaps/plugins/PumpdanaRv2/comm/MsgSetAPSTempBasalStart_v2Test.java
new file mode 100644
index 0000000000..e36c5a7c24
--- /dev/null
+++ b/app/src/test/java/info/nightscout/androidaps/plugins/PumpdanaRv2/comm/MsgSetAPSTempBasalStart_v2Test.java
@@ -0,0 +1,72 @@
+package info.nightscout.androidaps.plugins.PumpdanaRv2.comm;
+
+
+import org.junit.Test;
+
+import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_APS_Basal_Set_Temporary_Basal;
+import info.nightscout.androidaps.plugins.PumpDanaRv2.comm.MsgSetAPSTempBasalStart_v2;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Created by mike on 20.11.2017.
+ */
+
+public class MsgSetAPSTempBasalStart_v2Test extends MsgSetAPSTempBasalStart_v2 {
+
+ @Test
+ public void runTest() throws Exception {
+ // under 100% should last 30 min
+ setParams(0);
+ assertEquals(0, intFromBuff(buffer, 0, 2));
+ assertEquals(PARAM30MIN, intFromBuff(buffer, 2, 1));
+ resetBuffer();
+ // over 100% should last 15 min
+ setParams(150);
+ assertEquals(150, intFromBuff(buffer, 0, 2));
+ assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
+ resetBuffer();
+ // test low hard limit
+ setParams(-1);
+ assertEquals(0, intFromBuff(buffer, 0, 2));
+ assertEquals(PARAM30MIN, intFromBuff(buffer, 2, 1));
+ resetBuffer();
+ // test high hard limit
+ setParams(550);
+ assertEquals(500, intFromBuff(buffer, 0, 2));
+ assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
+ resetBuffer();
+ // test setting 15 min
+ setParams(50, true, false);
+ assertEquals(50, intFromBuff(buffer, 0, 2));
+ assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
+ resetBuffer();
+ // test setting 30 min
+ setParams(50, false, true);
+ assertEquals(50, intFromBuff(buffer, 0, 2));
+ assertEquals(PARAM30MIN, intFromBuff(buffer, 2, 1));
+ resetBuffer();
+ // over 200% set always 15 min
+ setParams(250, false, true);
+ assertEquals(250, intFromBuff(buffer, 0, 2));
+ assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
+ resetBuffer();
+ // test low hard limit
+ setParams(-1, false, true);
+ assertEquals(0, intFromBuff(buffer, 0, 2));
+ assertEquals(PARAM30MIN, intFromBuff(buffer, 2, 1));
+ resetBuffer();
+ // test high hard limit
+ setParams(550, false, true);
+ assertEquals(500, intFromBuff(buffer, 0, 2));
+ assertEquals(PARAM15MIN, intFromBuff(buffer, 2, 1));
+ resetBuffer();
+
+ // test message decoding
+ handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0});
+ assertEquals(true, failed);
+ handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1});
+ assertEquals(false, failed);
+ }
+
+}