addd setUserOption to Queue (Dana pumps)
This commit is contained in:
parent
6a4bb8a719
commit
04fffae811
10 changed files with 99 additions and 41 deletions
|
@ -9,4 +9,5 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
public interface DanaRInterface {
|
public interface DanaRInterface {
|
||||||
PumpEnactResult loadHistory(byte type); // for history browser
|
PumpEnactResult loadHistory(byte type); // for history browser
|
||||||
PumpEnactResult loadEvents(); // events history to build treatments from
|
PumpEnactResult loadEvents(); // events history to build treatments from
|
||||||
|
PumpEnactResult setUserSettings(); // like AnyDana does
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,4 +379,9 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
public PumpEnactResult loadEvents() {
|
public PumpEnactResult loadEvents() {
|
||||||
return null; // no history, not needed
|
return null; // no history, not needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult setUserSettings() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaR.activities;
|
package info.nightscout.androidaps.plugins.PumpDanaR.activities;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.RadioGroup;
|
import android.widget.RadioGroup;
|
||||||
|
@ -20,9 +20,11 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||||
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.NumberPicker;
|
import info.nightscout.utils.NumberPicker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,12 +170,8 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
} else
|
} else
|
||||||
pump.lowReservoirRate = 10;
|
pump.lowReservoirRate = 10;
|
||||||
|
|
||||||
// push new settings to pump
|
MainApp.getConfigBuilder().getCommandQueue().setUserSettings(null);
|
||||||
DanaRSPlugin pumpPlugin = MainApp.getSpecificPlugin(DanaRSPlugin.class);
|
finish();
|
||||||
if (!pumpPlugin.isConnected())
|
|
||||||
pumpPlugin.connect("UpdateUserOptions");
|
|
||||||
pumpPlugin.updateUserOptions();
|
|
||||||
pumpPlugin.disconnect("UpdateUserOprions");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,4 +380,9 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
public PumpEnactResult loadEvents() {
|
public PumpEnactResult loadEvents() {
|
||||||
return null; // no history, not needed
|
return null; // no history, not needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult setUserSettings() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,6 +223,11 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
return danaRSService.loadEvents();
|
return danaRSService.loadEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult setUserSettings() {
|
||||||
|
return danaRSService.setUserSettings();
|
||||||
|
}
|
||||||
|
|
||||||
// Constraints interface
|
// Constraints interface
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -759,19 +764,4 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
return loadHistory(RecordTypes.RECORD_TYPE_DAILY);
|
return loadHistory(RecordTypes.RECORD_TYPE_DAILY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUserOptions() {
|
|
||||||
if (danaRSService == null) {
|
|
||||||
log.error("updateUserOptions sExecutionService is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
log.debug("UserOptionsLoadedd2:"+(System.currentTimeMillis() - pump.lastConnection)/1000+" s ago"
|
|
||||||
+"\ntimeDisplayType:"+pump.timeDisplayType
|
|
||||||
+"\nbuttonScroll:"+pump.buttonScrollOnOff
|
|
||||||
+"\ntimeDisplayType:"+pump.timeDisplayType
|
|
||||||
+"\nlcdOnTimeSec:"+pump.lcdOnTimeSec
|
|
||||||
+"\nbacklight:"+pump.backlightOnTimeSec
|
|
||||||
+"\npumpUnits:"+pump.units
|
|
||||||
+"\nlowReservoir:"+pump.lowReservoirRate);
|
|
||||||
danaRSService.updateUserOptions();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,24 +182,6 @@ public class DanaRSService extends Service {
|
||||||
log.debug("Pump status loaded");
|
log.debug("Pump status loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUserOptions() {
|
|
||||||
try {
|
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
|
||||||
log.debug("UserOptionsLoadedd3:"+(System.currentTimeMillis() - pump.lastConnection)/1000+" s ago"
|
|
||||||
+"\ntimeDisplayType:"+pump.timeDisplayType
|
|
||||||
+"\nbuttonScroll:"+pump.buttonScrollOnOff
|
|
||||||
+"\ntimeDisplayType:"+pump.timeDisplayType
|
|
||||||
+"\nlcdOnTimeSec:"+pump.lcdOnTimeSec
|
|
||||||
+"\nbacklight:"+pump.backlightOnTimeSec
|
|
||||||
+"\npumpUnits:"+pump.units
|
|
||||||
+"\nlowReservoir:"+pump.lowReservoirRate);
|
|
||||||
//bleComm.sendMessage(new DanaRS_Packet_Option_Set_User_Option());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
log.debug("User options updates");
|
|
||||||
}
|
|
||||||
|
|
||||||
public PumpEnactResult loadEvents() {
|
public PumpEnactResult loadEvents() {
|
||||||
DanaRS_Packet_APS_History_Events msg;
|
DanaRS_Packet_APS_History_Events msg;
|
||||||
if (lastHistoryFetched == 0) {
|
if (lastHistoryFetched == 0) {
|
||||||
|
@ -223,6 +205,22 @@ public class DanaRSService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PumpEnactResult setUserSettings() {
|
||||||
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
|
log.debug("setUserSettings:"+(System.currentTimeMillis() - pump.lastConnection)/1000+" s ago"
|
||||||
|
+"\ntimeDisplayType:"+pump.timeDisplayType
|
||||||
|
+"\nbuttonScroll:"+pump.buttonScrollOnOff
|
||||||
|
+"\ntimeDisplayType:"+pump.timeDisplayType
|
||||||
|
+"\nlcdOnTimeSec:"+pump.lcdOnTimeSec
|
||||||
|
+"\nbacklight:"+pump.backlightOnTimeSec
|
||||||
|
+"\npumpUnits:"+pump.units
|
||||||
|
+"\nlowReservoir:"+pump.lowReservoirRate);
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Option_Set_User_Option());
|
||||||
|
bleComm.sendMessage(new DanaRS_Packet_Option_Get_User_Option());
|
||||||
|
return new PumpEnactResult().success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean bolus(final double insulin, int carbs, long carbtime, Treatment t) {
|
public boolean bolus(final double insulin, int carbs, long carbtime, Treatment t) {
|
||||||
if (!isConnected()) return false;
|
if (!isConnected()) return false;
|
||||||
if (BolusProgressDialog.stopPressed) return false;
|
if (BolusProgressDialog.stopPressed) return false;
|
||||||
|
|
|
@ -389,4 +389,9 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
return sExecutionService.loadEvents();
|
return sExecutionService.loadEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult setUserSettings() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import info.nightscout.androidaps.queue.commands.CommandLoadTDDs;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandReadStatus;
|
import info.nightscout.androidaps.queue.commands.CommandReadStatus;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandSMBBolus;
|
import info.nightscout.androidaps.queue.commands.CommandSMBBolus;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandSetProfile;
|
import info.nightscout.androidaps.queue.commands.CommandSetProfile;
|
||||||
|
import info.nightscout.androidaps.queue.commands.CommandSetUserSettings;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandTempBasalAbsolute;
|
import info.nightscout.androidaps.queue.commands.CommandTempBasalAbsolute;
|
||||||
import info.nightscout.androidaps.queue.commands.CommandTempBasalPercent;
|
import info.nightscout.androidaps.queue.commands.CommandTempBasalPercent;
|
||||||
|
|
||||||
|
@ -403,6 +404,25 @@ public class CommandQueue {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns true if command is queued
|
||||||
|
public boolean setUserSettings(Callback callback) {
|
||||||
|
if (isRunning(Command.CommandType.SETUSERSETTINGS)) {
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(executingNowError()).run();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove all unfinished
|
||||||
|
removeAll(Command.CommandType.SETUSERSETTINGS);
|
||||||
|
|
||||||
|
// add new command to queue
|
||||||
|
add(new CommandSetUserSettings(callback));
|
||||||
|
|
||||||
|
notifyAboutNewCommand();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// returns true if command is queued
|
// returns true if command is queued
|
||||||
public boolean loadTDDs(Callback callback) {
|
public boolean loadTDDs(Callback callback) {
|
||||||
if (isRunning(Command.CommandType.LOADHISTORY)) {
|
if (isRunning(Command.CommandType.LOADHISTORY)) {
|
||||||
|
|
|
@ -18,7 +18,8 @@ public abstract class Command {
|
||||||
BASALPROFILE,
|
BASALPROFILE,
|
||||||
READSTATUS,
|
READSTATUS,
|
||||||
LOADHISTORY, // TDDs and so far only Dana specific
|
LOADHISTORY, // TDDs and so far only Dana specific
|
||||||
LOADEVENTS // so far only Dana specific
|
LOADEVENTS, // so far only Dana specific
|
||||||
|
SETUSERSETTINGS // so far only Dana specific
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandType commandType;
|
public CommandType commandType;
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package info.nightscout.androidaps.queue.commands;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
|
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 10.11.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CommandSetUserSettings extends Command {
|
||||||
|
|
||||||
|
public CommandSetUserSettings(Callback callback) {
|
||||||
|
commandType = CommandType.SETUSERSETTINGS;
|
||||||
|
this.callback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
|
if (pump instanceof DanaRInterface) {
|
||||||
|
DanaRInterface danaPump = (DanaRInterface) pump;
|
||||||
|
PumpEnactResult r = danaPump.setUserSettings();
|
||||||
|
if (callback != null)
|
||||||
|
callback.result(r).run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String status() {
|
||||||
|
return "SETUSERSETTINGS";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue