handle bolus stop prior to delivery correctly

This commit is contained in:
Milos Kozak 2017-12-03 19:34:01 +01:00
parent 9e0241aebc
commit 4185bb347d
6 changed files with 20 additions and 9 deletions

View file

@ -35,6 +35,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
static double amount;
public static boolean bolusEnded = false;
public static boolean running = true;
public static boolean stopPressed = false;
public BolusProgressDialog() {
super();
@ -62,6 +63,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
progressBar.setMax(100);
statusView.setText(MainApp.sResources.getString(R.string.waitingforpump));
setCancelable(false);
stopPressed = false;
return view;
}
@ -95,6 +97,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
switch (view.getId()) {
case R.id.overview_bolusprogress_stop:
log.debug("Stop bolus delivery button pressed");
stopPressed = true;
stopPressedView.setVisibility(View.VISIBLE);
stopButton.setVisibility(View.INVISIBLE);
ConfigBuilderPlugin.getActivePump().stopBolusDelivering();

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -365,6 +366,9 @@ public class DanaRExecutionService extends Service {
}
public boolean bolus(double amount, int carbs, final Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
bolusingTreatment = t;
int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
MessageBase start;
@ -374,8 +378,6 @@ public class DanaRExecutionService extends Service {
start = new MsgBolusStartWithSpeed(amount, preferencesSpeed);
MsgBolusStop stop = new MsgBolusStop(amount, t);
if (!isConnected()) return false;
if (carbs > 0) {
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(System.currentTimeMillis(), carbs));
}

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
@ -358,12 +359,13 @@ public class DanaRKoreanExecutionService extends Service {
}
public boolean bolus(double amount, int carbs, final Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
bolusingTreatment = t;
MsgBolusStart start = new MsgBolusStart(amount);
MsgBolusStop stop = new MsgBolusStop(amount, t);
if (!isConnected()) return false;
if (carbs > 0) {
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(System.currentTimeMillis(), carbs));
}

View file

@ -24,6 +24,7 @@ import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
@ -191,6 +192,9 @@ public class DanaRSService extends Service {
public boolean bolus(final double insulin, int carbs, long carbtime, Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus)));
bolusingTreatment = t;
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
@ -198,8 +202,6 @@ public class DanaRSService extends Service {
DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(insulin, t); // initialize static variables
DanaRS_Packet_Notify_Delivery_Complete complete = new DanaRS_Packet_Notify_Delivery_Complete(insulin, t); // initialize static variables
if (!isConnected()) return false;
if (carbs > 0) {
// MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs); ####
// bleComm.sendMessage(msg);

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
@ -357,6 +358,9 @@ public class DanaRv2ExecutionService extends Service {
}
public boolean bolus(final double amount, int carbs, long carbtime, final Treatment t) {
if (!isConnected()) return false;
if (BolusProgressDialog.stopPressed) return false;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus)));
bolusingTreatment = t;
final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
@ -367,8 +371,6 @@ public class DanaRv2ExecutionService extends Service {
start = new MsgBolusStartWithSpeed(amount, preferencesSpeed);
MsgBolusStop stop = new MsgBolusStop(amount, t);
if (!isConnected()) return false;
if (carbs > 0) {
MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs);
mSerialIOThread.sendMessage(msg);

View file

@ -97,8 +97,8 @@ public class QueueThread extends Thread {
if (queue.performing() == null) {
// Pickup 1st command and set performing variable
if (queue.size() > 0) {
log.debug("State: performing " + queue.performing().status());
queue.pickup();
log.debug("State: performing " + queue.performing().status());
MainApp.bus().post(new EventQueueChanged());
queue.performing().execute();
queue.resetPerforming();