Merge pull request #7 from MilosKozak/dev

Dev
This commit is contained in:
Simon Pauwels 2017-10-22 22:13:16 +02:00 committed by GitHub
commit ac66e37bec
42 changed files with 395 additions and 211 deletions

View file

@ -29,4 +29,14 @@ public class DetailedBolusInfo {
public Context context = null; // context for progress dialog 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 long pumpId = 0; // id of record if comming from pump history (not a newly created treatment)
public boolean isSMB = false; // is a Super-MicroBolus 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;
}
} }

View file

@ -256,7 +256,7 @@ public class Profile {
private String format_HH_MM(Integer timeAsSeconds) { private String format_HH_MM(Integer timeAsSeconds) {
String time; String time;
int hour = timeAsSeconds / 60 / 60; int hour = timeAsSeconds / 60 / 60;
int minutes = timeAsSeconds - hour * 60 * 60; int minutes = (timeAsSeconds - hour * 60 * 60) / 60;
DecimalFormat df = new DecimalFormat("00"); DecimalFormat df = new DecimalFormat("00");
time = df.format(hour) + ":" + df.format(minutes); time = df.format(hour) + ":" + df.format(minutes);
return time; return time;

View file

@ -961,7 +961,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
} }
public String getProfileUnits() { public String getProfileUnits() {
return activeProfile.getUnits(); return getProfile().getUnits();
} }
public Profile getProfile(long time) { public Profile getProfile(long time) {

View file

@ -20,7 +20,7 @@ public class DetailedBolusInfoStorage {
private static List<DetailedBolusInfo> store = new ArrayList<>(); private static List<DetailedBolusInfo> store = new ArrayList<>();
public static void add(DetailedBolusInfo detailedBolusInfo) { 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); store.add(detailedBolusInfo);
} }
@ -29,7 +29,7 @@ public class DetailedBolusInfoStorage {
DetailedBolusInfo found = null; DetailedBolusInfo found = null;
for (int i = 0; i < store.size(); i++) { for (int i = 0; i < store.size(); i++) {
long infoTime = store.get(i).date; 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) { if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) {
found = store.get(i); found = store.get(i);
break; break;
@ -42,7 +42,7 @@ public class DetailedBolusInfoStorage {
for (int i = 0; i < store.size(); i++) { for (int i = 0; i < store.size(); i++) {
long infoTime = store.get(i).date; long infoTime = store.get(i).date;
if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { 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); store.remove(i);
break; break;
} }

View file

@ -366,6 +366,9 @@ public class IobCobCalculatorPlugin implements PluginBase {
continue; continue;
} }
if (profile.getIsf(bgTime) == null)
return; // profile not set yet
double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits()); double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits());
AutosensData autosensData = new AutosensData(); AutosensData autosensData = new AutosensData();

View file

@ -183,7 +183,7 @@ public class BroadcastTreatment {
ret.add(newarr); ret.add(newarr);
} }
newarr = new JSONArray(); newarr = new JSONArray();
count = 50; count = 20;
} }
newarr.put(array.get(i)); newarr.put(array.get(i));
--count; --count;

View file

@ -32,6 +32,7 @@ import com.squareup.otto.Subscribe;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.mozilla.javascript.tools.debugger.Main;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -401,15 +402,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
ArrayList<CharSequence> profileList; ArrayList<CharSequence> profileList;
profileList = profileStore.getProfileList(); profileList = profileStore.getProfileList();
profileList.add(0, MainApp.sResources.getString(R.string.active));
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(), ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
R.layout.spinner_centered, profileList); R.layout.spinner_centered, profileList);
profileSpinner.setAdapter(adapter); 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(); String units = profile.getUnits();
bgUnits.setText(units); bgUnits.setText(units);
@ -451,7 +448,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
if (profileSpinner == null || profileSpinner.getSelectedItem() == null) if (profileSpinner == null || profileSpinner.getSelectedItem() == null)
return; // not initialized yet return; // not initialized yet
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString(); 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 // Entered values
Double c_bg = SafeParse.stringToDouble(editBg.getText()); Double c_bg = SafeParse.stringToDouble(editBg.getText());

View file

@ -187,12 +187,12 @@ public class SerialIOThread extends Thread {
scheduledDisconnection = null; scheduledDisconnection = null;
} }
} }
// prepare task for execution in 5 sec // prepare task for execution in 10 sec
// cancel waiting task to prevent sending multiple disconnections // cancel waiting task to prevent sending multiple disconnections
if (scheduledDisconnection != null) if (scheduledDisconnection != null)
scheduledDisconnection.cancel(false); scheduledDisconnection.cancel(false);
Runnable task = new DisconnectRunnable(); Runnable task = new DisconnectRunnable();
final int sec = 5; final int sec = 10;
scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS); scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS);
} }

View file

