Merge remote-tracking branch 'milosremote/dev' into develop

This commit is contained in:
Timm Korte 2017-08-10 11:13:21 +02:00
commit e7249bf72e
11 changed files with 144 additions and 19 deletions

View file

@ -950,6 +950,10 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
if (tempBasal.source == Source.NIGHTSCOUT) {
old = getDaoTemporaryBasal().queryForId(tempBasal.date);
if (old != null) {
if (!old.isAbsolute && tempBasal.isAbsolute) { // converted to absolute by "ns_sync_use_absolute"
// so far ignore, do not convert back because it may not be accurate
return false;
}
if (!old.isEqual(tempBasal)) {
long oldDate = old.date;
getDaoTemporaryBasal().delete(old); // need to delete/create because date may change too

View file

@ -0,0 +1,41 @@
package info.nightscout.androidaps.plugins.ConfigBuilder;
import android.support.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.data.DetailedBolusInfo;
/**
* Created by mike on 08.08.2017.
*/
public class DetailedBolusInfoStorage {
private static Logger log = LoggerFactory.getLogger(DetailedBolusInfoStorage.class);
private static List<DetailedBolusInfo> store = new ArrayList<>();
public static void add(DetailedBolusInfo detailedBolusInfo) {
log.debug("Bolus info stored: " + new Date(detailedBolusInfo.date).toLocaleString());
store.add(detailedBolusInfo);
}
@Nullable
public static DetailedBolusInfo findDetailedBolusInfo(long bolustime) {
DetailedBolusInfo found = null;
for (int i = 0; i < store.size(); i++) {
long infoTime = store.get(0).date;
log.debug("Existing info: " + new Date(infoTime).toLocaleString());
if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) {
found = store.get(i);
store.remove(i);
break;
}
}
return found;
}
}

View file

@ -522,20 +522,22 @@ public class IobCobCalculatorPlugin implements PluginBase {
@Nullable
public static AutosensData getAutosensData(long time) {
long now = System.currentTimeMillis();
if (time > now)
return null;
Long previous = findPreviousTimeFromBucketedData(time);
if (previous == null)
return null;
time = roundUpTime(previous);
AutosensData data = autosensDataTable.get(time);
if (data != null) {
//log.debug(">>> getAutosensData Cache hit " + data.log(time));
return data;
} else {
//log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString());
return null;
synchronized (dataLock) {
long now = System.currentTimeMillis();
if (time > now)
return null;
Long previous = findPreviousTimeFromBucketedData(time);
if (previous == null)
return null;
time = roundUpTime(previous);
AutosensData data = autosensDataTable.get(time);
if (data != null) {
//log.debug(">>> getAutosensData Cache hit " + data.log(time));
return data;
} else {
//log.debug(">>> getAutosensData Cache miss " + new Date(time).toLocaleString());
return null;
}
}
}

View file

@ -66,6 +66,8 @@ public class DanaRv2Fragment extends SubscriberFragment {
TextView reservoirView;
TextView iobView;
TextView firmwareView;
TextView basalStepView;
TextView bolusStepView;
Button viewProfileButton;
Button historyButton;
Button statsButton;
@ -112,6 +114,8 @@ public class DanaRv2Fragment extends SubscriberFragment {
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
historyButton = (Button) view.findViewById(R.id.danar_history);
statsButton = (Button) view.findViewById(R.id.danar_stats);
basalStepView = (TextView) view.findViewById(R.id.danar_basalstep);
bolusStepView = (TextView) view.findViewById(R.id.danar_bolusstep);
viewProfileButton.setOnClickListener(new View.OnClickListener() {
@ -236,6 +240,8 @@ public class DanaRv2Fragment extends SubscriberFragment {
} else {
firmwareView.setText("OLD");
}
basalStepView.setText("" + pump.basalStep);
bolusStepView.setText("" + pump.bolusStep);
}
});

View file

@ -39,6 +39,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
@ -286,6 +287,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history
Treatment t = new Treatment(detailedBolusInfo.insulinInterface);
boolean connectionOK = false;
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
@ -297,6 +299,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
if (Config.logPumpActions)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
// remove carbs because it's get from history seprately
return result;
} else {
PumpEnactResult result = new PumpEnactResult();

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
@ -62,7 +63,15 @@ public class MsgHistoryEvents_v2 extends MessageBase {
extendedBolus.source = Source.PUMP;
extendedBolus.pumpId = datetime.getTime();
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime());
if (detailedBolusInfo == null) {
log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString());
detailedBolusInfo = new DetailedBolusInfo();
} else {
log.debug("DetailedBolusInfo found for " + datetime.toLocaleString() + ": " + new Date(detailedBolusInfo.date).toLocaleString());
detailedBolusInfo.carbTime = 0;
detailedBolusInfo.carbs = 0;
}
detailedBolusInfo.date = datetime.getTime();
detailedBolusInfo.source = Source.PUMP;
detailedBolusInfo.pumpId = datetime.getTime();
@ -122,7 +131,7 @@ public class MsgHistoryEvents_v2 extends MessageBase {
log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U");
break;
case DanaRPump.PROFILECHANGE:
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + "U CurrentRate: " + param2 + "U/h");
log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h");
break;
case DanaRPump.CARBS:
log.debug("EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");

View file

@ -502,6 +502,7 @@ public class DanaRv2ExecutionService extends Service {
public boolean loadEvents() {
if (!isConnected()) return false;
waitMsec(300);
MsgHistoryEvents_v2 msg;
if (lastHistoryFetched == 0) {
msg = new MsgHistoryEvents_v2();

View file

@ -12,7 +12,7 @@
<string name="careportal_newnstreatment_sensor">Sensor</string>
<string name="configbuilder_profile">Profil</string>
<string name="configbuilder_pump">Pumpe</string>
<string name="confirmation">Konfiguration</string>
<string name="confirmation">Bestätigung</string>
<string name="days">Tage</string>
<string name="ok">OK</string>
<string name="openapsma_profile_label">Profil</string>
@ -109,8 +109,8 @@
<string name="treatments_newtreatment_carbsamount_label">Kohlehydrat Menge</string>
<string name="treatments_newtreatment_insulinamount_label">Insulin Menge</string>
<string name="treatments">Treatments</string>
<string name="treatmentssafety_maxbolus_title">Max erlaubter Bolus</string>
<string name="treatmentssafety_maxcarbs_title">Max erlaubte Kohlehydrate</string>
<string name="treatmentssafety_maxbolus_title">Max erlaubter Bolus [U]</string>
<string name="treatmentssafety_maxcarbs_title">Max erlaubte Kohlehydrate [g]</string>
<string name="treatmentssafety_title">Tratments Sicherheit</string>
<string name="simpleprofile">Einfaches Profil</string>
<string name="setextendedbolusquestion">Setze neuen extended Bolus:</string>

View file

@ -1,5 +1,25 @@
apply plugin: 'com.android.application'
def generateGitBuild = { ->
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append('"')
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--always'
standardOutput = stdout
}
String commitObject = stdout.toString().trim()
stringBuilder.append(commitObject)
} catch (ignored) {
stringBuilder.append('NoGitSystemAvailable')
}
stringBuilder.append('-')
stringBuilder.append((new Date()).format('yyyy.MM.dd'))
stringBuilder.append('"')
return stringBuilder.toString()
}
android {
compileSdkVersion 23
@ -11,6 +31,7 @@ android {
targetSdkVersion 23
versionCode 1
versionName "1.0.2"
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}
buildTypes {
release {

View file

@ -0,0 +1,31 @@
package info.nightscout.androidaps.interaction.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.Toast;
import info.nightscout.androidaps.BuildConfig;
import preference.WearListPreference;
/**
* Created by adrian on 07/08/17.
*/
public class VersionPreference extends WearListPreference {
public VersionPreference(Context context, AttributeSet attrs) {
super(context, attrs);
entries = new CharSequence[]{BuildConfig.BUILDVERSION};
entryValues = new CharSequence[]{BuildConfig.BUILDVERSION};
}
@Override public CharSequence getSummary(@NonNull final Context context) {
return BuildConfig.BUILDVERSION;
}
@Override
public void onPreferenceClick(@NonNull Context context) {
Toast.makeText(context, "Build version:" + BuildConfig.BUILDVERSION, Toast.LENGTH_LONG).show();
}
}

View file

@ -149,4 +149,11 @@
android:title="Wizard Percentage"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
<info.nightscout.androidaps.interaction.utils.VersionPreference
android:defaultValue="1"
android:entries="@array/input_design"
android:entryValues="@array/input_design_values"
android:key="version_number"
android:summary="Input Design"
android:title="Version:" />
</PreferenceScreen>