From 06507bab2cc7815ef8afea0f8acbfa77522ee619 Mon Sep 17 00:00:00 2001 From: Roumen Georgiev Date: Tue, 12 Jun 2018 12:41:40 +0300 Subject: [PATCH] update method names --- .../plugins/PumpDanaR/DanaRPlugin.java | 2 +- .../PumpDanaR/comm/MsgSettingUserOptions.java | 25 ++++++++----------- .../PumpDanaRKorean/DanaRKoreanPlugin.java | 2 +- .../plugins/PumpDanaRv2/DanaRv2Plugin.java | 2 +- .../services/DanaRv2ExecutionService.java | 13 +++++++--- .../commands/CommandSetUserSettings.java | 8 +++--- 6 files changed, 29 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java index c2143ad9ec..69c07ce706 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java @@ -381,7 +381,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin { } @Override - public PumpEnactResult setUserSettings() { + public PumpEnactResult setUserOptions() { return null; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java index d88deb5f1d..56a71d00f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java @@ -4,11 +4,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; -import info.nightscout.androidaps.plugins.Overview.notifications.Notification; -import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 05.07.2016. @@ -32,6 +27,7 @@ public class MsgSettingUserOptions extends MessageBase { public MsgSettingUserOptions(int timeDisplayType, int buttonScrollOnOff, int beepAndAlarm, int lcdOnTimeSec, int backlightOnTimeSec, int selectedLanguage, int glucoseUnit, int shutdownHour, int lowReservoirRate, int cannulaVolume, int refillRate) { this(); + log.debug(" initializing MsgSetUserOptions"); this.timeDisplayType = timeDisplayType; this.buttonScrollOnOff = buttonScrollOnOff; this.beepAndAlarm = beepAndAlarm; @@ -44,15 +40,15 @@ public class MsgSettingUserOptions extends MessageBase { this.cannulaVolume = cannulaVolume; this.refillRate = refillRate; - AddParamInt(timeDisplayType); - AddParamInt(buttonScrollOnOff); - AddParamInt(beepAndAlarm); - AddParamInt(lcdOnTimeSec); - AddParamInt(backlightOnTimeSec); - AddParamInt(selectedLanguage); - AddParamInt(glucoseUnit); - AddParamInt(shutdownHour); - AddParamInt(lowReservoirRate); + AddParamByte((byte) timeDisplayType); + AddParamByte((byte) buttonScrollOnOff); + AddParamByte((byte) beepAndAlarm); + AddParamByte((byte) lcdOnTimeSec); + AddParamByte((byte) backlightOnTimeSec); + AddParamByte((byte) selectedLanguage); + AddParamByte((byte) glucoseUnit); + AddParamByte((byte) shutdownHour); + AddParamByte((byte) lowReservoirRate); } private static Logger log = LoggerFactory.getLogger(MsgSettingUserOptions.class); @@ -62,6 +58,7 @@ public class MsgSettingUserOptions extends MessageBase { } public void handleMessage(byte[] bytes) { + log.debug("Entering handleMessage "); int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java index 59430b8793..b7b100a3a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java @@ -382,7 +382,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin { } @Override - public PumpEnactResult setUserSettings() { + public PumpEnactResult setUserOptions() { return null; } } 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 606b0d0c76..83d6b24a6b 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 @@ -392,7 +392,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { @Override public PumpEnactResult setUserOptions() { DanaRv2ExecutionService service = new DanaRv2ExecutionService(); - log.debug("MsgSetingUserOptions executed!"); + log.debug("MsgSetUserOptions executed!"); return service.setUserOptions(); } 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 5eab684bbd..0b646fde48 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 @@ -477,12 +477,19 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { } public PumpEnactResult setUserOptions() { - if (!isConnected()) - return new PumpEnactResult().success(false); + if (!isConnected()) { + log.debug("MsgSetUserOptions - service is not connected"); +// return new PumpEnactResult().success(false); + connect(); + } SystemClock.sleep(300); DanaRPump pump = DanaRPump.getInstance(); MsgSettingUserOptions msg = new MsgSettingUserOptions(pump.timeDisplayType, pump.buttonScrollOnOff, pump.beepAndAlarm, pump.lcdOnTimeSec, pump.backlightOnTimeSec, pump.selectedLanguage, pump.units, pump.shutdownHour, pump.lowReservoirRate, 0, 0); - + if (mSerialIOThread != null) { + mSerialIOThread.disconnect("MsgSetUserOptions - Recreate SerialIOThread"); + } + mSerialIOThread = new SerialIOThread(mRfcommSocket); + MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0)); mSerialIOThread.sendMessage(msg); while (!msg.done && mRfcommSocket.isConnected()) { SystemClock.sleep(100); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java index 357c766652..f3d9fe2a4b 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java @@ -1,5 +1,8 @@ package info.nightscout.androidaps.queue.commands; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.interfaces.DanaRInterface; @@ -14,7 +17,7 @@ import info.nightscout.androidaps.queue.Callback; */ public class CommandSetUserSettings extends Command { - + private static Logger log = LoggerFactory.getLogger(CommandSetUserSettings.class); public CommandSetUserSettings(Callback callback) { commandType = CommandType.SETUSERSETTINGS; this.callback = callback; @@ -27,8 +30,7 @@ public class CommandSetUserSettings extends Command { DanaRInterface danaPump = (DanaRInterface) pump; boolean isDanaRv2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class) != null && MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PUMP); if(isDanaRv2){ - pump.getPumpStatus(); - danaPump.setUserOptions(); + log.debug("MsgSetUserOptions detected for DanaRv2"); } PumpEnactResult r = danaPump.setUserOptions(); if (callback != null)