@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.data.Profile; 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.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.SerialIOThread; 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) { public boolean bolus(double amount, int carbs, Treatment t) {
bolusingTreatment = 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; MessageBase start;
if (speed == 0) if (preferencesSpeed == 0)
start = new MsgBolusStart(amount); start = new MsgBolusStart(amount);
else else
start = new MsgBolusStartWithSpeed(amount, speed); start = new MsgBolusStartWithSpeed(amount, preferencesSpeed);
MsgBolusStop stop = new MsgBolusStop(amount, t); MsgBolusStop stop = new MsgBolusStop(amount, t);
connect("bolus"); connect("bolus");
@ -426,7 +427,7 @@ public class DanaRExecutionService extends Service {
} }
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
long startTime = System.currentTimeMillis(); long bolusStart = System.currentTimeMillis();
if (!stop.stopped) { if (!stop.stopped) {
mSerialIOThread.sendMessage(start); mSerialIOThread.sendMessage(start);
@ -436,23 +437,47 @@ public class DanaRExecutionService extends Service {
} }
while (!stop.stopped && !start.failed) { while (!stop.stopped && !start.failed) {
waitMsec(100); 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.stopped = true;
stop.forced = true; stop.forced = true;
log.debug("Communication stopped"); log.debug("Communication stopped");
} }
} }
waitMsec(300); waitMsec(300);
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.t = t;
bolusingEvent.percent = 99;
bolusingTreatment = null; 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 // try to find real amount if bolusing was interrupted or comm failed
if (t.insulin != amount) { if (t.insulin != amount) {
disconnect("bolusingInterrupted"); disconnect("bolusingInterrupted");
long now = System.currentTimeMillis(); long bolusDurationInMSec = (long) (amount * speed * 1000);
long estimatedBolusEnd = (long) (startTime + amount / 5d * 60 * 1000); // std delivery rate 5 U/min long expectedEnd = bolusStart + bolusDurationInMSec + 3000;
waitMsec(Math.max(5000, estimatedBolusEnd - now + 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"); connect("bolusingInterrupted");
getPumpStatus(); 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; t.insulin = danaRPump.lastBolusAmount;
log.debug("Used bolus amount from history: " + danaRPump.lastBolusAmount); log.debug("Used bolus amount from history: " + danaRPump.lastBolusAmount);
} else { } else {

View file

@ -49,6 +49,7 @@ import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange; import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService; import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -218,7 +219,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
connect(from); connect(from);
} }
public static synchronized void connect(String from) { public static void connect(String from) {
log.debug("RS connect from: " + from); log.debug("RS connect from: " + from);
if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) {
final Object o = new Object(); final Object o = new Object();
@ -264,7 +265,9 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
@Override @Override
public boolean loadHistory(byte type) { public boolean loadHistory(byte type) {
connectIfNotConnected("loadHistory"); connectIfNotConnected("loadHistory");
return danaRSService.loadHistory(type); danaRSService.loadHistory(type);
disconnect("LoadHistory");
return true;
} }
// Constraints interface // Constraints interface
@ -375,7 +378,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
} }
@Override @Override
public int setNewBasalProfile(Profile profile) { public synchronized int setNewBasalProfile(Profile profile) {
if (danaRSService == null) { if (danaRSService == null) {
log.error("setNewBasalProfile sExecutionService is null"); log.error("setNewBasalProfile sExecutionService is null");
return FAILED; return FAILED;
@ -392,10 +395,12 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
if (!danaRSService.updateBasalsInPump(profile)) { if (!danaRSService.updateBasalsInPump(profile)) {
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT); Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification)); MainApp.bus().post(new EventNewNotification(notification));
disconnect("SetNewBasalProfile");
return FAILED; return FAILED;
} else { } else {
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
disconnect("SetNewBasalProfile");
return SUCCESS; return SUCCESS;
} }
} }
@ -426,10 +431,11 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
} }
@Override @Override
public void refreshDataFromPump(String reason) { public synchronized void refreshDataFromPump(String reason) {
log.debug("Refreshing data from pump"); log.debug("Refreshing data from pump");
if (!isConnected() && !isConnecting()) { if (!isConnected() && !isConnecting()) {
connect(reason); connect(reason);
disconnect("RefreshDataFromPump");
} else } else
log.debug("Already connecting ..."); log.debug("Already connecting ...");
} }
@ -440,11 +446,10 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
} }
@Override @Override
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { public synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { 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 preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
int speed = 12; int speed = 12;
switch (preferencesSpeed) { switch (preferencesSpeed) {
@ -459,8 +464,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
break; break;
} }
// v2 stores end time for bolus, we need to adjust time // 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
detailedBolusInfo.date += detailedBolusInfo.insulin / speed * 60d * 1000; detailedBolusInfo.date += detailedBolusInfo.insulin * speed * 1000;
// clean carbs to prevent counting them as twice because they will picked up as another record // 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 // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records
double carbs = detailedBolusInfo.carbs; double carbs = detailedBolusInfo.carbs;
@ -468,6 +473,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
int carbTime = detailedBolusInfo.carbTime; int carbTime = detailedBolusInfo.carbTime;
detailedBolusInfo.carbTime = 0; detailedBolusInfo.carbTime = 0;
DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history
Treatment t = new Treatment(); Treatment t = new Treatment();
boolean connectionOK = false; boolean connectionOK = false;
connectIfNotConnected("bolus"); connectIfNotConnected("bolus");
@ -480,7 +487,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
// remove carbs because it's get from history seprately disconnect("DeliverTreatment");
return result; return result;
} else { } else {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
@ -504,7 +511,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
// This is called from APS // This is called from APS
@Override @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 // Recheck pump status if older than 30 min
if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) { if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) {
connect("setTempBasalAbsolute old data"); connect("setTempBasalAbsolute old data");
@ -581,7 +588,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
} }
@Override @Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
percent = configBuilderPlugin.applyBasalConstraints(percent); percent = configBuilderPlugin.applyBasalConstraints(percent);
@ -623,6 +630,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
result.isPercent = true; result.isPercent = true;
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalPercent: OK"); log.debug("setTempBasalPercent: OK");
disconnect("setTempBasalPercent");
return result; return result;
} }
result.enacted = false; result.enacted = false;
@ -632,7 +640,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
return result; return result;
} }
public PumpEnactResult setHighTempBasalPercent(Integer percent) { public synchronized PumpEnactResult setHighTempBasalPercent(Integer percent) {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
connectIfNotConnected("hightempbasal"); connectIfNotConnected("hightempbasal");
boolean connectionOK = danaRSService.highTempBasal(percent); boolean connectionOK = danaRSService.highTempBasal(percent);
@ -646,6 +654,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
result.isPercent = true; result.isPercent = true;
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setHighTempBasalPercent: OK"); log.debug("setHighTempBasalPercent: OK");
disconnect("setHighTempBasalPercent");
return result; return result;
} }
result.enacted = false; result.enacted = false;
@ -656,7 +665,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
} }
@Override @Override
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { public synchronized PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
insulin = configBuilderPlugin.applyBolusConstraints(insulin); insulin = configBuilderPlugin.applyBolusConstraints(insulin);
// needs to be rounded // needs to be rounded
@ -689,6 +698,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
result.isPercent = false; result.isPercent = false;
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setExtendedBolus: OK"); log.debug("setExtendedBolus: OK");
disconnect("setExtendedBolus");
return result; return result;
} }
result.enacted = false; result.enacted = false;
@ -699,7 +709,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
} }
@Override @Override
public PumpEnactResult cancelTempBasal(boolean force) { public synchronized PumpEnactResult cancelTempBasal(boolean force) {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null) { if (runningTB != null) {
@ -707,6 +717,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
danaRSService.tempBasalStop(); danaRSService.tempBasalStop();
result.enacted = true; result.enacted = true;
result.isTempCancel = true; result.isTempCancel = true;
disconnect("cancelTempBasal");
} }
if (!pump.isTempBasalInProgress) { if (!pump.isTempBasalInProgress) {
result.success = true; result.success = true;
@ -725,7 +736,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
} }
@Override @Override
public PumpEnactResult cancelExtendedBolus() { public synchronized PumpEnactResult cancelExtendedBolus() {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()); ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (runningEB != null) { if (runningEB != null) {
@ -733,6 +744,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
danaRSService.extendedBolusStop(); danaRSService.extendedBolusStop();
result.enacted = true; result.enacted = true;
result.isTempCancel = true; result.isTempCancel = true;
disconnect("extendedBolusStop");
} }
if (!pump.isExtendedInProgress) { if (!pump.isExtendedInProgress) {
result.success = true; result.success = true;
@ -808,7 +820,28 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface,
@Override @Override
public String shortStatus(boolean veryShort) { 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 @Override

View file

@ -10,15 +10,14 @@ import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.db.DanaRHistoryRecord;
import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; 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; import info.nightscout.utils.DateUtil;
public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { 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; private int sec = 0;
public boolean done; public boolean done;
public int totalCount; private int totalCount;
public static long lastEventTimeLoaded = 0; public static long lastEventTimeLoaded = 0;
public DanaRS_Packet_APS_History_Events() { DanaRS_Packet_APS_History_Events() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS; opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS;
done = false; done = false;
@ -97,70 +96,87 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) { if (detailedBolusInfo == null) {
log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString()); log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
detailedBolusInfo = new DetailedBolusInfo(); detailedBolusInfo = new DetailedBolusInfo();
} else {
log.debug("Detailed bolus info found: " + detailedBolusInfo);
} }
detailedBolusInfo.date = datetime.getTime(); detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP; detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = datetime.getTime(); detailedBolusInfo.pumpId = datetime.getTime();
String status;
switch (recordCode) { switch (recordCode) {
case DanaRPump.TEMPSTART: case DanaRPump.TEMPSTART:
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
temporaryBasal.percentRate = param1; temporaryBasal.percentRate = param1;
temporaryBasal.durationInMinutes = param2; temporaryBasal.durationInMinutes = param2;
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
status = "TEMPSTART " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.TEMPSTOP: case DanaRPump.TEMPSTOP:
log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
status = "TEMPSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.EXTENDEDSTART: case DanaRPump.EXTENDEDSTART:
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.EXTENDEDSTOP: case DanaRPump.EXTENDEDSTOP:
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.BOLUS: case DanaRPump.BOLUS:
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date); DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "BOLUS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALBOLUS: case DanaRPump.DUALBOLUS:
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date); DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "DUALBOLUS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALEXTENDEDSTART: case DanaRPump.DUALEXTENDEDSTART:
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALEXTENDEDSTOP: case DanaRPump.DUALEXTENDEDSTOP:
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDON: case DanaRPump.SUSPENDON:
log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDON " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDOFF: case DanaRPump.SUSPENDOFF:
log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDOFF " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.REFILL: case DanaRPump.REFILL:
log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "REFILL " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PRIME: case DanaRPump.PRIME:
log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "PRIME " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PROFILECHANGE: case DanaRPump.PROFILECHANGE:
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
status = "PROFILECHANGE " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.CARBS: case DanaRPump.CARBS:
DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo(); DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo();
@ -170,17 +186,22 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
emptyCarbsInfo.pumpId = datetime.getTime(); emptyCarbsInfo.pumpId = datetime.getTime();
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo); newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo);
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
status = "CARBS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PRIMECANNULA: 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; break;
default: default:
log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
status = "UNKNOWN " + DateUtil.timeString(datetime);
break; break;
} }
if (datetime.getTime() > lastEventTimeLoaded) if (datetime.getTime() > lastEventTimeLoaded)
lastEventTimeLoaded = datetime.getTime(); lastEventTimeLoaded = datetime.getTime();
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status));
} }
@Override @Override

