diff --git a/app/build.gradle b/app/build.gradle index fc47ac7928..1e468de9e8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -50,7 +50,6 @@ android { buildConfigField "String", "BUILDVERSION", generateGitBuild() ndk { - abiFilters "armeabi-v7a", "x86", "armeabi", "mips" moduleName "BleCommandUtil" } } @@ -152,7 +151,6 @@ dependencies { } compile 'org.slf4j:slf4j-api:1.7.12' compile 'com.jjoe64:graphview:4.0.1' - compile 'com.eclipsesource.j2v8:j2v8:3.1.6@aar' compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.1.1' compile 'com.google.android.gms:play-services-wearable:7.5.0' compile 'junit:junit:4.12' diff --git a/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java b/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java index 2d928a5541..7720b03d3e 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java +++ b/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java @@ -29,4 +29,14 @@ public class DetailedBolusInfo { public Context context = null; // context for progress dialog public long pumpId = 0; // id of record if comming from pump history (not a newly created treatment) public boolean isSMB = false; // is a Super-MicroBolus + + @Override + public String toString() { + return new Date(date).toLocaleString() + + " insulin: " + insulin + + " carbs: " + carbs + + " isValid: " + isValid + + " carbTime: " + carbTime + + " isSMB: " + isSMB; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/data/Profile.java b/app/src/main/java/info/nightscout/androidaps/data/Profile.java index 1ec6f54b71..61c7397694 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/app/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -256,7 +256,7 @@ public class Profile { private String format_HH_MM(Integer timeAsSeconds) { String time; int hour = timeAsSeconds / 60 / 60; - int minutes = timeAsSeconds - hour * 60 * 60; + int minutes = (timeAsSeconds - hour * 60 * 60) / 60; DecimalFormat df = new DecimalFormat("00"); time = df.format(hour) + ":" + df.format(minutes); return time; 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 b60ab20d88..b9e13f0426 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 @@ -961,7 +961,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain } public String getProfileUnits() { - return activeProfile.getUnits(); + return getProfile().getUnits(); } public Profile getProfile(long time) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java index d6352cdb18..abe3c75c73 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java @@ -20,7 +20,7 @@ public class DetailedBolusInfoStorage { private static List store = new ArrayList<>(); public static void add(DetailedBolusInfo detailedBolusInfo) { - log.debug("Bolus info stored: " + new Date(detailedBolusInfo.date).toLocaleString()); + log.debug("Stored bolus info: " + detailedBolusInfo); store.add(detailedBolusInfo); } @@ -29,7 +29,7 @@ public class DetailedBolusInfoStorage { DetailedBolusInfo found = null; for (int i = 0; i < store.size(); i++) { long infoTime = store.get(i).date; - log.debug("Existing info: " + new Date(infoTime).toLocaleString()); + log.debug("Existing bolus info: " + store.get(i)); if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { found = store.get(i); break; @@ -42,7 +42,7 @@ public class DetailedBolusInfoStorage { for (int i = 0; i < store.size(); i++) { long infoTime = store.get(i).date; if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { - log.debug("Removing info: " + new Date(infoTime).toLocaleString()); + log.debug("Removing bolus info: " + store.get(i)); store.remove(i); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java index 9939bd44d1..e6d58178f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java @@ -13,6 +13,7 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin; +import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin; import info.nightscout.utils.SP; /** @@ -32,7 +33,7 @@ public class AutosensData { time = t.date; carbs = t.carbs; remaining = t.carbs; - if (MainApp.getSpecificPlugin(SensitivityAAPSPlugin.class) != null && MainApp.getSpecificPlugin(SensitivityAAPSPlugin.class).isEnabled(PluginBase.SENSITIVITY)) { + if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginBase.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginBase.SENSITIVITY)) { double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, 4d); Profile profile = MainApp.getConfigBuilder().getProfile(t.date); double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index 445eda93cd..a76e694372 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -366,6 +366,9 @@ public class IobCobCalculatorPlugin implements PluginBase { continue; } + if (profile.getIsf(bgTime) == null) + return; // profile not set yet + double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits()); AutosensData autosensData = new AutosensData(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java index 9dd63a83fe..c6158be296 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java @@ -183,7 +183,7 @@ public class BroadcastTreatment { ret.add(newarr); } newarr = new JSONArray(); - count = 50; + count = 20; } newarr.put(array.get(i)); --count; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java index 2a2e1b8044..2df50b2bd1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java @@ -254,7 +254,7 @@ public class NSDeviceStatus { long clockEnacted = 0L; JSONObject suggested = null; - JSONObject enacted = null; + public JSONObject enacted = null; } public void updateOpenApsData(JSONObject object) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java index 774ff55401..e4c23ae043 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java @@ -1,7 +1,5 @@ package info.nightscout.androidaps.plugins.OpenAPSAMA; -import com.eclipsesource.v8.V8Object; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index 308965a5ea..dbe16c0a9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -32,6 +32,7 @@ import com.squareup.otto.Subscribe; import org.json.JSONException; import org.json.JSONObject; +import org.mozilla.javascript.tools.debugger.Main; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -401,15 +402,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com ArrayList profileList; profileList = profileStore.getProfileList(); + profileList.add(0, MainApp.sResources.getString(R.string.active)); ArrayAdapter adapter = new ArrayAdapter(getContext(), R.layout.spinner_centered, profileList); profileSpinner.setAdapter(adapter); - // set selected to actual profile - for (int p = 0; p < profileList.size(); p++) { - if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName())) - profileSpinner.setSelection(p); - } String units = profile.getUnits(); bgUnits.setText(units); @@ -451,7 +448,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com if (profileSpinner == null || profileSpinner.getSelectedItem() == null) return; // not initialized yet String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString(); - Profile specificProfile = profile.getSpecificProfile(selectedAlternativeProfile); + Profile specificProfile; + if (selectedAlternativeProfile.equals(MainApp.sResources.getString(R.string.active))) + specificProfile = MainApp.getConfigBuilder().getProfile(); + else + specificProfile = profile.getSpecificProfile(selectedAlternativeProfile); // Entered values Double c_bg = SafeParse.stringToDouble(editBg.getText()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java index af3b852aa6..b6a54f4ec1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java @@ -187,12 +187,12 @@ public class SerialIOThread extends Thread { scheduledDisconnection = null; } } - // prepare task for execution in 5 sec + // prepare task for execution in 10 sec // cancel waiting task to prevent sending multiple disconnections if (scheduledDisconnection != null) scheduledDisconnection.cancel(false); Runnable task = new DisconnectRunnable(); - final int sec = 5; + final int sec = 10; scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS); } 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 9d94634094..1ef5349f25 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 @@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.SerialIOThread; @@ -410,12 +411,12 @@ public class DanaRExecutionService extends Service { public boolean bolus(double amount, int carbs, Treatment t) { bolusingTreatment = t; - int speed = SP.getInt(R.string.key_danars_bolusspeed, 0); + int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); MessageBase start; - if (speed == 0) + if (preferencesSpeed == 0) start = new MsgBolusStart(amount); else - start = new MsgBolusStartWithSpeed(amount, speed); + start = new MsgBolusStartWithSpeed(amount, preferencesSpeed); MsgBolusStop stop = new MsgBolusStop(amount, t); connect("bolus"); @@ -426,7 +427,7 @@ public class DanaRExecutionService extends Service { } MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables - long startTime = System.currentTimeMillis(); + long bolusStart = System.currentTimeMillis(); if (!stop.stopped) { mSerialIOThread.sendMessage(start); @@ -436,23 +437,47 @@ public class DanaRExecutionService extends Service { } while (!stop.stopped && !start.failed) { waitMsec(100); - if ((System.currentTimeMillis() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm + if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm stop.stopped = true; stop.forced = true; log.debug("Communication stopped"); } } waitMsec(300); + + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); + bolusingEvent.t = t; + bolusingEvent.percent = 99; + bolusingTreatment = null; + + int speed = 12; + switch (preferencesSpeed) { + case 0: + speed = 12; + break; + case 1: + speed = 30; + break; + case 2: + speed = 60; + break; + } // try to find real amount if bolusing was interrupted or comm failed if (t.insulin != amount) { disconnect("bolusingInterrupted"); - long now = System.currentTimeMillis(); - long estimatedBolusEnd = (long) (startTime + amount / 5d * 60 * 1000); // std delivery rate 5 U/min - waitMsec(Math.max(5000, estimatedBolusEnd - now + 3000)); + long bolusDurationInMSec = (long) (amount * speed * 1000); + long expectedEnd = bolusStart + bolusDurationInMSec + 3000; + + while (System.currentTimeMillis() < expectedEnd) { + long waitTime = expectedEnd - System.currentTimeMillis(); + bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000); + MainApp.bus().post(bolusingEvent); + SystemClock.sleep(1000); + } connect("bolusingInterrupted"); getPumpStatus(); - if (danaRPump.lastBolusTime.getTime() > now - 60 * 1000L) { // last bolus max 1 min old + if (danaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old t.insulin = danaRPump.lastBolusAmount; log.debug("Used bolus amount from history: " + danaRPump.lastBolusAmount); } else { 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 160a71695f..cee63a170f 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 @@ -49,6 +49,7 @@ import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange; import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService; import info.nightscout.utils.DateUtil; +import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.Round; import info.nightscout.utils.SP; @@ -218,7 +219,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, connect(from); } - public static synchronized void connect(String from) { + public static void connect(String from) { log.debug("RS connect from: " + from); if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { final Object o = new Object(); @@ -264,7 +265,9 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, @Override public boolean loadHistory(byte type) { connectIfNotConnected("loadHistory"); - return danaRSService.loadHistory(type); + danaRSService.loadHistory(type); + disconnect("LoadHistory"); + return true; } // Constraints interface @@ -374,7 +377,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public int setNewBasalProfile(Profile profile) { + public synchronized int setNewBasalProfile(Profile profile) { if (danaRSService == null) { log.error("setNewBasalProfile sExecutionService is null"); return FAILED; @@ -391,10 +394,12 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, if (!danaRSService.updateBasalsInPump(profile)) { Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); + disconnect("SetNewBasalProfile"); return FAILED; } else { MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); + disconnect("SetNewBasalProfile"); return SUCCESS; } } @@ -425,10 +430,11 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public void refreshDataFromPump(String reason) { + public synchronized void refreshDataFromPump(String reason) { log.debug("Refreshing data from pump"); if (!isConnected() && !isConnecting()) { connect(reason); + disconnect("RefreshDataFromPump"); } else log.debug("Already connecting ..."); } @@ -439,11 +445,10 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { + public synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { - DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); int speed = 12; switch (preferencesSpeed) { @@ -458,8 +463,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, break; } // v2 stores end time for bolus, we need to adjust time - // default delivery speed is 12 U/min - detailedBolusInfo.date += detailedBolusInfo.insulin / speed * 60d * 1000; + // default delivery speed is 12 sec/U + detailedBolusInfo.date += detailedBolusInfo.insulin * speed * 1000; // clean carbs to prevent counting them as twice because they will picked up as another record // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records double carbs = detailedBolusInfo.carbs; @@ -467,6 +472,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, int carbTime = detailedBolusInfo.carbTime; detailedBolusInfo.carbTime = 0; + DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history + Treatment t = new Treatment(); boolean connectionOK = false; connectIfNotConnected("bolus"); @@ -479,7 +486,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); if (Config.logPumpActions) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); - // remove carbs because it's get from history seprately + disconnect("DeliverTreatment"); return result; } else { PumpEnactResult result = new PumpEnactResult(); @@ -503,7 +510,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, // This is called from APS @Override - public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew) { + public synchronized PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew) { // Recheck pump status if older than 30 min if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) { connect("setTempBasalAbsolute old data"); @@ -580,7 +587,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { + public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { PumpEnactResult result = new PumpEnactResult(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); percent = configBuilderPlugin.applyBasalConstraints(percent); @@ -622,6 +629,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, result.isPercent = true; if (Config.logPumpActions) log.debug("setTempBasalPercent: OK"); + disconnect("setTempBasalPercent"); return result; } result.enacted = false; @@ -631,7 +639,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, return result; } - public PumpEnactResult setHighTempBasalPercent(Integer percent) { + public synchronized PumpEnactResult setHighTempBasalPercent(Integer percent) { PumpEnactResult result = new PumpEnactResult(); connectIfNotConnected("hightempbasal"); boolean connectionOK = danaRSService.highTempBasal(percent); @@ -645,6 +653,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, result.isPercent = true; if (Config.logPumpActions) log.debug("setHighTempBasalPercent: OK"); + disconnect("setHighTempBasalPercent"); return result; } result.enacted = false; @@ -655,7 +664,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { + public synchronized PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); insulin = configBuilderPlugin.applyBolusConstraints(insulin); // needs to be rounded @@ -688,6 +697,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, result.isPercent = false; if (Config.logPumpActions) log.debug("setExtendedBolus: OK"); + disconnect("setExtendedBolus"); return result; } result.enacted = false; @@ -698,7 +708,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult cancelTempBasal(boolean force) { + public synchronized PumpEnactResult cancelTempBasal(boolean force) { PumpEnactResult result = new PumpEnactResult(); TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); if (runningTB != null) { @@ -706,6 +716,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, danaRSService.tempBasalStop(); result.enacted = true; result.isTempCancel = true; + disconnect("cancelTempBasal"); } if (!pump.isTempBasalInProgress) { result.success = true; @@ -724,7 +735,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult cancelExtendedBolus() { + public synchronized PumpEnactResult cancelExtendedBolus() { PumpEnactResult result = new PumpEnactResult(); ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()); if (runningEB != null) { @@ -732,6 +743,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, danaRSService.extendedBolusStop(); result.enacted = true; result.isTempCancel = true; + disconnect("extendedBolusStop"); } if (!pump.isExtendedInProgress) { result.success = true; @@ -807,7 +819,28 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, @Override public String shortStatus(boolean veryShort) { - return null; + String ret = ""; + if (pump.lastConnection.getTime() != 0) { + Long agoMsec = System.currentTimeMillis() - pump.lastConnection.getTime(); + int agoMin = (int) (agoMsec / 60d / 1000d); + ret += "LastConn: " + agoMin + " minago\n"; + } + if (pump.lastBolusTime.getTime() != 0) { + ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n"; + } + if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) { + ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull() + "\n"; + } + if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { + ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString() + "\n"; + } + if (!veryShort) { + ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n"; + } + ret += "IOB: " + pump.iob + "U\n"; + ret += "Reserv: " + DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + "U\n"; + ret += "Batt: " + pump.batteryRemaining + "\n"; + return ret; } @Override 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 7ce847dc58..06608b5a74 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 @@ -51,9 +51,9 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = byteArrayToInt(getBytes(data, DATA_START, 1)); - if (result != 1) { + if (result != 0) { failed = true; - log.debug("Set APS temp basal start result: " + result + " FAILED!!!"); + log.error("Set APS temp basal start result: " + result + " FAILED!!!"); } else { if (Config.logDanaMessageDetail) log.debug("Set APS temp basal start result: " + result); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java index fe010eb72f..8e58dc2cb5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java @@ -10,15 +10,14 @@ import java.util.Date; import java.util.GregorianCalendar; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; -import info.nightscout.androidaps.db.DanaRHistoryRecord; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; -import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; -import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.utils.DateUtil; public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { @@ -32,11 +31,11 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { private int sec = 0; public boolean done; - public int totalCount; + private int totalCount; public static long lastEventTimeLoaded = 0; - public DanaRS_Packet_APS_History_Events() { + DanaRS_Packet_APS_History_Events() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS; done = false; @@ -97,70 +96,87 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); if (detailedBolusInfo == null) { - log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString()); + log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); detailedBolusInfo = new DetailedBolusInfo(); + } else { + log.debug("Detailed bolus info found: " + detailedBolusInfo); } detailedBolusInfo.date = datetime.getTime(); detailedBolusInfo.source = Source.PUMP; detailedBolusInfo.pumpId = datetime.getTime(); + String status; + switch (recordCode) { case DanaRPump.TEMPSTART: log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); temporaryBasal.percentRate = param1; temporaryBasal.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); + status = "TEMPSTART " + DateUtil.timeString(datetime); break; case DanaRPump.TEMPSTOP: log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); + status = "TEMPSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTART: log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "EXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTOP: log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.BOLUS: detailedBolusInfo.insulin = param1 / 100d; boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); + status = "BOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALBOLUS: detailedBolusInfo.insulin = param1 / 100d; newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); + status = "DUALBOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTART: log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTOP: log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDON: log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); + status = "SUSPENDON " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDOFF: log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); + status = "SUSPENDOFF " + DateUtil.timeString(datetime); break; case DanaRPump.REFILL: log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "REFILL " + DateUtil.timeString(datetime); break; case DanaRPump.PRIME: log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "PRIME " + DateUtil.timeString(datetime); break; case DanaRPump.PROFILECHANGE: log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); + status = "PROFILECHANGE " + DateUtil.timeString(datetime); break; case DanaRPump.CARBS: DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo(); @@ -170,17 +186,22 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { emptyCarbsInfo.pumpId = datetime.getTime(); newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); + status = "CARBS " + DateUtil.timeString(datetime); break; case DanaRPump.PRIMECANNULA: - log.debug("EVENT PRIME CANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "PRIMECANNULA " + DateUtil.timeString(datetime); break; default: log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); + status = "UNKNOWN " + DateUtil.timeString(datetime); break; } if (datetime.getTime() > lastEventTimeLoaded) lastEventTimeLoaded = datetime.getTime(); + + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status)); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java index 0f102090a7..4e559a77df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java @@ -61,9 +61,9 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (result != 1) { + if (result != 0) { failed = true; - log.debug("Set history entry result: " + result + " FAILED!!!"); + log.error("Set history entry result: " + result + " FAILED!!!"); } else { if (Config.logDanaMessageDetail) log.debug("Set history entry result: " + result); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java index 6f56464c51..a64da24bf3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java @@ -4,13 +4,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; + import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Basal_Rate.class); private double[] profileBasalRate; - public int error; public DanaRS_Packet_Basal_Set_Basal_Rate() { super(); @@ -38,11 +38,12 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java index 70a8b02826..538750a45b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java @@ -10,8 +10,6 @@ import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.class); - public int error; - public DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL; @@ -22,9 +20,12 @@ public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packe @Override public void handleMessage(byte[] data) { - error = byteArrayToInt(getBytes(data, DATA_START, 1)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java index 82a63f0ca7..66d0e7b4bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java @@ -11,7 +11,6 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { private int profileNumber; // 0 - 4 private double[] profileBasalRate; - public int error; public DanaRS_Packet_Basal_Set_Profile_Basal_Rate() { super(); @@ -41,11 +40,12 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java index fe47f89dfc..69f7eae8dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java @@ -10,7 +10,6 @@ import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Profile_Number.class); private int profileNumber; - public int error; public DanaRS_Packet_Basal_Set_Profile_Number() { super(); @@ -33,11 +32,12 @@ public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java index 1b9444c2d3..4c78038162 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java @@ -8,7 +8,6 @@ import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_Off.class); - public int error; public DanaRS_Packet_Basal_Set_Suspend_Off() { super(); @@ -20,11 +19,12 @@ public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java index 01e90e026c..75a2a5fada 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java @@ -8,7 +8,6 @@ import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_On.class); - public int error; public DanaRS_Packet_Basal_Set_Suspend_On() { super(); @@ -20,11 +19,12 @@ public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java index a81d85f016..d2f68ff864 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java @@ -11,7 +11,6 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { private int temporaryBasalRatio; private int temporaryBasalDuration; - public int error; public DanaRS_Packet_Basal_Set_Temporary_Basal() { super(); @@ -37,11 +36,12 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java index e20baeaee6..103bac3ecf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java @@ -111,12 +111,12 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java index cf6a459d83..062ae00712 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java @@ -83,12 +83,12 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java index 31c80a702a..e769bea195 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java @@ -44,12 +44,12 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java index d5f61c0946..887a9d852a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java @@ -40,12 +40,12 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java index 10aa5f4979..132de649cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java @@ -19,12 +19,12 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel extends DanaRS_Packet @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java index a475e7675d..a174d39b53 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java @@ -44,12 +44,12 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java index 1263aeb629..4c5cc23ef3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java @@ -48,14 +48,12 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet { } @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - - failed = status != 0x00; - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java index 61ddd05c9b..5383fca413 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java @@ -35,13 +35,14 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); stopped = true; if (!forced) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java index 7d9ec07ff1..878cfd64dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java @@ -31,12 +31,12 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java index 9cc6b7b2e0..3917f31050 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java @@ -17,12 +17,12 @@ public class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear extends DanaR @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java index e93e18796d..007623afca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java @@ -45,7 +45,10 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet { int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (error == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + error); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java index 49c6d35708..e5d9374f32 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java @@ -47,7 +47,10 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet { int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (error == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + error); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java index dde50a93e1..42f077887d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java @@ -165,19 +165,6 @@ public class BLEComm { MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING)); isConnecting = true; - // Following should be removed later because we close Gatt on disconnect and this should never happen - if ((mBluetoothDeviceAddress != null) && (address.equals(mBluetoothDeviceAddress)) && (mBluetoothGatt != null)) { - log.debug("Trying to use an existing mBluetoothGatt for connection."); - sHandler.post(updateProgress); - if (mBluetoothGatt.connect()) { - setCharacteristicNotification(getUARTReadBTGattChar(), true); - return true; - } - sHandler.removeCallbacks(updateProgress); - return false; - } - // end - BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); if (device == null) { log.debug("Device not found. Unable to connect."); @@ -201,12 +188,19 @@ public class BLEComm { public void disconnect(String from) { log.debug("disconnect from: " + from); + + // cancel previous scheduled disconnection to prevent closing upcomming connection + if (scheduledDisconnection != null) + scheduledDisconnection.cancel(false); + scheduledDisconnection = null; + if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { return; } setCharacteristicNotification(getUARTReadBTGattChar(), false); mBluetoothGatt.disconnect(); isConnected = false; + SystemClock.sleep(2000); } public void close() { @@ -214,6 +208,7 @@ public class BLEComm { if (mBluetoothGatt == null) { return; } + mBluetoothGatt.close(); mBluetoothGatt = null; } @@ -687,18 +682,19 @@ public class BLEComm { } public void scheduleDisconnection() { + class DisconnectRunnable implements Runnable { public void run() { disconnect("scheduleDisconnection"); scheduledDisconnection = null; } } - // prepare task for execution in 5 sec + // prepare task for execution in 30 sec // cancel waiting task to prevent sending multiple disconnections if (scheduledDisconnection != null) scheduledDisconnection.cancel(false); Runnable task = new DisconnectRunnable(); - final int sec = 5; + final int sec = 30; scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS); log.debug("Disconnection scheduled"); } 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 6b39788342..399254f84b 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 @@ -26,6 +26,7 @@ import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; @@ -188,16 +189,16 @@ public class DanaRSService extends Service { while (!msg.done && bleComm.isConnected()) { SystemClock.sleep(100); } - SystemClock.sleep(200); lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded; return true; } - public boolean bolus(double insulin, int carbs, long carbtime, Treatment t) { + public boolean bolus(final double insulin, int carbs, long carbtime, Treatment t) { + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus))); bolusingTreatment = t; - int speed = SP.getInt(R.string.key_danars_bolusspeed, 0); - DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, speed); + final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); + DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, preferencesSpeed); 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 @@ -210,28 +211,60 @@ public class DanaRSService extends Service { bleComm.sendMessage(msgSetHistoryEntry_v2); lastHistoryFetched = carbtime - 60000; } - if (insulin > 0) { - DanaRS_Packet_Notify_Delivery_Rate_Display progress = new DanaRS_Packet_Notify_Delivery_Rate_Display(insulin, t); // initialize static variables + final long bolusStart = System.currentTimeMillis(); + if (insulin > 0) { if (!stop.stopped) { bleComm.sendMessage(start); } else { t.insulin = 0d; return false; } + DanaRS_Packet_Notify_Delivery_Rate_Display progress = new DanaRS_Packet_Notify_Delivery_Rate_Display(insulin, t); // initialize static variables + while (!stop.stopped && !start.failed && !complete.done) { SystemClock.sleep(100); - if ((System.currentTimeMillis() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm + if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 20 sec expecting broken comm stop.stopped = true; stop.forced = true; log.debug("Communication stopped"); } } } - SystemClock.sleep(3000); + + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); + bolusingEvent.t = t; + bolusingEvent.percent = 99; + bolusingTreatment = null; - DanaRSPlugin.connectIfNotConnected("ReadHistoryAfterBolus"); + int speed = 12; + switch (preferencesSpeed) { + case 0: + speed = 12; + break; + case 1: + speed = 30; + break; + case 2: + speed = 60; + break; + } + long bolusDurationInMSec = (long) (insulin * speed * 1000); + long expectedEnd = bolusStart + bolusDurationInMSec + 2000; + while (System.currentTimeMillis() < expectedEnd) { + long waitTime = expectedEnd - System.currentTimeMillis(); + bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000); + MainApp.bus().post(bolusingEvent); + SystemClock.sleep(1000); + } + if (!(isConnected())) + DanaRSPlugin.getPlugin().connect("loadEvents"); loadEvents(); + // reread bolus status + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); + bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus + bolusingEvent.percent = 100; + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); return true; } 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 ea174e4608..4a224bd57b 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 @@ -293,9 +293,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { - DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history // v2 stores end time for bolus, we need to adjust time - // default delivery speed is 12 U/min + // default delivery speed is 12 sec/U int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); int speed = 12; switch (preferencesSpeed) { @@ -309,7 +308,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, speed = 60; break; } - detailedBolusInfo.date += detailedBolusInfo.insulin / speed * 60d * 1000; + detailedBolusInfo.date += speed * detailedBolusInfo.insulin * 1000; // clean carbs to prevent counting them as twice because they will picked up as another record // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records double carbs = detailedBolusInfo.carbs; @@ -317,6 +316,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, int carbTime = detailedBolusInfo.carbTime; detailedBolusInfo.carbTime = 0; + DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history + Treatment t = new Treatment(); boolean connectionOK = false; if (detailedBolusInfo.insulin > 0 || carbs > 0) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java index 244014f3d0..da9e44f925 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java @@ -188,12 +188,12 @@ public class SerialIOThread extends Thread { scheduledDisconnection = null; } } - // prepare task for execution in 5 sec + // prepare task for execution in 10 sec // cancel waiting task to prevent sending multiple disconnections if (scheduledDisconnection != null) scheduledDisconnection.cancel(false); Runnable task = new DisconnectRunnable(); - final int sec = 5; + final int sec = 10; scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java index f04218ac61..922047e5cb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java @@ -7,13 +7,16 @@ import java.util.Date; import java.util.GregorianCalendar; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; +import info.nightscout.utils.DateUtil; public class MsgHistoryEvents_v2 extends MessageBase { private static Logger log = LoggerFactory.getLogger(MsgHistoryEvents_v2.class); @@ -65,70 +68,87 @@ public class MsgHistoryEvents_v2 extends MessageBase { DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); if (detailedBolusInfo == null) { - log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString()); + log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); detailedBolusInfo = new DetailedBolusInfo(); + } else { + log.debug("Detailed bolus info found: " + detailedBolusInfo); } detailedBolusInfo.date = datetime.getTime(); detailedBolusInfo.source = Source.PUMP; detailedBolusInfo.pumpId = datetime.getTime(); + String status = ""; + switch (recordCode) { case DanaRPump.TEMPSTART: log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); temporaryBasal.percentRate = param1; temporaryBasal.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); + status = "TEMPSTART " + DateUtil.timeString(datetime); break; case DanaRPump.TEMPSTOP: log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); + status = "TEMPSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTART: log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "EXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTOP: log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.BOLUS: detailedBolusInfo.insulin = param1 / 100d; boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); + status = "BOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALBOLUS: detailedBolusInfo.insulin = param1 / 100d; newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); + status = "DUALBOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTART: log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTOP: log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDON: log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); + status = "SUSPENDON " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDOFF: log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); + status = "SUSPENDOFF " + DateUtil.timeString(datetime); break; case DanaRPump.REFILL: log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "REFILL " + DateUtil.timeString(datetime); break; case DanaRPump.PRIME: log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "PRIME " + DateUtil.timeString(datetime); break; case DanaRPump.PROFILECHANGE: log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); + status = "PROFILECHANGE " + DateUtil.timeString(datetime); break; case DanaRPump.CARBS: DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo(); @@ -138,14 +158,17 @@ public class MsgHistoryEvents_v2 extends MessageBase { emptyCarbsInfo.pumpId = datetime.getTime(); newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); + status = "CARBS " + DateUtil.timeString(datetime); break; default: log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); + status = "UNKNOWN " + DateUtil.timeString(datetime); break; } if (datetime.getTime() > lastEventTimeLoaded) lastEventTimeLoaded = datetime.getTime(); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status)); } } 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 fc3df19296..6eabb668fb 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 @@ -36,6 +36,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.*; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; @@ -261,13 +262,13 @@ public class DanaRv2ExecutionService extends Service { } } + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); mSerialIOThread.sendMessage(statusMsg); mSerialIOThread.sendMessage(statusBasicMsg); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingtempbasalstatus))); mSerialIOThread.sendMessage(tempStatusMsg); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingextendedbolusstatus))); mSerialIOThread.sendMessage(exStatusMsg); - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); if (!statusMsg.received) { mSerialIOThread.sendMessage(statusMsg); @@ -400,14 +401,15 @@ public class DanaRv2ExecutionService extends Service { return true; } - public boolean bolus(double amount, int carbs, long carbtime, Treatment t) { + public boolean bolus(final double amount, int carbs, long carbtime, Treatment t) { + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus))); bolusingTreatment = t; - int speed = SP.getInt(R.string.key_danars_bolusspeed, 0); + final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); MessageBase start; - if (speed == 0) + if (preferencesSpeed == 0) start = new MsgBolusStart(amount); else - start = new MsgBolusStartWithSpeed(amount, speed); + start = new MsgBolusStartWithSpeed(amount, preferencesSpeed); MsgBolusStop stop = new MsgBolusStop(amount, t); connect("bolus"); @@ -420,6 +422,8 @@ public class DanaRv2ExecutionService extends Service { mSerialIOThread.sendMessage(msgSetHistoryEntry_v2); lastHistoryFetched = carbtime - 60000; } + + final long bolusStart = System.currentTimeMillis(); if (amount > 0) { MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables @@ -431,26 +435,49 @@ public class DanaRv2ExecutionService extends Service { } while (!stop.stopped && !start.failed) { waitMsec(100); - if ((System.currentTimeMillis() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm + if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm stop.stopped = true; stop.forced = true; log.debug("Communication stopped"); } } } + + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); + bolusingEvent.t = t; + bolusingEvent.percent = 99; + bolusingTreatment = null; - // run loading history in separate thread and allow bolus dialog to be closed - new Thread(new Runnable() { - @Override - public void run() { - waitMsec(4000); - if (!(isConnected())) - connect("loadEvents"); - loadEvents(); - } - }).start(); + int speed = 12; + switch (preferencesSpeed) { + case 0: + speed = 12; + break; + case 1: + speed = 30; + break; + case 2: + speed = 60; + break; + } + long bolusDurationInMSec = (long) (amount * speed * 1000); + long expectedEnd = bolusStart + bolusDurationInMSec + 2000; + while (System.currentTimeMillis() < expectedEnd) { + long waitTime = expectedEnd - System.currentTimeMillis(); + bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000); + MainApp.bus().post(bolusingEvent); + SystemClock.sleep(1000); + } + if (!(isConnected())) + connect("loadEvents"); + loadEvents(); + // load last bolus status + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); + mSerialIOThread.sendMessage(new MsgStatus()); + bolusingEvent.percent = 100; + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); return true; - } +} public void bolusStop() { if (Config.logDanaBTComm) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java index 258ea09b33..68537cf47c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java @@ -5,11 +5,9 @@ import android.support.v4.util.LongSparseArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Date; -import java.util.List; +import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; @@ -32,7 +30,7 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity private boolean fragmentEnabled = true; private boolean fragmentVisible = false; - static SensitivityWeightedAveragePlugin plugin = null; + private static SensitivityWeightedAveragePlugin plugin = null; public static SensitivityWeightedAveragePlugin getPlugin() { if (plugin == null) @@ -108,13 +106,15 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours); if (autosensDataTable == null || autosensDataTable.size() < 4) { - log.debug("No autosens data available"); + if (Config.logAutosensData) + log.debug("No autosens data available"); return new AutosensResult(); } AutosensData current = IobCobCalculatorPlugin.getAutosensData(toTime); if (current == null) { - log.debug("No autosens data available"); + if (Config.logAutosensData) + log.debug("No autosens data available"); return new AutosensResult(); } @@ -181,9 +181,10 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity double sens = profile.getIsf(); String ratioLimit = ""; - String sensResult = ""; + String sensResult; - log.debug("Records: " + index + " " + pastSensitivity); + if (Config.logAutosensData) + log.debug("Records: " + index + " " + pastSensitivity); double average = weightedsum / weights; double basalOff = average * (60 / 5) / Profile.toMgdl(sens, profile.getUnits()); @@ -197,7 +198,8 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity sensResult = "Sensitivity normal"; } - log.debug(sensResult); + if (Config.logAutosensData) + log.debug(sensResult); double rawRatio = ratio; ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7"))); @@ -205,10 +207,12 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity if (ratio != rawRatio) { ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio; - log.debug(ratioLimit); + if (Config.logAutosensData) + log.debug(ratioLimit); } - log.debug("Sensitivity to: " + new Date(toTime).toLocaleString() + " weightedaverage: " + average + " ratio: " + ratio); + if (Config.logAutosensData) + log.debug("Sensitivity to: " + new Date(toTime).toLocaleString() + " weightedaverage: " + average + " ratio: " + ratio); AutosensResult output = new AutosensResult(); output.ratio = Round.roundTo(ratio, 0.01); diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index aa4840b0e7..c55a7246ff 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -11,7 +11,7 @@ Сигурни ли сте че искате да изтриете всички данни? Изход Използвай удължен болус за над 200% - DanaR Bluetooth устройство + DanaR Bluetooth устройство Използване на абсолютни стойности за базал Рестартирайте телефона или AndroidAPS от системните настройки или Android APS няма да записва проблемите (което е важно за работата на алгоритъма)! Цел: @@ -71,10 +71,10 @@ Стойност Срок Основание - КЗ - Промяна + Кръвна захар + Изменение (Δ) Delta: - Средна промяна + Средно изменение (Δ), Конфигурация Цели OpenAPS MA @@ -85,8 +85,6 @@ Лечения Виртуална помпа Careportal - - Помпа Treatments Временен базал @@ -140,7 +138,7 @@ Несъвместима версия на Nightscout NSClient не е открит. Записът е загубен! КЗ да се вижда в NS - Статуса на помпа да е достъпен в NS + Статуса на помпата да е достъпен в NS Ръчно приложени LOOP Е СПРЯН ОТ ОГРАНИЧЕНИЯТА Czech @@ -370,7 +368,7 @@ Отвори настройките на часовника Грешка в промпата Изтощена батерия - Помпа изключена + Помпата е изключена Батерията на помпата е изтощена DanaR Korean Избран е грешен тип помпа @@ -448,7 +446,7 @@ По подразбиране: разрешено\nТова позволява на autosens да променя и целевите КЗ(освен чувствителност и базал). По подразбиране: 2\nBolus snooze се активира след като поставите болус за основно хранене, така Loop няма да пуснка/намаля базалите веднага след като сте се хранили. Примерът тук е с 2; така при 3 часа DIA това ще означава че bolus snooze ще бъде внимателно изместен 1.5 часа (3DIA/2). По подразбиране: 3.0\nТова е настройка на количеството на покачване на КЗ при усвояване на въглехидратите за всеки 5 минути. По подразбиране 3мг/дл/5мин. Това се отразява на това колко бързо се усвояват COB според алгоритъма, и как това се отразява в предвиждането на КЗ, когато тя не се покачва или пада с различен темп от очакваното. - Attention!\nNormally you do not have to change these values below. Please CLICK HERE and READ the text and make sure you UNDERSTAND it before change any of these values. + Внимание! Обикновено Вие не трябва да променяте тези стойности. Моля НАТИСНЕТЕ ТУК, прочетете текста и бъдете сигурни, че го РАЗБИРАТЕ преди да направите каквито и да е промени! http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html Позволени са само числа Позволени са числа между %1$s - %2$s @@ -529,7 +527,7 @@ Wrong duration Loop suspended Loop resumed - промяна за 15мин + Δ за 15мин COB Суперболус Записвай всяко стартиране на AndroidAPS в NS @@ -649,4 +647,36 @@ Swedish Fiasp Ултра бързодействащ по Oref + време за физ. активност + Целева КЗ при физ. активност + Скорост на болус + % от профила + Време на отместване + Все още устройството не е намерено + DanaRS + Dana + Временна цел по подразбиране + Време за \"Преди хранене\" + Цел за \"Преди хранене\" + Празен резервоар + Получава болус статус + Получава статус на удължен болус + Получава настройките на помпата + Получава времето на помпата + Получава статус на временен базал + СДВОЯВАНЕ + Сдвоени + Времето за сдвояване изтече + Сдвояване с нова помпа + отново + Избрана помпа + Сериен номер + ЛЕЧ + Очаква сдвояване с помпа + Времето за връзка изтече + Преглед на известията + Изпращай известията като съобщения към часовника + Настройки на часовник + Задаване временни цели и въвеждане Лечения от часовник Android wear + Контролиране от часовник diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 3484e4ec92..cb1d976ffb 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -659,4 +659,8 @@ Nastavování dočasných cílů a vkládání ošetření na hodinkách Wear Řízení z hodinek Wear Model: %02X Protokol: %02X Kód: %02X + ]]> + Výstraha měření glykémie + Vypršel čas připojování + DC diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 248c2f3f21..176e914676 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -165,7 +165,7 @@ LOOP DEAKTIVIERT DURCH DIE BESCHRÄNKUNG Nach Beschränkungen Loop - Manual enacts + Manuelle Eingriffe Kohlenhydrate Beschränkung erreicht Reset Datenbanken Minimale Dauer @@ -314,8 +314,8 @@ LOOP LP DANA - "CONF" - "CPP" + CONF + CPP CP Bitte verwenden Sie nur Ziffern. Pflichtfeld @@ -512,7 +512,7 @@ Restart Beende Applikation um neue Einstellungen zu laden. Fortsetzten - Russian + Russisch Kalibrierung %.1f an xDrip senden? Passwort für die Einstellungen Setzte temp Basal @@ -591,7 +591,7 @@ Empfindlichkeitserkennung COB Aktiviere die SuperBolus-Funktion im Wizard. Nicht aktivieren, wenn du nicht weißt, was es macht! ES KANN ZU EINER ÜBERDOSIERUNG AN INSULIN KOMMEN, WENN DU ES BLIND BENUTZT! - "Verstehen des OpenLoops und der Temp-Basal-Empfehlungen + Verstehen des OpenLoops und der Temp-Basal-Empfehlungen Verwende AMA Autosense Um Basal mit %.2fU/h zu starten, antworte mit dem Code %s Fiasp @@ -619,6 +619,60 @@ DIA von %s ist zu kurz - aaps nutzt stattdessen %s! Möglicherweise ungenau, wenn zum Befüllen ein Bolus verwendet wurde! Verhältnis + aktiviere Profil + Aktivitätsdauer + Aktivitätsziel + BZ-Messung + Bolus Geschwindigkeit + Prozentsatz + Zeitverschiebung + BAT + CircadianPercantage + Verbindungs-Unterbrechungs-Dauer + Füllen + DE Bolus + DS Bolus + E Bolus + Basalschritt setzen zu 0.01 U/h + Tägl. Basalmenge + Tägl. Basalmenge * 2 + Tägl. Gesamtdosis + Gerät nicht gefunden + DanaRS + Dana + Datum + Standard Temp. Ziele + Eating Soon Dauer + Eating Soon Ziel + Reservoir leer + Ausgeführt + Ermittle Bolus Status + Ermittle verz. Bolus Status + Ermittle Pumpen Einstell. + Ermittle Pumpenzeit + Ermittle temp. Basal Status + Ungültig + Langes durchschn. Delta + ICT + integrierter NSClient + Basaltyp + Verbindung Zeit überschritten + Verbinde neue Pumpe + Delta Einstellungen + Restinsulin + erneut verwenden + ausgewählte Pumpe + Seriennummer + auf Verbindung warten + Setze temp. Ziele und Behandlungen auf Uhr + Steuerung von der Uhr + SENS + SEN + Verbindung OK + Verbindung + PRE + Interner NSClient + NSCI Aktualisieren Aktivität %d%% (%d verbleibend) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index e6e0dbed7e..a0504dc51a 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -342,10 +342,10 @@ NS에 업로드만 하기. 로컬소스(xDrip)가 선택되지 않으면 SGV에는 효력이 없습니다. NS프로파일이 사용중이라면 프로파일에는 효력이 없습니다. 펌프가 초기화 되지 않았습니다! 펌프가 초기화와 프로파일 설정이 되지 않았습니다! - 공기/채움 + 교체/채움 양이 인퓨전세트의 사양과 일치하는지 확인하세요! 기타 - 공기/채움 기본 인슐린양 + 교체/채움 기본 인슐린양 버튼1 버튼2 버튼3 @@ -411,7 +411,7 @@ 비율 #일 가중 - 공기/채움을 위해 식사주입을 사용한 경우 부정확할 수 있습니다!! + 교체/채움을 위해 식사주입을 사용한 경우 부정확할 수 있습니다!! 오래된 데이터입니다. "새로고침"을 누르세요. 총기초량 총기초량 * 2 @@ -541,7 +541,7 @@ Superbolus 앱시작을 NS에 기록하기 설정을 적용하기위해 앱을 종료합니다. - DanaRv2 + 다나Rv2 인슐린 Fast Acting Insulin Novorapid, Novolog, Humalog @@ -557,7 +557,7 @@ 펌웨어 최근 연결 블루투스 상태 - About + 버전정보 SMS 권한 누락 DEV xDrip 상태(워치) @@ -648,8 +648,7 @@ ACTIVATE PROFILE Date INVALID - - 펌프연동 대기중 +펌프연동 대기중 연동완료 연동시간초과 연동중 @@ -680,7 +679,35 @@ 재사용 워치로 작동하기 임시목표와 관리입력을 워치로 설정합니다. + 연결시간초과 펌프연동 대기중연동완료 + 연동시간초과 + 연동중 + 현재까지 발견된 기기가 없습니다. + 빈 주사기 + 혈당측정알람 + 남은 인슐린 양 + 다나RS + Dana + 선택된 펌프 + 새 펌프와 연동 + 식사주입 속도 + 기초주입 단위를 0.01 U/h로 설정하세요 + 시리얼번호 + 퍼센트 + 시간 이동 + 임시목표 기본값 + eatingsoon 기간 + eatingsoon 목표 + activity 기간 + activity 목표 + 교체 + 확장식사주입 상태 가져오는중 + 식사주입상태 가져오는중 + 임시기초주입상태 가져오는중 + 펌프설정 가져오는중 + 펌프시간 가져오는중 + 재사용 + 워치로 작동하기 + 임시목표와 관리입력을 워치로 설정합니다. 연결시간초과 - - AndroidAPS diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index f350a98b68..71960023f9 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -649,4 +649,36 @@ Snel-werkende Oref Fiasp Ultra-Rapid Oref + Periode van inspanning + Activiteits doel + Bloed glucose meetpunt alarm + Bolus snelheid + Percentage + Tijd verschuiving + Connectie verlopen + Vullen + Zet de basale stap op 0,01 E/u + Geen toestel gevonden + DanaRS + Dana + Standaart tijdelijk basaal + Eet binnenkort periode + Eet binnenkort doel + Bolus status ophalen + Vertraagde bolus status ophalen + Pomp instellingen ophalen + Pomp tijd ophalen + Ophalen van tijdelijke basaal status + Koppelen + Koppeling geslaagd + Koppeling verlopen + Koppel nieuwe pomp + Resterende insuline hoeveelheid + Herbruik + Geselecteerde pomp + Serie nummer + Stel tijdelijke doelen en bolussen in vanop je horloge. + Bedieningen via horloge + Ampull leeg + Wachten op koppelen van de pomp diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index efa2d31c4d..c8bdc47ec9 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -49,9 +49,9 @@ - 12s 1U - 30s 1U - 60s 1U + 12 s/U + 30 s/U + 60 s/U 0 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e94e8a5794..92e955c122 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -750,6 +750,10 @@ Set Temp-Targets and enter Treatments from the watch. Connection timed out + ]]> + Waiting for estimated bolus end. Remaining %d sec. + Processing event + Starting bolus delivery Stopping bolus delivery Bolus delivery stopped diff --git a/gradle.properties b/gradle.properties index c8d0d56109..1d3591c8a4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,4 @@ # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true - -android.useDeprecatedNdk=true \ No newline at end of file +# org.gradle.parallel=true \ No newline at end of file