Merge remote-tracking branch 'origin/dev' into combo-scripter-v2

* origin/dev:
  Cockpit watch face: Double-tap opens MainMenuActivity
  prevent processing incomplete profiles
  set defaults for display range
  actual bg in objective 1
  warn if wrong profile is detected
This commit is contained in:
Johannes Mockenhaupt 2018-01-06 00:30:04 +01:00
commit 3aafcc9854
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
10 changed files with 55 additions and 31 deletions

View file

@ -172,8 +172,16 @@ public class Profile {
tas = getShitfTimeSecs(DateUtil.toSeconds(time));
//log.debug(">>>>>>>>>>>> Used recalculated timeAsSecons: " + time + " " + tas);
}
Double value = o.getDouble("value") * multiplier;
double value = o.getDouble("value") * multiplier;
sparse.put(tas, value);
if (tas % 3600 != 0) {
Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, MainApp.sResources.getString(R.string.basalprofilenotaligned), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
if (value == 0) {
Notification notification = new Notification(Notification.ZERO_VALUE_IN_PROFILE, MainApp.sResources.getString(R.string.zerovalueinprofile), Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
}
} catch (JSONException e) {
log.error("Unhandled exception", e);
log.error(json.toString());

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
@ -160,19 +161,21 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
boolean isVirtualPump = VirtualPumpPlugin.getPlugin().isEnabled(PluginBase.PUMP);
boolean vpUploadEnabled = SP.getBoolean("virtualpump_uploadstatus", false);
boolean vpUploadNeeded = !isVirtualPump || vpUploadEnabled;
boolean hasBGData = DatabaseHelper.lastBg()!=null;
boolean apsEnabled = false;
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS))
apsEnabled = true;
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientInternalPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP) && apsEnabled && vpUploadNeeded,
return new RequirementResult(hasBGData&&bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientInternalPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP) && apsEnabled && vpUploadNeeded,
MainApp.sResources.getString(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS)
+ " " + MainApp.sResources.getString(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientInternalPlugin.getPlugin().hasWritePermission())
+ (isVirtualPump ? " " + MainApp.sResources.getString(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "")
+ " " + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS)
+ " " + MainApp.sResources.getString(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP))
+ " " + MainApp.sResources.getString(R.string.apsselected) + ": " + yesOrNo(apsEnabled)
+ "\n" + MainApp.sResources.getString(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientInternalPlugin.getPlugin().hasWritePermission())
+ (isVirtualPump ? "\n" + MainApp.sResources.getString(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "")
+ "\n" + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS)
+ "\n" + MainApp.sResources.getString(R.string.hasbgdata) + ": " + yesOrNo(hasBGData)
+ "\n" + MainApp.sResources.getString(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP))
+ "\n" + MainApp.sResources.getString(R.string.apsselected) + ": " + yesOrNo(apsEnabled)
);
case 1:
return new RequirementResult(manualEnacts >= manualEnactsNeeded,

View file

@ -941,8 +941,16 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
return;
}
final double lowLine = SP.getDouble("low_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units));
final double highLine = SP.getDouble("high_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units));
double lowLineSetting = SP.getDouble("low_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units));
double highLineSetting = SP.getDouble("high_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units));
if (lowLineSetting < 1)
lowLineSetting = Profile.fromMgdlToUnits(76d, units);
if (highLineSetting < 1)
highLineSetting = Profile.fromMgdlToUnits(180d, units);
final double lowLine = lowLineSetting;
final double highLine = highLineSetting;
//Start with updating the BG as it is unaffected by loop.
// **** BG value ****

View file

@ -58,6 +58,8 @@ public class Notification {
public static final int BG_READINGS_MISSED = 27;
public static final int UNSUPPORTED_FIRMWARE = 28;
public static final int MINIMAL_BASAL_VALUE_REPLACED = 29;
public static final int BASAL_PROFILE_NOT_ALIGNED_TO_HOURS = 30;
public static final int ZERO_VALUE_IN_PROFILE = 31;
public int id;
public Date date;

View file

@ -162,9 +162,6 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
baseic[i] = SP.getDouble(SETTINGS_PREFIX + "baseic" + i, baseic[i]);
baseisf[i] = SP.getDouble(SETTINGS_PREFIX + "baseisf" + i, baseisf[i]);
}
createConvertedProfile();
}
public String externallySetParameters(int timeshift, int percentage) {
@ -347,6 +344,9 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
@Override
public ProfileStore getProfile() {
if (convertedProfile == null)
createConvertedProfile();
performLimitCheck();
return convertedProfile;
}
@ -358,6 +358,9 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
@Override
public String getProfileName() {
if (convertedProfile == null)
createConvertedProfile();
performLimitCheck();
return convertedProfileName;
}

View file

@ -178,7 +178,6 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
} catch (JSONException ignored) {
}
}
createConvertedProfile();
}
/*
@ -244,6 +243,8 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
@Override
public ProfileStore getProfile() {
if (convertedProfile == null)
createConvertedProfile();
return convertedProfile;
}
@ -254,6 +255,8 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
@Override
public String getProfileName() {
if (convertedProfile == null)
createConvertedProfile();
return DecimalFormatter.to2Decimal(convertedProfile.getDefaultProfile().percentageBasalSum()) + "U ";
}

View file

@ -13,9 +13,9 @@ import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.utils.SP;
/**
@ -146,7 +146,6 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
basal = SP.getDouble("SimpleProfile" + "basal", 1d);
targetLow = SP.getDouble("SimpleProfile" + "targetlow", 80d);
targetHigh = SP.getDouble("SimpleProfile" + "targethigh", 120d);
createConvertedProfile();
}
/*
@ -211,6 +210,8 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
@Override
public ProfileStore getProfile() {
if (convertedProfile == null)
createConvertedProfile();
return convertedProfile;
}

View file

@ -149,12 +149,13 @@ public class BGSourceFragment extends SubscriberFragment {
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profile.getUnits()));
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
final String _id = bgReading._id;
/* final String _id = bgReading._id;
if (NSUpload.isIdValid(_id)) {
NSUpload.removeFoodFromNS(_id);
} else {
UploadQueue.removeID("dbAdd", _id);
}
*/
bgReading.isValid = false;
MainApp.getDbHelper().update(bgReading);
updateGUI();

View file

@ -808,6 +808,9 @@
<string name="nsclienthaswritepermission">NSClient has write permission</string>
<string name="closedmodeenabled">Closed mode enabled</string>
<string name="maxiobset">Maximal IOB set properly</string>
<string name="hasbgdata">BG available from selected source</string>
<string name="basalprofilenotaligned">Basal values not aligned to hours</string>
<string name="zerovalueinprofile">Zero value in profile</string>
<string name="bolusstopping">Stopping bolus delivery</string>
<string name="bolusstopped">Bolus delivery stopped</string>
<string name="combo_programming_bolus">Programming pump for bolusing</string>

View file

@ -27,14 +27,7 @@ public class Cockpit extends BaseWatchFace {
@Override
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
if (mSgv != null) {
int extra = (mSgv.getRight() - mSgv.getLeft()) / 2;
if (tapType == TAP_TYPE_TAP &&
x + extra >= mSgv.getLeft() &&
x - extra <= mSgv.getRight() &&
y >= mSgv.getTop() &&
y <= mSgv.getBottom()) {
if (tapType == TAP_TYPE_TAP ) {
if (eventTime - sgvTapTime < 800) {
Intent intent = new Intent(this, MainMenuActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -43,7 +36,6 @@ public class Cockpit extends BaseWatchFace {
sgvTapTime = eventTime;
}
}
}
@Override
protected WatchFaceStyle getWatchFaceStyle() {