View file

@ -4,13 +4,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import com.cozmo.danar.util.BleCommandUtil; import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { 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 static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Basal_Rate.class);
private double[] profileBasalRate; private double[] profileBasalRate;
public int error;
public DanaRS_Packet_Basal_Set_Basal_Rate() { public DanaRS_Packet_Basal_Set_Basal_Rate() {
super(); super();
@ -38,11 +38,12 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + error); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -10,8 +10,6 @@ import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packet { 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); 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() { public DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL; 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 @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
error = byteArrayToInt(getBytes(data, DATA_START, 1)); int result = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result " + error); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -11,7 +11,6 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet {
private int profileNumber; // 0 - 4 private int profileNumber; // 0 - 4
private double[] profileBasalRate; private double[] profileBasalRate;
public int error;
public DanaRS_Packet_Basal_Set_Profile_Basal_Rate() { public DanaRS_Packet_Basal_Set_Profile_Basal_Rate() {
super(); super();
@ -41,11 +40,12 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + error); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -10,7 +10,6 @@ import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { 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 static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Profile_Number.class);
private int profileNumber; private int profileNumber;
public int error;
public DanaRS_Packet_Basal_Set_Profile_Number() { public DanaRS_Packet_Basal_Set_Profile_Number() {
super(); super();
@ -33,11 +32,12 @@ public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + error); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -8,7 +8,6 @@ import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet {
private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_Off.class); private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_Off.class);
public int error;
public DanaRS_Packet_Basal_Set_Suspend_Off() { public DanaRS_Packet_Basal_Set_Suspend_Off() {
super(); super();
@ -20,11 +19,12 @@ public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + error); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -8,7 +8,6 @@ import com.cozmo.danar.util.BleCommandUtil;
public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet {
private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_On.class); private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_On.class);
public int error;
public DanaRS_Packet_Basal_Set_Suspend_On() { public DanaRS_Packet_Basal_Set_Suspend_On() {
super(); super();
@ -20,11 +19,12 @@ public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + error); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -11,7 +11,6 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet {
private int temporaryBasalRatio; private int temporaryBasalRatio;
private int temporaryBasalDuration; private int temporaryBasalDuration;
public int error;
public DanaRS_Packet_Basal_Set_Temporary_Basal() { public DanaRS_Packet_Basal_Set_Temporary_Basal() {
super(); super();
@ -37,11 +36,12 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + error); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -111,12 +111,12 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -83,12 +83,12 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -44,12 +44,12 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -40,12 +40,12 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -19,12 +19,12 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel extends DanaRS_Packet
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -44,12 +44,12 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -48,14 +48,12 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet {
} }
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
failed = status != 0x00;
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -35,13 +35,14 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet {
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
stopped = true; stopped = true;
if (!forced) { if (!forced) {

View file

@ -31,12 +31,12 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -17,12 +17,12 @@ public class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear extends DanaR
@Override @Override
public void handleMessage(byte[] data) { public void handleMessage(byte[] data) {
int dataIndex = DATA_START; int result = intFromBuff(data, 0, 1);
int dataSize = 1;
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + status); if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
} }
} }

View file

@ -45,7 +45,10 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet {
int dataSize = 1; int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + error); if (error == 0)
log.debug("Result OK");
else
log.error("Result Error: " + error);
} }
} }

View file

@ -47,7 +47,10 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet {
int dataSize = 1; int dataSize = 1;
error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("Result: " + error); if (error == 0)
log.debug("Result OK");
else
log.error("Result Error: " + error);
} }
} }

View file

@ -165,19 +165,6 @@ public class BLEComm {
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING)); MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING));
isConnecting = true; 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); BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
if (device == null) { if (device == null) {
log.debug("Device not found. Unable to connect."); log.debug("Device not found. Unable to connect.");
@ -201,12 +188,19 @@ public class BLEComm {
public void disconnect(String from) { public void disconnect(String from) {
log.debug("disconnect from: " + 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)) { if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
return; return;
} }
setCharacteristicNotification(getUARTReadBTGattChar(), false); setCharacteristicNotification(getUARTReadBTGattChar(), false);
mBluetoothGatt.disconnect(); mBluetoothGatt.disconnect();
isConnected = false; isConnected = false;
SystemClock.sleep(2000);
} }
public void close() { public void close() {
@ -214,6 +208,7 @@ public class BLEComm {
if (mBluetoothGatt == null) { if (mBluetoothGatt == null) {
return; return;
} }
mBluetoothGatt.close(); mBluetoothGatt.close();
mBluetoothGatt = null; mBluetoothGatt = null;
} }
@ -687,18 +682,19 @@ public class BLEComm {
} }
public void scheduleDisconnection() { public void scheduleDisconnection() {
class DisconnectRunnable implements Runnable { class DisconnectRunnable implements Runnable {
public void run() { public void run() {
disconnect("scheduleDisconnection"); disconnect("scheduleDisconnection");
scheduledDisconnection = null; scheduledDisconnection = null;
} }
} }
// prepare task for execution in 5 sec // prepare task for execution in 30 sec
// cancel waiting task to prevent sending multiple disconnections // cancel waiting task to prevent sending multiple disconnections
if (scheduledDisconnection != null) if (scheduledDisconnection != null)
scheduledDisconnection.cancel(false); scheduledDisconnection.cancel(false);
Runnable task = new DisconnectRunnable(); Runnable task = new DisconnectRunnable();
final int sec = 5; final int sec = 30;
scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS); scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS);
log.debug("Disconnection scheduled"); log.debug("Disconnection scheduled");
} }

View file

@ -26,6 +26,7 @@ import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; 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.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
@ -188,16 +189,16 @@ public class DanaRSService extends Service {
while (!msg.done && bleComm.isConnected()) { while (!msg.done && bleComm.isConnected()) {
SystemClock.sleep(100); SystemClock.sleep(100);
} }
SystemClock.sleep(200);
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded; lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded;
return true; 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; bolusingTreatment = t;
int speed = SP.getInt(R.string.key_danars_bolusspeed, 0); 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, speed); 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_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 DanaRS_Packet_Notify_Delivery_Complete complete = new DanaRS_Packet_Notify_Delivery_Complete(insulin, t); // initialize static variables
@ -210,28 +211,57 @@ public class DanaRSService extends Service {
bleComm.sendMessage(msgSetHistoryEntry_v2); bleComm.sendMessage(msgSetHistoryEntry_v2);
lastHistoryFetched = carbtime - 60000; 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) { if (!stop.stopped) {
bleComm.sendMessage(start); bleComm.sendMessage(start);
} else { } else {
t.insulin = 0d; t.insulin = 0d;
return false; 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) { while (!stop.stopped && !start.failed && !complete.done) {
SystemClock.sleep(100); 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.stopped = true;
stop.forced = true; stop.forced = true;
log.debug("Communication stopped"); log.debug("Communication stopped");
} }
} }
} }
SystemClock.sleep(3000);
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.t = t;
bolusingEvent.percent = 99;
bolusingTreatment = null; 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(); loadEvents();
bolusingEvent.percent = 100;
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting)));
return true; return true;
} }

View file

@ -293,9 +293,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { 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 // 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 preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0);
int speed = 12; int speed = 12;
switch (preferencesSpeed) { switch (preferencesSpeed) {
@ -309,7 +308,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
speed = 60; speed = 60;
break; 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 // 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 // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records
double carbs = detailedBolusInfo.carbs; double carbs = detailedBolusInfo.carbs;
@ -317,6 +316,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
int carbTime = detailedBolusInfo.carbTime; int carbTime = detailedBolusInfo.carbTime;
detailedBolusInfo.carbTime = 0; detailedBolusInfo.carbTime = 0;
DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history
Treatment t = new Treatment(); Treatment t = new Treatment();
boolean connectionOK = false; boolean connectionOK = false;
if (detailedBolusInfo.insulin > 0 || carbs > 0) if (detailedBolusInfo.insulin > 0 || carbs > 0)

View file

@ -188,12 +188,12 @@ public class SerialIOThread extends Thread {
scheduledDisconnection = null; scheduledDisconnection = null;
} }
} }
// prepare task for execution in 5 sec // prepare task for execution in 10 sec
// cancel waiting task to prevent sending multiple disconnections // cancel waiting task to prevent sending multiple disconnections
if (scheduledDisconnection != null) if (scheduledDisconnection != null)
scheduledDisconnection.cancel(false); scheduledDisconnection.cancel(false);
Runnable task = new DisconnectRunnable(); Runnable task = new DisconnectRunnable();
final int sec = 5; final int sec = 10;
scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS); scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS);
} }

View file

@ -7,13 +7,16 @@ import java.util.Date;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
import info.nightscout.utils.DateUtil;
public class MsgHistoryEvents_v2 extends MessageBase { public class MsgHistoryEvents_v2 extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgHistoryEvents_v2.class); 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()); DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) { if (detailedBolusInfo == null) {
log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString()); log.debug("Detailed bolus info not found for " + datetime.toLocaleString());
detailedBolusInfo = new DetailedBolusInfo(); detailedBolusInfo = new DetailedBolusInfo();
} else {
log.debug("Detailed bolus info found: " + detailedBolusInfo);
} }
detailedBolusInfo.date = datetime.getTime(); detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP; detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = datetime.getTime(); detailedBolusInfo.pumpId = datetime.getTime();
String status = "";
switch (recordCode) { switch (recordCode) {
case DanaRPump.TEMPSTART: case DanaRPump.TEMPSTART:
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
temporaryBasal.percentRate = param1; temporaryBasal.percentRate = param1;
temporaryBasal.durationInMinutes = param2; temporaryBasal.durationInMinutes = param2;
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
status = "TEMPSTART " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.TEMPSTOP: case DanaRPump.TEMPSTOP:
log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
status = "TEMPSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.EXTENDEDSTART: case DanaRPump.EXTENDEDSTART:
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.EXTENDEDSTOP: case DanaRPump.EXTENDEDSTOP:
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.BOLUS: case DanaRPump.BOLUS:
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date); DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "BOLUS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALBOLUS: case DanaRPump.DUALBOLUS:
detailedBolusInfo.insulin = param1 / 100d; detailedBolusInfo.insulin = param1 / 100d;
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
DetailedBolusInfoStorage.remove(detailedBolusInfo.date); DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
status = "DUALBOLUS " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALEXTENDEDSTART: case DanaRPump.DUALEXTENDEDSTART:
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
extendedBolus.insulin = param1 / 100d; extendedBolus.insulin = param1 / 100d;
extendedBolus.durationInMinutes = param2; extendedBolus.durationInMinutes = param2;
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.DUALEXTENDEDSTOP: case DanaRPump.DUALEXTENDEDSTOP:
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDON: case DanaRPump.SUSPENDON:
log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDON " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.SUSPENDOFF: case DanaRPump.SUSPENDOFF:
log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString());
status = "SUSPENDOFF " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.REFILL: case DanaRPump.REFILL:
log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "REFILL " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PRIME: case DanaRPump.PRIME:
log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
status = "PRIME " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.PROFILECHANGE: case DanaRPump.PROFILECHANGE:
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
status = "PROFILECHANGE " + DateUtil.timeString(datetime);
break; break;
case DanaRPump.CARBS: case DanaRPump.CARBS:
DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo(); DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo();
@ -138,14 +158,17 @@ public class MsgHistoryEvents_v2 extends MessageBase {
emptyCarbsInfo.pumpId = datetime.getTime(); emptyCarbsInfo.pumpId = datetime.getTime();
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo); newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo);
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
status = "CARBS " + DateUtil.timeString(datetime);
break; break;
default: default:
log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2);
status = "UNKNOWN " + DateUtil.timeString(datetime);
break; break;
} }
if (datetime.getTime() > lastEventTimeLoaded) if (datetime.getTime() > lastEventTimeLoaded)
lastEventTimeLoaded = datetime.getTime(); lastEventTimeLoaded = datetime.getTime();
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status));
} }
} }

View file

@ -36,6 +36,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; 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.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.*; import info.nightscout.androidaps.plugins.PumpDanaR.comm.*;
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
@ -400,14 +401,15 @@ public class DanaRv2ExecutionService extends Service {
return true; 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; 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; MessageBase start;
if (speed == 0) if (preferencesSpeed == 0)
start = new MsgBolusStart(amount); start = new MsgBolusStart(amount);
else else
start = new MsgBolusStartWithSpeed(amount, speed); start = new MsgBolusStartWithSpeed(amount, preferencesSpeed);
MsgBolusStop stop = new MsgBolusStop(amount, t); MsgBolusStop stop = new MsgBolusStop(amount, t);
connect("bolus"); connect("bolus");
@ -420,6 +422,8 @@ public class DanaRv2ExecutionService extends Service {
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2); mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
lastHistoryFetched = carbtime - 60000; lastHistoryFetched = carbtime - 60000;
} }
final long bolusStart = System.currentTimeMillis();
if (amount > 0) { if (amount > 0) {
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
@ -431,26 +435,46 @@ public class DanaRv2ExecutionService extends Service {
} }
while (!stop.stopped && !start.failed) { while (!stop.stopped && !start.failed) {
waitMsec(100); 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.stopped = true;
stop.forced = true; stop.forced = true;
log.debug("Communication stopped"); log.debug("Communication stopped");
} }
} }
} }
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
bolusingEvent.t = t;
bolusingEvent.percent = 99;
bolusingTreatment = null; bolusingTreatment = null;
// run loading history in separate thread and allow bolus dialog to be closed int speed = 12;
new Thread(new Runnable() { switch (preferencesSpeed) {
@Override case 0:
public void run() { speed = 12;
waitMsec(4000); 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())) if (!(isConnected()))
connect("loadEvents"); connect("loadEvents");
loadEvents(); loadEvents();
} bolusingEvent.percent = 100;
}).start(); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting)));
return true; return true;
} }
public void bolusStop() { public void bolusStop() {
if (Config.logDanaBTComm) if (Config.logDanaBTComm)

View file

@ -5,11 +5,9 @@ import android.support.v4.util.LongSparseArray;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
@ -32,7 +30,7 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity
private boolean fragmentEnabled = true; private boolean fragmentEnabled = true;
private boolean fragmentVisible = false; private boolean fragmentVisible = false;
static SensitivityWeightedAveragePlugin plugin = null; private static SensitivityWeightedAveragePlugin plugin = null;
public static SensitivityWeightedAveragePlugin getPlugin() { public static SensitivityWeightedAveragePlugin getPlugin() {
if (plugin == null) if (plugin == null)
@ -108,12 +106,14 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity
int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours); int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours);
if (autosensDataTable == null || autosensDataTable.size() < 4) { if (autosensDataTable == null || autosensDataTable.size() < 4) {
if (Config.logAutosensData)
log.debug("No autosens data available"); log.debug("No autosens data available");
return new AutosensResult(); return new AutosensResult();
} }
AutosensData current = IobCobCalculatorPlugin.getAutosensData(toTime); AutosensData current = IobCobCalculatorPlugin.getAutosensData(toTime);
if (current == null) { if (current == null) {
if (Config.logAutosensData)
log.debug("No autosens data available"); log.debug("No autosens data available");
return new AutosensResult(); return new AutosensResult();
} }
@ -181,8 +181,9 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity
double sens = profile.getIsf(); double sens = profile.getIsf();
String ratioLimit = ""; String ratioLimit = "";
String sensResult = ""; String sensResult;
if (Config.logAutosensData)
log.debug("Records: " + index + " " + pastSensitivity); log.debug("Records: " + index + " " + pastSensitivity);
double average = weightedsum / weights; double average = weightedsum / weights;
@ -197,6 +198,7 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity
sensResult = "Sensitivity normal"; sensResult = "Sensitivity normal";
} }
if (Config.logAutosensData)
log.debug(sensResult); log.debug(sensResult);
double rawRatio = ratio; double rawRatio = ratio;
@ -205,9 +207,11 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity
if (ratio != rawRatio) { if (ratio != rawRatio) {
ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio; ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
if (Config.logAutosensData)
log.debug(ratioLimit); log.debug(ratioLimit);
} }
if (Config.logAutosensData)
log.debug("Sensitivity to: " + new Date(toTime).toLocaleString() + " weightedaverage: " + average + " ratio: " + ratio); log.debug("Sensitivity to: " + new Date(toTime).toLocaleString() + " weightedaverage: " + average + " ratio: " + ratio);
AutosensResult output = new AutosensResult(); AutosensResult output = new AutosensResult();

View file

@ -72,9 +72,9 @@
<string name="duration">Срок</string> <string name="duration">Срок</string>
<string name="reason">Основание</string> <string name="reason">Основание</string>
<string name="glucose">Кръвна захар</string> <string name="glucose">Кръвна захар</string>
<string name="delta">Промяна</string> <string name="delta">Изменение (Δ)</string>
<string name="sms_delta">Delta:</string> <string name="sms_delta">Delta:</string>
<string name="avgdelta">Средна промяна</string> <string name="avgdelta">Средно изменение (Δ),</string>
<string name="configbuilder">Конфигурация</string> <string name="configbuilder">Конфигурация</string>
<string name="objectives">Цели</string> <string name="objectives">Цели</string>
<string name="openapsma">OpenAPS MA</string> <string name="openapsma">OpenAPS MA</string>
@ -85,8 +85,6 @@
<string name="treatments">Лечения</string> <string name="treatments">Лечения</string>
<string name="virtualpump">Виртуална помпа</string> <string name="virtualpump">Виртуална помпа</string>
<string name="careportal">Careportal</string> <string name="careportal">Careportal</string>
<string name="configbuilder_pump">Помпа</string> <string name="configbuilder_pump">Помпа</string>
<string name="configbuilder_treatments">Treatments</string> <string name="configbuilder_treatments">Treatments</string>
<string name="configbuilder_tempbasals">Временен базал</string> <string name="configbuilder_tempbasals">Временен базал</string>
@ -140,7 +138,7 @@
<string name="unsupportednsversion">Несъвместима версия на Nightscout</string> <string name="unsupportednsversion">Несъвместима версия на Nightscout</string>
<string name="nsclientnotinstalled">NSClient не е открит. Записът е загубен!</string> <string name="nsclientnotinstalled">NSClient не е открит. Записът е загубен!</string>
<string name="objectives_bgavailableinns">КЗ да се вижда в NS</string> <string name="objectives_bgavailableinns">КЗ да се вижда в NS</string>
<string name="objectives_pumpstatusavailableinns">Статуса на помпа да е достъпен в NS</string> <string name="objectives_pumpstatusavailableinns">Статуса на помпата да е достъпен в NS</string>
<string name="objectives_manualenacts">Ръчно приложени</string> <string name="objectives_manualenacts">Ръчно приложени</string>
<string name="loopdisabled">LOOP Е СПРЯН ОТ ОГРАНИЧЕНИЯТА</string> <string name="loopdisabled">LOOP Е СПРЯН ОТ ОГРАНИЧЕНИЯТА</string>
<string name="cs_lang">Czech</string> <string name="cs_lang">Czech</string>
@ -370,7 +368,7 @@
<string name="open_settings_on_wear">Отвори настройките на часовника</string> <string name="open_settings_on_wear">Отвори настройките на часовника</string>
<string name="pumperror">Грешка в промпата</string> <string name="pumperror">Грешка в промпата</string>
<string name="lowbattery">Изтощена батерия</string> <string name="lowbattery">Изтощена батерия</string>
<string name="pumpshutdown">Помпа изключена</string> <string name="pumpshutdown">Помпата е изключена</string>
<string name="batterydischarged">Батерията на помпата е изтощена</string> <string name="batterydischarged">Батерията на помпата е изтощена</string>
<string name="danarkoreanpump">DanaR Korean</string> <string name="danarkoreanpump">DanaR Korean</string>
<string name="wrongpumpdriverselected">Избран е грешен тип помпа</string> <string name="wrongpumpdriverselected">Избран е грешен тип помпа</string>
@ -448,7 +446,7 @@
<string name="openapsama_autosens_adjusttargets_summary">По подразбиране: разрешено\nТова позволява на autosens да променя и целевите КЗ(освен чувствителност и базал).</string> <string name="openapsama_autosens_adjusttargets_summary">По подразбиране: разрешено\nТова позволява на autosens да променя и целевите КЗ(освен чувствителност и базал).</string>
<string name="openapsama_bolussnooze_dia_divisor_summary">По подразбиране: 2\nBolus snooze се активира след като поставите болус за основно хранене, така Loop няма да пуснка/намаля базалите веднага след като сте се хранили. Примерът тук е с 2; така при 3 часа DIA това ще означава че bolus snooze ще бъде внимателно изместен 1.5 часа (3DIA/2).</string> <string name="openapsama_bolussnooze_dia_divisor_summary">По подразбиране: 2\nBolus snooze се активира след като поставите болус за основно хранене, така Loop няма да пуснка/намаля базалите веднага след като сте се хранили. Примерът тук е с 2; така при 3 часа DIA това ще означава че bolus snooze ще бъде внимателно изместен 1.5 часа (3DIA/2).</string>
<string name="openapsama_min_5m_carbimpact_summary">По подразбиране: 3.0\nТова е настройка на количеството на покачване на КЗ при усвояване на въглехидратите за всеки 5 минути. По подразбиране 3мг/дл/5мин. Това се отразява на това колко бързо се усвояват COB според алгоритъма, и как това се отразява в предвиждането на КЗ, когато тя не се покачва или пада с различен темп от очакваното.</string> <string name="openapsama_min_5m_carbimpact_summary">По подразбиране: 3.0\nТова е настройка на количеството на покачване на КЗ при усвояване на въглехидратите за всеки 5 минути. По подразбиране 3мг/дл/5мин. Това се отразява на това колко бързо се усвояват COB според алгоритъма, и как това се отразява в предвиждането на КЗ, когато тя не се покачва или пада с различен темп от очакваното.</string>
<string name="openapsama_link_to_preferncejson_doc_txt">Внимание! Обикновенно вие не трябва да променяте тези стойности. Моля НАТИСНЕТЕ ТУК, ПРОЧЕТЕТЕ текста и бъдете сигурни, че вие го РАЗБИРАТЕ преди да направите промени на тези стойности!</string> <string name="openapsama_link_to_preferncejson_doc_txt">Внимание! Обикновено Вие не трябва да променяте тези стойности. Моля НАТИСНЕТЕ ТУК, прочетете текста и бъдете сигурни, че го РАЗБИРАТЕ преди да направите каквито и да е промени!</string>
<string name="openapsama_link_to_preferncejson_doc">http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html</string> <string name="openapsama_link_to_preferncejson_doc">http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html</string>
<string name="error_only_numeric_digits_allowed">Позволени са само числа</string> <string name="error_only_numeric_digits_allowed">Позволени са само числа</string>
<string name="error_only_numeric_digits_range_allowed" formatted="false">Позволени са числа между %1$s - %2$s</string> <string name="error_only_numeric_digits_range_allowed" formatted="false">Позволени са числа между %1$s - %2$s</string>
@ -529,7 +527,7 @@
<string name="smscommunicator_wrongduration">Wrong duration</string> <string name="smscommunicator_wrongduration">Wrong duration</string>
<string name="smscommunicator_loopsuspended">Loop suspended</string> <string name="smscommunicator_loopsuspended">Loop suspended</string>
<string name="smscommunicator_loopresumed">Loop resumed</string> <string name="smscommunicator_loopresumed">Loop resumed</string>
<string name="treatments_wizard_bgtrend_label">промяна за 15мин</string> <string name="treatments_wizard_bgtrend_label">Δ за 15мин</string>
<string name="treatments_wizard_cob_label">COB</string> <string name="treatments_wizard_cob_label">COB</string>
<string name="superbolus">Суперболус</string> <string name="superbolus">Суперболус</string>
<string name="ns_logappstartedevent">Записвай всяко стартиране на AndroidAPS в NS</string> <string name="ns_logappstartedevent">Записвай всяко стартиране на AndroidAPS в NS</string>
@ -652,7 +650,7 @@
<string name="activity_duration">време за физ. активност</string> <string name="activity_duration">време за физ. активност</string>
<string name="activity_target">Целева КЗ при физ. активност</string> <string name="activity_target">Целева КЗ при физ. активност</string>
<string name="bolusspeed">Скорост на болус</string> <string name="bolusspeed">Скорост на болус</string>
<string name="careportal_newnstreatment_percentage_label">% промяна</string> <string name="careportal_newnstreatment_percentage_label">% от профила</string>
<string name="careportal_newnstreatment_timeshift_label">Време на отместване</string> <string name="careportal_newnstreatment_timeshift_label">Време на отместване</string>
<string name="danars_nodeviceavailable">Все още устройството не е намерено</string> <string name="danars_nodeviceavailable">Все още устройството не е намерено</string>
<string name="danarspump">DanaRS</string> <string name="danarspump">DanaRS</string>
@ -663,14 +661,14 @@
<string name="emptyreservoir">Празен резервоар</string> <string name="emptyreservoir">Празен резервоар</string>
<string name="gettingbolusstatus">Получава болус статус</string> <string name="gettingbolusstatus">Получава болус статус</string>
<string name="gettingextendedbolusstatus">Получава статус на удължен болус</string> <string name="gettingextendedbolusstatus">Получава статус на удължен болус</string>
<string name="gettingpumpsettings">Получава настройки на помпа</string> <string name="gettingpumpsettings">Получава настройките на помпата</string>
<string name="gettingpumptime">Получава време на помпата</string> <string name="gettingpumptime">Получава времето на помпата</string>
<string name="gettingtempbasalstatus">Получава статус на временен базал</string> <string name="gettingtempbasalstatus">Получава статус на временен базал</string>
<string name="pairing">СДВОЯВАНЕ</string> <string name="pairing">СДВОЯВАНЕ</string>
<string name="pairingok">Сдвоени</string> <string name="pairingok">Сдвоени</string>
<string name="pairingtimedout">Времето за сдвояване изтече</string> <string name="pairingtimedout">Времето за сдвояване изтече</string>
<string name="pairpump">Сдвояване с нова помпа</string> <string name="pairpump">Сдвояване с нова помпа</string>
<string name="reuse">опитва отново</string> <string name="reuse">отново</string>
<string name="selectedpump">Избрана помпа</string> <string name="selectedpump">Избрана помпа</string>
<string name="serialnumber">Сериен номер</string> <string name="serialnumber">Сериен номер</string>
<string name="treatments_wizard_tt_label">ЛЕЧ</string> <string name="treatments_wizard_tt_label">ЛЕЧ</string>

View file

@ -659,4 +659,8 @@
<string name="wearcontrol_summary">Nastavování dočasných cílů a vkládání ošetření na hodinkách Wear</string> <string name="wearcontrol_summary">Nastavování dočasných cílů a vkládání ošetření na hodinkách Wear</string>
<string name="wearcontrol_title">Řízení z hodinek Wear</string> <string name="wearcontrol_title">Řízení z hodinek Wear</string>
<string name="danar_model" formatted="false">Model: %02X Protokol: %02X Kód: %02X</string> <string name="danar_model" formatted="false">Model: %02X Protokol: %02X Kód: %02X</string>
<string name="active"><![CDATA[<Aktivní>]]></string>
<string name="bloodsugarmeasurementalert">Výstraha měření glykémie</string>
<string name="connectiontimedout">Vypršel čas připojování</string>
<string name="treatments_wizard_tt_label">DC</string>
</resources> </resources>

View file

@ -165,7 +165,7 @@
<string name="loopdisabled">LOOP DEAKTIVIERT DURCH DIE BESCHRÄNKUNG</string> <string name="loopdisabled">LOOP DEAKTIVIERT DURCH DIE BESCHRÄNKUNG</string>
<string name="loop_constraintsprocessed_label">Nach Beschränkungen</string> <string name="loop_constraintsprocessed_label">Nach Beschränkungen</string>
<string name="loop">Loop</string> <string name="loop">Loop</string>
<string name="objectives_manualenacts">Manual enacts</string> <string name="objectives_manualenacts">Manuelle Eingriffe</string>
<string name="carbsconstraintapplied">Kohlenhydrate Beschränkung erreicht</string> <string name="carbsconstraintapplied">Kohlenhydrate Beschränkung erreicht</string>
<string name="nav_resetdb">Reset Datenbanken</string> <string name="nav_resetdb">Reset Datenbanken</string>
<string name="objectives_minimalduration">Minimale Dauer</string> <string name="objectives_minimalduration">Minimale Dauer</string>
@ -231,7 +231,7 @@
<string name="nobtadapter">Kein Bluetoothadapter gefunden</string> <string name="nobtadapter">Kein Bluetoothadapter gefunden</string>
<string name="smscommunicator_remotebolusnotallowed">Remote Bolus ist nicht erlaubt</string> <string name="smscommunicator_remotebolusnotallowed">Remote Bolus ist nicht erlaubt</string>
<string formatted="false" name="smscommunicator_bolusreplywithcode">Um Bolus %.2fU bitte mit %s antworten</string> <string formatted="false" name="smscommunicator_bolusreplywithcode">Um Bolus %.2fU bitte mit %s antworten</string>
<string name="ko_lang">Koreanisch</string> <string name="ko_lang">Korean</string>
<string name="youareonallowedlimit">Limit erreicht</string> <string name="youareonallowedlimit">Limit erreicht</string>
<string name="wrongpumppassword">Falsches Pumpen-Passwort!</string> <string name="wrongpumppassword">Falsches Pumpen-Passwort!</string>
<string name="waitingforpumpclicktorefresh">Warte auf Pumpe. Klicke zum aktualisieren.</string> <string name="waitingforpumpclicktorefresh">Warte auf Pumpe. Klicke zum aktualisieren.</string>
@ -314,8 +314,8 @@
<string name="loop_shortname">LOOP</string> <string name="loop_shortname">LOOP</string>
<string name="localprofile_shortname">LP</string> <string name="localprofile_shortname">LP</string>
<string name="danarpump_shortname">DANA</string> <string name="danarpump_shortname">DANA</string>
<string name="configbuilder_shortname">"CONF"</string> <string name="configbuilder_shortname">CONF</string>
<string name="circadian_percentage_profile_shortname">"CPP"</string> <string name="circadian_percentage_profile_shortname">CPP</string>
<string name="careportal_shortname">CP</string> <string name="careportal_shortname">CP</string>
<string name="error_only_numeric_digits_allowed">Bitte verwenden Sie nur Ziffern.</string> <string name="error_only_numeric_digits_allowed">Bitte verwenden Sie nur Ziffern.</string>
<string name="error_field_must_not_be_empty">Pflichtfeld</string> <string name="error_field_must_not_be_empty">Pflichtfeld</string>
@ -591,7 +591,7 @@
<string name="configbuilder_sensitivity">Empfindlichkeitserkennung</string> <string name="configbuilder_sensitivity">Empfindlichkeitserkennung</string>
<string name="cob">COB</string> <string name="cob">COB</string>
<string name="enablesuperbolus_summary">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!</string> <string name="enablesuperbolus_summary">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!</string>
<string name="objectives_2_objective">"Verstehen des OpenLoops und der Temp-Basal-Empfehlungen</string> <string name="objectives_2_objective">Verstehen des OpenLoops und der Temp-Basal-Empfehlungen</string>
<string name="openapsama_useautosens">Verwende AMA Autosense</string> <string name="openapsama_useautosens">Verwende AMA Autosense</string>
<string formatted="false" name="smscommunicator_basalreplywithcode">Um Basal mit %.2fU/h zu starten, antworte mit dem Code %s</string> <string formatted="false" name="smscommunicator_basalreplywithcode">Um Basal mit %.2fU/h zu starten, antworte mit dem Code %s</string>
<string name="ultrafastactinginsulincomment">Fiasp</string> <string name="ultrafastactinginsulincomment">Fiasp</string>

View file

@ -49,9 +49,9 @@
</string-array> </string-array>
<string-array name="danaSpeedArray"> <string-array name="danaSpeedArray">
<item>12s 1U</item> <item>12 s/U</item>
<item>30s 1U</item> <item>30 s/U</item>
<item>60s 1U</item> <item>60 s/U</item>
</string-array> </string-array>
<string-array name="danaSpeedValues"> <string-array name="danaSpeedValues">
<item>0</item> <item>0</item>

View file

@ -746,5 +746,9 @@
<string name="wearcontrol_title">Controls from Watch</string> <string name="wearcontrol_title">Controls from Watch</string>
<string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string> <string name="wearcontrol_summary">Set Temp-Targets and enter Treatments from the watch.</string>
<string name="connectiontimedout">Connection timed out</string> <string name="connectiontimedout">Connection timed out</string>
<string name="active"><![CDATA[<Active>]]></string>
<string name="waitingforestimatedbolusend" formatted="false">Waiting for estimated bolus end. Remaining %d sec.</string>
<string name="processinghistory">Processing event</string>
<string name="startingbolus">Starting bolus delivery</string>
</resources> </resources>